4 | An easy to use, simple screen oriented editor.
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 | This editor was purposely developed to be simple, both in
38 | interface and implementation. This editor was developed to
39 | address a specific audience: the user who is new to computers
42 | ee is not aimed at technical users; for that reason more
43 | complex features were intentionally left out. In addition,
44 | ee is intended to be compiled by people with little computer
45 | experience, which means that it needs to be small, relatively
46 | simple in implementation, and portable.
48 | This software and documentation contains
49 | proprietary information which is protected by
50 | copyright. All rights are reserved.
54 static const char rcsid[] =
58 char *ee_copyright_message =
59 "Copyright (c) 1986, 1990, 1991, 1992, 1993, 1994, 1995, 1996 Hugh Mahon ";
61 char *ee_long_notice[] = {
62 "This software and documentation contains",
63 "proprietary information which is protected by",
64 "copyright. All rights are reserved."
67 char *version = "@(#) ee, version 1.3";
70 #include "new_curse.h"
85 #include <sys/types.h>
103 #include <nl_types.h>
107 #define catgetlocal(a, b) (b)
108 #endif /* NO_CATGETS */
111 #define SIGCHLD SIGCLD
115 #define max(a, b) (a > b ? a : b)
116 #define min(a, b) (a < b ? a : b)
119 | defines for type of data to show in info window
122 #define CONTROL_KEYS 1
126 char *line; /* line of characters */
127 int line_number; /* line number */
128 int line_length; /* actual number of characters in the line */
129 int max_length; /* maximum number of characters the line handles */
130 struct text *next_line; /* next line of text */
131 struct text *prev_line; /* previous line of text */
134 struct text *first_line; /* first line of current buffer */
135 struct text *dlt_line; /* structure for info on deleted line */
136 struct text *curr_line; /* current line cursor is on */
137 struct text *tmp_line; /* temporary line pointer */
138 struct text *srch_line; /* temporary pointer for search routine */
140 struct files { /* structure to store names of files to be edited*/
141 char *name; /* name of file */
142 struct files *next_name;
145 struct files *top_of_stack = NULL;
147 int d_wrd_len; /* length of deleted word */
148 int position; /* offset in bytes from begin of line */
149 int scr_pos; /* horizontal position */
150 int scr_vert; /* vertical position on screen */
151 int scr_horz; /* horizontal position on screen */
152 int tmp_vert, tmp_horz;
153 int input_file; /* indicate to read input file */
154 int recv_file; /* indicate reading a file */
155 int edit; /* continue executing while true */
156 int gold; /* 'gold' function key pressed */
157 int fildes; /* file descriptor */
158 int case_sen; /* case sensitive search flag */
159 int last_line; /* last line for text display */
160 int last_col; /* last column for text display */
161 int horiz_offset = 0; /* offset from left edge of text */
162 int clear_com_win; /* flag to indicate com_win needs clearing */
163 int text_changes = FALSE; /* indicate changes have been made to text */
164 int get_fd; /* file descriptor for reading a file */
165 int info_window = TRUE; /* flag to indicate if help window visible */
166 int info_type = CONTROL_KEYS; /* flag to indicate type of info to display */
167 int expand_tabs = TRUE; /* flag for expanding tabs */
168 int right_margin = 0; /* the right margin */
169 int observ_margins = TRUE; /* flag for whether margins are observed */
171 int temp_stdin; /* temporary storage for stdin */
172 int temp_stdout; /* temp storage for stdout descriptor */
173 int temp_stderr; /* temp storage for stderr descriptor */
174 int pipe_out[2]; /* pipe file desc for output */
175 int pipe_in[2]; /* pipe file descriptors for input */
176 int out_pipe; /* flag that info is piped out */
177 int in_pipe; /* flag that info is piped in */
178 int formatted = FALSE; /* flag indicating paragraph formatted */
179 int auto_format = FALSE; /* flag for auto_format mode */
180 int restricted = FALSE; /* flag to indicate restricted mode */
181 int nohighlight = FALSE; /* turns off highlighting */
182 int eightbit = TRUE; /* eight bit character flag */
183 int local_LINES = 0; /* copy of LINES, to detect when win resizes */
184 int local_COLS = 0; /* copy of COLS, to detect when win resizes */
185 int curses_initialized = FALSE; /* flag indicating if curses has been started*/
186 int emacs_keys_mode = FALSE; /* mode for if emacs key binings are used */
188 char *point; /* points to current position in line */
189 char *srch_str; /* pointer for search string */
190 char *u_srch_str; /* pointer to non-case sensitive search */
191 char *srch_1; /* pointer to start of suspect string */
192 char *srch_2; /* pointer to next character of string */
194 char *in_file_name = NULL; /* name of input file */
195 char *tmp_file; /* temporary file name */
196 char d_char; /* deleted character */
197 char *d_word; /* deleted word */
198 char *d_line; /* deleted line */
199 char in_string[513]; /* buffer for reading a file */
200 char *print_command = "lpr"; /* string to use for the print command */
201 char *start_at_line = NULL; /* move to this line at start of session*/
202 int in; /* input character */
204 FILE *temp_fp; /* temporary file pointer */
205 FILE *bit_bucket; /* file pointer to /dev/null */
208 "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "\t", "^J",
209 "^K", "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U",
210 "^V", "^W", "^X", "^Y", "^Z", "^[", "^\\", "^]", "^^", "^_"
218 #if defined(__STDC__) || defined(__cplusplus)
226 | The following structure allows menu items to be flexibly declared.
227 | The first item is the string describing the selection, the second
228 | is the address of the procedure to call when the item is selected,
229 | and the third is the argument for the procedure.
231 | For those systems with i18n, the string should be accompanied by a
232 | catalog number. The 'int *' should be replaced with 'void *' on
233 | systems with that type.
235 | The first menu item will be the title of the menu, with NULL
236 | parameters for the procedure and argument, followed by the menu items.
238 | If the procedure value is NULL, the menu item is displayed, but no
239 | procedure is called when the item is selected. The number of the
240 | item will be returned. If the third (argument) parameter is -1, no
241 | argument is given to the procedure when it is called.
244 struct menu_entries {
246 int (*procedure)P_((struct menu_entries *));
247 struct menu_entries *ptr_argument;
248 int (*iprocedure)P_((int));
249 void (*nprocedure)P_((void));
250 unsigned int argument;
253 int main P_((int argc, char *argv[]));
254 char *resiz_line P_((int factor, struct text *rline, int rpos));
255 void insert P_((int character));
256 void delete P_((int disp));
257 void scanline P_((char *pos));
258 int tabshift P_((int temp_int));
259 int out_char P_((WINDOW *window, int character, int column));
260 int len_char P_((int character, int column));
261 void draw_line P_((int vertical, int horiz, char *ptr, int t_pos, int length));
262 void insert_line P_((int disp));
263 struct text *txtalloc P_((void));
264 struct files *name_alloc P_((void));
265 char *next_word P_((char *string));
266 void prev_word P_((void));
267 void control P_((void));
268 void emacs_control P_((void));
269 void bottom P_((void));
271 void nextline P_((void));
272 void prevline P_((void));
273 void left P_((int disp));
274 void right P_((int disp));
275 void find_pos P_((void));
277 void down P_((void));
278 void function_key P_((void));
279 void print_buffer P_((void));
280 void command_prompt P_((void));
281 void command P_((char *cmd_str1));
282 int scan P_((char *line, int offset, int column));
283 char *get_string P_((char *prompt, int advance));
284 int compare P_((char *string1, char *string2, int sensitive));
285 void goto_line P_((char *cmd_str));
286 void midscreen P_((int line, char *pnt));
287 void get_options P_((int numargs, char *arguments[]));
288 void check_fp P_((void));
289 void get_file P_((char *file_name));
290 void get_line P_((int length, char *in_string, int *append));
291 void draw_screen P_((void));
292 void finish P_((void));
293 int quit P_((int noverify));
294 void edit_abort P_((int arg));
295 void delete_text P_((void));
296 int write_file P_((char *file_name));
297 int search P_((int display_message));
298 void search_prompt P_((void));
299 void del_char P_((void));
300 void undel_char P_((void));
301 void del_word P_((void));
302 void undel_word P_((void));
303 void del_line P_((void));
304 void undel_line P_((void));
305 void adv_word P_((void));
306 void move_rel P_((char *direction, int lines));
309 void adv_line P_((void));
310 void sh_command P_((char *string));
311 void set_up_term P_((void));
312 void resize_check P_((void));
313 int menu_op P_((struct menu_entries *));
314 void paint_menu P_((struct menu_entries menu_list[], int max_width, int max_height, int list_size, int top_offset, WINDOW *menu_win, int off_start, int vert_size));
315 void help P_((void));
316 void paint_info_win P_((void));
317 void no_info_window P_((void));
318 void create_info_window P_((void));
319 int file_op P_((int arg));
320 void shell_op P_((void));
321 void leave_op P_((void));
322 void redraw P_((void));
323 int Blank_Line P_((struct text *test_line));
324 void Format P_((void));
325 void ee_init P_((void));
326 void dump_ee_conf P_((void));
327 void echo_string P_((char *string));
328 void spell_op P_((void));
329 void ispell_op P_((void));
330 int first_word_len P_((struct text *test_line));
331 void Auto_Format P_((void));
332 void modes_op P_((void));
333 char *is_in_string P_((char *string, char *substring));
334 char *resolve_name P_((char *name));
335 int restrict_mode P_((void));
336 int unique_test P_((char *string, char *list[]));
337 void strings_init P_((void));
341 | allocate space here for the strings that will be in the menu
344 struct menu_entries modes_menu[] = {
345 {"", NULL, NULL, NULL, NULL, 0},
346 {"", NULL, NULL, NULL, NULL, -1},
347 {"", NULL, NULL, NULL, NULL, -1},
348 {"", NULL, NULL, NULL, NULL, -1},
349 {"", NULL, NULL, NULL, NULL, -1},
350 {"", NULL, NULL, NULL, NULL, -1},
351 {"", NULL, NULL, NULL, NULL, -1},
352 {"", NULL, NULL, NULL, NULL, -1},
353 {"", NULL, NULL, NULL, NULL, -1},
354 {"", NULL, NULL, NULL, dump_ee_conf, -1},
355 {NULL, NULL, NULL, NULL, NULL, -1}
358 char *mode_strings[10];
360 #define NUM_MODES_ITEMS 9
362 struct menu_entries config_dump_menu[] = {
363 {"", NULL, NULL, NULL, NULL, 0},
364 {"", NULL, NULL, NULL, NULL, -1},
365 {"", NULL, NULL, NULL, NULL, -1},
366 {NULL, NULL, NULL, NULL, NULL, -1}
369 struct menu_entries leave_menu[] = {
370 {"", NULL, NULL, NULL, NULL, -1},
371 {"", NULL, NULL, NULL, finish, -1},
372 {"", NULL, NULL, quit, NULL, TRUE},
373 {NULL, NULL, NULL, NULL, NULL, -1}
380 struct menu_entries file_menu[] = {
381 {"", NULL, NULL, NULL, NULL, -1},
382 {"", NULL, NULL, file_op, NULL, READ_FILE},
383 {"", NULL, NULL, file_op, NULL, WRITE_FILE},
384 {"", NULL, NULL, file_op, NULL, SAVE_FILE},
385 {"", NULL, NULL, NULL, print_buffer, -1},
386 {NULL, NULL, NULL, NULL, NULL, -1}
389 struct menu_entries search_menu[] = {
390 {"", NULL, NULL, NULL, NULL, 0},
391 {"", NULL, NULL, NULL, search_prompt, -1},
392 {"", NULL, NULL, search, NULL, TRUE},
393 {NULL, NULL, NULL, NULL, NULL, -1}
396 struct menu_entries spell_menu[] = {
397 {"", NULL, NULL, NULL, NULL, -1},
398 {"", NULL, NULL, NULL, spell_op, -1},
399 {"", NULL, NULL, NULL, ispell_op, -1},
400 {NULL, NULL, NULL, NULL, NULL, -1}
403 struct menu_entries misc_menu[] = {
404 {"", NULL, NULL, NULL, NULL, -1},
405 {"", NULL, NULL, NULL, Format, -1},
406 {"", NULL, NULL, NULL, shell_op, -1},
407 {"", menu_op, spell_menu, NULL, NULL, -1},
408 {NULL, NULL, NULL, NULL, NULL, -1}
411 struct menu_entries main_menu[] = {
412 {"", NULL, NULL, NULL, NULL, -1},
413 {"", NULL, NULL, NULL, leave_op, -1},
414 {"", NULL, NULL, NULL, help, -1},
415 {"", menu_op, file_menu, NULL, NULL, -1},
416 {"", NULL, NULL, NULL, redraw, -1},
417 {"", NULL, NULL, NULL, modes_op, -1},
418 {"", menu_op, search_menu, NULL, NULL, -1},
419 {"", menu_op, misc_menu, NULL, NULL, -1},
420 {NULL, NULL, NULL, NULL, NULL, -1}
424 char *control_keys[5];
426 char *emacs_help_text[22];
427 char *emacs_control_keys[5];
429 char *command_strings[5];
431 char *init_strings[20];
435 #define max_alpha_char 36
438 | Declarations for strings for localization
441 char *com_win_message; /* to be shown in com_win if no info window */
442 char *no_file_string;
443 char *ascii_code_str;
444 char *printer_msg_str;
446 char *file_write_prompt_str;
447 char *file_read_prompt_str;
450 char *non_unique_cmd_msg;
453 char *current_file_str;
459 char *file_is_dir_msg;
463 char *file_read_fin_msg;
464 char *reading_file_msg;
466 char *file_read_lines_msg;
467 char *save_file_name_prompt;
468 char *file_not_saved_msg;
469 char *changes_made_prompt;
471 char *file_exists_prompt;
472 char *create_file_fail_msg;
473 char *writing_file_msg;
474 char *file_written_msg;
476 char *str_not_found_msg;
477 char *search_prompt_str;
480 char *menu_cancel_msg;
481 char *menu_size_err_msg;
482 char *press_any_key_msg;
484 char *formatting_msg;
485 char *shell_echo_msg;
486 char *spell_in_prog_msg;
488 char *restricted_msg;
521 char *NOEMACS_string;
522 char *conf_dump_err_msg;
523 char *conf_dump_success_msg;
524 char *conf_not_saved_msg;
525 char *ree_no_file_msg;
527 char *menu_too_lrg_msg;
528 char *more_above_str, *more_below_str;
532 extern char *malloc();
533 extern char *realloc();
534 extern char *getenv();
535 FILE *fopen(); /* declaration for open function */
536 #endif /* HAS_STDLIB */
537 #endif /* __STDC__ */
540 main(argc, argv) /* beginning of main program */
546 for (counter = 1; counter < 24; counter++)
547 signal(counter, SIG_IGN);
549 signal(SIGCHLD, SIG_DFL);
550 signal(SIGSEGV, SIG_DFL);
551 signal(SIGINT, edit_abort);
554 d_word = malloc(150);
555 *d_word = (char) NULL;
557 dlt_line = txtalloc();
558 dlt_line->line = d_line;
559 dlt_line->line_length = 1;
560 curr_line = first_line = txtalloc();
561 curr_line->line = point = malloc(10);
562 curr_line->line_length = 1;
563 curr_line->max_length = 10;
564 curr_line->prev_line = NULL;
565 curr_line->next_line = NULL;
566 curr_line->line_number = 1;
573 bit_bucket = fopen("/dev/null", "w");
575 gold = case_sen = FALSE;
580 get_options(argc, argv);
582 if (right_margin == 0)
583 right_margin = COLS - 1;
584 if (top_of_stack == NULL)
588 wmove(com_win, 0, 0);
590 wprintw(com_win, ree_no_file_msg);
594 wprintw(com_win, no_file_string);
600 clear_com_win = TRUE;
605 in = wgetch(text_win);
613 clear_com_win = FALSE;
614 wmove(com_win, 0, 0);
618 wprintw(com_win, "%s", com_win_message);
625 else if ((in == '\10') || (in == 127))
627 else if ((in > 31) || (in == 9))
629 else if ((in >= 0) && (in <= 31))
641 resiz_line(factor, rline, rpos) /* resize the line to length + factor*/
642 int factor; /* resize factor */
643 struct text *rline; /* position in line */
649 rline->max_length += factor;
650 rpoint = rline->line = realloc(rline->line, rline->max_length );
651 for (resiz_var = 1 ; (resiz_var < rpos) ; resiz_var++)
657 insert(character) /* insert character into line */
658 int character; /* new character */
662 char *temp; /* temporary pointer */
663 char *temp2; /* temporary pointer */
665 if ((character == '\011') && (expand_tabs))
667 counter = len_char('\011', scr_horz);
668 for (; counter > 0; counter--)
675 if ((curr_line->max_length - curr_line->line_length) < 5)
676 point = resiz_line(10, curr_line, position);
677 curr_line->line_length++;
680 while (counter < curr_line->line_length) /* find end of line */
685 temp++; /* increase length of line by one */
689 *temp= *temp2; /* shift characters over by one */
692 *point = character; /* insert new character */
694 if (((character >= 0) && (character < ' ')) || (character >= 127)) /* check for TAB character*/
696 scr_pos = scr_horz += out_char(text_win, character, scr_horz);
702 waddch(text_win, character);
703 scr_pos = ++scr_horz;
708 if ((observ_margins) && (right_margin < scr_pos))
711 while (scr_pos > right_margin)
715 while (position < counter)
722 for (value = 0; value < counter; value++)
727 if ((scr_horz - horiz_offset) > last_col)
730 midscreen(scr_vert, point);
733 if ((auto_format) && (character == ' ') && (!formatted))
735 else if ((character != ' ') && (character != '\t'))
738 draw_line(scr_vert, scr_horz, point, position, curr_line->line_length);
742 delete(disp) /* delete character */
747 struct text *temp_buff;
751 if (point != curr_line->line) /* if not at beginning of line */
757 if ((*tp >= '\000') && (*tp < ' ')) /* check for TAB */
763 d_char = *point; /* save deleted character */
764 temp_pos = --position;
765 curr_line->line_length--;
766 while (temp_pos <= curr_line->line_length)
773 if (scr_horz < horiz_offset)
776 midscreen(scr_vert, point);
779 else if (curr_line->prev_line != NULL)
782 left(disp); /* go to previous line */
783 temp_buff = curr_line->next_line;
784 point = resiz_line(temp_buff->line_length, curr_line, position);
785 if (temp_buff->next_line != NULL)
786 temp_buff->next_line->prev_line = curr_line;
787 curr_line->next_line = temp_buff->next_line;
788 temp2 = temp_buff->line;
793 while (temp_pos < temp_buff->line_length)
795 curr_line->line_length++;
802 free(temp_buff->line);
804 temp_buff = curr_line;
805 temp_vert = scr_vert;
807 if (scr_vert < last_line)
809 wmove(text_win, scr_vert + 1, 0);
812 while ((temp_buff != NULL) && (temp_vert < last_line))
814 temp_buff = temp_buff->next_line;
817 if ((temp_vert == last_line) && (temp_buff != NULL))
819 tp = temp_buff->line;
820 wmove(text_win, last_line,0);
822 draw_line(last_line, 0, tp, 1, temp_buff->line_length);
823 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
826 draw_line(scr_vert, scr_horz, point, position, curr_line->line_length);
831 scanline(pos) /* find the proper horizontal position for the pointer */
837 ptr = curr_line->line;
841 if ((*ptr >= 0) && (*ptr <= 8))
844 temp += tabshift(temp);
845 else if ((*ptr >= 10) && (*ptr <= 31))
847 else if ((*ptr >= 32) && (*ptr < 127))
849 else if (*ptr == 127)
858 if ((scr_horz - horiz_offset) > last_col)
860 horiz_offset = (scr_horz - (scr_horz % 8)) - (COLS - 8);
861 midscreen(scr_vert, point);
863 else if (scr_horz < horiz_offset)
865 horiz_offset = max(0, (scr_horz - (scr_horz % 8)));
866 midscreen(scr_vert, point);
871 tabshift(temp_int) /* give the number of spaces to shift */
876 leftover = ((temp_int + 1) % 8);
880 return (9 - leftover);
884 out_char(window, character, column) /* output non-printing character */
893 if (character == TAB)
895 i1 = tabshift(column);
897 (i2 < i1) && (((column+i2+1)-horiz_offset) < last_col); i2++)
903 else if ((character >= '\0') && (character < ' '))
905 string = table[(int) character];
907 else if ((character < 0) || (character >= 127))
909 if (character == 127)
913 sprintf(string2, "<%d>", (character < 0) ? (character + 256) : character);
918 waddch(window, (unsigned char)character );
924 waddch(window, (unsigned char)character);
927 for (i2 = 0; (string[i2] != (char) NULL) && (((column+i2+1)-horiz_offset) < last_col); i2++)
928 waddch(window, string[i2]);
929 return(strlen(string));
933 len_char(character, column) /* return the length of the character */
935 int column; /* the column must be known to provide spacing for tabs */
939 if (character == '\t')
940 length = tabshift(column);
941 else if ((character >= 0) && (character < 32))
943 else if ((character >= 32) && (character <= 126))
945 else if (character == 127)
947 else if (((character > 126) || (character < 0)) && (!eightbit))
956 draw_line(vertical, horiz, ptr, t_pos, length) /* redraw line from current position */
957 int vertical; /* current vertical position on screen */
958 int horiz; /* current horizontal position on screen */
959 char *ptr; /* pointer to line */
960 int t_pos; /* current position (offset in bytes) from bol */
961 int length; /* length (in bytes) of line */
963 int d; /* partial length of special or tab char to display */
964 char *temp; /* temporary pointer to position in line */
965 int abs_column; /* offset in screen units from begin of line */
966 int column; /* horizontal position on screen */
967 int row; /* vertical position on screen */
968 int posit; /* temporary position indicator within line */
971 column = horiz - horiz_offset;
978 wmove(text_win, row, 0);
983 d = len_char(*temp, abs_column);
989 wmove(text_win, row, column);
991 while ((posit < length) && (column <= last_col))
993 if ((*temp < 32) || (*temp == 127))
995 column += len_char(*temp, abs_column);
996 abs_column += out_char(text_win, *temp, abs_column);
1002 waddch(text_win, *temp);
1007 if (column < last_col)
1008 wclrtoeol(text_win);
1009 wmove(text_win, vertical, (horiz - horiz_offset));
1013 insert_line(disp) /* insert new line */
1020 struct text *temp_nod;
1022 text_changes = TRUE;
1023 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1024 wclrtoeol(text_win);
1025 temp_nod= txtalloc();
1026 temp_nod->line = extra= malloc(10);
1027 temp_nod->line_length = 1;
1028 temp_nod->max_length = 10;
1029 temp_nod->line_number = curr_line->line_number + 1;
1030 temp_nod->next_line = curr_line->next_line;
1031 if (temp_nod->next_line != NULL)
1032 temp_nod->next_line->prev_line = temp_nod;
1033 temp_nod->prev_line = curr_line;
1034 curr_line->next_line = temp_nod;
1035 temp_pos2 = position;
1037 if (temp_pos2 < curr_line->line_length)
1040 while (temp_pos2 < curr_line->line_length)
1042 if ((temp_nod->max_length - temp_nod->line_length)< 5)
1043 extra = resiz_line(10, temp_nod, temp_pos);
1044 temp_nod->line_length++;
1052 *temp = (char) NULL;
1053 temp = resiz_line((1 - temp_nod->line_length), curr_line, position);
1054 curr_line->line_length = 1 + temp - curr_line->line;
1056 curr_line->line_length = position;
1057 curr_line = temp_nod;
1058 *extra = (char) NULL;
1060 point= curr_line->line;
1063 if (scr_vert < last_line)
1066 wclrtoeol(text_win);
1067 wmove(text_win, scr_vert, 0);
1068 winsertln(text_win);
1072 wmove(text_win, 0,0);
1073 wdeleteln(text_win);
1074 wmove(text_win, last_line,0);
1075 wclrtobot(text_win);
1077 scr_pos = scr_horz = 0;
1081 midscreen(scr_vert, point);
1083 draw_line(scr_vert, scr_horz, point, position,
1084 curr_line->line_length);
1088 struct text *txtalloc() /* allocate space for line structure */
1090 return((struct text *) malloc(sizeof( struct text)));
1093 struct files *name_alloc() /* allocate space for file name list node */
1095 return((struct files *) malloc(sizeof( struct files)));
1098 char *next_word(string) /* move to next word in string */
1101 while ((*string != (char) NULL) && ((*string != 32) && (*string != 9)))
1103 while ((*string != (char) NULL) && ((*string == 32) || (*string == 9)))
1109 prev_word() /* move to start of previous word in text */
1113 if ((position != 1) && ((point[-1] == ' ') || (point[-1] == '\t')))
1114 { /* if at the start of a word */
1115 while ((position != 1) && ((*point != ' ') && (*point != '\t')))
1118 while ((position != 1) && ((*point == ' ') || (*point == '\t')))
1120 while ((position != 1) && ((*point != ' ') && (*point != '\t')))
1122 if ((position != 1) && ((*point == ' ') || (*point == '\t')))
1130 control() /* use control for commands */
1134 if (in == 1) /* control a */
1136 string = get_string(ascii_code_str, TRUE);
1137 if (*string != (char) NULL)
1140 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1145 else if (in == 2) /* control b */
1147 else if (in == 3) /* control c */
1151 else if (in == 4) /* control d */
1153 else if (in == 5) /* control e */
1155 else if (in == 6) /* control f */
1157 else if (in == 7) /* control g */
1159 else if (in == 8) /* control h */
1161 else if (in == 9) /* control i */
1163 else if (in == 10) /* control j */
1165 else if (in == 11) /* control k */
1167 else if (in == 12) /* control l */
1169 else if (in == 13) /* control m */
1171 else if (in == 14) /* control n */
1172 move_rel("d", max(5, (last_line - 5)));
1173 else if (in == 15) /* control o */
1175 else if (in == 16) /* control p */
1176 move_rel("u", max(5, (last_line - 5)));
1177 else if (in == 17) /* control q */
1179 else if (in == 18) /* control r */
1181 else if (in == 19) /* control s */
1183 else if (in == 20) /* control t */
1185 else if (in == 21) /* control u */
1187 else if (in == 22) /* control v */
1189 else if (in == 23) /* control w */
1191 else if (in == 24) /* control x */
1193 else if (in == 25) /* control y */
1195 else if (in == 26) /* control z */
1197 else if (in == 27) /* control [ (escape) */
1204 | Emacs control-key bindings
1212 if (in == 1) /* control a */
1214 else if (in == 2) /* control b */
1216 else if (in == 3) /* control c */
1220 else if (in == 4) /* control d */
1222 else if (in == 5) /* control e */
1224 else if (in == 6) /* control f */
1226 else if (in == 7) /* control g */
1227 move_rel("u", max(5, (last_line - 5)));
1228 else if (in == 8) /* control h */
1230 else if (in == 9) /* control i */
1232 else if (in == 10) /* control j */
1234 else if (in == 11) /* control k */
1236 else if (in == 12) /* control l */
1238 else if (in == 13) /* control m */
1240 else if (in == 14) /* control n */
1242 else if (in == 15) /* control o */
1244 string = get_string(ascii_code_str, TRUE);
1245 if (*string != (char) NULL)
1248 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1253 else if (in == 16) /* control p */
1255 else if (in == 17) /* control q */
1257 else if (in == 18) /* control r */
1259 else if (in == 19) /* control s */
1261 else if (in == 20) /* control t */
1263 else if (in == 21) /* control u */
1265 else if (in == 22) /* control v */
1266 move_rel("d", max(5, (last_line - 5)));
1267 else if (in == 23) /* control w */
1269 else if (in == 24) /* control x */
1271 else if (in == 25) /* control y */
1273 else if (in == 26) /* control z */
1275 else if (in == 27) /* control [ (escape) */
1282 bottom() /* go to bottom of file */
1284 while (curr_line->next_line != NULL)
1285 curr_line = curr_line->next_line;
1286 point = curr_line->line;
1290 midscreen(last_line, point);
1295 top() /* go to top of file */
1297 while (curr_line->prev_line != NULL)
1298 curr_line = curr_line->prev_line;
1299 point = curr_line->line;
1303 midscreen(0, point);
1308 nextline() /* move pointers to start of next line */
1310 curr_line = curr_line->next_line;
1311 point = curr_line->line;
1313 if (scr_vert == last_line)
1315 wmove(text_win, 0,0);
1316 wdeleteln(text_win);
1317 wmove(text_win, last_line,0);
1318 wclrtobot(text_win);
1319 draw_line(last_line,0,point,1,curr_line->line_length);
1326 prevline() /* move pointers to start of previous line*/
1328 curr_line = curr_line->prev_line;
1329 point = curr_line->line;
1333 winsertln(text_win);
1334 draw_line(0,0,point,1,curr_line->line_length);
1338 while (position < curr_line->line_length)
1346 left(disp) /* move left one character */
1349 if (point != curr_line->line) /* if not at begin of line */
1354 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1357 else if (curr_line->prev_line != NULL)
1361 curr_line = curr_line->prev_line;
1362 point = curr_line->line + curr_line->line_length;
1363 position = curr_line->line_length;
1370 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1375 right(disp) /* move right one character */
1378 if (position < curr_line->line_length)
1383 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1386 else if (curr_line->next_line != NULL)
1390 curr_line = curr_line->next_line;
1391 point = curr_line->line;
1396 scr_pos = scr_horz = 0;
1400 midscreen(scr_vert, point);
1402 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1408 find_pos() /* move to the same column as on other line */
1412 while ((scr_horz < scr_pos) && (position < curr_line->line_length))
1415 scr_horz += tabshift(scr_horz);
1416 else if ((*point >= '\0') && (*point < ' '))
1423 if ((scr_horz - horiz_offset) > last_col)
1425 horiz_offset = (scr_horz - (scr_horz % 8)) - (COLS - 8);
1426 midscreen(scr_vert, point);
1428 else if (scr_horz < horiz_offset)
1430 horiz_offset = max(0, (scr_horz - (scr_horz % 8)));
1431 midscreen(scr_vert, point);
1433 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1437 up() /* move up one line */
1439 if (curr_line->prev_line != NULL)
1442 point = curr_line->line;
1448 down() /* move down one line */
1450 if (curr_line->next_line != NULL)
1458 function_key() /* process function key */
1462 else if (in == KEY_RIGHT)
1464 else if (in == KEY_HOME)
1466 else if (in == KEY_END)
1468 else if ( in == KEY_UP)
1470 else if (in == KEY_DOWN)
1472 else if (in == KEY_NPAGE)
1473 move_rel("d", max( 5, (last_line - 5)));
1474 else if (in == KEY_PPAGE)
1475 move_rel("u", max(5, (last_line - 5)));
1476 else if (in == KEY_DL)
1478 else if (in == KEY_DC)
1480 else if (in == KEY_BACKSPACE)
1482 else if (in == KEY_IL)
1483 { /* insert a line before current line */
1487 else if (in == KEY_F(1))
1489 else if (in == KEY_F(2))
1499 else if (in == KEY_F(3))
1509 else if (in == KEY_F(4))
1515 midscreen(scr_vert, point);
1520 else if (in == KEY_F(5))
1530 else if (in == KEY_F(6))
1540 else if (in == KEY_F(7))
1550 else if (in == KEY_F(8))
1567 sprintf(buffer, ">!%s", print_command);
1568 wmove(com_win, 0, 0);
1570 wprintw(com_win, printer_msg_str, print_command);
1581 info_type = COMMANDS;
1583 cmd_str = get_string(command_str, TRUE);
1584 if ((result = unique_test(cmd_str, commands)) != 1)
1587 wmove(com_win, 0, 0);
1589 wprintw(com_win, unkn_cmd_str, cmd_str);
1591 wprintw(com_win, non_unique_cmd_msg);
1595 info_type = CONTROL_KEYS;
1598 if (cmd_str != NULL)
1604 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1605 info_type = CONTROL_KEYS;
1607 if (cmd_str != NULL)
1612 command(cmd_str1) /* process commands from keyboard */
1615 char *cmd_str2 = NULL;
1616 char *cmd_str = cmd_str1;
1618 clear_com_win = TRUE;
1619 if (compare(cmd_str, HELP, FALSE))
1621 else if (compare(cmd_str, WRITE, FALSE))
1623 if (restrict_mode())
1627 cmd_str = next_word(cmd_str);
1628 if (*cmd_str == (char) NULL)
1630 cmd_str = cmd_str2 = get_string(file_write_prompt_str, TRUE);
1632 tmp_file = resolve_name(cmd_str);
1633 write_file(tmp_file);
1634 if (tmp_file != cmd_str)
1637 else if (compare(cmd_str, READ, FALSE))
1639 if (restrict_mode())
1643 cmd_str = next_word(cmd_str);
1644 if (*cmd_str == (char) NULL)
1646 cmd_str = cmd_str2 = get_string(file_read_prompt_str, TRUE);
1650 tmp_file = resolve_name(cmd_str);
1652 if (tmp_file != cmd_str)
1655 else if (compare(cmd_str, LINE, FALSE))
1657 wmove(com_win, 0, 0);
1659 wprintw(com_win, line_num_str, curr_line->line_number);
1660 wprintw(com_win, line_len_str, curr_line->line_length);
1662 else if (compare(cmd_str, FILE_str, FALSE))
1664 wmove(com_win, 0, 0);
1666 if (in_file_name == NULL)
1667 wprintw(com_win, no_file_string);
1669 wprintw(com_win, current_file_str, in_file_name);
1671 else if ((*cmd_str >= '0') && (*cmd_str <= '9'))
1673 else if (compare(cmd_str, CHARACTER, FALSE))
1675 wmove(com_win, 0, 0);
1678 wprintw(com_win, char_str, *point);
1680 wprintw(com_win, char_str, (*point + 256));
1682 else if (compare(cmd_str, REDRAW, FALSE))
1684 else if (compare(cmd_str, RESEQUENCE, FALSE))
1686 tmp_line = first_line->next_line;
1687 while (tmp_line != NULL)
1689 tmp_line->line_number = tmp_line->prev_line->line_number + 1;
1690 tmp_line = tmp_line->next_line;
1693 else if (compare(cmd_str, AUTHOR, FALSE))
1695 wmove(com_win, 0, 0);
1697 wprintw(com_win, "written by Hugh Mahon");
1699 else if (compare(cmd_str, VERSION, FALSE))
1701 wmove(com_win, 0, 0);
1703 wprintw(com_win, "%s", version);
1705 else if (compare(cmd_str, CASE, FALSE))
1707 else if (compare(cmd_str, NOCASE, FALSE))
1709 else if (compare(cmd_str, EXPAND, FALSE))
1711 else if (compare(cmd_str, NOEXPAND, FALSE))
1712 expand_tabs = FALSE;
1713 else if (compare(cmd_str, Exit_string, FALSE))
1715 else if (compare(cmd_str, QUIT_string, FALSE))
1717 else if (*cmd_str == '!')
1720 if ((*cmd_str == ' ') || (*cmd_str == 9))
1721 cmd_str = next_word(cmd_str);
1722 sh_command(cmd_str);
1724 else if ((*cmd_str == '<') && (!in_pipe))
1729 if ((*cmd_str == ' ') || (*cmd_str == '\t'))
1730 cmd_str = next_word(cmd_str);
1735 else if ((*cmd_str == '>') && (!out_pipe))
1739 if ((*cmd_str == ' ') || (*cmd_str == '\t'))
1740 cmd_str = next_word(cmd_str);
1746 wmove(com_win, 0, 0);
1748 wprintw(com_win, unkn_cmd_str, cmd_str);
1750 if (cmd_str2 != NULL)
1755 scan(line, offset, column) /* determine horizontal position for get_string */
1770 j += len_char(*stemp, j);
1777 get_string(prompt, advance) /* read string from input on command line */
1778 char *prompt; /* string containing user prompt message */
1779 int advance; /* if true, skip leading spaces and tabs */
1786 int g_horz, g_position, g_pos;
1789 g_point = tmp_string = malloc(512);
1792 waddstr(com_win, prompt);
1794 nam_str = tmp_string;
1795 clear_com_win = TRUE;
1796 g_horz = g_position = scan(prompt, strlen(prompt), 0);
1801 in = wgetch(com_win);
1804 if (((in == 8) || (in == 127) || (in == KEY_BACKSPACE)) && (g_pos > 0))
1808 g_horz = scan(g_point, g_pos, g_position);
1809 tmp_int = tmp_int - g_horz;
1810 for (; 0 < tmp_int; tmp_int--)
1812 if ((g_horz+tmp_int) < (last_col - 1))
1814 waddch(com_win, '\010');
1815 waddch(com_win, ' ');
1816 waddch(com_win, '\010');
1821 else if ((in != 8) && (in != 127) && (in != '\n') && (in != '\r') && (in < 256))
1823 if (in == '\026') /* control-v, accept next character verbatim */
1824 { /* allows entry of ^m, ^j, and ^h */
1826 in = wgetch(com_win);
1832 if (((in < ' ') || (in > 126)) && (g_horz < (last_col - 1)))
1833 g_horz += out_char(com_win, in, g_horz);
1837 if (g_horz < (last_col - 1))
1838 waddch(com_win, in);
1845 } while ((in != '\n') && (in != '\r'));
1846 *nam_str = (char) NULL;
1847 nam_str = tmp_string;
1848 if (((*nam_str == ' ') || (*nam_str == 9)) && (advance))
1849 nam_str = next_word(nam_str);
1850 string = malloc(strlen(nam_str) + 1);
1851 strcpy(string, nam_str);
1858 compare(string1, string2, sensitive) /* compare two strings */
1871 if ((strng1 == NULL) || (strng2 == NULL) || (*strng1 == (char) NULL) || (*strng2 == (char) NULL))
1878 if (*strng1 != *strng2)
1883 if (toupper(*strng1) != toupper(*strng2))
1888 if ((*strng1 == (char) NULL) || (*strng2 == (char) NULL) || (*strng1 == ' ') || (*strng2 == ' '))
1902 char *direction = NULL;
1903 struct text *t_line;
1907 while ((*ptr >='0') && (*ptr <= '9'))
1909 i= i * 10 + (*ptr - '0');
1915 while ((t_line->line_number > number) && (t_line->prev_line != NULL))
1918 t_line = t_line->prev_line;
1921 while ((t_line->line_number < number) && (t_line->next_line != NULL))
1925 t_line = t_line->next_line;
1927 if ((i < 30) && (i > 0))
1929 move_rel(direction, i);
1934 point = curr_line->line;
1936 midscreen((last_line / 2), point);
1939 wmove(com_win, 0, 0);
1941 wprintw(com_win, line_num_str, curr_line->line_number);
1942 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1946 midscreen(line, pnt) /* put current line in middle of screen */
1950 struct text *mid_line;
1953 line = min(line, last_line);
1954 mid_line = curr_line;
1955 for (i = 0; ((i < line) && (curr_line->prev_line != NULL)); i++)
1956 curr_line = curr_line->prev_line;
1957 scr_vert = scr_horz = 0;
1958 wmove(text_win, 0, 0);
1961 curr_line = mid_line;
1963 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
1967 get_options(numargs, arguments) /* get arguments from command line */
1973 struct files *temp_names = NULL;
1978 | see if editor was invoked as 'ree' (restricted mode)
1981 if (!(name = strrchr(arguments[0], '/')))
1982 name = arguments[0];
1985 if (!strcmp(name, "ree"))
1988 top_of_stack = NULL;
1992 while (count < numargs)
1994 buff = arguments[count];
1995 if (!strcmp("-i", buff))
1997 info_window = FALSE;
1999 else if (!strcmp("-e", buff))
2001 expand_tabs = FALSE;
2003 else if (!strcmp("-h", buff))
2007 else if (!strcmp("-?", buff))
2009 fprintf(stderr, usage0, arguments[0]);
2010 fprintf(stderr, usage1);
2011 fprintf(stderr, usage2);
2012 fprintf(stderr, usage3);
2013 fprintf(stderr, usage4);
2016 else if (*buff == '+')
2019 start_at_line = buff;
2024 if (top_of_stack == NULL)
2026 temp_names = top_of_stack = name_alloc();
2030 temp_names->next_name = name_alloc();
2031 temp_names = temp_names->next_name;
2033 ptr = temp_names->name = malloc(strlen(buff) + 1);
2034 while (*buff != (char) NULL)
2041 temp_names->next_name = NULL;
2050 check_fp() /* open or close files according to flags */
2056 clear_com_win = TRUE;
2057 tmp_vert = scr_vert;
2058 tmp_horz = scr_horz;
2059 tmp_line = curr_line;
2062 in_file_name = tmp_file = top_of_stack->name;
2063 top_of_stack = top_of_stack->next_name;
2065 temp = stat(tmp_file, &buf);
2066 buf.st_mode &= ~07777;
2067 if ((temp != -1) && (buf.st_mode != 0100000) && (buf.st_mode != 0))
2069 wprintw(com_win, file_is_dir_msg, tmp_file);
2079 if ((get_fd = open(tmp_file, O_RDONLY)) == -1)
2081 wmove(com_win, 0, 0);
2084 wprintw(com_win, new_file_msg, tmp_file);
2086 wprintw(com_win, cant_open_msg, tmp_file);
2088 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
2098 line_num = curr_line->line_number;
2099 scr_vert = tmp_vert;
2100 scr_horz = tmp_horz;
2102 curr_line= first_line;
2104 curr_line = tmp_line;
2105 point = curr_line->line;
2110 if (start_at_line != NULL)
2112 line_num = atoi(start_at_line) - 1;
2113 move_rel("d", line_num);
2115 start_at_line = NULL;
2120 wmove(com_win, 0, 0);
2122 text_changes = TRUE;
2123 if ((tmp_file != NULL) && (*tmp_file != (char) NULL))
2124 wprintw(com_win, file_read_fin_msg, tmp_file);
2127 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
2132 get_file(file_name) /* read specified file into current buffer */
2135 int can_read; /* file has at least one character */
2136 int length; /* length of line read by read */
2137 int append; /* should text be appended to current line */
2138 struct text *temp_line;
2139 char ro_flag = FALSE;
2141 if (recv_file) /* if reading a file */
2143 wmove(com_win, 0, 0);
2145 wprintw(com_win, reading_file_msg, file_name);
2146 if (access(file_name, 2)) /* check permission to write */
2148 if ((errno == ENOTDIR) || (errno == EACCES) || (errno == EROFS) || (errno == ETXTBSY) || (errno == EFAULT))
2150 wprintw(com_win, read_only_msg);
2156 if (curr_line->line_length > 1) /* if current line is not blank */
2164 can_read = FALSE; /* test if file has any characters */
2165 while (((length = read(get_fd, in_string, 512)) != 0) && (length != -1))
2167 can_read = TRUE; /* if set file has at least 1 character */
2168 get_line(length, in_string, &append);
2170 if ((can_read) && (curr_line->line_length == 1))
2172 temp_line = curr_line->prev_line;
2173 temp_line->next_line = curr_line->next_line;
2174 if (temp_line->next_line != NULL)
2175 temp_line->next_line->prev_line = temp_line;
2176 if (curr_line->line != NULL)
2177 free(curr_line->line);
2179 curr_line = temp_line;
2181 if (input_file) /* if this is the file to be edited display number of lines */
2183 wmove(com_win, 0, 0);
2185 wprintw(com_win, file_read_lines_msg, in_file_name, curr_line->line_number);
2187 wprintw(com_win, read_only_msg);
2190 else if (can_read) /* not input_file and file is non-zero size */
2191 text_changes = TRUE;
2193 if (recv_file) /* if reading a file */
2200 get_line(length, in_string, append) /* read string and split into lines */
2201 int length; /* length of string read by read */
2202 char *in_string; /* string read by read */
2203 int *append; /* TRUE if must append more text to end of current line */
2207 int num; /* offset from start of string */
2208 int char_count; /* length of new line (or added portion */
2209 int temp_counter; /* temporary counter value */
2210 struct text *tline; /* temporary pointer to new line */
2211 int first_time; /* if TRUE, the first time through the loop */
2216 while (num < length)
2230 /* find end of line */
2231 while ((*str2 != '\n') && (num < length))
2237 if (!(*append)) /* if not append to current line, insert new one */
2239 tline = txtalloc(); /* allocate data structure for next line */
2240 tline->line_number = curr_line->line_number + 1;
2241 tline->next_line = curr_line->next_line;
2242 tline->prev_line = curr_line;
2243 curr_line->next_line = tline;
2244 if (tline->next_line != NULL)
2245 tline->next_line->prev_line = tline;
2247 curr_line->line = point = (char *) malloc(char_count);
2248 curr_line->line_length = char_count;
2249 curr_line->max_length = char_count;
2253 point = resiz_line(char_count, curr_line, curr_line->line_length);
2254 curr_line->line_length += (char_count - 1);
2256 for (temp_counter = 1; temp_counter < char_count; temp_counter++)
2262 *point = (char) NULL;
2264 if ((num == length) && (*str2 != '\n'))
2270 draw_screen() /* redraw the screen from current postion */
2272 struct text *temp_line;
2276 temp_line = curr_line;
2277 temp_vert = scr_vert;
2278 wclrtobot(text_win);
2279 while ((temp_line != NULL) && (temp_vert <= last_line))
2281 line_out = temp_line->line;
2282 draw_line(temp_vert, 0, line_out, 1, temp_line->line_length);
2284 temp_line = temp_line->next_line;
2286 wmove(text_win, temp_vert, 0);
2287 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
2291 finish() /* prepare to exit edit session */
2293 char *file_name = in_file_name;
2296 | changes made here should be reflected in the 'save'
2297 | portion of file_op()
2300 if ((file_name == NULL) || (*file_name == (char) NULL))
2301 file_name = get_string(save_file_name_prompt, TRUE);
2303 if ((file_name == NULL) || (*file_name == (char) NULL))
2305 wmove(com_win, 0, 0);
2306 wprintw(com_win, file_not_saved_msg);
2309 clear_com_win = TRUE;
2313 tmp_file = resolve_name(file_name);
2314 if (tmp_file != file_name)
2317 file_name = tmp_file;
2320 if (write_file(file_name))
2322 text_changes = FALSE;
2328 quit(noverify) /* exit editor */
2335 if ((text_changes) && (!noverify))
2337 ans = get_string(changes_made_prompt, TRUE);
2338 if (toupper(*ans) == toupper(*yes_char))
2339 text_changes = FALSE;
2344 if (top_of_stack == NULL)
2378 while (curr_line->next_line != NULL)
2379 curr_line = curr_line->next_line;
2380 while (curr_line != first_line)
2382 free(curr_line->line);
2383 curr_line = curr_line->prev_line;
2384 free(curr_line->next_line);
2386 curr_line->next_line = NULL;
2387 *curr_line->line = (char) NULL;
2388 curr_line->line_length = 1;
2389 curr_line->line_number = 1;
2390 point = curr_line->line;
2391 scr_pos = scr_vert = scr_horz = 0;
2396 write_file(file_name)
2401 struct text *out_line;
2404 int write_flag = TRUE;
2407 if ((in_file_name == NULL) || strcmp(in_file_name, file_name))
2409 if ((temp_fp = fopen(file_name, "r")))
2411 tmp_point = get_string(file_exists_prompt, TRUE);
2412 if (toupper(*tmp_point) == toupper(*yes_char))
2421 clear_com_win = TRUE;
2425 if ((temp_fp = fopen(file_name, "w")) == NULL)
2427 clear_com_win = TRUE;
2430 wprintw(com_win, create_file_fail_msg, file_name);
2438 wprintw(com_win, writing_file_msg, file_name);
2441 out_line = first_line;
2442 while (out_line != NULL)
2445 tmp_point= out_line->line;
2446 while (temp_pos < out_line->line_length)
2448 putc(*tmp_point, temp_fp);
2452 charac += out_line->line_length;
2453 out_line = out_line->next_line;
2460 wprintw(com_win, file_written_msg, file_name, lines, charac);
2470 search(display_message) /* search for string in srch_str */
2471 int display_message;
2477 if ((srch_str == NULL) || (*srch_str == (char) NULL))
2479 if (display_message)
2481 wmove(com_win, 0, 0);
2483 wprintw(com_win, searching_msg);
2485 clear_com_win = TRUE;
2489 srch_line = curr_line;
2491 if (position < curr_line->line_length)
2493 iter = position + 1;
2494 while ((!found) && (srch_line != NULL))
2496 while ((iter < srch_line->line_length) && (!found))
2499 if (case_sen) /* if case sensitive */
2502 while ((*srch_2 == *srch_3) && (*srch_3 != (char) NULL))
2509 else /* if not case sensitive */
2511 srch_3 = u_srch_str;
2512 while ((toupper(*srch_2) == *srch_3) && (*srch_3 != (char) NULL))
2519 if (!((*srch_3 == (char) NULL) && (found)))
2522 if (iter < srch_line->line_length)
2529 srch_line = srch_line->next_line;
2530 if (srch_line != NULL)
2531 srch_1 = srch_line->line;
2538 if (display_message)
2540 wmove(com_win, 0, 0);
2544 if (lines_moved == 0)
2546 while (position < iter)
2551 if (lines_moved < 30)
2553 move_rel("d", lines_moved);
2554 while (position < iter)
2559 curr_line = srch_line;
2564 midscreen((last_line / 2), point);
2570 if (display_message)
2572 wmove(com_win, 0, 0);
2574 wprintw(com_win, str_not_found_msg, srch_str);
2577 wmove(text_win, scr_vert,(scr_horz - horiz_offset));
2583 search_prompt() /* prompt and read search string (srch_str) */
2585 if (srch_str != NULL)
2587 if ((u_srch_str != NULL) && (*u_srch_str != (char) NULL))
2589 srch_str = get_string(search_prompt_str, FALSE);
2592 srch_1 = u_srch_str = malloc(strlen(srch_str) + 1);
2593 while (*srch_3 != (char) NULL)
2595 *srch_1 = toupper(*srch_3);
2599 *srch_1 = (char) NULL;
2604 del_char() /* delete current character */
2606 in = 8; /* backspace */
2607 if (position < curr_line->line_length) /* if not end of line */
2622 undel_char() /* undelete last deleted character */
2624 if (d_char == '\n') /* insert line if last del_char deleted eol */
2634 del_word() /* delete word in front of cursor */
2644 d_word = malloc(curr_line->line_length);
2649 while ((tposit < curr_line->line_length) &&
2650 ((*d_word3 != ' ') && (*d_word3 != '\t')))
2653 *d_word2 = *d_word3;
2657 while ((tposit < curr_line->line_length) &&
2658 ((*d_word3 == ' ') || (*d_word3 == '\t')))
2661 *d_word2 = *d_word3;
2665 *d_word2 = (char) NULL;
2666 d_wrd_len = difference = d_word2 - d_word;
2668 while (tposit < curr_line->line_length)
2671 *d_word2 = *d_word3;
2675 curr_line->line_length -= difference;
2676 *d_word2 = (char) NULL;
2677 draw_line(scr_vert, scr_horz,point,position,curr_line->line_length);
2679 text_changes = TRUE;
2684 undel_word() /* undelete last deleted word */
2694 | resize line to handle undeleted word
2696 if ((curr_line->max_length - (curr_line->line_length + d_wrd_len)) < 5)
2697 point = resiz_line(d_wrd_len, curr_line, position);
2698 tmp_ptr = tmp_space = malloc(curr_line->line_length + d_wrd_len);
2699 d_word_ptr = d_word;
2702 | copy d_word contents into temp space
2704 while (temp <= d_wrd_len)
2707 *tmp_ptr = *d_word_ptr;
2711 tmp_old_ptr = point;
2714 | copy contents of line from curent position to eol into
2717 while (tposit < curr_line->line_length)
2721 *tmp_ptr = *tmp_old_ptr;
2725 curr_line->line_length += d_wrd_len;
2726 tmp_old_ptr = point;
2727 *tmp_ptr = (char) NULL;
2728 tmp_ptr = tmp_space;
2731 | now copy contents from temp space back to original line
2733 while (tposit < temp)
2736 *tmp_old_ptr = *tmp_ptr;
2740 *tmp_old_ptr = (char) NULL;
2742 draw_line(scr_vert, scr_horz, point, position, curr_line->line_length);
2746 del_line() /* delete from cursor to end of line */
2754 d_line = malloc(curr_line->line_length);
2758 while (tposit < curr_line->line_length)
2765 dlt_line->line_length = 1 + tposit - position;
2767 *point = (char) NULL;
2768 curr_line->line_length = position;
2769 wclrtoeol(text_win);
2770 if (curr_line->next_line != NULL)
2775 text_changes = TRUE;
2779 undel_line() /* undelete last deleted line */
2787 point = resiz_line(dlt_line->line_length, curr_line, position);
2788 curr_line->line_length += dlt_line->line_length - 1;
2792 while (tposit < dlt_line->line_length)
2800 draw_line(scr_vert, scr_horz,point,position,curr_line->line_length);
2804 adv_word() /* advance to next word */
2806 while ((position < curr_line->line_length) && ((*point != 32) && (*point != 9)))
2808 while ((position < curr_line->line_length) && ((*point == 32) || (*point == 9)))
2813 move_rel(direction, lines) /* move relative to current line */
2820 if (*direction == 'u')
2823 while (position > 1)
2825 for (i = 0; i < lines; i++)
2829 if ((last_line > 5) && ( scr_vert < 4))
2832 tmp_line = curr_line;
2833 for (i= 0;(i<5)&&(curr_line->prev_line != NULL); i++)
2837 scr_vert = scr_vert + i;
2838 curr_line = tmp_line;
2845 if ((position != 1) && (curr_line->next_line != NULL))
2848 scr_pos = scr_horz = 0;
2852 midscreen(scr_vert, point);
2857 for (i = 1; i < lines; i++)
2861 if ((last_line > 10) && (scr_vert > (last_line - 5)))
2864 tmp_line = curr_line;
2865 for (i=0; (i<5) && (curr_line->next_line != NULL); i++)
2869 scr_vert = scr_vert - i;
2870 curr_line = tmp_line;
2875 wmove(text_win, scr_vert, (scr_horz - horiz_offset));
2879 eol() /* go to end of line */
2881 if (position < curr_line->line_length)
2883 while (position < curr_line->line_length)
2886 else if (curr_line->next_line != NULL)
2889 while (position < curr_line->line_length)
2895 bol() /* move to beginning of line */
2897 if (point != curr_line->line)
2899 while (point != curr_line->line)
2902 else if (curr_line->prev_line != NULL)
2910 adv_line() /* advance to beginning of next line */
2912 if ((point != curr_line->line) || (scr_pos > 0))
2914 while (position < curr_line->line_length)
2918 else if (curr_line->next_line != NULL)
2926 sh_command(string) /* execute shell command */
2927 char *string; /* string containing user command */
2931 char *path; /* directory path to executable */
2932 int parent; /* zero if child, child's pid if parent */
2935 struct text *line_holder;
2937 if (restrict_mode())
2942 if (!(path = getenv("SHELL")))
2944 last_slash = temp_point = path;
2945 while (*temp_point != (char) NULL)
2947 if (*temp_point == '/')
2948 last_slash = ++temp_point;
2954 | if in_pipe is true, then output of the shell operation will be
2955 | read by the editor, and curses doesn't need to be turned off
2960 keypad(com_win, FALSE);
2961 keypad(text_win, FALSE);
2974 pipe(pipe_in); /* create a pipe */
2976 if (!parent) /* if the child */
2979 | child process which will fork and exec shell command (if shell output is
2980 | to be read by editor)
2984 | redirect stdout to pipe
2986 temp_stdout = dup(1);
2990 | redirect stderr to pipe
2992 temp_stderr = dup(2);
2997 | child will now continue down 'if (!in_pipe)'
3001 else /* if the parent */
3004 | prepare editor to read from the pipe
3006 signal(SIGCHLD, SIG_IGN);
3007 line_holder = curr_line;
3008 tmp_vert = scr_vert;
3010 get_fd = pipe_in[0];
3013 scr_vert = tmp_vert;
3014 scr_horz = scr_pos = 0;
3016 curr_line = line_holder;
3017 point = curr_line->line;
3019 signal(SIGCHLD, SIG_DFL);
3021 | since flag "in_pipe" is still TRUE, the path which waits for the child
3022 | process to die will be avoided.
3023 | (the pipe is closed, no more output can be expected)
3029 signal(SIGINT, SIG_IGN);
3035 | fork process which will exec command
3038 if (!parent) /* if the child */
3045 | prepare the child process (soon to exec a shell command) to read from the
3046 | pipe (which will be output from the editor's buffer)
3053 for (value = 1; value < 24; value++)
3054 signal(value, SIG_DFL);
3055 execl(path, last_slash, "-c", string, NULL);
3056 errx(1, exec_err_msg, path);
3058 else /* if the parent */
3063 | output the contents of the buffer to the pipe (to be read by the
3064 | process forked and exec'd above as stdin)
3067 line_holder = first_line;
3068 while (line_holder != NULL)
3070 write(pipe_out[1], line_holder->line, (line_holder->line_length-1));
3071 write(pipe_out[1], "\n", 1);
3072 line_holder = line_holder->next_line;
3079 return_val = wait((int *) 0);
3081 while ((return_val != parent) && (return_val != -1));
3083 | if this process is actually the child of the editor, exit. Here's how it
3085 | The editor forks a process. If output must be sent to the command to be
3086 | exec'd another process is forked, and that process (the child's child)
3087 | will exec the command. In this case, "shell_fork" will be FALSE. If no
3088 | output is to be performed to the shell command, "shell_fork" will be TRUE.
3089 | If this is the editor process, shell_fork will be true, otherwise this is
3090 | the child of the edit process.
3095 signal(SIGINT, edit_abort);
3099 printf(continue_msg);
3101 while ((in = getchar()) != '\n')
3111 keypad(text_win, TRUE);
3112 keypad(com_win, TRUE);
3114 clearok(info_win, TRUE);
3121 set_up_term() /* set up the terminal for operating with ae */
3123 if (!curses_initialized)
3130 curses_initialized = TRUE;
3133 if (((LINES > 15) && (COLS >= 80)) && info_window)
3134 last_line = LINES - 8;
3137 info_window = FALSE;
3138 last_line = LINES - 2;
3141 idlok(stdscr, TRUE);
3142 com_win = newwin(1, COLS, (LINES - 1), 0);
3143 keypad(com_win, TRUE);
3144 idlok(com_win, TRUE);
3147 text_win = newwin((LINES - 1), COLS, 0, 0);
3149 text_win = newwin((LINES - 7), COLS, 6, 0);
3150 keypad(text_win, TRUE);
3151 idlok(text_win, TRUE);
3153 help_win = newwin((LINES - 1), COLS, 0, 0);
3154 keypad(help_win, TRUE);
3155 idlok(help_win, TRUE);
3158 info_type = CONTROL_KEYS;
3159 info_win = newwin(6, COLS, 0, 0);
3164 last_col = COLS - 1;
3165 local_LINES = LINES;
3172 if ((LINES == local_LINES) && (COLS == local_COLS))
3185 static char item_alpha[] = "abcdefghijklmnopqrstuvwxyz0123456789 ";
3189 struct menu_entries menu_list[];
3192 int max_width, max_height;
3199 int top_offset; /* offset from top where menu items start */
3200 int vert_pos; /* vertical position */
3201 int vert_size; /* vertical size for menu list item display */
3202 int off_start = 1; /* offset from start of menu items to start display */
3206 | determine number and width of menu items
3210 while (menu_list[list_size + 1].item_string != NULL)
3213 for (counter = 0; counter <= list_size; counter++)
3215 if ((length = strlen(menu_list[counter].item_string)) > max_width)
3219 max_width = max(max_width, strlen(cancel_string));
3220 max_width = max(max_width, max(strlen(more_above_str), strlen(more_below_str)));
3224 | make sure that window is large enough to handle menu
3225 | if not, print error message and return to calling function
3228 if (max_width > COLS)
3230 wmove(com_win, 0, 0);
3232 wprintw(com_win, menu_too_lrg_msg);
3234 clear_com_win = TRUE;
3240 if (list_size > LINES)
3243 if (max_height > 11)
3244 vert_size = max_height - 8;
3246 vert_size = max_height;
3250 vert_size = list_size;
3251 max_height = list_size;
3254 if (LINES >= (vert_size + 8))
3256 if (menu_list[0].argument != MENU_WARN)
3257 max_height = vert_size + 8;
3259 max_height = vert_size + 7;
3262 x_off = (COLS - max_width) / 2;
3263 y_off = (LINES - max_height - 1) / 2;
3264 temp_win = newwin(max_height, max_width, y_off, x_off);
3265 keypad(temp_win, TRUE);
3267 paint_menu(menu_list, max_width, max_height, list_size, top_offset, temp_win, off_start, vert_size);
3274 wmove(temp_win, (1 + counter + top_offset - off_start), 3);
3276 wmove(temp_win, (counter + top_offset - off_start), 3);
3279 in = wgetch(temp_win);
3284 if (((tolower(input) >= 'a') && (tolower(input) <= 'z')) ||
3285 ((input >= '0') && (input <= '9')))
3287 if ((tolower(input) >= 'a') && (tolower(input) <= 'z'))
3289 temp = 1 + tolower(input) - 'a';
3291 else if ((input >= '0') && (input <= '9'))
3293 temp = (2 + 'z' - 'a') + (input - '0');
3296 if (temp <= list_size)
3306 case ' ': /* space */
3307 case '\004': /* ^d, down */
3311 if (counter > list_size)
3314 case '\010': /* ^h, backspace*/
3315 case '\025': /* ^u, up */
3316 case 127: /* ^?, delete */
3322 counter = list_size;
3324 case '\033': /* escape key */
3325 if (menu_list[0].argument != MENU_WARN)
3328 case '\014': /* ^l */
3329 case '\022': /* ^r, redraw */
3330 paint_menu(menu_list, max_width, max_height,
3331 list_size, top_offset, temp_win,
3332 off_start, vert_size);
3339 if (((list_size - off_start) >= (vert_size - 1)) &&
3340 (counter > (off_start + vert_size - 3)) &&
3343 if (counter == list_size)
3344 off_start = (list_size - vert_size) + 2;
3348 paint_menu(menu_list, max_width, max_height,
3349 list_size, top_offset, temp_win, off_start,
3352 else if ((list_size != vert_size) &&
3353 (counter > (off_start + vert_size - 2)))
3355 if (counter == list_size)
3356 off_start = 2 + (list_size - vert_size);
3357 else if (off_start == 1)
3362 paint_menu(menu_list, max_width, max_height,
3363 list_size, top_offset, temp_win, off_start,
3366 else if (counter < off_start)
3371 off_start = counter;
3373 paint_menu(menu_list, max_width, max_height,
3374 list_size, top_offset, temp_win, off_start,
3378 while ((input != '\r') && (input != '\n') && (counter != 0));
3384 if ((menu_list[counter].procedure != NULL) ||
3385 (menu_list[counter].iprocedure != NULL) ||
3386 (menu_list[counter].nprocedure != NULL))
3388 if (menu_list[counter].argument != -1)
3389 (*menu_list[counter].iprocedure)(menu_list[counter].argument);
3390 else if (menu_list[counter].ptr_argument != NULL)
3391 (*menu_list[counter].procedure)(menu_list[counter].ptr_argument);
3393 (*menu_list[counter].nprocedure)();
3404 paint_menu(menu_list, max_width, max_height, list_size, top_offset, menu_win,
3405 off_start, vert_size)
3406 struct menu_entries menu_list[];
3407 int max_width, max_height, list_size, top_offset;
3409 int off_start, vert_size;
3411 int counter, temp_int;
3416 | output top and bottom portions of menu box only if window
3420 if (max_height > vert_size)
3422 wmove(menu_win, 1, 1);
3424 wstandout(menu_win);
3425 waddch(menu_win, '+');
3426 for (counter = 0; counter < (max_width - 4); counter++)
3427 waddch(menu_win, '-');
3428 waddch(menu_win, '+');
3430 wmove(menu_win, (max_height - 2), 1);
3431 waddch(menu_win, '+');
3432 for (counter = 0; counter < (max_width - 4); counter++)
3433 waddch(menu_win, '-');
3434 waddch(menu_win, '+');
3435 wstandend(menu_win);
3436 wmove(menu_win, 2, 3);
3437 waddstr(menu_win, menu_list[0].item_string);
3438 wmove(menu_win, (max_height - 3), 3);
3439 if (menu_list[0].argument != MENU_WARN)
3440 waddstr(menu_win, cancel_string);
3443 wstandout(menu_win);
3445 for (counter = 0; counter < (vert_size + top_offset); counter++)
3447 if (top_offset == 4)
3449 temp_int = counter + 2;
3454 wmove(menu_win, temp_int, 1);
3455 waddch(menu_win, '|');
3456 wmove(menu_win, temp_int, (max_width - 2));
3457 waddch(menu_win, '|');
3459 wstandend(menu_win);
3461 if (list_size > vert_size)
3466 wmove(menu_win, top_offset, 3);
3467 waddstr(menu_win, more_above_str);
3472 for (counter = off_start;
3473 ((temp_int + counter - off_start) < (vert_size - 1));
3476 wmove(menu_win, (top_offset + temp_int +
3477 (counter - off_start)), 3);
3479 wprintw(menu_win, "%c) ", item_alpha[min((counter - 1), max_alpha_char)]);
3480 waddstr(menu_win, menu_list[counter].item_string);
3483 wmove(menu_win, (top_offset + (vert_size - 1)), 3);
3485 if (counter == list_size)
3488 wprintw(menu_win, "%c) ", item_alpha[min((counter - 1), max_alpha_char)]);
3489 wprintw(menu_win, menu_list[counter].item_string);
3492 wprintw(menu_win, more_below_str);
3496 for (counter = 1; counter <= list_size; counter++)
3498 wmove(menu_win, (top_offset + counter - 1), 3);
3500 wprintw(menu_win, "%c) ", item_alpha[min((counter - 1), max_alpha_char)]);
3501 waddstr(menu_win, menu_list[counter].item_string);
3512 clearok(help_win, TRUE);
3513 for (counter = 0; counter < 22; counter++)
3515 wmove(help_win, counter, 0);
3516 waddstr(help_win, (emacs_keys_mode) ?
3517 emacs_help_text[counter] : help_text[counter]);
3521 wmove(com_win, 0, 0);
3522 wprintw(com_win, press_any_key_msg);
3524 counter = wgetch(com_win);
3528 wmove(com_win, 0, 0);
3544 for (counter = 0; counter < 5; counter++)
3546 wmove(info_win, counter, 0);
3547 wclrtoeol(info_win);
3548 if (info_type == CONTROL_KEYS)
3549 waddstr(info_win, (emacs_keys_mode) ?
3550 emacs_control_keys[counter] : control_keys[counter]);
3551 else if (info_type == COMMANDS)
3552 waddstr(info_win, command_strings[counter]);
3554 wmove(info_win, 5, 0);
3556 wstandout(info_win);
3557 waddstr(info_win, "===============================================================================");
3558 wstandend(info_win);
3569 info_window = FALSE;
3570 last_line = LINES - 2;
3571 text_win = newwin((LINES - 1), COLS, 0, 0);
3572 keypad(text_win, TRUE);
3573 idlok(text_win, TRUE);
3574 clearok(text_win, TRUE);
3575 midscreen(scr_vert, point);
3577 clear_com_win = TRUE;
3581 create_info_window()
3585 last_line = LINES - 8;
3587 text_win = newwin((LINES - 7), COLS, 6, 0);
3588 keypad(text_win, TRUE);
3589 idlok(text_win, TRUE);
3592 info_win = newwin(6, COLS, 0, 0);
3594 info_type = CONTROL_KEYS;
3595 midscreen(min(scr_vert, last_line), point);
3596 clearok(info_win, TRUE);
3599 clear_com_win = TRUE;
3609 if (restrict_mode())
3614 if (arg == READ_FILE)
3616 string = get_string(file_read_prompt_str, TRUE);
3618 tmp_file = resolve_name(string);
3620 if (tmp_file != string)
3624 else if (arg == WRITE_FILE)
3626 string = get_string(file_write_prompt_str, TRUE);
3627 tmp_file = resolve_name(string);
3628 write_file(tmp_file);
3629 if (tmp_file != string)
3633 else if (arg == SAVE_FILE)
3636 | changes made here should be reflected in finish()
3644 string = in_file_name;
3645 if ((string == NULL) || (*string == (char) NULL))
3646 string = get_string(save_file_name_prompt, TRUE);
3647 if ((string == NULL) || (*string == (char) NULL))
3649 wmove(com_win, 0, 0);
3650 wprintw(com_win, file_not_saved_msg);
3653 clear_com_win = TRUE;
3658 tmp_file = resolve_name(string);
3659 if (tmp_file != string)
3665 if (write_file(string))
3667 in_file_name = string;
3668 text_changes = FALSE;
3681 if (((string = get_string(shell_prompt, TRUE)) != NULL) &&
3682 (*string != (char) NULL))
3694 menu_op(leave_menu);
3705 clearok(info_win, TRUE);
3709 clearok(text_win, TRUE);
3710 midscreen(scr_vert, point);
3714 | The following routines will "format" a paragraph (as defined by a
3715 | block of text with blank lines before and after the block).
3719 Blank_Line(test_line) /* test if line has any non-space characters */
3720 struct text *test_line;
3725 if (test_line == NULL)
3729 line = test_line->line;
3732 | To handle troff/nroff documents, consider a line with a
3733 | period ('.') in the first column to be blank. To handle mail
3734 | messages with included text, consider a line with a '>' blank.
3737 if ((*line == '.') || (*line == '>'))
3740 while (((*line == ' ') || (*line == '\t')) && (length < test_line->line_length))
3745 if (length != test_line->line_length)
3752 Format() /* format the paragraph according to set margins */
3762 char *temp1, *temp2;
3764 char temp_d_char = d_char;
3767 | if observ_margins is not set, or the current line is blank,
3768 | do not format the current paragraph
3771 if ((!observ_margins) || (Blank_Line(curr_line)))
3775 | save the currently set flags, and clear them
3778 wmove(com_win, 0, 0);
3780 wprintw(com_win, formatting_msg);
3784 | get current position in paragraph, so after formatting, the cursor
3785 | will be in the same relative position
3788 tmp_af = auto_format;
3789 auto_format = FALSE;
3793 temp_dword = d_word;
3795 temp_case = case_sen;
3797 tmp_srchstr = srch_str;
3798 temp2 = srch_str = (char *) malloc(1 + curr_line->line_length - position);
3799 if ((*point == ' ') || (*point == '\t'))
3803 line = temp1 = point;
3804 while ((*temp1 != (char) NULL) && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length))
3811 *temp2 = (char) NULL;
3814 while (!Blank_Line(curr_line->prev_line))
3818 while ((line != point) && (status))
3820 status = search(FALSE);
3824 wmove(com_win, 0, 0);
3826 wprintw(com_win, formatting_msg);
3830 | now get back to the start of the paragraph to start formatting
3835 while (!Blank_Line(curr_line->prev_line))
3838 observ_margins = FALSE;
3841 | Start going through lines, putting spaces at end of lines if they do
3842 | not already exist. Append lines together to get one long line, and
3843 | eliminate spacing at begin of lines.
3846 while (!Blank_Line(curr_line->next_line))
3858 if ((*point == ' ') || (*point == '\t'))
3863 | Now there is one long line. Eliminate extra spaces within the line
3864 | after the first word (so as not to blow away any indenting the user
3870 while (position < curr_line->line_length)
3872 if ((*point == ' ') && (*(point + 1) == ' '))
3879 | Now make sure there are two spaces after a '.'.
3883 while (position < curr_line->line_length)
3885 if ((*point == '.') && (*(point + 1) == ' '))
3890 while (*point == ' ')
3896 observ_margins = TRUE;
3899 wmove(com_win, 0, 0);
3901 wprintw(com_win, formatting_msg);
3905 | create lines between margins
3908 while (position < curr_line->line_length)
3910 while ((scr_pos < right_margin) && (position < curr_line->line_length))
3912 if (position < curr_line->line_length)
3922 | go back to begin of paragraph, put cursor back to original position
3926 while (!Blank_Line(curr_line->prev_line))
3930 | find word cursor was in
3933 while ((status) && (string_count > 0))
3940 | offset the cursor to where it was before from the start of the word
3950 | reset flags and strings to what they were before formatting
3955 d_word = temp_dword;
3956 case_sen = temp_case;
3958 srch_str = tmp_srchstr;
3959 d_char = temp_d_char;
3960 auto_format = tmp_af;
3962 midscreen(scr_vert, point);
3967 char *init_name[3] = {
3968 "/usr/share/misc/init.ee",
3974 ee_init() /* check for init file and read it if it exists */
3984 string = getenv("HOME");
3986 string = "/root"; /* Set to reasonable default so we don't crash */
3987 str1 = home = malloc(strlen(string)+10);
3988 strcpy(home, string);
3989 strcat(home, "/.init.ee");
3990 init_name[1] = home;
3991 string = malloc(512);
3993 for (counter = 0; counter < 3; counter++)
3995 if (!(access(init_name[counter], 4)))
3997 init_file = fopen(init_name[counter], "r");
3998 while ((str2 = fgets(string, 512, init_file)) != NULL)
4000 str1 = str2 = string;
4001 while (*str2 != '\n')
4003 *str2 = (char) NULL;
4005 if (unique_test(string, init_strings) != 1)
4008 if (compare(str1, CASE, FALSE))
4010 else if (compare(str1, NOCASE, FALSE))
4012 else if (compare(str1, EXPAND, FALSE))
4014 else if (compare(str1, NOEXPAND, FALSE))
4015 expand_tabs = FALSE;
4016 else if (compare(str1, INFO, FALSE))
4018 else if (compare(str1, NOINFO, FALSE))
4019 info_window = FALSE;
4020 else if (compare(str1, MARGINS, FALSE))
4021 observ_margins = TRUE;
4022 else if (compare(str1, NOMARGINS, FALSE))
4023 observ_margins = FALSE;
4024 else if (compare(str1, AUTOFORMAT, FALSE))
4027 observ_margins = TRUE;
4029 else if (compare(str1, NOAUTOFORMAT, FALSE))
4030 auto_format = FALSE;
4031 else if (compare(str1, Echo, FALSE))
4033 str1 = next_word(str1);
4034 if (*str1 != (char) NULL)
4037 else if (compare(str1, PRINTCOMMAND, FALSE))
4039 str1 = next_word(str1);
4040 print_command = malloc(strlen(str1)+1);
4041 strcpy(print_command, str1);
4043 else if (compare(str1, RIGHTMARGIN, FALSE))
4045 str1 = next_word(str1);
4046 if ((*str1 >= '0') && (*str1 <= '9'))
4048 temp_int = atoi(str1);
4050 right_margin = temp_int;
4053 else if (compare(str1, HIGHLIGHT, FALSE))
4054 nohighlight = FALSE;
4055 else if (compare(str1, NOHIGHLIGHT, FALSE))
4057 else if (compare(str1, EIGHTBIT, FALSE))
4059 else if (compare(str1, NOEIGHTBIT, FALSE))
4061 else if (compare(str1, EMACS_string, FALSE))
4062 emacs_keys_mode = TRUE;
4063 else if (compare(str1, NOEMACS_string, FALSE))
4064 emacs_keys_mode = FALSE;
4074 | Save current configuration to .init.ee file in the current directory.
4081 FILE *old_init_file = NULL;
4082 char *file_name = ".init.ee";
4083 char *home_dir = "~/.init.ee";
4090 if (restrict_mode())
4095 option = menu_op(config_dump_menu);
4098 wmove(com_win, 0, 0);
4102 wprintw(com_win, conf_not_saved_msg);
4106 else if (option == 2)
4107 file_name = resolve_name(home_dir);
4110 | If a .init.ee file exists, move it to .init.ee.old.
4113 if (stat(file_name, &buf) != -1)
4115 sprintf(buffer, "%s.old", file_name);
4117 link(file_name, buffer);
4119 old_init_file = fopen(buffer, "r");
4122 init_file = fopen(file_name, "w");
4123 if (init_file == NULL)
4125 wprintw(com_win, conf_dump_err_msg);
4130 if (old_init_file != NULL)
4133 | Copy non-configuration info into new .init.ee file.
4135 while ((string = fgets(buffer, 512, old_init_file)) != NULL)
4137 length = strlen(string);
4138 string[length - 1] = (char) NULL;
4140 if (unique_test(string, init_strings) == 1)
4142 if (compare(string, Echo, FALSE))
4144 fprintf(init_file, "%s\n", string);
4148 fprintf(init_file, "%s\n", string);
4151 fclose(old_init_file);
4154 fprintf(init_file, "%s\n", case_sen ? CASE : NOCASE);
4155 fprintf(init_file, "%s\n", expand_tabs ? EXPAND : NOEXPAND);
4156 fprintf(init_file, "%s\n", info_window ? INFO : NOINFO );
4157 fprintf(init_file, "%s\n", observ_margins ? MARGINS : NOMARGINS );
4158 fprintf(init_file, "%s\n", auto_format ? AUTOFORMAT : NOAUTOFORMAT );
4159 fprintf(init_file, "%s %s\n", PRINTCOMMAND, print_command);
4160 fprintf(init_file, "%s %d\n", RIGHTMARGIN, right_margin);
4161 fprintf(init_file, "%s\n", nohighlight ? NOHIGHLIGHT : HIGHLIGHT );
4162 fprintf(init_file, "%s\n", eightbit ? EIGHTBIT : NOEIGHTBIT );
4163 fprintf(init_file, "%s\n", emacs_keys_mode ? EMACS_string : NOEMACS_string );
4167 wprintw(com_win, conf_dump_success_msg, file_name);
4170 if ((option == 2) && (file_name != home_dir))
4177 echo_string(string) /* echo the given string */
4184 while (*temp != (char) NULL)
4191 else if (*temp == 't')
4193 else if (*temp == 'b')
4195 else if (*temp == 'r')
4197 else if (*temp == 'f')
4199 else if ((*temp == 'e') || (*temp == 'E'))
4200 putchar('\033'); /* escape */
4201 else if (*temp == '\\')
4203 else if (*temp == '\'')
4205 else if ((*temp >= '0') && (*temp <= '9'))
4208 while ((*temp >= '0') && (*temp <= '9'))
4210 Counter = (8 * Counter) + (*temp - '0');
4229 spell_op() /* check spelling of words in the editor */
4231 if (restrict_mode())
4235 top(); /* go to top of file */
4236 insert_line(FALSE); /* create two blank lines */
4239 command(shell_echo_msg);
4241 wmove(com_win, 0, 0);
4242 wprintw(com_win, spell_in_prog_msg);
4244 command("<>!spell"); /* send contents of buffer to command 'spell'
4245 and read the results back into the editor */
4255 if (restrict_mode())
4260 sprintf(name, "/tmp/ee.%d", pid);
4261 if (write_file(name))
4263 sprintf(string, "ispell %s", name);
4274 first_word_len(test_line)
4275 struct text *test_line;
4280 if (test_line == NULL)
4283 pnt = test_line->line;
4284 if ((pnt == NULL) || (*pnt == (char) NULL) ||
4285 (*pnt == '.') || (*pnt == '>'))
4288 if ((*pnt == ' ') || (*pnt == '\t'))
4290 pnt = next_word(pnt);
4293 if (*pnt == (char) NULL)
4297 while ((*pnt != (char) NULL) && ((*pnt != ' ') && (*pnt != '\t')))
4302 while ((*pnt != (char) NULL) && ((*pnt == ' ') || (*pnt == '\t')))
4311 Auto_Format() /* format the paragraph according to set margins */
4318 int tmp_d_line_length;
4319 int leave_loop = FALSE;
4325 char *temp1, *temp2;
4327 char temp_d_char = d_char;
4331 | if observ_margins is not set, or the current line is blank,
4332 | do not format the current paragraph
4335 if ((!observ_margins) || (Blank_Line(curr_line)))
4339 | get current position in paragraph, so after formatting, the cursor
4340 | will be in the same relative position
4343 tmp_d_line = d_line;
4344 tmp_d_line_length = dlt_line->line_length;
4346 auto_format = FALSE;
4348 if ((position != 1) && ((*point == ' ') || (*point == '\t') || (position == curr_line->line_length) || (*point == (char) NULL)))
4350 temp_dword = d_word;
4351 temp_dwl = d_wrd_len;
4354 temp_case = case_sen;
4356 tmp_srchstr = srch_str;
4357 temp2 = srch_str = (char *) malloc(1 + curr_line->line_length - position);
4358 if ((*point == ' ') || (*point == '\t'))
4362 line = temp1 = point;
4363 while ((*temp1 != (char) NULL) && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length))
4370 *temp2 = (char) NULL;
4373 while (!Blank_Line(curr_line->prev_line))
4377 while ((line != point) && (status))
4379 status = search(FALSE);
4384 | now get back to the start of the paragraph to start checking
4389 while (!Blank_Line(curr_line->prev_line))
4393 | Start going through lines, putting spaces at end of lines if they do
4394 | not already exist. Check line length, and move words to the next line
4395 | if they cross the margin. Then get words from the next line if they
4396 | will fit in before the margin.
4403 if (position != curr_line->line_length)
4417 | fill line if first word on next line will fit
4418 | in the line without crossing the margin
4421 while ((curr_line->next_line != NULL) &&
4422 ((word_len = first_word_len(curr_line->next_line)) > 0)
4423 && ((scr_pos + word_len) < right_margin))
4426 if ((*point == ' ') || (*point == '\t'))
4433 | We know this line was not blank before, so
4434 | make sure that it doesn't have one of the
4435 | leading characters that indicate the line
4436 | should not be modified.
4438 | We also know that this character should not
4439 | be left as the first character of this line.
4442 if ((Blank_Line(curr_line)) &&
4443 (curr_line->line[0] != '.') &&
4444 (curr_line->line[0] != '>'))
4453 | go to end of previous line
4459 | make sure there's a space at the end of the line
4472 | make sure line does not cross right margin
4475 while (right_margin <= scr_pos)
4481 if (Blank_Line(curr_line->next_line))
4485 if ((*point == ' ') || (*point == '\t'))
4495 if ((!Blank_Line(curr_line->next_line)) || (not_blank))
4505 | go back to begin of paragraph, put cursor back to original position
4510 while ((counter-- > 0) || (!Blank_Line(curr_line->prev_line)))
4514 | find word cursor was in
4518 while ((status) && (string_count > 0))
4520 status = search(FALSE);
4525 | offset the cursor to where it was before from the start of the word
4534 if ((string_count > 0) && (offset < 0))
4544 | reset flags and strings to what they were before formatting
4549 d_word = temp_dword;
4550 d_wrd_len = temp_dwl;
4551 case_sen = temp_case;
4553 srch_str = tmp_srchstr;
4554 d_char = temp_d_char;
4556 dlt_line->line_length = tmp_d_line_length;
4557 d_line = tmp_d_line;
4560 midscreen(scr_vert, point);
4572 sprintf(modes_menu[1].item_string, "%s %s", mode_strings[1],
4573 (expand_tabs ? ON : OFF));
4574 sprintf(modes_menu[2].item_string, "%s %s", mode_strings[2],
4575 (case_sen ? ON : OFF));
4576 sprintf(modes_menu[3].item_string, "%s %s", mode_strings[3],
4577 (observ_margins ? ON : OFF));
4578 sprintf(modes_menu[4].item_string, "%s %s", mode_strings[4],
4579 (auto_format ? ON : OFF));
4580 sprintf(modes_menu[5].item_string, "%s %s", mode_strings[5],
4581 (eightbit ? ON : OFF));
4582 sprintf(modes_menu[6].item_string, "%s %s", mode_strings[6],
4583 (info_window ? ON : OFF));
4584 sprintf(modes_menu[7].item_string, "%s %s", mode_strings[7],
4585 (emacs_keys_mode ? ON : OFF));
4586 sprintf(modes_menu[8].item_string, "%s %d", mode_strings[8],
4589 ret_value = menu_op(modes_menu);
4594 expand_tabs = !expand_tabs;
4597 case_sen = !case_sen;
4600 observ_margins = !observ_margins;
4603 auto_format = !auto_format;
4605 observ_margins = TRUE;
4608 eightbit = !eightbit;
4610 wnoutrefresh(text_win);
4616 create_info_window();
4619 emacs_keys_mode = !emacs_keys_mode;
4624 string = get_string(margin_prompt, TRUE);
4627 counter = atoi(string);
4629 right_margin = counter;
4637 while (ret_value != 0);
4641 is_in_string(string, substring) /* a strchr() look-alike for systems without
4643 char * string, *substring;
4647 for (sub = substring; (sub != NULL) && (*sub != (char)NULL); sub++)
4649 for (full = string; (full != NULL) && (*full != (char)NULL);
4660 | handle names of the form "~/file", "~user/file",
4661 | "$HOME/foo", "~/$FOO", etc.
4668 char long_buffer[1024];
4669 char short_buffer[128];
4677 struct passwd *user;
4684 user = (struct passwd *) getpwuid(index);
4689 slash = strchr(name, '/');
4692 *slash = (char) NULL;
4693 user = (struct passwd *) getpwnam((name + 1));
4700 buffer = malloc(strlen(user->pw_dir) + strlen(slash) + 1);
4701 strcpy(buffer, user->pw_dir);
4702 strcat(buffer, slash);
4707 if (is_in_string(buffer, "$"))
4712 while ((*tmp != (char) NULL) && (index < 1024))
4715 while ((*tmp != (char) NULL) && (*tmp != '$') &&
4718 long_buffer[index] = *tmp;
4723 if ((*tmp == '$') && (index < 1024))
4728 if (*tmp == '{') /* } */ /* bracketed variable name */
4731 while ((*tmp != (char) NULL) &&
4735 short_buffer[counter] = *tmp;
4744 while ((*tmp != (char) NULL) &&
4749 short_buffer[counter] = *tmp;
4754 short_buffer[counter] = (char) NULL;
4755 if ((slash = getenv(short_buffer)) != NULL)
4757 offset = strlen(slash);
4758 if ((offset + index) < 1024)
4759 strcpy(&long_buffer[index], slash);
4764 while ((start_of_var != tmp) && (index < 1024))
4766 long_buffer[index] = *start_of_var;
4777 long_buffer[index] = (char) NULL;
4781 buffer = malloc(index + 1);
4782 strcpy(buffer, long_buffer);
4794 wmove(com_win, 0, 0);
4795 wprintw(com_win, restricted_msg);
4798 clear_com_win = TRUE;
4803 | The following routine tests the input string against the list of
4804 | strings, to determine if the string is a unique match with one of the
4809 unique_test(string, list)
4819 while (list[counter] != NULL)
4821 result = compare(string, list[counter], FALSE);
4831 | Get the catalog entry, and if it got it from the catalog,
4832 | make a copy, since the buffer will be overwritten by the
4833 | next call to catgets().
4837 catgetlocal(number, string)
4844 temp1 = catgets(catalog, 1, number, string);
4845 if (temp1 != string)
4847 temp2 = malloc(strlen(temp1) + 1);
4848 strcpy(temp2, temp1);
4853 #endif /* NO_CATGETS */
4856 | The following is to allow for using message catalogs which allow
4857 | the software to be 'localized', that is, to use different languages
4858 | all with the same binary. For more information, see your system
4859 | documentation, or the X/Open Internationalization Guide.
4868 setlocale(LC_ALL, "");
4869 catalog = catopen("ee", NL_CAT_LOCALE);
4870 #endif /* NO_CATGETS */
4872 modes_menu[0].item_string = catgetlocal( 1, "modes menu");
4873 mode_strings[1] = catgetlocal( 2, "tabs to spaces ");
4874 mode_strings[2] = catgetlocal( 3, "case sensitive search");
4875 mode_strings[3] = catgetlocal( 4, "margins observed ");
4876 mode_strings[4] = catgetlocal( 5, "auto-paragraph format");
4877 mode_strings[5] = catgetlocal( 6, "eightbit characters ");
4878 mode_strings[6] = catgetlocal( 7, "info window ");
4879 mode_strings[8] = catgetlocal( 8, "right margin ");
4880 leave_menu[0].item_string = catgetlocal( 9, "leave menu");
4881 leave_menu[1].item_string = catgetlocal( 10, "save changes");
4882 leave_menu[2].item_string = catgetlocal( 11, "no save");
4883 file_menu[0].item_string = catgetlocal( 12, "file menu");
4884 file_menu[1].item_string = catgetlocal( 13, "read a file");
4885 file_menu[2].item_string = catgetlocal( 14, "write a file");
4886 file_menu[3].item_string = catgetlocal( 15, "save file");
4887 file_menu[4].item_string = catgetlocal( 16, "print editor contents");
4888 search_menu[0].item_string = catgetlocal( 17, "search menu");
4889 search_menu[1].item_string = catgetlocal( 18, "search for ...");
4890 search_menu[2].item_string = catgetlocal( 19, "search");
4891 spell_menu[0].item_string = catgetlocal( 20, "spell menu");
4892 spell_menu[1].item_string = catgetlocal( 21, "use 'spell'");
4893 spell_menu[2].item_string = catgetlocal( 22, "use 'ispell'");
4894 misc_menu[0].item_string = catgetlocal( 23, "miscellaneous menu");
4895 misc_menu[1].item_string = catgetlocal( 24, "format paragraph");
4896 misc_menu[2].item_string = catgetlocal( 25, "shell command");
4897 misc_menu[3].item_string = catgetlocal( 26, "check spelling");
4898 main_menu[0].item_string = catgetlocal( 27, "main menu");
4899 main_menu[1].item_string = catgetlocal( 28, "leave editor");
4900 main_menu[2].item_string = catgetlocal( 29, "help");
4901 main_menu[3].item_string = catgetlocal( 30, "file operations");
4902 main_menu[4].item_string = catgetlocal( 31, "redraw screen");
4903 main_menu[5].item_string = catgetlocal( 32, "settings");
4904 main_menu[6].item_string = catgetlocal( 33, "search");
4905 main_menu[7].item_string = catgetlocal( 34, "miscellaneous");
4906 help_text[0] = catgetlocal( 35, "Control keys: ");
4907 help_text[1] = catgetlocal( 36, "^a ascii code ^i tab ^r right ");
4908 help_text[2] = catgetlocal( 37, "^b bottom of text ^j newline ^t top of text ");
4909 help_text[3] = catgetlocal( 38, "^c command ^k delete char ^u up ");
4910 help_text[4] = catgetlocal( 39, "^d down ^l left ^v undelete word ");
4911 help_text[5] = catgetlocal( 40, "^e search prompt ^m newline ^w delete word ");
4912 help_text[6] = catgetlocal( 41, "^f undelete char ^n next page ^x search ");
4913 help_text[7] = catgetlocal( 42, "^g begin of line ^o end of line ^y delete line ");
4914 help_text[8] = catgetlocal( 43, "^h backspace ^p prev page ^z undelete line ");
4915 help_text[9] = catgetlocal( 44, "^[ (escape) menu ESC-Enter: exit ee ");
4916 help_text[10] = catgetlocal( 45, " ");
4917 help_text[11] = catgetlocal( 46, "Commands: ");
4918 help_text[12] = catgetlocal( 47, "help : get this info file : print file name ");
4919 help_text[13] = catgetlocal( 48, "read : read a file char : ascii code of char ");
4920 help_text[14] = catgetlocal( 49, "write : write a file case : case sensitive search ");
4921 help_text[15] = catgetlocal( 50, "exit : leave and save nocase : case insensitive search ");
4922 help_text[16] = catgetlocal( 51, "quit : leave, no save !cmd : execute \"cmd\" in shell ");
4923 help_text[17] = catgetlocal( 52, "line : display line # 0-9 : go to line \"#\" ");
4924 help_text[18] = catgetlocal( 53, "expand : expand tabs noexpand: do not expand tabs ");
4925 help_text[19] = catgetlocal( 54, " ");
4926 help_text[20] = catgetlocal( 55, " ee [-i] [-e] [-h] [file(s)] ");
4927 help_text[21] = catgetlocal( 56, " -i : no information window -e : do not expand tabs -h : no highlight ");
4928 control_keys[0] = catgetlocal( 57, "^[ (escape) menu ^e search prompt ^y delete line ^u up ^p prev page ");
4929 control_keys[1] = catgetlocal( 58, "^a ascii code ^x search ^z undelete line ^d down ^n next page ");
4930 control_keys[2] = catgetlocal( 59, "^b bottom of text ^g begin of line ^w delete word ^l left ");
4931 control_keys[3] = catgetlocal( 60, "^t top of text ^o end of line ^v undelete word ^r right ");
4932 control_keys[4] = catgetlocal( 61, "^c command ^k delete char ^f undelete char ESC-Enter: exit ee ");
4933 command_strings[0] = catgetlocal( 62, "help : get help info |file : print file name |line : print line # ");
4934 command_strings[1] = catgetlocal( 63, "read : read a file |char : ascii code of char |0-9 : go to line \"#\"");
4935 command_strings[2] = catgetlocal( 64, "write: write a file |case : case sensitive search |exit : leave and save ");
4936 command_strings[3] = catgetlocal( 65, "!cmd : shell \"cmd\" |nocase: ignore case in search |quit : leave, no save");
4937 command_strings[4] = catgetlocal( 66, "expand: expand tabs |noexpand: do not expand tabs ");
4938 com_win_message = catgetlocal( 67, " press Escape (^[) for menu");
4939 no_file_string = catgetlocal( 68, "no file");
4940 ascii_code_str = catgetlocal( 69, "ascii code: ");
4941 printer_msg_str = catgetlocal( 70, "sending contents of buffer to \"%s\" ");
4942 command_str = catgetlocal( 71, "command: ");
4943 file_write_prompt_str = catgetlocal( 72, "name of file to write: ");
4944 file_read_prompt_str = catgetlocal( 73, "name of file to read: ");
4945 char_str = catgetlocal( 74, "character = %d");
4946 unkn_cmd_str = catgetlocal( 75, "unknown command \"%s\"");
4947 non_unique_cmd_msg = catgetlocal( 76, "entered command is not unique");
4948 line_num_str = catgetlocal( 77, "line %d ");
4949 line_len_str = catgetlocal( 78, "length = %d");
4950 current_file_str = catgetlocal( 79, "current file is \"%s\" ");
4951 usage0 = catgetlocal( 80, "usage: %s [-i] [-e] [-h] [+line_number] [file(s)]\n");
4952 usage1 = catgetlocal( 81, " -i turn off info window\n");
4953 usage2 = catgetlocal( 82, " -e do not convert tabs to spaces\n");
4954 usage3 = catgetlocal( 83, " -h do not use highlighting\n");
4955 file_is_dir_msg = catgetlocal( 84, "file \"%s\" is a directory");
4956 new_file_msg = catgetlocal( 85, "new file \"%s\"");
4957 cant_open_msg = catgetlocal( 86, "can't open \"%s\"");
4958 open_file_msg = catgetlocal( 87, "file \"%s\", %d lines");
4959 file_read_fin_msg = catgetlocal( 88, "finished reading file \"%s\"");
4960 reading_file_msg = catgetlocal( 89, "reading file \"%s\"");
4961 read_only_msg = catgetlocal( 90, ", read only");
4962 file_read_lines_msg = catgetlocal( 91, "file \"%s\", %d lines");
4963 save_file_name_prompt = catgetlocal( 92, "enter name of file: ");
4964 file_not_saved_msg = catgetlocal( 93, "no filename entered: file not saved");
4965 changes_made_prompt = catgetlocal( 94, "changes have been made, are you sure? (y/n [n]) ");
4966 yes_char = catgetlocal( 95, "y");
4967 file_exists_prompt = catgetlocal( 96, "file already exists, overwrite? (y/n) [n] ");
4968 create_file_fail_msg = catgetlocal( 97, "unable to create file \"%s\"");
4969 writing_file_msg = catgetlocal( 98, "writing file \"%s\"");
4970 file_written_msg = catgetlocal( 99, "\"%s\" %d lines, %d characters");
4971 searching_msg = catgetlocal( 100, " ...searching");
4972 str_not_found_msg = catgetlocal( 101, "string \"%s\" not found");
4973 search_prompt_str = catgetlocal( 102, "search for: ");
4974 exec_err_msg = catgetlocal( 103, "could not exec %s");
4975 continue_msg = catgetlocal( 104, "press return to continue ");
4976 menu_cancel_msg = catgetlocal( 105, "press Esc to cancel");
4977 menu_size_err_msg = catgetlocal( 106, "menu too large for window");
4978 press_any_key_msg = catgetlocal( 107, "press any key to continue ");
4979 shell_prompt = catgetlocal( 108, "shell command: ");
4980 formatting_msg = catgetlocal( 109, "...formatting paragraph...");
4981 shell_echo_msg = catgetlocal( 110, "<!echo 'list of unrecognized words'; echo -=-=-=-=-=-");
4982 spell_in_prog_msg = catgetlocal( 111, "sending contents of edit buffer to 'spell'");
4983 margin_prompt = catgetlocal( 112, "right margin is: ");
4984 restricted_msg = catgetlocal( 113, "restricted mode: unable to perform requested operation");
4985 ON = catgetlocal( 114, "ON");
4986 OFF = catgetlocal( 115, "OFF");
4987 HELP = catgetlocal( 116, "HELP");
4988 WRITE = catgetlocal( 117, "WRITE");
4989 READ = catgetlocal( 118, "READ");
4990 LINE = catgetlocal( 119, "LINE");
4991 FILE_str = catgetlocal( 120, "FILE");
4992 CHARACTER = catgetlocal( 121, "CHARACTER");
4993 REDRAW = catgetlocal( 122, "REDRAW");
4994 RESEQUENCE = catgetlocal( 123, "RESEQUENCE");
4995 AUTHOR = catgetlocal( 124, "AUTHOR");
4996 VERSION = catgetlocal( 125, "VERSION");
4997 CASE = catgetlocal( 126, "CASE");
4998 NOCASE = catgetlocal( 127, "NOCASE");
4999 EXPAND = catgetlocal( 128, "EXPAND");
5000 NOEXPAND = catgetlocal( 129, "NOEXPAND");
5001 Exit_string = catgetlocal( 130, "EXIT");
5002 QUIT_string = catgetlocal( 131, "QUIT");
5003 INFO = catgetlocal( 132, "INFO");
5004 NOINFO = catgetlocal( 133, "NOINFO");
5005 MARGINS = catgetlocal( 134, "MARGINS");
5006 NOMARGINS = catgetlocal( 135, "NOMARGINS");
5007 AUTOFORMAT = catgetlocal( 136, "AUTOFORMAT");
5008 NOAUTOFORMAT = catgetlocal( 137, "NOAUTOFORMAT");
5009 Echo = catgetlocal( 138, "ECHO");
5010 PRINTCOMMAND = catgetlocal( 139, "PRINTCOMMAND");
5011 RIGHTMARGIN = catgetlocal( 140, "RIGHTMARGIN");
5012 HIGHLIGHT = catgetlocal( 141, "HIGHLIGHT");
5013 NOHIGHLIGHT = catgetlocal( 142, "NOHIGHLIGHT");
5014 EIGHTBIT = catgetlocal( 143, "EIGHTBIT");
5015 NOEIGHTBIT = catgetlocal( 144, "NOEIGHTBIT");
5019 mode_strings[7] = catgetlocal( 145, "emacs key bindings ");
5020 emacs_help_text[0] = help_text[0];
5021 emacs_help_text[1] = catgetlocal( 146, "^a beginning of line ^i tab ^r restore word ");
5022 emacs_help_text[2] = catgetlocal( 147, "^b back 1 char ^j undel char ^t begin of file ");
5023 emacs_help_text[3] = catgetlocal( 148, "^c command ^k delete line ^u end of file ");
5024 emacs_help_text[4] = catgetlocal( 149, "^d delete char ^l undelete line ^v next page ");
5025 emacs_help_text[5] = catgetlocal( 150, "^e end of line ^m newline ^w delete word ");
5026 emacs_help_text[6] = catgetlocal( 151, "^f forward 1 char ^n next line ^x search ");
5027 emacs_help_text[7] = catgetlocal( 152, "^g go back 1 page ^o ascii char insert ^y search prompt ");
5028 emacs_help_text[8] = catgetlocal( 153, "^h backspace ^p prev line ^z next word ");
5029 emacs_help_text[9] = help_text[9];
5030 emacs_help_text[10] = help_text[10];
5031 emacs_help_text[11] = help_text[11];
5032 emacs_help_text[12] = help_text[12];
5033 emacs_help_text[13] = help_text[13];
5034 emacs_help_text[14] = help_text[14];
5035 emacs_help_text[15] = help_text[15];
5036 emacs_help_text[16] = help_text[16];
5037 emacs_help_text[17] = help_text[17];
5038 emacs_help_text[18] = help_text[18];
5039 emacs_help_text[19] = help_text[19];
5040 emacs_help_text[20] = help_text[20];
5041 emacs_help_text[21] = help_text[21];
5042 emacs_control_keys[0] = catgetlocal( 154, "^[ (escape) menu ^y search prompt ^k delete line ^p prev line ^g prev page");
5043 emacs_control_keys[1] = catgetlocal( 155, "^o ascii code ^x search ^l undelete line ^n next line ^v next page");
5044 emacs_control_keys[2] = catgetlocal( 156, "^u end of file ^a begin of line ^w delete word ^b back char ^z next word");
5045 emacs_control_keys[3] = catgetlocal( 157, "^t begin of file ^e end of line ^r restore word ^f forward char ");
5046 emacs_control_keys[4] = catgetlocal( 158, "^c command ^d delete char ^j undelete char ESC-Enter: exit");
5047 EMACS_string = catgetlocal( 159, "EMACS");
5048 NOEMACS_string = catgetlocal( 160, "NOEMACS");
5049 usage4 = catgetlocal( 161, " +# put cursor at line #\n");
5050 conf_dump_err_msg = catgetlocal( 162, "unable to open .init.ee for writing, no configuration saved!");
5051 conf_dump_success_msg = catgetlocal( 163, "ee configuration saved in file %s");
5052 modes_menu[9].item_string = catgetlocal( 164, "save editor configuration");
5053 config_dump_menu[0].item_string = catgetlocal( 165, "save ee configuration");
5054 config_dump_menu[1].item_string = catgetlocal( 166, "save in current directory");
5055 config_dump_menu[2].item_string = catgetlocal( 167, "save in home directory");
5056 conf_not_saved_msg = catgetlocal( 168, "ee configuration not saved");
5057 ree_no_file_msg = catgetlocal( 169, "must specify a file when invoking ree");
5058 cancel_string = catgetlocal( 170, "press Esc to cancel");
5059 menu_too_lrg_msg = catgetlocal( 180, "menu too large for window");
5060 more_above_str = catgetlocal( 181, "^^more^^");
5061 more_below_str = catgetlocal( 182, "VVmoreVV");
5064 commands[1] = WRITE;
5067 commands[4] = FILE_str;
5068 commands[5] = REDRAW;
5069 commands[6] = RESEQUENCE;
5070 commands[7] = AUTHOR;
5071 commands[8] = VERSION;
5073 commands[10] = NOCASE;
5074 commands[11] = EXPAND;
5075 commands[12] = NOEXPAND;
5076 commands[13] = Exit_string;
5077 commands[14] = QUIT_string;
5091 commands[28] = CHARACTER;
5092 commands[29] = NULL;
5093 init_strings[0] = CASE;
5094 init_strings[1] = NOCASE;
5095 init_strings[2] = EXPAND;
5096 init_strings[3] = NOEXPAND;
5097 init_strings[4] = INFO;
5098 init_strings[5] = NOINFO;
5099 init_strings[6] = MARGINS;
5100 init_strings[7] = NOMARGINS;
5101 init_strings[8] = AUTOFORMAT;
5102 init_strings[9] = NOAUTOFORMAT;
5103 init_strings[10] = Echo;
5104 init_strings[11] = PRINTCOMMAND;
5105 init_strings[12] = RIGHTMARGIN;
5106 init_strings[13] = HIGHLIGHT;
5107 init_strings[14] = NOHIGHLIGHT;
5108 init_strings[15] = EIGHTBIT;
5109 init_strings[16] = NOEIGHTBIT;
5110 init_strings[17] = EMACS_string;
5111 init_strings[18] = NOEMACS_string;
5112 init_strings[19] = NULL;
5115 | allocate space for strings here for settings menu
5118 for (counter = 1; counter < NUM_MODES_ITEMS; counter++)
5120 modes_menu[counter].item_string = malloc(80);
5125 #endif /* NO_CATGETS */