Subversion Repositories SvarDOS

Rev

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

Rev 1548 Rev 1549
Line 84... Line 84...
84
  unsigned short curline;
84
  unsigned short curline;
85
  unsigned short curline_prev;
85
  unsigned short curline_prev;
86
  char lfonly;   /* set if line endings are LF (CR/LF otherwise) */
86
  char lfonly;   /* set if line endings are LF (CR/LF otherwise) */
87
  char modflag;  /* non-zero if file has been modified since last save */
87
  char modflag;  /* non-zero if file has been modified since last save */
88
  char modflagprev;
88
  char modflagprev;
-
 
89
  char slotid; /* 0..9 */
89
  char fname[128];
90
  char fname[128];
90
};
91
};
91
 
92
 
92
 
93
 
93
/*****************************************************************************
94
/*****************************************************************************
Line 287... Line 288...
287
 
288
 
288
  return(errflag);
289
  return(errflag);
289
}
290
}
290
 
291
 
291
 
292
 
292
static void ui_statusbar(const struct file *db, unsigned char slotnum) {
293
static void ui_statusbar(const struct file *db) {
293
  const char *s = svarlang_strid(0); /* ESC=MENU */
294
  const char *s = svarlang_strid(0); /* ESC=MENU */
294
  unsigned short helpcol = screenw - strlen(s);
295
  unsigned short helpcol = screenw - strlen(s);
295
  unsigned short col;
296
  unsigned short col;
296
 
297
 
297
  /* slot number (guaranteed to be 0-9) */
298
  /* slot number (guaranteed to be 0-9) */
298
  {
299
  {
299
    char slot[4] = "#00";
300
    char slot[4] = "#00";
300
    if (slotnum == 9) {
301
    if (db->slotid == 9) {
301
      slot[1] = '1';
302
      slot[1] = '1';
302
    } else {
303
    } else {
303
      slotnum++;
-
 
304
      slot[2] += slotnum;
304
      slot[2] += db->slotid + 1;
305
    }
305
    }
306
    mdr_cout_str(screenlastrow, 0, slot, SCHEME_STBAR2, 3);
306
    mdr_cout_str(screenlastrow, 0, slot, SCHEME_STBAR2, 3);
307
  }
307
  }
308
 
308
 
309
  /* fill rest of status bar with background */
309
  /* fill rest of status bar with background */
Line 943... Line 943...
943
    }
943
    }
944
  }
944
  }
945
}
945
}
946
 
946
 
947
 
947
 
948
static struct file *select_slot(struct file *dbarr, unsigned char curfile) {
948
static struct file *select_slot(struct file *dbarr, unsigned short curfile) {
949
  uidirty.from = 0;
949
  uidirty.from = 0;
950
  uidirty.to = 0xff;
950
  uidirty.to = 0xff;
951
  uidirty.statusbar = 1;
951
  uidirty.statusbar = 1;
952
 
952
 
953
  dbarr = &(dbarr[curfile]);
953
  dbarr = &(dbarr[curfile]);
-
 
954
 
954
  /* force redraw now, because the main() routine might not if this is exit
955
  /* force redraw now, because the main() routine might not if this is exit
955
   * time and we want to show the user which file has unsaved changes */
956
   * time and we want to show the user which file has unsaved changes */
956
  ui_statusbar(dbarr, curfile);
957
  ui_statusbar(dbarr);
957
  ui_refresh(dbarr);
958
  ui_refresh(dbarr);
958
  return(dbarr);
959
  return(dbarr);
959
}
960
}
960
 
961
 
961
 
962
 
962
/* main returns nothing, ie. sved always exits with a zero exit code
963
/* main returns nothing, ie. sved always exits with a zero exit code
963
 * (this saves 20 bytes of executable footprint) */
964
 * (this saves 20 bytes of executable footprint) */
964
void main(void) {
965
void main(void) {
965
  static struct file dbarr[10];
966
  static struct file dbarr[10];
966
  unsigned short curfile;
-
 
967
  struct file *db = dbarr; /* visible file is the first slot by default */
967
  struct file *db = dbarr; /* visible file is the first slot by default */
968
  static struct line far *clipboard;
968
  static struct line far *clipboard;
969
  static unsigned char original_breakflag;
969
  static unsigned char original_breakflag;
970
 
970
 
971
  { /* load NLS resource */
971
  { /* load NLS resource */
Line 980... Line 980...
980
      svarlang_autoload_exepath(buff, mdr_dos_getenv(lang, "LANG", sizeof(lang)));
980
      svarlang_autoload_exepath(buff, mdr_dos_getenv(lang, "LANG", sizeof(lang)));
981
    }
981
    }
982
  }
982
  }
983
 
983
 
984
  /* preload all slots with empty files */
984
  /* preload all slots with empty files */
-
 
985
  {
-
 
986
    unsigned short i;
985
  for (curfile = 9;; curfile--) {
987
    for (i = 0; i < 10; i++) {
986
    loadfile(&(dbarr[curfile]), NULL);
988
      loadfile(&(dbarr[i]), NULL);
987
    if (curfile == 0) break;
989
      dbarr[i].slotid = i;
-
 
990
    }
988
  }
991
  }
989
 
992
 
990
  /* parse argv (and load files, if any passed on) */
993
  /* parse argv (and load files, if any passed on) */
991
  if (parseargv(dbarr) != 0) return;
994
  if (parseargv(dbarr) != 0) return;
992
 
995
 
Line 1026... Line 1029...
1026
    mdr_cout_locate(db->cursorposy, db->cursorposx);
1029
    mdr_cout_locate(db->cursorposy, db->cursorposx);
1027
 
1030
 
1028
    ui_refresh(db);
1031
    ui_refresh(db);
1029
 
1032
 
1030
    if ((uidirty.statusbar != 0) || (db->modflagprev != db->modflag) || (db->curline_prev != db->curline)) {
1033
    if ((uidirty.statusbar != 0) || (db->modflagprev != db->modflag) || (db->curline_prev != db->curline)) {
1031
      ui_statusbar(db, curfile);
1034
      ui_statusbar(db);
1032
      uidirty.statusbar = 0;
1035
      uidirty.statusbar = 0;
1033
      db->modflagprev = db->modflag;
1036
      db->modflagprev = db->modflag;
1034
      db->curline_prev = db->curline;
1037
      db->curline_prev = db->curline;
1035
    }
1038
    }
1036
#ifdef DBG_LINENUM
1039
#ifdef DBG_LINENUM
Line 1182... Line 1185...
1182
          db->lfonly ^= 1;
1185
          db->lfonly ^= 1;
1183
          break;
1186
          break;
1184
 
1187
 
1185
        case MENU_QUIT:
1188
        case MENU_QUIT:
1186
          quitnow = 1;
1189
          quitnow = 1;
-
 
1190
          {
-
 
1191
            unsigned short curfile;
1187
          for (curfile = 0; curfile < 10; curfile++) {
1192
            for (curfile = 0; curfile < 10; curfile++) {
1188
            if (dbarr[curfile].modflag) {
1193
              if (dbarr[curfile].modflag == 0) continue; /* skip unmodified slots */
1189
              db = select_slot(dbarr, curfile);
1194
              db = select_slot(dbarr, curfile);
1190
              if (ui_confirm_if_unsaved(db) != 0) {
1195
              if (ui_confirm_if_unsaved(db) != 0) {
1191
                quitnow = 0;
1196
                quitnow = 0;
1192
                break;
1197
                break;
1193
              }
1198
              }
Line 1232... Line 1237...
1232
      } else {
1237
      } else {
1233
        insert_in_line(db, "\t", 1);
1238
        insert_in_line(db, "\t", 1);
1234
      }
1239
      }
1235
 
1240
 
1236
    } else if ((k >= 0x13b) && (k <= 0x144)) { /* F1..F10 */
1241
    } else if ((k >= 0x13b) && (k <= 0x144)) { /* F1..F10 */
1237
      curfile = k - 0x13b;
-
 
1238
      db = select_slot(dbarr, curfile);
1242
      db = select_slot(dbarr, k - 0x13b);
1239
 
1243
 
1240
    } else if (k == 0x174) { /* CTRL+ArrRight - jump to next word */
1244
    } else if (k == 0x174) { /* CTRL+ArrRight - jump to next word */
1241
      /* if currently cursor is on a non-space, then fast-forward to nearest space or EOL */
1245
      /* if currently cursor is on a non-space, then fast-forward to nearest space or EOL */
1242
      for (;;) {
1246
      for (;;) {
1243
        if (db->xoffset + db->cursorposx == db->cursor->len) break;
1247
        if (db->xoffset + db->cursorposx == db->cursor->len) break;