Subversion Repositories SvarDOS

Rev

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

Rev 1539 Rev 1541
Line 220... Line 220...
220
  while (db->cursor->prev) db->cursor = db->cursor->prev;
220
  while (db->cursor->prev) db->cursor = db->cursor->prev;
221
  db->curline = 0;
221
  db->curline = 0;
222
}
222
}
223
 
223
 
224
 
224
 
-
 
225
/* saves db file, resets db->modflag on success and overwrites the filename
-
 
226
 * field if saveas is not NULL */
225
static int savefile(const struct file *db, const char *saveas) {
227
static int savefile(struct file *db, const char *saveas) {
226
  int fd = 0;
228
  int fd = 0;
227
  const struct line far *l;
229
  const struct line far *l;
228
  unsigned int bytes;
230
  unsigned int bytes;
229
  unsigned char eollen = 2;
231
  unsigned char eollen = 2;
230
  const unsigned char *eolbuf = "\r\n";
232
  const unsigned char *eolbuf = "\r\n";
Line 274... Line 276...
274
    l = l->next;
276
    l = l->next;
275
  }
277
  }
276
 
278
 
277
  errflag |= _dos_close(fd);
279
  errflag |= _dos_close(fd);
278
 
280
 
-
 
281
  /* did it all work? */
-
 
282
  if (errflag == 0) {
-
 
283
    db->modflag = 0;
-
 
284
    if (saveas != db->fname) mdr_dos_truename(db->fname, saveas);
-
 
285
  }
-
 
286
 
279
  return(errflag);
287
  return(errflag);
280
}
288
}
281
 
289
 
282
 
290
 
283
static void ui_statusbar(const struct file *db, unsigned char slotnum) {
291
static void ui_statusbar(const struct file *db, unsigned char slotnum) {
Line 372... Line 380...
372
  if (uidirty.to < y+4) uidirty.to = y+4;
380
  if (uidirty.to < y+4) uidirty.to = y+4;
373
}
381
}
374
 
382
 
375
 
383
 
376
/* returns 0 if operation may proceed, non-zero to cancel */
384
/* returns 0 if operation may proceed, non-zero to cancel */
377
static unsigned char ui_confirm_if_unsaved(const struct file *db) {
385
static unsigned char ui_confirm_if_unsaved(struct file *db) {
378
  int k;
386
  int k;
379
 
387
 
380
  if (db->modflag == 0) return(0);
388
  if (db->modflag == 0) return(0);
381
 
389
 
382
  mdr_cout_cursor_hide();
390
  mdr_cout_cursor_hide();
Line 1136... Line 1144...
1136
        case MENU_SAVE:
1144
        case MENU_SAVE:
1137
          if ((saveflag != 0) || (db->fname[0] == 0)) { /* save as... */
1145
          if ((saveflag != 0) || (db->fname[0] == 0)) { /* save as... */
1138
            ui_getstring(svarlang_str(0,6), fname, sizeof(fname));
1146
            ui_getstring(svarlang_str(0,6), fname, sizeof(fname));
1139
            if (*fname == 0) break;
1147
            if (*fname == 0) break;
1140
            saveflag = savefile(db, fname);
1148
            saveflag = savefile(db, fname);
1141
            if (saveflag == 0) mdr_dos_truename(db->fname, fname);
-
 
1142
          } else {
1149
          } else {
1143
            saveflag = savefile(db, NULL);
1150
            saveflag = savefile(db, NULL);
1144
          }
1151
          }
1145
 
1152
 
1146
          mdr_cout_cursor_hide();
1153
          mdr_cout_cursor_hide();
1147
 
1154
 
1148
          if (saveflag == 0) {
1155
          if (saveflag == 0) {
1149
            db->modflag = 0;
-
 
1150
            ui_msg(svarlang_str(0, 2), NULL, SCHEME_MSG);
1156
            ui_msg(svarlang_str(0, 2), NULL, SCHEME_MSG);
1151
            mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */
1157
            mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */
1152
          } else {
1158
          } else {
1153
            ui_msg(svarlang_str(0, 10), NULL, SCHEME_ERR);
1159
            ui_msg(svarlang_str(0, 10), NULL, SCHEME_ERR);
1154
            mdr_bios_tickswait(36); /* 2s */
1160
            mdr_bios_tickswait(36); /* 2s */