1/* 2 | ee (easy editor) 3 | 4 | An easy to use, simple screen oriented editor. 5 | 6 | written by Hugh Mahon 7 | |
8 | |
9 | Copyright (c) 2009, Hugh Mahon 10 | All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions 14 | are met: 15 | 16 | * Redistributions of source code must retain the above copyright 17 | notice, this list of conditions and the following disclaimer. 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the following 20 | disclaimer in the documentation and/or other materials provided 21 | with the distribution. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | POSSIBILITY OF SUCH DAMAGE. |
35 | |
36 | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
37 | |
38 | This editor was purposely developed to be simple, both in 39 | interface and implementation. This editor was developed to 40 | address a specific audience: the user who is new to computers 41 | (especially UNIX). 42 | 43 | ee is not aimed at technical users; for that reason more 44 | complex features were intentionally left out. In addition, 45 | ee is intended to be compiled by people with little computer 46 | experience, which means that it needs to be small, relatively 47 | simple in implementation, and portable. 48 | 49 | This software and documentation contains 50 | proprietary information which is protected by 51 | copyright. All rights are reserved. 52 | |
53 | $Header: /home/hugh/sources/old_ae/RCS/ee.c,v 1.102 2009/02/17 03:22:50 hugh Exp hugh $ |
54 | 55 */ 56 57#include <sys/cdefs.h> |
58__FBSDID("$FreeBSD: head/contrib/ee/ee.c 192914 2009-05-27 17:27:03Z ed $"); |
59 60char *ee_copyright_message = |
61"Copyright (c) 1986, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2009 Hugh Mahon "; |
62 |
63#include "ee_version.h" |
64 |
65char *version = "@(#) ee, version " EE_VERSION " $Revision: 1.102 $"; |
66 67#ifdef NCURSE 68#include "new_curse.h" 69#elif HAS_NCURSES 70#include <ncurses.h> 71#else 72#include <curses.h> 73#endif 74 75#ifdef HAS_CTYPE 76#include <ctype.h> 77#endif |
78 |
79#include <signal.h> |
80#include <fcntl.h> |
81#include <sys/types.h> 82#include <sys/stat.h> |
83#include <errno.h> 84#include <string.h> 85#include <pwd.h> 86 |
87#ifdef HAS_SYS_WAIT 88#include <sys/wait.h> 89#endif |
90 |
91#ifdef HAS_STDLIB 92#include <stdlib.h> 93#endif |
94 95#ifdef HAS_STDARG 96#include <stdarg.h> 97#endif 98 |
99#ifdef HAS_UNISTD 100#include <unistd.h> 101#endif 102 |
103 |
104#ifndef NO_CATGETS 105#include <locale.h> 106#include <nl_types.h> 107 108nl_catd catalog; 109#else 110#define catgetlocal(a, b) (b) 111#endif /* NO_CATGETS */ --- 35 unchanged lines hidden (view full) --- 147 148struct files *top_of_stack = NULL; 149 150int d_wrd_len; /* length of deleted word */ 151int position; /* offset in bytes from begin of line */ 152int scr_pos; /* horizontal position */ 153int scr_vert; /* vertical position on screen */ 154int scr_horz; /* horizontal position on screen */ |
155int absolute_lin; /* number of lines from top */ |
156int tmp_vert, tmp_horz; 157int input_file; /* indicate to read input file */ 158int recv_file; /* indicate reading a file */ 159int edit; /* continue executing while true */ 160int gold; /* 'gold' function key pressed */ 161int fildes; /* file descriptor */ 162int case_sen; /* case sensitive search flag */ 163int last_line; /* last line for text display */ --- 36 unchanged lines hidden (view full) --- 200unsigned char *srch_2; /* pointer to next character of string */ 201unsigned char *srch_3; 202unsigned char *in_file_name = NULL; /* name of input file */ 203char *tmp_file; /* temporary file name */ 204unsigned char *d_char; /* deleted character */ 205unsigned char *d_word; /* deleted word */ 206unsigned char *d_line; /* deleted line */ 207char in_string[513]; /* buffer for reading a file */ |
208unsigned char *print_command = (unsigned char *)"lpr"; /* string to use for the print command */ |
209unsigned char *start_at_line = NULL; /* move to this line at start of session*/ |
210int in; /* input character */ 211 212FILE *temp_fp; /* temporary file pointer */ 213FILE *bit_bucket; /* file pointer to /dev/null */ 214 215char *table[] = { 216 "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "\t", "^J", 217 "^K", "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", 218 "^V", "^W", "^X", "^Y", "^Z", "^[", "^\\", "^]", "^^", "^_" 219 }; 220 221WINDOW *com_win; 222WINDOW *text_win; 223WINDOW *help_win; 224WINDOW *info_win; |
225 226#if defined(__STDC__) || defined(__cplusplus) 227#define P_(s) s 228#else 229#define P_(s) () 230#endif 231 232 --- 104 unchanged lines hidden (view full) --- 337void ispell_op P_((void)); 338int first_word_len P_((struct text *test_line)); 339void Auto_Format P_((void)); 340void modes_op P_((void)); 341char *is_in_string P_((char *string, char *substring)); 342char *resolve_name P_((char *name)); 343int restrict_mode P_((void)); 344int unique_test P_((char *string, char *list[])); |
345void strings_init P_((void)); 346 347#undef P_ 348/* 349 | allocate space here for the strings that will be in the menu 350 */ 351 352struct menu_entries modes_menu[] = { --- 177 unchanged lines hidden (view full) --- 530char *NOEMACS_string; 531char *conf_dump_err_msg; 532char *conf_dump_success_msg; 533char *conf_not_saved_msg; 534char *ree_no_file_msg; 535char *cancel_string; 536char *menu_too_lrg_msg; 537char *more_above_str, *more_below_str; |
538char *separator = "==============================================================================="; |
539 540char *chinese_cmd, *nochinese_cmd; 541 |
542#ifndef __STDC__ 543#ifndef HAS_STDLIB 544extern char *malloc(); 545extern char *realloc(); 546extern char *getenv(); 547FILE *fopen(); /* declaration for open function */ 548#endif /* HAS_STDLIB */ 549#endif /* __STDC__ */ |
550 551int 552main(argc, argv) /* beginning of main program */ 553int argc; 554char *argv[]; 555{ |
556 int counter; |
557 |
558 for (counter = 1; counter < 24; counter++) 559 signal(counter, SIG_IGN); 560 |
561 signal(SIGCHLD, SIG_DFL); 562 signal(SIGSEGV, SIG_DFL); 563 signal(SIGINT, edit_abort); |
564 d_char = malloc(3); /* provide a buffer for multi-byte chars */ 565 d_word = malloc(150); |
566 *d_word = '\0'; |
567 d_line = NULL; 568 dlt_line = txtalloc(); 569 dlt_line->line = d_line; 570 dlt_line->line_length = 0; 571 curr_line = first_line = txtalloc(); 572 curr_line->line = point = malloc(10); 573 curr_line->line_length = 1; 574 curr_line->max_length = 10; 575 curr_line->prev_line = NULL; 576 curr_line->next_line = NULL; 577 curr_line->line_number = 1; 578 srch_str = NULL; 579 u_srch_str = NULL; 580 position = 1; 581 scr_pos =0; 582 scr_vert = 0; 583 scr_horz = 0; |
584 absolute_lin = 1; 585 bit_bucket = fopen("/dev/null", "w"); |
586 edit = TRUE; 587 gold = case_sen = FALSE; 588 shell_fork = TRUE; 589 strings_init(); 590 ee_init(); 591 if (argc > 0 ) 592 get_options(argc, argv); 593 set_up_term(); --- 12 unchanged lines hidden (view full) --- 606 wprintw(com_win, no_file_string); 607 wrefresh(com_win); 608 } 609 else 610 check_fp(); 611 612 clear_com_win = TRUE; 613 |
614 counter = 0; 615 |
616 while(edit) 617 { |
618 /* 619 | display line and column information 620 */ |
621 if (info_window) 622 { |
623 if (!nohighlight) |
624 wstandout(info_win); 625 wmove(info_win, 5, 0); 626 wprintw(info_win, separator); 627 wmove(info_win, 5, 5); 628 wprintw(info_win, "line %d col %d lines from top %d ", 629 curr_line->line_number, scr_horz, absolute_lin); 630 wstandend(info_win); 631 wrefresh(info_win); |
632 } 633 |
634 wrefresh(text_win); |
635 in = wgetch(text_win); 636 if (in == -1) |
637 exit(0); /* without this exit ee will go into an 638 infinite loop if the network 639 session detaches */ |
640 641 resize_check(); 642 643 if (clear_com_win) 644 { 645 clear_com_win = FALSE; 646 wmove(com_win, 0, 0); 647 werase(com_win); --- 158 unchanged lines hidden (view full) --- 806 { 807 if (del_width == 1) 808 *d_char = *point; /* save deleted character */ 809 else 810 { 811 d_char[0] = *point; 812 d_char[1] = *(point + 1); 813 } |
814 d_char[del_width] = '\0'; |
815 } 816 while (temp_pos <= curr_line->line_length) 817 { 818 temp_pos++; 819 *tp = *temp2; 820 tp++; 821 temp2++; 822 } 823 if (scr_horz < horiz_offset) 824 { 825 horiz_offset -= 8; 826 midscreen(scr_vert, point); 827 } 828 } 829 else if (curr_line->prev_line != NULL) 830 { |
831 absolute_lin--; |
832 text_changes = TRUE; 833 left(disp); /* go to previous line */ 834 temp_buff = curr_line->next_line; 835 point = resiz_line(temp_buff->line_length, curr_line, position); 836 if (temp_buff->next_line != NULL) 837 temp_buff->next_line->prev_line = curr_line; 838 curr_line->next_line = temp_buff->next_line; |
839 temp2 = temp_buff->line; 840 if (in == 8) 841 { 842 d_char[0] = '\n'; |
843 d_char[1] = '\0'; |
844 } 845 tp = point; 846 temp_pos = 1; 847 while (temp_pos < temp_buff->line_length) 848 { 849 curr_line->line_length++; 850 temp_pos++; 851 *tp = *temp2; 852 tp++; 853 temp2++; 854 } |
855 *tp = '\0'; |
856 free(temp_buff->line); 857 free(temp_buff); 858 temp_buff = curr_line; 859 temp_vert = scr_vert; 860 scr_pos = scr_horz; 861 if (scr_vert < last_line) 862 { 863 wmove(text_win, scr_vert + 1, 0); --- 72 unchanged lines hidden (view full) --- 936 937int 938out_char(window, character, column) /* output non-printing character */ 939WINDOW *window; 940char character; 941int column; 942{ 943 int i1, i2; |
944 char *string; |
945 char string2[8]; 946 947 if (character == TAB) 948 { 949 i1 = tabshift(column); 950 for (i2 = 0; 951 (i2 < i1) && (((column+i2+1)-horiz_offset) < last_col); i2++) 952 { --- 11 unchanged lines hidden (view full) --- 964 string = "^?"; 965 else if (!eightbit) 966 { 967 sprintf(string2, "<%d>", (character < 0) ? (character + 256) : character); 968 string = string2; 969 } 970 else 971 { |
972 waddch(window, (char)character ); |
973 return(1); 974 } 975 } 976 else 977 { |
978 waddch(window, (char)character); |
979 return(1); 980 } |
981 for (i2 = 0; (string[i2] != '\0') && (((column+i2+1)-horiz_offset) < last_col); i2++) |
982 waddch(window, string[i2]); 983 return(strlen(string)); 984} 985 986int 987len_char(character, column) /* return the length of the character */ 988char character; 989int column; /* the column must be known to provide spacing for tabs */ --- 85 unchanged lines hidden (view full) --- 1075 1076 text_changes = TRUE; 1077 wmove(text_win, scr_vert, (scr_horz - horiz_offset)); 1078 wclrtoeol(text_win); 1079 temp_nod= txtalloc(); 1080 temp_nod->line = extra= malloc(10); 1081 temp_nod->line_length = 1; 1082 temp_nod->max_length = 10; |
1083 temp_nod->line_number = curr_line->line_number + 1; |
1084 temp_nod->next_line = curr_line->next_line; |
1085 if (temp_nod->next_line != NULL) 1086 temp_nod->next_line->prev_line = temp_nod; 1087 temp_nod->prev_line = curr_line; 1088 curr_line->next_line = temp_nod; 1089 temp_pos2 = position; 1090 temp = point; 1091 if (temp_pos2 < curr_line->line_length) 1092 { --- 5 unchanged lines hidden (view full) --- 1098 temp_nod->line_length++; 1099 temp_pos++; 1100 temp_pos2++; 1101 *extra= *temp; 1102 extra++; 1103 temp++; 1104 } 1105 temp=point; |
1106 *temp = '\0'; |
1107 temp = resiz_line((1 - temp_nod->line_length), curr_line, position); 1108 curr_line->line_length = 1 + temp - curr_line->line; 1109 } 1110 curr_line->line_length = position; |
1111 absolute_lin++; |
1112 curr_line = temp_nod; |
1113 *extra = '\0'; |
1114 position = 1; 1115 point= curr_line->line; 1116 if (disp) 1117 { 1118 if (scr_vert < last_line) 1119 { 1120 scr_vert++; 1121 wclrtoeol(text_win); --- 26 unchanged lines hidden (view full) --- 1148struct files *name_alloc() /* allocate space for file name list node */ 1149{ 1150 return((struct files *) malloc(sizeof( struct files))); 1151} 1152 1153unsigned char *next_word(string) /* move to next word in string */ 1154unsigned char *string; 1155{ |
1156 while ((*string != '\0') && ((*string != 32) && (*string != 9))) |
1157 string++; |
1158 while ((*string != '\0') && ((*string == 32) || (*string == 9))) |
1159 string++; 1160 return(string); 1161} 1162 1163void 1164prev_word() /* move to start of previous word in text */ 1165{ 1166 if (position != 1) --- 17 unchanged lines hidden (view full) --- 1184void 1185control() /* use control for commands */ 1186{ 1187 char *string; 1188 1189 if (in == 1) /* control a */ 1190 { 1191 string = get_string(ascii_code_str, TRUE); |
1192 if (*string != '\0') |
1193 { 1194 in = atoi(string); 1195 wmove(text_win, scr_vert, (scr_horz - horiz_offset)); 1196 insert(in); 1197 } 1198 free(string); 1199 } 1200 else if (in == 2) /* control b */ --- 91 unchanged lines hidden (view full) --- 1292 undel_line(); 1293 else if (in == 13) /* control m */ 1294 insert_line(TRUE); 1295 else if (in == 14) /* control n */ 1296 down(); 1297 else if (in == 15) /* control o */ 1298 { 1299 string = get_string(ascii_code_str, TRUE); |
1300 if (*string != '\0') |
1301 { 1302 in = atoi(string); 1303 wmove(text_win, scr_vert, (scr_horz - horiz_offset)); 1304 insert(in); 1305 } 1306 free(string); 1307 } 1308 else if (in == 16) /* control p */ --- 23 unchanged lines hidden (view full) --- 1332 menu_op(main_menu); 1333 } 1334} 1335 1336void 1337bottom() /* go to bottom of file */ 1338{ 1339 while (curr_line->next_line != NULL) |
1340 { |
1341 curr_line = curr_line->next_line; |
1342 absolute_lin++; 1343 } |
1344 point = curr_line->line; 1345 if (horiz_offset) 1346 horiz_offset = 0; 1347 position = 1; 1348 midscreen(last_line, point); 1349 scr_pos = scr_horz; 1350} 1351 1352void 1353top() /* go to top of file */ 1354{ 1355 while (curr_line->prev_line != NULL) |
1356 { |
1357 curr_line = curr_line->prev_line; |
1358 absolute_lin--; 1359 } |
1360 point = curr_line->line; 1361 if (horiz_offset) 1362 horiz_offset = 0; 1363 position = 1; 1364 midscreen(0, point); 1365 scr_pos = scr_horz; 1366} 1367 1368void 1369nextline() /* move pointers to start of next line */ 1370{ 1371 curr_line = curr_line->next_line; |
1372 absolute_lin++; |
1373 point = curr_line->line; 1374 position = 1; 1375 if (scr_vert == last_line) 1376 { 1377 wmove(text_win, 0,0); 1378 wdeleteln(text_win); 1379 wmove(text_win, last_line,0); 1380 wclrtobot(text_win); 1381 draw_line(last_line,0,point,1,curr_line->line_length); 1382 } 1383 else 1384 scr_vert++; 1385} 1386 1387void 1388prevline() /* move pointers to start of previous line*/ 1389{ 1390 curr_line = curr_line->prev_line; |
1391 absolute_lin--; |
1392 point = curr_line->line; 1393 position = 1; 1394 if (scr_vert == 0) 1395 { 1396 winsertln(text_win); 1397 draw_line(0,0,point,1,curr_line->line_length); 1398 } 1399 else --- 21 unchanged lines hidden (view full) --- 1421 scanline(point); 1422 wmove(text_win, scr_vert, (scr_horz - horiz_offset)); 1423 scr_pos = scr_horz; 1424 } 1425 else if (curr_line->prev_line != NULL) 1426 { 1427 if (!disp) 1428 { |
1429 absolute_lin--; |
1430 curr_line = curr_line->prev_line; 1431 point = curr_line->line + curr_line->line_length; 1432 position = curr_line->line_length; 1433 return; 1434 } 1435 position = 1; 1436 prevline(); 1437 scanline(point); --- 19 unchanged lines hidden (view full) --- 1457 scanline(point); 1458 wmove(text_win, scr_vert, (scr_horz - horiz_offset)); 1459 scr_pos = scr_horz; 1460 } 1461 else if (curr_line->next_line != NULL) 1462 { 1463 if (!disp) 1464 { |
1465 absolute_lin++; |
1466 curr_line = curr_line->next_line; 1467 point = curr_line->line; 1468 position = 1; 1469 return; 1470 } 1471 nextline(); 1472 scr_pos = scr_horz = 0; 1473 if (horiz_offset) --- 69 unchanged lines hidden (view full) --- 1543 if (in == KEY_LEFT) 1544 left(TRUE); 1545 else if (in == KEY_RIGHT) 1546 right(TRUE); 1547 else if (in == KEY_HOME) 1548 bol(); 1549 else if (in == KEY_END) 1550 eol(); |
1551 else if (in == KEY_UP) |
1552 up(); 1553 else if (in == KEY_DOWN) 1554 down(); 1555 else if (in == KEY_NPAGE) 1556 move_rel("d", max( 5, (last_line - 5))); 1557 else if (in == KEY_PPAGE) 1558 move_rel("u", max(5, (last_line - 5))); 1559 else if (in == KEY_DL) --- 143 unchanged lines hidden (view full) --- 1703 help(); 1704 else if (compare(cmd_str, WRITE, FALSE)) 1705 { 1706 if (restrict_mode()) 1707 { 1708 return; 1709 } 1710 cmd_str = next_word(cmd_str); |
1711 if (*cmd_str == '\0') |
1712 { 1713 cmd_str = cmd_str2 = get_string(file_write_prompt_str, TRUE); 1714 } 1715 tmp_file = resolve_name(cmd_str); 1716 write_file(tmp_file, 1); 1717 if (tmp_file != cmd_str) 1718 free(tmp_file); 1719 } 1720 else if (compare(cmd_str, READ, FALSE)) 1721 { 1722 if (restrict_mode()) 1723 { 1724 return; 1725 } 1726 cmd_str = next_word(cmd_str); |
1727 if (*cmd_str == '\0') |
1728 { 1729 cmd_str = cmd_str2 = get_string(file_read_prompt_str, TRUE); 1730 } 1731 tmp_file = cmd_str; 1732 recv_file = TRUE; 1733 tmp_file = resolve_name(cmd_str); 1734 check_fp(); 1735 if (tmp_file != cmd_str) --- 153 unchanged lines hidden (view full) --- 1889 clear_com_win = TRUE; 1890 g_horz = g_position = scan(prompt, strlen(prompt), 0); 1891 g_pos = 0; 1892 do 1893 { 1894 esc_flag = FALSE; 1895 in = wgetch(com_win); 1896 if (in == -1) |
1897 exit(0); |
1898 if (((in == 8) || (in == 127) || (in == KEY_BACKSPACE)) && (g_pos > 0)) 1899 { 1900 tmp_int = g_horz; 1901 g_pos--; 1902 g_horz = scan(g_point, g_pos, g_position); 1903 tmp_int = tmp_int - g_horz; 1904 for (; 0 < tmp_int; tmp_int--) 1905 { --- 8 unchanged lines hidden (view full) --- 1914 } 1915 else if ((in != 8) && (in != 127) && (in != '\n') && (in != '\r') && (in < 256)) 1916 { 1917 if (in == '\026') /* control-v, accept next character verbatim */ 1918 { /* allows entry of ^m, ^j, and ^h */ 1919 esc_flag = TRUE; 1920 in = wgetch(com_win); 1921 if (in == -1) |
1922 exit(0); |
1923 } 1924 *nam_str = in; 1925 g_pos++; 1926 if (((in < ' ') || (in > 126)) && (g_horz < (last_col - 1))) 1927 g_horz += out_char(com_win, in, g_horz); 1928 else 1929 { 1930 g_horz++; 1931 if (g_horz < (last_col - 1)) 1932 waddch(com_win, in); 1933 } 1934 nam_str++; 1935 } 1936 wrefresh(com_win); 1937 if (esc_flag) |
1938 in = '\0'; |
1939 } while ((in != '\n') && (in != '\r')); |
1940 *nam_str = '\0'; |
1941 nam_str = tmp_string; 1942 if (((*nam_str == ' ') || (*nam_str == 9)) && (advance)) 1943 nam_str = next_word(nam_str); 1944 string = malloc(strlen(nam_str) + 1); 1945 strcpy(string, nam_str); 1946 free(tmp_string); 1947 wrefresh(com_win); 1948 return(string); --- 8 unchanged lines hidden (view full) --- 1957 char *strng1; 1958 char *strng2; 1959 int tmp; 1960 int equal; 1961 1962 strng1 = string1; 1963 strng2 = string2; 1964 tmp = 0; |
1965 if ((strng1 == NULL) || (strng2 == NULL) || (*strng1 == '\0') || (*strng2 == '\0')) |
1966 return(FALSE); 1967 equal = TRUE; 1968 while (equal) 1969 { 1970 if (sensitive) 1971 { 1972 if (*strng1 != *strng2) 1973 equal = FALSE; 1974 } 1975 else 1976 { 1977 if (toupper(*strng1) != toupper(*strng2)) 1978 equal = FALSE; 1979 } 1980 strng1++; 1981 strng2++; |
1982 if ((*strng1 == '\0') || (*strng2 == '\0') || (*strng1 == ' ') || (*strng2 == ' ')) |
1983 break; 1984 tmp++; 1985 } 1986 return(equal); 1987} 1988 1989void 1990goto_line(cmd_str) --- 28 unchanged lines hidden (view full) --- 2019 t_line = t_line->next_line; 2020 } 2021 if ((i < 30) && (i > 0)) 2022 { 2023 move_rel(direction, i); 2024 } 2025 else 2026 { |
2027 if (!strcmp(direction, "d")) 2028 { 2029 absolute_lin += i; 2030 } 2031 else 2032 { 2033 absolute_lin -= i; 2034 } |
2035 curr_line = t_line; 2036 point = curr_line->line; 2037 position = 1; 2038 midscreen((last_line / 2), point); 2039 scr_pos = scr_horz; 2040 } 2041 wmove(com_win, 0, 0); 2042 wclrtoeol(com_win); --- 44 unchanged lines hidden (view full) --- 2087 name++; 2088 if (!strcmp(name, "ree")) 2089 restricted = TRUE; 2090 2091 top_of_stack = NULL; 2092 input_file = FALSE; 2093 recv_file = FALSE; 2094 count = 1; |
2095 while ((count < numargs)&& (!no_more_opts)) |
2096 { 2097 buff = arguments[count]; 2098 if (!strcmp("-i", buff)) 2099 { 2100 info_window = FALSE; 2101 } 2102 else if (!strcmp("-e", buff)) 2103 { --- 7 unchanged lines hidden (view full) --- 2111 { 2112 fprintf(stderr, usage0, arguments[0]); 2113 fprintf(stderr, usage1); 2114 fprintf(stderr, usage2); 2115 fprintf(stderr, usage3); 2116 fprintf(stderr, usage4); 2117 exit(1); 2118 } |
2119 else if ((*buff == '+') && (start_at_line == NULL)) |
2120 { 2121 buff++; 2122 start_at_line = buff; 2123 } 2124 else if (!(strcmp("--", buff))) 2125 no_more_opts = TRUE; 2126 else 2127 { --- 10 unchanged lines hidden (view full) --- 2138 temp_names = top_of_stack = name_alloc(); 2139 } 2140 else 2141 { 2142 temp_names->next_name = name_alloc(); 2143 temp_names = temp_names->next_name; 2144 } 2145 ptr = temp_names->name = malloc(strlen(buff) + 1); |
2146 while (*buff != '\0') |
2147 { 2148 *ptr = *buff; 2149 buff++; 2150 ptr++; 2151 } |
2152 *ptr = '\0'; |
2153 temp_names->next_name = NULL; 2154 input_file = TRUE; 2155 recv_file = TRUE; 2156 count++; 2157 } 2158} 2159 2160void --- 65 unchanged lines hidden (view full) --- 2226 start_at_line = NULL; 2227 } 2228 } 2229 else 2230 { 2231 wmove(com_win, 0, 0); 2232 wclrtoeol(com_win); 2233 text_changes = TRUE; |
2234 if ((tmp_file != NULL) && (*tmp_file != '\0')) |
2235 wprintw(com_win, file_read_fin_msg, tmp_file); 2236 } 2237 wrefresh(com_win); 2238 wmove(text_win, scr_vert, (scr_horz - horiz_offset)); 2239 wrefresh(text_win); 2240} 2241 2242void --- 100 unchanged lines hidden (view full) --- 2343 { 2344 str2++; 2345 num++; 2346 char_count++; 2347 } 2348 if (!(*append)) /* if not append to current line, insert new one */ 2349 { 2350 tline = txtalloc(); /* allocate data structure for next line */ |
2351 tline->line_number = curr_line->line_number + 1; |
2352 tline->next_line = curr_line->next_line; |
2353 tline->prev_line = curr_line; 2354 curr_line->next_line = tline; 2355 if (tline->next_line != NULL) 2356 tline->next_line->prev_line = tline; 2357 curr_line = tline; 2358 curr_line->line = point = (unsigned char *) malloc(char_count); 2359 curr_line->line_length = char_count; 2360 curr_line->max_length = char_count; --- 4 unchanged lines hidden (view full) --- 2365 curr_line->line_length += (char_count - 1); 2366 } 2367 for (temp_counter = 1; temp_counter < char_count; temp_counter++) 2368 { 2369 *point = *str1; 2370 point++; 2371 str1++; 2372 } |
2373 *point = '\0'; |
2374 *append = FALSE; 2375 if ((num == length) && (*str2 != '\n')) 2376 *append = TRUE; 2377 } 2378} 2379 2380void 2381draw_screen() /* redraw the screen from current postion */ --- 21 unchanged lines hidden (view full) --- 2403{ 2404 char *file_name = in_file_name; 2405 2406 /* 2407 | changes made here should be reflected in the 'save' 2408 | portion of file_op() 2409 */ 2410 |
2411 if ((file_name == NULL) || (*file_name == '\0')) |
2412 file_name = get_string(save_file_name_prompt, TRUE); 2413 |
2414 if ((file_name == NULL) || (*file_name == '\0')) |
2415 { 2416 wmove(com_win, 0, 0); 2417 wprintw(com_win, file_not_saved_msg); 2418 wclrtoeol(com_win); 2419 wrefresh(com_win); 2420 clear_com_win = TRUE; 2421 return; 2422 } --- 40 unchanged lines hidden (view full) --- 2463 exit(0); 2464 } 2465 else 2466 { 2467 delete_text(); 2468 recv_file = TRUE; 2469 input_file = TRUE; 2470 check_fp(); |
2471 } 2472 return(0); 2473} 2474 2475void 2476edit_abort(arg) 2477int arg; 2478{ --- 8 unchanged lines hidden (view full) --- 2487delete_text() 2488{ 2489 while (curr_line->next_line != NULL) 2490 curr_line = curr_line->next_line; 2491 while (curr_line != first_line) 2492 { 2493 free(curr_line->line); 2494 curr_line = curr_line->prev_line; |
2495 absolute_lin--; |
2496 free(curr_line->next_line); 2497 } 2498 curr_line->next_line = NULL; |
2499 *curr_line->line = '\0'; |
2500 curr_line->line_length = 1; 2501 curr_line->line_number = 1; 2502 point = curr_line->line; 2503 scr_pos = scr_vert = scr_horz = 0; 2504 position = 1; 2505} 2506 2507int --- 75 unchanged lines hidden (view full) --- 2583int 2584search(display_message) /* search for string in srch_str */ 2585int display_message; 2586{ 2587 int lines_moved; 2588 int iter; 2589 int found; 2590 |
2591 if ((srch_str == NULL) || (*srch_str == '\0')) |
2592 return(FALSE); 2593 if (display_message) 2594 { 2595 wmove(com_win, 0, 0); 2596 wclrtoeol(com_win); 2597 wprintw(com_win, searching_msg); 2598 wrefresh(com_win); 2599 clear_com_win = TRUE; --- 8 unchanged lines hidden (view full) --- 2608 while ((!found) && (srch_line != NULL)) 2609 { 2610 while ((iter < srch_line->line_length) && (!found)) 2611 { 2612 srch_2 = srch_1; 2613 if (case_sen) /* if case sensitive */ 2614 { 2615 srch_3 = srch_str; |
2616 while ((*srch_2 == *srch_3) && (*srch_3 != '\0')) |
2617 { 2618 found = TRUE; 2619 srch_2++; 2620 srch_3++; 2621 } /* end while */ 2622 } 2623 else /* if not case sensitive */ 2624 { 2625 srch_3 = u_srch_str; |
2626 while ((toupper(*srch_2) == *srch_3) && (*srch_3 != '\0')) |
2627 { 2628 found = TRUE; 2629 srch_2++; 2630 srch_3++; 2631 } 2632 } /* end else */ |
2633 if (!((*srch_3 == '\0') && (found))) |
2634 { 2635 found = FALSE; 2636 if (iter < srch_line->line_length) 2637 srch_1++; 2638 iter++; 2639 } 2640 } 2641 if (!found) --- 23 unchanged lines hidden (view full) --- 2665 if (lines_moved < 30) 2666 { 2667 move_rel("d", lines_moved); 2668 while (position < iter) 2669 right(TRUE); 2670 } 2671 else 2672 { |
2673 absolute_lin += lines_moved; |
2674 curr_line = srch_line; 2675 point = srch_1; 2676 position = iter; 2677 scanline(point); 2678 scr_pos = scr_horz; 2679 midscreen((last_line / 2), point); 2680 } 2681 } --- 12 unchanged lines hidden (view full) --- 2694 return(found); 2695} 2696 2697void 2698search_prompt() /* prompt and read search string (srch_str) */ 2699{ 2700 if (srch_str != NULL) 2701 free(srch_str); |
2702 if ((u_srch_str != NULL) && (*u_srch_str != '\0')) |
2703 free(u_srch_str); 2704 srch_str = get_string(search_prompt_str, FALSE); 2705 gold = FALSE; 2706 srch_3 = srch_str; 2707 srch_1 = u_srch_str = malloc(strlen(srch_str) + 1); |
2708 while (*srch_3 != '\0') |
2709 { 2710 *srch_1 = toupper(*srch_3); 2711 srch_1++; 2712 srch_3++; 2713 } |
2714 *srch_1 = '\0'; |
2715 search(TRUE); 2716} 2717 2718void 2719del_char() /* delete current character */ 2720{ 2721 in = 8; /* backspace */ 2722 if (position < curr_line->line_length) /* if not end of line */ --- 20 unchanged lines hidden (view full) --- 2743undel_char() /* undelete last deleted character */ 2744{ 2745 if (d_char[0] == '\n') /* insert line if last del_char deleted eol */ 2746 insert_line(TRUE); 2747 else 2748 { 2749 in = d_char[0]; 2750 insert(in); |
2751 if (d_char[1] != '\0') |
2752 { 2753 in = d_char[1]; 2754 insert(in); 2755 } 2756 } 2757} 2758 2759void --- 25 unchanged lines hidden (view full) --- 2785 while ((tposit < curr_line->line_length) && 2786 ((*d_word3 == ' ') || (*d_word3 == '\t'))) 2787 { 2788 tposit++; 2789 *d_word2 = *d_word3; 2790 d_word2++; 2791 d_word3++; 2792 } |
2793 *d_word2 = '\0'; |
2794 d_wrd_len = difference = d_word2 - d_word; 2795 d_word2 = point; 2796 while (tposit < curr_line->line_length) 2797 { 2798 tposit++; 2799 *d_word2 = *d_word3; 2800 d_word2++; 2801 d_word3++; 2802 } 2803 curr_line->line_length -= difference; |
2804 *d_word2 = '\0'; |
2805 draw_line(scr_vert, scr_horz,point,position,curr_line->line_length); 2806 d_char[0] = tmp_char[0]; 2807 d_char[1] = tmp_char[1]; 2808 d_char[2] = tmp_char[2]; 2809 text_changes = TRUE; 2810 formatted = FALSE; 2811} 2812 --- 36 unchanged lines hidden (view full) --- 2849 temp++; 2850 tposit++; 2851 *tmp_ptr = *tmp_old_ptr; 2852 tmp_ptr++; 2853 tmp_old_ptr++; 2854 } 2855 curr_line->line_length += d_wrd_len; 2856 tmp_old_ptr = point; |
2857 *tmp_ptr = '\0'; |
2858 tmp_ptr = tmp_space; 2859 tposit = 1; 2860 /* 2861 | now copy contents from temp space back to original line 2862 */ 2863 while (tposit < temp) 2864 { 2865 tposit++; 2866 *tmp_old_ptr = *tmp_ptr; 2867 tmp_ptr++; 2868 tmp_old_ptr++; 2869 } |
2870 *tmp_old_ptr = '\0'; |
2871 free(tmp_space); 2872 draw_line(scr_vert, scr_horz, point, position, curr_line->line_length); 2873} 2874 2875void 2876del_line() /* delete from cursor to end of line */ 2877{ 2878 unsigned char *dl1; --- 9 unchanged lines hidden (view full) --- 2888 while (tposit < curr_line->line_length) 2889 { 2890 *dl1 = *dl2; 2891 dl1++; 2892 dl2++; 2893 tposit++; 2894 } 2895 dlt_line->line_length = 1 + tposit - position; |
2896 *dl1 = '\0'; 2897 *point = '\0'; |
2898 curr_line->line_length = position; 2899 wclrtoeol(text_win); 2900 if (curr_line->next_line != NULL) 2901 { 2902 right(FALSE); 2903 delete(FALSE); 2904 } 2905 text_changes = TRUE; --- 18 unchanged lines hidden (view full) --- 2924 tposit = 1; 2925 while (tposit < dlt_line->line_length) 2926 { 2927 tposit++; 2928 *ud1 = *ud2; 2929 ud1++; 2930 ud2++; 2931 } |
2932 *ud1 = '\0'; |
2933 draw_line(scr_vert, scr_horz,point,position,curr_line->line_length); 2934} 2935 2936void 2937adv_word() /* advance to next word */ 2938{ 2939while ((position < curr_line->line_length) && ((*point != 32) && (*point != 9))) 2940 right(TRUE); --- 23 unchanged lines hidden (view full) --- 2964 tmp = point; 2965 tmp_line = curr_line; 2966 for (i= 0;(i<5)&&(curr_line->prev_line != NULL); i++) 2967 { 2968 up(); 2969 } 2970 scr_vert = scr_vert + i; 2971 curr_line = tmp_line; |
2972 absolute_lin += i; |
2973 point = tmp; 2974 scanline(point); 2975 } 2976 } 2977 else 2978 { 2979 if ((position != 1) && (curr_line->next_line != NULL)) 2980 { --- 14 unchanged lines hidden (view full) --- 2995 if ((last_line > 10) && (scr_vert > (last_line - 5))) 2996 { 2997 tmp = point; 2998 tmp_line = curr_line; 2999 for (i=0; (i<5) && (curr_line->next_line != NULL); i++) 3000 { 3001 down(); 3002 } |
3003 absolute_lin -= i; |
3004 scr_vert = scr_vert - i; 3005 curr_line = tmp_line; 3006 point = tmp; 3007 scanline(point); 3008 } 3009 } 3010 wmove(text_win, scr_vert, (scr_horz - horiz_offset)); 3011} --- 41 unchanged lines hidden (view full) --- 3053 else if (curr_line->next_line != NULL) 3054 { 3055 scr_pos = 0; 3056 down(); 3057 } 3058} 3059 3060void |
3061from_top() 3062{ 3063 struct text *tmpline = first_line; 3064 int x = 1; 3065 3066 while ((tmpline != NULL) && (tmpline != curr_line)) 3067 { 3068 x++; 3069 tmpline = tmpline->next_line; 3070 } 3071 absolute_lin = x; 3072} 3073 3074void |
3075sh_command(string) /* execute shell command */ 3076char *string; /* string containing user command */ 3077{ 3078 char *temp_point; 3079 char *last_slash; 3080 char *path; /* directory path to executable */ 3081 int parent; /* zero if child, child's pid if parent */ 3082 int value; 3083 int return_val; 3084 struct text *line_holder; 3085 3086 if (restrict_mode()) 3087 { 3088 return; 3089 } 3090 3091 if (!(path = getenv("SHELL"))) 3092 path = "/bin/sh"; 3093 last_slash = temp_point = path; |
3094 while (*temp_point != '\0') |
3095 { 3096 if (*temp_point == '/') 3097 last_slash = ++temp_point; 3098 else 3099 temp_point++; 3100 } 3101 3102 /* --- 55 unchanged lines hidden (view full) --- 3158 close(pipe_in[1]); 3159 get_fd = pipe_in[0]; 3160 get_file(""); 3161 close(pipe_in[0]); 3162 scr_vert = tmp_vert; 3163 scr_horz = scr_pos = 0; 3164 position = 1; 3165 curr_line = line_holder; |
3166 from_top(); |
3167 point = curr_line->line; 3168 out_pipe = FALSE; 3169 signal(SIGCHLD, SIG_DFL); 3170/* 3171 | since flag "in_pipe" is still TRUE, the path which waits for the child 3172 | process to die will be avoided. 3173 | (the pipe is closed, no more output can be expected) 3174 */ --- 22 unchanged lines hidden (view full) --- 3197 */ 3198 close(0); 3199 dup(pipe_out[0]); 3200 close(pipe_out[0]); 3201 close(pipe_out[1]); 3202 } 3203 for (value = 1; value < 24; value++) 3204 signal(value, SIG_DFL); |
3205 execl(path, last_slash, "-c", string, NULL); 3206 fprintf(stderr, exec_err_msg, path); 3207 exit(-1); |
3208 } 3209 else /* if the parent */ 3210 { 3211 if (out_pipe) 3212 { 3213/* 3214 | output the contents of the buffer to the pipe (to be read by the 3215 | process forked and exec'd above as stdin) --- 26 unchanged lines hidden (view full) --- 3242 */ 3243 if (!shell_fork) 3244 exit(0); 3245 } 3246 signal(SIGINT, edit_abort); 3247 } 3248 if (shell_fork) 3249 { |
3250 printf(continue_msg); |
3251 fflush(stdout); 3252 while ((in = getchar()) != '\n') 3253 ; 3254 } 3255 3256 if (!in_pipe) 3257 { 3258 fixterm(); --- 43 unchanged lines hidden (view full) --- 3302 idlok(text_win, TRUE); 3303 wrefresh(text_win); 3304 help_win = newwin((LINES - 1), COLS, 0, 0); 3305 keypad(help_win, TRUE); 3306 idlok(help_win, TRUE); 3307 if (info_window) 3308 { 3309 info_type = CONTROL_KEYS; |
3310 info_win = newwin(6, COLS, 0, 0); |
3311 werase(info_win); 3312 paint_info_win(); |
3313 } 3314 3315 last_col = COLS - 1; 3316 local_LINES = LINES; 3317 local_COLS = COLS; 3318 3319#ifdef NCURSE 3320 if (ee_chinese) --- 8 unchanged lines hidden (view full) --- 3329 if ((LINES == local_LINES) && (COLS == local_COLS)) 3330 return; 3331 3332 if (info_window) 3333 delwin(info_win); 3334 delwin(text_win); 3335 delwin(com_win); 3336 delwin(help_win); |
3337 set_up_term(); 3338 redraw(); 3339 wrefresh(text_win); 3340} 3341 3342static char item_alpha[] = "abcdefghijklmnopqrstuvwxyz0123456789 "; 3343 3344int 3345menu_op(menu_list) 3346struct menu_entries menu_list[]; 3347{ 3348 WINDOW *temp_win; 3349 int max_width, max_height; 3350 int x_off, y_off; 3351 int counter; 3352 int length; 3353 int input; |
3354 int temp; |
3355 int list_size; 3356 int top_offset; /* offset from top where menu items start */ 3357 int vert_pos; /* vertical position */ 3358 int vert_size; /* vertical size for menu list item display */ 3359 int off_start = 1; /* offset from start of menu items to start display */ 3360 3361 3362 /* --- 65 unchanged lines hidden (view full) --- 3428 do 3429 { 3430 if (off_start > 2) 3431 wmove(temp_win, (1 + counter + top_offset - off_start), 3); 3432 else 3433 wmove(temp_win, (counter + top_offset - off_start), 3); 3434 3435 wrefresh(temp_win); |
3436 in = wgetch(temp_win); 3437 input = in; 3438 if (input == -1) 3439 exit(0); |
3440 3441 if (((tolower(input) >= 'a') && (tolower(input) <= 'z')) || 3442 ((input >= '0') && (input <= '9'))) 3443 { 3444 if ((tolower(input) >= 'a') && (tolower(input) <= 'z')) 3445 { 3446 temp = 1 + tolower(input) - 'a'; 3447 } --- 226 unchanged lines hidden (view full) --- 3674 emacs_help_text[counter] : help_text[counter]); 3675 } 3676 wrefresh(help_win); 3677 werase(com_win); 3678 wmove(com_win, 0, 0); 3679 wprintw(com_win, press_any_key_msg); 3680 wrefresh(com_win); 3681 counter = wgetch(com_win); |
3682 if (counter == -1) 3683 exit(0); |
3684 werase(com_win); 3685 wmove(com_win, 0, 0); 3686 werase(help_win); 3687 wrefresh(help_win); 3688 wrefresh(com_win); 3689 redraw(); 3690} 3691 --- 11 unchanged lines hidden (view full) --- 3703 wmove(info_win, counter, 0); 3704 wclrtoeol(info_win); 3705 if (info_type == CONTROL_KEYS) 3706 waddstr(info_win, (emacs_keys_mode) ? 3707 emacs_control_keys[counter] : control_keys[counter]); 3708 else if (info_type == COMMANDS) 3709 waddstr(info_win, command_strings[counter]); 3710 } |
3711 wmove(info_win, 5, 0); 3712 if (!nohighlight) 3713 wstandout(info_win); 3714 waddstr(info_win, separator); 3715 wstandend(info_win); |
3716 wrefresh(info_win); 3717} 3718 3719void 3720no_info_window() 3721{ 3722 if (!info_window) 3723 return; --- 17 unchanged lines hidden (view full) --- 3741 return; 3742 last_line = LINES - 8; 3743 delwin(text_win); 3744 text_win = newwin((LINES - 7), COLS, 6, 0); 3745 keypad(text_win, TRUE); 3746 idlok(text_win, TRUE); 3747 werase(text_win); 3748 info_window = TRUE; |
3749 info_win = newwin(6, COLS, 0, 0); |
3750 werase(info_win); 3751 info_type = CONTROL_KEYS; 3752 midscreen(min(scr_vert, last_line), point); 3753 clearok(info_win, TRUE); 3754 paint_info_win(); |
3755 wrefresh(text_win); 3756 clear_com_win = TRUE; 3757} 3758 3759int 3760file_op(arg) 3761int arg; 3762{ --- 31 unchanged lines hidden (view full) --- 3794 */ 3795 3796 if (in_file_name) 3797 flag = TRUE; 3798 else 3799 flag = FALSE; 3800 3801 string = in_file_name; |
3802 if ((string == NULL) || (*string == '\0')) |
3803 string = get_string(save_file_name_prompt, TRUE); |
3804 if ((string == NULL) || (*string == '\0')) |
3805 { 3806 wmove(com_win, 0, 0); 3807 wprintw(com_win, file_not_saved_msg); 3808 wclrtoeol(com_win); 3809 wrefresh(com_win); 3810 clear_com_win = TRUE; 3811 return(0); 3812 } --- 18 unchanged lines hidden (view full) --- 3831} 3832 3833void 3834shell_op() 3835{ 3836 char *string; 3837 3838 if (((string = get_string(shell_prompt, TRUE)) != NULL) && |
3839 (*string != '\0')) |
3840 { 3841 sh_command(string); 3842 free(string); 3843 } 3844} 3845 3846void 3847leave_op() --- 109 unchanged lines hidden (view full) --- 3957 case_sen = TRUE; 3958 tmp_srchstr = srch_str; 3959 temp2 = srch_str = (unsigned char *) malloc(1 + curr_line->line_length - position); 3960 if ((*point == ' ') || (*point == '\t')) 3961 adv_word(); 3962 offset -= position; 3963 counter = position; 3964 line = temp1 = point; |
3965 while ((*temp1 != '\0') && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length)) |
3966 { 3967 *temp2 = *temp1; 3968 temp2++; 3969 temp1++; 3970 counter++; 3971 } |
3972 *temp2 = '\0'; |
3973 if (position != 1) 3974 bol(); 3975 while (!Blank_Line(curr_line->prev_line)) 3976 bol(); 3977 string_count = 0; 3978 status = TRUE; 3979 while ((line != point) && (status)) 3980 { --- 159 unchanged lines hidden (view full) --- 4140 unsigned char *string; 4141 unsigned char *str1; 4142 unsigned char *str2; 4143 char *home; 4144 int counter; 4145 int temp_int; 4146 4147 string = getenv("HOME"); |
4148 if (string == NULL) 4149 string = "/tmp"; |
4150 str1 = home = malloc(strlen(string)+10); 4151 strcpy(home, string); 4152 strcat(home, "/.init.ee"); 4153 init_name[1] = home; 4154 string = malloc(512); 4155 4156 for (counter = 0; counter < 3; counter++) 4157 { 4158 if (!(access(init_name[counter], 4))) 4159 { 4160 init_file = fopen(init_name[counter], "r"); 4161 while ((str2 = fgets(string, 512, init_file)) != NULL) 4162 { 4163 str1 = str2 = string; 4164 while (*str2 != '\n') 4165 str2++; |
4166 *str2 = '\0'; |
4167 4168 if (unique_test(string, init_strings) != 1) 4169 continue; 4170 4171 if (compare(str1, CASE, FALSE)) 4172 case_sen = TRUE; 4173 else if (compare(str1, NOCASE, FALSE)) 4174 case_sen = FALSE; --- 14 unchanged lines hidden (view full) --- 4189 auto_format = TRUE; 4190 observ_margins = TRUE; 4191 } 4192 else if (compare(str1, NOAUTOFORMAT, FALSE)) 4193 auto_format = FALSE; 4194 else if (compare(str1, Echo, FALSE)) 4195 { 4196 str1 = next_word(str1); |
4197 if (*str1 != '\0') |
4198 echo_string(str1); 4199 } 4200 else if (compare(str1, PRINTCOMMAND, FALSE)) 4201 { 4202 str1 = next_word(str1); 4203 print_command = malloc(strlen(str1)+1); 4204 strcpy(print_command, str1); 4205 } --- 107 unchanged lines hidden (view full) --- 4313 if (old_init_file != NULL) 4314 { 4315 /* 4316 | Copy non-configuration info into new .init.ee file. 4317 */ 4318 while ((string = fgets(buffer, 512, old_init_file)) != NULL) 4319 { 4320 length = strlen(string); |
4321 string[length - 1] = '\0'; |
4322 4323 if (unique_test(string, init_strings) == 1) 4324 { 4325 if (compare(string, Echo, FALSE)) 4326 { 4327 fprintf(init_file, "%s\n", string); 4328 } 4329 } --- 30 unchanged lines hidden (view full) --- 4360void 4361echo_string(string) /* echo the given string */ 4362char *string; 4363{ 4364 char *temp; 4365 int Counter; 4366 4367 temp = string; |
4368 while (*temp != '\0') |
4369 { 4370 if (*temp == '\\') 4371 { 4372 temp++; 4373 if (*temp == 'n') 4374 putchar('\n'); 4375 else if (*temp == 't') 4376 putchar('\t'); --- 59 unchanged lines hidden (view full) --- 4436 char string[256]; 4437 int fd; 4438 4439 if (restrict_mode()) 4440 { 4441 return; 4442 } 4443 (void)sprintf(template, "/tmp/ee.XXXXXXXX"); |
4444 fd = mkstemp(template); |
4445 if (fd < 0) { 4446 wmove(com_win, 0, 0); 4447 wprintw(com_win, create_file_fail_msg, name); 4448 wrefresh(com_win); 4449 return; 4450 } 4451 close(fd); 4452 if (write_file(name, 0)) --- 14 unchanged lines hidden (view full) --- 4467{ 4468 int counter; 4469 unsigned char *pnt; 4470 4471 if (test_line == NULL) 4472 return(0); 4473 4474 pnt = test_line->line; |
4475 if ((pnt == NULL) || (*pnt == '\0') || |
4476 (*pnt == '.') || (*pnt == '>')) 4477 return(0); 4478 4479 if ((*pnt == ' ') || (*pnt == '\t')) 4480 { 4481 pnt = next_word(pnt); 4482 } 4483 |
4484 if (*pnt == '\0') |
4485 return(0); 4486 4487 counter = 0; |
4488 while ((*pnt != '\0') && ((*pnt != ' ') && (*pnt != '\t'))) |
4489 { 4490 pnt++; 4491 counter++; 4492 } |
4493 while ((*pnt != '\0') && ((*pnt == ' ') || (*pnt == '\t'))) |
4494 { 4495 pnt++; 4496 counter++; 4497 } 4498 return(counter); 4499} 4500 4501void --- 34 unchanged lines hidden (view full) --- 4536 | will be in the same relative position 4537 */ 4538 4539 tmp_d_line = d_line; 4540 tmp_d_line_length = dlt_line->line_length; 4541 d_line = NULL; 4542 auto_format = FALSE; 4543 offset = position; |
4544 if ((position != 1) && ((*point == ' ') || (*point == '\t') || (position == curr_line->line_length) || (*point == '\0'))) |
4545 prev_word(); 4546 temp_dword = d_word; 4547 temp_dwl = d_wrd_len; 4548 d_wrd_len = 0; 4549 d_word = NULL; 4550 temp_case = case_sen; 4551 case_sen = TRUE; 4552 tmp_srchstr = srch_str; 4553 temp2 = srch_str = (unsigned char *) malloc(1 + curr_line->line_length - position); 4554 if ((*point == ' ') || (*point == '\t')) 4555 adv_word(); 4556 offset -= position; 4557 counter = position; 4558 line = temp1 = point; |
4559 while ((*temp1 != '\0') && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length)) |
4560 { 4561 *temp2 = *temp1; 4562 temp2++; 4563 temp1++; 4564 counter++; 4565 } |
4566 *temp2 = '\0'; |
4567 if (position != 1) 4568 bol(); 4569 while (!Blank_Line(curr_line->prev_line)) 4570 bol(); 4571 string_count = 0; 4572 status = TRUE; 4573 while ((line != point) && (status)) 4574 { --- 285 unchanged lines hidden (view full) --- 4860 4861char * 4862is_in_string(string, substring) /* a strchr() look-alike for systems without 4863 strchr() */ 4864char * string, *substring; 4865{ 4866 char *full, *sub; 4867 |
4868 for (sub = substring; (sub != NULL) && (*sub != '\0'); sub++) |
4869 { |
4870 for (full = string; (full != NULL) && (*full != '\0'); |
4871 full++) 4872 { 4873 if (*sub == *full) 4874 return(full); 4875 } 4876 } 4877 return(NULL); 4878} --- 26 unchanged lines hidden (view full) --- 4905 user = (struct passwd *) getpwuid(index); 4906 slash = name + 1; 4907 } 4908 else 4909 { 4910 slash = strchr(name, '/'); 4911 if (slash == NULL) 4912 return(name); |
4913 *slash = '\0'; |
4914 user = (struct passwd *) getpwnam((name + 1)); 4915 *slash = '/'; 4916 } 4917 if (user == NULL) 4918 { 4919 return(name); 4920 } 4921 buffer = malloc(strlen(user->pw_dir) + strlen(slash) + 1); 4922 strcpy(buffer, user->pw_dir); 4923 strcat(buffer, slash); 4924 } 4925 else 4926 buffer = name; 4927 4928 if (is_in_string(buffer, "$")) 4929 { 4930 tmp = buffer; 4931 index = 0; 4932 |
4933 while ((*tmp != '\0') && (index < 1024)) |
4934 { 4935 |
4936 while ((*tmp != '\0') && (*tmp != '$') && |
4937 (index < 1024)) 4938 { 4939 long_buffer[index] = *tmp; 4940 tmp++; 4941 index++; 4942 } 4943 4944 if ((*tmp == '$') && (index < 1024)) 4945 { 4946 counter = 0; 4947 start_of_var = tmp; 4948 tmp++; 4949 if (*tmp == '{') /* } */ /* bracketed variable name */ 4950 { 4951 tmp++; /* { */ |
4952 while ((*tmp != '\0') && |
4953 (*tmp != '}') && 4954 (counter < 128)) 4955 { 4956 short_buffer[counter] = *tmp; 4957 counter++; 4958 tmp++; 4959 } /* { */ 4960 if (*tmp == '}') 4961 tmp++; 4962 } 4963 else 4964 { |
4965 while ((*tmp != '\0') && |
4966 (*tmp != '/') && 4967 (*tmp != '$') && 4968 (counter < 128)) 4969 { 4970 short_buffer[counter] = *tmp; 4971 counter++; 4972 tmp++; 4973 } 4974 } |
4975 short_buffer[counter] = '\0'; |
4976 if ((slash = getenv(short_buffer)) != NULL) 4977 { 4978 offset = strlen(slash); 4979 if ((offset + index) < 1024) 4980 strcpy(&long_buffer[index], slash); 4981 index += offset; 4982 } 4983 else --- 6 unchanged lines hidden (view full) --- 4990 } 4991 } 4992 } 4993 } 4994 4995 if (index == 1024) 4996 return(buffer); 4997 else |
4998 long_buffer[index] = '\0'; |
4999 5000 if (name != buffer) 5001 free(buffer); 5002 buffer = malloc(index + 1); 5003 strcpy(buffer, long_buffer); 5004 } 5005 5006 return(buffer); --- 35 unchanged lines hidden (view full) --- 5042 result = compare(string, list[counter], FALSE); 5043 if (result) 5044 num_match++; 5045 counter++; 5046 } 5047 return(num_match); 5048} 5049 |
5050#ifndef NO_CATGETS 5051/* 5052 | Get the catalog entry, and if it got it from the catalog, 5053 | make a copy, since the buffer will be overwritten by the 5054 | next call to catgets(). 5055 */ 5056 5057char * --- 129 unchanged lines hidden (view full) --- 5187 yes_char = catgetlocal( 95, "y"); 5188 file_exists_prompt = catgetlocal( 96, "file already exists, overwrite? (y/n) [n] "); 5189 create_file_fail_msg = catgetlocal( 97, "unable to create file \"%s\""); 5190 writing_file_msg = catgetlocal( 98, "writing file \"%s\""); 5191 file_written_msg = catgetlocal( 99, "\"%s\" %d lines, %d characters"); 5192 searching_msg = catgetlocal( 100, " ...searching"); 5193 str_not_found_msg = catgetlocal( 101, "string \"%s\" not found"); 5194 search_prompt_str = catgetlocal( 102, "search for: "); |
5195 exec_err_msg = catgetlocal( 103, "could not exec %s\n"); |
5196 continue_msg = catgetlocal( 104, "press return to continue "); 5197 menu_cancel_msg = catgetlocal( 105, "press Esc to cancel"); 5198 menu_size_err_msg = catgetlocal( 106, "menu too large for window"); 5199 press_any_key_msg = catgetlocal( 107, "press any key to continue "); 5200 shell_prompt = catgetlocal( 108, "shell command: "); 5201 formatting_msg = catgetlocal( 109, "...formatting paragraph..."); 5202 shell_echo_msg = catgetlocal( 110, "<!echo 'list of unrecognized words'; echo -=-=-=-=-=-"); 5203 spell_in_prog_msg = catgetlocal( 111, "sending contents of edit buffer to 'spell'"); --- 31 unchanged lines hidden (view full) --- 5235 EIGHTBIT = catgetlocal( 143, "EIGHTBIT"); 5236 NOEIGHTBIT = catgetlocal( 144, "NOEIGHTBIT"); 5237 /* 5238 | additions 5239 */ 5240 mode_strings[7] = catgetlocal( 145, "emacs key bindings "); 5241 emacs_help_text[0] = help_text[0]; 5242 emacs_help_text[1] = catgetlocal( 146, "^a beginning of line ^i tab ^r restore word "); |
5243 emacs_help_text[2] = catgetlocal( 147, "^b back 1 char ^j undel char ^t top of text "); 5244 emacs_help_text[3] = catgetlocal( 148, "^c command ^k delete line ^u bottom of text "); |
5245 emacs_help_text[4] = catgetlocal( 149, "^d delete char ^l undelete line ^v next page "); 5246 emacs_help_text[5] = catgetlocal( 150, "^e end of line ^m newline ^w delete word "); 5247 emacs_help_text[6] = catgetlocal( 151, "^f forward 1 char ^n next line ^x search "); 5248 emacs_help_text[7] = catgetlocal( 152, "^g go back 1 page ^o ascii char insert ^y search prompt "); 5249 emacs_help_text[8] = catgetlocal( 153, "^h backspace ^p prev line ^z next word "); 5250 emacs_help_text[9] = help_text[9]; 5251 emacs_help_text[10] = help_text[10]; 5252 emacs_help_text[11] = help_text[11]; 5253 emacs_help_text[12] = help_text[12]; 5254 emacs_help_text[13] = help_text[13]; 5255 emacs_help_text[14] = help_text[14]; 5256 emacs_help_text[15] = help_text[15]; 5257 emacs_help_text[16] = help_text[16]; 5258 emacs_help_text[17] = help_text[17]; 5259 emacs_help_text[18] = help_text[18]; 5260 emacs_help_text[19] = help_text[19]; 5261 emacs_help_text[20] = help_text[20]; 5262 emacs_help_text[21] = help_text[21]; |
5263 emacs_control_keys[0] = catgetlocal( 154, "^[ (escape) menu ^y search prompt ^k delete line ^p prev li ^g prev page"); 5264 emacs_control_keys[1] = catgetlocal( 155, "^o ascii code ^x search ^l undelete line ^n next li ^v next page"); 5265 emacs_control_keys[2] = catgetlocal( 156, "^u end of file ^a begin of line ^w delete word ^b back 1 char ^z next word"); 5266 emacs_control_keys[3] = catgetlocal( 157, "^t top of text ^e end of line ^r restore word ^f forward char "); |
5267 emacs_control_keys[4] = catgetlocal( 158, "^c command ^d delete char ^j undelete char ESC-Enter: exit"); 5268 EMACS_string = catgetlocal( 159, "EMACS"); 5269 NOEMACS_string = catgetlocal( 160, "NOEMACS"); 5270 usage4 = catgetlocal( 161, " +# put cursor at line #\n"); 5271 conf_dump_err_msg = catgetlocal( 162, "unable to open .init.ee for writing, no configuration saved!"); 5272 conf_dump_success_msg = catgetlocal( 163, "ee configuration saved in file %s"); 5273 modes_menu[10].item_string = catgetlocal( 164, "save editor configuration"); 5274 config_dump_menu[0].item_string = catgetlocal( 165, "save ee configuration"); --- 80 unchanged lines hidden --- |