Subversion Repositories SvarDOS

Rev

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

Rev 1307 Rev 1308
Line 243... Line 243...
243
    *uidirtyto = 0xff;
243
    *uidirtyto = 0xff;
244
  }
244
  }
245
}
245
}
246
 
246
 
247
 
247
 
-
 
248
static void cursor_right(struct linedb *db, unsigned char *cursorposx, unsigned char *cursorposy, unsigned char screenw, unsigned char screenh, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
-
 
249
  if (db->cursor->len > db->xoffset + *cursorposx) {
-
 
250
    if (*cursorposx < screenw - 2) {
-
 
251
      *cursorposx += 1;
-
 
252
    } else {
-
 
253
      db->xoffset += 1;
-
 
254
      *uidirtyfrom = 0;
-
 
255
      *uidirtyto = 0xff;
-
 
256
    }
-
 
257
  } else {
-
 
258
    cursor_down(db, cursorposy, screenh, uidirtyfrom, uidirtyto);
-
 
259
    cursor_home(db, cursorposx, uidirtyfrom, uidirtyto);
-
 
260
  }
-
 
261
}
-
 
262
 
-
 
263
 
248
static void del(struct linedb *db, unsigned char cursorposx, unsigned char cursorposy, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
264
static void del(struct linedb *db, unsigned char cursorposx, unsigned char cursorposy, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
249
  if (cursorposx + db->xoffset < db->cursor->len) {
265
  if (cursorposx + db->xoffset < db->cursor->len) {
250
    _fmemmove(db->cursor->payload + cursorposx + db->xoffset, db->cursor->payload + cursorposx + db->xoffset + 1, db->cursor->len - cursorposx - db->xoffset);
266
    _fmemmove(db->cursor->payload + cursorposx + db->xoffset, db->cursor->payload + cursorposx + db->xoffset + 1, db->cursor->len - cursorposx - db->xoffset);
251
    db->cursor->len -= 1; /* do this AFTER memmove so the copy includes the nul terminator */
267
    db->cursor->len -= 1; /* do this AFTER memmove so the copy includes the nul terminator */
252
    *uidirtyfrom = cursorposy;
268
    *uidirtyfrom = cursorposy;
Line 407... Line 423...
407
 
423
 
408
    } else if (k == 0x148) { /* up */
424
    } else if (k == 0x148) { /* up */
409
      cursor_up(&db, &cursorposy, &uidirtyfrom, &uidirtyto);
425
      cursor_up(&db, &cursorposy, &uidirtyfrom, &uidirtyto);
410
 
426
 
411
    } else if (k == 0x14D) { /* right */
427
    } else if (k == 0x14D) { /* right */
412
      if (db.cursor->len > db.xoffset + cursorposx) {
-
 
413
        if (cursorposx < screenw - 2) {
-
 
414
          cursorposx++;
-
 
415
        } else {
-
 
416
          db.xoffset++;
-
 
417
          uidirtyfrom = 0;
-
 
418
          uidirtyto = 0xff;
-
 
419
        }
-
 
420
      } else {
-
 
421
        cursor_down(&db, &cursorposy, screenh, &uidirtyfrom, &uidirtyto);
428
      cursor_right(&db, &cursorposx, &cursorposy, screenw, screenh, &uidirtyfrom, &uidirtyto);
422
        cursor_home(&db, &cursorposx, &uidirtyfrom, &uidirtyto);
-
 
423
      }
-
 
424
 
429
 
425
    } else if (k == 0x14B) { /* left */
430
    } else if (k == 0x14B) { /* left */
426
      cursor_left(&db, &cursorposx, &cursorposy, screenw, &uidirtyfrom, &uidirtyto);
431
      cursor_left(&db, &cursorposx, &cursorposy, screenw, &uidirtyfrom, &uidirtyto);
427
 
432
 
428
    } else if (k == 0x149) { /* pgup */
433
    } else if (k == 0x149) { /* pgup */
Line 464... Line 469...
464
      del(&db, cursorposx, cursorposy, &uidirtyfrom, &uidirtyto);
469
      del(&db, cursorposx, cursorposy, &uidirtyfrom, &uidirtyto);
465
 
470
 
466
    } else if (k == 0x008) { /* BKSPC */
471
    } else if (k == 0x008) { /* BKSPC */
467
      bkspc(&db, &cursorposx, &cursorposy, screenw, &uidirtyfrom, &uidirtyto);
472
      bkspc(&db, &cursorposx, &cursorposy, screenw, &uidirtyfrom, &uidirtyto);
468
 
473
 
-
 
474
    } else if ((k >= 0x20) && (k <= 0xff)) { /* "normal" character */
-
 
475
      struct line far *n;
-
 
476
      n = _frealloc(db.cursor, sizeof(struct line) + db.cursor->len);
-
 
477
      if (n != NULL) {
-
 
478
        unsigned short off = db.xoffset + cursorposx;
-
 
479
        if (n->prev) n->prev->next = n;
-
 
480
        if (n->next) n->next->prev = n;
-
 
481
        if (db.topscreen == db.cursor) db.topscreen = n;
-
 
482
        db.cursor = n;
-
 
483
        _fmemmove(db.cursor->payload + off + 1, db.cursor->payload + off, db.cursor->len - off + 1);
-
 
484
        db.cursor->len += 1;
-
 
485
        uidirtyfrom = cursorposy;
-
 
486
        uidirtyto = cursorposy;
-
 
487
        db.cursor->payload[off] = k;
-
 
488
        cursor_right(&db, &cursorposx, &cursorposy, screenw, screenh, &uidirtyfrom, &uidirtyto);
-
 
489
      }
-
 
490
 
469
    } else { /* UNHANDLED KEY - TODO IGNORE THIS IN PRODUCTION RELEASE */
491
    } else { /* UNHANDLED KEY - TODO IGNORE THIS IN PRODUCTION RELEASE */
470
      char buff[4];
492
      char buff[4];
471
      const char *HEX = "0123456789ABCDEF";
493
      const char *HEX = "0123456789ABCDEF";
472
      buff[0] = HEX[(k >> 8) & 15];
494
      buff[0] = HEX[(k >> 8) & 15];
473
      buff[1] = HEX[(k >> 4) & 15];
495
      buff[1] = HEX[(k >> 4) & 15];