English version Russian version Version française Nederlandse versie Versión española Version portuguese Version polonaise Italian version Versiunea româna   KiTTY News

KiTTY : Forum

Last modification : -

KiTTY web site




Forum Home
 

Patch for fixing arrow keys with modifiers

Bruno Figueiredo - Mon 09/04/2018 21:21:24 CEST +0200

Hello,

I use tmux and arrow keys with lots of modifiers for mapping actions, and it always bugged me that putty/kitty never got them working properly. So I decided to fix it. Cyd, if you can, please include the following changes against 0.70.0.3:

============== snip ===================
diff --git a/0.70_My_PuTTY/terminal.c b/0.70_My_PuTTY/terminal.c
index de098de..c011612 100644
--- a/0.70_My_PuTTY/terminal.c
+++ b/0.70_My_PuTTY/terminal.c
@@ -6642,18 +6642,24 @@ int format_arrow_key(char *buf, Terminal *term, int xkey, int ctrl)
#endif
#ifdef KEYMAPPINGPORT
if( !get_param("PUTTY") ) {
- if (modifier == 1 && alt == 1)
- p += sprintf((char *) p, "\x1B[1;10%c", xkey); /* Alt-Shift */
+ if (modifier == 3 && alt == 1)
+ p += sprintf((char *) p, "\x1B[1;8%c", xkey); /* Control+Alt-Shift */
+ else if (modifier == 2 && alt == 1)
+ p += sprintf((char *) p, "\x1B[1;7%c", xkey); /* Control+Alt */
+ else if (modifier == 3)
+ p += sprintf((char *) p, "\x1B[1;6%c", xkey); /* Control+Shift */
+ else if (modifier == 2)
+ p += sprintf((char *) p, "\x1B[1;5%c", xkey); /* Control */
+ else if (modifier == 1 && alt == 1)
+ p += sprintf((char *) p, "\x1B[1;4%c", xkey); /* Alt+Shift */
else if (alt == 1)
- p += sprintf((char *) p, "\x1B[1;3%c", xkey); /* Alt */
+ p += sprintf((char *) p, "\x1B[1;3%c", xkey); /* Alt */
else if (modifier == 1)
- p += sprintf((char *) p, "\x1B[1;2%c", xkey); /* Shift */
- else if (modifier)
- p += sprintf((char *) p, "\x1B[1;5%c", xkey); /* Control */
+ p += sprintf((char *) p, "\x1B[1;2%c", xkey); /* Shift */
else if (app_flg)
- p += sprintf((char *) p, "\x1BO%c", xkey); /* Application mode */
+ p += sprintf((char *) p, "\x1BO%c", xkey); /* Application mode */
else
- p += sprintf((char *) p, "\x1B[%c", xkey); /* Normal */
+ p += sprintf((char *) p, "\x1B[%c", xkey); /* Normal */
}
else {
/* Useful mapping of Ctrl-arrows */
diff --git a/0.70_My_PuTTY/windows/window.c b/0.70_My_PuTTY/windows/window.c
index 89012f7..73252b3 100644
--- a/0.70_My_PuTTY/windows/window.c
+++ b/0.70_My_PuTTY/windows/window.c
@@ -6527,22 +6527,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
p += sprintf((char *) p, "\x1B[27;6;9~");
return p - output;
}
- if (wParam == VK_UP && shift_state == 3) { /* Ctrl-Shift-Up */
- p += sprintf((char *) p, "\x1B[1;6A");
- return p - output;
- }
- if (wParam == VK_DOWN && shift_state == 3) { /* Ctrl-Shift-Down */
- p += sprintf((char *) p, "\x1B[1;6B");
- return p - output;
- }
- if (wParam == VK_RIGHT && shift_state == 3) { /* Ctrl-Shift-Right */
- p += sprintf((char *) p, "\x1B[1;6C");
- return p - output;
- }
- if (wParam == VK_LEFT && shift_state == 3) { /* Ctrl-Shift-Left */
- p += sprintf((char *) p, "\x1B[1;6D");
- return p - output;
- }
}
#endif
if (wParam == VK_TAB && shift_state == 1) { /* Shift tab */













Answer


The forum is actually closed