nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit df4536559282282d75787aade511e43b5803c572
parent 6397b592fbc08714e538ef5e77221ec10c694d70
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Fri, 21 Apr 2006 02:05:09 +0000

add shortcuts to go to the first or last line of the file from the main
list, make all the equivalent shortcuts elsewhere consistent, and
simplify input parsing in do_help()


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3406 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
MChangeLog | 10++++++++++
Msrc/global.c | 48++++++++++++++++++++++++++++--------------------
Msrc/help.c | 5++---
Msrc/nano.h | 8+++++++-
4 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -73,6 +73,11 @@ CVS code - instead of "show", for consistency. (DLR) - In the main shortcut list, move the "Refresh" shortcut down to after the "Enter" shortcut, for consistency. (DLR) + - Add the ability to go to the first and last line of the + current file from the main list via Meta-/ and Meta-\. Also, + make sure all the equivalent shortcuts in the search, replace, + and "Go To Line" lists accept both the meta keys and the + equivalent function keys. (DLR) toggle_init() - In the global toggle list, move the "Constant cursor position display" toggle up to after the "Use more space for editing" @@ -82,6 +87,11 @@ CVS code - displayed, followed by toggles that affect editing, followed by toggles that have to do with peripheral things. (DLR, suggested by Benno Schulenberg) +- help.c: + do_help() + - Call get_shortcut() after getting input, so that we only have + to check for a main shortcut key instead of both it and all of + its equivalents. (DLR) - nano.c: renumber() - Remove invalid assert. (DLR, found by Filipe Moreira) diff --git a/src/global.c b/src/global.c @@ -650,6 +650,14 @@ void shortcut_init(bool unjustify) NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void); #endif + sc_init_one(&main_list, NANO_NO_KEY, first_line_msg, + IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY), NANO_NO_KEY, + NANO_NO_KEY, VIEW, do_first_line); + + sc_init_one(&main_list, NANO_NO_KEY, last_line_msg, + IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY), NANO_NO_KEY, + NANO_NO_KEY, VIEW, do_last_line); + #ifdef ENABLE_MULTIBUFFER sc_init_one(&main_list, NANO_NO_KEY, N_("Previous File"), IFHELP(nano_prevfile_msg, NANO_PREVFILE_KEY), NANO_NO_KEY, @@ -708,12 +716,12 @@ void shortcut_init(bool unjustify) VIEW, NULL); sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg, - IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY, - NANO_NO_KEY, VIEW, do_first_line); + IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY), + NANO_FIRSTLINE_FKEY, NANO_NO_KEY, VIEW, do_first_line); sc_init_one(&whereis_list, NANO_LASTLINE_KEY, last_line_msg, - IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY, - NANO_NO_KEY, VIEW, do_last_line); + IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY), + NANO_LASTLINE_FKEY, NANO_NO_KEY, VIEW, do_last_line); sc_init_one(&whereis_list, NANO_TOOTHERSEARCH_KEY, replace_msg, IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY, @@ -782,12 +790,12 @@ void shortcut_init(bool unjustify) VIEW, NULL); sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, first_line_msg, - IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY, - NANO_NO_KEY, VIEW, do_first_line); + IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY), + NANO_FIRSTLINE_FKEY, NANO_NO_KEY, VIEW, do_first_line); sc_init_one(&replace_list, NANO_LASTLINE_KEY, last_line_msg, - IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY, - NANO_NO_KEY, VIEW, do_last_line); + IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY), + NANO_LASTLINE_FKEY, NANO_NO_KEY, VIEW, do_last_line); /* TRANSLATORS: Try to keep this at most 12 characters. */ sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"), @@ -837,12 +845,12 @@ void shortcut_init(bool unjustify) VIEW, NULL); sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, first_line_msg, - IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY, - NANO_NO_KEY, VIEW, do_first_line); + IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY), + NANO_FIRSTLINE_FKEY, NANO_NO_KEY, VIEW, do_first_line); sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, last_line_msg, - IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY, - NANO_NO_KEY, VIEW, do_last_line); + IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY), + NANO_LASTLINE_FKEY, NANO_NO_KEY, VIEW, do_last_line); #ifndef NANO_TINY sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg, @@ -867,12 +875,12 @@ void shortcut_init(bool unjustify) VIEW, NULL); sc_init_one(&gotoline_list, NANO_FIRSTLINE_KEY, first_line_msg, - IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY, - NANO_NO_KEY, VIEW, do_first_line); + IFHELP(nano_firstline_msg, NANO_FIRSTLINE_ALTKEY), + NANO_FIRSTLINE_FKEY, NANO_NO_KEY, VIEW, do_first_line); sc_init_one(&gotoline_list, NANO_LASTLINE_KEY, last_line_msg, - IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY, - NANO_NO_KEY, VIEW, do_last_line); + IFHELP(nano_lastline_msg, NANO_LASTLINE_ALTKEY), + NANO_LASTLINE_FKEY, NANO_NO_KEY, VIEW, do_last_line); sc_init_one(&gotoline_list, NANO_TOOTHERWHEREIS_KEY, N_("Go To Text"), IFHELP(nano_whereis_msg, NANO_NO_KEY), @@ -1114,12 +1122,12 @@ void shortcut_init(bool unjustify) VIEW, NULL); sc_init_one(&whereis_file_list, NANO_FIRSTFILE_KEY, first_file_msg, - IFHELP(nano_firstfile_msg, NANO_NO_KEY), NANO_FIRSTFILE_FKEY, - NANO_NO_KEY, VIEW, do_first_file); + IFHELP(nano_firstfile_msg, NANO_FIRSTFILE_ALTKEY), + NANO_FIRSTFILE_FKEY, NANO_NO_KEY, VIEW, do_first_file); sc_init_one(&whereis_file_list, NANO_LASTFILE_KEY, last_file_msg, - IFHELP(nano_lastfile_msg, NANO_NO_KEY), NANO_LASTFILE_FKEY, - NANO_NO_KEY, VIEW, do_last_file); + IFHELP(nano_lastfile_msg, NANO_LASTFILE_ALTKEY), + NANO_LASTFILE_FKEY, NANO_NO_KEY, VIEW, do_last_file); #ifndef NANO_SMALL sc_init_one(&whereis_file_list, NANO_NO_KEY, case_sens_msg, diff --git a/src/help.c b/src/help.c @@ -93,7 +93,6 @@ void do_help(void (*refresh_func)(void)) break; #endif case NANO_PREVPAGE_KEY: - case NANO_PREVPAGE_FKEY: if (line > 0) { line -= editwinrows - 2; if (line < 0) @@ -101,7 +100,6 @@ void do_help(void (*refresh_func)(void)) } break; case NANO_NEXTPAGE_KEY: - case NANO_NEXTPAGE_FKEY: if (!no_more) line += editwinrows - 2; break; @@ -145,7 +143,8 @@ void do_help(void (*refresh_func)(void)) skip_redisplay: kbinput = get_kbinput(edit, &meta_key, &func_key); - } while (kbinput != NANO_EXIT_KEY && kbinput != NANO_EXIT_FKEY); + get_shortcut(help_list, &kbinput, &meta_key, &func_key); + } while (kbinput != NANO_EXIT_KEY); #ifndef DISABLE_MOUSE currshortcut = oldshortcut; diff --git a/src/nano.h b/src/nano.h @@ -414,11 +414,13 @@ typedef struct rcoption { #define NANO_ALT_COMMA ',' #define NANO_ALT_MINUS '-' #define NANO_ALT_PERIOD '.' -#define NANO_ALT_9 '9' +#define NANO_ALT_SLASH '/' #define NANO_ALT_0 '0' +#define NANO_ALT_9 '9' #define NANO_ALT_LCARAT '<' #define NANO_ALT_EQUALS '=' #define NANO_ALT_RCARAT '>' +#define NANO_ALT_BACKSLASH '\\' #define NANO_ALT_RBRACKET ']' #define NANO_ALT_USCORE '_' #define NANO_ALT_A 'a' @@ -495,12 +497,16 @@ typedef struct rcoption { #define NANO_SPELL_FKEY KEY_F(12) #define NANO_FIRSTLINE_KEY NANO_PREVPAGE_KEY #define NANO_FIRSTLINE_FKEY NANO_PREVPAGE_FKEY +#define NANO_FIRSTLINE_ALTKEY NANO_ALT_SLASH #define NANO_FIRSTFILE_KEY NANO_FIRSTLINE_KEY #define NANO_FIRSTFILE_FKEY NANO_FIRSTLINE_FKEY +#define NANO_FIRSTFILE_ALTKEY NANO_FIRSTLINE_ALTKEY #define NANO_LASTLINE_KEY NANO_NEXTPAGE_KEY #define NANO_LASTLINE_FKEY NANO_NEXTPAGE_FKEY +#define NANO_LASTLINE_ALTKEY NANO_ALT_BACKSLASH #define NANO_LASTFILE_KEY NANO_LASTLINE_KEY #define NANO_LASTFILE_FKEY NANO_LASTLINE_FKEY +#define NANO_LASTFILE_ALTKEY NANO_LASTLINE_ALTKEY #define NANO_REFRESH_KEY NANO_CONTROL_L #define NANO_JUSTIFY_KEY NANO_CONTROL_J #define NANO_JUSTIFY_FKEY KEY_F(4)