Subversion Repositories SvarDOS

Rev

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

Rev 1342 Rev 1343
Line 708... Line 708...
708
  line_add(db, NULL, 0);
708
  line_add(db, NULL, 0);
709
  db_rewind(db);
709
  db_rewind(db);
710
}
710
}
711
 
711
 
712
 
712
 
-
 
713
/* recompute db->curline by counting nodes in linked list */
-
 
714
static void recompute_curline(struct file *db) {
-
 
715
  const struct line far *l = db->cursor;
-
 
716
 
-
 
717
  db->curline = 0;
-
 
718
  while (l->prev != NULL) {
-
 
719
    db->curline += 1;
-
 
720
    l = l->prev;
-
 
721
  }
-
 
722
}
-
 
723
 
-
 
724
 
713
int main(void) {
725
int main(void) {
714
  const char *fname;
726
  const char *fname;
715
  struct file *db;
727
  struct file *db;
716
 
728
 
717
  {
729
  {
Line 799... Line 811...
799
        dist = db->cursorposy;
811
        dist = db->cursorposy;
800
        while ((dist--) && (db->cursor->next)) db->cursor = db->cursor->next;
812
        while ((dist--) && (db->cursor->next)) db->cursor = db->cursor->next;
801
      }
813
      }
802
      uidirty.from = 0;
814
      uidirty.from = 0;
803
      uidirty.to = 0xff;
815
      uidirty.to = 0xff;
-
 
816
      recompute_curline(db);
804
 
817
 
805
    } else if (k == 0x151) { /* pgdown */
818
    } else if (k == 0x151) { /* pgdown */
806
      unsigned char dist = screenh + screenh - db->cursorposy - 3;
819
      unsigned char dist = screenh + screenh - db->cursorposy - 3;
807
      while ((dist != 0) && (db->cursor->next != NULL)) {
820
      while ((dist != 0) && (db->cursor->next != NULL)) {
808
        db->cursor = db->cursor->next;
821
        db->cursor = db->cursor->next;
Line 816... Line 829...
816
        dist = screenh - 2 - db->cursorposy;
829
        dist = screenh - 2 - db->cursorposy;
817
        while ((dist--) && (db->cursor->prev)) db->cursor = db->cursor->prev;
830
        while ((dist--) && (db->cursor->prev)) db->cursor = db->cursor->prev;
818
      }
831
      }
819
      uidirty.from = 0;
832
      uidirty.from = 0;
820
      uidirty.to = 0xff;
833
      uidirty.to = 0xff;
-
 
834
      recompute_curline(db);
821
 
835
 
822
    } else if (k == 0x147) { /* home */
836
    } else if (k == 0x147) { /* home */
823
       cursor_home(db);
837
       cursor_home(db);
824
 
838
 
825
    } else if (k == 0x14F) { /* end */
839
    } else if (k == 0x14F) { /* end */
Line 832... Line 846...
832
      unsigned short off = db->xoffset + db->cursorposx;
846
      unsigned short off = db->xoffset + db->cursorposx;
833
      /* add a new line */
847
      /* add a new line */
834
      if (line_add(db, db->cursor->payload + off, db->cursor->len - off) == 0) {
848
      if (line_add(db, db->cursor->payload + off, db->cursor->len - off) == 0) {
835
        db->modflag = 1;
849
        db->modflag = 1;
836
        db->cursor = db->cursor->prev; /* back to original line */
850
        db->cursor = db->cursor->prev; /* back to original line */
837
        db->curline -= 1;
-
 
838
        /* trim the line above */
851
        /* trim the line above */
839
        db->cursor->len = off;
852
        db->cursor->len = off;
840
        /* move cursor to the (new) line below */
853
        /* move cursor to the (new) line below */
-
 
854
        db->curline -= 1;
841
        uidirty.from = db->cursorposy;
855
        uidirty.from = db->cursorposy;
842
        uidirty.to = 0xff;
856
        uidirty.to = 0xff;
843
        cursor_down(db);
857
        cursor_down(db);
844
        cursor_home(db);
858
        cursor_home(db);
845
      } else {
859
      } else {