nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] options: add -f/--functionkeys to show and enable t


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] options: add -f/--functionkeys to show and enable the function keys
Date: Mon, 8 Oct 2018 20:11:27 +0200

In Pico, the function keys work only when -f is used.  And when -f
is used, the help lines don't show Ctrl keystrokes but only the
function keys, from F1 to F12, in a regular ascending pattern.

The pattern that 'nano -f' now shows is chaotic -- it doesn't make
sense.  The thing to do would be: to arrange the help items in the
standard Pico way when -f is used.  But... do I want to expend the
required amount of code to achieve that?  And how many people use
the function keys anyway?  That is: how many people used 'pico -f'
and are accustomed to those function keys?  Because I cannot imagine
that anyone who started with nano without ever using pico has learnt
to use the function keys, because they are not shown in the bottom
rows, they are not mnemonic, and often F1 and F11 and sometimes F10
are grabbed by the terminal emulator.
---
 src/global.c | 52 ++++++++++++++++++++++++++++------------------------
 src/nano.c   |  6 +++++-
 src/nano.h   |  3 ++-
 3 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/src/global.c b/src/global.c
index a19b0db2..0c9e7385 100644
--- a/src/global.c
+++ b/src/global.c
@@ -1082,6 +1082,34 @@ void shortcut_init(void)
        add_to_sclist(MMOST, "Bsp", KEY_BACKSPACE, do_backspace, 0);
        add_to_sclist(MMOST, "^D", 0, do_delete, 0);
        add_to_sclist(MMOST, "Del", 0, do_delete, 0);
+
+       if (ISSET(FUNCTION_KEYS)) {
+               add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
+               add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
+               add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
+#ifdef ENABLE_JUSTIFY
+               add_to_sclist(MMAIN, "F4", 0, do_justify_void, 0);
+#endif
+               add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
+               add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search_forward, 
0);
+               add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, 
do_page_up, 0);
+               add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, 
do_page_down, 0);
+               add_to_sclist(MMOST, "F9", 0, do_cut_text_void, 0);
+               add_to_sclist(MMOST, "F10", 0, do_uncut_text, 0);
+               add_to_sclist(MMAIN, "F11", 0, do_cursorpos_void, 0);
+#ifdef ENABLE_SPELLER
+               add_to_sclist(MMAIN, "F12", 0, do_spell, 0);
+#endif
+               add_to_sclist(MMAIN, "F13", 0, do_gotolinecolumn_void, 0);
+#ifdef ENABLE_BROWSER
+               add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
+
+#endif
+               add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
+#ifndef NANO_TINY
+               add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
+#endif
+       }
        /* Make ASCII DEL do a delete when requested, otherwise a backspace. */
        if (ISSET(REBIND_DELETE))
                add_to_sclist(MMOST, "Del", DEL_CODE, do_delete, 0);
@@ -1338,30 +1366,6 @@ void shortcut_init(void)
 #ifdef ENABLE_COLOR
        add_to_sclist(MLINTER, "^X", 0, do_cancel, 0);
 #endif
-       add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
-       add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
-       add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
-#ifdef ENABLE_JUSTIFY
-       add_to_sclist(MMAIN, "F4", 0, do_justify_void, 0);
-#endif
-       add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
-       add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search_forward, 0);
-       add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
-       add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
-       add_to_sclist(MMOST, "F9", 0, do_cut_text_void, 0);
-       add_to_sclist(MMOST, "F10", 0, do_uncut_text, 0);
-       add_to_sclist(MMAIN, "F11", 0, do_cursorpos_void, 0);
-#ifdef ENABLE_SPELLER
-       add_to_sclist(MMAIN, "F12", 0, do_spell, 0);
-#endif
-       add_to_sclist(MMAIN, "F13", 0, do_gotolinecolumn_void, 0);
-#ifdef ENABLE_BROWSER
-       add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
-#endif
-       add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
-#ifndef NANO_TINY
-       add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
-#endif
 
 #ifdef DEBUG
        print_sclist();
diff --git a/src/nano.c b/src/nano.c
index b3105e19..e20ba75f 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -855,6 +855,7 @@ void usage(void)
        print_opt("-c", "--constantshow", N_("Constantly show cursor 
position"));
        print_opt("-d", "--rebinddelete",
                                        N_("Fix Backspace/Delete confusion 
problem"));
+       print_opt("-f", "--functionkeys", N_("Enable the use of the function 
keys"));
 #ifdef ENABLE_BROWSER
        if (!ISSET(RESTRICTED))
                print_opt("-g", "--showcursor", N_("Show cursor in file browser 
& help text"));
@@ -1985,6 +1986,7 @@ int main(int argc, char **argv)
 #endif
                {"constantshow", 0, NULL, 'c'},
                {"rebinddelete", 0, NULL, 'd'},
+               {"functionkeys", 0, NULL, 'f'},
 #ifdef ENABLE_BROWSER
                {"showcursor", 0, NULL, 'g'},
 #endif
@@ -2205,6 +2207,9 @@ int main(int argc, char **argv)
                        case 'd':
                                SET(REBIND_DELETE);
                                break;
+                       case 'f':
+                               SET(FUNCTION_KEYS);
+                               break;
                        case 'g':
                                SET(SHOW_CURSOR);
                                break;
@@ -2301,7 +2306,6 @@ int main(int argc, char **argv)
 #endif
                        case 'b':  /* Pico compatibility flags. */
                        case 'e':
-                       case 'f':
                        case 'j':
                                break;
                        default:
diff --git a/src/nano.h b/src/nano.h
index 480e4c3c..0b2a7de7 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -540,7 +540,8 @@ enum
        LINE_NUMBERS,
        NO_PAUSES,
        AT_BLANKS,
-       AFTER_ENDS
+       AFTER_ENDS,
+       FUNCTION_KEYS
 };
 
 /* Flags for the menus in which a given function should be present. */
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]