1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-22 06:38:37 -05:00

Fix Alt handling in the new shifted-arrow-key support.

As well as affecting the bitmap field in the escape sequence, it was
_also_ having its otherwise standard effect of prefixing Esc to the
whole sequence. It shouldn't do both.
This commit is contained in:
Simon Tatham 2021-10-23 10:52:11 +01:00
parent 6c24cb5c9f
commit a40b581fc1
4 changed files with 19 additions and 6 deletions

View File

@ -1945,7 +1945,7 @@ typedef enum SmallKeypadKey {
SKK_HOME, SKK_END, SKK_INSERT, SKK_DELETE, SKK_PGUP, SKK_PGDN, SKK_HOME, SKK_END, SKK_INSERT, SKK_DELETE, SKK_PGUP, SKK_PGDN,
} SmallKeypadKey; } SmallKeypadKey;
int format_arrow_key(char *buf, Terminal *term, int xkey, int format_arrow_key(char *buf, Terminal *term, int xkey,
bool shift, bool ctrl, bool alt); bool shift, bool ctrl, bool alt, bool *consumed_alt);
int format_function_key(char *buf, Terminal *term, int key_number, int format_function_key(char *buf, Terminal *term, int key_number,
bool shift, bool ctrl); bool shift, bool ctrl);
int format_small_keypad_key(char *buf, Terminal *term, SmallKeypadKey key); int format_small_keypad_key(char *buf, Terminal *term, SmallKeypadKey key);

View File

@ -7241,16 +7241,18 @@ void term_mouse(Terminal *term, Mouse_Button braw, Mouse_Button bcooked,
term_schedule_update(term); term_schedule_update(term);
} }
static int shift_bitmap(bool shift, bool ctrl, bool alt) static int shift_bitmap(bool shift, bool ctrl, bool alt, bool *consumed_alt)
{ {
int bitmap = (shift ? 1 : 0) + (alt ? 2 : 0) + (ctrl ? 4 : 0); int bitmap = (shift ? 1 : 0) + (alt ? 2 : 0) + (ctrl ? 4 : 0);
if (bitmap) if (bitmap)
bitmap++; bitmap++;
if (alt && consumed_alt)
*consumed_alt = true;
return bitmap; return bitmap;
} }
int format_arrow_key(char *buf, Terminal *term, int xkey, int format_arrow_key(char *buf, Terminal *term, int xkey,
bool shift, bool ctrl, bool alt) bool shift, bool ctrl, bool alt, bool *consumed_alt)
{ {
char *p = buf; char *p = buf;
@ -7283,7 +7285,7 @@ int format_arrow_key(char *buf, Terminal *term, int xkey,
app_flg = !app_flg; app_flg = !app_flg;
break; break;
case SHARROW_BITMAP: case SHARROW_BITMAP:
bitmap = shift_bitmap(shift, ctrl, alt); bitmap = shift_bitmap(shift, ctrl, alt, consumed_alt);
break; break;
} }

View File

@ -1808,6 +1808,8 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
switch (event->keyval) { switch (event->keyval) {
int fkey_number; int fkey_number;
bool consumed_meta_key;
case GDK_KEY_F1: fkey_number = 1; goto numbered_function_key; case GDK_KEY_F1: fkey_number = 1; goto numbered_function_key;
case GDK_KEY_F2: fkey_number = 2; goto numbered_function_key; case GDK_KEY_F2: fkey_number = 2; goto numbered_function_key;
case GDK_KEY_F3: fkey_number = 3; goto numbered_function_key; case GDK_KEY_F3: fkey_number = 3; goto numbered_function_key;
@ -1875,10 +1877,14 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
case GDK_KEY_Begin: case GDK_KEY_KP_Begin: case GDK_KEY_Begin: case GDK_KEY_KP_Begin:
xkey = 'G'; goto arrow_key; xkey = 'G'; goto arrow_key;
arrow_key: arrow_key:
consumed_meta_key = false;
end = 1 + format_arrow_key(output+1, inst->term, xkey, end = 1 + format_arrow_key(output+1, inst->term, xkey,
event->state & GDK_SHIFT_MASK, event->state & GDK_SHIFT_MASK,
event->state & GDK_CONTROL_MASK, event->state & GDK_CONTROL_MASK,
event->state & GDK_META_MASK); event->state & inst->meta_mod_mask,
&consumed_meta_key);
if (consumed_meta_key)
start = 1; /* supersedes the usual prefixing of Esc */
#ifdef KEY_EVENT_DIAGNOSTICS #ifdef KEY_EVENT_DIAGNOSTICS
debug(" - arrow key"); debug(" - arrow key");
#endif #endif

View File

@ -4429,6 +4429,8 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
} }
switch (wParam) { switch (wParam) {
bool consumed_alt;
case VK_NUMPAD0: keypad_key = '0'; goto numeric_keypad; case VK_NUMPAD0: keypad_key = '0'; goto numeric_keypad;
case VK_NUMPAD1: keypad_key = '1'; goto numeric_keypad; case VK_NUMPAD1: keypad_key = '1'; goto numeric_keypad;
case VK_NUMPAD2: keypad_key = '2'; goto numeric_keypad; case VK_NUMPAD2: keypad_key = '2'; goto numeric_keypad;
@ -4536,8 +4538,11 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
case VK_LEFT: xkey = 'D'; goto arrow_key; case VK_LEFT: xkey = 'D'; goto arrow_key;
case VK_CLEAR: xkey = 'G'; goto arrow_key; /* close enough */ case VK_CLEAR: xkey = 'G'; goto arrow_key; /* close enough */
arrow_key: arrow_key:
consumed_alt = false;
p += format_arrow_key((char *)p, term, xkey, shift_state & 1, p += format_arrow_key((char *)p, term, xkey, shift_state & 1,
shift_state & 2, left_alt); shift_state & 2, left_alt, &consumed_alt);
if (consumed_alt)
left_alt = false; /* supersedes the usual prefixing of Esc */
return p - output; return p - output;
case VK_RETURN: case VK_RETURN: