Skip to content
Myr

Add keybindings for CTRL, ALT, SHIFT + UP, DOWN, RIGHT, LEFT, HOME, END, BACKSPACE, DELETE & more (#3996)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Added tests for `LightRenderer` * Added common SHIFT, ALT and ALT+SHIFT key sequences * Added common CTRL key sequences * Added common CTRL+ALT, CTRL+SHIFT, CTRL+ALT+SHIFT key sequences * Added proper xterm META modifier handling according to https://github.com/joejulian/xterm/blob/defc6dd5684a12dc8e56cb6973ef973e7a32caa3/input.c#L357-L375 * Fix `ctrl-backspace` and `ctrl-alt-backspace` * Fix broken tcell tests on windows by swallowing Resize events * Added tests for FullscreenRenderer * Removed own fork of tcell and updated tcell to 2.9.0 tcell 2.9.0 is needed for `Ctrl-Alt-*` and `Ctrl-Alt-Shift-*` shortcuts in Windows * Replace conditional checks with switch statements to improve readability * Replace long conditionals with constant slices to improve readability * Bind `ctrl-bspace` (`ctrl-h`) to `backward-delete-char` by default Since we now distinguish between Backspace and Ctrl-Backspace, Ctrl-Backspace should trigger the same action as Backspace by default. In that way nothing changes for the user but you can bind other actions to Ctrl-Backspace when desired.

authored by Massimo Mund · committed by GitHub · parent 129cb23 · Browse files · 9 files+1228 added−117 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

9 files+1228 added−117 removed

  • other:+1228 added−117 removed

9 files+1228 added−117 removed

modified:man/man1/fzf.1+109 added-3 removed
1471 unmodified lines
1472\fIalt\-left\fR1473.br1474\fIalt\-right\fR1475.br1476\fIalt\-enter\fR1476\fIalt\-home\fR1477.br1478\fIalt\-space\fR1478\fIalt\-end\fR1479.br1480\fIalt\-backspace\fR (\fIalt\-bspace\fR \fIalt\-bs\fR)1481.br1482\fIalt\-delete\fR1483.br1484\fIalt\-page\-up\fR1485.br1486\fIalt\-page\-down\fR1487.br1488\fIalt\-enter\fR1489.br1490\fIalt\-space\fR1491.br1492\fItab\fR1493.br1494\fIshift\-tab\fR (\fIbtab\fR)1495.br
18 unmodified lines
1514\fIpage\-up\fR (\fIpgup\fR)1515.br1516\fIpage\-down\fR (\fIpgdn\fR)1517.br1518\fIctrl\-up\fR1519.br1520\fIctrl\-down\fR1521.br1522\fIctrl\-left\fR1523.br1524\fIctrl\-right\fR1525.br1526\fIctrl\-home\fR1527.br1528\fIctrl\-end\fR1529.br1530\fIctrl\-backspace\fR (\fIctrl\-bspace\fR \fIctrl\-bs\fR)1531.br1532\fIctrl\-delete\fR1533.br1534\fIctrl\-page\-up\fR1535.br1536\fIctrl\-page\-down\fR1537.br1538\fIshift\-up\fR1539.br1540\fIshift\-down\fR1541.br1542\fIshift\-left\fR1543.br1544\fIshift\-right\fR1545.br1546\fIshift\-home\fR1547.br1548\fIshift\-end\fR1549.br1550\fIshift\-delete\fR1551.br1552\fIshift\-page\-up\fR1553.br1554\fIshift\-page\-down\fR1555.br1556\fIalt\-shift\-up\fR1557.br1558\fIalt\-shift\-down\fR1559.br1560\fIalt\-shift\-left\fR1561.br1562\fIalt\-shift\-right\fR1563.br1564\fIalt\-shift\-home\fR1565.br1566\fIalt\-shift\-end\fR1567.br1568\fIalt\-shift\-delete\fR1569.br1570\fIalt\-shift\-page\-up\fR1571.br1572\fIalt\-shift\-page\-down\fR1573.br1574\fIctrl\-alt\-up\fR1575.br1576\fIctrl\-alt\-down\fR1577.br1578\fIctrl\-alt\-left\fR1579.br1580\fIctrl\-alt\-right\fR1581.br1582\fIctrl\-alt\-home\fR1583.br1584\fIctrl\-alt\-end\fR1585.br1586\fIctrl\-alt\-backspace\fR (\fIctrl\-alt\-bspace\fR \fIctrl\-alt\-bs\fR)1587.br1588\fIctrl\-alt\-delete\fR1589.br1590\fIctrl\-alt\-page\-up\fR1591.br1592\fIctrl\-alt\-page\-down\fR1593.br1594\fIctrl\-shift\-up\fR1595.br1596\fIctrl\-shift\-down\fR1597.br1598\fIctrl\-shift\-left\fR1599.br1600\fIctrl\-shift\-right\fR1601.br1602\fIctrl\-shift\-home\fR1603.br1604\fIctrl\-shift\-end\fR1605.br1606\fIctrl\-shift\-delete\fR1607.br1608\fIctrl\-shift\-page\-up\fR1609.br1610\fIctrl\-shift\-page\-down\fR1611.br1612\fIctrl\-alt\-shift\-up\fR1613.br1614\fIctrl\-alt\-shift\-down\fR1615.br1616\fIctrl\-alt\-shift\-left\fR1617.br1618\fIctrl\-alt\-shift\-right\fR1619.br1620\fIctrl\-alt\-shift\-home\fR1621.br1622\fIctrl\-alt\-shift\-end\fR1623.br1624\fIctrl\-alt\-shift\-delete\fR1625.br1626\fIctrl\-alt\-shift\-page\-up\fR1627.br1628\fIctrl\-alt\-shift\-page\-down\fR1629.br1630\fIleft\-click\fR1631.br1632\fIright\-click\fR1633.br
16 unmodified lines
1650\fIshift\-scroll\-down\fR1651.br1652or any single character16531654Note that some terminal emulators may not support \fIctrl-*\fR bindings.16551656.SS AVAILABLE EVENTS:1657\fIstart\fR1658.RS1659Triggered only once when fzf finder starts. Since fzf consumes the input stream
144 unmodified lines
1804 \fBaccept\fR \fIenter double\-click\fR1805 \fBaccept\-non\-empty\fR (same as \fBaccept\fR except that it prevents fzf from exiting without selection)1806 \fBaccept\-or\-print\-query\fR (same as \fBaccept\fR except that it prints the query when there's no match)1807 \fBbackward\-char\fR \fIctrl\-b left\fR1702 \fBbackward\-delete\-char\fR \fIctrl\-h bspace\fR1808 \fBbackward\-delete\-char\fR \fIctrl\-h ctrl\-bspace bspace\fR1809 \fBbackward\-delete\-char/eof\fR (same as \fBbackward\-delete\-char\fR except aborts fzf if query is empty)1810 \fBbackward\-kill\-word\fR \fIalt\-bs\fR1811 \fBbackward\-word\fR \fIalt\-b shift\-left\fR1812 \fBbecome(...)\fR (replace fzf process with the specified command; see below for the details)
319 unmodified lines
modified:src/tui/eventtype_string.go+128 added-77 removed
35 unmodified lines
36 _ = x[CtrlY-25]37 _ = x[CtrlZ-26]38 _ = x[Esc-27]39 _ = x[CtrlSpace-28]40 _ = x[CtrlDelete-29]41 _ = x[CtrlBackSlash-30]42 _ = x[CtrlRightBracket-31]43 _ = x[CtrlCaret-32]44 _ = x[CtrlSlash-33]45 _ = x[ShiftTab-34]46 _ = x[Backspace-35]47 _ = x[Delete-36]48 _ = x[PageUp-37]49 _ = x[PageDown-38]50 _ = x[Up-39]51 _ = x[Down-40]52 _ = x[Left-41]53 _ = x[Right-42]54 _ = x[Home-43]55 _ = x[End-44]56 _ = x[Insert-45]57 _ = x[ShiftUp-46]58 _ = x[ShiftDown-47]59 _ = x[ShiftLeft-48]60 _ = x[ShiftRight-49]61 _ = x[ShiftDelete-50]62 _ = x[F1-51]63 _ = x[F2-52]64 _ = x[F3-53]65 _ = x[F4-54]66 _ = x[F5-55]67 _ = x[F6-56]68 _ = x[F7-57]69 _ = x[F8-58]70 _ = x[F9-59]71 _ = x[F10-60]72 _ = x[F11-61]73 _ = x[F12-62]74 _ = x[AltBackspace-63]75 _ = x[AltUp-64]76 _ = x[AltDown-65]77 _ = x[AltLeft-66]78 _ = x[AltRight-67]79 _ = x[AltShiftUp-68]80 _ = x[AltShiftDown-69]81 _ = x[AltShiftLeft-70]82 _ = x[AltShiftRight-71]83 _ = x[Alt-72]84 _ = x[CtrlAlt-73]85 _ = x[Invalid-74]86 _ = x[Fatal-75]87 _ = x[BracketedPasteBegin-76]88 _ = x[BracketedPasteEnd-77]89 _ = x[Mouse-78]90 _ = x[DoubleClick-79]91 _ = x[LeftClick-80]92 _ = x[RightClick-81]93 _ = x[SLeftClick-82]94 _ = x[SRightClick-83]95 _ = x[ScrollUp-84]96 _ = x[ScrollDown-85]97 _ = x[SScrollUp-86]98 _ = x[SScrollDown-87]99 _ = x[PreviewScrollUp-88]100 _ = x[PreviewScrollDown-89]101 _ = x[Resize-90]102 _ = x[Change-91]103 _ = x[BackwardEOF-92]104 _ = x[Start-93]105 _ = x[Load-94]106 _ = x[Focus-95]107 _ = x[One-96]108 _ = x[Zero-97]109 _ = x[Result-98]110 _ = x[Jump-99]111 _ = x[JumpCancel-100]112 _ = x[ClickHeader-101]113 _ = x[ClickFooter-102]114 _ = x[Multi-103]40 _ = x[CtrlBackSlash-29]41 _ = x[CtrlRightBracket-30]42 _ = x[CtrlCaret-31]43 _ = x[CtrlSlash-32]44 _ = x[ShiftTab-33]45 _ = x[Backspace-34]46 _ = x[Delete-35]47 _ = x[PageUp-36]48 _ = x[PageDown-37]49 _ = x[Up-38]50 _ = x[Down-39]51 _ = x[Left-40]52 _ = x[Right-41]53 _ = x[Home-42]54 _ = x[End-43]55 _ = x[Insert-44]56 _ = x[ShiftUp-45]57 _ = x[ShiftDown-46]58 _ = x[ShiftLeft-47]59 _ = x[ShiftRight-48]60 _ = x[ShiftDelete-49]61 _ = x[ShiftHome-50]62 _ = x[ShiftEnd-51]63 _ = x[ShiftPageUp-52]64 _ = x[ShiftPageDown-53]65 _ = x[F1-54]66 _ = x[F2-55]67 _ = x[F3-56]68 _ = x[F4-57]69 _ = x[F5-58]70 _ = x[F6-59]71 _ = x[F7-60]72 _ = x[F8-61]73 _ = x[F9-62]74 _ = x[F10-63]75 _ = x[F11-64]76 _ = x[F12-65]77 _ = x[AltBackspace-66]78 _ = x[AltUp-67]79 _ = x[AltDown-68]80 _ = x[AltLeft-69]81 _ = x[AltRight-70]82 _ = x[AltDelete-71]83 _ = x[AltHome-72]84 _ = x[AltEnd-73]85 _ = x[AltPageUp-74]86 _ = x[AltPageDown-75]87 _ = x[AltShiftUp-76]88 _ = x[AltShiftDown-77]89 _ = x[AltShiftLeft-78]90 _ = x[AltShiftRight-79]91 _ = x[AltShiftDelete-80]92 _ = x[AltShiftHome-81]93 _ = x[AltShiftEnd-82]94 _ = x[AltShiftPageUp-83]95 _ = x[AltShiftPageDown-84]96 _ = x[CtrlUp-85]97 _ = x[CtrlDown-86]98 _ = x[CtrlLeft-87]99 _ = x[CtrlRight-88]100 _ = x[CtrlHome-89]101 _ = x[CtrlEnd-90]102 _ = x[CtrlBackspace-91]103 _ = x[CtrlDelete-92]104 _ = x[CtrlPageUp-93]105 _ = x[CtrlPageDown-94]106 _ = x[Alt-95]107 _ = x[CtrlAlt-96]108 _ = x[CtrlAltUp-97]109 _ = x[CtrlAltDown-98]110 _ = x[CtrlAltLeft-99]111 _ = x[CtrlAltRight-100]112 _ = x[CtrlAltHome-101]113 _ = x[CtrlAltEnd-102]114 _ = x[CtrlAltBackspace-103]115 _ = x[CtrlAltDelete-104]116 _ = x[CtrlAltPageUp-105]117 _ = x[CtrlAltPageDown-106]118 _ = x[CtrlShiftUp-107]119 _ = x[CtrlShiftDown-108]120 _ = x[CtrlShiftLeft-109]121 _ = x[CtrlShiftRight-110]122 _ = x[CtrlShiftHome-111]123 _ = x[CtrlShiftEnd-112]124 _ = x[CtrlShiftDelete-113]125 _ = x[CtrlShiftPageUp-114]126 _ = x[CtrlShiftPageDown-115]127 _ = x[CtrlAltShiftUp-116]128 _ = x[CtrlAltShiftDown-117]129 _ = x[CtrlAltShiftLeft-118]130 _ = x[CtrlAltShiftRight-119]131 _ = x[CtrlAltShiftHome-120]132 _ = x[CtrlAltShiftEnd-121]133 _ = x[CtrlAltShiftDelete-122]134 _ = x[CtrlAltShiftPageUp-123]135 _ = x[CtrlAltShiftPageDown-124]136 _ = x[Invalid-125]137 _ = x[Fatal-126]138 _ = x[BracketedPasteBegin-127]139 _ = x[BracketedPasteEnd-128]140 _ = x[Mouse-129]141 _ = x[DoubleClick-130]142 _ = x[LeftClick-131]143 _ = x[RightClick-132]144 _ = x[SLeftClick-133]145 _ = x[SRightClick-134]146 _ = x[ScrollUp-135]147 _ = x[ScrollDown-136]148 _ = x[SScrollUp-137]149 _ = x[SScrollDown-138]150 _ = x[PreviewScrollUp-139]151 _ = x[PreviewScrollDown-140]152 _ = x[Resize-141]153 _ = x[Change-142]154 _ = x[BackwardEOF-143]155 _ = x[Start-144]156 _ = x[Load-145]157 _ = x[Focus-146]158 _ = x[One-147]159 _ = x[Zero-148]160 _ = x[Result-149]161 _ = x[Jump-150]162 _ = x[JumpCancel-151]163 _ = x[ClickHeader-152]164 _ = x[ClickFooter-153]165 _ = x[Multi-154]166}167117const _EventType_name = "RuneCtrlACtrlBCtrlCCtrlDCtrlECtrlFCtrlGCtrlHTabCtrlJCtrlKCtrlLEnterCtrlNCtrlOCtrlPCtrlQCtrlRCtrlSCtrlTCtrlUCtrlVCtrlWCtrlXCtrlYCtrlZEscCtrlSpaceCtrlDeleteCtrlBackSlashCtrlRightBracketCtrlCaretCtrlSlashShiftTabBackspaceDeletePageUpPageDownUpDownLeftRightHomeEndInsertShiftUpShiftDownShiftLeftShiftRightShiftDeleteF1F2F3F4F5F6F7F8F9F10F11F12AltBackspaceAltUpAltDownAltLeftAltRightAltShiftUpAltShiftDownAltShiftLeftAltShiftRightAltCtrlAltInvalidFatalBracketedPasteBeginBracketedPasteEndMouseDoubleClickLeftClickRightClickSLeftClickSRightClickScrollUpScrollDownSScrollUpSScrollDownPreviewScrollUpPreviewScrollDownResizeChangeBackwardEOFStartLoadFocusOneZeroResultJumpJumpCancelClickHeaderClickFooterMulti"168const _EventType_name = "RuneCtrlACtrlBCtrlCCtrlDCtrlECtrlFCtrlGCtrlHTabCtrlJCtrlKCtrlLEnterCtrlNCtrlOCtrlPCtrlQCtrlRCtrlSCtrlTCtrlUCtrlVCtrlWCtrlXCtrlYCtrlZEscCtrlSpaceCtrlBackSlashCtrlRightBracketCtrlCaretCtrlSlashShiftTabBackspaceDeletePageUpPageDownUpDownLeftRightHomeEndInsertShiftUpShiftDownShiftLeftShiftRightShiftDeleteShiftHomeShiftEndShiftPageUpShiftPageDownF1F2F3F4F5F6F7F8F9F10F11F12AltBackspaceAltUpAltDownAltLeftAltRightAltDeleteAltHomeAltEndAltPageUpAltPageDownAltShiftUpAltShiftDownAltShiftLeftAltShiftRightAltShiftDeleteAltShiftHomeAltShiftEndAltShiftPageUpAltShiftPageDownCtrlUpCtrlDownCtrlLeftCtrlRightCtrlHomeCtrlEndCtrlBackspaceCtrlDeleteCtrlPageUpCtrlPageDownAltCtrlAltCtrlAltUpCtrlAltDownCtrlAltLeftCtrlAltRightCtrlAltHomeCtrlAltEndCtrlAltBackspaceCtrlAltDeleteCtrlAltPageUpCtrlAltPageDownCtrlShiftUpCtrlShiftDownCtrlShiftLeftCtrlShiftRightCtrlShiftHomeCtrlShiftEndCtrlShiftDeleteCtrlShiftPageUpCtrlShiftPageDownCtrlAltShiftUpCtrlAltShiftDownCtrlAltShiftLeftCtrlAltShiftRightCtrlAltShiftHomeCtrlAltShiftEndCtrlAltShiftDeleteCtrlAltShiftPageUpCtrlAltShiftPageDownInvalidFatalBracketedPasteBeginBracketedPasteEndMouseDoubleClickLeftClickRightClickSLeftClickSRightClickScrollUpScrollDownSScrollUpSScrollDownPreviewScrollUpPreviewScrollDownResizeChangeBackwardEOFStartLoadFocusOneZeroResultJumpJumpCancelClickHeaderClickFooterMulti"169119var _EventType_index = [...]uint16{0, 4, 9, 14, 19, 24, 29, 34, 39, 44, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97, 102, 107, 112, 117, 122, 127, 132, 135, 144, 154, 167, 183, 192, 201, 209, 218, 224, 230, 238, 240, 244, 248, 253, 257, 260, 266, 273, 282, 291, 301, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 333, 336, 339, 351, 356, 363, 370, 378, 388, 400, 412, 425, 428, 435, 442, 447, 466, 483, 488, 499, 508, 518, 528, 539, 547, 557, 566, 577, 592, 609, 615, 621, 632, 637, 641, 646, 649, 653, 659, 663, 673, 684, 695, 700}170var _EventType_index = [...]uint16{0, 4, 9, 14, 19, 24, 29, 34, 39, 44, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97, 102, 107, 112, 117, 122, 127, 132, 135, 144, 157, 173, 182, 191, 199, 208, 214, 220, 228, 230, 234, 238, 243, 247, 250, 256, 263, 272, 281, 291, 302, 311, 319, 330, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 364, 367, 370, 382, 387, 394, 401, 409, 418, 425, 431, 440, 451, 461, 473, 485, 498, 512, 524, 535, 549, 565, 571, 579, 587, 596, 604, 611, 624, 634, 644, 656, 659, 666, 675, 686, 697, 709, 720, 730, 746, 759, 772, 787, 798, 811, 824, 838, 851, 863, 878, 893, 910, 924, 940, 956, 973, 989, 1004, 1022, 1040, 1060, 1067, 1072, 1091, 1108, 1113, 1124, 1133, 1143, 1153, 1164, 1172, 1182, 1191, 1202, 1217, 1234, 1240, 1246, 1257, 1262, 1266, 1271, 1274, 1278, 1284, 1288, 1298, 1309, 1320, 1325}171172func (i EventType) String() string {173 if i < 0 || i >= EventType(len(_EventType_index)-1) {174 return "EventType(" + strconv.FormatInt(int64(i), 10) + ")"
3 unmodified lines
added:src/tui/light_test.go+335 added
1package tui23import (4 "fmt"5 "os"6 "testing"7 "unicode"8)910func TestLightRenderer(t *testing.T) {11 tty_file, _ := os.Open("")12 renderer, _ := NewLightRenderer(13 "", tty_file, &ColorTheme{}, true, false, 0, false, true,14 func(h int) int { return h })1516 light_renderer := renderer.(*LightRenderer)1718 assertCharSequence := func(sequence string, name string) {19 bytes := []byte(sequence)20 light_renderer.buffer = bytes21 event := light_renderer.GetChar()22 if event.KeyName() != name {23 t.Errorf(24 "sequence: %q | %v | '%s' (%s) != %s",25 string(bytes), bytes,26 event.KeyName(), event.Type.String(), name)27 }28 }2930 assertEscSequence := func(sequence string, name string) {31 bytes := []byte(sequence)32 light_renderer.buffer = bytes3334 sz := 135 event := light_renderer.escSequence(&sz)36 if fmt.Sprintf("!%s", event.Type.String()) == name {37 // this is fine38 } else if event.KeyName() != name {39 t.Errorf(40 "sequence: %q | %v | '%s' (%s) != %s",41 string(bytes), bytes,42 event.KeyName(), event.Type.String(), name)43 }44 }4546 // invalid47 assertEscSequence("\x1b[<", "!Invalid")48 assertEscSequence("\x1b[1;1R", "!Invalid")49 assertEscSequence("\x1b[", "!Invalid")50 assertEscSequence("\x1b[1", "!Invalid")51 assertEscSequence("\x1b[3;3~1", "!Invalid")52 assertEscSequence("\x1b[13", "!Invalid")53 assertEscSequence("\x1b[1;3", "!Invalid")54 assertEscSequence("\x1b[1;10", "!Invalid")55 assertEscSequence("\x1b[220~", "!Invalid")56 assertEscSequence("\x1b[5;30~", "!Invalid")57 assertEscSequence("\x1b[6;30~", "!Invalid")5859 // general60 for r := 'a'; r < 'z'; r++ {61 lower_r := fmt.Sprintf("%c", r)62 upper_r := fmt.Sprintf("%c", unicode.ToUpper(r))63 assertCharSequence(lower_r, lower_r)64 assertCharSequence(upper_r, upper_r)65 }6667 assertCharSequence("\x01", "ctrl-a")68 assertCharSequence("\x02", "ctrl-b")69 assertCharSequence("\x03", "ctrl-c")70 assertCharSequence("\x04", "ctrl-d")71 assertCharSequence("\x05", "ctrl-e")72 assertCharSequence("\x06", "ctrl-f")73 assertCharSequence("\x07", "ctrl-g")74 // ctrl-h is the same as ctrl-backspace75 // ctrl-i is the same as tab76 assertCharSequence("\n", "ctrl-j")77 assertCharSequence("\x0b", "ctrl-k")78 assertCharSequence("\x0c", "ctrl-l")79 assertCharSequence("\r", "enter") // enter80 assertCharSequence("\x0e", "ctrl-n")81 assertCharSequence("\x0f", "ctrl-o")82 assertCharSequence("\x10", "ctrl-p")83 assertCharSequence("\x11", "ctrl-q")84 assertCharSequence("\x12", "ctrl-r")85 assertCharSequence("\x13", "ctrl-s")86 assertCharSequence("\x14", "ctrl-t")87 assertCharSequence("\x15", "ctrl-u")88 assertCharSequence("\x16", "ctrl-v")89 assertCharSequence("\x17", "ctrl-w")90 assertCharSequence("\x18", "ctrl-x")91 assertCharSequence("\x19", "ctrl-y")92 assertCharSequence("\x1a", "ctrl-z")9394 assertCharSequence("\x00", "ctrl-space")95 assertCharSequence("\x1c", "ctrl-\\")96 assertCharSequence("\x1d", "ctrl-]")97 assertCharSequence("\x1e", "ctrl-^")98 assertCharSequence("\x1f", "ctrl-/")99100 assertEscSequence("\x1ba", "alt-a")101 assertEscSequence("\x1bb", "alt-b")102 assertEscSequence("\x1bc", "alt-c")103 assertEscSequence("\x1bd", "alt-d")104 assertEscSequence("\x1be", "alt-e")105 assertEscSequence("\x1bf", "alt-f")106 assertEscSequence("\x1bg", "alt-g")107 assertEscSequence("\x1bh", "alt-h")108 assertEscSequence("\x1bi", "alt-i")109 assertEscSequence("\x1bj", "alt-j")110 assertEscSequence("\x1bk", "alt-k")111 assertEscSequence("\x1bl", "alt-l")112 assertEscSequence("\x1bm", "alt-m")113 assertEscSequence("\x1bn", "alt-n")114 assertEscSequence("\x1bo", "alt-o")115 assertEscSequence("\x1bp", "alt-p")116 assertEscSequence("\x1bq", "alt-q")117 assertEscSequence("\x1br", "alt-r")118 assertEscSequence("\x1bs", "alt-s")119 assertEscSequence("\x1bt", "alt-t")120 assertEscSequence("\x1bu", "alt-u")121 assertEscSequence("\x1bv", "alt-v")122 assertEscSequence("\x1bw", "alt-w")123 assertEscSequence("\x1bx", "alt-x")124 assertEscSequence("\x1by", "alt-y")125 assertEscSequence("\x1bz", "alt-z")126127 assertEscSequence("\x1bOP", "f1")128 assertEscSequence("\x1bOQ", "f2")129 assertEscSequence("\x1bOR", "f3")130 assertEscSequence("\x1bOS", "f4")131 assertEscSequence("\x1b[15~", "f5")132 assertEscSequence("\x1b[17~", "f6")133 assertEscSequence("\x1b[18~", "f7")134 assertEscSequence("\x1b[19~", "f8")135 assertEscSequence("\x1b[20~", "f9")136 assertEscSequence("\x1b[21~", "f10")137 assertEscSequence("\x1b[23~", "f11")138 assertEscSequence("\x1b[24~", "f12")139140 assertEscSequence("\x1b", "esc")141 assertCharSequence("\t", "tab")142 assertEscSequence("\x1b[Z", "shift-tab")143144 assertCharSequence("\x7f", "backspace")145 assertEscSequence("\x1b\x7f", "alt-backspace")146 assertCharSequence("\b", "ctrl-backspace")147 assertEscSequence("\x1b\b", "ctrl-alt-backspace")148149 assertEscSequence("\x1b[A", "up")150 assertEscSequence("\x1b[B", "down")151 assertEscSequence("\x1b[C", "right")152 assertEscSequence("\x1b[D", "left")153 assertEscSequence("\x1b[H", "home")154 assertEscSequence("\x1b[F", "end")155 assertEscSequence("\x1b[2~", "insert")156 assertEscSequence("\x1b[3~", "delete")157 assertEscSequence("\x1b[5~", "page-up")158 assertEscSequence("\x1b[6~", "page-down")159 assertEscSequence("\x1b[7~", "home")160 assertEscSequence("\x1b[8~", "end")161162 assertEscSequence("\x1b[1;2A", "shift-up")163 assertEscSequence("\x1b[1;2B", "shift-down")164 assertEscSequence("\x1b[1;2C", "shift-right")165 assertEscSequence("\x1b[1;2D", "shift-left")166 assertEscSequence("\x1b[1;2H", "shift-home")167 assertEscSequence("\x1b[1;2F", "shift-end")168 assertEscSequence("\x1b[3;2~", "shift-delete")169 assertEscSequence("\x1b[5;2~", "shift-page-up")170 assertEscSequence("\x1b[6;2~", "shift-page-down")171172 assertEscSequence("\x1b\x1b", "esc")173 assertEscSequence("\x1b\x1b[A", "alt-up")174 assertEscSequence("\x1b\x1b[B", "alt-down")175 assertEscSequence("\x1b\x1b[C", "alt-right")176 assertEscSequence("\x1b\x1b[D", "alt-left")177178 assertEscSequence("\x1b[1;3A", "alt-up")179 assertEscSequence("\x1b[1;3B", "alt-down")180 assertEscSequence("\x1b[1;3C", "alt-right")181 assertEscSequence("\x1b[1;3D", "alt-left")182 assertEscSequence("\x1b[1;3H", "alt-home")183 assertEscSequence("\x1b[1;3F", "alt-end")184 assertEscSequence("\x1b[3;3~", "alt-delete")185 assertEscSequence("\x1b[5;3~", "alt-page-up")186 assertEscSequence("\x1b[6;3~", "alt-page-down")187188 assertEscSequence("\x1b[1;4A", "alt-shift-up")189 assertEscSequence("\x1b[1;4B", "alt-shift-down")190 assertEscSequence("\x1b[1;4C", "alt-shift-right")191 assertEscSequence("\x1b[1;4D", "alt-shift-left")192 assertEscSequence("\x1b[1;4H", "alt-shift-home")193 assertEscSequence("\x1b[1;4F", "alt-shift-end")194 assertEscSequence("\x1b[3;4~", "alt-shift-delete")195 assertEscSequence("\x1b[5;4~", "alt-shift-page-up")196 assertEscSequence("\x1b[6;4~", "alt-shift-page-down")197198 assertEscSequence("\x1b[1;5A", "ctrl-up")199 assertEscSequence("\x1b[1;5B", "ctrl-down")200 assertEscSequence("\x1b[1;5C", "ctrl-right")201 assertEscSequence("\x1b[1;5D", "ctrl-left")202 assertEscSequence("\x1b[1;5H", "ctrl-home")203 assertEscSequence("\x1b[1;5F", "ctrl-end")204 assertEscSequence("\x1b[3;5~", "ctrl-delete")205 assertEscSequence("\x1b[5;5~", "ctrl-page-up")206 assertEscSequence("\x1b[6;5~", "ctrl-page-down")207208 assertEscSequence("\x1b[1;7A", "ctrl-alt-up")209 assertEscSequence("\x1b[1;7B", "ctrl-alt-down")210 assertEscSequence("\x1b[1;7C", "ctrl-alt-right")211 assertEscSequence("\x1b[1;7D", "ctrl-alt-left")212 assertEscSequence("\x1b[1;7H", "ctrl-alt-home")213 assertEscSequence("\x1b[1;7F", "ctrl-alt-end")214 assertEscSequence("\x1b[3;7~", "ctrl-alt-delete")215 assertEscSequence("\x1b[5;7~", "ctrl-alt-page-up")216 assertEscSequence("\x1b[6;7~", "ctrl-alt-page-down")217218 assertEscSequence("\x1b[1;6A", "ctrl-shift-up")219 assertEscSequence("\x1b[1;6B", "ctrl-shift-down")220 assertEscSequence("\x1b[1;6C", "ctrl-shift-right")221 assertEscSequence("\x1b[1;6D", "ctrl-shift-left")222 assertEscSequence("\x1b[1;6H", "ctrl-shift-home")223 assertEscSequence("\x1b[1;6F", "ctrl-shift-end")224 assertEscSequence("\x1b[3;6~", "ctrl-shift-delete")225 assertEscSequence("\x1b[5;6~", "ctrl-shift-page-up")226 assertEscSequence("\x1b[6;6~", "ctrl-shift-page-down")227228 assertEscSequence("\x1b[1;8A", "ctrl-alt-shift-up")229 assertEscSequence("\x1b[1;8B", "ctrl-alt-shift-down")230 assertEscSequence("\x1b[1;8C", "ctrl-alt-shift-right")231 assertEscSequence("\x1b[1;8D", "ctrl-alt-shift-left")232 assertEscSequence("\x1b[1;8H", "ctrl-alt-shift-home")233 assertEscSequence("\x1b[1;8F", "ctrl-alt-shift-end")234 assertEscSequence("\x1b[3;8~", "ctrl-alt-shift-delete")235 assertEscSequence("\x1b[5;8~", "ctrl-alt-shift-page-up")236 assertEscSequence("\x1b[6;8~", "ctrl-alt-shift-page-down")237238 // xterm meta & mac239 assertEscSequence("\x1b[1;9A", "alt-up")240 assertEscSequence("\x1b[1;9B", "alt-down")241 assertEscSequence("\x1b[1;9C", "alt-right")242 assertEscSequence("\x1b[1;9D", "alt-left")243 assertEscSequence("\x1b[1;9H", "alt-home")244 assertEscSequence("\x1b[1;9F", "alt-end")245 assertEscSequence("\x1b[3;9~", "alt-delete")246 assertEscSequence("\x1b[5;9~", "alt-page-up")247 assertEscSequence("\x1b[6;9~", "alt-page-down")248249 assertEscSequence("\x1b[1;10A", "alt-shift-up")250 assertEscSequence("\x1b[1;10B", "alt-shift-down")251 assertEscSequence("\x1b[1;10C", "alt-shift-right")252 assertEscSequence("\x1b[1;10D", "alt-shift-left")253 assertEscSequence("\x1b[1;10H", "alt-shift-home")254 assertEscSequence("\x1b[1;10F", "alt-shift-end")255 assertEscSequence("\x1b[3;10~", "alt-shift-delete")256 assertEscSequence("\x1b[5;10~", "alt-shift-page-up")257 assertEscSequence("\x1b[6;10~", "alt-shift-page-down")258259 assertEscSequence("\x1b[1;11A", "alt-up")260 assertEscSequence("\x1b[1;11B", "alt-down")261 assertEscSequence("\x1b[1;11C", "alt-right")262 assertEscSequence("\x1b[1;11D", "alt-left")263 assertEscSequence("\x1b[1;11H", "alt-home")264 assertEscSequence("\x1b[1;11F", "alt-end")265 assertEscSequence("\x1b[3;11~", "alt-delete")266 assertEscSequence("\x1b[5;11~", "alt-page-up")267 assertEscSequence("\x1b[6;11~", "alt-page-down")268269 assertEscSequence("\x1b[1;12A", "alt-shift-up")270 assertEscSequence("\x1b[1;12B", "alt-shift-down")271 assertEscSequence("\x1b[1;12C", "alt-shift-right")272 assertEscSequence("\x1b[1;12D", "alt-shift-left")273 assertEscSequence("\x1b[1;12H", "alt-shift-home")274 assertEscSequence("\x1b[1;12F", "alt-shift-end")275 assertEscSequence("\x1b[3;12~", "alt-shift-delete")276 assertEscSequence("\x1b[5;12~", "alt-shift-page-up")277 assertEscSequence("\x1b[6;12~", "alt-shift-page-down")278279 assertEscSequence("\x1b[1;13A", "ctrl-alt-up")280 assertEscSequence("\x1b[1;13B", "ctrl-alt-down")281 assertEscSequence("\x1b[1;13C", "ctrl-alt-right")282 assertEscSequence("\x1b[1;13D", "ctrl-alt-left")283 assertEscSequence("\x1b[1;13H", "ctrl-alt-home")284 assertEscSequence("\x1b[1;13F", "ctrl-alt-end")285 assertEscSequence("\x1b[3;13~", "ctrl-alt-delete")286 assertEscSequence("\x1b[5;13~", "ctrl-alt-page-up")287 assertEscSequence("\x1b[6;13~", "ctrl-alt-page-down")288289 assertEscSequence("\x1b[1;14A", "ctrl-alt-shift-up")290 assertEscSequence("\x1b[1;14B", "ctrl-alt-shift-down")291 assertEscSequence("\x1b[1;14C", "ctrl-alt-shift-right")292 assertEscSequence("\x1b[1;14D", "ctrl-alt-shift-left")293 assertEscSequence("\x1b[1;14H", "ctrl-alt-shift-home")294 assertEscSequence("\x1b[1;14F", "ctrl-alt-shift-end")295 assertEscSequence("\x1b[3;14~", "ctrl-alt-shift-delete")296 assertEscSequence("\x1b[5;14~", "ctrl-alt-shift-page-up")297 assertEscSequence("\x1b[6;14~", "ctrl-alt-shift-page-down")298299 assertEscSequence("\x1b[1;15A", "ctrl-alt-up")300 assertEscSequence("\x1b[1;15B", "ctrl-alt-down")301 assertEscSequence("\x1b[1;15C", "ctrl-alt-right")302 assertEscSequence("\x1b[1;15D", "ctrl-alt-left")303 assertEscSequence("\x1b[1;15H", "ctrl-alt-home")304 assertEscSequence("\x1b[1;15F", "ctrl-alt-end")305 assertEscSequence("\x1b[3;15~", "ctrl-alt-delete")306 assertEscSequence("\x1b[5;15~", "ctrl-alt-page-up")307 assertEscSequence("\x1b[6;15~", "ctrl-alt-page-down")308309 assertEscSequence("\x1b[1;16A", "ctrl-alt-shift-up")310 assertEscSequence("\x1b[1;16B", "ctrl-alt-shift-down")311 assertEscSequence("\x1b[1;16C", "ctrl-alt-shift-right")312 assertEscSequence("\x1b[1;16D", "ctrl-alt-shift-left")313 assertEscSequence("\x1b[1;16H", "ctrl-alt-shift-home")314 assertEscSequence("\x1b[1;16F", "ctrl-alt-shift-end")315 assertEscSequence("\x1b[3;16~", "ctrl-alt-shift-delete")316 assertEscSequence("\x1b[5;16~", "ctrl-alt-shift-page-up")317 assertEscSequence("\x1b[6;16~", "ctrl-alt-shift-page-down")318319 // tmux & emacs320 assertEscSequence("\x1bOA", "up")321 assertEscSequence("\x1bOB", "down")322 assertEscSequence("\x1bOC", "right")323 assertEscSequence("\x1bOD", "left")324 assertEscSequence("\x1bOH", "home")325 assertEscSequence("\x1bOF", "end")326327 // rrvt328 assertEscSequence("\x1b[1~", "home")329 assertEscSequence("\x1b[4~", "end")330 assertEscSequence("\x1b[11~", "f1")331 assertEscSequence("\x1b[12~", "f2")332 assertEscSequence("\x1b[13~", "f3")333 assertEscSequence("\x1b[14~", "f4")334335}
modified:src/tui/light.go+255 added-27 removed
333 unmodified lines
334 case CtrlQ.Byte():335 return Event{CtrlQ, 0, nil}336 case 127:337 return Event{Backspace, 0, nil}338 case 8:339 return Event{CtrlBackspace, 0, nil}340 case 0:341 return Event{CtrlSpace, 0, nil}342 case 28:343 return Event{CtrlBackSlash, 0, nil}
38 unmodified lines
382 return Event{Invalid, 0, nil}383 }384385 *sz = 2386 if r.buffer[1] == 8 {387 return Event{CtrlAltBackspace, 0, nil}388 }389 if r.buffer[1] >= 1 && r.buffer[1] <= 'z'-'a'+1 {390 return CtrlAltKey(rune(r.buffer[1] + 'a' - 1))391 }392 alt := false
84 unmodified lines
477 case '3':478 if r.buffer[3] == '~' {479 return Event{Delete, 0, nil}480 }481 if len(r.buffer) == 7 && r.buffer[6] == '~' && r.buffer[4] == '1' {482 switch r.buffer[5] {483 case '0':484 return Event{AltShiftDelete, 0, nil}485 case '1':486 return Event{AltDelete, 0, nil}487 case '2':488 return Event{AltShiftDelete, 0, nil}489 case '3':490 return Event{CtrlAltDelete, 0, nil}491 case '4':492 return Event{CtrlAltShiftDelete, 0, nil}493 case '5':494 return Event{CtrlAltDelete, 0, nil}495 case '6':496 return Event{CtrlAltShiftDelete, 0, nil}497 }498 }499 if len(r.buffer) == 6 && r.buffer[5] == '~' {500 *sz = 6501 switch r.buffer[4] {479 case '5':480 return Event{CtrlDelete, 0, nil}502 case '2':503 return Event{ShiftDelete, 0, nil}504 case '3':505 return Event{AltDelete, 0, nil}506 case '4':507 return Event{AltShiftDelete, 0, nil}508 case '5':509 return Event{CtrlDelete, 0, nil}510 case '6':511 return Event{CtrlShiftDelete, 0, nil}512 case '7':513 return Event{CtrlAltDelete, 0, nil}514 case '8':515 return Event{CtrlAltShiftDelete, 0, nil}516 case '9':517 return Event{AltDelete, 0, nil}518 }519 }520 return Event{Invalid, 0, nil}521 case '4':522 return Event{End, 0, nil}523 case '5':524 if r.buffer[3] == '~' {489 return Event{PageUp, 0, nil}525 return Event{PageUp, 0, nil}526 }527 if len(r.buffer) == 7 && r.buffer[6] == '~' && r.buffer[4] == '1' {528 switch r.buffer[5] {529 case '0':530 return Event{AltShiftPageUp, 0, nil}531 case '1':532 return Event{AltPageUp, 0, nil}533 case '2':534 return Event{AltShiftPageUp, 0, nil}535 case '3':536 return Event{CtrlAltPageUp, 0, nil}537 case '4':538 return Event{CtrlAltShiftPageUp, 0, nil}539 case '5':540 return Event{CtrlAltPageUp, 0, nil}541 case '6':542 return Event{CtrlAltShiftPageUp, 0, nil}543 }544 }545 if len(r.buffer) == 6 && r.buffer[5] == '~' {546 *sz = 6547 switch r.buffer[4] {548 case '2':549 return Event{ShiftPageUp, 0, nil}550 case '3':551 return Event{AltPageUp, 0, nil}552 case '4':553 return Event{AltShiftPageUp, 0, nil}554 case '5':555 return Event{CtrlPageUp, 0, nil}556 case '6':557 return Event{CtrlShiftPageUp, 0, nil}558 case '7':559 return Event{CtrlAltPageUp, 0, nil}560 case '8':561 return Event{CtrlAltShiftPageUp, 0, nil}562 case '9':563 return Event{AltPageUp, 0, nil}564 }565 }566 return Event{Invalid, 0, nil}567 case '6':568 if r.buffer[3] == '~' {491 return Event{PageDown, 0, nil}569 return Event{PageDown, 0, nil}570 }571 if len(r.buffer) == 7 && r.buffer[6] == '~' && r.buffer[4] == '1' {572 switch r.buffer[5] {573 case '0':574 return Event{AltShiftPageDown, 0, nil}575 case '1':576 return Event{AltPageDown, 0, nil}577 case '2':578 return Event{AltShiftPageDown, 0, nil}579 case '3':580 return Event{CtrlAltPageDown, 0, nil}581 case '4':582 return Event{CtrlAltShiftPageDown, 0, nil}583 case '5':584 return Event{CtrlAltPageDown, 0, nil}585 case '6':586 return Event{CtrlAltShiftPageDown, 0, nil}587 }588 }589 if len(r.buffer) == 6 && r.buffer[5] == '~' {590 *sz = 6591 switch r.buffer[4] {592 case '2':593 return Event{ShiftPageDown, 0, nil}594 case '3':595 return Event{AltPageDown, 0, nil}596 case '4':597 return Event{AltShiftPageDown, 0, nil}598 case '5':599 return Event{CtrlPageDown, 0, nil}600 case '6':601 return Event{CtrlShiftPageDown, 0, nil}602 case '7':603 return Event{CtrlAltPageDown, 0, nil}604 case '8':605 return Event{CtrlAltShiftPageDown, 0, nil}606 case '9':607 return Event{AltPageDown, 0, nil}608 }609 }610 return Event{Invalid, 0, nil}611 case '7':612 return Event{Home, 0, nil}613 case '8':614 return Event{End, 0, nil}
29 unmodified lines
644 return Event{Invalid, 0, nil}645 }646 *sz = 6647 switch r.buffer[4] {529 case '1', '2', '3', '4', '5':648 case '1', '2', '3', '4', '5', '6', '7', '8', '9':649 // Kitty iTerm2 WezTerm650 // SHIFT-ARROW "\e[1;2D"651 // ALT-SHIFT-ARROW "\e[1;4D" "\e[1;10D" "\e[1;4D"652 // CTRL-SHIFT-ARROW "\e[1;6D" N/A653 // CMD-SHIFT-ARROW "\e[1;10D" N/A N/A ("\e[1;2D")535 alt := r.buffer[4] == '3'654 ctrl := bytes.IndexByte([]byte{'5', '6', '7', '8'}, r.buffer[4]) >= 0655 alt := bytes.IndexByte([]byte{'3', '4', '7', '8'}, r.buffer[4]) >= 0656 shift := bytes.IndexByte([]byte{'2', '4', '6', '8'}, r.buffer[4]) >= 0657 char := r.buffer[5]537 altShift := false538 if r.buffer[4] == '1' && r.buffer[5] == '0' {539 altShift = true540 if len(r.buffer) < 7 {541 return Event{Invalid, 0, nil}542 }543 *sz = 7544 char = r.buffer[6]545 } else if r.buffer[4] == '4' {546 altShift = true658 if r.buffer[4] == '9' {659 ctrl = false660 alt = true661 shift = false662 if len(r.buffer) < 6 {663 return Event{Invalid, 0, nil}664 }665 *sz = 6666 char = r.buffer[5]667 } else if r.buffer[4] == '1' && bytes.IndexByte([]byte{'0', '1', '2', '3', '4', '5', '6'}, r.buffer[5]) >= 0 {668 ctrl = bytes.IndexByte([]byte{'3', '4', '5', '6'}, r.buffer[5]) >= 0669 alt = true670 shift = bytes.IndexByte([]byte{'0', '2', '4', '6'}, r.buffer[5]) >= 0671 if len(r.buffer) < 7 {672 return Event{Invalid, 0, nil}673 }674 *sz = 7675 char = r.buffer[6]676 }677 ctrlShift := ctrl && shift678 ctrlAlt := ctrl && alt679 altShift := alt && shift680 ctrlAltShift := ctrl && alt && shift681 switch char {682 case 'A':555 if alt {556 return Event{AltUp, 0, nil}683 if ctrlAltShift {684 return Event{CtrlAltShiftUp, 0, nil}685 }686 if ctrlAlt {687 return Event{CtrlAltUp, 0, nil}688 }689 if ctrlShift {690 return Event{CtrlShiftUp, 0, nil}691 }692 if altShift {693 return Event{AltShiftUp, 0, nil}694 }561 return Event{ShiftUp, 0, nil}562 case 'B':695 if ctrl {696 return Event{CtrlUp, 0, nil}697 }698 if alt {564 return Event{AltDown, 0, nil}699 return Event{AltUp, 0, nil}700 }701 if shift {702 return Event{ShiftUp, 0, nil}703 }704 case 'B':705 if ctrlAltShift {706 return Event{CtrlAltShiftDown, 0, nil}707 }708 if ctrlAlt {709 return Event{CtrlAltDown, 0, nil}710 }711 if ctrlShift {712 return Event{CtrlShiftDown, 0, nil}713 }714 if altShift {715 return Event{AltShiftDown, 0, nil}716 }569 return Event{ShiftDown, 0, nil}570 case 'C':717 if ctrl {718 return Event{CtrlDown, 0, nil}719 }720 if alt {572 return Event{AltRight, 0, nil}721 return Event{AltDown, 0, nil}722 }723 if shift {724 return Event{ShiftDown, 0, nil}725 }726 case 'C':727 if ctrlAltShift {728 return Event{CtrlAltShiftRight, 0, nil}729 }730 if ctrlAlt {731 return Event{CtrlAltRight, 0, nil}732 }733 if ctrlShift {734 return Event{CtrlShiftRight, 0, nil}735 }736 if altShift {737 return Event{AltShiftRight, 0, nil}738 }739 if ctrl {740 return Event{CtrlRight, 0, nil}741 }742 if shift {577 return Event{ShiftRight, 0, nil}743 return Event{ShiftRight, 0, nil}744 }745 if alt {746 return Event{AltRight, 0, nil}747 }748 case 'D':749 if ctrlAltShift {750 return Event{CtrlAltShiftLeft, 0, nil}751 }752 if ctrlAlt {753 return Event{CtrlAltLeft, 0, nil}754 }755 if ctrlShift {756 return Event{CtrlShiftLeft, 0, nil}757 }758 if altShift {759 return Event{AltShiftLeft, 0, nil}760 }761 if ctrl {762 return Event{CtrlLeft, 0, nil}763 }764 if alt {765 return Event{AltLeft, 0, nil}766 }767 if shift {768 return Event{ShiftLeft, 0, nil}769 }770 case 'H':771 if ctrlAltShift {772 return Event{CtrlAltShiftHome, 0, nil}773 }774 if ctrlAlt {775 return Event{CtrlAltHome, 0, nil}776 }777 if ctrlShift {778 return Event{CtrlShiftHome, 0, nil}779 }780 if altShift {583 return Event{AltShiftLeft, 0, nil}781 return Event{AltShiftHome, 0, nil}782 }783 if ctrl {784 return Event{CtrlHome, 0, nil}785 }786 if alt {787 return Event{AltHome, 0, nil}788 }789 if shift {585 return Event{ShiftLeft, 0, nil}790 return Event{ShiftHome, 0, nil}791 }792 case 'F':793 if ctrlAltShift {794 return Event{CtrlAltShiftEnd, 0, nil}795 }796 if ctrlAlt {797 return Event{CtrlAltEnd, 0, nil}798 }799 if ctrlShift {800 return Event{CtrlShiftEnd, 0, nil}801 }802 if altShift {803 return Event{AltShiftEnd, 0, nil}804 }805 if ctrl {806 return Event{CtrlEnd, 0, nil}807 }808 if alt {809 return Event{AltEnd, 0, nil}810 }811 if shift {812 return Event{ShiftEnd, 0, nil}813 }814 }815 } // r.buffer[4]816 } // r.buffer[3]817 } // r.buffer[2]
685 unmodified lines
modified:src/tui/tcell_test.go+84 added-6 removed
105 unmodified lines
106 {giveKey{tcell.KeyBackspace2, 0, tcell.ModNone}, wantKey{Backspace, 0, nil}}, // fabricated107 {giveKey{tcell.KeyBackspace2, 0, tcell.ModAlt}, wantKey{AltBackspace, 0, nil}}, // fabricated108 {giveKey{tcell.KeyDEL, 0, tcell.ModNone}, wantKey{Backspace, 0, nil}}, // fabricated, unhandled109 {giveKey{tcell.KeyDelete, 0, tcell.ModNone}, wantKey{Delete, 0, nil}},110 {giveKey{tcell.KeyDelete, 0, tcell.ModAlt}, wantKey{Delete, 0, nil}},110 {giveKey{tcell.KeyDelete, 0, tcell.ModAlt}, wantKey{AltDelete, 0, nil}},111 {giveKey{tcell.KeyBackspace, 0, tcell.ModCtrl}, wantKey{CtrlBackspace, 0, nil}},112 {giveKey{tcell.KeyBackspace, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltBackspace, 0, nil}},113 {giveKey{tcell.KeyBackspace, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled114 {giveKey{tcell.KeyBS, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled115 {giveKey{tcell.KeyCtrlH, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled116 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModNone}, wantKey{Backspace, 0, nil}}, // actual "Backspace" keystroke117 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModAlt}, wantKey{AltBackspace, 0, nil}}, // actual "Alt+Backspace" keystroke116 {giveKey{tcell.KeyDEL, rune(tcell.KeyDEL), tcell.ModCtrl}, wantKey{Backspace, 0, nil}}, // actual "Ctrl+Backspace" keystroke118 {giveKey{tcell.KeyDEL, rune(tcell.KeyDEL), tcell.ModCtrl}, wantKey{CtrlBackspace, 0, nil}}, // actual "Ctrl+Backspace" keystroke119 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModShift}, wantKey{Backspace, 0, nil}}, // actual "Shift+Backspace" keystroke118 {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{Backspace, 0, nil}}, // actual "Ctrl+Alt+Backspace" keystroke119 {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{Backspace, 0, nil}}, // actual "Ctrl+Shift+Backspace" keystroke120 {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltBackspace, 0, nil}}, // actual "Ctrl+Alt+Backspace" keystroke121 {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlBackspace, 0, nil}}, // actual "Ctrl+Shift+Backspace" keystroke122 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModShift | tcell.ModAlt}, wantKey{AltBackspace, 0, nil}}, // actual "Shift+Alt+Backspace" keystroke121 {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt | tcell.ModShift}, wantKey{Backspace, 0, nil}}, // actual "Ctrl+Shift+Alt+Backspace" keystroke123 {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt | tcell.ModShift}, wantKey{CtrlAltBackspace, 0, nil}}, // actual "Ctrl+Shift+Alt+Backspace" keystroke124 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModCtrl}, wantKey{CtrlH, 0, nil}}, // actual "Ctrl+H" keystroke125 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAlt, 'h', nil}}, // fabricated "Ctrl+Alt+H" keystroke126 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlH, 0, nil}}, // actual "Ctrl+Shift+H" keystroke127 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModCtrl | tcell.ModAlt | tcell.ModShift}, wantKey{CtrlAlt, 'h', nil}}, // fabricated "Ctrl+Shift+Alt+H" keystroke128129 // section 4: (Alt+Shift)+Key(Up|Down|Left|Right)130 {giveKey{tcell.KeyUp, 0, tcell.ModNone}, wantKey{Up, 0, nil}},129 {giveKey{tcell.KeyDown, 0, tcell.ModAlt}, wantKey{AltDown, 0, nil}},131 {giveKey{tcell.KeyDown, 0, tcell.ModNone}, wantKey{Down, 0, nil}},132 {giveKey{tcell.KeyLeft, 0, tcell.ModNone}, wantKey{Left, 0, nil}},133 {giveKey{tcell.KeyRight, 0, tcell.ModNone}, wantKey{Right, 0, nil}},134 {giveKey{tcell.KeyUp, 0, tcell.ModNone}, wantKey{Up, 0, nil}},135 {giveKey{tcell.KeyDown, 0, tcell.ModNone}, wantKey{Down, 0, nil}},136 {giveKey{tcell.KeyRight, 0, tcell.ModNone}, wantKey{Right, 0, nil}},137 {giveKey{tcell.KeyLeft, 0, tcell.ModNone}, wantKey{Left, 0, nil}},138 {giveKey{tcell.KeyUp, 0, tcell.ModCtrl}, wantKey{CtrlUp, 0, nil}},139 {giveKey{tcell.KeyDown, 0, tcell.ModCtrl}, wantKey{CtrlDown, 0, nil}},140 {giveKey{tcell.KeyRight, 0, tcell.ModCtrl}, wantKey{CtrlRight, 0, nil}},141 {giveKey{tcell.KeyLeft, 0, tcell.ModCtrl}, wantKey{CtrlLeft, 0, nil}},142 {giveKey{tcell.KeyUp, 0, tcell.ModShift}, wantKey{ShiftUp, 0, nil}},143 {giveKey{tcell.KeyDown, 0, tcell.ModShift}, wantKey{ShiftDown, 0, nil}},144 {giveKey{tcell.KeyRight, 0, tcell.ModShift}, wantKey{ShiftRight, 0, nil}},145 {giveKey{tcell.KeyLeft, 0, tcell.ModShift}, wantKey{ShiftLeft, 0, nil}},146 {giveKey{tcell.KeyUp, 0, tcell.ModAlt}, wantKey{AltUp, 0, nil}},147 {giveKey{tcell.KeyDown, 0, tcell.ModAlt}, wantKey{AltDown, 0, nil}},148 {giveKey{tcell.KeyRight, 0, tcell.ModAlt}, wantKey{AltRight, 0, nil}},149 {giveKey{tcell.KeyLeft, 0, tcell.ModAlt}, wantKey{AltLeft, 0, nil}},150 {giveKey{tcell.KeyUp, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlShiftUp, 0, nil}},151 {giveKey{tcell.KeyDown, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlShiftDown, 0, nil}},152 {giveKey{tcell.KeyRight, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlShiftRight, 0, nil}},153 {giveKey{tcell.KeyLeft, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlShiftLeft, 0, nil}},154 {giveKey{tcell.KeyUp, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltUp, 0, nil}},155 {giveKey{tcell.KeyDown, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltDown, 0, nil}},156 {giveKey{tcell.KeyRight, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltRight, 0, nil}},157 {giveKey{tcell.KeyLeft, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltLeft, 0, nil}},158 {giveKey{tcell.KeyUp, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftUp, 0, nil}},159 {giveKey{tcell.KeyDown, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftDown, 0, nil}},160 {giveKey{tcell.KeyRight, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftRight, 0, nil}},161 {giveKey{tcell.KeyLeft, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftLeft, 0, nil}},162 {giveKey{tcell.KeyUp, 0, tcell.ModCtrl | tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAltShiftUp, 0, nil}},163 {giveKey{tcell.KeyDown, 0, tcell.ModCtrl | tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAltShiftDown, 0, nil}},164 {giveKey{tcell.KeyRight, 0, tcell.ModCtrl | tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAltShiftRight, 0, nil}},165 {giveKey{tcell.KeyLeft, 0, tcell.ModCtrl | tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAltShiftLeft, 0, nil}},166 {giveKey{tcell.KeyUpLeft, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled167 {giveKey{tcell.KeyUpRight, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled168 {giveKey{tcell.KeyDownLeft, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled169 {giveKey{tcell.KeyDownRight, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled170 {giveKey{tcell.KeyCenter, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled171 // section 5: (Insert|Home|Delete|End|PgUp|PgDn|BackTab|F1-F12)172 {giveKey{tcell.KeyInsert, 0, tcell.ModNone}, wantKey{Insert, 0, nil}},173 {giveKey{tcell.KeyF1, 0, tcell.ModNone}, wantKey{F1, 0, nil}},174 {giveKey{tcell.KeyHome, 0, tcell.ModNone}, wantKey{Home, 0, nil}},175 {giveKey{tcell.KeyEnd, 0, tcell.ModNone}, wantKey{End, 0, nil}},176 {giveKey{tcell.KeyDelete, 0, tcell.ModNone}, wantKey{Delete, 0, nil}},177 {giveKey{tcell.KeyPgUp, 0, tcell.ModNone}, wantKey{PageUp, 0, nil}},178 {giveKey{tcell.KeyPgDn, 0, tcell.ModNone}, wantKey{PageDown, 0, nil}},179 {giveKey{tcell.KeyHome, 0, tcell.ModCtrl}, wantKey{CtrlHome, 0, nil}},180 {giveKey{tcell.KeyEnd, 0, tcell.ModCtrl}, wantKey{CtrlEnd, 0, nil}},181 {giveKey{tcell.KeyDelete, 0, tcell.ModCtrl}, wantKey{CtrlDelete, 0, nil}},182 {giveKey{tcell.KeyPgUp, 0, tcell.ModCtrl}, wantKey{CtrlPageUp, 0, nil}},183 {giveKey{tcell.KeyPgDn, 0, tcell.ModCtrl}, wantKey{CtrlPageDown, 0, nil}},184 {giveKey{tcell.KeyHome, 0, tcell.ModShift}, wantKey{ShiftHome, 0, nil}},185 {giveKey{tcell.KeyEnd, 0, tcell.ModShift}, wantKey{ShiftEnd, 0, nil}},186 {giveKey{tcell.KeyDelete, 0, tcell.ModShift}, wantKey{ShiftDelete, 0, nil}},187 {giveKey{tcell.KeyPgUp, 0, tcell.ModShift}, wantKey{ShiftPageUp, 0, nil}},188 {giveKey{tcell.KeyPgDn, 0, tcell.ModShift}, wantKey{ShiftPageDown, 0, nil}},189 {giveKey{tcell.KeyHome, 0, tcell.ModAlt}, wantKey{AltHome, 0, nil}},190 {giveKey{tcell.KeyEnd, 0, tcell.ModAlt}, wantKey{AltEnd, 0, nil}},191 {giveKey{tcell.KeyDelete, 0, tcell.ModAlt}, wantKey{AltDelete, 0, nil}},192 {giveKey{tcell.KeyPgUp, 0, tcell.ModAlt}, wantKey{AltPageUp, 0, nil}},193 {giveKey{tcell.KeyPgDn, 0, tcell.ModAlt}, wantKey{AltPageDown, 0, nil}},194 {giveKey{tcell.KeyHome, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlShiftHome, 0, nil}},195 {giveKey{tcell.KeyEnd, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlShiftEnd, 0, nil}},196 {giveKey{tcell.KeyDelete, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlShiftDelete, 0, nil}},197 {giveKey{tcell.KeyPgUp, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlShiftPageUp, 0, nil}},198 {giveKey{tcell.KeyPgDn, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlShiftPageDown, 0, nil}},199 {giveKey{tcell.KeyHome, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltHome, 0, nil}},200 {giveKey{tcell.KeyEnd, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltEnd, 0, nil}},201 {giveKey{tcell.KeyDelete, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltDelete, 0, nil}},202 {giveKey{tcell.KeyPgUp, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltPageUp, 0, nil}},203 {giveKey{tcell.KeyPgDn, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAltPageDown, 0, nil}},204 {giveKey{tcell.KeyHome, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftHome, 0, nil}},205 {giveKey{tcell.KeyEnd, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftEnd, 0, nil}},206 {giveKey{tcell.KeyDelete, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftDelete, 0, nil}},207 {giveKey{tcell.KeyPgUp, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftPageUp, 0, nil}},208 {giveKey{tcell.KeyPgDn, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftPageDown, 0, nil}},209 {giveKey{tcell.KeyHome, 0, tcell.ModCtrl | tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAltShiftHome, 0, nil}},210 {giveKey{tcell.KeyEnd, 0, tcell.ModCtrl | tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAltShiftEnd, 0, nil}},211 {giveKey{tcell.KeyDelete, 0, tcell.ModCtrl | tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAltShiftDelete, 0, nil}},212 {giveKey{tcell.KeyPgUp, 0, tcell.ModCtrl | tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAltShiftPageUp, 0, nil}},213 {giveKey{tcell.KeyPgDn, 0, tcell.ModCtrl | tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAltShiftPageDown, 0, nil}},214 // section 6: (Ctrl+Alt)+'rune'215 {giveKey{tcell.KeyRune, 'a', tcell.ModNone}, wantKey{Rune, 'a', nil}},216 {giveKey{tcell.KeyRune, 'a', tcell.ModCtrl}, wantKey{Rune, 'a', nil}}, // fabricated217 {giveKey{tcell.KeyRune, 'a', tcell.ModAlt}, wantKey{Alt, 'a', nil}},
53 unmodified lines
271 t.Logf("Resize as Invalid swallowed")272 initialResizeAsInvalid = false273 gotEvent = r.GetChar()274 }275 if gotEvent.Type == Resize {276 t.Logf("Resize swallowed")277 gotEvent = r.GetChar()278 }279 t.Logf("wantEvent = %T{Type: %v, Char: %q (%[3]v)}\n", test.wantKey, test.wantKey.Type, test.wantKey.Char)280 t.Logf("gotEvent = %T{Type: %v, Char: %q (%[3]v)}\n", gotEvent, gotEvent.Type, gotEvent.Char)281282 assert(t, "r.GetChar().Type", gotEvent.Type, test.wantKey.Type)
191 unmodified lines
modified:src/tui/tcell.go+156 added-1 removed
352 unmodified lines
353 ctrl := (mods & tcell.ModCtrl) > 0354 shift := (mods & tcell.ModShift) > 0355 ctrlAlt := ctrl && alt356 altShift := alt && shift357 ctrlShift := ctrl && shift358 ctrlAltShift := ctrl && alt && shift359360 keyfn := func(r rune) Event {361 if alt {362 return CtrlAltKey(r)
18 unmodified lines
381 return keyfn('g')382 case tcell.KeyCtrlH:383 switch ev.Rune() {384 case 0:385 if ctrlAlt {386 return Event{CtrlAltBackspace, 0, nil}387 }388 if ctrl {384 return Event{Backspace, 0, nil}389 return Event{CtrlBackspace, 0, nil}390 }391 case rune(tcell.KeyCtrlH):392 switch {393 case ctrl:
52 unmodified lines
446 case tcell.KeyCtrlUnderscore:447 return Event{CtrlSlash, 0, nil}448 // section 3: (Alt)+Backspace2449 case tcell.KeyBackspace2:450 if ctrl {451 return Event{CtrlBackspace, 0, nil}452 }453 if alt {454 return Event{AltBackspace, 0, nil}455 }456 return Event{Backspace, 0, nil}457458 // section 4: (Alt+Shift)+Key(Up|Down|Left|Right)459 case tcell.KeyUp:460 if ctrlAltShift {461 return Event{CtrlAltShiftUp, 0, nil}462 }463 if ctrlAlt {464 return Event{CtrlAltUp, 0, nil}465 }466 if ctrlShift {467 return Event{CtrlShiftUp, 0, nil}468 }469 if altShift {470 return Event{AltShiftUp, 0, nil}471 }472 if ctrl {473 return Event{CtrlUp, 0, nil}474 }475 if shift {476 return Event{ShiftUp, 0, nil}477 }478 if alt {479 return Event{AltUp, 0, nil}480 }481 return Event{Up, 0, nil}482 case tcell.KeyDown:483 if ctrlAltShift {484 return Event{CtrlAltShiftDown, 0, nil}485 }486 if ctrlAlt {487 return Event{CtrlAltDown, 0, nil}488 }489 if ctrlShift {490 return Event{CtrlShiftDown, 0, nil}491 }492 if altShift {493 return Event{AltShiftDown, 0, nil}494 }495 if ctrl {496 return Event{CtrlDown, 0, nil}497 }498 if shift {499 return Event{ShiftDown, 0, nil}500 }501 if alt {502 return Event{AltDown, 0, nil}503 }504 return Event{Down, 0, nil}505 case tcell.KeyLeft:506 if ctrlAltShift {507 return Event{CtrlAltShiftLeft, 0, nil}508 }509 if ctrlAlt {510 return Event{CtrlAltLeft, 0, nil}511 }512 if ctrlShift {513 return Event{CtrlShiftLeft, 0, nil}514 }515 if altShift {516 return Event{AltShiftLeft, 0, nil}517 }518 if ctrl {519 return Event{CtrlLeft, 0, nil}520 }521 if shift {522 return Event{ShiftLeft, 0, nil}523 }524 if alt {525 return Event{AltLeft, 0, nil}526 }527 return Event{Left, 0, nil}528 case tcell.KeyRight:529 if ctrlAltShift {530 return Event{CtrlAltShiftRight, 0, nil}531 }532 if ctrlAlt {533 return Event{CtrlAltRight, 0, nil}534 }535 if ctrlShift {536 return Event{CtrlShiftRight, 0, nil}537 }538 if altShift {539 return Event{AltShiftRight, 0, nil}540 }541 if ctrl {542 return Event{CtrlRight, 0, nil}543 }544 if shift {545 return Event{ShiftRight, 0, nil}546 }547 if alt {
4 unmodified lines
552 // section 5: (Insert|Home|Delete|End|PgUp|PgDn|BackTab|F1-F12)553 case tcell.KeyInsert:554 return Event{Insert, 0, nil}555 case tcell.KeyHome:556 if ctrlAltShift {557 return Event{CtrlAltShiftHome, 0, nil}558 }559 if ctrlAlt {560 return Event{CtrlAltHome, 0, nil}561 }562 if ctrlShift {563 return Event{CtrlShiftHome, 0, nil}564 }565 if altShift {566 return Event{AltShiftHome, 0, nil}567 }568 if ctrl {569 return Event{CtrlHome, 0, nil}570 }571 if shift {572 return Event{ShiftHome, 0, nil}573 }574 if alt {575 return Event{AltHome, 0, nil}576 }577 return Event{Home, 0, nil}578 case tcell.KeyDelete:579 if ctrlAltShift {580 return Event{CtrlAltShiftDelete, 0, nil}581 }582 if ctrlAlt {583 return Event{CtrlAltDelete, 0, nil}584 }585 if ctrlShift {586 return Event{CtrlShiftDelete, 0, nil}587 }588 if altShift {589 return Event{AltShiftDelete, 0, nil}590 }591 if ctrl {592 return Event{CtrlDelete, 0, nil}593 }594 if alt {595 return Event{AltDelete, 0, nil}596 }597 if shift {598 return Event{ShiftDelete, 0, nil}599 }600 return Event{Delete, 0, nil}601 case tcell.KeyEnd:602 if ctrlAltShift {603 return Event{CtrlAltShiftEnd, 0, nil}604 }605 if ctrlAlt {606 return Event{CtrlAltEnd, 0, nil}607 }608 if ctrlShift {609 return Event{CtrlShiftEnd, 0, nil}610 }611 if altShift {612 return Event{AltShiftEnd, 0, nil}613 }614 if ctrl {615 return Event{CtrlEnd, 0, nil}616 }617 if shift {618 return Event{ShiftEnd, 0, nil}619 }620 if alt {621 return Event{AltEnd, 0, nil}622 }623 return Event{End, 0, nil}624 case tcell.KeyPgUp:625 if ctrlAltShift {626 return Event{CtrlAltShiftPageUp, 0, nil}627 }628 if ctrlAlt {629 return Event{CtrlAltPageUp, 0, nil}630 }631 if ctrlShift {632 return Event{CtrlShiftPageUp, 0, nil}633 }634 if altShift {635 return Event{AltShiftPageUp, 0, nil}636 }637 if ctrl {638 return Event{CtrlPageUp, 0, nil}639 }640 if shift {641 return Event{ShiftPageUp, 0, nil}642 }643 if alt {644 return Event{AltPageUp, 0, nil}645 }646 return Event{PageUp, 0, nil}647 case tcell.KeyPgDn:648 if ctrlAltShift {649 return Event{CtrlAltShiftPageDown, 0, nil}650 }651 if ctrlAlt {652 return Event{CtrlAltPageDown, 0, nil}653 }654 if ctrlShift {655 return Event{CtrlShiftPageDown, 0, nil}656 }657 if altShift {658 return Event{AltShiftPageDown, 0, nil}659 }660 if ctrl {661 return Event{CtrlPageDown, 0, nil}662 }663 if shift {664 return Event{ShiftPageDown, 0, nil}665 }666 if alt {667 return Event{AltPageDown, 0, nil}668 }669 return Event{PageDown, 0, nil}670 case tcell.KeyBacktab:671 return Event{ShiftTab, 0, nil}672 case tcell.KeyF1:
413 unmodified lines
modified:src/tui/tui.go+56 added-1 removed
42 unmodified lines
43 CtrlY44 CtrlZ45 Esc46 CtrlSpace47 CtrlDelete4748 // https://apple.stackexchange.com/questions/24261/how-do-i-send-c-that-is-control-slash-to-the-terminal49 CtrlBackSlash50 CtrlRightBracket
19 unmodified lines
70 ShiftDown71 ShiftLeft72 ShiftRight73 ShiftDelete74 ShiftHome75 ShiftEnd76 ShiftPageUp77 ShiftPageDown7879 F180 F281 F3
12 unmodified lines
94 AltUp95 AltDown96 AltLeft97 AltRight98 AltDelete99 AltHome100 AltEnd101 AltPageUp102 AltPageDown103104 AltShiftUp105 AltShiftDown106 AltShiftLeft107 AltShiftRight108 AltShiftDelete109 AltShiftHome110 AltShiftEnd111 AltShiftPageUp112 AltShiftPageDown113114 CtrlUp115 CtrlDown116 CtrlLeft117 CtrlRight118 CtrlHome119 CtrlEnd120 CtrlBackspace121 CtrlDelete122 CtrlPageUp123 CtrlPageDown124125 Alt126 CtrlAlt127128 CtrlAltUp129 CtrlAltDown130 CtrlAltLeft131 CtrlAltRight132 CtrlAltHome133 CtrlAltEnd134 CtrlAltBackspace135 CtrlAltDelete136 CtrlAltPageUp137 CtrlAltPageDown138139 CtrlShiftUp140 CtrlShiftDown141 CtrlShiftLeft142 CtrlShiftRight143 CtrlShiftHome144 CtrlShiftEnd145 CtrlShiftDelete146 CtrlShiftPageUp147 CtrlShiftPageDown148149 CtrlAltShiftUp150 CtrlAltShiftDown151 CtrlAltShiftLeft152 CtrlAltShiftRight153 CtrlAltShiftHome154 CtrlAltShiftEnd155 CtrlAltShiftDelete156 CtrlAltShiftPageUp157 CtrlAltShiftPageDown158159 Invalid160 Fatal161 BracketedPasteBegin162 BracketedPasteEnd
1046 unmodified lines
modified:src/options.go+104 added-2 removed
972 unmodified lines
973 case "backspace", "bspace", "bs":974 add(tui.Backspace)975 case "ctrl-space":976 add(tui.CtrlSpace)977 case "ctrl-delete":978 add(tui.CtrlDelete)977 case "ctrl-^", "ctrl-6":978 add(tui.CtrlCaret)979 case "ctrl-/", "ctrl-_":980 add(tui.CtrlSlash)
38 unmodified lines
1019 chords[evt] = key1020 list = append(list, evt)1021 case "alt-bs", "alt-bspace", "alt-backspace":1022 add(tui.AltBackspace)1023 case "ctrl-bs", "ctrl-bspace", "ctrl-backspace":1024 add(tui.CtrlBackspace)1025 case "ctrl-alt-bs", "ctrl-alt-bspace", "ctrl-alt-backspace":1026 add(tui.CtrlAltBackspace)1027 case "alt-up":1028 add(tui.AltUp)1029 case "alt-down":1030 add(tui.AltDown)1031 case "alt-left":1032 add(tui.AltLeft)1033 case "alt-right":1034 add(tui.AltRight)1035 case "alt-home":1036 add(tui.AltHome)1037 case "alt-end":1038 add(tui.AltEnd)1039 case "alt-delete":1040 add(tui.AltDelete)1041 case "alt-page-up":1042 add(tui.AltPageUp)1043 case "alt-page-down":1044 add(tui.AltPageDown)1045 case "tab":1046 add(tui.Tab)1047 case "btab", "shift-tab":1048 add(tui.ShiftTab)
18 unmodified lines
1067 case "alt-shift-left", "shift-alt-left":1068 add(tui.AltShiftLeft)1069 case "alt-shift-right", "shift-alt-right":1070 add(tui.AltShiftRight)1071 case "alt-shift-home", "shift-alt-home":1072 add(tui.AltShiftHome)1073 case "alt-shift-end", "shift-alt-end":1074 add(tui.AltShiftEnd)1075 case "alt-shift-delete", "shift-alt-delete":1076 add(tui.AltShiftDelete)1077 case "alt-shift-page-up", "shift-alt-page-up":1078 add(tui.AltShiftPageUp)1079 case "alt-shift-page-down", "shift-alt-page-down":1080 add(tui.AltShiftPageDown)1081 case "ctrl-up":1082 add(tui.CtrlUp)1083 case "ctrl-down":1084 add(tui.CtrlDown)1085 case "ctrl-right":1086 add(tui.CtrlRight)1087 case "ctrl-left":1088 add(tui.CtrlLeft)1089 case "ctrl-home":1090 add(tui.CtrlHome)1091 case "ctrl-end":1092 add(tui.CtrlEnd)1093 case "ctrl-delete":1094 add(tui.CtrlDelete)1095 case "ctrl-page-up":1096 add(tui.CtrlPageUp)1097 case "ctrl-page-down":1098 add(tui.CtrlPageDown)1099 case "ctrl-alt-up", "alt-ctrl-up":1100 add(tui.CtrlAltUp)1101 case "ctrl-alt-down", "alt-ctrl-down":1102 add(tui.CtrlAltDown)1103 case "ctrl-alt-right", "alt-ctrl-right":1104 add(tui.CtrlAltRight)1105 case "ctrl-alt-left", "alt-ctrl-left":1106 add(tui.CtrlAltLeft)1107 case "ctrl-alt-home", "alt-ctrl-home":1108 add(tui.CtrlAltHome)1109 case "ctrl-alt-end", "alt-ctrl-end":1110 add(tui.CtrlAltEnd)1111 case "ctrl-alt-delete", "alt-ctrl-delete":1112 add(tui.CtrlAltDelete)1113 case "ctrl-alt-page-up", "alt-ctrl-page-up":1114 add(tui.CtrlAltPageUp)1115 case "ctrl-alt-page-down", "alt-ctrl-page-down":1116 add(tui.CtrlAltPageDown)1117 case "ctrl-shift-up", "shift-ctrl-up":1118 add(tui.CtrlShiftUp)1119 case "ctrl-shift-down", "shift-ctrl-down":1120 add(tui.CtrlShiftDown)1121 case "ctrl-shift-right", "shift-ctrl-right":1122 add(tui.CtrlShiftRight)1123 case "ctrl-shift-left", "shift-ctrl-left":1124 add(tui.CtrlShiftLeft)1125 case "ctrl-shift-home", "shift-ctrl-home":1126 add(tui.CtrlShiftHome)1127 case "ctrl-shift-end", "shift-ctrl-end":1128 add(tui.CtrlShiftEnd)1129 case "ctrl-shift-delete", "shift-ctrl-delete":1130 add(tui.CtrlShiftDelete)1131 case "ctrl-shift-page-up", "shift-ctrl-page-up":1132 add(tui.CtrlShiftPageUp)1133 case "ctrl-shift-page-down", "shift-ctrl-page-down":1134 add(tui.CtrlShiftPageDown)1135 case "ctrl-alt-shift-up":1136 add(tui.CtrlAltShiftUp)1137 case "ctrl-alt-shift-down":1138 add(tui.CtrlAltShiftDown)1139 case "ctrl-alt-shift-right":1140 add(tui.CtrlAltShiftRight)1141 case "ctrl-alt-shift-left":1142 add(tui.CtrlAltShiftLeft)1143 case "ctrl-alt-shift-home":1144 add(tui.CtrlAltShiftHome)1145 case "ctrl-alt-shift-end":1146 add(tui.CtrlAltShiftEnd)1147 case "ctrl-alt-shift-delete":1148 add(tui.CtrlAltShiftDelete)1149 case "ctrl-alt-shift-page-up":1150 add(tui.CtrlAltShiftPageUp)1151 case "ctrl-alt-shift-page-down":1152 add(tui.CtrlAltShiftPageDown)1153 case "shift-up":1154 add(tui.ShiftUp)1155 case "shift-down":1156 add(tui.ShiftDown)1157 case "shift-left":1158 add(tui.ShiftLeft)1159 case "shift-right":1160 add(tui.ShiftRight)1161 case "shift-home":1162 add(tui.ShiftHome)1163 case "shift-end":1164 add(tui.ShiftEnd)1165 case "shift-delete":1166 add(tui.ShiftDelete)1167 case "shift-page-up":1168 add(tui.ShiftPageUp)1169 case "shift-page-down":1170 add(tui.ShiftPageDown)1171 case "left-click":1172 add(tui.LeftClick)1173 case "right-click":1174 add(tui.RightClick)
2558 unmodified lines
modified:src/terminal.go+1 added
780 unmodified lines
781 add(tui.CtrlE, actEndOfLine)782 add(tui.CtrlF, actForwardChar)783 add(tui.CtrlH, actBackwardDeleteChar)784 add(tui.Backspace, actBackwardDeleteChar)785 add(tui.CtrlBackspace, actBackwardDeleteChar)786 add(tui.Tab, actToggleDown)787 add(tui.ShiftTab, actToggleUp)788 add(tui.CtrlJ, actDown)789 add(tui.CtrlK, actUp)
6225 unmodified lines