ee.c (199123) | ee.c (213567) |
---|---|
1/* 2 | ee (easy editor) 3 | 4 | An easy to use, simple screen oriented editor. 5 | 6 | written by Hugh Mahon 7 | 8 | --- 36 unchanged lines hidden (view full) --- 45 | ee is intended to be compiled by people with little computer 46 | experience, which means that it needs to be small, relatively 47 | simple in implementation, and portable. 48 | 49 | This software and documentation contains 50 | proprietary information which is protected by 51 | copyright. All rights are reserved. 52 | | 1/* 2 | ee (easy editor) 3 | 4 | An easy to use, simple screen oriented editor. 5 | 6 | written by Hugh Mahon 7 | 8 | --- 36 unchanged lines hidden (view full) --- 45 | ee is intended to be compiled by people with little computer 46 | experience, which means that it needs to be small, relatively 47 | simple in implementation, and portable. 48 | 49 | This software and documentation contains 50 | proprietary information which is protected by 51 | copyright. All rights are reserved. 52 | |
53 | $Header: /home/hugh/sources/old_ae/RCS/ee.c,v 1.102 2009/02/17 03:22:50 hugh Exp hugh $ | 53 | $Header: /home/hugh/sources/old_ae/RCS/ee.c,v 1.104 2010/06/04 01:55:31 hugh Exp hugh $ |
54 | 55 */ 56 57#include <sys/cdefs.h> | 54 | 55 */ 56 57#include <sys/cdefs.h> |
58__FBSDID("$FreeBSD: head/contrib/ee/ee.c 199123 2009-11-10 00:48:24Z delphij $"); | 58__FBSDID("$FreeBSD: head/contrib/ee/ee.c 213567 2010-10-08 09:43:06Z ed $"); |
59 60char *ee_copyright_message = 61"Copyright (c) 1986, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2009 Hugh Mahon "; 62 63#include "ee_version.h" 64 | 59 60char *ee_copyright_message = 61"Copyright (c) 1986, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2009 Hugh Mahon "; 62 63#include "ee_version.h" 64 |
65char *version = "@(#) ee, version " EE_VERSION " $Revision: 1.102 $"; | 65char *version = "@(#) ee, version " EE_VERSION " $Revision: 1.104 $"; |
66 67#ifdef NCURSE 68#include "new_curse.h" 69#elif HAS_NCURSES 70#include <ncurses.h> 71#else 72#include <curses.h> 73#endif --- 228 unchanged lines hidden (view full) --- 302void search_prompt P_((void)); 303void del_char P_((void)); 304void undel_char P_((void)); 305void del_word P_((void)); 306void undel_word P_((void)); 307void del_line P_((void)); 308void undel_line P_((void)); 309void adv_word P_((void)); | 66 67#ifdef NCURSE 68#include "new_curse.h" 69#elif HAS_NCURSES 70#include <ncurses.h> 71#else 72#include <curses.h> 73#endif --- 228 unchanged lines hidden (view full) --- 302void search_prompt P_((void)); 303void del_char P_((void)); 304void undel_char P_((void)); 305void del_word P_((void)); 306void undel_word P_((void)); 307void del_line P_((void)); 308void undel_line P_((void)); 309void adv_word P_((void)); |
310void move_rel P_((char *direction, int lines)); | 310void move_rel P_((char direction, int lines)); |
311void eol P_((void)); 312void bol P_((void)); 313void adv_line P_((void)); 314void sh_command P_((char *string)); 315void set_up_term P_((void)); 316void resize_check P_((void)); 317int menu_op P_((struct menu_entries *)); 318void 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)); --- 492 unchanged lines hidden (view full) --- 811 } 812 while (temp_pos <= curr_line->line_length) 813 { 814 temp_pos++; 815 *tp = *temp2; 816 tp++; 817 temp2++; 818 } | 311void eol P_((void)); 312void bol P_((void)); 313void adv_line P_((void)); 314void sh_command P_((char *string)); 315void set_up_term P_((void)); 316void resize_check P_((void)); 317int menu_op P_((struct menu_entries *)); 318void 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)); --- 492 unchanged lines hidden (view full) --- 811 } 812 while (temp_pos <= curr_line->line_length) 813 { 814 temp_pos++; 815 *tp = *temp2; 816 tp++; 817 temp2++; 818 } |
819 if (scr_horz < horiz_offset) | 819 if ((scr_horz < horiz_offset) && (horiz_offset > 0)) |
820 { 821 horiz_offset -= 8; 822 midscreen(scr_vert, point); 823 } 824 } 825 else if (curr_line->prev_line != NULL) 826 { | 820 { 821 horiz_offset -= 8; 822 midscreen(scr_vert, point); 823 } 824 } 825 else if (curr_line->prev_line != NULL) 826 { |
827 absolute_lin--; | |
828 text_changes = TRUE; 829 left(disp); /* go to previous line */ 830 temp_buff = curr_line->next_line; 831 point = resiz_line(temp_buff->line_length, curr_line, position); 832 if (temp_buff->next_line != NULL) 833 temp_buff->next_line->prev_line = curr_line; 834 curr_line->next_line = temp_buff->next_line; 835 temp2 = temp_buff->line; --- 379 unchanged lines hidden (view full) --- 1215 insert_line(TRUE); 1216 else if (in == 11) /* control k */ 1217 del_char(); 1218 else if (in == 12) /* control l */ 1219 left(TRUE); 1220 else if (in == 13) /* control m */ 1221 insert_line(TRUE); 1222 else if (in == 14) /* control n */ | 827 text_changes = TRUE; 828 left(disp); /* go to previous line */ 829 temp_buff = curr_line->next_line; 830 point = resiz_line(temp_buff->line_length, curr_line, position); 831 if (temp_buff->next_line != NULL) 832 temp_buff->next_line->prev_line = curr_line; 833 curr_line->next_line = temp_buff->next_line; 834 temp2 = temp_buff->line; --- 379 unchanged lines hidden (view full) --- 1214 insert_line(TRUE); 1215 else if (in == 11) /* control k */ 1216 del_char(); 1217 else if (in == 12) /* control l */ 1218 left(TRUE); 1219 else if (in == 13) /* control m */ 1220 insert_line(TRUE); 1221 else if (in == 14) /* control n */ |
1223 move_rel("d", max(5, (last_line - 5))); | 1222 move_rel('d', max(5, (last_line - 5))); |
1224 else if (in == 15) /* control o */ 1225 eol(); 1226 else if (in == 16) /* control p */ | 1223 else if (in == 15) /* control o */ 1224 eol(); 1225 else if (in == 16) /* control p */ |
1227 move_rel("u", max(5, (last_line - 5))); | 1226 move_rel('u', max(5, (last_line - 5))); |
1228 else if (in == 17) /* control q */ 1229 ; 1230 else if (in == 18) /* control r */ 1231 right(TRUE); 1232 else if (in == 19) /* control s */ 1233 ; 1234 else if (in == 20) /* control t */ 1235 top(); --- 34 unchanged lines hidden (view full) --- 1270 } 1271 else if (in == 4) /* control d */ 1272 del_char(); 1273 else if (in == 5) /* control e */ 1274 eol(); 1275 else if (in == 6) /* control f */ 1276 right(TRUE); 1277 else if (in == 7) /* control g */ | 1227 else if (in == 17) /* control q */ 1228 ; 1229 else if (in == 18) /* control r */ 1230 right(TRUE); 1231 else if (in == 19) /* control s */ 1232 ; 1233 else if (in == 20) /* control t */ 1234 top(); --- 34 unchanged lines hidden (view full) --- 1269 } 1270 else if (in == 4) /* control d */ 1271 del_char(); 1272 else if (in == 5) /* control e */ 1273 eol(); 1274 else if (in == 6) /* control f */ 1275 right(TRUE); 1276 else if (in == 7) /* control g */ |
1278 move_rel("u", max(5, (last_line - 5))); | 1277 move_rel('u', max(5, (last_line - 5))); |
1279 else if (in == 8) /* control h */ 1280 delete(TRUE); 1281 else if (in == 9) /* control i */ 1282 ; 1283 else if (in == 10) /* control j */ 1284 undel_char(); 1285 else if (in == 11) /* control k */ 1286 del_line(); --- 22 unchanged lines hidden (view full) --- 1309 undel_word(); 1310 else if (in == 19) /* control s */ 1311 ; 1312 else if (in == 20) /* control t */ 1313 top(); 1314 else if (in == 21) /* control u */ 1315 bottom(); 1316 else if (in == 22) /* control v */ | 1278 else if (in == 8) /* control h */ 1279 delete(TRUE); 1280 else if (in == 9) /* control i */ 1281 ; 1282 else if (in == 10) /* control j */ 1283 undel_char(); 1284 else if (in == 11) /* control k */ 1285 del_line(); --- 22 unchanged lines hidden (view full) --- 1308 undel_word(); 1309 else if (in == 19) /* control s */ 1310 ; 1311 else if (in == 20) /* control t */ 1312 top(); 1313 else if (in == 21) /* control u */ 1314 bottom(); 1315 else if (in == 22) /* control v */ |
1317 move_rel("d", max(5, (last_line - 5))); | 1316 move_rel('d', max(5, (last_line - 5))); |
1318 else if (in == 23) /* control w */ 1319 del_word(); 1320 else if (in == 24) /* control x */ 1321 search(TRUE); 1322 else if (in == 25) /* control y */ 1323 search_prompt(); 1324 else if (in == 26) /* control z */ 1325 adv_word(); --- 218 unchanged lines hidden (view full) --- 1544 bol(); 1545 else if (in == KEY_END) 1546 eol(); 1547 else if (in == KEY_UP) 1548 up(); 1549 else if (in == KEY_DOWN) 1550 down(); 1551 else if (in == KEY_NPAGE) | 1317 else if (in == 23) /* control w */ 1318 del_word(); 1319 else if (in == 24) /* control x */ 1320 search(TRUE); 1321 else if (in == 25) /* control y */ 1322 search_prompt(); 1323 else if (in == 26) /* control z */ 1324 adv_word(); --- 218 unchanged lines hidden (view full) --- 1543 bol(); 1544 else if (in == KEY_END) 1545 eol(); 1546 else if (in == KEY_UP) 1547 up(); 1548 else if (in == KEY_DOWN) 1549 down(); 1550 else if (in == KEY_NPAGE) |
1552 move_rel("d", max( 5, (last_line - 5))); | 1551 move_rel('d', max( 5, (last_line - 5))); |
1553 else if (in == KEY_PPAGE) | 1552 else if (in == KEY_PPAGE) |
1554 move_rel("u", max(5, (last_line - 5))); | 1553 move_rel('u', max(5, (last_line - 5))); |
1555 else if (in == KEY_DL) 1556 del_line(); 1557 else if (in == KEY_DC) 1558 del_char(); 1559 else if (in == KEY_BACKSPACE) 1560 delete(TRUE); 1561 else if (in == KEY_IL) 1562 { /* insert a line before current line */ --- 421 unchanged lines hidden (view full) --- 1984 1985void 1986goto_line(cmd_str) 1987char *cmd_str; 1988{ 1989 int number; 1990 int i; 1991 char *ptr; | 1554 else if (in == KEY_DL) 1555 del_line(); 1556 else if (in == KEY_DC) 1557 del_char(); 1558 else if (in == KEY_BACKSPACE) 1559 delete(TRUE); 1560 else if (in == KEY_IL) 1561 { /* insert a line before current line */ --- 421 unchanged lines hidden (view full) --- 1983 1984void 1985goto_line(cmd_str) 1986char *cmd_str; 1987{ 1988 int number; 1989 int i; 1990 char *ptr; |
1992 char *direction = "d"; | 1991 char direction = '\0'; |
1993 struct text *t_line; 1994 1995 ptr = cmd_str; 1996 i= 0; 1997 while ((*ptr >='0') && (*ptr <= '9')) 1998 { 1999 i= i * 10 + (*ptr - '0'); 2000 ptr++; 2001 } 2002 number = i; 2003 i = 0; 2004 t_line = curr_line; 2005 while ((t_line->line_number > number) && (t_line->prev_line != NULL)) 2006 { 2007 i++; 2008 t_line = t_line->prev_line; | 1992 struct text *t_line; 1993 1994 ptr = cmd_str; 1995 i= 0; 1996 while ((*ptr >='0') && (*ptr <= '9')) 1997 { 1998 i= i * 10 + (*ptr - '0'); 1999 ptr++; 2000 } 2001 number = i; 2002 i = 0; 2003 t_line = curr_line; 2004 while ((t_line->line_number > number) && (t_line->prev_line != NULL)) 2005 { 2006 i++; 2007 t_line = t_line->prev_line; |
2009 direction = "u"; | 2008 direction = 'u'; |
2010 } 2011 while ((t_line->line_number < number) && (t_line->next_line != NULL)) 2012 { 2013 i++; | 2009 } 2010 while ((t_line->line_number < number) && (t_line->next_line != NULL)) 2011 { 2012 i++; |
2014 direction = "d"; | 2013 direction = 'd'; |
2015 t_line = t_line->next_line; 2016 } 2017 if ((i < 30) && (i > 0)) 2018 { 2019 move_rel(direction, i); 2020 } 2021 else 2022 { | 2014 t_line = t_line->next_line; 2015 } 2016 if ((i < 30) && (i > 0)) 2017 { 2018 move_rel(direction, i); 2019 } 2020 else 2021 { |
2023 if (!strcmp(direction, "d")) | 2022 if (direction != 'd') |
2024 { 2025 absolute_lin += i; 2026 } 2027 else 2028 { 2029 absolute_lin -= i; 2030 } 2031 curr_line = t_line; --- 180 unchanged lines hidden (view full) --- 2212 point = curr_line->line; 2213 draw_screen(); 2214 if (input_file) 2215 { 2216 input_file = FALSE; 2217 if (start_at_line != NULL) 2218 { 2219 line_num = atoi(start_at_line) - 1; | 2023 { 2024 absolute_lin += i; 2025 } 2026 else 2027 { 2028 absolute_lin -= i; 2029 } 2030 curr_line = t_line; --- 180 unchanged lines hidden (view full) --- 2211 point = curr_line->line; 2212 draw_screen(); 2213 if (input_file) 2214 { 2215 input_file = FALSE; 2216 if (start_at_line != NULL) 2217 { 2218 line_num = atoi(start_at_line) - 1; |
2220 move_rel("d", line_num); | 2219 move_rel('d', line_num); |
2221 line_num = 0; 2222 start_at_line = NULL; 2223 } 2224 } 2225 else 2226 { 2227 wmove(com_win, 0, 0); 2228 wclrtoeol(com_win); --- 426 unchanged lines hidden (view full) --- 2655 { 2656 while (position < iter) 2657 right(TRUE); 2658 } 2659 else 2660 { 2661 if (lines_moved < 30) 2662 { | 2220 line_num = 0; 2221 start_at_line = NULL; 2222 } 2223 } 2224 else 2225 { 2226 wmove(com_win, 0, 0); 2227 wclrtoeol(com_win); --- 426 unchanged lines hidden (view full) --- 2654 { 2655 while (position < iter) 2656 right(TRUE); 2657 } 2658 else 2659 { 2660 if (lines_moved < 30) 2661 { |
2663 move_rel("d", lines_moved); | 2662 move_rel('d', lines_moved); |
2664 while (position < iter) 2665 right(TRUE); 2666 } 2667 else 2668 { 2669 absolute_lin += lines_moved; 2670 curr_line = srch_line; 2671 point = srch_1; --- 53 unchanged lines hidden (view full) --- 2725 } 2726 position++; 2727 point++; 2728 scanline(point); 2729 delete(TRUE); 2730 } 2731 else 2732 { | 2663 while (position < iter) 2664 right(TRUE); 2665 } 2666 else 2667 { 2668 absolute_lin += lines_moved; 2669 curr_line = srch_line; 2670 point = srch_1; --- 53 unchanged lines hidden (view full) --- 2724 } 2725 position++; 2726 point++; 2727 scanline(point); 2728 delete(TRUE); 2729 } 2730 else 2731 { |
2733 right(FALSE); 2734 delete(FALSE); | 2732 right(TRUE); 2733 delete(TRUE); |
2735 } 2736} 2737 2738void 2739undel_char() /* undelete last deleted character */ 2740{ 2741 if (d_char[0] == '\n') /* insert line if last del_char deleted eol */ 2742 insert_line(TRUE); --- 192 unchanged lines hidden (view full) --- 2935while ((position < curr_line->line_length) && ((*point != 32) && (*point != 9))) 2936 right(TRUE); 2937while ((position < curr_line->line_length) && ((*point == 32) || (*point == 9))) 2938 right(TRUE); 2939} 2940 2941void 2942move_rel(direction, lines) /* move relative to current line */ | 2734 } 2735} 2736 2737void 2738undel_char() /* undelete last deleted character */ 2739{ 2740 if (d_char[0] == '\n') /* insert line if last del_char deleted eol */ 2741 insert_line(TRUE); --- 192 unchanged lines hidden (view full) --- 2934while ((position < curr_line->line_length) && ((*point != 32) && (*point != 9))) 2935 right(TRUE); 2936while ((position < curr_line->line_length) && ((*point == 32) || (*point == 9))) 2937 right(TRUE); 2938} 2939 2940void 2941move_rel(direction, lines) /* move relative to current line */ |
2943char *direction; | 2942char direction; |
2944int lines; 2945{ 2946 int i; 2947 char *tmp; 2948 | 2943int lines; 2944{ 2945 int i; 2946 char *tmp; 2947 |
2949 if (*direction == 'u') | 2948 if (direction == 'u') |
2950 { 2951 scr_pos = 0; 2952 while (position > 1) 2953 left(TRUE); 2954 for (i = 0; i < lines; i++) 2955 { 2956 up(); 2957 } --- 2392 unchanged lines hidden --- | 2949 { 2950 scr_pos = 0; 2951 while (position > 1) 2952 left(TRUE); 2953 for (i = 0; i < lines; i++) 2954 { 2955 up(); 2956 } --- 2392 unchanged lines hidden --- |