Chris Allegretta | 11b0011 | 2000-08-06 21:13:45 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 2 | /************************************************************************** |
| 3 | * global.c * |
| 4 | * * |
| 5 | * Copyright (C) 1999 Chris Allegretta * |
| 6 | * This program is free software; you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 1, or (at your option) * |
| 9 | * any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, write to the Free Software * |
| 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * |
| 19 | * * |
| 20 | **************************************************************************/ |
| 21 | |
| 22 | #include <sys/stat.h> |
| 23 | #include "config.h" |
| 24 | #include "nano.h" |
| 25 | #include "proto.h" |
| 26 | |
| 27 | #ifndef NANO_SMALL |
| 28 | #include <libintl.h> |
| 29 | #define _(string) gettext(string) |
| 30 | #else |
| 31 | #define _(string) (string) |
| 32 | #endif |
| 33 | |
| 34 | /* |
| 35 | * Global variables |
| 36 | */ |
| 37 | int flags = 0; /* Our new flag containig many options */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 38 | WINDOW *edit; /* The file portion of the editor */ |
| 39 | WINDOW *topwin; /* Top line of screen */ |
| 40 | WINDOW *bottomwin; /* Bottom buffer */ |
Chris Allegretta | 1a6e904 | 2000-12-14 13:56:28 +0000 | [diff] [blame] | 41 | char *filename = NULL; /* Name of the file */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 42 | int editwinrows = 0; /* How many rows long is the edit |
| 43 | window? */ |
| 44 | filestruct *current; /* Current buffer pointer */ |
| 45 | int current_x = 0, current_y = 0; /* Current position of X and Y in |
| 46 | the editor - relative to edit |
| 47 | window (0,0) */ |
| 48 | filestruct *fileage = NULL; /* Our file buffer */ |
| 49 | filestruct *edittop = NULL; /* Pointer to the top of the edit |
| 50 | buffer with respect to the |
| 51 | file struct */ |
| 52 | filestruct *editbot = NULL; /* Same for the bottom */ |
| 53 | filestruct *filebot = NULL; /* Last node in the file struct */ |
| 54 | filestruct *cutbuffer = NULL; /* A place to store cut text */ |
| 55 | |
Chris Allegretta | 31925e4 | 2000-11-02 04:40:39 +0000 | [diff] [blame] | 56 | char *answer = NULL; /* Answer str to many questions */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 57 | int totlines = 0; /* Total number of lines in the file */ |
| 58 | int totsize = 0; /* Total number of bytes in the file */ |
| 59 | int placewewant = 0; /* The collum we'd like the cursor |
| 60 | to jump to when we go to the |
| 61 | next or previous line */ |
| 62 | |
Chris Allegretta | 6d690a3 | 2000-08-03 22:51:21 +0000 | [diff] [blame] | 63 | int tabsize = 8; /* Our internal tabsize variable */ |
| 64 | |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 65 | char *hblank; /* A horizontal blank line */ |
| 66 | char *help_text; /* The text in the help window */ |
| 67 | |
| 68 | /* More stuff for the marker select */ |
| 69 | |
| 70 | filestruct *mark_beginbuf; /* the begin marker buffer */ |
| 71 | int mark_beginx; /* X value in the string to start */ |
| 72 | |
| 73 | shortcut main_list[MAIN_LIST_LEN]; |
| 74 | shortcut whereis_list[WHEREIS_LIST_LEN]; |
| 75 | shortcut replace_list[REPLACE_LIST_LEN]; |
Chris Allegretta | 105da33 | 2000-10-31 05:10:10 +0000 | [diff] [blame] | 76 | shortcut replace_list_2[REPLACE_LIST_LEN]; /* 2nd half of replace dialog */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 77 | shortcut goto_list[GOTO_LIST_LEN]; |
| 78 | shortcut writefile_list[WRITEFILE_LIST_LEN]; |
| 79 | shortcut help_list[HELP_LIST_LEN]; |
| 80 | shortcut spell_list[SPELL_LIST_LEN]; |
Rocco Corsi | af5c302 | 2001-01-12 07:51:05 +0000 | [diff] [blame] | 81 | #ifndef DISABLE_BROWSER |
Chris Allegretta | f4b9601 | 2001-01-03 07:11:47 +0000 | [diff] [blame] | 82 | shortcut browser_list[BROWSER_LIST_LEN]; |
| 83 | #endif |
| 84 | |
Chris Allegretta | f0b26df | 2001-01-20 22:18:18 +0000 | [diff] [blame] | 85 | #ifndef NANO_SMALL |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 86 | toggle toggles[TOGGLE_LEN]; |
Chris Allegretta | f0b26df | 2001-01-20 22:18:18 +0000 | [diff] [blame] | 87 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 88 | |
Chris Allegretta | 9fc8d43 | 2000-07-07 01:49:52 +0000 | [diff] [blame] | 89 | /* Regular expressions */ |
| 90 | |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 91 | #ifdef HAVE_REGEX_H |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 92 | regex_t search_regexp; /* Global to store compiled search regexp */ |
| 93 | regmatch_t regmatches[10]; /* Match positions for parenthetical |
| 94 | subexpressions, max of 10 */ |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 95 | #endif |
Chris Allegretta | 9fc8d43 | 2000-07-07 01:49:52 +0000 | [diff] [blame] | 96 | |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 97 | /* Initialize a struct *without* our lovely braces =( */ |
| 98 | void sc_init_one(shortcut * s, int key, char *desc, char *help, int alt, |
| 99 | int misc1, int misc2, int view, int (*func) (void)) |
| 100 | { |
| 101 | s->val = key; |
| 102 | s->desc = desc; |
| 103 | s->help = help; |
| 104 | s->altval = alt; |
| 105 | s->misc1 = misc1; |
| 106 | s->misc2 = misc2; |
| 107 | s->viewok = view; |
| 108 | s->func = func; |
| 109 | } |
| 110 | |
Chris Allegretta | f0b26df | 2001-01-20 22:18:18 +0000 | [diff] [blame] | 111 | #ifndef NANO_SMALL |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 112 | /* Initialize the toggles in the same manner */ |
| 113 | void toggle_init_one(toggle * t, int val, char *desc, int flag) |
| 114 | { |
| 115 | t->val = val; |
| 116 | t->desc = desc; |
| 117 | t->flag = flag; |
| 118 | } |
Chris Allegretta | f0b26df | 2001-01-20 22:18:18 +0000 | [diff] [blame] | 119 | #endif |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 120 | |
| 121 | void toggle_init(void) |
| 122 | { |
| 123 | #ifndef NANO_SMALL |
| 124 | char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg, |
| 125 | *toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg, |
Chris Allegretta | d7934d4 | 2000-10-03 05:39:29 +0000 | [diff] [blame] | 126 | *toggle_cuttoend_msg, *toggle_wrap_msg; |
| 127 | #ifdef HAVE_REGEX_H |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 128 | char *toggle_regexp_msg; |
Chris Allegretta | d7934d4 | 2000-10-03 05:39:29 +0000 | [diff] [blame] | 129 | #endif |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 130 | |
| 131 | toggle_const_msg = _("Constant cursor position"); |
Chris Allegretta | f8163dc | 2000-09-03 01:06:40 +0000 | [diff] [blame] | 132 | toggle_autoindent_msg = _("Auto indent"); |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 133 | toggle_suspend_msg = _("Suspend"); |
Chris Allegretta | f0f63a8 | 2000-09-02 18:44:21 +0000 | [diff] [blame] | 134 | toggle_nohelp_msg = _("Help mode"); |
Chris Allegretta | bf9a8cc | 2000-11-17 01:37:39 +0000 | [diff] [blame] | 135 | toggle_picomode_msg = _("Pico mode"); |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 136 | toggle_mouse_msg = _("Mouse support"); |
| 137 | toggle_cuttoend_msg = _("Cut to end"); |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 138 | #ifdef HAVE_REGEX_H |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 139 | toggle_regexp_msg = _("Regular expressions"); |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 140 | #endif |
Chris Allegretta | f0f63a8 | 2000-09-02 18:44:21 +0000 | [diff] [blame] | 141 | toggle_wrap_msg = _("Auto wrap"); |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 142 | |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 143 | toggle_init_one(&toggles[0], TOGGLE_CONST_KEY, toggle_const_msg, |
| 144 | CONSTUPDATE); |
| 145 | toggle_init_one(&toggles[1], TOGGLE_AUTOINDENT_KEY, |
| 146 | toggle_autoindent_msg, AUTOINDENT); |
| 147 | toggle_init_one(&toggles[2], TOGGLE_SUSPEND_KEY, toggle_suspend_msg, |
| 148 | SUSPEND); |
| 149 | toggle_init_one(&toggles[3], TOGGLE_NOHELP_KEY, toggle_nohelp_msg, |
| 150 | NO_HELP); |
| 151 | toggle_init_one(&toggles[4], TOGGLE_PICOMODE_KEY, toggle_picomode_msg, |
Chris Allegretta | bf9a8cc | 2000-11-17 01:37:39 +0000 | [diff] [blame] | 152 | PICO_MODE); |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 153 | toggle_init_one(&toggles[5], TOGGLE_WRAP_KEY, toggle_wrap_msg, |
| 154 | NO_WRAP); |
| 155 | toggle_init_one(&toggles[6], TOGGLE_MOUSE_KEY, toggle_mouse_msg, |
| 156 | USE_MOUSE); |
| 157 | toggle_init_one(&toggles[7], TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, |
| 158 | CUT_TO_END); |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 159 | #ifdef HAVE_REGEX_H |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 160 | toggle_init_one(&toggles[8], TOGGLE_REGEXP_KEY, toggle_regexp_msg, |
| 161 | USE_REGEXP); |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 162 | #endif |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 163 | #endif |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Chris Allegretta | 0779835 | 2000-11-27 22:58:23 +0000 | [diff] [blame] | 166 | void shortcut_init(int unjustify) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 167 | { |
| 168 | char *nano_help_msg = "", *nano_writeout_msg = "", *nano_exit_msg = "", |
| 169 | *nano_goto_msg = "", *nano_justify_msg = "", *nano_replace_msg = |
| 170 | "", *nano_insert_msg = "", *nano_whereis_msg = |
| 171 | "", *nano_prevpage_msg = "", *nano_nextpage_msg = |
| 172 | "", *nano_cut_msg = "", *nano_uncut_msg = "", *nano_cursorpos_msg = |
| 173 | "", *nano_spell_msg = "", *nano_up_msg = "", *nano_down_msg = |
| 174 | "", *nano_forward_msg = "", *nano_back_msg = "", *nano_home_msg = |
| 175 | "", *nano_end_msg = "", *nano_firstline_msg = |
| 176 | "", *nano_lastline_msg = "", *nano_refresh_msg = |
| 177 | "", *nano_mark_msg = "", *nano_delete_msg = |
| 178 | "", *nano_backspace_msg = "", *nano_tab_msg = |
| 179 | "", *nano_enter_msg = "", *nano_case_msg = |
Chris Allegretta | 6636dc3 | 2001-01-05 05:41:07 +0000 | [diff] [blame] | 180 | "", *nano_cancel_msg = "", *nano_unjustify_msg = ""; |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 181 | |
| 182 | #ifndef NANO_SMALL |
Chris Allegretta | 6636dc3 | 2001-01-05 05:41:07 +0000 | [diff] [blame] | 183 | char *nano_tofiles_msg = ""; |
| 184 | |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 185 | nano_help_msg = _("Invoke the help menu"); |
| 186 | nano_writeout_msg = _("Write the current file to disk"); |
| 187 | nano_exit_msg = _("Exit from nano"); |
| 188 | nano_goto_msg = _("Goto a specific line number"); |
| 189 | nano_justify_msg = _("Justify the current paragraph"); |
Chris Allegretta | 0779835 | 2000-11-27 22:58:23 +0000 | [diff] [blame] | 190 | nano_unjustify_msg = _("Unjustify after a justify"); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 191 | nano_replace_msg = _("Replace text within the editor"); |
| 192 | nano_insert_msg = _("Insert another file into the current one"); |
| 193 | nano_whereis_msg = _("Search for text within the editor"); |
| 194 | nano_prevpage_msg = _("Move to the previous screen"); |
| 195 | nano_nextpage_msg = _("Move to the next screen"); |
| 196 | nano_cut_msg = _("Cut the current line and store it in the cutbuffer"); |
| 197 | nano_uncut_msg = _("Uncut from the cutbuffer into the current line"); |
| 198 | nano_cursorpos_msg = _("Show the posititon of the cursor"); |
| 199 | nano_spell_msg = _("Invoke the spell checker (if available)"); |
| 200 | nano_up_msg = _("Move up one line"); |
| 201 | nano_down_msg = _("Move down one line"); |
| 202 | nano_forward_msg = _("Move forward one character"); |
| 203 | nano_back_msg = _("Move back one character"); |
| 204 | nano_home_msg = _("Move to the beginning of the current line"); |
| 205 | nano_end_msg = _("Move to the end of the current line"); |
| 206 | nano_firstline_msg = _("Go to the first line of the file"); |
| 207 | nano_lastline_msg = _("Go to the last line of the file"); |
| 208 | nano_refresh_msg = _("Refresh (redraw) the current screen"); |
| 209 | nano_mark_msg = _("Mark text at the current cursor location"); |
| 210 | nano_delete_msg = _("Delete the character under the cursor"); |
| 211 | nano_backspace_msg = |
| 212 | _("Delete the character to the left of the cursor"); |
| 213 | nano_tab_msg = _("Insert a tab character"); |
| 214 | nano_enter_msg = _("Insert a carriage return at the cursor position"); |
| 215 | nano_case_msg = |
| 216 | _("Make the current search or replace case (in)sensitive"); |
Chris Allegretta | f4b9601 | 2001-01-03 07:11:47 +0000 | [diff] [blame] | 217 | nano_tofiles_msg = _("Go to file browser"); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 218 | nano_cancel_msg = _("Cancel the current function"); |
| 219 | #endif |
| 220 | |
Chris Allegretta | bf9a8cc | 2000-11-17 01:37:39 +0000 | [diff] [blame] | 221 | if (ISSET(PICO_MODE)) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 222 | sc_init_one(&main_list[0], NANO_HELP_KEY, _("Get Help"), |
Chris Allegretta | 16e4168 | 2000-09-11 22:33:54 +0000 | [diff] [blame] | 223 | nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 224 | else |
| 225 | sc_init_one(&main_list[0], NANO_WRITEOUT_KEY, _("WriteOut"), |
| 226 | nano_writeout_msg, |
| 227 | 0, NANO_WRITEOUT_FKEY, 0, NOVIEW, do_writeout_void); |
| 228 | |
| 229 | sc_init_one(&main_list[1], NANO_EXIT_KEY, _("Exit"), |
| 230 | nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit); |
| 231 | |
Chris Allegretta | bf9a8cc | 2000-11-17 01:37:39 +0000 | [diff] [blame] | 232 | if (ISSET(PICO_MODE)) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 233 | sc_init_one(&main_list[2], NANO_WRITEOUT_KEY, _("WriteOut"), |
| 234 | nano_writeout_msg, |
| 235 | 0, NANO_WRITEOUT_FKEY, 0, NOVIEW, do_writeout_void); |
| 236 | else |
| 237 | sc_init_one(&main_list[2], NANO_GOTO_KEY, _("Goto Line"), |
| 238 | nano_goto_msg, |
| 239 | NANO_ALT_G, NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void); |
| 240 | |
Chris Allegretta | bf9a8cc | 2000-11-17 01:37:39 +0000 | [diff] [blame] | 241 | if (ISSET(PICO_MODE)) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 242 | sc_init_one(&main_list[3], NANO_JUSTIFY_KEY, _("Justify"), |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 243 | nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0, |
Chris Allegretta | 16e4168 | 2000-09-11 22:33:54 +0000 | [diff] [blame] | 244 | NOVIEW, do_justify); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 245 | else |
| 246 | sc_init_one(&main_list[3], NANO_REPLACE_KEY, _("Replace"), |
| 247 | nano_replace_msg, |
| 248 | NANO_ALT_R, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace); |
| 249 | |
| 250 | sc_init_one(&main_list[4], NANO_INSERTFILE_KEY, _("Read File"), |
| 251 | nano_insert_msg, |
| 252 | 0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile); |
| 253 | |
| 254 | sc_init_one(&main_list[5], NANO_WHEREIS_KEY, _("Where Is"), |
| 255 | nano_whereis_msg, |
| 256 | 0, NANO_WHEREIS_FKEY, 0, VIEW, do_search); |
| 257 | |
| 258 | sc_init_one(&main_list[6], NANO_PREVPAGE_KEY, _("Prev Page"), |
| 259 | nano_prevpage_msg, |
| 260 | 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, page_up); |
| 261 | |
| 262 | sc_init_one(&main_list[7], NANO_NEXTPAGE_KEY, _("Next Page"), |
| 263 | nano_nextpage_msg, |
| 264 | 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, page_down); |
| 265 | |
| 266 | sc_init_one(&main_list[8], NANO_CUT_KEY, _("Cut Text"), |
| 267 | nano_cut_msg, 0, NANO_CUT_FKEY, 0, NOVIEW, do_cut_text); |
| 268 | |
Chris Allegretta | 0779835 | 2000-11-27 22:58:23 +0000 | [diff] [blame] | 269 | if (unjustify) |
| 270 | sc_init_one(&main_list[9], NANO_UNJUSTIFY_KEY, _("UnJustify"), |
| 271 | nano_unjustify_msg, 0, 0, 0, NOVIEW, do_uncut_text); |
| 272 | else |
| 273 | sc_init_one(&main_list[9], NANO_UNCUT_KEY, _("UnCut Txt"), |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 274 | nano_uncut_msg, |
| 275 | 0, NANO_UNCUT_FKEY, 0, NOVIEW, do_uncut_text); |
| 276 | |
| 277 | sc_init_one(&main_list[10], NANO_CURSORPOS_KEY, _("Cur Pos"), |
| 278 | nano_cursorpos_msg, |
| 279 | 0, NANO_CURSORPOS_FKEY, 0, VIEW, do_cursorpos); |
| 280 | |
| 281 | sc_init_one(&main_list[11], NANO_SPELL_KEY, _("To Spell"), |
| 282 | nano_spell_msg, 0, NANO_SPELL_FKEY, 0, NOVIEW, do_spell); |
| 283 | |
| 284 | |
| 285 | sc_init_one(&main_list[12], NANO_UP_KEY, _("Up"), |
| 286 | nano_up_msg, 0, KEY_UP, 0, VIEW, do_up); |
| 287 | |
| 288 | sc_init_one(&main_list[13], NANO_DOWN_KEY, _("Down"), |
| 289 | nano_down_msg, 0, KEY_DOWN, 0, VIEW, do_down); |
| 290 | |
| 291 | sc_init_one(&main_list[14], NANO_FORWARD_KEY, _("Forward"), |
| 292 | nano_forward_msg, 0, KEY_RIGHT, 0, VIEW, do_right); |
| 293 | |
| 294 | sc_init_one(&main_list[15], NANO_BACK_KEY, _("Back"), |
| 295 | nano_back_msg, 0, KEY_LEFT, 0, VIEW, do_left); |
| 296 | |
| 297 | sc_init_one(&main_list[16], NANO_HOME_KEY, _("Home"), |
| 298 | nano_home_msg, 0, KEY_HOME, 362, VIEW, do_home); |
| 299 | |
| 300 | sc_init_one(&main_list[17], NANO_END_KEY, _("End"), |
| 301 | nano_end_msg, 0, KEY_END, 385, VIEW, do_end); |
| 302 | |
| 303 | sc_init_one(&main_list[18], NANO_REFRESH_KEY, _("Refresh"), |
| 304 | nano_refresh_msg, 0, 0, 0, VIEW, total_refresh); |
| 305 | |
| 306 | sc_init_one(&main_list[19], NANO_MARK_KEY, _("Mark Text"), |
| 307 | nano_mark_msg, 0, 0, 0, NOVIEW, do_mark); |
| 308 | |
| 309 | sc_init_one(&main_list[20], NANO_DELETE_KEY, _("Delete"), |
| 310 | nano_delete_msg, 0, KEY_DC, |
| 311 | NANO_CONTROL_D, NOVIEW, do_delete); |
| 312 | |
| 313 | sc_init_one(&main_list[21], NANO_BACKSPACE_KEY, _("Backspace"), |
| 314 | nano_backspace_msg, 0, |
| 315 | KEY_BACKSPACE, 127, NOVIEW, do_backspace); |
| 316 | |
| 317 | sc_init_one(&main_list[22], NANO_TAB_KEY, _("Tab"), |
| 318 | nano_tab_msg, 0, 0, 0, NOVIEW, do_tab); |
| 319 | |
Chris Allegretta | bf9a8cc | 2000-11-17 01:37:39 +0000 | [diff] [blame] | 320 | if (ISSET(PICO_MODE)) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 321 | sc_init_one(&main_list[23], NANO_REPLACE_KEY, _("Replace"), |
| 322 | nano_replace_msg, |
| 323 | NANO_ALT_R, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace); |
| 324 | else |
| 325 | sc_init_one(&main_list[23], NANO_JUSTIFY_KEY, _("Justify"), |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 326 | nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0, |
Chris Allegretta | 16e4168 | 2000-09-11 22:33:54 +0000 | [diff] [blame] | 327 | NOVIEW, do_justify); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 328 | |
| 329 | sc_init_one(&main_list[24], NANO_ENTER_KEY, _("Enter"), |
| 330 | nano_enter_msg, |
| 331 | 0, KEY_ENTER, NANO_CONTROL_M, NOVIEW, do_enter_void); |
| 332 | |
Chris Allegretta | bf9a8cc | 2000-11-17 01:37:39 +0000 | [diff] [blame] | 333 | if (ISSET(PICO_MODE)) |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 334 | sc_init_one(&main_list[25], NANO_GOTO_KEY, _("Goto Line"), |
| 335 | nano_goto_msg, |
| 336 | NANO_ALT_G, NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void); |
| 337 | else |
| 338 | sc_init_one(&main_list[25], NANO_HELP_KEY, _("Get Help"), |
Chris Allegretta | 16e4168 | 2000-09-11 22:33:54 +0000 | [diff] [blame] | 339 | nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 340 | |
| 341 | |
| 342 | sc_init_one(&whereis_list[0], NANO_FIRSTLINE_KEY, _("First Line"), |
| 343 | nano_firstline_msg, 0, 0, 0, VIEW, do_first_line); |
| 344 | |
| 345 | sc_init_one(&whereis_list[1], NANO_LASTLINE_KEY, _("Last Line"), |
| 346 | nano_lastline_msg, 0, 0, 0, VIEW, do_last_line); |
| 347 | |
| 348 | sc_init_one(&whereis_list[2], NANO_CASE_KEY, _("Case Sens"), |
| 349 | nano_case_msg, 0, 0, 0, VIEW, 0); |
| 350 | |
| 351 | |
Chris Allegretta | 715e7dd | 2000-06-30 20:35:26 +0000 | [diff] [blame] | 352 | sc_init_one(&whereis_list[3], NANO_OTHERSEARCH_KEY, _("Replace"), |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 353 | nano_replace_msg, 0, 0, 0, VIEW, do_replace); |
| 354 | |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 355 | sc_init_one(&whereis_list[4], NANO_FROMSEARCHTOGOTO_KEY, |
| 356 | _("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW, |
| 357 | do_gotoline_void); |
Chris Allegretta | 8c2b40f | 2000-06-29 01:30:04 +0000 | [diff] [blame] | 358 | |
| 359 | sc_init_one(&whereis_list[5], NANO_CANCEL_KEY, _("Cancel"), |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 360 | nano_cancel_msg, 0, 0, 0, VIEW, 0); |
| 361 | |
| 362 | |
| 363 | sc_init_one(&replace_list[0], NANO_FIRSTLINE_KEY, _("First Line"), |
| 364 | nano_firstline_msg, 0, 0, 0, VIEW, do_first_line); |
| 365 | |
| 366 | sc_init_one(&replace_list[1], NANO_LASTLINE_KEY, _("Last Line"), |
| 367 | nano_lastline_msg, 0, 0, 0, VIEW, do_last_line); |
| 368 | |
| 369 | sc_init_one(&replace_list[2], NANO_CASE_KEY, _("Case Sens"), |
| 370 | nano_case_msg, 0, 0, 0, VIEW, 0); |
| 371 | |
Chris Allegretta | 8c2b40f | 2000-06-29 01:30:04 +0000 | [diff] [blame] | 372 | sc_init_one(&replace_list[3], NANO_OTHERSEARCH_KEY, _("No Replace"), |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 373 | nano_whereis_msg, 0, 0, 0, VIEW, do_search); |
| 374 | |
Chris Allegretta | bd9e7c3 | 2000-10-26 01:44:42 +0000 | [diff] [blame] | 375 | sc_init_one(&replace_list[4], NANO_FROMSEARCHTOGOTO_KEY, |
| 376 | _("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW, |
| 377 | do_gotoline_void); |
Chris Allegretta | 8c2b40f | 2000-06-29 01:30:04 +0000 | [diff] [blame] | 378 | |
Chris Allegretta | 105da33 | 2000-10-31 05:10:10 +0000 | [diff] [blame] | 379 | sc_init_one(&replace_list[5], NANO_CANCEL_KEY, _("Cancel"), |
| 380 | nano_cancel_msg, 0, 0, 0, VIEW, 0); |
| 381 | |
| 382 | |
| 383 | |
| 384 | sc_init_one(&replace_list_2[0], NANO_FIRSTLINE_KEY, _("First Line"), |
| 385 | nano_firstline_msg, 0, 0, 0, VIEW, do_first_line); |
| 386 | |
| 387 | sc_init_one(&replace_list_2[1], NANO_LASTLINE_KEY, _("Last Line"), |
| 388 | nano_lastline_msg, 0, 0, 0, VIEW, do_last_line); |
| 389 | |
Chris Allegretta | 4d29be1 | 2000-10-31 05:32:09 +0000 | [diff] [blame] | 390 | sc_init_one(&replace_list_2[2], NANO_CANCEL_KEY, _("Cancel"), |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 391 | nano_cancel_msg, 0, 0, 0, VIEW, 0); |
| 392 | |
| 393 | |
| 394 | sc_init_one(&goto_list[0], NANO_FIRSTLINE_KEY, _("First Line"), |
| 395 | nano_firstline_msg, 0, 0, 0, VIEW, &do_first_line); |
| 396 | |
| 397 | sc_init_one(&goto_list[1], NANO_LASTLINE_KEY, _("Last Line"), |
| 398 | nano_lastline_msg, 0, 0, 0, VIEW, &do_last_line); |
| 399 | |
| 400 | sc_init_one(&goto_list[2], NANO_CANCEL_KEY, _("Cancel"), |
| 401 | nano_cancel_msg, 0, 0, 0, VIEW, 0); |
| 402 | |
| 403 | |
| 404 | sc_init_one(&help_list[0], NANO_PREVPAGE_KEY, _("Prev Page"), |
| 405 | nano_prevpage_msg, |
| 406 | 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, page_up); |
| 407 | |
| 408 | sc_init_one(&help_list[1], NANO_NEXTPAGE_KEY, _("Next Page"), |
| 409 | nano_nextpage_msg, |
| 410 | 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, page_down); |
| 411 | |
| 412 | sc_init_one(&help_list[2], NANO_EXIT_KEY, _("Exit"), |
| 413 | nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit); |
| 414 | |
| 415 | |
Rocco Corsi | af5c302 | 2001-01-12 07:51:05 +0000 | [diff] [blame] | 416 | #ifndef DISABLE_BROWSER |
Chris Allegretta | f4b9601 | 2001-01-03 07:11:47 +0000 | [diff] [blame] | 417 | sc_init_one(&writefile_list[0], NANO_TOFILES_KEY, _("To Files"), |
| 418 | nano_tofiles_msg, 0, 0, 0, NOVIEW, 0); |
| 419 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 420 | |
Chris Allegretta | f4b9601 | 2001-01-03 07:11:47 +0000 | [diff] [blame] | 421 | sc_init_one(&writefile_list[WRITEFILE_LIST_LEN - 1], NANO_CANCEL_KEY, _("Cancel"), |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 422 | nano_cancel_msg, 0, 0, 0, VIEW, 0); |
| 423 | |
Chris Allegretta | 56b24b5 | 2000-11-29 23:57:20 +0000 | [diff] [blame] | 424 | sc_init_one(&spell_list[0], NANO_CANCEL_KEY, _("Cancel"), |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 425 | nano_cancel_msg, 0, 0, 0, VIEW, 0); |
| 426 | |
Rocco Corsi | af5c302 | 2001-01-12 07:51:05 +0000 | [diff] [blame] | 427 | #ifndef DISABLE_BROWSER |
Chris Allegretta | f4b9601 | 2001-01-03 07:11:47 +0000 | [diff] [blame] | 428 | sc_init_one(&browser_list[0], NANO_PREVPAGE_KEY, _("Prev Page"), |
| 429 | nano_prevpage_msg, |
| 430 | 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, 0); |
| 431 | |
| 432 | sc_init_one(&browser_list[1], NANO_NEXTPAGE_KEY, _("Next Page"), |
| 433 | nano_nextpage_msg, |
| 434 | 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, 0); |
| 435 | |
| 436 | sc_init_one(&browser_list[2], NANO_EXIT_KEY, _("Exit"), |
| 437 | nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, 0); |
| 438 | |
| 439 | #endif |
| 440 | |
| 441 | |
Chris Allegretta | 756f220 | 2000-09-01 13:32:47 +0000 | [diff] [blame] | 442 | toggle_init(); |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 443 | } |