55
58
#define swap(x, y) { int d = (x); (x) = (y); (y) = d; }
57
60
/* Terminal capabilities */
58
static char *CM, *IS, *RS, *AC, *EA;
59
static char *ME, *SE, *UE, *AE;
60
static char *AS, *MB, *MD, *MR, *SO, *US;
61
static char *CE, *Al, *Dl, *AL, *DL;
62
static char *CS, *SF, *SR, *VB, *BL;
63
static char *VE, *VI, *KS, *KE;
64
static char *CD, *CL, *IC, *DC;
65
static char *BC, *CR, *NL;
67
static char *TS, *FS, *DS;
61
static const char *CM, *IS, *RS, *AC, *EA;
62
static const char *ME, *SE, *UE, *AE;
63
static const char *AS, *MB, *MD, *MR, *SO, *US;
64
static const char *CE, *Al, *Dl, *AL, *DL;
65
static const char *CS, *SF, *SR, *VB, *BL;
66
static const char *VE, *VI, *KS, *KE;
67
static const char *CD, *CL, *IC, *DC;
68
static const char *CR, *NL;
70
static const char *TS, *FS, *DS;
70
73
/* Special characters */
194
200
* Turn off all attributes
196
static void _attroff()
202
static void _attroff(void)
201
if (SE != CNULL) outstr(SE);
202
if (UE != CNULL) outstr(UE);
204
if (AE != CNULL) outstr(AE);
208
217
* Turn some attributes on
210
static void _attron(attr)
219
static void _attron(char attr)
213
221
if (!usecolor || (attr & XA_REVERSE) == 0) {
214
/* Reverse standout does not look too good.. */
215
if (attr & XA_BOLD && MD != CNULL) outstr(MD);
216
if (attr & XA_STANDOUT && SO != CNULL) outstr(SO);
217
if (attr & XA_UNDERLINE && US != CNULL) outstr(US);
222
/* Reverse standout does not look too good.. */
223
if (attr & XA_BOLD && MD != NULL)
225
if (attr & XA_STANDOUT && SO != NULL)
227
if (attr & XA_UNDERLINE && US != NULL)
219
if (attr & XA_REVERSE && MR != CNULL) outstr(MR);
220
if (attr & XA_BLINK && MB != CNULL) outstr(MB);
221
if (attr & XA_ALTCHARSET && AS != CNULL) outstr(AS);
230
if (attr & XA_REVERSE && MR != NULL)
232
if (attr & XA_BLINK && MB != NULL)
234
if (attr & XA_ALTCHARSET && AS != NULL)
227
static void _colson(color)
241
static void _colson(char color)
231
244
sprintf(buf, "\033[%d;%dm", COLFG(color) + 30, COLBG(color) + 40);
236
249
* Set global attributes, if different.
238
static void _setattr(attr, color)
251
static void _setattr(char attr, char color)
241
if (!useattr) return;
245
if (attr == curattr) return;
251
if (attr == curattr && color == curcolor) return;
265
if (attr == curattr && color == curcolor)
260
275
* Goto (x, y) in stdwin
262
static void _gotoxy(x, y)
277
static void _gotoxy(int x, int y)
265
279
int oldattr = -1;
270
284
/* Sanity check. */
271
if (x >= COLS || y > LINES || (x == curx && y == cury)) return;
285
if (x >= COLS || y > LINES || (x == curx && y == cury))
273
288
if (use_status) {
274
/* Leaving status line? */
275
if (cury == LINES && y < cury) {
277
/* Re-set attributes. */
280
_setattr(tmp, curcolor);
281
outstr(tgoto(CM, x, y));
285
/* Writing on status line? */
286
else if (y == LINES) {
287
/* From normal screen? */
289
outstr(tgoto(TS, x, x));
292
/* Set the right attributes. */
295
_setattr(tmp, curcolor);
289
/* Leaving status line? */
290
if (cury == LINES && y < cury) {
292
/* Re-set attributes. */
295
_setattr(tmp, curcolor);
296
outstr(tgoto(CM, x, y));
300
/* Writing on status line? */
301
else if (y == LINES) {
302
/* From normal screen? */
304
outstr(tgoto(TS, x, x));
307
/* Set the right attributes. */
310
_setattr(tmp, curcolor);
301
316
/* Sanity check. */
302
317
if (x >= COLS || y >= LINES || (x == curx && y == cury)) {
304
if (x >= COLS || y >= LINES)
305
fprintf(stderr, "OOPS: (x, y) == (%d, %d)\n",
319
if (x >= COLS || y >= LINES)
320
fprintf(stderr, "OOPS: (x, y) == (%d, %d)\n",
312
327
if (!_mv_standout && curattr != XA_NORMAL) {
314
_setattr(XA_NORMAL, curcolor);
329
_setattr(XA_NORMAL, curcolor);
316
if (CR != CNULL && y == cury && x == 0)
331
if (CR != NULL && y == cury && x == 0)
318
333
#if 0 /* Hmm, sometimes NL only works in the first column */
319
else if (NL != CNULL && x == curx && y == cury + 1)
334
else if (NL != NULL && x == curx && y == cury + 1)
322
else if (NL != CNULL && x == 0 && x == curx && y == cury + 1)
337
else if (NL != NULL && x == 0 && x == curx && y == cury + 1)
325
else if (BC != CNULL && y == cury && x == curx - 1)
328
outstr(tgoto(CM, x, y));
340
else if (BC != NULL && y == cury && x == curx - 1)
343
outstr(tgoto(CM, x, y));
331
if (oldattr != -1) _setattr(oldattr, curcolor);
347
_setattr(oldattr, curcolor);
349
362
* character is automatically restored.
351
364
if (_has_am && y >= LINES - 1 && x >= COLS - 1) {
359
if (x < COLS && y <= LINES) {
372
if (x < COLS && y <= LINES)
361
if (x < COLS && y < LINES) {
374
if (x < COLS && y < LINES)
364
static int x0=-1, y0=-1, c0=0;
365
static char attr0, color0;
366
if (x!=x0+1 || y!=y0 || attr!=attr0 || color!=color0 || !(c0&128)) {
368
_setattr(attr, color);
370
x0=x; y0=y; attr0=attr; color0=color; c0=c;
371
(void) outchar((screen_ibmpc || screen_iso || (attr & XA_ALTCHARSET)) ? c : wcharmap[(unsigned char)c]);
372
/* a little test at 10.3.1998 / jl */
373
/* (void) outchar((unsigned char) c); */
378
e = &gmap[x + y * COLS];
378
static int x0 = -1, y0 = -1, c0 = 0;
379
static char attr0, color0;
380
if (x!=x0+1 || y!=y0 || attr!=attr0 || color!=color0 || !(c0&128)) {
382
_setattr(attr, color);
384
x0 = x; y0 = y; attr0 = attr; color0 = color; c0 = c;
385
if ((attr & XA_ALTCHARSET) != 0)
388
char buf[MB_LEN_MAX];
391
len = one_wctomb(buf, c);
392
for (i = 0; i < (size_t)len; i++)
399
e = &gmap[x + y * COLS];
387
408
* Set cursor type.
389
static void _cursor(type)
410
static void _cursor(int type)
392
412
_curstype = type;
394
if (type == CNORMAL && VE != CNULL) outstr(VE);
395
if (type == CNONE && VE != CNULL && VI != CNULL) outstr(VI);
414
if (type == CNORMAL && VE != NULL)
416
if (type == CNONE && VE != NULL && VI != NULL)
407
429
* Resize a window
409
void wresize(win, lines, cols)
431
void wresize(WIN *win, int lines, int cols)
414
434
ELM *oldmap, *newmap, *e, *n;
416
if ((newmap = (ELM *)malloc((lines + 1) * cols * sizeof(ELM))) == (ELM *)NULL)
436
if ((newmap = malloc((lines + 1) * cols * sizeof(ELM))) == NULL)
418
438
if (win == stdwin)
423
for(y = 0; y < lines; y++)
424
for(x = 0; x < cols; x++) {
425
n = &newmap[y + x * cols];
426
if (x < win->xs && y < win->ys) {
427
e = &oldmap[y + x * COLS];
433
n->color = win->color;
437
if (win->sy2 == win->y2) win->sy2 = win->y1 + lines - 1;
443
for (y = 0; y < lines; y++)
444
for (x = 0; x < cols; x++) {
445
n = &newmap[y + x * cols];
446
if (x < win->xs && y < win->ys) {
447
e = &oldmap[y + x * COLS];
453
n->color = win->color;
457
if (win->sy2 == win->y2)
458
win->sy2 = win->y1 + lines - 1;
438
459
win->y2 = win->y1 + lines - 1;
442
463
if (win == stdwin) {
452
473
* Create a new window.
455
WIN *wopen(x1, y1, x2, y2, border, attr, fg, bg, direct, histlines, doclr)
458
int attr, fg, bg, direct;
475
WIN *wopen(int x1, int y1, int x2, int y2, int border, int attr,
476
int fg, int bg, int direct, int histlines, int doclr)
511
534
w->direct = direct;
513
536
if (border != BNONE) {
517
542
/* Store whatever we are overlapping */
518
543
bytes = (y2 - y1 + 1) * (x2 - x1 + 1) * sizeof(ELM) + 100;
519
if ((e = (ELM *)malloc(bytes)) == (ELM *)0) {
544
if ((e = malloc(bytes)) == NULL) {
524
549
/* How many bytes is one line */
525
550
bytes = (x2 - x1 + 1) * sizeof(ELM);
527
for(y = y1; y <= y2; y++) {
528
memcpy(e, gmap + COLS * y + x1, bytes);
552
for (y = y1; y <= y2; y++) {
553
memcpy(e, gmap + COLS * y + x1, bytes);
533
557
/* Do we want history? */
534
558
w->histline = w->histlines = 0;
535
w->histbuf = (ELM *)0;
537
/* Reserve some memory. */
538
bytes = w->xs * histlines * sizeof(ELM);
539
if ((w->histbuf = (ELM *)malloc(bytes)) == NULL) {
544
w->histlines = histlines;
561
/* Reserve some memory. */
562
bytes = w->xs * histlines * sizeof(ELM);
563
if ((w->histbuf = malloc(bytes)) == NULL) {
568
w->histlines = histlines;
546
/* Clear the history buf. */
548
for(y = 0; y < w->xs * histlines; y++) {
570
/* Clear the history buf. */
572
for (y = 0; y < w->xs * histlines; y++) {
557
580
/* And draw the window */
559
_write(border == BSINGLE ? S_UL : D_UL, w->direct, x1, y1,
561
for(x = x1 + 1; x < x2; x++)
562
_write(border == BSINGLE ? S_HOR : D_HOR, w->direct, x, y1,
564
_write(border == BSINGLE ? S_UR : D_UR, w->direct, x2, y1,
566
for(y = y1 + 1; y < y2; y++) {
567
_write(border == BSINGLE ? S_VER : D_VER, w->direct, x1, y,
569
for(x = x1 + 1; x < x2; x++)
570
_write(' ', w->direct, x, y, attr, color);
571
_write(border == BSINGLE ? S_VER : D_VER, w->direct, x2, y,
574
_write(border == BSINGLE ? S_LL : D_LL, w->direct, x1, y2,
576
for(x = x1 + 1; x < x2; x++)
577
_write(border == BSINGLE ? S_HOR : D_HOR, w->direct,
578
x, y2, xattr, color);
579
_write(border == BSINGLE ? S_LR : D_LR, w->direct, x2, y2,
581
if (w->direct) _gotoxy(x1 + 1, y1 + 1);
582
_write(border == BSINGLE ? S_UL : D_UL, w->direct, x1, y1, xattr, color);
583
for (x = x1 + 1; x < x2; x++)
584
_write(border == BSINGLE ? S_HOR : D_HOR, w->direct, x, y1, xattr, color);
585
_write(border == BSINGLE ? S_UR : D_UR, w->direct, x2, y1, xattr, color);
586
for (y = y1 + 1; y < y2; y++) {
587
_write(border == BSINGLE ? S_VER : D_VER, w->direct, x1, y, xattr, color);
588
for (x = x1 + 1; x < x2; x++)
589
_write(' ', w->direct, x, y, attr, color);
590
_write(border == BSINGLE ? S_VER : D_VER, w->direct, x2, y, xattr, color);
592
_write(border == BSINGLE ? S_LL : D_LL, w->direct, x1, y2, xattr, color);
593
for (x = x1 + 1; x < x2; x++)
594
_write(border == BSINGLE ? S_HOR : D_HOR, w->direct, x, y2, xattr, color);
595
_write(border == BSINGLE ? S_LR : D_LR, w->direct, x2, y2, xattr, color);
597
_gotoxy(x1 + 1, y1 + 1);
583
if (doclr) winclr(w);
586
if (w->direct) wflush();
591
609
* Close a window.
593
void wclose(win, replace)
611
void wclose(WIN *win, int replace)
606
623
if (win == stdwin) {
612
629
if (win->border) {
613
win->x1--; win->x2++;
614
win->y1--; win->y2++;
616
635
wcursor(win, win->o_cursor);
618
for(y = win->y1; y <= win->y2; y++) {
619
/* temporal way to avoid 'half-character' problem */
620
/* in multibyte characters such as Japanese -- from here */
622
g = gmap + (y * stdwin->xs);
623
for(x = 0 ; x < win->x1; x++) {
624
_write(g->value, 1, x, y, g->attr, g->color);
628
for(x = win->x1; x <= win->x2; x++) {
629
_write(e->value, 1, x, y, e->attr, e->color);
633
_gotoxy(win->o_curx, win->o_cury);
634
_setattr(win->o_attr, win->o_color);
637
for (y = win->y1; y <= win->y2; y++) {
638
/* temporal way to avoid 'half-character' problem */
639
/* in multibyte characters such as Japanese -- from here */
641
g = gmap + (y * stdwin->xs);
642
for (x = 0 ; x < win->x1; x++) {
643
_write(g->value, 1, x, y, g->attr, g->color);
647
for (x = win->x1; x <= win->x2; x++) {
648
_write(e->value, 1, x, y, e->attr, e->color);
652
_gotoxy(win->o_curx, win->o_cury);
653
_setattr(win->o_attr, win->o_color);
638
if (win->histbuf) free(win->histbuf);
640
658
free(win); /* 1.1.98 dickey@clark.net */
648
666
* Clear screen & restore keyboard modes
654
672
ocursor = _curstype;
656
(void) setcbreak(0); /* Normal */
674
setcbreak(0); /* Normal */
657
675
_gotoxy(0, LINES - 1);
658
676
_setattr(XA_NORMAL, COLATTR(WHITE, BLACK));
659
677
_cursor(CNORMAL);
667
if (KE != CNULL) outstr(KE);
668
if (RS != CNULL) outstr(RS);
684
(void) setcbreak(1); /* Cbreak, no echo */
686
if (IS != CNULL) outstr(IS); /* Initialization string */
687
if (EA != CNULL) outstr(EA); /* Graphics init. */
688
if (KS != CNULL) outstr(KS); /* Keypad mode */
705
setcbreak(1); /* Cbreak, no echo */
708
outstr(IS); /* Initialization string */
710
outstr(EA); /* Graphics init. */
712
outstr(KS); /* Keypad mode */
691
715
_cursor(ocursor);
694
for(y = 0; y <LINES; y++) {
695
for(x = 0; x < COLS; x++) {
696
_write(e->value, -1, x, y, e->attr, e->color);
718
for (y = 0; y <LINES; y++) {
719
for(x = 0; x < COLS; x++) {
720
_write(e->value, -1, x, y, e->attr, e->color);
700
724
_gotoxy(oldx, oldy);
793
812
* If the window *is* the physical screen, we can scroll very simple.
794
813
* This improves performance on slow screens (eg ATARI ST) dramatically.
796
if (win->direct && SF != CNULL &&
797
(dir == S_UP || SR != CNULL) && (LINES == win->sy2 - win->sy1 + 1)) {
800
_setattr(win->attr, win->color);
802
_gotoxy(0, LINES - 1);
815
if (win->direct && SF != NULL &&
816
(dir == S_UP || SR != NULL) && (LINES == win->sy2 - win->sy1 + 1)) {
819
_setattr(win->attr, win->color);
821
_gotoxy(0, LINES - 1);
810
829
* If the window is as wide as the physical screen, we can
811
830
* scroll it with insert/delete line (or set scroll region - vt100!)
813
832
else if (win->direct && win->xs == COLS &&
814
((CS != CNULL && SF != CNULL && SR != CNULL)
815
|| (Dl != CNULL && Al != CNULL))) {
818
_setattr(win->attr, win->color);
819
if (CS != CNULL && SF != CNULL && SR != CNULL) { /* Scrolling Region */
820
/* If the scroll region we want to initialize already is as
821
* big as the physical screen, we don't _have_ to
824
if (win->sy2 == LINES - 1 && win->sy1 == 0) fs = 1;
826
outstr(tgoto(CS, win->sy2, win->sy1));
830
_gotoxy(0, win->sy2);
833
_gotoxy(0, win->sy1);
837
outstr(tgoto(CS, LINES - 1, 0));
840
_gotoxy(0, win->sy2);
841
} else { /* Use insert/delete line */
843
_gotoxy(0, win->sy1);
845
_gotoxy(0, win->sy2);
848
_gotoxy(0, win->sy2);
850
_gotoxy(0, win->sy1);
833
((CS != NULL && SF != NULL && SR != NULL)
834
|| (Dl != NULL && Al != NULL))) {
837
_setattr(win->attr, win->color);
838
if (CS != NULL && SF != NULL && SR != NULL) { /* Scrolling Region */
839
/* If the scroll region we want to initialize already is as
840
* big as the physical screen, we don't _have_ to
843
if (win->sy2 == LINES - 1 && win->sy1 == 0)
846
outstr(tgoto(CS, win->sy2, win->sy1));
850
_gotoxy(0, win->sy2);
853
_gotoxy(0, win->sy1);
857
outstr(tgoto(CS, LINES - 1, 0));
860
_gotoxy(0, win->sy2);
861
} else { /* Use insert/delete line */
863
_gotoxy(0, win->sy1);
865
_gotoxy(0, win->sy2);
868
_gotoxy(0, win->sy2);
870
_gotoxy(0, win->sy1);
856
876
/* If a terminal has automatic margins, we can't write
858
878
* the non-visible character that is now visible.
860
880
if (sflag && win->sy2 == (LINES - 1) && win->sy1 != win->sy2) {
862
_write(oldc.value, 1, COLS - 1, LINES - 2,
863
oldc.attr, oldc.color);
882
_write(oldc.value, 1, COLS - 1, LINES - 2,
883
oldc.attr, oldc.color);
868
888
ocurx = win->curx;
871
890
/* If this window has a history buf, see if we want to use it. */
872
891
if (win->histbuf && dir == S_UP &&
873
win->sy2 == win->y2 && win->sy1 == win->y1) {
875
/* Calculate screen buffer */
876
e = gmap + win->y1 * COLS + win->x1;
878
/* Calculate history buffer */
879
f = win->histbuf + (win->xs * win->histline);
881
/* Copy line from screen to history buffer */
882
memcpy((char *)f, (char *)e, win->xs * sizeof(ELM));
884
/* Postion the next line in the history buffer */
886
if (win->histline >= win->histlines) win->histline = 0;
892
win->sy2 == win->y2 && win->sy1 == win->y1) {
894
/* Calculate screen buffer */
895
e = gmap + win->y1 * COLS + win->x1;
897
/* Calculate history buffer */
898
f = win->histbuf + (win->xs * win->histline);
900
/* Copy line from screen to history buffer */
901
memcpy((char *)f, (char *)e, win->xs * sizeof(ELM));
903
/* Postion the next line in the history buffer */
905
if (win->histline >= win->histlines)
890
909
/* If the window is screen-wide and has no border, there
891
910
* is a much simpler & FASTER way of scrolling the memory image !!
894
len = (win->sy2 - win->sy1) * win->xs * sizeof(ELM);
896
dst = (char *)&gmap[0]; /* First line */
897
src = (char *)&gmap[win->xs]; /* Second line */
898
win->cury = win->sy2 - win->y1;
900
src = (char *)&gmap[0]; /* First line */
901
dst = (char *)&gmap[win->xs]; /* Second line */
902
win->cury = win->sy1 - win->y1;
904
/* memmove copies len bytes from src to dst, even if the
913
len = (win->sy2 - win->sy1) * win->xs * sizeof(ELM);
915
dst = (char *)&gmap[0]; /* First line */
916
src = (char *)&gmap[win->xs]; /* Second line */
917
win->cury = win->sy2 - win->y1;
919
src = (char *)&gmap[0]; /* First line */
920
dst = (char *)&gmap[win->xs]; /* Second line */
921
win->cury = win->sy1 - win->y1;
923
/* memmove copies len bytes from src to dst, even if the
909
memcpy((char *)dst, (char *)src, len);
928
memcpy((char *)dst, (char *)src, len);
912
bcopy((char *)src, (char *)dst, len);
931
bcopy((char *)src, (char *)dst, len);
914
memmove((char *)dst, (char *)src, len);
933
memmove((char *)dst, (char *)src, len);
918
/* Now scroll the memory image. */
920
for(y = win->sy1 + 1; y <= win->sy2; y++) {
921
e = gmap + y * COLS + win->x1;
922
for(x = win->x1; x <= win->x2; x++) {
923
_write(e->value, win->direct && doit,
924
x, y - 1, e->attr, e->color);
929
win->cury = win->sy2 - win->y1;
930
if (doit) (void) _wclreol(win);
932
for(y = win->sy2 - 1; y >= win->sy1; y--) {
933
e = gmap + y * COLS + win->x1;
934
for(x = win->x1; x <= win->x2; x++) {
935
_write(e->value, win->direct && doit,
936
x, y + 1, e->attr, e->color);
941
win->cury = win->sy1 - win->y1;
942
if (doit) (void) _wclreol(win);
937
/* Now scroll the memory image. */
939
for (y = win->sy1 + 1; y <= win->sy2; y++) {
940
e = gmap + y * COLS + win->x1;
941
for (x = win->x1; x <= win->x2; x++) {
942
_write(e->value, win->direct && doit, x, y - 1, e->attr, e->color);
947
win->cury = win->sy2 - win->y1;
951
for (y = win->sy2 - 1; y >= win->sy1; y--) {
952
e = gmap + y * COLS + win->x1;
953
for (x = win->x1; x <= win->x2; x++) {
954
_write(e->value, win->direct && doit, x, y + 1, e->attr, e->color);
959
win->cury = win->sy1 - win->y1;
946
965
win->curx = ocurx;
948
if (!doit) for(x = win->x1; x <= win->x2; x++)
949
_write(' ', 0, x, win->y1 + win->cury, win->attr, win->color);
968
for (x = win->x1; x <= win->x2; x++)
969
_write(' ', 0, x, win->y1 + win->cury, win->attr, win->color);
950
970
if (!_intern && win->direct)
951
_gotoxy(win->x1 + win->curx, win->y1 + win->cury);
952
if (dirflush && !_intern && win->direct) wflush();
971
_gotoxy(win->x1 + win->curx, win->y1 + win->cury);
972
if (dirflush && !_intern && win->direct)
956
977
* Locate the cursor in a window.
958
void wlocate(win, x, y)
979
void wlocate(WIN *win, int x, int y)
964
if (x >= win->xs) x = win->xs - 1;
965
if (y >= win->ys) y = win->ys - 1;
969
if (win->direct) _gotoxy(win->x1 + x, win->y1 + y);
993
_gotoxy(win->x1 + x, win->y1 + y);
971
if (dirflush) wflush();
975
1000
* Print a character in a window.
1002
void wputc(WIN *win, wchar_t c)
993
if (win->curx == 0) break;
1002
wputc(win, ' '); /* Recursion! */
1003
} while(win->curx % 8);
1006
if (win->autocr) win->curx = 0;
1009
/* See if we need to scroll/move. (vt100 behaviour!) */
1010
if (c == '\n' || (win->curx >= win->xs && win->wrap)) {
1011
if (c != '\n') win->curx = 0;
1014
if (win->cury == win->sy2 - win->y1 + 1) {
1018
win->cury = win->sy1 - win->y1;
1020
if (win->cury >= win->ys) win->cury = win->ys - 1;
1022
/* Now write the character. */
1024
_write(c, win->direct, win->curx + win->x1,
1025
win->cury + win->y1, win->attr, win->color);
1026
if (++win->curx >= win->xs && !win->wrap) {
1028
curx = 0; /* Force to move */
1026
wputc(win, ' '); /* Recursion! */
1027
} while (win->curx % 8);
1034
/* See if we need to scroll/move. (vt100 behaviour!) */
1035
if (c == '\n' || (win->curx >= win->xs && win->wrap)) {
1040
if (win->cury == win->sy2 - win->y1 + 1) {
1044
win->cury = win->sy1 - win->y1;
1046
if (win->cury >= win->ys)
1047
win->cury = win->ys - 1;
1049
/* Now write the character. */
1051
if (!win->wrap && win->curx >= win->xs)
1053
_write(c, win->direct, win->curx + win->x1,
1054
win->cury + win->y1, win->attr, win->color);
1055
if (++win->curx >= win->xs && !win->wrap) {
1057
curx = 0; /* Force to move */
1034
1063
if (mv && win->direct)
1035
_gotoxy(win->x1 + win->curx, win->y1 + win->cury);
1064
_gotoxy(win->x1 + win->curx, win->y1 + win->cury);
1037
if (win->direct && dirflush && !_intern) wflush();
1066
if (win->direct && dirflush && !_intern)
1040
1070
/* Draw one line in a window */
1041
void wdrawelm(w, y, e)
1071
void wdrawelm(WIN *w, int y, ELM *e)
1048
1075
/* MARK updated 02/17/94 - Fixes bug, to do all 80 cols, not 79 cols */
1049
for(x = w->x1; x <= w->x2; x++)
1051
_write(e->value, w->direct, x, y + w->y1, e->attr, e->color);
1052
/*y + w->y1, XA_NORMAL, e->color);*/
1076
for (x = w->x1; x <= w->x2; x++) {
1077
_write(e->value, w->direct, x, y + w->y1, e->attr, e->color);
1078
/*y + w->y1, XA_NORMAL, e->color);*/
1060
1085
* 'accumulate' one line of ELM's into a string
1061
1086
* WHY: need this in search function to see if line contains search pattern
1063
void wdrawelm_var(w, e, buf)
1088
void wdrawelm_var(WIN *w, ELM *e, wchar_t *buf)
1070
1092
/* MARK updated 02/17/94 - Fixes bug, to do all 80 cols, not 79 cols */
1071
for(x = w->x1; x <= w->x2; x++)
1093
for (x = w->x1; x <= w->x2; x++) {
1094
buf[c++] = e->value;
1077
#endif /*SEARCH_HISTORY*/
1081
1101
* 'draw' one line of ELM's in a window INVERTED (text-mode-wise)
1082
1102
* WHY: need this in search function to see if line contains search pattern
1084
void wdrawelm_inverse(w, y, e)
1104
void wdrawelm_inverse(WIN *w, int y, ELM *e)
1126
1146
* Print a formatted string in a window.
1127
1147
* Should return stringlength - but who cares.
1130
int wprintf(win, s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
1132
char *s, *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9, *a10;
1149
int wprintf(WIN *win, const char *fmt, ...)
1140
snprintf(buf, sizeof(buf), s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
1141
while(*t) wputc(win, *t++);
1143
if (dirflush && win->direct) wflush();
1155
vsnprintf(buf, sizeof(buf), fmt, va);
1149
1163
* Sound a bell.
1155
else if (VB != CNULL)
1169
else if (VB != NULL)
1158
(void) outchar('\007');
1163
1177
* Set cursor type.
1165
void wcursor(win, type)
1179
void wcursor(WIN *win, int type)
1169
1181
win->cursor = type;
1170
1182
if (win->direct) {
1172
if (dirflush) wflush();
1176
void wtitle(w, pos, s)
1189
void wtitle(WIN *w, int pos, const char *s)
1187
if (w->border == BNONE) return;
1189
if (pos == TLEFT) x = w->x1;
1190
if (pos == TRIGHT) x = w->x2 - strlen(s) - 1;
1191
if (pos == TMID) x = w->x1 + (w->xs - strlen(s)) / 2 - 1;
1192
if (x < w->x1) x = w->x1;
1194
if (x < w->x2) _write('[', w->direct, x++, w->y1 - 1, w->attr, w->color);
1195
while(*s && x <= w->x2) _write(*s++, w->direct, x++, w->y1 - 1,
1197
if (x <= w->x2) _write(']', w->direct, x++, w->y1 - 1, w->attr, w->color);
1197
if (w->border == BNONE)
1203
x = w->x2 - mbslen(s) - 1;
1205
x = w->x1 + (w->xs - mbslen(s)) / 2 - 1;
1210
_write('[', w->direct, x++, w->y1 - 1, w->attr, w->color);
1211
while (*s && x <= w->x2) {
1214
s += one_mbtowc(&wc, s, MB_LEN_MAX);
1215
_write(wc, w->direct, x++, w->y1 - 1, w->attr, w->color);
1218
_write(']', w->direct, x++, w->y1 - 1, w->attr, w->color);
1199
1220
if (w->direct) {
1200
_gotoxy(w->x1 + w->curx, w->y1 + w->cury);
1201
if (dirflush) wflush();
1221
_gotoxy(w->x1 + w->curx, w->y1 + w->cury);
1225
1244
e = gmap + y * COLS + w->x1;
1227
1246
/* If we can't do reverse, just put a '>' in front of
1228
1247
* the line. We only support XA_NORMAL & XA_REVERSE.
1230
if (!useattr || MR == CNULL) {
1231
if (attr & XA_REVERSE)
1235
_write(x, w->direct, w->x1, y, attr, e->color);
1249
if (!useattr || MR == NULL) {
1250
if (attr & XA_REVERSE)
1254
_write(x, w->direct, w->x1, y, attr, e->color);
1237
for(x = w->x1; x <= w->x2; x++) {
1238
_write(e->value, w->direct, x, y, attr, e->color);
1256
for (x = w->x1; x <= w->x2; x++) {
1257
_write(e->value, w->direct, x, y, attr, e->color);
1242
if ((VI == CNULL || _curstype == CNORMAL) && w->direct)
1244
if (w->direct) wflush();
1261
if ((VI == NULL || _curstype == CNORMAL) && w->direct)
1248
1268
* wselect - select one of many choices.
1250
int wselect(x, y, choices, funlist, title, attr, fg, bg)
1270
int wselect(int x, int y, const char *const *choices,
1271
void (*const *funlist)(void),
1272
const char *title, int attr, int fg, int bg)
1274
const char *const *a = choices;
1258
1275
unsigned int len = 0;
1263
1280
int high_on = XA_REVERSE | attr;
1264
1281
int high_off = attr;
1266
1283
/* first count how many, and max. width. */
1268
while (*a != CNULL) {
1270
if (strlen(_(*a)) > len)
1271
len = strlen(_(*a));
1285
while (*a != NULL) {
1287
if (mbslen(_(*a)) > len)
1288
len = mbslen(_(*a));
1274
if (title != CNULL && strlen(title) + 2 > len)
1275
len = strlen(title) + 2;
1291
if (title != NULL && mbslen(title) + 2 > len)
1292
len = mbslen(title) + 2;
1276
1293
if (attr & XA_REVERSE) {
1277
high_on = attr & ~XA_REVERSE;
1294
high_on = attr & ~XA_REVERSE;
1281
if ((w = wopen(x, y, x + len + 2, y + count - 1, BDOUBLE,
1282
attr, fg, bg, 0, 0, 0)) == (WIN *)0) return(-1);
1298
if ((w = wopen(x, y, x + len + 2, y + count - 1,
1299
BDOUBLE, attr, fg, bg, 0, 0, 0)) == NULL)
1283
1301
wcursor(w, CNONE);
1285
if (title != CNULL) wtitle(w, TMID, title);
1304
wtitle(w, TMID, title);
1287
for(c = 0; c < count; c++) {
1288
wprintf(w, " %s%s", _(choices[c]), c == count - 1 ? "" : "\n");
1306
for (c = 0; c < count; c++)
1307
wprintf(w, " %s%s", _(choices[c]), c == count - 1 ? "" : "\n");
1291
1309
wcurbar(w, cur, high_on);
1295
while((c = wxgetch()) != 27 && c != '\n' && c!= '\r' && c != ' ') {
1296
if (c == K_UP || c == K_DN || c == 'j' || c == 'k' ||
1297
c == K_HOME || c == K_END)
1298
wcurbar(w, cur, high_off);
1303
if (cur < 0) cur = count - 1;
1308
if (cur >= count) cur = 0;
1317
if (c == K_UP || c == K_DN || c == 'j' || c == 'k' ||
1318
c == K_HOME || c == K_END)
1319
wcurbar(w, cur, high_on);
1321
wcursor(w, CNORMAL);
1322
if (c == ' ' || c == 27) {
1326
if (funlist == NIL_FUNLIST || funlist[cur] == NIL_FUN) {
1313
while ((c = wxgetch()) != 27 && c != '\n' && c!= '\r' && c != ' ') {
1314
if (c == K_UP || c == K_DN || c == 'j' || c == 'k' ||
1315
c == K_HOME || c == K_END)
1316
wcurbar(w, cur, high_off);
1337
if (c == K_UP || c == K_DN || c == 'j' || c == 'k' ||
1338
c == K_HOME || c == K_END)
1339
wcurbar(w, cur, high_on);
1341
wcursor(w, CNORMAL);
1342
if (c == ' ' || c == 27) {
1346
if (funlist == NULL || funlist[cur] == NULL) {
1353
1400
* Clear to end of line.
1402
void wclreol(WIN *w)
1358
if (_wclreol(w) && w->direct) _gotoxy(w->x1 + w->curx, w->y1 + w->cury);
1359
if (dirflush) wflush();
1404
if (_wclreol(w) && w->direct)
1405
_gotoxy(w->x1 + w->curx, w->y1 + w->cury);
1363
1411
* Clear to begin of line
1413
void wclrbol(WIN *w)
1374
1421
y = w->cury + w->y1;
1376
if (w->direct) _gotoxy(w->x1, y);
1378
1426
n = w->x1 + w->curx;
1379
if( n > w->x2) n = w->x2;
1380
for(x = w->x1; x <= n; x++) _write(' ', w->direct, x, y,
1429
for (x = w->x1; x <= n; x++)
1430
_write(' ', w->direct, x, y, w->attr, w->color);
1382
1431
if (w->direct) {
1384
if (dirflush) wflush();
1389
1439
* Clear to end of screen
1441
void wclreos(WIN *w)
1395
1444
int ocurx, ocury;
1397
1446
ocurx = w->curx;
1398
1447
ocury = w->cury;
1402
for(y = w->cury + 1; y <= w->y2 - w->y1; y++) {
1451
for (y = w->cury + 1; y <= w->y2 - w->y1; y++) {
1406
1455
w->curx = ocurx;
1407
1456
w->cury = ocury;
1408
if (_wclreol(w) && w->direct) _gotoxy(w->x1 + w->curx, w->y1 + w->cury);
1409
if (dirflush && w->direct) wflush();
1457
if (_wclreol(w) && w->direct)
1458
_gotoxy(w->x1 + w->curx, w->y1 + w->cury);
1459
if (dirflush && w->direct)
1413
1464
* Clear to begin of screen.
1466
void wclrbos(WIN *w)
1418
1468
int ocurx, ocury;
1421
1471
ocurx = w->curx;
1422
1472
ocury = w->cury;
1426
for(y = 0; y < ocury; y++) {
1476
for (y = 0; y < ocury; y++) {
1430
1480
w->curx = ocurx;
1431
1481
w->cury = ocury;
1436
1486
* Clear a window.
1442
1491
int olddir = w->direct;
1448
1496
/* If this window has history, save the image. */
1449
1497
if (w->histbuf) {
1451
/* MARK updated 02/17/95 - Scan backwards from the bottom of the */
1452
/* window for the first non-empty line. We should save all other */
1453
/* blank lines inside screen, since some nice BBS ANSI menus */
1454
/* contains them for cosmetic purposes or as separators. */
1455
for(m = w->y2; m >= w->y1; m--) {
1456
/* Start of this line in the global map. */
1457
e = gmap + m * COLS + w->x1;
1459
/* Quick check to see if line is empty. */
1460
for(i = 0; i < w->xs; i++)
1461
if (e[i].value != ' ') break;
1463
if (i != w->xs) break; /* Non empty line */
1466
/* Copy window into history buffer line-by-line. */
1467
for(y = w->y1; y <= m; y++) {
1468
/* Start of this line in the global map. */
1469
e = gmap + y * COLS + w->x1;
1471
/* Now copy this line. */
1472
f = w->histbuf + (w->xs * w->histline); /* History buffer */
1473
memcpy((char *)f, (char *)e, w->xs * sizeof(ELM));
1475
if (w->histline >= w->histlines) w->histline = 0;
1498
/* MARK updated 02/17/95 - Scan backwards from the bottom of the */
1499
/* window for the first non-empty line. We should save all other */
1500
/* blank lines inside screen, since some nice BBS ANSI menus */
1501
/* contains them for cosmetic purposes or as separators. */
1502
for (m = w->y2; m >= w->y1; m--) {
1503
/* Start of this line in the global map. */
1504
e = gmap + m * COLS + w->x1;
1506
/* Quick check to see if line is empty. */
1507
for (i = 0; i < w->xs; i++)
1508
if (e[i].value != ' ')
1512
break; /* Non empty line */
1515
/* Copy window into history buffer line-by-line. */
1516
for (y = w->y1; y <= m; y++) {
1517
/* Start of this line in the global map. */
1518
e = gmap + y * COLS + w->x1;
1520
/* Now copy this line. */
1521
f = w->histbuf + (w->xs * w->histline); /* History buffer */
1522
memcpy((char *)f, (char *)e, w->xs * sizeof(ELM));
1524
if (w->histline >= w->histlines)
1480
1529
_setattr(w->attr, w->color);
1483
if (CL && w->y1 == 0 && w->y2 == LINES-1 &&
1484
w->x1 == 0 && w->x2 == COLS-1) {
1532
if (CL && w->y1 == 0 && w->y2 == LINES-1 && w->x1 == 0 && w->x2 == COLS-1) {
1490
for(y = w->ys - 1; y >= 0; y--) {
1538
for (y = w->ys - 1; y >= 0; y--) {
1494
1542
w->direct = olddir;
1495
1543
_gotoxy(w->x1, w->y1);
1496
if (dirflush) wflush();
1499
1548
/* ==== Insert / Delete functions ==== */
1550
void winsline(WIN *w)
1504
1552
int osy1, osy2;
1509
1557
w->sy1 = w->y1 + w->cury;
1510
1558
w->sy2 = w->y2;
1511
if (w->sy1 < osy1) w->sy1 = osy1;
1512
if (w->sy2 > osy2) w->sy2 = osy2;
1513
1563
wscroll(w, S_DOWN);
1569
void wdelline(WIN *w)
1522
1571
int osy1, osy2;
1525
1574
ocury = w->cury;
1529
1578
w->sy1 = w->y1 + w->cury;
1530
1579
w->sy2 = w->y2;
1531
if (w->sy1 < osy1) w->sy1 = osy1;
1532
if (w->sy2 > osy2) w->sy2 = osy2;
1535
1586
wscroll(w, S_UP);
1563
1610
/* See if we need to insert. */
1564
if (c == 0 || strchr("\r\n\t\b\007", c) || w->curx >= w->xs - 1) {
1611
if (c == 0 || wcschr(L"\r\n\t\b\007", c) || w->curx >= w->xs - 1) {
1569
1616
odir = w->direct;
1570
if (w->xs == COLS && IC != CNULL) {
1571
/* We can use the insert character capability. */
1572
if (w->direct) outstr(IC);
1574
/* No need to draw the character if it's a space. */
1575
if (c == ' ') w->direct = 0;
1577
/* We don't need to draw the new line at all. */
1617
if (w->xs == COLS && IC != NULL) {
1618
/* We can use the insert character capability. */
1622
/* No need to draw the character if it's a space. */
1626
/* We don't need to draw the new line at all. */
1581
1630
/* Get the rest of line into buffer */
1582
1631
y = w->y1 + w->cury;
1583
1632
x = w->x1 + w->curx;
1584
1633
oldx = w->curx;
1585
1634
len = w->xs - w->curx;
1636
buf = malloc(sizeof(ELM) * len);
1638
return; /* Umm... */
1586
1639
memcpy(buf, gmap + COLS * y + x, sizeof(ELM) * len);
1588
1641
/* Now, put the new character on screen. */
1590
if (!move) w->curx = oldx;
1592
1646
/* Write buffer to screen */
1594
for(++x; x <= w->x2; x++) {
1595
_write(e->value, doit && w->direct, x, y, e->attr, e->color);
1648
for (++x; x <= w->x2; x++) {
1649
_write(e->value, doit && w->direct, x, y, e->attr, e->color);
1598
1654
w->direct = odir;
1599
1655
wlocate(w, w->curx, w->cury);
1658
void winschar(WIN *w)
1605
1660
winschar2(w, ' ', 0);
1690
if (linelen >= i - 1) linelen = i - 1;
1736
if (linelen >= i - 1)
1692
1739
/* We assume the line has already been drawn on the screen. */
1693
if ((idx = strlen(s)) > linelen)
1695
strncpy(buf, s, sizeof(buf));
1740
if ((idx = wcslen(s)) > linelen)
1742
wcsncpy(buf, s, sizeof(buf) / sizeof(*buf));
1696
1743
wlocate(w, x + idx, y);
1706
if (c > 255 || c == K_BS || c == K_DEL) delete = 0;
1714
case K_ESC: /* Exit without changing. */
1716
lredraw(w, x, y, s, linelen);
1721
case K_HOME: /* Home */
1725
if (r) lredraw(w, x, y, buf, linelen);
1729
case K_END: /* End of line. */
1732
while(idx - offs > linelen) {
1736
if (r) lredraw(w, x, y, buf + offs, linelen);
1737
wlocate(w, x + idx - offs, y);
1740
case K_LT: /* Cursor left. */
1741
case K_BS: /* Backspace is first left, then DEL. */
1742
if (idx == 0) break;
1746
/*if (c == K_LT) FIXME? */
1747
lredraw(w, x, y, buf + offs, linelen);
1750
wlocate(w, x + idx - offs, y);
1755
case K_DEL: /* Delete character under cursor. */
1756
if (buf[idx] == 0) break;
1757
for(f = idx; buf[f]; f++)
1759
lredraw(w, x + idx - offs, y, buf + idx,
1760
linelen - (idx - offs));
1761
wlocate(w, x + idx - offs, y);
1765
if (buf[idx] == 0) break;
1767
if (idx - offs > linelen) {
1769
lredraw(w, x, y, buf + offs, linelen);
1771
wlocate(w, x + idx - offs, y);
1775
/* If delete == 1, delete the buffer. */
1777
if ((i = strlen(buf)) > linelen)
1783
for(f = 0; f < i; f++) wputc(w, ' ');
1753
if (c > 255 || c == K_BS || c == K_DEL)
1762
case K_ESC: /* Exit without changing. */
1764
lredraw(w, x, y, s, linelen);
1769
case K_HOME: /* Home */
1774
lredraw(w, x, y, buf, linelen);
1778
case K_END: /* End of line. */
1781
while (idx - offs > linelen) {
1786
lredraw(w, x, y, buf + offs, linelen);
1787
wlocate(w, x + idx - offs, y);
1790
case K_LT: /* Cursor left. */
1791
case K_BS: /* Backspace is first left, then DEL. */
1797
/*if (c == K_LT) FIXME? */
1798
lredraw(w, x, y, buf + offs, linelen);
1801
wlocate(w, x + idx - offs, y);
1806
case K_DEL: /* Delete character under cursor. */
1809
for (f = idx; buf[f]; f++)
1811
lredraw(w, x + idx - offs, y, buf + idx, linelen - (idx - offs));
1812
wlocate(w, x + idx - offs, y);
1819
if (idx - offs > linelen) {
1821
lredraw(w, x, y, buf + offs, linelen);
1823
wlocate(w, x + idx - offs, y);
1827
/* If delete == 1, delete the buffer. */
1829
if ((i = wcslen(buf)) > linelen)
1835
for (f = 0; f < i; f++)
1787
/* Insert character at cursor position. */
1788
if (c < 32 || c > 255) break;
1789
if (idx + 1 >= maxlen) break;
1790
for(f = strlen(buf) + 1; f > idx; f--)
1794
if (i == 0) buf[idx+1] = i;
1795
if (idx - offs >= linelen) {
1797
lredraw(w, x, y, buf + offs, linelen);
1799
lredraw(w, x + idx - offs, y, buf + idx,
1800
linelen - (idx - offs));
1802
wlocate(w, x + idx - offs, y);
1840
/* Insert character at cursor position. */
1841
if (c < 32 || c > 255)
1843
f = wcslen(buf) + 2;
1851
if (idx - offs >= linelen) {
1853
lredraw(w, x, y, buf + offs, linelen);
1855
lredraw(w, x + idx - offs, y, buf + idx, linelen - (idx - offs));
1857
wlocate(w, x + idx - offs, y);
1807
if (st == 0) strcpy(s, buf);
1808
1864
dirflush = direct;
1868
/* wgets - edit one line in a window. */
1869
int wgets(WIN *w, char *s, int linelen, int maxlen)
1872
wchar_t buf[BUFLEN];
1877
for (i = 0; *sptr != 0 && i < sizeof (buf) - 1; i++)
1878
sptr += one_mbtowc(buf + i, sptr, MB_LEN_MAX);
1880
st = wgetwcs(w, buf, linelen, maxlen);
1883
for (i = 0; buf[i] != 0; i++)
1885
char tmp[MB_LEN_MAX];
1888
/* This truncates data; too bad */
1889
l = one_wctomb(tmp, buf[i]);
1890
if (sptr + l >= s + maxlen)
1892
memcpy(sptr, tmp, l);
1812
1900
/* ==== Initialization code ==== */
1832
1920
/* Code for the BBS system.. */
1833
int win_init(term, lines)
1921
int win_init(char *term, int lines)
1837
1923
int fg = WHITE;
1838
1924
int bg = BLACK;
1839
1925
int attr = XA_NORMAL;
1841
1927
/* Code for other applications (minicom!) */
1842
int win_init(fg, bg, attr)
1928
int win_init(int fg, int bg, int attr)
1849
1932
static WIN _stdwin;
1850
1933
int f, olduseattr;
1852
if (w_init) return(0);
1855
if ((term = getenv("TERM")) == CNULL) {
1856
fprintf(stderr, _("Environment variable TERM not set\n"));
1939
if ((term = getenv("TERM")) == NULL) {
1940
fprintf(stderr, _("Environment variable TERM not set\n"));
1860
switch((f = tgetent(cbuf, term))) {
1862
fprintf(stderr, _("No termcap entry for %s\n"), term);
1865
fprintf(stderr, _("No termcap database present!\n"));
1944
switch ((f = tgetent(cbuf, term))) {
1946
fprintf(stderr, _("No termcap entry for %s\n"), term);
1949
fprintf(stderr, _("No termcap database present!\n"));
1872
if ((CM = tgetstr("cm", &_tptr)) == CNULL) {
1873
fprintf(stderr, _("No cursor motion capability (cm)\n"));
1956
if ((CM = tgetstr("cm", &_tptr)) == NULL) {
1957
fprintf(stderr, _("No cursor motion capability (cm)\n"));
1876
1960
LINES = COLS = 0;
1877
1961
getrowcols(&LINES, &COLS);
1923
2007
NL = tgetstr("nl", &_tptr);
1924
2008
AC = tgetstr("ac", &_tptr);
1925
2009
EA = tgetstr("eA", &_tptr);
1927
2011
TS = tgetstr("ts", &_tptr);
1928
2012
FS = tgetstr("fs", &_tptr);
1929
2013
DS = tgetstr("ds", &_tptr);
1932
if (MR == CNULL) MR = SO; /* Try standout */
1933
if (MR == CNULL) MR = US; /* Try underline */
1934
if (MR == CNULL) MR = MD; /* Try bold */
1935
if (SF == CNULL) SF = "\n";
1936
if (AC == NULL || *AC == 0) AC = def_ac; /* Standard vt100 mappings. */
2017
MR = SO; /* Try standout */
2019
MR = US; /* Try underline */
2021
MR = MD; /* Try bold */
2024
if (AC == NULL || *AC == 0)
2025
AC = def_ac; /* Standard vt100 mappings. */
1938
2027
/* cr and nl are often not defined but result in great optimization.
1939
2028
* I only hope that minicom does not break on terminals where this
1940
2029
* really does not work..
1942
if (CR == CNULL) CR = "\r";
1943
if (NL == CNULL) NL = "\n";
1946
2037
/* See if we can use the status line. */
1947
2038
if (!tgetflag("hs") || !tgetflag("es") || !TS || !FS)
1950
2041
use_status = 0;
1953
if (IS != CNULL) outstr(IS); /* Initialization string */
2045
outstr(IS); /* Initialization string */
1955
2047
/* Reset attributes */
1956
2048
olduseattr = useattr;
1990
2085
if (AS != NULL && !screen_ibmpc) {
1991
/* Try to find AC mappings. */
1992
D_UL = S_UL = acmap('l');
1993
D_HOR = S_HOR = acmap('q');
1994
D_UR = S_UR = acmap('k');
1995
D_LL = S_LL = acmap('m');
1996
D_VER = S_VER = acmap('x');
1997
D_LR = S_LR = acmap('j');
2086
/* Try to find AC mappings. */
2087
D_UL = S_UL = acmap('l');
2088
D_HOR = S_HOR = acmap('q');
2089
D_UR = S_UR = acmap('k');
2090
D_LL = S_LL = acmap('m');
2091
D_VER = S_VER = acmap('x');
2092
D_LR = S_LR = acmap('j');
2000
2095
if (screen_iso) {
2001
/* Try to find AC mappings. */
2003
D_HOR = S_HOR = '-';
2006
D_VER = S_VER = '|';
2096
/* Try to find AC mappings. */
2098
D_HOR = S_HOR = '-';
2101
D_VER = S_VER = '|';
2012
if ((p = tgetstr("gA", &_tptr)) != CNULL) wcharmap[201] = *p;
2013
if ((p = tgetstr("gB", &_tptr)) != CNULL) wcharmap[205] = *p;
2014
if ((p = tgetstr("gC", &_tptr)) != CNULL) wcharmap[187] = *p;
2015
if ((p = tgetstr("gD", &_tptr)) != CNULL) wcharmap[200] = *p;
2016
if ((p = tgetstr("gE", &_tptr)) != CNULL) wcharmap[186] = *p;
2017
if ((p = tgetstr("gF", &_tptr)) != CNULL) wcharmap[188] = *p;
2018
if ((p = tgetstr("gG", &_tptr)) != CNULL) wcharmap[218] = *p;
2019
if ((p = tgetstr("gH", &_tptr)) != CNULL) wcharmap[240] = *p;
2020
if ((p = tgetstr("gI", &_tptr)) != CNULL) wcharmap[191] = *p;
2021
if ((p = tgetstr("gJ", &_tptr)) != CNULL) wcharmap[192] = *p;
2022
if ((p = tgetstr("gK", &_tptr)) != CNULL) wcharmap[179] = *p;
2023
if ((p = tgetstr("gL", &_tptr)) != CNULL) wcharmap[217] = *p;
2026
2106
/* Memory for global map */
2027
if ((gmap = (ELM *)malloc(sizeof(ELM) * (LINES + 1) * COLS)) == (ELM *)0) {
2028
fprintf(stderr, "Not enough memory\n");
2107
if ((gmap = malloc(sizeof(ELM) * (LINES + 1) * COLS)) == NULL) {
2108
fprintf(stderr, "Not enough memory\n");
2031
2111
_buffend = _bufstart + BUFFERSIZE;
2033
2113
/* Initialize stdwin */
2034
2114
stdwin = &_stdwin;
2037
stdwin->cursor = CNORMAL;
2117
stdwin->cursor = CNORMAL;
2039
2119
stdwin->doscroll = 1;
2041
stdwin->sy1 = stdwin->y1 = 0;
2042
stdwin->x2 = COLS - 1;
2043
stdwin->sy2 = stdwin->y2 = LINES - 1;
2046
stdwin->attr = attr;
2047
stdwin->color = COLATTR(fg, bg);
2050
stdwin->histbuf = (ELM *)0;
2053
if (EA != CNULL) outstr(EA); /* Graphics init. */
2054
if (KS != CNULL) outstr(KS); /* Keypad mode */
2056
(void) setcbreak(1); /* Cbreak, no echo */
2121
stdwin->sy1 = stdwin->y1 = 0;
2122
stdwin->x2 = COLS - 1;
2123
stdwin->sy2 = stdwin->y2 = LINES - 1;
2126
stdwin->attr = attr;
2127
stdwin->color = COLATTR(fg, bg);
2129
stdwin->histbuf = NULL;
2132
outstr(EA); /* Graphics init. */
2134
outstr(KS); /* Keypad mode */
2136
setcbreak(1); /* Cbreak, no echo */
2058
2138
winclr(stdwin);
2065
if (gmap == (ELM *)0 || w_init == 0) return;
2066
(void) setcbreak(0); /* Reset */
2145
if (gmap == NULL || w_init == 0)
2147
setcbreak(0); /* Reset */
2067
2148
stdwin->attr = XA_NORMAL;
2068
2149
stdwin->color = COLATTR(WHITE, BLACK);
2069
2150
_setattr(stdwin->attr, stdwin->color);
2070
2151
winclr(stdwin);
2074
2156
wcursor(stdwin, CNORMAL);
2075
if (KE != CNULL) outstr(KE);
2076
if (RS != CNULL) outstr(RS);
2077
else if (IS != CNULL) outstr(IS);
2161
else if (IS != NULL)