Skip to content
Myr

Allow alt-enter and alt-space for --bind (#571)

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 66f86e1 · Browse files · 3 files+15 added−3 removed
This commit

State

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

Diff stats

3 files+15 added−3 removed

  • other:+15 added−3 removed

3 files+15 added−3 removed

modified:src/curses/curses.go+6 added
79 unmodified lines
80 F281 F382 F48384 AltEnter85 AltSpace86 AltBS87 AltA88 AltB89 AltC
328 unmodified lines
418 return Event{ESC, 0, nil}419 }420 *sz = 2421 switch _buf[1] {422 case 13:423 return Event{AltEnter, 0, nil}424 case 32:425 return Event{AltSpace, 0, nil}426 case 98:427 return Event{AltB, 0, nil}428 case 100:429 return Event{AltD, 0, nil}
171 unmodified lines
modified:src/options_test.go+5 added-3 removed
121 unmodified lines
122 }123}124125func TestParseKeys(t *testing.T) {126 pairs := parseKeyChords("ctrl-z,alt-z,f2,@,Alt-a,!,ctrl-G,J,g", "")126 pairs := parseKeyChords("ctrl-z,alt-z,f2,@,Alt-a,!,ctrl-G,J,g,ALT-enter,alt-SPACE", "")127 check := func(i int, s string) {128 if pairs[i] != s {129 t.Errorf("%s != %s", pairs[i], s)130 }131 }132 if len(pairs) != 9 {133 t.Error(9)132 if len(pairs) != 11 {133 t.Error(11)134 }135 check(curses.CtrlZ, "ctrl-z")136 check(curses.AltZ, "alt-z")137 check(curses.F2, "f2")
2 unmodified lines
140 check(curses.AltZ+'!', "!")141 check(curses.CtrlA+'g'-'a', "ctrl-G")142 check(curses.AltZ+'J', "J")143 check(curses.AltZ+'g', "g")144 check(curses.AltEnter, "ALT-enter")145 check(curses.AltSpace, "alt-SPACE")146147 // Synonyms148 pairs = parseKeyChords("enter,Return,space,tab,btab,esc,up,down,left,right", "")149 if len(pairs) != 9 {
228 unmodified lines
modified:src/options.go+4 added
313 unmodified lines
314 case "space":315 chord = curses.AltZ + int(' ')316 case "bspace", "bs":317 chord = curses.BSpace318 case "alt-enter", "alt-return":319 chord = curses.AltEnter320 case "alt-space":321 chord = curses.AltSpace322 case "alt-bs", "alt-bspace":323 chord = curses.AltBS324 case "tab":325 chord = curses.Tab
634 unmodified lines