Fix Backspace key to emit BSpace and AltBS events instead of CtrlH
Before adoption: this commit came in with the history the project adopted, so no landing records it.
CtrlH events are still sent when appropriate. I have adjusted FullscreenRenderer to match the LightRenderer's behaviour, which seems to be correct.
authored by Vlastimil Ovčáčík · committed by Junegunn Choi · parent 09700f6 · Browse files · 2 files·+26 added−10 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+26 added−10 removed
- other:+26 added−10 removed
Provenance
- Commit
ca43f95- Tree
f2033f7- Author
Vlastimil Ovčáčík <vovcacik@github.ovcacik.org>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
09700f6
2 files changed+26 added−10 removed
modified:src/tui/tcell_test.go+10 added-9 removed
105 unmodified lines106 {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}},110- {giveKey{tcell.KeyBackspace, 0, tcell.ModNone}, wantKey{CtrlH, 0, nil}}, // fabricated, unhandled111- {giveKey{tcell.KeyBS, 0, tcell.ModNone}, wantKey{CtrlH, 0, nil}}, // fabricated, unhandled112- {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModNone}, wantKey{CtrlH, 0, nil}}, // actual "Backspace" keystroke113- {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModAlt}, wantKey{CtrlAlt, 'h', nil}}, // actual "Alt+Backspace" keystroke110+ {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" keystroke115- {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModShift}, wantKey{CtrlH, 0, nil}}, // actual "Shift+Backspace" keystroke116- {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt}, wantKey{CtrlAlt, 'h', nil}}, // actual "Ctrl+Alt+Backspace" keystroke117- {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModShift}, wantKey{CtrlH, 0, nil}}, // actual "Ctrl+Shift+Backspace" keystroke118- {giveKey{tcell.KeyCtrlH, rune(tcell.KeyCtrlH), tcell.ModShift | tcell.ModAlt}, wantKey{CtrlAlt, 'h', nil}}, // actual "Shift+Alt+Backspace" keystroke119- {giveKey{tcell.KeyCtrlH, 0, tcell.ModCtrl | tcell.ModAlt | tcell.ModShift}, wantKey{CtrlAlt, 'h', nil}}, // actual "Ctrl+Shift+Alt+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" 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" keystroke268 unmodified linesmodified:src/tui/tcell.go+16 added-1 removed
221 unmodified lines222 223 // process keyboard:224 case *tcell.EventKey:225 mods := ev.Modifiers()226+ none := mods == tcell.ModNone227 alt := (mods & tcell.ModAlt) > 0228 ctrl := (mods & tcell.ModCtrl) > 0229 shift := (mods & tcell.ModShift) > 0230 ctrlAlt := ctrl && alt21 unmodified lines252 return keyfn('f')253 case tcell.KeyCtrlG:254 return keyfn('g')255 case tcell.KeyCtrlH:256+ switch ev.Rune() {257+ case 0:258+ if ctrl {259+ return Event{BSpace, 0, nil}260+ }261+ case rune(tcell.KeyCtrlH):262+ switch {263+ case ctrl:255- return keyfn('h')264+ return keyfn('h')265+ case alt:266+ return Event{AltBS, 0, nil}267+ case none, shift:268+ return Event{BSpace, 0, nil}269+ }270+ }271 case tcell.KeyCtrlI:272 return keyfn('i')273 case tcell.KeyCtrlJ:274 return keyfn('j')410 unmodified lines