4 | A subset of curses developed for use with ae.
6 | written by Hugh Mahon
8 | THIS MATERIAL IS PROVIDED "AS IS". THERE ARE
9 | NO WARRANTIES OF ANY KIND WITH REGARD TO THIS
10 | MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE
11 | IMPLIED WARRANTIES OF MERCHANTABILITY AND
12 | FITNESS FOR A PARTICULAR PURPOSE. Neither
13 | Hewlett-Packard nor Hugh Mahon shall be liable
14 | for errors contained herein, nor for
15 | incidental or consequential damages in
16 | connection with the furnishing, performance or
17 | use of this material. Neither Hewlett-Packard
18 | nor Hugh Mahon assumes any responsibility for
19 | the use or reliability of this software or
20 | documentation. This software and
21 | documentation is totally UNSUPPORTED. There
22 | is no support contract available. Hewlett-
23 | Packard has done NO Quality Assurance on ANY
24 | of the program or documentation. You may find
25 | the quality of the materials inferior to
26 | supported materials.
28 | This software is not a product of Hewlett-Packard, Co., or any
29 | other company. No support is implied or offered with this software.
30 | You've got the source, and you're on your own.
32 | This software may be distributed under the terms of Larry Wall's
33 | Artistic license, a copy of which is included in this distribution.
35 | This notice must be included with this software and any derivatives.
37 | Copyright (c) 1986, 1987, 1988, 1991, 1992, 1993, 1994, 1995 Hugh Mahon
38 | All are rights reserved.
44 char *copyright_message[] = { "Copyright (c) 1986, 1987, 1988, 1991, 1992, 1993, 1994, 1995 Hugh Mahon",
45 "All rights are reserved."};
47 char * new_curse_name= "@(#) new_curse.c $FreeBSD$";
49 #include "new_curse.h"
60 #include <sys/types.h>
64 #include <sys/select.h> /* on AIX */
67 #endif /* BSD_SELECT */
84 #include <sys/ioctl.h>
89 static WINDOW *virtual_scr;
91 WINDOW *last_window_refreshed;
97 #define min(a, b) (a < b ? a : b)
100 #define String_Out(table, stack, place) Info_Out(table, stack, place)
102 #define String_Out(table, stack, place) Cap_Out(table, stack, place)
105 #define bw__ 0 /* booleans */
108 #define xs__ 3 /* hp glitch (standout not erased by overwrite) */
111 #define gn__ 6 /* generic type terminal */
112 #define hc__ 7 /* hardcopy terminal */
118 #define mi__ 13 /* safe to move during insert mode */
119 #define ms__ 14 /* safe to move during standout mode */
123 #define hz__ 18 /* hazeltine glitch */
132 #define co__ 0 /* number of columns */ /* numbers */
133 #define it__ 1 /* spaces per tab */
134 #define li__ 2 /* number of lines */
136 #define sg__ 4 /* magic cookie glitch */
150 #define bt__ 0 /* back tab */ /* strings */
151 #define bl__ 1 /* bell */
152 #define cr__ 2 /* carriage return */
153 #define cs__ 3 /* change scroll region */
154 #define ct__ 4 /* clear all tab stops */
155 #define cl__ 5 /* clear screen and home cursor */
156 #define ce__ 6 /* clear to end of line */
157 #define cd__ 7 /* clear to end of display */
158 #define ch__ 8 /* set cursor column */
159 #define CC__ 9 /* term, settable cmd char in */
160 #define cm__ 10 /* screen rel cursor motion, row, column */
161 #define do__ 11 /* down one line */
162 #define ho__ 12 /* home cursor */
163 #define vi__ 13 /* make cursor invisible */
164 #define le__ 14 /* move cursor left one space */
165 #define CM__ 15 /* memory rel cursor addressing */
166 #define ve__ 16 /* make cursor appear normal */
167 #define nd__ 17 /* non-destructive space (cursor right) */
168 #define ll__ 18 /* last line, first col */
169 #define up__ 19 /* cursor up */
171 #define dc__ 21 /* delete character */
172 #define dl__ 22 /* delete line */
177 #define md__ 27 /* turn on bold */
179 #define dm__ 29 /* turn on delete mode */
180 #define mh__ 30 /* half bright mode */
181 #define im__ 31 /* insert mode */
185 #define so__ 35 /* enter standout mode */
192 #define ei__ 42 /* exit insert mode */
193 #define se__ 43 /* exit standout mode */
205 #define kb__ 55 /* backspace key */
237 #define ku__ 87 /* key up */
281 #define sa__ 131 /* sgr */
427 char *Boolean_names[] = {
428 "bw", "am", "xb", "xs", "xn", "eo", "gn", "hc", "km", "hs", "in", "da", "db",
429 "mi", "ms", "os", "es", "xt", "hz", "ul", "xo", "HC", "nx", "NR", "NP", "5i"
432 char *Number_names[] = {
433 "co#", "it#", "li#", "lm#", "sg#", "pb#", "vt#", "ws#", "Nl#", "lh#", "lw#"
436 char *String_names[] = {
437 "bt=", "bl=", "cr=", "cs=", "ct=", "cl=", "ce=", "cd=", "ch=", "CC=", "cm=",
438 "do=", "ho=", "vi=", "le=", "CM=", "ve=", "nd=", "ll=", "up=", "vs=", "dc=",
439 "dl=", "ds=", "hd=", "as=", "mb=", "md=", "ti=", "dm=", "mh=", "im=", "mk=",
440 "mp=", "mr=", "so=", "us=", "ec=", "ae=", "me=", "te=", "ed=", "ei=", "se=",
441 "ue=", "vb=", "ff=", "fs=", "i1=", "i2=", "i3=", "if=", "ic=", "al=", "ip=",
442 "kb=", "ka=", "kC=", "kt=", "kD=", "kL=", "kd=", "kM=", "kE=", "kS=", "k0=",
443 "k1=", "k;=", "k2=", "k3=", "k4=", "k5=", "k6=", "k7=", "k8=", "k9=", "kh=",
444 "kI=", "kA=", "kl=", "kH=", "kN=", "kP=", "kr=", "kF=", "kR=", "kT=", "ku=",
445 "ke=", "ks=", "l0=", "l1=", "la=", "l2=", "l3=", "l4=", "l5=", "l6=", "l7=",
446 "l8=", "l9=", "mo=", "mm=", "nw=", "pc=", "DC=", "DL=", "DO=", "IC=", "SF=",
447 "AL=", "LE=", "RI=", "SR=", "UP=", "pk=", "pl=", "px=", "ps=", "pf=", "po=",
448 "rp=", "r1=", "r2=", "r3=", "rf=", "rc=", "cv=", "sc=", "sf=", "sr=", "sa=",
449 "st=", "wi=", "ta=", "ts=", "uc=", "hu=", "iP=", "K1=", "K3=", "K2=", "K4=",
450 "K5=", "pO=", "rP=", "ac=", "pn=", "kB=", "SX=", "RX=", "SA=", "RA=", "XN=",
451 "XF=", "eA=", "LO=", "LF=", "@1=", "@2=", "@3=", "@4=", "@5=", "@6=", "@7=",
452 "@8=", "@9=", "@0=", "%1=", "%2=", "%3=", "%4=", "%5=", "%6=", "%7=", "%8=",
453 "%9=", "%0=", "&1=", "&2=", "&3=", "&4=", "&5=", "&6=", "&7=", "&8=", "&9=",
454 "&0=", "*1=", "*2=", "*3=", "*4=", "*5=", "*6=", "*7=", "*8=", "*9=", "*0=",
455 "#1=", "#2=", "#3=", "#4=", "%a=", "%b=", "%c=", "%d=", "%e=", "%f=", "%g=",
456 "%h=", "%i=", "%j=", "!1=", "!2=", "!3=", "RF=", "F1=", "F2=", "F3=", "F4=",
457 "F5=", "F6=", "F7=", "F8=", "F9=", "FA=", "FB=", "FC=", "FD=", "FE=", "FF=",
458 "FG=", "FH=", "FI=", "FJ=", "FK=", "FL=", "FM=", "FN=", "FO=", "FP=", "FQ=",
459 "FR=", "FS=", "FT=", "FU=", "FV=", "FW=", "FX=", "FY=", "FZ=", "Fa=", "Fb=",
460 "Fc=", "Fd=", "Fe=", "Ff=", "Fg=", "Fh=", "Fi=", "Fj=", "Fk=", "Fl=", "Fm=",
461 "Fn=", "Fo=", "Fp=", "Fq=", "Fr=", "cb=", "MC=", "ML=", "MR="
465 char *new_curse = "October 1987";
467 char in_buff[100]; /* buffer for ungetch */
468 int bufp; /* next free position in in_buff */
470 char *TERMINAL_TYPE = NULL; /* terminal type to be gotten from environment */
472 int Data_Line_len = 0;
473 int Max_Key_len; /* max length of a sequence sent by a key */
474 char *Data_Line = NULL;
475 char *TERM_PATH = NULL;
476 char *TERM_data_ptr = NULL;
477 char *Term_File_name = NULL; /* name of file containing terminal description */
478 FILE *TFP; /* file pointer to file with terminal des. */
479 int Fildes; /* file descriptor for terminfo file */
480 int STAND = FALSE; /* is standout mode activated? */
481 int TERM_INFO = FALSE; /* is terminfo being used (TRUE), or termcap (FALSE) */
482 int Time_Out; /* set when time elapsed while trying to read function key */
483 int Curr_x; /* current x position on screen */
484 int Curr_y; /* current y position on the screen */
487 int Move_It; /* flag to move cursor if magic cookie glitch */
488 int initialized = FALSE; /* tells whether new_curse is initialized */
490 float chars_per_millisecond;
491 int Repaint_screen; /* if an operation to change screen impossible, repaint screen */
492 int Intr; /* storeage for interrupt character */
493 int Parity; /* 0 = no parity, 1 = odd parity, 2 = even parity */
494 int Noblock; /* for BSD systems */
495 int Num_bits; /* number of bits per character */
496 int Flip_Bytes; /* some systems have byte order reversed */
497 int interrupt_flag = FALSE; /* set true if SIGWINCH received */
504 int length; /* length of string sent by key */
505 char *string; /* string sent by key */
506 int value; /* CURSES value of key (9-bit) */
510 struct KEYS *element;
511 struct KEY_STACK *next;
514 struct KEY_STACK *KEY_TOS = NULL;
515 struct KEY_STACK *KEY_POINT;
519 struct Parameters *next;
523 0407, 0526, 0515, 0525, 0512, 0510, 0402, 0514, 0517, 0516, 0410, 0411,
524 0422, 0412, 0413, 0414, 0415, 0416, 0417, 0420, 0421, 0406, 0513, 0511,
525 0404, 0533, 0522, 0523, 0405, 0520, 0521, 0524, 0403,
526 0534, 0535, 0536, 0537, 0540, 0541, 0542, 0543, 0544, 0545, 0546, 0547,
527 0550, 0527, 0551, 0552, 0553, 0554, 0555, 0556, 0557, 0560, 0561, 0562,
528 0532, 0563, 0564, 0565, 0566, 0567, 0570, 0571, 0627, 0630, 0572, 0573,
529 0574, 0575, 0576, 0577, 0600, 0601, 0602, 0603, 0604, 0605, 0606, 0607,
530 0610, 0611, 0612, 0613, 0614, 0615, 0616, 0617, 0620, 0621, 0622, 0623,
531 0624, 0625, 0626, 0423, 0424, 0425, 0426, 0427, 0430, 0431,
532 0432, 0433, 0434, 0435, 0436, 0437, 0440, 0441, 0442, 0443, 0444, 0445,
533 0446, 0447, 0450, 0451, 0452, 0453, 0454, 0455, 0456, 0457, 0460, 0461,
534 0462, 0463, 0464, 0465, 0466, 0467, 0470, 0471, 0472, 0473, 0474, 0475,
535 0476, 0477, 0500, 0501, 0502, 0503, 0504, 0505, 0506, 0507
538 int attributes_set[9];
541 struct termio Terminal;
542 struct termio Saved_tty;
544 struct sgttyb Terminal;
545 struct sgttyb Saved_tty;
552 char *String_table[1024];
556 static char nc_scrolling_ability = FALSE;
560 #if __STDC__ || defined(__cplusplus)
564 #endif /* __STDC__ */
566 int tc_Get_int P_((int));
567 void CAP_PARSE P_((void));
568 void Find_term P_((void));
577 extern char *fgets();
578 extern char *malloc();
579 extern char *getenv();
580 FILE *fopen(); /* declaration for open function */
581 #endif /* HAS_STDLIB */
582 #endif /* __STDC__ */
587 | Copy the contents of one window to another.
591 copy_window(origin, destination)
592 WINDOW *origin, *destination;
595 struct _line *orig, *dest;
597 orig = origin->first_line;
598 dest = destination->first_line;
601 row < (min(origin->Num_lines, destination->Num_lines));
605 column < (min(origin->Num_cols, destination->Num_cols));
608 dest->row[column] = orig->row[column];
609 dest->attributes[column] = orig->attributes[column];
611 dest->changed = orig->changed;
612 dest->scroll = orig->scroll;
613 dest->last_char = min(orig->last_char, destination->Num_cols);
614 orig = orig->next_screen;
615 dest = dest->next_screen;
617 destination->LX = min((destination->Num_cols - 1), origin->LX);
618 destination->LY = min((destination->Num_lines - 1), origin->LY);
619 destination->Attrib = origin->Attrib;
620 destination->scroll_up = origin->scroll_up;
621 destination->scroll_down = origin->scroll_down;
622 destination->SCROLL_CLEAR = origin->SCROLL_CLEAR;
633 signal(SIGWINCH, reinitscr);
635 if (ioctl(0, TIOCGWINSZ, &ws) >= 0)
637 if (ws.ws_row == LINES && ws.ws_col == COLS)
644 #endif /* TIOCGWINSZ */
645 local_virt = newwin(LINES, COLS, 0, 0);
646 local_std = newwin(LINES, COLS, 0, 0);
647 local_cur = newwin(LINES, COLS, 0, 0);
648 copy_window(virtual_scr, local_virt);
649 copy_window(stdscr, local_std);
650 copy_window(curscr, local_cur);
654 virtual_scr = local_virt;
658 virtual_lines = (int *) malloc(LINES * (sizeof(int)));
659 interrupt_flag = TRUE;
661 #endif /* SIGWINCH */
664 initscr() /* initialize terminal for operations */
668 char *columns_string;
674 printf("starting initscr \n");fflush(stdout);
680 #endif /* BSD_SELECT */
688 value = ioctl(0, TCGETA, &Terminal);
689 if (Terminal.c_cflag & PARENB)
691 if (Terminal.c_cflag & PARENB)
696 if ((Terminal.c_cflag & CS8) == CS8)
700 else if ((Terminal.c_cflag & CS7) == CS7)
702 else if ((Terminal.c_cflag & CS6) == CS6)
706 value = Terminal.c_cflag & 037;
708 case 01: speed = 50.0;
710 case 02: speed = 75.0;
712 case 03: speed = 110.0;
714 case 04: speed = 134.5;
716 case 05: speed = 150.0;
718 case 06: speed = 200.0;
720 case 07: speed = 300.0;
722 case 010: speed = 600.0;
724 case 011: speed = 900.0;
726 case 012: speed = 1200.0;
728 case 013: speed = 1800.0;
730 case 014: speed = 2400.0;
732 case 015: speed = 3600.0;
734 case 016: speed = 4800.0;
736 case 017: speed = 7200.0;
738 case 020: speed = 9600.0;
740 case 021: speed = 19200.0;
742 case 022: speed = 38400.0;
744 default: speed = 0.0;
747 value = ioctl(0, TIOCGETP, &Terminal);
748 if (Terminal.sg_flags & EVENP)
750 else if (Terminal.sg_flags & ODDP)
752 value = Terminal.sg_ospeed;
754 case 01: speed = 50.0;
756 case 02: speed = 75.0;
758 case 03: speed = 110.0;
760 case 04: speed = 134.5;
762 case 05: speed = 150.0;
764 case 06: speed = 200.0;
766 case 07: speed = 300.0;
768 case 010: speed = 600.0;
770 case 011: speed = 1200.0;
772 case 012: speed = 1800.0;
774 case 013: speed = 2400.0;
776 case 014: speed = 4800.0;
778 case 015: speed = 9600.0;
780 default: speed = 0.0;
783 chars_per_millisecond = (0.001 * speed) / 8.0;
784 TERMINAL_TYPE = getenv("TERM");
785 if (TERMINAL_TYPE == NULL)
787 printf("unknown terminal type\n");
792 TERM_PATH = getenv("TERMINFO");
793 if (TERM_PATH != NULL)
795 Data_Line_len = 23 + strlen(TERM_PATH) + strlen(TERMINAL_TYPE);
796 Term_File_name = malloc(Data_Line_len);
797 sprintf(Term_File_name, "%s/%c/%s", TERM_PATH, *TERMINAL_TYPE, TERMINAL_TYPE);
798 Fildes = open(Term_File_name, O_RDONLY);
802 TERM_PATH = "/usr/lib/terminfo";
803 Data_Line_len = 23 + strlen(TERM_PATH) + strlen(TERMINAL_TYPE);
804 Term_File_name = malloc(Data_Line_len);
805 sprintf(Term_File_name, "%s/%c/%s", TERM_PATH, *TERMINAL_TYPE, TERMINAL_TYPE);
806 Fildes = open(Term_File_name, O_RDONLY);
810 TERM_PATH = "/usr/share/lib/terminfo";
811 Data_Line_len = 23 + strlen(TERM_PATH) + strlen(TERMINAL_TYPE);
812 Term_File_name = malloc(Data_Line_len);
813 sprintf(Term_File_name, "%s/%c/%s", TERM_PATH, *TERMINAL_TYPE, TERMINAL_TYPE);
814 Fildes = open(Term_File_name, O_RDONLY);
818 free(Term_File_name);
819 Term_File_name = NULL;
822 TERM_INFO = INFO_PARSE();
825 | termcap information can be in the TERMCAP env variable, if so
826 | use that, otherwise check the /etc/termcap file
828 if ((pointer = Term_File_name = getenv("TERMCAP")) != NULL)
830 if (*Term_File_name != '/')
831 Term_File_name = "/etc/termcap";
835 Term_File_name = "/etc/termcap";
837 if ((TFP = fopen(Term_File_name, "r")) == NULL)
839 printf("unable to open /etc/termcap file \n");
842 for (value = 0; value < 1024; value++)
843 String_table[value] = NULL;
844 for (value = 0; value < 128; value++)
846 for (value = 0; value < 128; value++)
848 Data_Line = malloc(512);
849 if (pointer && *pointer != '/')
851 TERM_data_ptr = pointer;
860 if (String_table[pc__] == NULL)
861 String_table[pc__] = "\0";
862 if ((String_table[cm__] == NULL) || (Booleans[hc__]))
864 fprintf(stderr, "sorry, unable to use this terminal type for screen editing\n");
868 LINES = Numbers[li__];
869 COLS = Numbers[co__];
870 if ((lines_string = getenv("LINES")) != NULL)
872 value = atoi(lines_string);
876 if ((columns_string = getenv("COLUMNS")) != NULL)
878 value = atoi(columns_string);
884 | get the window size
886 if (ioctl(0, TIOCGWINSZ, &ws) >= 0)
894 virtual_scr = newwin(LINES, COLS, 0, 0);
895 stdscr = newwin(LINES, COLS, 0, 0);
896 curscr = newwin(LINES, COLS, 0, 0);
899 Repaint_screen = TRUE;
901 virtual_lines = (int *) malloc(LINES * (sizeof(int)));
905 | reset size of windows and LINES and COLS if term window
908 signal(SIGWINCH, reinitscr);
909 #endif /* SIGWINCH */
912 | check if scrolling is available
915 nc_scrolling_ability = ((String_table[al__] != NULL) &&
916 (String_table[dl__])) || ((String_table[cs__])
917 && (String_table[sr__]));
923 Get_int() /* get a two-byte integer from the terminfo file */
929 Low_byte = *((unsigned char *) TERM_data_ptr++);
930 High_byte = *((unsigned char *) TERM_data_ptr++);
934 Low_byte = High_byte;
937 if ((High_byte == 255) && (Low_byte == 255))
940 return(Low_byte + (High_byte * 256));
944 INFO_PARSE() /* parse off the data in the terminfo data file */
947 int magic_number = 0;
953 int string_table_len = 0;
956 TERM_data_ptr = Data_Line = malloc((10240 * (sizeof(char))));
957 Data_Line_len = read(Fildes, Data_Line, 10240);
958 if ((Data_Line_len >= 10240) || (Data_Line_len < 0))
963 magic_number = Get_int();
965 | if magic number not right, reverse byte order and check again
967 if (magic_number != 282)
972 magic_number = Get_int();
973 if (magic_number != 282)
977 | get the number of each type in the terminfo data file
979 Num_names = Get_int();
980 Num_bools = Get_int();
981 Num_ints = Get_int();
982 Num_strings = Get_int();
983 string_table_len = Get_int();
984 Strings = malloc(string_table_len);
985 while (Num_names > 0)
994 Booleans[counter++] = *TERM_data_ptr++;
996 if (((unsigned int) TERM_data_ptr) & 1) /* force alignment */
1002 Numbers[counter] = Get_int();
1005 temp_ptr = TERM_data_ptr + Num_strings + Num_strings;
1006 memcpy(Strings, temp_ptr, string_table_len);
1011 if ((offset=Get_int()) != -1)
1013 if (String_table[counter] == NULL)
1014 String_table[counter] = Strings + offset;
1017 String_table[counter] = NULL;
1024 #endif /* ifndef CAP */
1027 AtoI() /* convert ascii text to integers */
1032 while ((*TERM_data_ptr >= '0') && (*TERM_data_ptr <= '9'))
1034 Temp = (Temp * 10) + (*TERM_data_ptr - '0');
1041 Key_Get() /* create linked list with all key sequences obtained from terminal database */
1046 struct KEY_STACK *Spoint;
1051 while (key_def <= kf63__)
1053 if (key_def == ke__)
1055 else if (key_def == (K5__ + 1))
1057 else if (key_def == (kcbt__ + 1))
1059 else if (key_def == (kUND__ + 1))
1061 if (String_table[key_def] != NULL)
1063 if (KEY_TOS == NULL)
1064 Spoint = KEY_TOS = (struct KEY_STACK *) malloc(sizeof(struct KEY_STACK));
1068 while (Spoint->next != NULL)
1069 Spoint = Spoint->next;
1070 Spoint->next = (struct KEY_STACK *) malloc(sizeof(struct KEY_STACK));
1071 Spoint = Spoint->next;
1073 Spoint->next = NULL;
1074 Spoint->element = (struct KEYS *) malloc(sizeof(struct KEYS));
1075 Spoint->element->string = String_table[key_def];
1076 Spoint->element->length = strlen(String_table[key_def]);
1077 Spoint->element->value = Key_vals[Counter];
1078 Klen = strlen(Spoint->element->string);
1079 if (Klen > Max_Key_len)
1082 | Some terminal types accept keystrokes of the form
1083 | \E[A and \EOA, substituting '[' for 'O'. Make a
1084 | duplicate of such key strings (since the
1085 | database will only have one version) so new_curse
1086 | can understand both.
1088 if ((Spoint->element->length > 1) &&
1089 ((String_table[key_def][1] == '[') ||
1090 (String_table[key_def][1] == 'O')))
1092 Spoint->next = (struct KEY_STACK *) malloc(sizeof(struct KEY_STACK));
1093 Spoint = Spoint->next;
1094 Spoint->next = NULL;
1095 Spoint->element = (struct KEYS *) malloc(sizeof(struct KEYS));
1096 Spoint->element->length = strlen(String_table[key_def]);
1097 Spoint->element->string = malloc(Spoint->element->length + 1);
1098 strcpy(Spoint->element->string, String_table[key_def]);
1099 Spoint->element->value = Key_vals[Counter];
1100 Klen = strlen(Spoint->element->string);
1101 if (Klen > Max_Key_len)
1104 if (String_table[key_def][1] == '[')
1105 Spoint->element->string[1] = 'O';
1107 Spoint->element->string[1] = '[';
1117 String_Get(param) /* read the string */
1126 while (*TERM_data_ptr != '=')
1128 Temp = ++TERM_data_ptr;
1130 while ((*Temp != ':') && (*Temp != (char)NULL))
1135 if (Counter == 1) /* no data */
1137 String = Temp = malloc(Counter);
1138 while ((*TERM_data_ptr != ':') && (*TERM_data_ptr != (char)NULL))
1140 if (*TERM_data_ptr == '\\')
1143 if (*TERM_data_ptr == 'n')
1145 else if (*TERM_data_ptr == 't')
1147 else if (*TERM_data_ptr == 'b')
1149 else if (*TERM_data_ptr == 'r')
1151 else if (*TERM_data_ptr == 'f')
1153 else if ((*TERM_data_ptr == 'e') || (*TERM_data_ptr == 'E'))
1154 *Temp = '\033'; /* escape */
1155 else if (*TERM_data_ptr == '\\')
1157 else if (*TERM_data_ptr == '\'')
1159 else if ((*TERM_data_ptr >= '0') && (*TERM_data_ptr <= '9'))
1162 while ((*TERM_data_ptr >= '0') && (*TERM_data_ptr <= '9'))
1164 Counter = (8 * Counter) + (*TERM_data_ptr - '0');
1165 TERM_data_ptr++; /* ? */
1173 else if (*TERM_data_ptr == '^')
1176 if ((*TERM_data_ptr >= '@') && (*TERM_data_ptr <= '_'))
1177 *Temp = *TERM_data_ptr - '@';
1178 else if (*TERM_data_ptr == '?')
1184 *Temp++ = *TERM_data_ptr++;
1191 while ((*TERM_data_ptr != (char)NULL) && (*TERM_data_ptr != ':'))
1198 tc_Get_int(param) /* read the integer */
1205 while ((*TERM_data_ptr != (char)NULL) && (*TERM_data_ptr != '#'))
1213 while (*TERM_data_ptr != ':')
1220 Find_term() /* find terminal description in termcap file */
1225 Ftemp = Name = malloc(strlen(TERMINAL_TYPE + 1) + 1);
1226 strcpy(Name, TERMINAL_TYPE);
1227 while (*Ftemp != (char)NULL)
1230 *Ftemp = (char)NULL;
1232 Data_Line_len = strlen(TERMINAL_TYPE) + 1;
1233 while ((!CFOUND) && ((TERM_data_ptr=fgets(Data_Line, 512, TFP)) != NULL))
1235 if ((*TERM_data_ptr != ' ') && (*TERM_data_ptr != '\t') && (*TERM_data_ptr != '#'))
1237 while ((!CFOUND) && (*TERM_data_ptr != (char)NULL))
1239 CFOUND = !strncmp(TERM_data_ptr, Name, Data_Line_len);
1240 while ((*TERM_data_ptr != (char)NULL) && (*TERM_data_ptr != '|') && (*TERM_data_ptr != '#') && (*TERM_data_ptr != ':'))
1242 if (*TERM_data_ptr == '|')
1245 *TERM_data_ptr = (char)NULL;
1251 printf("terminal type %s not found\n", TERMINAL_TYPE);
1257 CAP_PARSE() /* parse off the data in the termcap data file */
1264 while (*TERM_data_ptr != (char)NULL)
1266 for (found = FALSE, offset = 0; (!found) && (offset < 26); offset++)
1268 if (!strncmp(TERM_data_ptr, Boolean_names[offset], 2))
1271 Booleans[offset] = TRUE;
1276 for (found = FALSE, offset = 0; (!found) && (offset < lw__); offset++)
1278 if (!strncmp(TERM_data_ptr, Number_names[offset], 3))
1281 Numbers[offset] = tc_Get_int(Numbers[offset]);
1287 for (found = FALSE, offset = 0; (!found) && (offset < smgr__); offset++)
1289 if (!strncmp(TERM_data_ptr, String_names[offset], 3))
1292 String_table[offset] = String_Get(String_table[offset]);
1297 if (!strncmp(TERM_data_ptr, "tc=", 3))
1298 tc_ = String_Get(NULL);
1299 while ((*TERM_data_ptr != ':') && (*TERM_data_ptr != (char)NULL))
1301 if (*TERM_data_ptr == ':')
1304 } while (((TERM_data_ptr = fgets(Data_Line, 512, TFP)) != NULL) && ((*TERM_data_ptr == ' ') || (*TERM_data_ptr == '\t')));
1307 TERMINAL_TYPE = tc_;
1317 #endif /* ifdef CAP */
1320 Screenalloc(columns)
1326 tmp = (struct _line *) malloc(sizeof (struct _line));
1327 tmp->row = malloc(columns + 1);
1328 tmp->attributes = malloc(columns + 1);
1329 tmp->prev_screen = NULL;
1330 tmp->next_screen = NULL;
1331 for (i = 0; i < columns; i++)
1334 tmp->attributes[i] = (char) NULL;
1336 tmp->scroll = tmp->changed = FALSE;
1337 tmp->row[0] = (char) NULL;
1338 tmp->attributes[0] = (char) NULL;
1339 tmp->row[columns] = (char) NULL;
1340 tmp->attributes[columns] = (char) NULL;
1345 WINDOW *newwin(lines, cols, start_l, start_c)
1346 int lines, cols; /* number of lines and columns to be in window */
1347 int start_l, start_c; /* starting line and column to be inwindow */
1350 struct _line *temp_screen;
1353 Ntemp = (WINDOW *) malloc(sizeof(WINDOW));
1354 Ntemp->SR = start_l;
1355 Ntemp->SC = start_c;
1356 Ntemp->Num_lines = lines;
1357 Ntemp->Num_cols = cols;
1360 Ntemp->scroll_down = Ntemp->scroll_up = 0;
1361 Ntemp->SCROLL_CLEAR = FALSE;
1362 Ntemp->Attrib = FALSE;
1363 Ntemp->first_line = temp_screen = Screenalloc(cols);
1364 Ntemp->first_line->number = 0;
1365 for (i = 1; i < lines; i++)
1367 temp_screen->next_screen = Screenalloc(cols);
1368 temp_screen->next_screen->number = i;
1369 temp_screen->next_screen->prev_screen = temp_screen;
1370 temp_screen = temp_screen->next_screen;
1372 Ntemp->first_line->prev_screen = NULL;
1373 temp_screen->next_screen = NULL;
1379 Cap_Out(string, p_list, place) /* interpret the output string if necessary */
1381 int p_list[]; /* stack of values */
1382 int place; /* place keeper of top of stack */
1384 char *Otemp; /* temporary string pointer to parse output */
1394 p1 = p_list[--place];
1395 p2 = p_list[--place];
1399 if ((*Otemp >= '0') && (*Otemp <= '9'))
1401 delay = atoi(Otemp);
1402 while ((*Otemp >= '0') && (*Otemp <= '9'))
1407 while (*Otemp != (char)NULL)
1412 if ((*Otemp == 'd') || (*Otemp == '2') || (*Otemp == '3') || (*Otemp == '.') || (*Otemp == '+'))
1416 else if (*Otemp == '2')
1418 else if (*Otemp == '3')
1420 else if (*Otemp == '+')
1426 else if (*Otemp == '.')
1431 else if (*Otemp == '>')
1442 else if (*Otemp == 'r')
1448 else if (*Otemp == 'i')
1453 else if (*Otemp == '%')
1455 else if (*Otemp == 'n')
1460 else if (*Otemp == 'B')
1462 p1 = (16 * (p1/10)) + (p1 % 10);
1463 p2 = (16 * (p2/10)) + (p2 % 10);
1465 else if (*Otemp == 'D')
1467 p1 = (p1 - 2 * (p1 % 16));
1468 p2 = (p2 - 2 * (p2 % 16));
1477 chars = delay * chars_per_millisecond;
1479 if ((chars - delay) > 0.0)
1481 for (; delay > 0; delay--)
1482 putchar(*String_table[pc__]);
1489 char *Otemp; /* temporary string pointer to parse output */
1495 Operation(Temp_Stack, place) /* handle conditional operations */
1504 temp = Temp_Stack[--place];
1507 else if (!strncmp(Otemp, "2d", 2))
1509 temp = Temp_Stack[--place];
1510 printf("%2d", temp);
1514 else if (!strncmp(Otemp, "3d", 2))
1516 temp = Temp_Stack[--place];
1517 printf("%0d", temp);
1521 else if (!strncmp(Otemp, "02d", 3))
1523 temp = Temp_Stack[--place];
1524 printf("%02d", temp);
1529 else if (!strncmp(Otemp, "03d", 3))
1531 temp = Temp_Stack[--place];
1532 printf("%03d", temp);
1537 else if (*Otemp == '+')
1540 temp = Temp_Stack[--place];
1541 temp += Temp_Stack[--place];
1542 Temp_Stack[place++] = temp;
1544 else if (*Otemp == '-')
1547 temp = Temp_Stack[--place];
1548 temp -= Temp_Stack[--place];
1549 Temp_Stack[place++] = temp;
1551 else if (*Otemp == '*')
1554 temp = Temp_Stack[--place];
1555 temp *= Temp_Stack[--place];
1556 Temp_Stack[place++] = temp;
1558 else if (*Otemp == '/')
1561 temp = Temp_Stack[--place];
1562 temp /= Temp_Stack[--place];
1563 Temp_Stack[place++] = temp;
1565 else if (*Otemp == 'm')
1568 temp = Temp_Stack[--place];
1569 temp %= Temp_Stack[--place];
1570 Temp_Stack[place++] = temp;
1572 else if (*Otemp == '&')
1575 temp = Temp_Stack[--place];
1576 temp &= Temp_Stack[--place];
1577 Temp_Stack[place++] = temp;
1579 else if (*Otemp == '|')
1582 temp = Temp_Stack[--place];
1583 temp |= Temp_Stack[--place];
1584 Temp_Stack[place++] = temp;
1586 else if (*Otemp == '^')
1589 temp = Temp_Stack[--place];
1590 temp ^= Temp_Stack[--place];
1591 Temp_Stack[place++] = temp;
1593 else if (*Otemp == '=')
1596 temp = Temp_Stack[--place];
1597 temp = (temp == Temp_Stack[--place]);
1598 Temp_Stack[place++] = temp;
1600 else if (*Otemp == '>')
1603 temp = Temp_Stack[--place];
1604 temp = temp > Temp_Stack[--place];
1605 Temp_Stack[place++] = temp;
1607 else if (*Otemp == '<')
1610 temp = Temp_Stack[--place];
1611 temp = temp < Temp_Stack[--place];
1612 Temp_Stack[place++] = temp;
1614 else if (*Otemp == 'c')
1617 putchar(Temp_Stack[--place]);
1619 else if (*Otemp == 'i')
1625 else if (*Otemp == '%')
1630 else if (*Otemp == '!')
1632 temp = ! Temp_Stack[--place];
1633 Temp_Stack[place++] = temp;
1636 else if (*Otemp == '~')
1638 temp = ~Temp_Stack[--place];
1639 Temp_Stack[place++] = temp;
1642 else if (*Otemp == 'p')
1645 Temp_Stack[place++] = p[*Otemp - '0'];
1648 else if (*Otemp == 'P')
1651 Temp_Stack[place++] = variable[*Otemp - 'a'];
1654 else if (*Otemp == 'g')
1657 variable[*Otemp - 'a'] = Temp_Stack[--place];
1660 else if (*Otemp == '\'')
1663 Temp_Stack[place++] = *Otemp;
1667 else if (*Otemp == '{')
1671 Temp_Stack[place++] = temp;
1672 while (*Otemp != '}')
1680 Info_Out(string, p_list, place) /* interpret the output string if necessary */
1690 int Cond_Stack[128];
1713 for (temp = 1; (place != 0); temp++)
1715 p[temp] = p_list[--place];
1720 while (*Otemp != (char) NULL)
1725 if ((*Otemp == '?') || (*Otemp == 't') || (*Otemp == 'e') || (*Otemp == ';'))
1735 | find the end of the
1736 | conditional statement
1738 while ((strncmp(Otemp, "%t", 2)) && (*Otemp != (char) NULL))
1744 Cond_place = Operation(Cond_Stack, Cond_place);
1748 | if condition is true
1750 if ((Cond_place > 0) && (Cond_Stack[Cond_place-1]))
1760 else /* condition is false */
1763 | find 'else' or end
1766 while ((strncmp(Otemp, "%e", 2)) && (strncmp(Otemp, "%;", 2)) && (*Otemp != (char) NULL))
1769 | if an 'else' found
1771 if ((*Otemp != (char) NULL) && (!strncmp(Otemp, "%e", 2)))
1777 | check for 'then' part
1779 while ((*tchar != (char) NULL) && (strncmp(tchar, "%t", 2)) && (strncmp(tchar, "%;", 2)))
1784 if (*tchar == (char) NULL)
1791 | if end of if found,
1795 else if (!strncmp(tchar, "%;", 2))
1804 | if end of if found,
1808 else if ((*Otemp != (char) NULL) && (!strncmp(Otemp, "%;", 2)))
1814 else /* Otemp == NULL */
1828 while ((*Otemp != (char) NULL) && (strncmp(Otemp, "%;", 2)))
1830 if (*Otemp != (char) NULL)
1842 Top_of_stack = Operation(Stack, Top_of_stack);
1845 else if (!strncmp(Otemp, "$<", 2))
1849 delay = atoi(Otemp);
1850 while (*Otemp != '>')
1853 chars = delay * chars_per_millisecond;
1855 if ((chars - delay) > 0.0)
1857 if (String_table[pc__] == NULL)
1860 temp = *String_table[pc__];
1861 for (; delay > 0; delay--)
1875 wmove(window, row, column) /* move cursor to indicated position in window */
1879 if ((row < window->Num_lines) && (column < window->Num_cols))
1881 window->LX = column;
1887 clear_line(line, column, cols)
1894 if (column > line->last_char)
1895 line->row[line->last_char] = ' ';
1896 line->last_char = column;
1897 line->row[column] = (char) NULL;
1898 line->attributes[column] = (char) NULL;
1899 line->changed = TRUE;
1900 for (j = column + 1; j < cols; j++)
1903 line->attributes[j] = (char) NULL;
1908 werase(window) /* clear the specified window */
1914 window->SCROLL_CLEAR = CLEAR;
1915 window->scroll_up = window->scroll_down = 0;
1916 for (i = 0, tmp = window->first_line; i < window->Num_lines; i++, tmp = tmp->next_screen)
1917 clear_line(tmp, 0, window->Num_cols);
1921 wclrtoeol(window) /* erase from current cursor position to end of line */
1927 window->SCROLL_CLEAR = CHANGE;
1928 column = window->LX;
1930 for (row = 0, tmp = window->first_line; row < window->LY; row++)
1931 tmp = tmp->next_screen;
1932 clear_line(tmp, column, window->Num_cols);
1936 wrefresh(window) /* flush all previous output */
1939 wnoutrefresh(window);
1944 fprintf(stderr, "columns=%d, lines=%d, SC=%d, SR=%d\n",window->Num_cols, window->Num_lines, window->SC, window->SR);
1945 for (value = 0, temp = window->first_line; value < window->Num_lines; value++, temp = temp->next_screen)
1947 if (temp->number == -1)
1948 fprintf(stderr, "line moved ");
1950 fprintf(stderr, "scroll_x is set: ");
1951 fprintf(stderr, "lc%d=%s|\n", temp->last_char, temp->row);
1953 fprintf(stderr, "+-------------------- virtual screen ----------------------------------------+\n");
1954 fprintf(stderr, "columns=%d, lines=%d \n",virtual_scr->Num_cols, virtual_scr->Num_lines);
1955 for (value = 0, temp = virtual_scr->first_line; value < virtual_scr->Num_lines; value++, temp = temp->next_screen)
1957 if (temp->number == -1)
1958 fprintf(stderr, "line moved ");
1960 fprintf(stderr, "scroll_x is set: ");
1961 fprintf(stderr, "lc%d=%s|\n", temp->last_char, temp->row);
1963 fprintf(stderr, "columns=%d, lines=%d \n",curscr->Num_cols, curscr->Num_lines);
1964 for (value = 0, temp = curscr->first_line; value < curscr->Num_lines; value++, temp = temp->next_screen)
1965 fprintf(stderr, "line=%s|\n", temp->row);
1969 virtual_scr->SCROLL_CLEAR = FALSE;
1970 virtual_scr->scroll_down = virtual_scr->scroll_up = 0;
1978 struct _line *user_line;
1979 int line_counter = 0;
1981 for (line_counter = 0, user_line = window->first_line;
1982 line_counter < window->Num_lines; line_counter++)
1984 user_line->changed = TRUE;
1986 window->SCROLL_CLEAR = TRUE;
1990 wnoutrefresh(window)
1993 struct _line *user_line;
1994 struct _line *virtual_line;
1995 int line_counter = 0;
1999 if (window->SR >= virtual_scr->Num_lines)
2001 user_line = window->first_line;
2002 virtual_line = virtual_scr->first_line;
2003 virtual_scr->SCROLL_CLEAR = window->SCROLL_CLEAR;
2004 virtual_scr->LX = window->LX + window->SC;
2005 virtual_scr->LY = window->LY + window->SR;
2006 virtual_scr->scroll_up = window->scroll_up;
2007 virtual_scr->scroll_down = window->scroll_down;
2008 if ((last_window_refreshed == window) && (!window->SCROLL_CLEAR))
2010 for (line_counter = 0; line_counter < window->SR; line_counter++)
2012 virtual_line = virtual_line->next_screen;
2014 for (line_counter = 0; (line_counter < window->Num_lines)
2015 && ((line_counter + window->SR) < virtual_scr->Num_lines);
2018 if ((last_window_refreshed != window) || (user_line->changed) || ((SCROLL | CLEAR) & window->SCROLL_CLEAR))
2020 for (user_col = 0, virt_col = window->SC;
2021 (virt_col < virtual_scr->Num_cols)
2022 && (user_col < window->Num_cols);
2023 virt_col++, user_col++)
2025 virtual_line->row[virt_col] = user_line->row[user_col];
2026 virtual_line->attributes[virt_col] = user_line->attributes[user_col];
2029 if (virtual_scr->Num_cols != window->Num_cols)
2031 if (virtual_line->last_char < (user_line->last_char + window->SC))
2033 if (virtual_line->row[virtual_line->last_char] == (char) NULL)
2034 virtual_line->row[virtual_line->last_char] = ' ';
2035 virtual_line->last_char =
2036 min(virtual_scr->Num_cols,
2037 (user_line->last_char + window->SC));
2039 else if (virtual_line->last_char > (user_line->last_char + window->SC))
2041 virtual_line->row[min(virtual_scr->Num_cols,
2042 (user_line->last_char + window->SC))] = ' ';
2046 virtual_line->last_char = user_line->last_char;
2047 virtual_line->row[virtual_line->last_char] = (char) NULL;
2048 virtual_line->changed = user_line->changed;
2049 virtual_line = virtual_line->next_screen;
2050 user_line = user_line->next_screen;
2052 window->SCROLL_CLEAR = FALSE;
2053 window->scroll_up = window->scroll_down = 0;
2054 last_window_refreshed = window;
2058 flushinp() /* flush input */
2063 ungetch(c) /* push a character back on input */
2067 in_buff[bufp++] = c;
2082 tv.tv_usec = 500000; /* half a second */
2084 Time_Out = FALSE; /* just in case */
2086 ret_val = select(nfds, &fds, 0, 0, &tv);
2089 | if ret_val is less than zero, there was no input
2090 | otherwise, get a character and return it
2099 return(read(0, &temp, 1)? temp : -1);
2104 wgetch(window) /* get character from specified window */
2115 in_value = ((bufp > 0) ? in_buff[--bufp] : timed_getchar());
2117 in_value = ((bufp > 0) ? in_buff[--bufp] : read(0, &temp, 1)? temp : -1);
2118 #else /* BSD_SELECT */
2120 in_value = ((bufp > 0) ? in_buff[--bufp] :
2121 (read(0, &temp, 1)> 0) ? temp : -1);
2126 old_arg = fcntl(0, F_GETFL, 0);
2127 in_value = fcntl(0, F_SETFL, old_arg | FNDELAY);
2129 in_value = ((bufp > 0) ? in_buff[--bufp] : read(0, &temp, 1)? temp : -1);
2132 fcntl(0, F_SETFL, old_arg);
2137 #endif /* BSD_SELECT */
2142 if ((Parity) && (Num_bits < 8))
2143 /* strip eighth bit if parity in use */
2146 else if (interrupt_flag)
2148 interrupt_flag = FALSE;
2149 in_value = wgetch(window);
2152 if ((in_value == '\033') || (in_value == '\037'))/* escape character */
2153 in_value = Get_key(in_value);
2159 Clear(arg) /* notify that time out has occurred */
2164 fprintf(stderr, "inside Clear()\n");
2168 #endif /* BSD_SELECT */
2171 Get_key(first_char) /* try to decode key sequence */
2172 int first_char; /* first character of sequence */
2180 struct termio Gterminal;
2182 struct sgttyb Gterminal;
2184 struct KEY_STACK *St_point;
2185 #if (!defined( BSD_SELECT)) || (!defined(SYS5))
2187 #endif /* BSD_SELECT */
2191 string[Count++] = first_char;
2192 string[Count] = (char) NULL;
2195 signal(SIGALRM, Clear);
2197 #endif /* BSD_SELECT */
2200 Gterminal.c_cc[VTIME] = 0; /* timeout value */
2201 Gterminal.c_lflag &= ~ICANON; /* disable canonical operation */
2202 Gterminal.c_lflag &= ~ECHO; /* disable echo */
2206 while ((Count < Max_Key_len) && (!Time_Out) && (!Found))
2208 in_char = wgetch(stdscr);
2210 fprintf(stderr, "back in GetKey()\n");
2215 string[Count++] = in_char;
2216 string[Count] = (char) NULL;
2218 while ((St_point != NULL) && (!Found))
2220 if (!strcmp(string, St_point->element->string))
2223 St_point = St_point->next;
2230 #endif /* BSD_SELECT */
2232 /* value = ioctl(0, TCSETA, &Terminal);*/
2234 value = ioctl(0, TIOCSETP, &Terminal);
2235 /* value = fcntl(0, F_SETFL, old_arg);*/
2240 return(St_point->element->value);
2246 if ((string[--Count] != -1) &&
2247 ((unsigned char) (string[Count]) != 255))
2250 fprintf(stderr, "ungetting character %d\n", string[Count]);fflush(stdout);
2252 ungetch(string[Count]);
2260 waddch(window, c) /* output the character in the specified window */
2265 int shift; /* number of spaces to shift if a tab */
2266 struct _line *tmpline;
2269 /*printf("starting waddch \n");fflush(stdout);*/
2272 column = window->LX;
2275 shift = (column + 1) % 8;
2283 waddch(window, ' ');
2286 else if ((column < window->Num_cols) && (row < window->Num_lines))
2288 if ((c == '~') && (Booleans[hz__]))
2291 if (( c != '\b') && (c != '\n') && (c != '\r'))
2294 tmpline = window->first_line;
2295 while (row < window->LY)
2298 tmpline = tmpline->next_screen;
2300 tmpline->row[column] = c;
2301 tmpline->attributes[column] = window->Attrib;
2302 tmpline->changed = TRUE;
2303 if (column >= tmpline->last_char)
2305 if (column > tmpline->last_char)
2306 tmpline->row[tmpline->last_char] = ' ';
2307 tmpline->row[column + 1] = (char) NULL;
2308 tmpline->attributes[column + 1] = (char) NULL;
2309 tmpline->last_char = column + 1;
2315 window->LX = window->Num_cols;
2324 if (window->LX >= window->Num_cols)
2328 if (window->LY >= window->Num_lines)
2330 window->LY = window->Num_lines - 1;
2331 /* window->LY = row;
2332 wmove(window, 0, 0);
2334 wmove(window, row, 0);*/
2337 window->SCROLL_CLEAR = CHANGE;
2341 winsertln(window) /* insert a blank line into the specified window */
2348 window->scroll_down += 1;
2349 window->SCROLL_CLEAR = SCROLL;
2350 column = window->LX;
2352 for (row = 0, tmp = window->first_line; (row < window->Num_lines) && (tmp->next_screen != NULL); row++)
2353 tmp = tmp->next_screen;
2354 if (tmp->prev_screen != NULL)
2355 tmp->prev_screen->next_screen = NULL;
2357 clear_line(tmp1, 0, window->Num_cols);
2359 for (row = 0, tmp = window->first_line; (row < window->LY) && (tmp->next_screen != NULL); row++)
2360 tmp = tmp->next_screen;
2361 if ((window->LY == (window->Num_lines - 1)) && (window->Num_lines > 1))
2363 tmp1->next_screen = tmp->next_screen;
2364 tmp->next_screen = tmp1;
2365 tmp->changed = TRUE;
2366 tmp->next_screen->prev_screen = tmp;
2368 else if (window->Num_lines > 1)
2370 if (tmp->prev_screen != NULL)
2371 tmp->prev_screen->next_screen = tmp1;
2372 tmp1->prev_screen = tmp->prev_screen;
2373 tmp->prev_screen = tmp1;
2374 tmp1->next_screen = tmp;
2375 tmp->changed = TRUE;
2378 if (window->LY == 0)
2379 window->first_line = tmp1;
2383 wdeleteln(window) /* delete a line in the specified window */
2388 struct _line *tmpline;
2390 if (window->Num_lines > 1)
2392 window->scroll_up += 1;
2393 window->SCROLL_CLEAR = SCROLL;
2394 column = window->LX;
2396 for (row = 0, tmp = window->first_line; row < window->LY; row++)
2397 tmp = tmp->next_screen;
2398 if (window->LY == 0)
2399 window->first_line = tmp->next_screen;
2400 if (tmp->prev_screen != NULL)
2401 tmp->prev_screen->next_screen = tmp->next_screen;
2402 if (tmp->next_screen != NULL)
2404 tmp->next_screen->changed = TRUE;
2405 tmp->next_screen->scroll = UP;
2406 tmp->next_screen->prev_screen = tmp->prev_screen;
2409 clear_line(tmpline, 0, window->Num_cols);
2410 tmpline->number = -1;
2411 for (row = 0, tmp = window->first_line; tmp->next_screen != NULL; row++)
2412 tmp = tmp->next_screen;
2415 tmp->next_screen = tmpline;
2416 tmp->next_screen->prev_screen = tmp;
2417 tmp->changed = TRUE;
2418 tmp = tmp->next_screen;
2422 tmp->next_screen = NULL;
2426 clear_line(window->first_line, 0, window->Num_cols);
2431 wclrtobot(window) /* delete from current position to end of the window */
2437 window->SCROLL_CLEAR |= CLEAR;
2438 column = window->LX;
2440 for (row = 0, tmp = window->first_line; row < window->LY; row++)
2441 tmp = tmp->next_screen;
2442 clear_line(tmp, column, window->Num_cols);
2443 for (row = (window->LY + 1); row < window->Num_lines; row++)
2445 tmp = tmp->next_screen;
2446 clear_line(tmp, 0, window->Num_cols);
2448 wmove(window, row, column);
2452 wstandout(window) /* begin standout mode in window */
2455 if (Numbers[sg__] < 1) /* if not magic cookie glitch */
2456 window->Attrib |= A_STANDOUT;
2460 wstandend(window) /* end standout mode in window */
2463 window->Attrib &= ~A_STANDOUT;
2467 waddstr(window, string) /* write 'string' in window */
2473 for (wstring = string; *wstring != (char) NULL; wstring++)
2474 waddch(window, *wstring);
2478 clearok(window, flag) /* erase screen and redraw at next refresh */
2482 Repaint_screen = TRUE;
2486 echo() /* turn on echoing */
2491 Terminal.c_lflag |= ECHO; /* enable echo */
2492 value = ioctl(0, TCSETA, &Terminal); /* set characteristics */
2494 Terminal.sg_flags |= ECHO; /* enable echo */
2495 value = ioctl(0, TIOCSETP, &Terminal); /* set characteristics */
2500 noecho() /* turn off echoing */
2505 Terminal.c_lflag &= ~ECHO; /* disable echo */
2506 value = ioctl(0, TCSETA, &Terminal); /* set characteristics */
2508 Terminal.sg_flags &= ~ECHO; /* disable echo */
2509 value = ioctl(0, TIOCSETP, &Terminal); /* set characteristics */
2514 raw() /* set to read characters immediately */
2519 Intr = Terminal.c_cc[VINTR]; /* get the interrupt character */
2520 Terminal.c_lflag &= ~ICANON; /* disable canonical operation */
2521 Terminal.c_lflag &= ~ISIG; /* disable signal checking */
2523 Terminal.c_lflag &= ~FLUSHO;
2526 Terminal.c_lflag &= ~PENDIN;
2529 Terminal.c_lflag &= ~IEXTEN;
2531 Terminal.c_cc[VMIN] = 1; /* minimum of one character */
2532 Terminal.c_cc[VTIME] = 255; /* timeout value */
2533 Terminal.c_cc[VINTR] = 0; /* eliminate interrupt */
2534 value = ioctl(0, TCSETA, &Terminal); /* set characteristics */
2536 Terminal.sg_flags |= RAW; /* enable raw mode */
2537 value = ioctl(0, TIOCSETP, &Terminal); /* set characteristics */
2542 noraw() /* set to normal character read mode */
2547 Terminal.c_lflag |= ICANON; /* enable canonical operation */
2548 Terminal.c_lflag |= ISIG; /* enable signal checking */
2549 Terminal.c_cc[VEOF] = 4; /* EOF character = 4 */
2550 Terminal.c_cc[VEOL] = (char) NULL; /* EOL = 0 */
2551 Terminal.c_cc[VINTR] = Intr; /* reset interrupt char */
2552 value = ioctl(0, TCSETA, &Terminal); /* set characteristics */
2554 Terminal.sg_flags &= ~RAW; /* disable raw mode */
2555 value = ioctl(0, TIOCSETP, &Terminal); /* set characteristics */
2556 /* old_arg = fcntl(0, F_GETFL, 0);
2557 value = fcntl(0, F_SETFL, old_arg & ~FNDELAY);*/
2567 Terminal.c_iflag |= ICRNL; /* enable carriage-return to line-feed mapping */
2568 value = ioctl(0, TCSETA, &Terminal); /* set characteristics */
2578 Terminal.c_iflag &= ~ICRNL; /* disable carriage-return to line-feed mapping */
2579 Terminal.c_iflag &= ~IGNCR; /* do not ignore carriage-return */
2580 value = ioctl(0, TCSETA, &Terminal); /* set characteristics */
2600 nodelay(window, flag)
2614 keypad(window, flag)
2619 String_Out(String_table[ks__], NULL, 0);
2621 String_Out(String_table[ke__], NULL, 0);
2625 savetty() /* save current tty stats */
2630 value = ioctl(0, TCGETA, &Saved_tty); /* set characteristics */
2632 value = ioctl(0, TIOCGETP, &Saved_tty); /* set characteristics */
2637 resetty() /* restore previous tty stats */
2642 value = ioctl(0, TCSETA, &Saved_tty); /* set characteristics */
2644 value = ioctl(0, TIOCSETP, &Saved_tty); /* set characteristics */
2649 endwin() /* end windows */
2651 keypad(stdscr, FALSE);
2653 initialized = FALSE;
2655 delwin(virtual_scr);
2660 /* old_arg = fcntl(0, F_GETFL, 0);
2661 value = fcntl(0, F_SETFL, old_arg & ~FNDELAY);*/
2667 delwin(window) /* delete the window structure */
2672 for (i = 1; (i < window->Num_lines) && (window->first_line->next_screen != NULL); i++)
2674 window->first_line = window->first_line->next_screen;
2675 free(window->first_line->prev_screen->row);
2676 free(window->first_line->prev_screen->attributes);
2677 free(window->first_line->prev_screen);
2679 if (window == last_window_refreshed)
2680 last_window_refreshed = 0;
2681 if (window->first_line != NULL)
2683 free(window->first_line->row);
2684 free(window->first_line->attributes);
2685 free(window->first_line);
2694 #else /* __STDC__ */
2696 wprintw(WINDOW *window, const char *format, ...)
2697 #endif /* __STDC__ */
2712 window = va_arg(ap, WINDOW *);
2713 format = va_arg(ap, char *);
2714 #else /* __STDC__ */
2715 va_start(ap, format);
2716 #endif /* __STDC__ */
2718 fpoint = (char *) format;
2719 while (*fpoint != (char) NULL)
2726 value = va_arg(ap, int);
2727 iout(window, value);
2729 else if (*fpoint == 'c')
2731 value = va_arg(ap, int);
2732 waddch(window, value);
2734 else if (*fpoint == 's')
2736 wtemp = va_arg(ap, char *);
2737 waddstr(window, wtemp);
2741 else if (*fpoint == '\\')
2745 waddch(window, '\n');
2746 else if ((*fpoint >= '0') && (*fpoint <= '9'))
2749 while ((*fpoint >= '0') && (*fpoint <= '9'))
2751 value = (value * 8) + (*fpoint - '0');
2754 waddch(window, value);
2759 waddch(window, *fpoint++);
2763 #endif /* __STDC__ */
2767 iout(window, value) /* output characters */
2773 if ((i = value / 10) != 0)
2775 waddch(window, ((value % 10) + '0'));
2779 Comp_line(line1, line2) /* compare lines */
2780 struct _line *line1;
2781 struct _line *line2;
2790 att1 = line1->attributes;
2791 att2 = line2->attributes;
2792 count2 = strlen(c1) + 1;
2793 count1 = strlen(c2) + 1;
2794 if (count1 > count2)
2800 if (count2 > (count1 + count1))
2803 while ((c1[i] != (char) NULL) && (c2[i] != (char) NULL) && (c1[i] == c2[i]) && (att1[i] == att2[i]))
2806 if ((count1 == 1) && (count2 == 1))
2807 count1 = 0; /* both lines blank */
2808 else if (count2 == count1)
2809 count1 = -1; /* equal */
2811 count1 = count2 / count1; /* lines unequal */
2816 Insert_line(row, end_row, window) /* insert line into screen */
2825 for (i = 0, tmp = curscr->first_line; i < window->SR; i++)
2826 tmp = tmp->next_screen;
2827 if ((end_row + window->SR) == 0)
2828 curscr->first_line = curscr->first_line->next_screen;
2831 | find bottom line to delete
2833 for (i = 0, tmp = top_of_win; (tmp->next_screen != NULL) && (i < end_row); i++)
2834 tmp = tmp->next_screen;
2835 if (tmp->prev_screen != NULL)
2836 tmp->prev_screen->next_screen = tmp->next_screen;
2837 if (tmp->next_screen != NULL)
2838 tmp->next_screen->prev_screen = tmp->prev_screen;
2841 | clear deleted line
2843 clear_line(tmp, 0, window->Num_cols);
2845 for (i = 0, tmp = curscr->first_line; (tmp->next_screen != NULL) && (i < window->SR); i++)
2846 tmp = tmp->next_screen;
2848 for (i = 0, tmp = top_of_win; i < row; i++)
2849 tmp = tmp->next_screen;
2850 if ((tmp->prev_screen != NULL) && (window->Num_lines > 0))
2851 tmp->prev_screen->next_screen = tmp1;
2852 tmp1->prev_screen = tmp->prev_screen;
2853 tmp->prev_screen = tmp1;
2854 tmp1->next_screen = tmp;
2855 if ((row + window->SR) == 0)
2856 curscr->first_line = tmp1;
2857 if (tmp1->next_screen != NULL)
2858 tmp1 = tmp1->next_screen;
2860 if ((!String_table[cs__]) && (end_row < window->Num_lines))
2862 Position(window, (window->SR + end_row), 0);
2863 String_Out(String_table[dl__], NULL, 0);
2865 Position(window, (window->SR + row), 0);
2866 if (String_table[al__] != NULL)
2867 String_Out(String_table[al__], NULL, 0);
2869 String_Out(String_table[sr__], NULL, 0);
2871 for (i = 0, top_of_win = curscr->first_line; (top_of_win->next_screen != NULL) && (i < window->SR); i++)
2872 top_of_win = top_of_win->next_screen;
2878 Delete_line(row, end_row, window) /* delete a line on screen */
2889 tmp = curscr->first_line;
2890 while (i < window->SR)
2893 tmp = tmp->next_screen;
2896 | find line to delete
2899 if ((row + window->SR) == 0)
2900 curscr->first_line = top_of_win->next_screen;
2901 for (i = 0, tmp = top_of_win; i < row; i++)
2902 tmp = tmp->next_screen;
2903 if (tmp->prev_screen != NULL)
2904 tmp->prev_screen->next_screen = tmp->next_screen;
2905 if (tmp->next_screen != NULL)
2906 tmp->next_screen->prev_screen = tmp->prev_screen;
2907 tmp2 = tmp->next_screen;
2910 | clear deleted line
2912 clear_line(tmp1, 0, window->Num_cols);
2915 | find location to insert deleted line
2917 for (i = 0, tmp = curscr->first_line; (tmp->next_screen != NULL) && (i < window->SR); i++)
2918 tmp = tmp->next_screen;
2920 for (i = 0, tmp = top_of_win; (i < end_row) && (tmp->next_screen != NULL); i++)
2921 tmp = tmp->next_screen;
2922 tmp1->next_screen = tmp;
2923 tmp1->prev_screen = tmp->prev_screen;
2924 if (tmp1->prev_screen != NULL)
2925 tmp1->prev_screen->next_screen = tmp1;
2926 tmp->prev_screen = tmp1;
2928 Position(window, (window->SR + row), 0);
2929 String_Out(String_table[dl__], NULL, 0);
2930 if ((!String_table[cs__]) && (end_row < window->Num_lines))
2932 Position(window, (window->SR + end_row), 0);
2933 String_Out(String_table[al__], NULL, 0);
2935 else if ((String_table[cs__] != NULL) && (String_table[dl__] == NULL))
2937 Position(window, (window->SR + end_row), 0);
2941 if (row == (window->Num_lines-1))
2943 if ((row + window->SR) == 0)
2944 curscr->first_line = top_of_win = tmp2;
2949 CLEAR_TO_EOL(window, row, column)
2956 for (y = 0, tmp1 = curscr->first_line; (y < (window->SR+row)) && (tmp1->next_screen != NULL); y++)
2957 tmp1 = tmp1->next_screen;
2958 for (x = column; x<window->Num_cols; x++)
2961 tmp1->attributes[x] = (char) NULL;
2963 tmp1->row[column] = (char) NULL;
2964 tmp1->last_char = column;
2970 Position(window, row, column);
2973 if (String_table[ce__] != NULL)
2974 String_Out(String_table[ce__], NULL, 0);
2977 for (x = column; x < window->Num_cols; x++)
2985 check_delete(window, line, offset, pointer_new, pointer_old)
2988 struct _line *pointer_new, *pointer_old;
3000 new_lin = pointer_new->row;
3001 new_att = pointer_new->attributes;
3002 old_lin = pointer_old->row;
3003 old_att = pointer_old->attributes;
3004 end_old = end_new = offset;
3005 while (((new_lin[end_new] != old_lin[end_old]) || (new_att[end_new] != old_att[end_old])) && (old_lin[end_old] != (char) NULL) && (new_lin[end_old] != (char) NULL))
3007 if (old_lin[end_old] != (char) NULL)
3010 while ((old_lin[end_old+k] == new_lin[end_new+k]) && (new_att[end_new+k] == old_att[end_old+k]) && (new_lin[end_new+k] != (char) NULL) && (old_lin[end_old+k] != (char) NULL) && (k < 10))
3012 if ((k > 8) || ((new_lin[end_new+k] == (char) NULL) && (k != 0)))
3014 if (new_lin[end_new+k] == (char) NULL)
3016 Position(window, line, (end_new+k));
3017 CLEAR_TO_EOL(window, line, (end_new+k));
3019 Position(window, line, offset);
3020 for (k = offset; k < end_old; k++)
3021 Char_del(old_lin, old_att, offset, window->Num_cols);
3022 while ((old_lin[offset] != (char) NULL) && (offset < COLS))
3024 pointer_old->last_char = offset;
3032 check_insert(window, line, offset, pointer_new, pointer_old)
3035 struct _line *pointer_new, *pointer_old;
3038 int end_old, end_new;
3049 new_lin = pointer_new->row;
3050 new_att = pointer_new->attributes;
3051 old_lin = pointer_old->row;
3052 old_att = pointer_old->attributes;
3053 end_old = end_new = offset;
3054 while (((new_lin[end_new] != old_lin[end_old]) || (new_att[end_new] != old_att[end_old])) && (new_lin[end_new] != (char) NULL) && (old_lin[end_new] != (char) NULL))
3056 if (new_lin[end_new] != (char) NULL)
3059 while ((old_lin[end_old+k] == new_lin[end_new+k]) && (old_att[end_old+k] == new_att[end_new+k]) && (new_lin[end_new+k] != (char) NULL) && (old_lin[end_old+k] != (char) NULL) && (k < 10))
3062 | check for commonality between rest of lines (are the old
3063 | and new lines the same, except for a chunk in the middle?)
3064 | if the rest of the lines are common, do not insert text
3067 while ((old_lin[old_off] != (char) NULL) && (new_lin[old_off] != (char) NULL) && (old_lin[old_off] == new_lin[old_off]) && (old_att[old_off] == new_att[old_off]))
3069 if ((old_lin[old_off] == new_lin[old_off]) && (old_att[old_off] == new_att[old_off]))
3071 if ((!same) && ((k > 8) || ((new_lin[end_new+k] == (char) NULL) && (k != 0))))
3073 Position(window, line, offset);
3075 if (String_table[ic__] == NULL)
3077 String_Out(String_table[im__], NULL, 0);
3080 for (k = offset; k < end_new; k++)
3083 String_Out(String_table[ic__], NULL, 0);
3084 Char_ins(old_lin, old_att, new_lin[k], new_att[k], k, window->Num_cols);
3087 String_Out(String_table[ei__], NULL, 0);
3088 while ((old_lin[offset] != (char) NULL) && (offset < COLS))
3090 pointer_old->last_char = offset;
3103 int begin_old, begin_new;
3104 int end_old, end_new;
3106 int from_top, tmp_ft, offset;
3126 window = virtual_scr;
3130 if (String_table[cl__])
3131 String_Out(String_table[cl__], NULL, 0);
3135 while (from_top < LINES)
3137 Position(curscr, from_top, 0);
3138 if (String_table[ce__] != NULL)
3139 String_Out(String_table[ce__], NULL, 0);
3142 for (j = 0; j < window->Num_cols; j++)
3148 for (from_top = 0, curr = curscr->first_line; from_top < curscr->Num_lines; from_top++, curr = curr->next_screen)
3150 Position(curscr, from_top, 0);
3151 for (j = 0; (curr->row[j] != (char) NULL) && (j < curscr->Num_cols); j++)
3153 Char_out(curr->row[j], curr->attributes[j], curr->row, curr->attributes, j);
3158 Position(curscr, from_top, j);
3162 Repaint_screen = FALSE;
3167 top_of_win = curscr->first_line;
3169 for (from_top = 0, curr = top_of_win, virt = window->first_line;
3170 from_top < window->Num_lines; from_top++)
3172 virtual_lines[from_top] = TRUE;
3173 if ((similar = Comp_line(curr, virt)) > 0)
3175 virtual_lines[from_top] = FALSE;
3178 curr = curr->next_screen;
3179 virt = virt->next_screen;
3183 virt = window->first_line;
3187 | if the window has lines that are different
3193 for (first_same = window->Num_lines;
3194 (first_same > from_top) && (virtual_lines[first_same - 1]);
3197 count1 = first_same - 1;
3199 (last_same < window->Num_lines) && (virtual_lines[last_same]== FALSE);
3202 while ((from_top < first_same) && nc_scrolling_ability)
3203 /* check entire lines for diffs */
3207 if (from_top >= last_same)
3209 for (last_same = from_top;
3210 (last_same < window->Num_lines) &&
3211 (virtual_lines[last_same] == FALSE);
3215 if (!virtual_lines[from_top])
3219 | check for lines deleted (scroll up)
3221 for (tmp_ft = from_top+1, old = curr->next_screen;
3222 ((window->scroll_up) && (diff) &&
3223 (tmp_ft < last_same) &&
3224 (!virtual_lines[tmp_ft]));
3227 if ((Comp_line(old, virt) == -1) && (!virtual_lines[from_top]))
3229 if (String_table[cs__]) /* scrolling region */
3232 list[0] = min((last_same - 1), (window->Num_lines - 1));
3233 String_Out(String_table[cs__], list, 2);
3234 Curr_y = Curr_x = -1;
3237 for (offset = (tmp_ft - from_top); (offset > 0); offset--)
3239 old = Delete_line(from_top, min((last_same - 1), (window->Num_lines - 1)), window);
3243 if (String_table[cs__]) /* scrolling region */
3247 String_Out(String_table[cs__], list, 2);
3248 Curr_y = Curr_x = -1;
3251 top_of_win = curscr->first_line;
3253 for (offset = 0; offset < from_top; offset++)
3254 curr = curr->next_screen;
3255 for (offset = from_top, old=curr, new=virt;
3256 offset < window->Num_lines;
3257 old=old->next_screen, new=new->next_screen,
3260 similar = Comp_line(old, new);
3261 virtual_lines[offset] = (similar > 0 ? FALSE : TRUE);
3265 old = old->next_screen;
3268 | check for lines inserted (scroll down)
3270 for (tmp_ft = from_top-1, old = curr->prev_screen;
3271 ((window->scroll_down) && (tmp_ft >= 0) &&
3273 (!virtual_lines[tmp_ft]));
3276 if (Comp_line(old, virt) == -1)
3278 if (String_table[cs__]) /* scrolling region */
3281 list[0] = min((last_same - 1), (window->Num_lines - 1));
3282 String_Out(String_table[cs__], list, 2);
3283 Curr_y = Curr_x = -1;
3286 for (offset = (from_top - tmp_ft); (offset > 0); offset--)
3288 old = Insert_line(tmp_ft, min((last_same - 1), (window->Num_lines -1)), window);
3292 if (String_table[cs__]) /* scrolling region */
3296 String_Out(String_table[cs__], list, 2);
3297 Curr_y = Curr_x = -1;
3300 top_of_win = curscr->first_line;
3302 for (offset = 0; offset < from_top; offset++)
3303 curr = curr->next_screen;
3304 for (offset = from_top, old=curr, new=virt;
3305 offset < window->Num_lines;
3306 old=old->next_screen, new=new->next_screen,
3309 similar = Comp_line(old, new);
3310 virtual_lines[offset] = (similar > 0 ? FALSE : TRUE);
3314 old = old->prev_screen;
3318 curr = curr->next_screen;
3319 virt = virt->next_screen;
3323 for (from_top = 0, curr = curscr->first_line; from_top < window->SR; from_top++)
3324 curr = curr->next_screen;
3326 for (from_top = 0, curr = top_of_win, virt = window->first_line; from_top < window->Num_lines; from_top++, curr = curr->next_screen, virt = virt->next_screen)
3328 if (((String_table[ic__]) || (String_table[im__])) && (String_table[dc__]) && (curr->row[0] != (char) NULL))
3332 vrt_lin = virt->row;
3333 vrt_att = virt->attributes;
3334 cur_lin = curr->row;
3335 cur_att = curr->attributes;
3336 while ((vrt_lin[j] != (char) NULL) && (j < window->Num_cols))
3338 if ((STAND) && (Booleans[xs__]))
3340 while ((vrt_lin[j] == cur_lin[j]) && (vrt_att[j] == cur_att[j]) && (vrt_lin[j] != (char) NULL) && (vrt_att[j]))
3342 if ((STAND) && (!vrt_att[j]))
3345 Position(window, from_top, j);
3352 while ((vrt_lin[j] == cur_lin[j]) && (vrt_att[j] == cur_att[j]) && (vrt_lin[j] != (char) NULL))
3355 if ((vrt_att[j] != cur_att[j]) && (cur_att[j]) && (Booleans[xs__]))
3357 Position(window, from_top, j);
3358 /* CLEAR_TO_EOL(window, from_top, j);*/
3362 if (vrt_lin[j] != (char) NULL)
3368 if ((first_time) && (virt->changed))
3370 if (curr->last_char <= virt->last_char)
3371 changed = check_insert(window, from_top, j, virt, curr);
3373 changed = check_delete(window, from_top, j, virt, curr);
3375 virt->changed = FALSE;
3377 changed = check_insert(window, from_top, j, virt, curr);
3378 if (((!changed) || (cur_lin[j] != vrt_lin[j]) || (cur_att[j] != vrt_att[j])) && (j < window->Num_cols))
3380 if ((vrt_lin[j] == ' ') && (cur_lin[j] == (char) NULL) && (vrt_att[j] == cur_att[j]))
3384 Position(window, from_top, j);
3385 Char_out(vrt_lin[j], vrt_att[j], cur_lin, cur_att, j);
3388 if ((vrt_lin[j] != (char) NULL))
3391 if ((STAND) && (!vrt_att[j]))
3394 Position(window, from_top, j);
3398 if ((vrt_lin[j] == (char) NULL) && (cur_lin[j] != (char) NULL))
3400 Position(window, from_top, j);
3401 CLEAR_TO_EOL(window, from_top, j);
3404 else /*if ((similar != -1) && (similar != 0))*/
3408 att1 = curr->attributes;
3410 att2 = virt->attributes;
3411 while ((j < window->Num_cols) && (c2[j] != (char) NULL))
3413 while ((c1[j] == c2[j]) && (att1[j] == att2[j]) && (j < window->Num_cols) && (c2[j] != (char) NULL))
3417 if ((j < window->Num_cols) && (c2[j] != (char) NULL))
3419 Position(window, from_top, begin_old);
3420 CLEAR_TO_EOL(window, from_top, j);
3421 Position(window, from_top, begin_old);
3422 for (j = begin_old; (c2[j] != (char) NULL) && (j < window->Num_cols); j++)
3423 Char_out(c2[j], att2[j], c1, att1, j);
3426 if ((c2[j] == (char) NULL) && (c1[j] != (char) NULL))
3428 Position(window, from_top, j);
3429 CLEAR_TO_EOL(window, from_top, j);
3435 Position(window, from_top, j);
3438 virt->number = from_top;
3440 Position(window, window->LY, window->LX);
3444 Position(window, row, col) /* position the cursor for output on the screen */
3455 pos_row = row + window->SR;
3456 pos_column = col + window->SC;
3457 if ((pos_row != Curr_y) || (pos_column != Curr_x))
3459 if (String_table[cm__] != NULL) /* && (row < window->Num_lines) && (column < window->Num_cols))*/
3462 list[place++] = pos_column;
3463 list[place++] = pos_row;
3464 String_Out(String_table[cm__], list, place);
3465 if ((STAND) && (!Booleans[ms__]))
3468 Curr_x = pos_column;
3474 Char_del(line, attrib, offset, maxlen) /* delete chars from line */
3482 for (one = offset, two = offset+1; (line[one] != (char) NULL) && (one < maxlen); one++, two++)
3484 line[one] = line[two];
3485 attrib[one] = attrib[two];
3487 String_Out(String_table[dc__], NULL, 0);
3491 Char_ins(line, attrib, newc, newatt, offset, maxlen) /* insert chars in line */
3502 while ((line[one] != (char) NULL) && (one < (maxlen - 2)))
3504 for (two = one + 1; (two > offset); one--, two--)
3506 line[two] = line[one];
3507 attrib[two] = attrib[one];
3509 line[offset] = newc;
3510 attrib[offset] = newatt;
3511 Char_out(newc, newatt, line, attrib, offset);
3517 if (String_table[sa__])
3519 attributes_set[0] = 1;
3520 String_Out(String_table[sa__], attributes_set, 1);
3522 else if (String_table[so__])
3523 String_Out(String_table[so__], NULL, 0);
3529 if (String_table[me__])
3530 String_Out(String_table[me__], NULL, 0);
3531 else if (String_table[sa__])
3533 attributes_set[0] = 0;
3534 String_Out(String_table[sa__], attributes_set, 1);
3536 else if (String_table[se__])
3537 String_Out(String_table[se__], NULL, 0);
3541 Char_out(newc, newatt, line, attrib, offset) /* output character with proper attribute */
3550 if ((newatt) && (!STAND))
3555 else if ((STAND) && (!newatt))
3561 if ((newatt) && (STAND) && (Booleans[xs__]))
3566 if (!((Curr_y >= (LINES - 1)) && (Curr_x >= (COLS - 1))))
3569 line[offset] = newc;
3570 attrib[offset] = newatt;