bindings: make ^Q and ^S do something useful by default

^S will be the first thing people will try for saving a file,
and ^Q is somewhat mnemonic because it is to the left of ^W:
it searches backward.

Make these keystrokes available also in the tiny version.
This commit is contained in:
Benno Schulenberg 2017-09-24 20:49:35 +02:00
parent c7eecd74de
commit ba65cd48cc
5 changed files with 4 additions and 23 deletions

View File

@ -269,9 +269,8 @@
## Key bindings.
## See nanorc(5) (section REBINDING KEYS) for more details on this.
##
## The following three functions are not bound to any key by default.
## You may wish to choose different keys than the ones suggested here.
# bind ^S savefile main
## The following two functions are not bound to any key by default.
## You may wish to choose other keys than the ones suggested here.
# bind M-B cutwordleft main
# bind M-N cutwordright main

View File

@ -2272,14 +2272,12 @@ void do_writeout_void(void)
close_and_go();
}
#ifndef NANO_TINY
/* If it has a name, write the current file to disk without prompting. */
void do_savefile(void)
{
if (do_writeout(FALSE, FALSE) == 2)
close_and_go();
}
#endif
/* Return a malloc()ed string containing the actual directory, used to
* convert ~user/ and ~/ notation. */

View File

@ -1079,11 +1079,13 @@ void shortcut_init(void)
add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
add_to_sclist(MMAIN, "^S", 0, do_savefile, 0);
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "^Q", 0, do_search_backward, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search, 0);
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
@ -1258,9 +1260,6 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPEND);
#endif /* !NANO_TINY */
add_to_sclist(MMAIN, "^Q", 0, xon_complaint, 0);
add_to_sclist(MMAIN, "^S", 0, xoff_complaint, 0);
add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", 0, do_cancel, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-C", 0, case_sens_void, 0);

View File

@ -1731,17 +1731,6 @@ int do_input(bool allow_funcs)
return input;
}
void xon_complaint(void)
{
statusbar(_("XON ignored, mumble mumble"));
}
void xoff_complaint(void)
{
statusbar(_("XOFF ignored, mumble mumble"));
}
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the edit window or the shortcut list. */
int do_mouse(void)

View File

@ -309,9 +309,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
#endif
int do_writeout(bool exiting, bool withprompt);
void do_writeout_void(void);
#ifndef NANO_TINY
void do_savefile(void);
#endif
char *real_dir_from_tilde(const char *buf);
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
int diralphasort(const void *va, const void *vb);
@ -691,8 +689,6 @@ void spotlight(bool active, size_t from_col, size_t to_col);
#ifndef NANO_TINY
void spotlight_softwrapped(bool active, size_t from_col, size_t to_col);
#endif
void xon_complaint(void);
void xoff_complaint(void);
void do_suspend_void(void);
void disable_waiting(void);
void enable_waiting(void);