Subversion Repositories SvarDOS

Rev

Rev 1396 | Rev 1412 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1396 Rev 1410
Line 28... Line 28...
28
#include <string.h>
28
#include <string.h>
29
 
29
 
30
#include "mdr\bios.h"
30
#include "mdr\bios.h"
31
#include "mdr\cout.h"
31
#include "mdr\cout.h"
32
#include "mdr\dos.h"
32
#include "mdr\dos.h"
33
#include "mdr\keyb.h"
-
 
34
 
33
 
35
#include "svarlang\svarlang.h"
34
#include "svarlang\svarlang.h"
36
 
35
 
37
 
36
 
38
#define PVER "2023.0"
37
#define PVER "2023.0"
Line 166... Line 165...
166
  x = mdr_cout_str(y, 0, query, SCHEME_STBAR3, 40);
165
  x = mdr_cout_str(y, 0, query, SCHEME_STBAR3, 40);
167
  mdr_cout_char_rep(y, x++, ' ', SCHEME_STBAR3, screenw - x);
166
  mdr_cout_char_rep(y, x++, ' ', SCHEME_STBAR3, screenw - x);
168
 
167
 
169
  for (;;) {
168
  for (;;) {
170
    mdr_cout_locate(y, x + len);
169
    mdr_cout_locate(y, x + len);
171
    k = keyb_getkey();
170
    k = mdr_dos_getkey2();
172
 
171
 
173
    switch (k) {
172
    switch (k) {
174
      case 0x1b: /* ESC */
173
      case 0x1b: /* ESC */
175
        s[0] = 0;
174
        s[0] = 0;
176
        return;
175
        return;
Line 286... Line 285...
286
 
285
 
287
  mdr_cout_cursor_hide();
286
  mdr_cout_cursor_hide();
288
 
287
 
289
  /* if file has been modified then ask for confirmation */
288
  /* if file has been modified then ask for confirmation */
290
  ui_msg(svarlang_str(0,4), svarlang_str(0,5), SCHEME_MSG);
289
  ui_msg(svarlang_str(0,4), svarlang_str(0,5), SCHEME_MSG);
291
  if (keyb_getkey() != '\r') r = 1;
290
  if (mdr_dos_getkey2() != '\r') r = 1;
292
 
291
 
293
  mdr_cout_cursor_show();
292
  mdr_cout_cursor_show();
294
 
293
 
295
  return(r);
294
  return(r);
296
}
295
}
Line 844... Line 843...
844
      if (i == curchoice) {
843
      if (i == curchoice) {
845
        mdr_cout_char_rep(yorigin + i, xorigin + x + 2, ' ', SCHEME_MENU_SEL, slen - x + 1);
844
        mdr_cout_char_rep(yorigin + i, xorigin + x + 2, ' ', SCHEME_MENU_SEL, slen - x + 1);
846
      }
845
      }
847
    }
846
    }
848
    /* wait for key */
847
    /* wait for key */
849
    switch (keyb_getkey()) {
848
    switch (mdr_dos_getkey2()) {
850
      case 0x150: /* down */
849
      case 0x150: /* down */
851
        if (curchoice == MENU_QUIT) {
850
        if (curchoice == MENU_QUIT) {
852
          curchoice = MENU_OPEN;
851
          curchoice = MENU_OPEN;
853
        } else {
852
        } else {
854
          curchoice++;
853
          curchoice++;
Line 888... Line 887...
888
 * (this saves 20 bytes of executable footprint) */
887
 * (this saves 20 bytes of executable footprint) */
889
void main(void) {
888
void main(void) {
890
  static struct file dbarr[10];
889
  static struct file dbarr[10];
891
  unsigned short curfile;
890
  unsigned short curfile;
892
  struct file *db = dbarr; /* visible file is the first slot by default */
891
  struct file *db = dbarr; /* visible file is the first slot by default */
-
 
892
  struct line far *clipboard = NULL;
893
 
893
 
894
  {
894
  {
895
    unsigned short i = 0;
895
    unsigned short i = 0;
896
    const char far *selfptr;
896
    const char far *selfptr;
897
    char self[128], lang[8];
897
    char self[128], lang[8];
Line 925... Line 925...
925
    SCHEME_SCROLL = 0x70;
925
    SCHEME_SCROLL = 0x70;
926
    SCHEME_MSG = 0x6f;
926
    SCHEME_MSG = 0x6f;
927
    SCHEME_ERR = 0x4f;
927
    SCHEME_ERR = 0x4f;
928
  }
928
  }
929
 
929
 
-
 
930
  /* disable CTRL+C handling, user needs it for copy/paste operations */
-
 
931
  mdr_dos_ctrlc_disable();
-
 
932
 
930
  for (;;) {
933
  for (;;) {
931
    int k;
934
    int k;
932
 
935
 
933
    /* add an extra empty line if cursor is on last line and this line is not empty */
936
    /* add an extra empty line if cursor is on last line and this line is not empty */
934
    if ((db->cursor->next == NULL) && (db->cursor->len != 0)) {
937
    if ((db->cursor->next == NULL) && (db->cursor->len != 0)) {
Line 962... Line 965...
962
        ddd[7] = 0;
965
        ddd[7] = 0;
963
        mdr_cout_str(screenh - 1, 40, ddd, SCHEME_STBAR1, sizeof(ddd));
966
        mdr_cout_str(screenh - 1, 40, ddd, SCHEME_STBAR1, sizeof(ddd));
964
      }
967
      }
965
#endif
968
#endif
966
 
969
 
967
    k = keyb_getkey();
970
    k = mdr_dos_getkey2();
968
 
971
 
969
    if (k == 0x150) { /* down */
972
    if (k == 0x150) { /* down */
970
      cursor_down(db);
973
      cursor_down(db);
971
 
974
 
972
    } else if (k == 0x148) { /* up */
975
    } else if (k == 0x148) { /* up */
Line 1176... Line 1179...
1176
          break;
1179
          break;
1177
        }
1180
        }
1178
        if ((db->cursorposx == 0) && (db->xoffset == 0)) break;
1181
        if ((db->cursorposx == 0) && (db->xoffset == 0)) break;
1179
      }
1182
      }
1180
 
1183
 
-
 
1184
    } else if ((k == 0x003) || (k == 0x018)) { /* CTRL+C or CTRL+X */
-
 
1185
      /* free clipboard if anything in it */
-
 
1186
      if (clipboard != NULL) line_free(clipboard);
-
 
1187
 
-
 
1188
      /* copy cursor line to clipboard */
-
 
1189
      clipboard = line_calloc(db->cursor->len);
-
 
1190
      if (clipboard == NULL) {
-
 
1191
        ui_msg(svarlang_str(0, 10), NULL, SCHEME_ERR); /* ERROR */
-
 
1192
        mdr_bios_tickswait(18); /* 1s */
-
 
1193
      } else {
-
 
1194
        mdr_cout_char_rep(db->cursorposy, 0, ' ', ((SCHEME_TEXT >> 4) | (SCHEME_TEXT << 4)) & 0xff, screenw - 1);
-
 
1195
        uidirty.from = db->cursorposy;
-
 
1196
        uidirty.to = db->cursorposy;
-
 
1197
        if (db->cursor->len != 0) {
-
 
1198
          _fmemmove(clipboard->payload, db->cursor->payload, db->cursor->len);
-
 
1199
          clipboard->len = db->cursor->len;
-
 
1200
        }
-
 
1201
        mdr_bios_tickswait(2); /* ca 100ms */
-
 
1202
 
-
 
1203
        /* if this is about cutting the line (CTRL+X) then delete cur line */
-
 
1204
        if ((k == 0x018) && ((db->cursor->next != NULL) || (db->cursor->prev != NULL))) {
-
 
1205
          if (db->cursor->next) db->cursor->next->prev = db->cursor->prev;
-
 
1206
          if (db->cursor->prev) db->cursor->prev->next = db->cursor->next;
-
 
1207
          clipboard->prev = db->cursor;
-
 
1208
          if (db->cursor->next) {
-
 
1209
            db->cursor = db->cursor->next;
-
 
1210
          } else {
-
 
1211
            cursor_up(db);
-
 
1212
          }
-
 
1213
          line_free(clipboard->prev);
-
 
1214
          uidirty.from = 0;
-
 
1215
          uidirty.to = 0xff;
-
 
1216
        }
-
 
1217
      }
-
 
1218
 
-
 
1219
    } else if (k == 0x016) { /* CTRL+V */
-
 
1220
      if (clipboard != NULL) {
-
 
1221
        if (line_add(db, clipboard->payload, clipboard->len) != 0) {
-
 
1222
          ui_msg(svarlang_str(0, 10), NULL, SCHEME_ERR); /* ERROR */
-
 
1223
          mdr_bios_tickswait(18); /* 1s */
-
 
1224
        } else {
-
 
1225
          /* rewire the linked list so the new line is on top of the previous one */
-
 
1226
          clipboard->prev = db->cursor->prev;
-
 
1227
          /* remove prev node from list */
-
 
1228
          db->cursor->prev = db->cursor->prev->prev;
-
 
1229
          if (db->cursor->prev != NULL) db->cursor->prev->next = db->cursor;
-
 
1230
          /* insert the node after cursor now */
-
 
1231
          clipboard->prev->next = db->cursor->next;
-
 
1232
          if (db->cursor->next != NULL) db->cursor->next->prev = clipboard->prev;
-
 
1233
          clipboard->prev->prev = db->cursor;
-
 
1234
          db->cursor->next = clipboard->prev;
-
 
1235
          cursor_down(db);
-
 
1236
        }
-
 
1237
      }
-
 
1238
      uidirty.from = 0;
-
 
1239
      uidirty.to = 0xff;
-
 
1240
 
1181
#ifdef DBG_UNHKEYS
1241
#ifdef DBG_UNHKEYS
1182
    } else { /* UNHANDLED KEY - TODO IGNORE THIS IN PRODUCTION RELEASE */
1242
    } else { /* UNHANDLED KEY - TODO IGNORE THIS IN PRODUCTION RELEASE */
1183
      char buff[4];
1243
      char buff[4];
1184
      const char *HEX = "0123456789ABCDEF";
1244
      const char *HEX = "0123456789ABCDEF";
1185
      buff[0] = HEX[(k >> 8) & 15];
1245
      buff[0] = HEX[(k >> 8) & 15];
1186
      buff[1] = HEX[(k >> 4) & 15];
1246
      buff[1] = HEX[(k >> 4) & 15];
1187
      buff[2] = HEX[k & 15];
1247
      buff[2] = HEX[k & 15];
1188
      mdr_cout_str(screenh - 1, 0, "UNHANDLED KEY: 0x", SCHEME_STBAR1, 17);
1248
      mdr_cout_str(screenh - 1, 0, "UNHANDLED KEY: 0x", SCHEME_STBAR1, 17);
1189
      mdr_cout_str(screenh - 1, 17, buff, SCHEME_STBAR1, 3);
1249
      mdr_cout_str(screenh - 1, 17, buff, SCHEME_STBAR1, 3);
1190
      keyb_getkey();
1250
      mdr_dos_getkey2();
1191
      break;
1251
      break;
1192
#endif
1252
#endif
1193
    }
1253
    }
1194
  }
1254
  }
1195
 
1255