input: allow using <Tab> and <Shift+Tab> to (un)indent selected region
When the mark is on, instead of letting a <Tab> simply insert a Tab character at the cursor position, let it indent the marked region. Original-idea-by: Chris Allegretta <chrisa@asty.org>master
parent
53fc9a66a6
commit
09958ebdff
|
@ -1147,6 +1147,9 @@ void shortcut_init(void)
|
||||||
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
|
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
|
||||||
add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
|
add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
|
||||||
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
|
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
|
||||||
|
#ifdef KEY_BTAB
|
||||||
|
add_to_sclist(MMAIN, "S-Tab", KEY_BTAB, do_unindent, 0);
|
||||||
|
#endif
|
||||||
add_to_sclist(MMAIN, "M-:", 0, record_macro, 0);
|
add_to_sclist(MMAIN, "M-:", 0, record_macro, 0);
|
||||||
add_to_sclist(MMAIN, "M-;", 0, run_macro, 0);
|
add_to_sclist(MMAIN, "M-;", 0, run_macro, 0);
|
||||||
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
|
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
|
||||||
|
|
18
src/winio.c
18
src/winio.c
|
@ -621,8 +621,14 @@ int parse_kbinput(WINDOW *win)
|
||||||
if (console && ioctl(0, TIOCLINUX, &modifiers) >= 0) {
|
if (console && ioctl(0, TIOCLINUX, &modifiers) >= 0) {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* Is Shift being held? */
|
/* Is Shift being held? */
|
||||||
if (modifiers & 0x01)
|
if (modifiers & 0x01) {
|
||||||
|
#ifdef KEY_BTAB
|
||||||
|
/* A shifted <Tab> is a back tab. */
|
||||||
|
if (retval == TAB_CODE)
|
||||||
|
return KEY_BTAB;
|
||||||
|
#endif
|
||||||
shift_held = TRUE;
|
shift_held = TRUE;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Is Ctrl being held? */
|
/* Is Ctrl being held? */
|
||||||
if (modifiers & 0x04) {
|
if (modifiers & 0x04) {
|
||||||
|
@ -655,6 +661,16 @@ int parse_kbinput(WINDOW *win)
|
||||||
}
|
}
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
/* When <Tab> is pressed while the mark is on, do an indent. */
|
||||||
|
if (retval == TAB_CODE && openfile->mark && currmenu == MMAIN) {
|
||||||
|
const sc *command = first_sc_for(MMAIN, do_indent);
|
||||||
|
|
||||||
|
meta_key = command->meta;
|
||||||
|
return command->keycode;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (retval) {
|
switch (retval) {
|
||||||
#ifdef KEY_SLEFT
|
#ifdef KEY_SLEFT
|
||||||
/* Slang doesn't support KEY_SLEFT. */
|
/* Slang doesn't support KEY_SLEFT. */
|
||||||
|
|
Loading…
Reference in New Issue