Fix tcell build
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent 1a9c282 · Browse files · 2 files·+44 added−44 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+44 added−44 removed
- other:+44 added−44 removed
Provenance
- Commit
892d1ac- Tree
ca08aa6- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
1a9c282
2 files changed+44 added−44 removed
modified:src/tui/tcell_test.go+25 added-25 removed
100 unmodified lines101 // section 3: (Alt)+Backspace2102 // KeyBackspace2 is alias for KeyDEL = 0x7F (ASCII) (allegedly unused by Windows)103 // KeyDelete = 0x2E (VK_DELETE constant in Windows)104 // KeyBackspace is alias for KeyBS = 0x08 (ASCII) (implicit alias with KeyCtrlH)105- {giveKey{tcell.KeyBackspace2, 0, tcell.ModNone}, wantKey{BSpace, 0, nil}}, // fabricated106- {giveKey{tcell.KeyBackspace2, 0, tcell.ModAlt}, wantKey{AltBS, 0, nil}}, // fabricated107- {giveKey{tcell.KeyDEL, 0, tcell.ModNone}, wantKey{BSpace, 0, nil}}, // fabricated, unhandled108- {giveKey{tcell.KeyDelete, 0, tcell.ModNone}, wantKey{Del, 0, nil}},109- {giveKey{tcell.KeyDelete, 0, tcell.ModAlt}, wantKey{Del, 0, nil}},105+ {giveKey{tcell.KeyBackspace2, 0, tcell.ModNone}, wantKey{Backspace, 0, nil}}, // fabricated106+ {giveKey{tcell.KeyBackspace2, 0, tcell.ModAlt}, wantKey{AltBackspace, 0, nil}}, // fabricated107+ {giveKey{tcell.KeyDEL, 0, tcell.ModNone}, wantKey{Backspace, 0, nil}}, // fabricated, unhandled108+ {giveKey{tcell.KeyDelete, 0, tcell.ModNone}, wantKey{Delete, 0, nil}},109+ {giveKey{tcell.KeyDelete, 0, tcell.ModAlt}, wantKey{Delete, 0, nil}},110 {giveKey{tcell.KeyBackspace, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled111 {giveKey{tcell.KeyBS, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled112 {giveKey{tcell.KeyCtrlH, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled113- {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModNone}, wantKey{BSpace, 0, nil}}, // actual "Backspace" keystroke114- {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModAlt}, wantKey{AltBS, 0, nil}}, // actual "Alt+Backspace" keystroke115- {giveKey{tcell.KeyDEL, rune(tcell.KeyDEL), tcell.ModCtrl}, wantKey{BSpace, 0, nil}}, // actual "Ctrl+Backspace" keystroke116- {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModShift}, wantKey{BSpace, 0, nil}}, // actual "Shift+Backspace" keystroke117- {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{BSpace, 0, nil}}, // actual "Ctrl+Alt+Backspace" keystroke118- {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{BSpace, 0, nil}}, // actual "Ctrl+Shift+Backspace" keystroke119- {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModShift | tcell.ModAlt}, wantKey{AltBS, 0, nil}}, // actual "Shift+Alt+Backspace" keystroke120- {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt | tcell.ModShift}, wantKey{BSpace, 0, nil}}, // actual "Ctrl+Shift+Alt+Backspace" keystroke113+ {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModNone}, wantKey{Backspace, 0, nil}}, // actual "Backspace" keystroke114+ {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModAlt}, wantKey{AltBackspace, 0, nil}}, // actual "Alt+Backspace" keystroke115+ {giveKey{tcell.KeyDEL, rune(tcell.KeyDEL), tcell.ModCtrl}, wantKey{Backspace, 0, nil}}, // actual "Ctrl+Backspace" keystroke116+ {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModShift}, wantKey{Backspace, 0, nil}}, // actual "Shift+Backspace" keystroke117+ {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{Backspace, 0, nil}}, // actual "Ctrl+Alt+Backspace" keystroke118+ {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{Backspace, 0, nil}}, // actual "Ctrl+Shift+Backspace" keystroke119+ {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModShift | tcell.ModAlt}, wantKey{AltBackspace, 0, nil}}, // actual "Shift+Alt+Backspace" keystroke120+ {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt | tcell.ModShift}, wantKey{Backspace, 0, nil}}, // actual "Ctrl+Shift+Alt+Backspace" keystroke121 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModCtrl}, wantKey{CtrlH, 0, nil}}, // actual "Ctrl+H" keystroke122 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAlt, 'h', nil}}, // fabricated "Ctrl+Alt+H" keystroke123 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlH, 0, nil}}, // actual "Ctrl+Shift+H" keystroke124 {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModCtrl | tcell.ModAlt | tcell.ModShift}, wantKey{CtrlAlt, 'h', nil}}, // fabricated "Ctrl+Shift+Alt+H" keystroke125 126 // section 4: (Alt+Shift)+Key(Up|Down|Left|Right)127 {giveKey{tcell.KeyUp, 0, tcell.ModNone}, wantKey{Up, 0, nil}},128 {giveKey{tcell.KeyDown, 0, tcell.ModAlt}, wantKey{AltDown, 0, nil}},129- {giveKey{tcell.KeyLeft, 0, tcell.ModShift}, wantKey{SLeft, 0, nil}},130- {giveKey{tcell.KeyRight, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltSRight, 0, nil}},129+ {giveKey{tcell.KeyLeft, 0, tcell.ModShift}, wantKey{ShiftLeft, 0, nil}},130+ {giveKey{tcell.KeyRight, 0, tcell.ModShift | tcell.ModAlt}, wantKey{AltShiftRight, 0, nil}},131 {giveKey{tcell.KeyUpLeft, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled132 {giveKey{tcell.KeyUpRight, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled133 {giveKey{tcell.KeyDownLeft, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled134 {giveKey{tcell.KeyDownRight, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}}, // fabricated, unhandled25 unmodified lines160 {giveKey{tcell.KeyRune, 'µ', tcell.ModCtrl | tcell.ModAlt}, wantKey{Rune, 'µ', nil}}, // DE: Ctrl+Alt+m = "µ"161 162 // section 7: Esc163 // KeyEsc and KeyEscape are aliases for KeyESC164- {giveKey{tcell.KeyEsc, rune(tcell.KeyEsc), tcell.ModNone}, wantKey{ESC, 0, nil}}, // fabricated165- {giveKey{tcell.KeyESC, rune(tcell.KeyESC), tcell.ModNone}, wantKey{ESC, 0, nil}}, // unhandled166- {giveKey{tcell.KeyEscape, rune(tcell.KeyEscape), tcell.ModNone}, wantKey{ESC, 0, nil}}, // fabricated, unhandled167- {giveKey{tcell.KeyESC, rune(tcell.KeyESC), tcell.ModCtrl}, wantKey{ESC, 0, nil}}, // actual Ctrl+[ keystroke168- {giveKey{tcell.KeyCtrlLeftSq, rune(tcell.KeyCtrlLeftSq), tcell.ModCtrl}, wantKey{ESC, 0, nil}}, // fabricated, unhandled164+ {giveKey{tcell.KeyEsc, rune(tcell.KeyEsc), tcell.ModNone}, wantKey{Esc, 0, nil}}, // fabricated165+ {giveKey{tcell.KeyESC, rune(tcell.KeyESC), tcell.ModNone}, wantKey{Esc, 0, nil}}, // unhandled166+ {giveKey{tcell.KeyEscape, rune(tcell.KeyEscape), tcell.ModNone}, wantKey{Esc, 0, nil}}, // fabricated, unhandled167+ {giveKey{tcell.KeyESC, rune(tcell.KeyESC), tcell.ModCtrl}, wantKey{Esc, 0, nil}}, // actual Ctrl+[ keystroke168+ {giveKey{tcell.KeyCtrlLeftSq, rune(tcell.KeyCtrlLeftSq), tcell.ModCtrl}, wantKey{Esc, 0, nil}}, // fabricated, unhandled169 170 // section 8: Invalid171 {giveKey{tcell.KeyRune, 'a', tcell.ModMeta}, wantKey{Rune, 'a', nil}}, // fabricated172 {giveKey{tcell.KeyF24, 0, tcell.ModNone}, wantKey{Invalid, 0, nil}},85 unmodified lines258 36 DoubleClick259 37 LeftClick260 38 RightClick261 39 BTab262-40 BSpace262+40 Backspace263 41 Del264 42 PgUp265 43 PgDn266 44 Up4 unmodified lines271 49 End272 50 Insert273 51 SUp274 52 SDown275-53 SLeft275+53 ShiftLeft276 54 SRight277 55 F1278 56 F2279 57 F37 unmodified lines287 65 F11288 66 F12289 67 Change290 68 BackwardEOF291-69 AltBS291+69 AltBackspace292 70 AltUp293 71 AltDown294 72 AltLeft295 73 AltRight296 74 AltSUp297 75 AltSDown298-76 AltSLeft299-77 AltSRight298+76 AltShiftLeft299+77 AltShiftRight300 78 Alt301 79 CtrlAlt302 ..303 127 3 KeyDEL KeyBackspace291 unmodified linesmodified:src/tui/tcell.go+19 added-19 removed
318 unmodified lines319 case tcell.KeyCtrlH:320 switch ev.Rune() {321 case 0:322 if ctrl {323- return Event{BSpace, 0, nil}323+ return Event{Backspace, 0, nil}324 }325 case rune(tcell.KeyCtrlH):326 switch {327 case ctrl:328 return keyfn('h')329 case alt:330- return Event{AltBS, 0, nil}330+ return Event{AltBackspace, 0, nil}331 case none, shift:332- return Event{BSpace, 0, nil}332+ return Event{Backspace, 0, nil}333 }334 }335 case tcell.KeyCtrlI:336 return keyfn('i')44 unmodified lines381 return Event{CtrlSlash, 0, nil}382 // section 3: (Alt)+Backspace2383 case tcell.KeyBackspace2:384 if alt {385- return Event{AltBS, 0, nil}385+ return Event{AltBackspace, 0, nil}386 }387- return Event{BSpace, 0, nil}387+ return Event{Backspace, 0, nil}388 389 // section 4: (Alt+Shift)+Key(Up|Down|Left|Right)390 case tcell.KeyUp:391 if altShift {392- return Event{AltSUp, 0, nil}392+ return Event{AltShiftUp, 0, nil}393 }394 if shift {395- return Event{SUp, 0, nil}395+ return Event{ShiftUp, 0, nil}396 }397 if alt {398 return Event{AltUp, 0, nil}399 }400 return Event{Up, 0, nil}401 case tcell.KeyDown:402 if altShift {403- return Event{AltSDown, 0, nil}403+ return Event{AltShiftDown, 0, nil}404 }405 if shift {406- return Event{SDown, 0, nil}406+ return Event{ShiftDown, 0, nil}407 }408 if alt {409 return Event{AltDown, 0, nil}410 }411 return Event{Down, 0, nil}412 case tcell.KeyLeft:413 if altShift {414- return Event{AltSLeft, 0, nil}414+ return Event{AltShiftLeft, 0, nil}415 }416 if shift {417- return Event{SLeft, 0, nil}417+ return Event{ShiftLeft, 0, nil}418 }419 if alt {420 return Event{AltLeft, 0, nil}421 }422 return Event{Left, 0, nil}423 case tcell.KeyRight:424 if altShift {425- return Event{AltSRight, 0, nil}425+ return Event{AltShiftRight, 0, nil}426 }427 if shift {428- return Event{SRight, 0, nil}428+ return Event{ShiftRight, 0, nil}429 }430 if alt {431 return Event{AltRight, 0, nil}432 }8 unmodified lines441 if ctrl {442 return Event{CtrlDelete, 0, nil}443 }444 if shift {445- return Event{SDelete, 0, nil}445+ return Event{ShiftDelete, 0, nil}446 }447- return Event{Del, 0, nil}447+ return Event{Delete, 0, nil}448 case tcell.KeyEnd:449 return Event{End, 0, nil}450 case tcell.KeyPgUp:451- return Event{PgUp, 0, nil}451+ return Event{PageUp, 0, nil}452 case tcell.KeyPgDn:453- return Event{PgDn, 0, nil}453+ return Event{PageDown, 0, nil}454 case tcell.KeyBacktab:455- return Event{BTab, 0, nil}455+ return Event{ShiftTab, 0, nil}456 case tcell.KeyF1:457 return Event{F1, 0, nil}458 case tcell.KeyF2:459 return Event{F2, 0, nil}37 unmodified lines497 }498 499 // section 7: Esc500 case tcell.KeyEsc:501- return Event{ESC, 0, nil}501+ return Event{Esc, 0, nil}502 }503 }504 505 // section 8: Invalid294 unmodified lines