Subversion Repositories SvarDOS

Rev

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

Rev 1325 Rev 1326
Line 34... Line 34...
34
#include "mdr\dos.h"
34
#include "mdr\dos.h"
35
#include "mdr\keyb.h"
35
#include "mdr\keyb.h"
36
 
36
 
37
#include "svarlang\svarlang.h"
37
#include "svarlang\svarlang.h"
38
 
38
 
-
 
39
 
-
 
40
/*****************************************************************************
-
 
41
 * global variables and definitions                                          *
-
 
42
 *****************************************************************************/
39
#define COL_TXT        0
43
#define COL_TXT        0
40
#define COL_STATUSBAR1 1
44
#define COL_STATUSBAR1 1
41
#define COL_STATUSBAR2 2
45
#define COL_STATUSBAR2 2
42
#define COL_SCROLLBAR  3
46
#define COL_SCROLLBAR  3
43
#define COL_MSG        4
47
#define COL_MSG        4
44
#define COL_ERR        5
48
#define COL_ERR        5
-
 
49
 
45
/* preload the mono scheme (to be overloaded at runtime if color adapter present) */
50
/* preload the mono scheme (to be overloaded at runtime if color adapter present) */
46
static unsigned char scheme[] = {0x07, 0x70, 0x70, 0x70, 0x70, 0xf0};
51
static unsigned char scheme[] = {0x07, 0x70, 0x70, 0x70, 0x70, 0xf0};
-
 
52
static unsigned char screenw, screenh;
47
 
53
 
48
#define SCROLL_CURSOR 0xB1
54
#define SCROLL_CURSOR 0xB1
49
 
55
 
50
 
-
 
51
struct line {
56
struct line {
52
  struct line far *prev;
57
  struct line far *prev;
53
  struct line far *next;
58
  struct line far *next;
54
  unsigned short len;
59
  unsigned short len;
55
  char payload[1];
60
  char payload[1];
Line 64... Line 69...
64
  char lfonly; /* set if line endings are LF (CR/LF otherwise) */
69
  char lfonly; /* set if line endings are LF (CR/LF otherwise) */
65
  char fname[1]; /* dynamically sized */
70
  char fname[1]; /* dynamically sized */
66
};
71
};
67
 
72
 
68
 
73
 
-
 
74
/*****************************************************************************
-
 
75
 * functions                                                                 *
-
 
76
 *****************************************************************************/
-
 
77
 
69
/* adds a new line at cursor position into file linked list and dvance cursor
78
/* adds a new line at cursor position into file linked list and dvance cursor
70
 * returns non-zero on error */
79
 * returns non-zero on error */
71
static int line_add(struct file *db, const char far *line) {
80
static int line_add(struct file *db, const char far *line) {
72
  unsigned short slen;
81
  unsigned short slen;
73
  struct line far *l;
82
  struct line far *l;
Line 131... Line 140...
131
  scheme[COL_MSG] = 0xf0;
140
  scheme[COL_MSG] = 0xf0;
132
  scheme[COL_ERR] = 0x4f;
141
  scheme[COL_ERR] = 0x4f;
133
}
142
}
134
 
143
 
135
 
144
 
136
static void ui_basic(unsigned char screenw, unsigned char screenh, const struct file *db) {
145
static void ui_basic(const struct file *db) {
137
  unsigned char i;
146
  unsigned char i;
138
  const char *s = svarlang_strid(0); /* HELP */
147
  const char *s = svarlang_strid(0); /* HELP */
139
  unsigned char helpcol = screenw - (strlen(s) + 4);
148
  unsigned char helpcol = screenw - (strlen(s) + 4);
140
 
149
 
141
  /* fill status bar with background */
150
  /* fill status bar with background */
Line 163... Line 172...
163
    mdr_cout_char(i, screenw - 1, SCROLL_CURSOR, scheme[COL_SCROLLBAR]);
172
    mdr_cout_char(i, screenw - 1, SCROLL_CURSOR, scheme[COL_SCROLLBAR]);
164
  }
173
  }
165
}
174
}
166
 
175
 
167
 
176
 
168
static void ui_msg(const char *msg, unsigned char screenw, unsigned char screenh, unsigned char *uidirtyfrom, unsigned char *uidirtyto, unsigned char attr) {
177
static void ui_msg(const char *msg, unsigned char *uidirtyfrom, unsigned char *uidirtyto, unsigned char attr) {
169
  unsigned short x, y, msglen, i;
178
  unsigned short x, y, msglen, i;
170
  msglen = strlen(msg);
179
  msglen = strlen(msg);
171
  y = (screenh - 4) >> 1;
180
  y = (screenh - 4) >> 1;
172
  x = (screenw - msglen - 4) >> 1;
181
  x = (screenw - msglen - 4) >> 1;
173
  for (i = y+2; i >= y; i--) mdr_cout_char_rep(i, x, ' ', attr, msglen + 2);
182
  for (i = y+2; i >= y; i--) mdr_cout_char_rep(i, x, ' ', attr, msglen + 2);
Line 176... Line 185...
176
  if (*uidirtyfrom > y) *uidirtyfrom = y;
185
  if (*uidirtyfrom > y) *uidirtyfrom = y;
177
  if (*uidirtyto < y+2) *uidirtyto = y+2;
186
  if (*uidirtyto < y+2) *uidirtyto = y+2;
178
}
187
}
179
 
188
 
180
 
189
 
181
static void ui_help(unsigned char screenw) {
190
static void ui_help(void) {
182
#define MAXLINLEN 35
191
#define MAXLINLEN 35
183
  unsigned short i, offset;
192
  unsigned short i, offset;
184
  offset = (screenw - MAXLINLEN + 2) >> 1;
193
  offset = (screenw - MAXLINLEN + 2) >> 1;
185
  mdr_cout_cursor_hide();
194
  mdr_cout_cursor_hide();
186
  for (i = 2; i <= 15; i++) {
195
  for (i = 2; i <= 15; i++) {
Line 200... Line 209...
200
  mdr_cout_cursor_show();
209
  mdr_cout_cursor_show();
201
#undef MAXLINLEN
210
#undef MAXLINLEN
202
}
211
}
203
 
212
 
204
 
213
 
205
static void ui_refresh(const struct file *db, unsigned char screenw, unsigned char screenh, unsigned char uidirtyfrom, unsigned char uidirtyto) {
214
static void ui_refresh(const struct file *db, unsigned char uidirtyfrom, unsigned char uidirtyto) {
206
  unsigned char x;
215
  unsigned char x;
207
  const struct line far *l;
216
  const struct line far *l;
208
  unsigned char y = db->cursorposy;
217
  unsigned char y = db->cursorposy;
209
 
218
 
210
#ifdef DBG_REFRESH
219
#ifdef DBG_REFRESH
Line 278... Line 287...
278
    }
287
    }
279
  }
288
  }
280
}
289
}
281
 
290
 
282
 
291
 
283
static void cursor_eol(struct file *db, unsigned char screenw, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
292
static void cursor_eol(struct file *db, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
284
  /* adjust xoffset to make sure eol is visible on screen */
293
  /* adjust xoffset to make sure eol is visible on screen */
285
  if (db->xoffset > db->cursor->len) {
294
  if (db->xoffset > db->cursor->len) {
286
    db->xoffset = db->cursor->len - 1;
295
    db->xoffset = db->cursor->len - 1;
287
    *uidirtyfrom = 0;
296
    *uidirtyfrom = 0;
288
    *uidirtyto = 0xff;
297
    *uidirtyto = 0xff;
Line 295... Line 304...
295
  }
304
  }
296
  db->cursorposx = db->cursor->len - db->xoffset;
305
  db->cursorposx = db->cursor->len - db->xoffset;
297
}
306
}
298
 
307
 
299
 
308
 
300
static void cursor_down(struct file *db, unsigned char screenh, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
309
static void cursor_down(struct file *db, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
301
  if (db->cursor->next != NULL) {
310
  if (db->cursor->next != NULL) {
302
    db->cursor = db->cursor->next;
311
    db->cursor = db->cursor->next;
303
    if (db->cursorposy < screenh - 2) {
312
    if (db->cursorposy < screenh - 2) {
304
      db->cursorposy += 1;
313
      db->cursorposy += 1;
305
    } else {
314
    } else {
Line 308... Line 317...
308
    }
317
    }
309
  }
318
  }
310
}
319
}
311
 
320
 
312
 
321
 
313
static void cursor_left(struct file *db, unsigned char screenw, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
322
static void cursor_left(struct file *db, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
314
  if (db->cursorposx > 0) {
323
  if (db->cursorposx > 0) {
315
    db->cursorposx -= 1;
324
    db->cursorposx -= 1;
316
  } else if (db->xoffset > 0) {
325
  } else if (db->xoffset > 0) {
317
    db->xoffset -= 1;
326
    db->xoffset -= 1;
318
    *uidirtyfrom = 0;
327
    *uidirtyfrom = 0;
319
    *uidirtyto = 0xff;
328
    *uidirtyto = 0xff;
320
  } else if (db->cursor->prev != NULL) { /* jump to end of line above */
329
  } else if (db->cursor->prev != NULL) { /* jump to end of line above */
321
    cursor_up(db, uidirtyfrom, uidirtyto);
330
    cursor_up(db, uidirtyfrom, uidirtyto);
322
    cursor_eol(db, screenw, uidirtyfrom, uidirtyto);
331
    cursor_eol(db, uidirtyfrom, uidirtyto);
323
  }
332
  }
324
}
333
}
325
 
334
 
326
 
335
 
327
static void cursor_home(struct file *db, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
336
static void cursor_home(struct file *db, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
Line 332... Line 341...
332
    *uidirtyto = 0xff;
341
    *uidirtyto = 0xff;
333
  }
342
  }
334
}
343
}
335
 
344
 
336
 
345
 
337
static void cursor_right(struct file *db, unsigned char screenw, unsigned char screenh, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
346
static void cursor_right(struct file *db, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
338
  if (db->cursor->len > db->xoffset + db->cursorposx) {
347
  if (db->cursor->len > db->xoffset + db->cursorposx) {
339
    if (db->cursorposx < screenw - 2) {
348
    if (db->cursorposx < screenw - 2) {
340
      db->cursorposx += 1;
349
      db->cursorposx += 1;
341
    } else {
350
    } else {
342
      db->xoffset += 1;
351
      db->xoffset += 1;
343
      *uidirtyfrom = 0;
352
      *uidirtyfrom = 0;
344
      *uidirtyto = 0xff;
353
      *uidirtyto = 0xff;
345
    }
354
    }
346
  } else {
355
  } else {
347
    cursor_down(db, screenh, uidirtyfrom, uidirtyto);
356
    cursor_down(db, uidirtyfrom, uidirtyto);
348
    cursor_home(db, uidirtyfrom, uidirtyto);
357
    cursor_home(db, uidirtyfrom, uidirtyto);
349
  }
358
  }
350
}
359
}
351
 
360
 
352
 
361
 
Line 374... Line 383...
374
    *uidirtyto = 0xff;
383
    *uidirtyto = 0xff;
375
  }
384
  }
376
}
385
}
377
 
386
 
378
 
387
 
379
static void bkspc(struct file *db, unsigned char screenw, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
388
static void bkspc(struct file *db, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
380
 
389
 
381
  /* backspace is basically "left + del", not applicable only if cursor is on 1st byte of the file */
390
  /* backspace is basically "left + del", not applicable only if cursor is on 1st byte of the file */
382
  if ((db->cursorposx == 0) && (db->xoffset == 0) && (db->cursor->prev == NULL)) return;
391
  if ((db->cursorposx == 0) && (db->xoffset == 0) && (db->cursor->prev == NULL)) return;
383
 
392
 
384
  cursor_left(db, screenw, uidirtyfrom, uidirtyto);
393
  cursor_left(db, uidirtyfrom, uidirtyto);
385
  del(db, uidirtyfrom, uidirtyto);
394
  del(db, uidirtyfrom, uidirtyto);
386
}
395
}
387
 
396
 
388
 
397
 
389
/* a custom argv-parsing routine that looks directly inside the PSP, avoids the need
398
/* a custom argv-parsing routine that looks directly inside the PSP, avoids the need
Line 559... Line 568...
559
  _dos_close(fd);
568
  _dos_close(fd);
560
  return(0);
569
  return(0);
561
}
570
}
562
 
571
 
563
 
572
 
564
static void insert_in_line(struct file *db, const char *databuf, unsigned short len, unsigned char screenw, unsigned char screenh, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
573
static void insert_in_line(struct file *db, const char *databuf, unsigned short len, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
565
  struct line far *n;
574
  struct line far *n;
566
  n = _frealloc(db->cursor, sizeof(struct line) + db->cursor->len + len);
575
  n = _frealloc(db->cursor, sizeof(struct line) + db->cursor->len + len);
567
  if (n != NULL) {
576
  if (n != NULL) {
568
    unsigned short off = db->xoffset + db->cursorposx;
577
    unsigned short off = db->xoffset + db->cursorposx;
569
    if (n->prev) n->prev->next = n;
578
    if (n->prev) n->prev->next = n;
Line 574... Line 583...
574
    *uidirtyfrom = db->cursorposy;
583
    *uidirtyfrom = db->cursorposy;
575
    *uidirtyto = db->cursorposy;
584
    *uidirtyto = db->cursorposy;
576
    while (len--) {
585
    while (len--) {
577
      db->cursor->payload[off++] = *databuf;
586
      db->cursor->payload[off++] = *databuf;
578
      databuf++;
587
      databuf++;
579
      cursor_right(db, screenw, screenh, uidirtyfrom, uidirtyto);
588
      cursor_right(db, uidirtyfrom, uidirtyto);
580
    }
589
    }
581
  }
590
  }
582
}
591
}
583
 
592
 
584
 
593
 
585
int main(void) {
594
int main(void) {
586
  const char *fname;
595
  const char *fname;
587
  struct file *db;
596
  struct file *db;
588
  unsigned char screenw = 0, screenh = 0;
-
 
589
  unsigned char uidirtyfrom = 0, uidirtyto = 0xff; /* make sure to redraw entire UI at first run */
597
  unsigned char uidirtyfrom = 0, uidirtyto = 0xff; /* make sure to redraw entire UI at first run */
590
 
598
 
591
  {
599
  {
592
    char nlspath[128], lang[8];
600
    char nlspath[128], lang[8];
593
    svarlang_autoload_pathlist("sved", mdr_dos_getenv(nlspath, "NLSPATH", sizeof(nlspath)), mdr_dos_getenv(lang, "LANG", sizeof(lang)));
601
    svarlang_autoload_pathlist("sved", mdr_dos_getenv(nlspath, "NLSPATH", sizeof(nlspath)), mdr_dos_getenv(lang, "LANG", sizeof(lang)));
Line 603... Line 611...
603
  /* load file */
611
  /* load file */
604
  db = loadfile(fname);
612
  db = loadfile(fname);
605
  if (db == NULL) return(1);
613
  if (db == NULL) return(1);
606
 
614
 
607
  if (mdr_cout_init(&screenw, &screenh)) load_colorscheme();
615
  if (mdr_cout_init(&screenw, &screenh)) load_colorscheme();
608
  ui_basic(screenw, screenh, db);
616
  ui_basic(db);
609
 
617
 
610
  for (;;) {
618
  for (;;) {
611
    int k;
619
    int k;
612
 
620
 
613
    check_cursor_not_after_eol(db, &uidirtyfrom, &uidirtyto);
621
    check_cursor_not_after_eol(db, &uidirtyfrom, &uidirtyto);
614
    mdr_cout_locate(db->cursorposy, db->cursorposx);
622
    mdr_cout_locate(db->cursorposy, db->cursorposx);
615
 
623
 
616
    if (uidirtyfrom != 0xff) {
624
    if (uidirtyfrom != 0xff) {
617
      ui_refresh(db, screenw, screenh, uidirtyfrom, uidirtyto);
625
      ui_refresh(db, uidirtyfrom, uidirtyto);
618
      uidirtyfrom = 0xff;
626
      uidirtyfrom = 0xff;
619
    }
627
    }
620
 
628
 
621
    k = keyb_getkey();
629
    k = keyb_getkey();
622
 
630
 
623
    if (k == 0x150) { /* down */
631
    if (k == 0x150) { /* down */
624
      cursor_down(db, screenh, &uidirtyfrom, &uidirtyto);
632
      cursor_down(db, &uidirtyfrom, &uidirtyto);
625
 
633
 
626
    } else if (k == 0x148) { /* up */
634
    } else if (k == 0x148) { /* up */
627
      cursor_up(db, &uidirtyfrom, &uidirtyto);
635
      cursor_up(db, &uidirtyfrom, &uidirtyto);
628
 
636
 
629
    } else if (k == 0x14D) { /* right */
637
    } else if (k == 0x14D) { /* right */
630
      cursor_right(db, screenw, screenh, &uidirtyfrom, &uidirtyto);
638
      cursor_right(db, &uidirtyfrom, &uidirtyto);
631
 
639
 
632
    } else if (k == 0x14B) { /* left */
640
    } else if (k == 0x14B) { /* left */
633
      cursor_left(db, screenw, &uidirtyfrom, &uidirtyto);
641
      cursor_left(db, &uidirtyfrom, &uidirtyto);
634
 
642
 
635
    } else if (k == 0x149) { /* pgup */
643
    } else if (k == 0x149) { /* pgup */
636
      // TODO
644
      // TODO
637
 
645
 
638
    } else if (k == 0x151) { /* pgdown */
646
    } else if (k == 0x151) { /* pgdown */
Line 640... Line 648...
640
 
648
 
641
    } else if (k == 0x147) { /* home */
649
    } else if (k == 0x147) { /* home */
642
       cursor_home(db, &uidirtyfrom, &uidirtyto);
650
       cursor_home(db, &uidirtyfrom, &uidirtyto);
643
 
651
 
644
    } else if (k == 0x14F) { /* end */
652
    } else if (k == 0x14F) { /* end */
645
       cursor_eol(db, screenw, &uidirtyfrom, &uidirtyto);
653
       cursor_eol(db, &uidirtyfrom, &uidirtyto);
646
 
654
 
647
    } else if (k == 0x1B) { /* ESC */
655
    } else if (k == 0x1B) { /* ESC */
648
      break;
656
      break;
649
 
657
 
650
    } else if (k == 0x0D) { /* ENTER */
658
    } else if (k == 0x0D) { /* ENTER */
Line 668... Line 676...
668
 
676
 
669
    } else if (k == 0x153) {  /* DEL */
677
    } else if (k == 0x153) {  /* DEL */
670
      del(db, &uidirtyfrom, &uidirtyto);
678
      del(db, &uidirtyfrom, &uidirtyto);
671
 
679
 
672
    } else if (k == 0x008) { /* BKSPC */
680
    } else if (k == 0x008) { /* BKSPC */
673
      bkspc(db, screenw, &uidirtyfrom, &uidirtyto);
681
      bkspc(db, &uidirtyfrom, &uidirtyto);
674
 
682
 
675
    } else if ((k >= 0x20) && (k <= 0xff)) { /* "normal" character */
683
    } else if ((k >= 0x20) && (k <= 0xff)) { /* "normal" character */
676
      char c = k;
684
      char c = k;
677
      insert_in_line(db, &c, 1, screenw, screenh, &uidirtyfrom, &uidirtyto);
685
      insert_in_line(db, &c, 1, &uidirtyfrom, &uidirtyto);
678
 
686
 
679
    } else if (k == 0x009) { /* TAB */
687
    } else if (k == 0x009) { /* TAB */
680
      const char *tab = "        ";
688
      const char *tab = "        ";
681
      insert_in_line(db, tab, 8, screenw, screenh, &uidirtyfrom, &uidirtyto);
689
      insert_in_line(db, tab, 8, &uidirtyfrom, &uidirtyto);
682
 
690
 
683
    } else if (k == 0x13b) { /* F1 */
691
    } else if (k == 0x13b) { /* F1 */
684
      ui_help(screenw);
692
      ui_help();
685
      uidirtyfrom = 0;
693
      uidirtyfrom = 0;
686
      uidirtyto = 0xff;
694
      uidirtyto = 0xff;
687
 
695
 
688
    } else if (k == 0x13f) { /* F5 */
696
    } else if (k == 0x13f) { /* F5 */
689
      if (savefile(db) == 0) {
697
      if (savefile(db) == 0) {
690
        ui_msg(svarlang_str(0, 2), screenw, screenh, &uidirtyfrom, &uidirtyto, scheme[COL_MSG]);
698
        ui_msg(svarlang_str(0, 2), &uidirtyfrom, &uidirtyto, scheme[COL_MSG]);
691
        mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */
699
        mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */
692
      } else {
700
      } else {
693
        ui_msg(svarlang_str(0, 3), screenw, screenh, &uidirtyfrom, &uidirtyto, scheme[COL_ERR]);
701
        ui_msg(svarlang_str(0, 3), &uidirtyfrom, &uidirtyto, scheme[COL_ERR]);
694
        mdr_bios_tickswait(36); /* 2s */
702
        mdr_bios_tickswait(36); /* 2s */
695
      }
703
      }
696
 
704
 
697
    } else if (k == 0x144) { /* F10 */
705
    } else if (k == 0x144) { /* F10 */
698
      db->lfonly ^= 1;
706
      db->lfonly ^= 1;
699
      ui_basic(screenw, screenh, db);
707
      ui_basic(db);
700
 
708
 
701
    } else if (k == 0x174) { /* CTRL+ArrRight - jump to next word */
709
    } else if (k == 0x174) { /* CTRL+ArrRight - jump to next word */
702
      /* if currently cursor is on a non-space, then fast-forward to nearest space or EOL */
710
      /* if currently cursor is on a non-space, then fast-forward to nearest space or EOL */
703
      for (;;) {
711
      for (;;) {
704
        if (db->xoffset + db->cursorposx == db->cursor->len) break;
712
        if (db->xoffset + db->cursorposx == db->cursor->len) break;
705
        if (db->cursor->payload[db->xoffset + db->cursorposx] == ' ') break;
713
        if (db->cursor->payload[db->xoffset + db->cursorposx] == ' ') break;
706
        cursor_right(db, screenw, screenh, &uidirtyfrom, &uidirtyto);
714
        cursor_right(db, &uidirtyfrom, &uidirtyto);
707
      }
715
      }
708
      /* now skip to next non-space or end of file */
716
      /* now skip to next non-space or end of file */
709
      for (;;) {
717
      for (;;) {
710
        cursor_right(db, screenw, screenh, &uidirtyfrom, &uidirtyto);
718
        cursor_right(db, &uidirtyfrom, &uidirtyto);
711
        if (db->cursor->payload[db->xoffset + db->cursorposx] != ' ') break;
719
        if (db->cursor->payload[db->xoffset + db->cursorposx] != ' ') break;
712
        if ((db->cursor->next == NULL) && (db->cursorposx + db->xoffset == db->cursor->len)) break;
720
        if ((db->cursor->next == NULL) && (db->cursorposx + db->xoffset == db->cursor->len)) break;
713
      }
721
      }
714
 
722
 
715
    } else if (k == 0x173) { /* CTRL+ArrLeft - jump to prev word */
723
    } else if (k == 0x173) { /* CTRL+ArrLeft - jump to prev word */
716
      cursor_left(db, screenw, &uidirtyfrom, &uidirtyto);
724
      cursor_left(db, &uidirtyfrom, &uidirtyto);
717
      /* if currently cursor is on a space, then fast-forward to nearest non-space or start of line */
725
      /* if currently cursor is on a space, then fast-forward to nearest non-space or start of line */
718
      for (;;) {
726
      for (;;) {
719
        if ((db->xoffset == 0) && (db->cursorposx == 0)) break;
727
        if ((db->xoffset == 0) && (db->cursorposx == 0)) break;
720
        if (db->cursor->payload[db->xoffset + db->cursorposx] != ' ') break;
728
        if (db->cursor->payload[db->xoffset + db->cursorposx] != ' ') break;
721
        cursor_left(db, screenw, &uidirtyfrom, &uidirtyto);
729
        cursor_left(db, &uidirtyfrom, &uidirtyto);
722
      }
730
      }
723
      /* now skip to next space or start of file */
731
      /* now skip to next space or start of file */
724
      for (;;) {
732
      for (;;) {
725
        cursor_left(db, screenw, &uidirtyfrom, &uidirtyto);
733
        cursor_left(db, &uidirtyfrom, &uidirtyto);
726
        if (db->cursor->payload[db->xoffset + db->cursorposx] == ' ') {
734
        if (db->cursor->payload[db->xoffset + db->cursorposx] == ' ') {
727
          cursor_right(db, screenw, screenh, &uidirtyfrom, &uidirtyto);
735
          cursor_right(db, &uidirtyfrom, &uidirtyto);
728
          break;
736
          break;
729
        }
737
        }
730
        if ((db->cursorposx == 0) && (db->xoffset == 0)) break;
738
        if ((db->cursorposx == 0) && (db->xoffset == 0)) break;
731
      }
739
      }
732
 
740