Skip to content

Commit b098409

Browse files
GUACAMOLE-1943: Add ctrl+arrows/backspace/del and shift+up/down/home/end keyboard shortcuts.
1 parent c96f0e5 commit b098409

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/terminal/terminal.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,9 +1468,21 @@ static int __guac_terminal_send_key(guac_terminal* term, int keysym, int pressed
14681468
if ((keysym == 'C' && term->mod_ctrl) || (keysym == 'c' && term->mod_meta))
14691469
return 0;
14701470

1471-
/* Shift+PgUp / Shift+PgDown shortcuts for scrolling */
1471+
/* Shortcuts for scrolling history with shift */
14721472
if (term->mod_shift) {
14731473

1474+
/* Home */
1475+
if (keysym == 0xFF50 || keysym == 0xFF95) {
1476+
guac_terminal_scroll_display_up(term, term->max_scrollback);
1477+
return 0;
1478+
}
1479+
1480+
/* End */
1481+
if (keysym == 0xFF57 || keysym == 0xFF9C) {
1482+
guac_terminal_scroll_display_down(term, term->max_scrollback);
1483+
return 0;
1484+
}
1485+
14741486
/* Page up */
14751487
if (keysym == 0xFF55) {
14761488
guac_terminal_scroll_display_up(term, term->term_height);
@@ -1483,6 +1495,18 @@ static int __guac_terminal_send_key(guac_terminal* term, int keysym, int pressed
14831495
return 0;
14841496
}
14851497

1498+
/* Up */
1499+
if (keysym == 0xFF52 || keysym == 0xFF97) {
1500+
guac_terminal_scroll_display_up(term, 1);
1501+
return 0;
1502+
}
1503+
1504+
/* Down */
1505+
if (keysym == 0xFF54 || keysym == 0xFF99) {
1506+
guac_terminal_scroll_display_down(term, 1);
1507+
return 0;
1508+
}
1509+
14861510
}
14871511

14881512
/* Reset scroll */
@@ -1518,6 +1542,22 @@ static int __guac_terminal_send_key(guac_terminal* term, int keysym, int pressed
15181542
else if (keysym >= '3' && keysym <= '7')
15191543
data = (char) (keysym - '3' + 0x1B);
15201544

1545+
/* CTRL+Left: return to previous word */
1546+
else if (keysym == 0xFF51 || keysym == 0xFF96)
1547+
return guac_terminal_send_string(term, "\033[1;5D");
1548+
1549+
/* CTRL+Right: go to next word */
1550+
else if (keysym == 0xFF53 || keysym == 0xFF98)
1551+
return guac_terminal_send_string(term, "\033[1;5C");
1552+
1553+
/* CTRL+Backspace: remove word (map to CTRL+w) */
1554+
else if (keysym == 0xFF08)
1555+
data = (char) 23;
1556+
1557+
/* CTRL+Supr: remove word to right */
1558+
else if (keysym == 0xFFFF)
1559+
return guac_terminal_send_string(term, "\033D");
1560+
15211561
/* Otherwise ignore */
15221562
else
15231563
return 0;

0 commit comments

Comments
 (0)