Subversion Repositories SvarDOS

Rev

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

Rev 1759 Rev 1760
Line 351... Line 351...
351
 
351
 
352
  /* if filename not overloaded then use the fname in db */
352
  /* if filename not overloaded then use the fname in db */
353
  if (saveas == NULL) saveas = db->fname;
353
  if (saveas == NULL) saveas = db->fname;
354
 
354
 
355
  _asm {
355
  _asm {
356
    push ax
-
 
357
    push cx
356
    push cx
358
    push dx
357
    push dx
359
 
358
 
360
    mov ah, 0x3C    /* create or truncate file */
359
    mov ah, 0x3C    /* create or truncate file */
361
    xor cx, cx      /* file attributes */
360
    xor cx, cx      /* file attributes */
Line 366... Line 365...
366
    DONE:
365
    DONE:
367
    mov fd, ax
366
    mov fd, ax
368
 
367
 
369
    pop dx
368
    pop dx
370
    pop cx
369
    pop cx
371
    pop ax
-
 
372
  }
370
  }
373
 
371
 
374
  if (errflag != 0) return(-1);
372
  if (errflag != 0) return(-1);
375
 
373
 
376
  l = db->cursor;
374
  l = db->cursor;
Line 671... Line 669...
671
    uidirty.to = 0xff;
669
    uidirty.to = 0xff;
672
  }
670
  }
673
}
671
}
674
 
672
 
675
 
673
 
676
static void cursor_left(struct file *db) {
-
 
677
  if (db->cursorposx > 0) {
-
 
678
    db->cursorposx -= 1;
-
 
679
  } else if (db->xoffset > 0) {
-
 
680
    db->xoffset -= 1;
-
 
681
    uidirty.from = 0;
-
 
682
    uidirty.to = 0xff;
-
 
683
  } else if (db->cursor->prev != NULL) { /* jump to end of line above */
-
 
684
    cursor_up(db);
-
 
685
    cursor_eol(db);
-
 
686
  }
-
 
687
}
-
 
688
 
-
 
689
 
-
 
690
static void cursor_home(struct file *db) {
674
static void cursor_home(struct file *db) {
691
  db->cursorposx = 0;
675
  db->cursorposx = 0;
692
  if (db->xoffset != 0) {
676
  if (db->xoffset != 0) {
693
    db->xoffset = 0;
677
    db->xoffset = 0;
694
    uidirty.from = 0;
678
    uidirty.from = 0;
Line 711... Line 695...
711
    cursor_home(db);
695
    cursor_home(db);
712
  }
696
  }
713
}
697
}
714
 
698
 
715
 
699
 
-
 
700
static void cursor_left(struct file *db) {
-
 
701
  if (db->cursorposx > 0) {
-
 
702
    db->cursorposx -= 1;
-
 
703
  } else if (db->xoffset > 0) {
-
 
704
    db->xoffset -= 1;
-
 
705
    uidirty.from = 0;
-
 
706
    uidirty.to = 0xff;
-
 
707
  } else if (db->cursor->prev != NULL) { /* jump to end of line above */
-
 
708
    cursor_up(db);
-
 
709
    cursor_eol(db);
-
 
710
  }
-
 
711
}
-
 
712
 
-
 
713
 
716
static void del(struct file *db) {
714
static void del(struct file *db) {
717
  if (db->cursorposx + db->xoffset < db->cursor->len) {
715
  if (db->cursorposx + db->xoffset < db->cursor->len) {
718
    fmemmove(db->cursor->payload + db->cursorposx + db->xoffset, db->cursor->payload + db->cursorposx + db->xoffset + 1, db->cursor->len - db->cursorposx - db->xoffset);
716
    fmemmove(db->cursor->payload + db->cursorposx + db->xoffset, db->cursor->payload + db->cursorposx + db->xoffset + 1, db->cursor->len - db->cursorposx - db->xoffset);
719
    db->cursor->len -= 1; /* do this AFTER memmove so the copy includes the nul terminator */
717
    db->cursor->len -= 1; /* do this AFTER memmove so the copy includes the nul terminator */
720
    uidirty.from = db->cursorposy;
718
    uidirty.from = db->cursorposy;
Line 932... Line 930...
932
 
930
 
933
      } else {  /* help screen */
931
      } else {  /* help screen */
934
        mdr_coutraw_str(svarlang_str(1,3)); /* Sved, the SvarDOS editor */
932
        mdr_coutraw_str(svarlang_str(1,3)); /* Sved, the SvarDOS editor */
935
        mdr_coutraw_str(" [");
933
        mdr_coutraw_str(" [");
936
        mdr_coutraw_str(svarlang_str(1,4)); /* ver */
934
        mdr_coutraw_str(svarlang_str(1,4)); /* ver */
937
        mdr_coutraw_puts(" " PVER "]");
935
        mdr_coutraw_str(" " PVER "]\r\n"
938
        mdr_coutraw_puts("Copyright (C) " PDATE " Mateusz Viste");
936
                         "Copyright (C) " PDATE " Mateusz Viste\n"
939
        mdr_coutraw_crlf();
937
                         "\r\n"
940
        mdr_coutraw_str("sved [/m] [/t] ");
938
                         "sved [/m] [/t] ");
941
        mdr_coutraw_puts(svarlang_str(1,1)); /* args syntax */
939
        mdr_coutraw_puts(svarlang_str(1,1)); /* args syntax */
942
        mdr_coutraw_crlf();
940
        mdr_coutraw_crlf();
943
        mdr_coutraw_puts(svarlang_str(1,10)); /* /m */
941
        mdr_coutraw_puts(svarlang_str(1,10)); /* /m */
944
        mdr_coutraw_puts(svarlang_str(1,11)); /* /t */
942
        mdr_coutraw_puts(svarlang_str(1,11)); /* /t */
945
        return(-1);
943
        return(-1);
Line 1080... Line 1078...
1080
    }
1078
    }
1081
  }
1079
  }
1082
}
1080
}
1083
 
1081
 
1084
 
1082
 
1085
static struct file *select_slot(struct file *dbarr, unsigned short curfile) {
1083
static void new_slot_selected(const struct file *dbarr) {
1086
  uidirty.from = 0;
1084
  uidirty.from = 0;
1087
  uidirty.to = 0xff;
1085
  uidirty.to = 0xff;
1088
  uidirty.statusbar = 1;
1086
  uidirty.statusbar = 1;
1089
 
1087
 
1090
  dbarr = &(dbarr[curfile]);
-
 
1091
 
-
 
1092
  /* force redraw now, because the main() routine might not if this is exit
1088
  /* force redraw now, because the main() routine might not if this is exit
1093
   * time and we want to show the user which file has unsaved changes */
1089
   * time and we want to show the user which file has unsaved changes */
1094
  ui_statusbar(dbarr);
1090
  ui_statusbar(dbarr);
1095
  ui_refresh(dbarr);
1091
  ui_refresh(dbarr);
1096
  return(dbarr);
-
 
1097
}
1092
}
1098
 
1093
 
1099
 
1094
 
1100
/* main returns nothing, ie. sved always exits with a zero exit code
1095
/* main returns nothing, ie. sved always exits with a zero exit code
1101
 * (this saves 20 bytes of executable footprint) */
1096
 * (this saves 20 bytes of executable footprint) */
Line 1326... Line 1321...
1326
          quitnow = 1;
1321
          quitnow = 1;
1327
          {
1322
          {
1328
            unsigned short curfile;
1323
            unsigned short curfile;
1329
            for (curfile = 0; curfile < 10; curfile++) {
1324
            for (curfile = 0; curfile < 10; curfile++) {
1330
              if (dbarr[curfile].modflag == 0) continue; /* skip unmodified slots */
1325
              if (dbarr[curfile].modflag == 0) continue; /* skip unmodified slots */
1331
              db = select_slot(dbarr, curfile);
1326
              db = dbarr + curfile;
-
 
1327
              new_slot_selected(db);
1332
              if (ui_confirm_if_unsaved(db) != 0) {
1328
              if (ui_confirm_if_unsaved(db) != 0) {
1333
                quitnow = 0;
1329
                quitnow = 0;
1334
                break;
1330
                break;
1335
              }
1331
              }
1336
            }
1332
            }
Line 1374... Line 1370...
1374
      } else {
1370
      } else {
1375
        insert_in_line(db, "\t", 1);
1371
        insert_in_line(db, "\t", 1);
1376
      }
1372
      }
1377
 
1373
 
1378
    } else if ((k >= 0x13b) && (k <= 0x144)) { /* F1..F10 */
1374
    } else if ((k >= 0x13b) && (k <= 0x144)) { /* F1..F10 */
1379
      db = select_slot(dbarr, k - 0x13b);
1375
      db = dbarr + (k - 0x13b);
-
 
1376
      new_slot_selected(db);
1380
 
1377
 
1381
    } else if (k == 0x174) { /* CTRL+ArrRight - jump to next word */
1378
    } else if (k == 0x174) { /* CTRL+ArrRight - jump to next word */
1382
      /* if currently cursor is on a non-space, then fast-forward to nearest space or EOL */
1379
      /* if currently cursor is on a non-space, then fast-forward to nearest space or EOL */
1383
      for (;;) {
1380
      for (;;) {
1384
        if (db->xoffset + db->cursorposx == db->cursor->len) break;
1381
        if (db->xoffset + db->cursorposx == db->cursor->len) break;