mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Handle newline and tab with shift/ctrl modifiers correctly.
MC already has its own half-ready trick: when pasting with Shift-Insert, using the X11 extension, the newline ("Enter" as mc calls it) with the Shift modifier pressed gets converted to a "Return", and in the editor the Return character inserts a non-indenting newline. This makes pasting better in terminals not supporting bracketed paste, however, it has some problems that this commit addresses: * Shift+newline gets this special treatment, but Ctrl+newline gets dropped. Hence e.g. when pasting in Gnome-terminal with Ctrl+Shift+V all the newlines will be missing. This commit adds the same non-indenting newline behavior to Ctrl+Newline and Ctrl+Shift+Newline. * The code forgets about Tab that also needs special treatment: - Most terminals send \e[Z on Shift+Tab, this is not handled by MC at all, moreover it causes a hang for about a second. This commit teaches this sequence to MC. This is especially useful when no X11 is available, because there Ctrl+Tab is identical to Tab, so the backwards tab feature is not available. With this commit Shift+Tab becomes a backwards tab too on all terminals that emit \e[Z. - When pasting to the editor, Shift+Tab, Ctrl+Tab and Ctrl+Shift+Tab should all insert a tab for the same reason mentioned at the newline. - It would look inconsistent in the keymap files to have logical code such as "backtab" instead of "shift-tab" and friends, hence get rid of KEY_BTAB and use KEY_M_SHIFT | '\t' instead. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
5b47861101
commit
930f683019
@ -331,6 +331,7 @@ static key_define_t xterm_key_defines[] = {
|
|||||||
{KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "[1;6B", MCKEY_NOACTION},
|
{KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "[1;6B", MCKEY_NOACTION},
|
||||||
{KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "[1;6C", MCKEY_NOACTION},
|
{KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "[1;6C", MCKEY_NOACTION},
|
||||||
{KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "[1;6D", MCKEY_NOACTION},
|
{KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "[1;6D", MCKEY_NOACTION},
|
||||||
|
{KEY_M_SHIFT | '\t', ESC_STR "[Z", MCKEY_NOACTION},
|
||||||
|
|
||||||
/* putty */
|
/* putty */
|
||||||
{KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "[[1;6A", MCKEY_NOACTION},
|
{KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "[[1;6A", MCKEY_NOACTION},
|
||||||
@ -1013,18 +1014,11 @@ correct_key_code (int code)
|
|||||||
if (c == KEY_SCANCEL)
|
if (c == KEY_SCANCEL)
|
||||||
c = '\t';
|
c = '\t';
|
||||||
|
|
||||||
/* Convert Shift+Tab and Ctrl+Tab to Back Tab
|
/* Convert Back Tab to Shift+Tab */
|
||||||
* only if modifiers directly from X11
|
if (c == KEY_BTAB)
|
||||||
*/
|
|
||||||
#ifdef HAVE_TEXTMODE_X11_SUPPORT
|
|
||||||
if (x11_window != 0)
|
|
||||||
#endif /* HAVE_TEXTMODE_X11_SUPPORT */
|
|
||||||
{
|
{
|
||||||
if ((c == '\t') && (mod & (KEY_M_SHIFT | KEY_M_CTRL)))
|
c = '\t';
|
||||||
{
|
mod = KEY_M_SHIFT;
|
||||||
c = KEY_BTAB;
|
|
||||||
mod = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* F0 is the same as F10 for out purposes */
|
/* F0 is the same as F10 for out purposes */
|
||||||
|
@ -493,7 +493,7 @@ dlg_key_event (WDialog * h, int d_key)
|
|||||||
dlg_one_down (h);
|
dlg_one_down (h);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (d_key == KEY_BTAB)
|
else if ((d_key & ~(KEY_M_SHIFT | KEY_M_CTRL)) == '\t')
|
||||||
{
|
{
|
||||||
dlg_one_up (h);
|
dlg_one_up (h);
|
||||||
return;
|
return;
|
||||||
|
@ -227,14 +227,14 @@ Right = right
|
|||||||
WordLeft = ctrl-left; ctrl-z
|
WordLeft = ctrl-left; ctrl-z
|
||||||
WordRight = ctrl-right; ctrl-x
|
WordRight = ctrl-right; ctrl-x
|
||||||
Enter = enter
|
Enter = enter
|
||||||
Return = shift-enter
|
Return = shift-enter; ctrl-enter; ctrl-shift-enter
|
||||||
BackSpace = backspace; ctrl-h
|
BackSpace = backspace; ctrl-h
|
||||||
Delete = delete; ctrl-d
|
Delete = delete; ctrl-d
|
||||||
PageUp = pgup
|
PageUp = pgup
|
||||||
PageDown = pgdn
|
PageDown = pgdn
|
||||||
Home = home
|
Home = home
|
||||||
End = end
|
End = end
|
||||||
Tab = tab
|
Tab = tab; shift-tab; ctrl-tab; ctrl-shift-tab
|
||||||
Undo = ctrl-u
|
Undo = ctrl-u
|
||||||
Redo = alt-r
|
Redo = alt-r
|
||||||
Top = ctrl-home; alt-lt
|
Top = ctrl-home; alt-lt
|
||||||
|
@ -227,14 +227,14 @@ Right = right; ctrl-f
|
|||||||
WordLeft = ctrl-left; alt-b
|
WordLeft = ctrl-left; alt-b
|
||||||
WordRight = ctrl-right; alt-f
|
WordRight = ctrl-right; alt-f
|
||||||
Enter = enter
|
Enter = enter
|
||||||
Return = shift-enter
|
Return = shift-enter; ctrl-enter; ctrl-shift-enter
|
||||||
BackSpace = backspace
|
BackSpace = backspace
|
||||||
Delete = delete
|
Delete = delete
|
||||||
PageUp = pgup; alt-v
|
PageUp = pgup; alt-v
|
||||||
PageDown = pgdn; ctrl-v
|
PageDown = pgdn; ctrl-v
|
||||||
Home = home; ctrl-a
|
Home = home; ctrl-a
|
||||||
End = end; ctrl-e
|
End = end; ctrl-e
|
||||||
Tab = tab
|
Tab = tab; shift-tab; ctrl-tab; ctrl-shift-tab
|
||||||
Undo = ctrl-u
|
Undo = ctrl-u
|
||||||
# Redo =
|
# Redo =
|
||||||
Top = ctrl-home; alt-lt
|
Top = ctrl-home; alt-lt
|
||||||
|
@ -320,8 +320,8 @@ static const global_keymap_ini_t default_help_keymap[] = {
|
|||||||
#ifdef USE_INTERNAL_EDIT
|
#ifdef USE_INTERNAL_EDIT
|
||||||
static const global_keymap_ini_t default_editor_keymap[] = {
|
static const global_keymap_ini_t default_editor_keymap[] = {
|
||||||
{"Enter", "enter"},
|
{"Enter", "enter"},
|
||||||
{"Return", "shift-enter"}, /* useful for pasting multiline text */
|
{"Return", "shift-enter; ctrl-enter; ctrl-shift-enter"}, /* useful for pasting multiline text */
|
||||||
{"Tab", "tab"},
|
{"Tab", "tab; shift-tab; ctrl-tab; ctrl-shift-tab"}, /* ditto */
|
||||||
{"BackSpace", "backspace; ctrl-h"},
|
{"BackSpace", "backspace; ctrl-h"},
|
||||||
{"Delete", "delete; ctrl-d"},
|
{"Delete", "delete; ctrl-d"},
|
||||||
{"Left", "left"},
|
{"Left", "left"},
|
||||||
|
Loading…
Reference in New Issue
Block a user