1/* 2 | new_curse.c 3 | 4 | A subset of curses developed for use with ae. 5 | 6 | written by Hugh Mahon 7 | |
8 | Copyright (c) 1986, 1987, 1988, 1991, 1992, 1993, 1994, 1995, 2009 Hugh Mahon 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions 13 | are met: 14 | 15 | * Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | * Redistributions in binary form must reproduce the above 18 | copyright notice, this list of conditions and the following 19 | disclaimer in the documentation and/or other materials provided 20 | with the distribution. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | POSSIBILITY OF SUCH DAMAGE. |
34 | |
35 | |
36 | All are rights reserved. 37 | |
38 | $Header: /home/hugh/sources/old_ae/RCS/new_curse.c,v 1.54 2002/09/21 00:47:14 hugh Exp $ |
39 | 40 */ 41 |
42char *copyright_message[] = { "Copyright (c) 1986, 1987, 1988, 1991, 1992, 1993, 1994, 1995, 2009 Hugh Mahon", |
43 "All rights are reserved."}; 44 |
45char * new_curse_name= "@(#) new_curse.c $Revision: 1.54 $"; |
46 47#include "new_curse.h" 48#include <signal.h> 49#include <fcntl.h> 50 51#ifdef SYS5 52#include <string.h> 53#else --- 440 unchanged lines hidden (view full) --- 494int Num_bits; /* number of bits per character */ 495int Flip_Bytes; /* some systems have byte order reversed */ 496int interrupt_flag = FALSE; /* set true if SIGWINCH received */ 497 498#ifndef CAP 499char *Strings; 500#endif 501 |
502#if !defined(TERMCAP) 503#define TERMCAP "/etc/termcap" 504#endif 505 |
506struct KEYS { 507 int length; /* length of string sent by key */ 508 char *string; /* string sent by key */ 509 int value; /* CURSES value of key (9-bit) */ 510 }; 511 512struct KEY_STACK { 513 struct KEYS *element; --- 141 unchanged lines hidden (view full) --- 655int Booleans[128]; 656int Numbers[128]; 657char *String_table[1024]; 658 659int *virtual_lines; 660 661static char nc_scrolling_ability = FALSE; 662 |
663char *terminfo_path[] = { 664 "/usr/lib/terminfo", 665 "/usr/share/lib/terminfo", 666 "/usr/share/terminfo", 667 NULL 668 }; 669 |
670#ifdef CAP 671 672#if defined(__STDC__) || defined(__cplusplus) 673#define P_(s) s 674#else 675#define P_(s) () 676#endif /* __STDC__ */ 677 --- 93 unchanged lines hidden (view full) --- 771 interrupt_flag = TRUE; 772} 773#endif /* SIGWINCH */ 774 775void 776initscr() /* initialize terminal for operations */ 777{ 778 int value; |
779 int counter; |
780 char *lines_string; 781 char *columns_string; 782#ifdef CAP 783 char *pointer; 784#endif /* CAP */ 785 786#ifdef DIAG 787printf("starting initscr \n");fflush(stdout); --- 116 unchanged lines hidden (view full) --- 904 Fildes = -1; 905 TERM_PATH = getenv("TERMINFO"); 906 if (TERM_PATH != NULL) 907 { 908 Data_Line_len = 23 + strlen(TERM_PATH) + strlen(TERMINAL_TYPE); 909 Term_File_name = malloc(Data_Line_len); 910 sprintf(Term_File_name, "%s/%c/%s", TERM_PATH, *TERMINAL_TYPE, TERMINAL_TYPE); 911 Fildes = open(Term_File_name, O_RDONLY); |
912 if (Fildes == -1) 913 { 914 sprintf(Term_File_name, "%s/%x/%s", TERM_PATH, *TERMINAL_TYPE, TERMINAL_TYPE); 915 Fildes = open(Term_File_name, O_RDONLY); 916 } |
917 } |
918 counter = 0; 919 while ((Fildes == -1) && (terminfo_path[counter] != NULL)) |
920 { |
921 TERM_PATH = terminfo_path[counter]; |
922 Data_Line_len = 23 + strlen(TERM_PATH) + strlen(TERMINAL_TYPE); 923 Term_File_name = malloc(Data_Line_len); 924 sprintf(Term_File_name, "%s/%c/%s", TERM_PATH, *TERMINAL_TYPE, TERMINAL_TYPE); 925 Fildes = open(Term_File_name, O_RDONLY); |
926 if (Fildes == -1) 927 { 928 sprintf(Term_File_name, "%s/%x/%s", TERM_PATH, *TERMINAL_TYPE, TERMINAL_TYPE); 929 Fildes = open(Term_File_name, O_RDONLY); 930 } 931 counter++; |
932 } 933 if (Fildes == -1) 934 { |
935 free(Term_File_name); 936 Term_File_name = NULL; 937 } 938 else 939 TERM_INFO = INFO_PARSE(); 940#else 941 /* 942 | termcap information can be in the TERMCAP env variable, if so 943 | use that, otherwise check the /etc/termcap file 944 */ 945 if ((pointer = Term_File_name = getenv("TERMCAP")) != NULL) 946 { 947 if (*Term_File_name != '/') |
948 Term_File_name = TERMCAP; |
949 } 950 else 951 { |
952 Term_File_name = TERMCAP; |
953 } 954 if ((TFP = fopen(Term_File_name, "r")) == NULL) 955 { |
956 printf("unable to open %s file \n", TERMCAP); |
957 exit(0); 958 } 959 for (value = 0; value < 1024; value++) 960 String_table[value] = NULL; 961 for (value = 0; value < 128; value++) 962 Booleans[value] = 0; 963 for (value = 0; value < 128; value++) 964 Numbers[value] = 0; --- 141 unchanged lines hidden (view full) --- 1106 Num_names--; 1107 } 1108 counter = 0; 1109 while (Num_bools) 1110 { 1111 Num_bools--; 1112 Booleans[counter++] = *TERM_data_ptr++; 1113 } |
1114 if ((unsigned long)TERM_data_ptr & 1) /* force alignment */ |
1115 TERM_data_ptr++; 1116 counter = 0; 1117 while (Num_ints) 1118 { 1119 Num_ints--; 1120 Numbers[counter] = Get_int(); 1121 counter++; 1122 } --- 238 unchanged lines hidden (view full) --- 1361} 1362 1363void 1364Find_term() /* find terminal description in termcap file */ 1365{ 1366 char *Name; 1367 char *Ftemp; 1368 |
1369 Ftemp = Name = malloc(strlen(TERMINAL_TYPE) + 2); |
1370 strcpy(Name, TERMINAL_TYPE); 1371 while (*Ftemp != (char)NULL) 1372 Ftemp++; 1373 *Ftemp++ = '|'; 1374 *Ftemp = (char)NULL; 1375 CFOUND = FALSE; 1376 Data_Line_len = strlen(TERMINAL_TYPE) + 1; 1377 while ((!CFOUND) && ((TERM_data_ptr=fgets(Data_Line, 512, TFP)) != NULL)) --- 91 unchanged lines hidden (view full) --- 1469 tmp = (struct _line *) malloc(sizeof (struct _line)); 1470 tmp->row = malloc(columns + 1); 1471 tmp->attributes = malloc(columns + 1); 1472 tmp->prev_screen = NULL; 1473 tmp->next_screen = NULL; 1474 for (i = 0; i < columns; i++) 1475 { 1476 tmp->row[i] = ' '; |
1477 tmp->attributes[i] = '\0'; |
1478 } 1479 tmp->scroll = tmp->changed = FALSE; |
1480 tmp->row[0] = '\0'; 1481 tmp->attributes[0] = '\0'; 1482 tmp->row[columns] = '\0'; 1483 tmp->attributes[columns] = '\0'; |
1484 tmp->last_char = 0; 1485 return(tmp); 1486} 1487 1488WINDOW *newwin(lines, cols, start_l, start_c) 1489int lines, cols; /* number of lines and columns to be in window */ 1490int start_l, start_c; /* starting line and column to be inwindow */ 1491{ --- 368 unchanged lines hidden (view full) --- 1860 { 1861 for (temp = 1; (place != 0); temp++) 1862 { 1863 p[temp] = p_list[--place]; 1864 } 1865 } 1866 delay = 0; 1867 Otemp = string; |
1868 while (*Otemp != '\0') |
1869 { 1870 if (*Otemp == '%') 1871 { 1872 Otemp++; 1873 if ((*Otemp == '?') || (*Otemp == 't') || (*Otemp == 'e') || (*Otemp == ';')) 1874 { 1875 if (*Otemp == '?') 1876 { 1877 Otemp++; 1878 Cond_FLAG = TRUE; 1879 EVAL = TRUE; 1880 while (EVAL) 1881 { 1882 /* 1883 | find the end of the 1884 | conditional statement 1885 */ |
1886 while ((strncmp(Otemp, "%t", 2)) && (*Otemp != '\0')) |
1887 { 1888 /* 1889 | move past '%' 1890 */ 1891 Otemp++; 1892 Cond_place = Operation(Cond_Stack, Cond_place); 1893 } 1894 --- 11 unchanged lines hidden (view full) --- 1906 Otemp++; 1907 } 1908 else /* condition is false */ 1909 { 1910 /* 1911 | find 'else' or end 1912 | of if statement 1913 */ |
1914 while ((strncmp(Otemp, "%e", 2)) && (strncmp(Otemp, "%;", 2)) && (*Otemp != '\0')) |
1915 Otemp++; 1916 /* 1917 | if an 'else' found 1918 */ |
1919 if ((*Otemp != '\0') && (!strncmp(Otemp, "%e", 2))) |
1920 { 1921 Otemp++; 1922 Otemp++; 1923 tchar = Otemp; 1924 /* 1925 | check for 'then' part 1926 */ |
1927 while ((*tchar != '\0') && (strncmp(tchar, "%t", 2)) && (strncmp(tchar, "%;", 2))) |
1928 tchar++; 1929 /* 1930 | if end of string 1931 */ |
1932 if (*tchar == '\0') |
1933 { 1934 EVAL = FALSE; 1935 Cond_FLAG = FALSE; 1936 Otemp = tchar; 1937 } 1938 /* 1939 | if end of if found, 1940 | set up to parse --- 7 unchanged lines hidden (view full) --- 1948 | 'else' 1949 */ 1950 } 1951 /* 1952 | if end of if found, 1953 | get out of if 1954 | statement 1955 */ |
1956 else if ((*Otemp != '\0') && (!strncmp(Otemp, "%;", 2))) |
1957 { 1958 EVAL = FALSE; 1959 Otemp++; 1960 Otemp++; 1961 } 1962 else /* Otemp == NULL */ 1963 { 1964 EVAL = FALSE; 1965 Cond_FLAG = FALSE; 1966 } 1967 } 1968 } 1969 } 1970 else 1971 { 1972 Otemp++; 1973 Cond_FLAG = FALSE; 1974 if (*Otemp != ';') 1975 { |
1976 while ((*Otemp != '\0') && (strncmp(Otemp, "%;", 2))) |
1977 Otemp++; |
1978 if (*Otemp != '\0') |
1979 { 1980 Otemp++; 1981 Otemp++; 1982 } 1983 } 1984 else 1985 Otemp++; 1986 } --- 52 unchanged lines hidden (view full) --- 2039{ 2040 int j; 2041 2042 if (column > line->last_char) 2043 { 2044 for (j = line->last_char; j < column; j++) 2045 { 2046 line->row[j] = ' '; |
2047 line->attributes[j] = '\0'; |
2048 } 2049 } 2050 line->last_char = column; |
2051 line->row[column] = '\0'; 2052 line->attributes[column] = '\0'; |
2053 line->changed = TRUE; 2054} 2055 2056void 2057werase(window) /* clear the specified window */ 2058WINDOW *window; 2059{ 2060 int i; --- 115 unchanged lines hidden (view full) --- 2176 } 2177 for (user_col = user_line->last_char, 2178 virt_col = window->SC + user_line->last_char; 2179 (virt_col < virtual_scr->Num_cols) 2180 && (user_col < window->Num_cols); 2181 virt_col++, user_col++) 2182 { 2183 virtual_line->row[virt_col] = ' '; |
2184 virtual_line->attributes[virt_col] = '\0'; |
2185 } 2186 } 2187 if (virtual_scr->Num_cols != window->Num_cols) 2188 { 2189 if (virtual_line->last_char < (user_line->last_char + window->SC)) 2190 { |
2191 if (virtual_line->row[virtual_line->last_char] == '\0') |
2192 virtual_line->row[virtual_line->last_char] = ' '; 2193 virtual_line->last_char = 2194 min(virtual_scr->Num_cols, 2195 (user_line->last_char + window->SC)); 2196 } 2197 } 2198 else 2199 virtual_line->last_char = user_line->last_char; |
2200 virtual_line->row[virtual_line->last_char] = '\0'; |
2201 virtual_line->changed = user_line->changed; 2202 virtual_line = virtual_line->next_screen; 2203 user_line = user_line->next_screen; 2204 } 2205 window->SCROLL_CLEAR = FALSE; 2206 window->scroll_up = window->scroll_down = 0; 2207 last_window_refreshed = window; 2208} --- 128 unchanged lines hidden (view full) --- 2337 struct KEY_STACK *St_point; 2338#if (!defined( BSD_SELECT)) || (!defined(SYS5)) 2339 int value; 2340#endif /* BSD_SELECT */ 2341 2342 Count = 0; 2343 Gtemp = string; 2344 string[Count++] = first_char; |
2345 string[Count] = '\0'; |
2346 Time_Out = FALSE; 2347#ifndef BSD_SELECT 2348 signal(SIGALRM, Clear); 2349 value = alarm(1); 2350#endif /* BSD_SELECT */ 2351 Noblock = TRUE; 2352#ifdef SYS5 2353 Gterminal.c_cc[VTIME] = 0; /* timeout value */ --- 7 unchanged lines hidden (view full) --- 2361 in_char = wgetch(stdscr); 2362#ifdef DEBUG 2363fprintf(stderr, "back in GetKey()\n"); 2364fflush(stderr); 2365#endif /* DEBUG */ 2366 if (in_char != -1) 2367 { 2368 string[Count++] = in_char; |
2369 string[Count] = '\0'; |
2370 St_point = KEY_TOS; 2371 while ((St_point != NULL) && (!Found)) 2372 { 2373 if (!strcmp(string, St_point->element->string)) 2374 Found = TRUE; 2375 else 2376 St_point = St_point->next; 2377 } --- 69 unchanged lines hidden (view full) --- 2447 tmpline->attributes[column] = window->Attrib; 2448 tmpline->changed = TRUE; 2449 if (column >= tmpline->last_char) 2450 { 2451 if (column > tmpline->last_char) 2452 for (j = tmpline->last_char; j < column; j++) 2453 { 2454 tmpline->row[j] = ' '; |
2455 tmpline->attributes[j] = '\0'; |
2456 } |
2457 tmpline->row[column + 1] = '\0'; 2458 tmpline->attributes[column + 1] = '\0'; |
2459 tmpline->last_char = column + 1; 2460 } 2461 } 2462 if (c == '\n') 2463 { 2464 wclrtoeol(window); 2465 window->LX = window->Num_cols; 2466 } --- 161 unchanged lines hidden (view full) --- 2628 2629void 2630waddstr(window, string) /* write 'string' in window */ 2631WINDOW *window; 2632char *string; 2633{ 2634 char *wstring; 2635 |
2636 for (wstring = string; *wstring != '\0'; wstring++) |
2637 waddch(window, *wstring); 2638} 2639 2640void 2641clearok(window, flag) /* erase screen and redraw at next refresh */ 2642WINDOW *window; 2643int flag; 2644{ --- 61 unchanged lines hidden (view full) --- 2706noraw() /* set to normal character read mode */ 2707{ 2708 int value; 2709 2710#ifdef SYS5 2711 Terminal.c_lflag |= ICANON; /* enable canonical operation */ 2712 Terminal.c_lflag |= ISIG; /* enable signal checking */ 2713 Terminal.c_cc[VEOF] = 4; /* EOF character = 4 */ |
2714 Terminal.c_cc[VEOL] = '\0'; /* EOL = 0 */ |
2715 Terminal.c_cc[VINTR] = Intr; /* reset interrupt char */ 2716 value = ioctl(0, TCSETA, &Terminal); /* set characteristics */ 2717#else 2718 Terminal.sg_flags &= ~RAW; /* disable raw mode */ 2719 value = ioctl(0, TIOCSETP, &Terminal); /* set characteristics */ 2720/* old_arg = fcntl(0, F_GETFL, 0); 2721 value = fcntl(0, F_SETFL, old_arg & ~FNDELAY);*/ 2722#endif --- 151 unchanged lines hidden (view full) --- 2874 va_start(ap); 2875 window = va_arg(ap, WINDOW *); 2876 format = va_arg(ap, char *); 2877#else /* __STDC__ */ 2878 va_start(ap, format); 2879#endif /* __STDC__ */ 2880 2881 fpoint = (char *) format; |
2882 while (*fpoint != '\0') |
2883 { 2884 if (*fpoint == '%') 2885 { 2886 fpoint++; 2887 if (*fpoint == 'd') 2888 { 2889 value = va_arg(ap, int); 2890 iout(window, value); --- 60 unchanged lines hidden (view full) --- 2951 if (line1->last_char != line2->last_char) 2952 return(2); 2953 2954 c1 = line1->row; 2955 c2 = line2->row; 2956 att1 = line1->attributes; 2957 att2 = line2->attributes; 2958 i = 0; |
2959 while ((c1[i] != '\0') && (c2[i] != '\0') && (c1[i] == c2[i]) && (att1[i] == att2[i])) |
2960 i++; 2961 count1 = i + 1; |
2962 if ((count1 == 1) && (c1[i] == '\0') && (c2[i] == '\0')) |
2963 count1 = 0; /* both lines blank */ |
2964 else if ((c1[i] == '\0') && (c2[i] == '\0')) |
2965 count1 = -1; /* equal */ 2966 else 2967 count1 = 1; /* lines unequal */ 2968 return(count1); 2969} 2970 2971struct _line * 2972Insert_line(row, end_row, window) /* insert line into screen */ --- 136 unchanged lines hidden (view full) --- 3109 int x, y; 3110 struct _line *tmp1; 3111 3112 for (y = 0, tmp1 = curscr->first_line; (y < (window->SR+row)) && (tmp1->next_screen != NULL); y++) 3113 tmp1 = tmp1->next_screen; 3114 for (x = column; x<window->Num_cols; x++) 3115 { 3116 tmp1->row[x] = ' '; |
3117 tmp1->attributes[x] = '\0'; |
3118 } |
3119 tmp1->row[column] = '\0'; |
3120 tmp1->last_char = column; 3121 if (column < COLS) 3122 { 3123 if (STAND) 3124 { 3125 STAND = FALSE; 3126 Position(window, row, column); 3127 attribute_off(); --- 25 unchanged lines hidden (view full) --- 3153 char *new_att; 3154 3155 changed = FALSE; 3156 new_lin = pointer_new->row; 3157 new_att = pointer_new->attributes; 3158 old_lin = pointer_old->row; 3159 old_att = pointer_old->attributes; 3160 end_old = end_new = offset; |
3161 while (((new_lin[end_new] != old_lin[end_old]) || (new_att[end_new] != old_att[end_old])) && (old_lin[end_old] != '\0') && (new_lin[end_old] != '\0')) |
3162 end_old++; |
3163 if (old_lin[end_old] != '\0') |
3164 { 3165 k = 0; |
3166 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] != '\0') && (old_lin[end_old+k] != '\0') && (k < 10)) |
3167 k++; |
3168 if ((k > 8) || ((new_lin[end_new+k] == '\0') && (k != 0))) |
3169 { |
3170 if (new_lin[end_new+k] == '\0') |
3171 { 3172 Position(window, line, (end_new+k)); 3173 CLEAR_TO_EOL(window, line, (end_new+k)); 3174 } 3175 Position(window, line, offset); 3176 for (k = offset; k < end_old; k++) 3177 Char_del(old_lin, old_att, offset, window->Num_cols); |
3178 while ((old_lin[offset] != '\0') && (offset < COLS)) |
3179 offset++; 3180 pointer_old->last_char = offset; 3181 changed = TRUE; 3182 } 3183 } 3184 return(changed); 3185} 3186 --- 20 unchanged lines hidden (view full) --- 3207 char *new_att; 3208 3209 changed = FALSE; 3210 new_lin = pointer_new->row; 3211 new_att = pointer_new->attributes; 3212 old_lin = pointer_old->row; 3213 old_att = pointer_old->attributes; 3214 end_old = end_new = offset; |
3215 while (((new_lin[end_new] != old_lin[end_old]) || (new_att[end_new] != old_att[end_old])) && (new_lin[end_new] != '\0') && (old_lin[end_new] != '\0')) |
3216 end_new++; |
3217 if (new_lin[end_new] != '\0') |
3218 { 3219 k = 0; |
3220 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] != '\0') && (old_lin[end_old+k] != '\0') && (k < 10)) |
3221 k++; 3222 /* 3223 | check for commonality between rest of lines (are the old 3224 | and new lines the same, except for a chunk in the middle?) 3225 | if the rest of the lines are common, do not insert text 3226 */ 3227 old_off = end_new; |
3228 while ((old_lin[old_off] != '\0') && (new_lin[old_off] != '\0') && (old_lin[old_off] == new_lin[old_off]) && (old_att[old_off] == new_att[old_off])) |
3229 old_off++; 3230 if ((old_lin[old_off] == new_lin[old_off]) && (old_att[old_off] == new_att[old_off])) 3231 same = TRUE; |
3232 if ((!same) && ((k > 8) || ((new_lin[end_new+k] == '\0') && (k != 0)))) |
3233 { 3234 Position(window, line, offset); 3235 insert = FALSE; 3236 if (String_table[ic__] == NULL) 3237 { 3238 String_Out(String_table[im__], NULL, 0); 3239 insert = TRUE; 3240 } 3241 for (k = offset; k < end_new; k++) 3242 { 3243 if (!insert) 3244 String_Out(String_table[ic__], NULL, 0); 3245 Char_ins(old_lin, old_att, new_lin[k], new_att[k], k, window->Num_cols); 3246 } 3247 if (insert) 3248 String_Out(String_table[ei__], NULL, 0); |
3249 while ((old_lin[offset] != '\0') && (offset < COLS)) |
3250 offset++; 3251 pointer_old->last_char = offset; 3252 changed = TRUE; 3253 } 3254 } 3255 return(changed); 3256} 3257 --- 54 unchanged lines hidden (view full) --- 3312 putchar(' '); 3313 } 3314 from_top++; 3315 } 3316 } 3317 for (from_top = 0, curr = curscr->first_line; from_top < curscr->Num_lines; from_top++, curr = curr->next_screen) 3318 { 3319 Position(curscr, from_top, 0); |
3320 for (j = 0; (curr->row[j] != '\0') && (j < curscr->Num_cols); j++) |
3321 { 3322 Char_out(curr->row[j], curr->attributes[j], curr->row, curr->attributes, j); 3323 } 3324 if (STAND) 3325 { 3326 STAND = FALSE; 3327 Position(curscr, from_top, j); 3328 attribute_off(); --- 205 unchanged lines hidden (view full) --- 3534 /* 3535 | If either 'insert mode' or 'insert char' are 3536 | available, enter the following 'if' statement, 3537 | else, need to simply rewrite the contents of the line 3538 | at the point where the contents of the line change. 3539 */ 3540 3541 if (((String_table[ic__]) || (String_table[im__])) && |
3542 (String_table[dc__]) && (curr->row[0] != '\0') && |
3543 (!NC_chinese)) 3544 { 3545 j = 0; 3546 first_time = TRUE; 3547 vrt_lin = virt->row; 3548 vrt_att = virt->attributes; 3549 cur_lin = curr->row; 3550 cur_att = curr->attributes; |
3551 while ((vrt_lin[j] != '\0') && (j < window->Num_cols)) |
3552 { 3553 if ((STAND) && (Booleans[xs__])) 3554 { |
3555 while ((vrt_lin[j] == cur_lin[j]) && (vrt_att[j] == cur_att[j]) && (vrt_lin[j] != '\0') && (vrt_att[j])) |
3556 j++; 3557 if ((STAND) && (!vrt_att[j])) 3558 { 3559 STAND = FALSE; 3560 Position(window, from_top, j); 3561 attribute_off(); 3562 attribute_off(); 3563 } 3564 } 3565 else 3566 { |
3567 while ((vrt_lin[j] == cur_lin[j]) && (vrt_att[j] == cur_att[j]) && (vrt_lin[j] != '\0')) |
3568 j++; 3569 } 3570 if ((vrt_att[j] != cur_att[j]) && (cur_att[j]) && (Booleans[xs__])) 3571 { 3572 Position(window, from_top, j); 3573/* CLEAR_TO_EOL(window, from_top, j);*/ 3574 attribute_off(); 3575 attribute_off(); 3576 } |
3577 if (vrt_lin[j] != '\0') |
3578 { 3579 begin_new = j; 3580 begin_old = j; 3581 end_old = j; 3582 end_new = j; 3583 if ((first_time) && (virt->changed)) 3584 { 3585 if (curr->last_char <= virt->last_char) 3586 changed = check_insert(window, from_top, j, virt, curr); 3587 } 3588 changed = check_delete(window, from_top, j, virt, curr); 3589 first_time = FALSE; 3590 virt->changed = FALSE; 3591 if (!changed) 3592 changed = check_insert(window, from_top, j, virt, curr); 3593 if (((!changed) || (cur_lin[j] != vrt_lin[j]) || (cur_att[j] != vrt_att[j])) && (j < window->Num_cols)) 3594 { |
3595 if ((vrt_lin[j] == ' ') && (cur_lin[j] == '\0') && (vrt_att[j] == cur_att[j])) |
3596 cur_lin[j] = ' '; 3597 else 3598 { 3599 Position(window, from_top, j); 3600 Char_out(vrt_lin[j], vrt_att[j], cur_lin, cur_att, j); 3601 } 3602 } |
3603 if ((vrt_lin[j] != '\0')) |
3604 j++; 3605 } 3606 if ((STAND) && (!vrt_att[j])) 3607 { 3608 STAND = FALSE; 3609 Position(window, from_top, j); 3610 attribute_off(); 3611 } 3612 } |
3613 if ((vrt_lin[j] == '\0') && (cur_lin[j] != '\0')) |
3614 { 3615 Position(window, from_top, j); 3616 CLEAR_TO_EOL(window, from_top, j); 3617 } 3618 } 3619 else /*if ((similar != -1) && (similar != 0))*/ 3620 { 3621 j = 0; 3622 c1 = curr->row; 3623 att1 = curr->attributes; 3624 c2 = virt->row; 3625 att2 = virt->attributes; |
3626 while ((j < window->Num_cols) && (c2[j] != '\0')) |
3627 { |
3628 while ((c1[j] == c2[j]) && (att1[j] == att2[j]) && (j < window->Num_cols) && (c2[j] != '\0')) |
3629 j++; 3630 3631 /* 3632 | if previous character is an eight bit 3633 | char, start redraw from that character 3634 */ 3635 3636 if ((NC_chinese) && (highbitset(c1[j - 1]))) 3637 j--; 3638 begin_old = j; 3639 begin_new = j; |
3640 if ((j < window->Num_cols) && (c2[j] != '\0')) |
3641 { 3642 Position(window, from_top, begin_old); 3643 CLEAR_TO_EOL(window, from_top, j); 3644 Position(window, from_top, begin_old); |
3645 for (j = begin_old; (c2[j] != '\0') && (j < window->Num_cols); j++) |
3646 Char_out(c2[j], att2[j], c1, att1, j); 3647 } 3648 } |
3649 if ((c2[j] == '\0') && (c1[j] != '\0')) |
3650 { 3651 Position(window, from_top, j); 3652 CLEAR_TO_EOL(window, from_top, j); 3653 } 3654 } 3655 if (STAND) 3656 { 3657 STAND = FALSE; --- 39 unchanged lines hidden (view full) --- 3697Char_del(line, attrib, offset, maxlen) /* delete chars from line */ 3698char *line; 3699char *attrib; 3700int offset; 3701int maxlen; 3702{ 3703 int one, two; 3704 |
3705 for (one = offset, two = offset+1; (line[one] != '\0') && (one < maxlen); one++, two++) |
3706 { 3707 line[one] = line[two]; 3708 attrib[one] = attrib[two]; 3709 } 3710 String_Out(String_table[dc__], NULL, 0); 3711} 3712 3713void 3714Char_ins(line, attrib, newc, newatt, offset, maxlen) /* insert chars in line */ 3715char *line; 3716char *attrib; 3717char newc; 3718char newatt; 3719int offset; 3720int maxlen; 3721{ 3722 int one, two; 3723 3724 one = 0; |
3725 while ((line[one] != '\0') && (one < (maxlen - 2))) |
3726 one++; 3727 for (two = one + 1; (two > offset); one--, two--) 3728 { 3729 line[two] = line[one]; 3730 attrib[two] = attrib[one]; 3731 } 3732 line[offset] = newc; 3733 attrib[offset] = newatt; --- 86 unchanged lines hidden --- |