Subversion Repositories SvarDOS

Rev

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

Rev 1545 Rev 1547
Line 354... Line 354...
354
 
354
 
355
  mdr_cout_str(screenlastrow, helpcol, s, SCHEME_STBAR2, 40);
355
  mdr_cout_str(screenlastrow, helpcol, s, SCHEME_STBAR2, 40);
356
}
356
}
357
 
357
 
358
 
358
 
359
static void ui_msg(const char *msg1, const char *msg2, unsigned char attr) {
359
static void ui_msg(unsigned short msgid1, unsigned short msgid2, unsigned short msgid3, unsigned char attr) {
360
  unsigned short x, y, msglen, i;
360
  unsigned short x, y, maxmsglen, i;
361
  unsigned short msg2flag = 0;
361
  unsigned short msgcount = 1;
-
 
362
  const char *msg[3];
362
 
363
 
363
  msglen = strlen(msg1);
364
  msg[0] = svarlang_strid(msgid1);
-
 
365
 
364
  if (msg2) {
366
  if (msgid2 != 0) {
-
 
367
    msgcount = 2;
-
 
368
    msg[1] = svarlang_strid(msgid2);
-
 
369
  }
-
 
370
  if (msgid3 != 0) {
365
    msg2flag = 1;
371
    msgcount = 3;
-
 
372
    msg[2] = svarlang_strid(msgid3);
-
 
373
  }
-
 
374
 
-
 
375
  /* find longest msg */
-
 
376
  maxmsglen = 0;
-
 
377
  for (i = 0; i < msgcount; i++) {
366
    i = strlen(msg2);
378
    y = strlen(msg[i]);
367
    if (i > msglen) msglen = i;
379
    if (y > maxmsglen) maxmsglen = y;
368
  }
380
  }
369
 
381
 
370
  y = (screenh - 6) >> 1;
382
  y = (screenh - 6) >> 1;
371
  x = (screenw - msglen - 3) >> 1;
383
  x = (screenw - maxmsglen - 3) >> 1;
372
  for (i = y+2+msg2flag; i >= y; i--) mdr_cout_char_rep(i, x, ' ', attr, msglen + 2);
384
  for (i = y+1+msgcount; i >= y; i--) mdr_cout_char_rep(i, x, ' ', attr, maxmsglen + 2);
373
  x++;
385
  x++;
374
 
386
 
375
  mdr_cout_str(y+1, x, msg1, attr, msglen);
387
  for (i = 0; i < msgcount; i++) {
376
  if (msg2) mdr_cout_str(y+2, x, msg2, attr, msglen);
388
    mdr_cout_str(y+1+i, x, msg[i], attr, maxmsglen);
-
 
389
  }
377
 
390
 
378
  if (uidirty.from > y) uidirty.from = y;
391
  if (uidirty.from > y) uidirty.from = y;
379
  if (uidirty.to < y+4) uidirty.to = y+4;
392
  if (uidirty.to < y+4) uidirty.to = y+4;
380
}
393
}
381
 
394
 
Line 390... Line 403...
390
 
403
 
391
  /* if file has been modified then ask for confirmation:
404
  /* if file has been modified then ask for confirmation:
392
   * ENTER        : agree to data loss
405
   * ENTER        : agree to data loss
393
   * SPACE        : SAVE file before quit (only if valid filename present)
406
   * SPACE        : SAVE file before quit (only if valid filename present)
394
   * anything else: ABORT */
407
   * anything else: ABORT */
395
  ui_msg(svarlang_str(0,4), svarlang_str(0,5), SCHEME_MSG);
408
  ui_msg(4, 5, (db->fname[0])?9:8, SCHEME_MSG);
396
 
409
 
397
  k = mdr_dos_getkey2();
410
  k = mdr_dos_getkey2();
398
  mdr_cout_cursor_show();
411
  mdr_cout_cursor_show();
399
 
412
 
400
  /* ENTER = agree to loose unsaved data */
413
  /* ENTER = agree to loose unsaved data */
Line 1106... Line 1119...
1106
        case MENU_NONE:
1119
        case MENU_NONE:
1107
          break;
1120
          break;
1108
 
1121
 
1109
        case MENU_OPEN:
1122
        case MENU_OPEN:
1110
          /* display a warning if unsaved changes are pending */
1123
          /* display a warning if unsaved changes are pending */
1111
          if (db->modflag != 0) ui_msg(svarlang_str(0,4), svarlang_str(0,8), SCHEME_MSG);
1124
          if (db->modflag != 0) ui_msg(4, 8, 0, SCHEME_MSG);
1112
 
1125
 
1113
          /* ask for filename */
1126
          /* ask for filename */
1114
          ui_getstring(svarlang_str(0,7), fname, sizeof(fname));
1127
          ui_getstring(svarlang_str(0,7), fname, sizeof(fname));
1115
          if (fname[0] != 0) {
1128
          if (fname[0] != 0) {
1116
            unsigned char err;
1129
            unsigned char err;
1117
            err = loadfile(db, fname);
1130
            err = loadfile(db, fname);
1118
            if (err != 0) {
1131
            if (err != 0) {
1119
              if (err == LOADFILE_FILENOTFOUND) {
1132
              if (err == LOADFILE_FILENOTFOUND) {
1120
                ui_msg(svarlang_str(0,11), NULL, SCHEME_ERR); /* file not found */
1133
                ui_msg(11, 0, 0, SCHEME_ERR); /* file not found */
1121
              } else {
1134
              } else {
1122
                ui_msg(svarlang_str(0,10), NULL, SCHEME_ERR);  /* ERROR */
1135
                ui_msg(10, 0, 0, SCHEME_ERR);  /* ERROR */
1123
              }
1136
              }
1124
              mdr_bios_tickswait(44); /* 3s */
1137
              mdr_bios_tickswait(44); /* 3s */
1125
              loadfile(db, NULL);
1138
              loadfile(db, NULL);
1126
            }
1139
            }
1127
          }
1140
          }
Line 1143... Line 1156...
1143
          }
1156
          }
1144
 
1157
 
1145
          mdr_cout_cursor_hide();
1158
          mdr_cout_cursor_hide();
1146
 
1159
 
1147
          if (saveflag == 0) {
1160
          if (saveflag == 0) {
1148
            ui_msg(svarlang_str(0, 2), NULL, SCHEME_MSG);
1161
            ui_msg(2, 0, 0, SCHEME_MSG);
1149
            mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */
1162
            mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */
1150
          } else {
1163
          } else {
1151
            ui_msg(svarlang_str(0, 10), NULL, SCHEME_ERR);
1164
            ui_msg(10, 0, 0, SCHEME_ERR);
1152
            mdr_bios_tickswait(36); /* 2s */
1165
            mdr_bios_tickswait(36); /* 2s */
1153
          }
1166
          }
1154
          mdr_cout_cursor_show();
1167
          mdr_cout_cursor_show();
1155
          break;
1168
          break;
1156
 
1169
 
Line 1260... Line 1273...
1260
      if (clipboard != NULL) line_free(clipboard);
1273
      if (clipboard != NULL) line_free(clipboard);
1261
 
1274
 
1262
      /* copy cursor line to clipboard */
1275
      /* copy cursor line to clipboard */
1263
      clipboard = line_calloc(db->cursor->len);
1276
      clipboard = line_calloc(db->cursor->len);
1264
      if (clipboard == NULL) {
1277
      if (clipboard == NULL) {
1265
        ui_msg(svarlang_str(0, 10), NULL, SCHEME_ERR); /* ERROR */
1278
        ui_msg(10, 0, 0, SCHEME_ERR); /* ERROR */
1266
        mdr_bios_tickswait(18); /* 1s */
1279
        mdr_bios_tickswait(18); /* 1s */
1267
      } else {
1280
      } else {
1268
        mdr_cout_char_rep(db->cursorposy, 0, ' ', ((SCHEME_TEXT >> 4) | (SCHEME_TEXT << 4)) & 0xff, screenlastcol);
1281
        mdr_cout_char_rep(db->cursorposy, 0, ' ', ((SCHEME_TEXT >> 4) | (SCHEME_TEXT << 4)) & 0xff, screenlastcol);
1269
        uidirty.from = db->cursorposy;
1282
        uidirty.from = db->cursorposy;
1270
        uidirty.to = db->cursorposy;
1283
        uidirty.to = db->cursorposy;
Line 1292... Line 1305...
1292
        }
1305
        }
1293
      }
1306
      }
1294
 
1307
 
1295
    } else if ((k == 0x016) && (clipboard != NULL)) { /* CTRL+V */
1308
    } else if ((k == 0x016) && (clipboard != NULL)) { /* CTRL+V */
1296
      if (line_add(db, clipboard->payload, clipboard->len) != 0) {
1309
      if (line_add(db, clipboard->payload, clipboard->len) != 0) {
1297
        ui_msg(svarlang_str(0, 10), NULL, SCHEME_ERR); /* ERROR */
1310
        ui_msg(10, 0, 0, SCHEME_ERR); /* ERROR */
1298
        mdr_bios_tickswait(18); /* 1s */
1311
        mdr_bios_tickswait(18); /* 1s */
1299
      } else {
1312
      } else {
1300
        /* rewire the linked list so the new line is on top of the previous one */
1313
        /* rewire the linked list so the new line is on top of the previous one */
1301
        clipboard->prev = db->cursor->prev;
1314
        clipboard->prev = db->cursor->prev;
1302
        /* remove prev node from list */
1315
        /* remove prev node from list */