Subversion Repositories SvarDOS

Rev

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

Rev 1289 Rev 1292
Line 228... Line 228...
228
    *uidirtyto = 0xff;
228
    *uidirtyto = 0xff;
229
  }
229
  }
230
}
230
}
231
 
231
 
232
 
232
 
-
 
233
static void del(struct linedb *db, unsigned char cursorposx, unsigned char cursorposy, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
-
 
234
  if (cursorposx + db->xoffset < db->cursor->len) {
-
 
235
    _fmemmove(db->cursor->payload + cursorposx + db->xoffset, db->cursor->payload + cursorposx + db->xoffset + 1, db->cursor->len - cursorposx - db->xoffset);
-
 
236
    db->cursor->len -= 1; /* do this AFTER memmove so the copy includes the nul terminator */
-
 
237
    *uidirtyfrom = cursorposy;
-
 
238
    *uidirtyto = cursorposy;
-
 
239
  } else if (db->cursor->next != NULL) { /* cursor is at end of line: merge current line with next one (if there is a next one) */
-
 
240
    struct line far *nextline = db->cursor->next;
-
 
241
    if (db->cursor->next->len > 0) {
-
 
242
      void far *newptr = _frealloc(db->cursor, sizeof(struct line) + db->cursor->len + db->cursor->next->len + 1);
-
 
243
      if (newptr != NULL) {
-
 
244
        db->cursor = newptr;
-
 
245
        _fmemcpy(db->cursor->payload + db->cursor->len, db->cursor->next->payload, db->cursor->next->len + 1);
-
 
246
        db->cursor->len += db->cursor->next->len;
-
 
247
        /* update db->topscreen if needed */
-
 
248
        if (cursorposy == 0) db->topscreen = db->cursor;
-
 
249
      }
-
 
250
    }
-
 
251
    db->cursor->next = db->cursor->next->next;
-
 
252
    db->cursor->next->prev = db->cursor;
-
 
253
    if (db->cursor->prev != NULL) db->cursor->prev->next = db->cursor; /* in case realloc changed my pointer */
-
 
254
    _ffree(nextline);
-
 
255
    *uidirtyfrom = cursorposy;
-
 
256
    *uidirtyto = 0xff;
-
 
257
  }
-
 
258
}
-
 
259
 
-
 
260
 
233
/* a custom argv-parsing routine that looks directly inside the PSP, avoids the need
261
/* a custom argv-parsing routine that looks directly inside the PSP, avoids the need
234
 * of argc and argv, saves some 330 bytes of binary size */
262
 * of argc and argv, saves some 330 bytes of binary size */
235
static char *parseargv(void) {
263
static char *parseargv(void) {
236
  char *tail = (void *)0x81; /* THIS WORKS ONLY IN SMALL MEMORY MODEL */
264
  char *tail = (void *)0x81; /* THIS WORKS ONLY IN SMALL MEMORY MODEL */
237
  unsigned char count = 0;
265
  unsigned char count = 0;
Line 411... Line 439...
411
        uidirtyto = 0xff;
439
        uidirtyto = 0xff;
412
      } else {
440
      } else {
413
        /* ERROR: OUT OF MEMORY */
441
        /* ERROR: OUT OF MEMORY */
414
      }
442
      }
415
 
443
 
-
 
444
    } else if (k == 0x153) {  /* DEL */
-
 
445
      del(&db, cursorposx, cursorposy, &uidirtyfrom, &uidirtyto);
-
 
446
 
416
    } else { /* UNHANDLED KEY - TODO IGNORE THIS IN PRODUCTION RELEASE */
447
    } else { /* UNHANDLED KEY - TODO IGNORE THIS IN PRODUCTION RELEASE */
417
      char buff[4];
448
      char buff[4];
418
      const char *HEX = "0123456789ABCDEF";
449
      const char *HEX = "0123456789ABCDEF";
419
      buff[0] = HEX[(k >> 8) & 15];
450
      buff[0] = HEX[(k >> 8) & 15];
420
      buff[1] = HEX[(k >> 4) & 15];
451
      buff[1] = HEX[(k >> 4) & 15];