bindings: support more modified keys
Add new supported keys: Ctrl+Enter Ctrl+Up Ctrl+Down Ctrl+Left Ctrl+Right Ctrl+PageUp Ctrl+PageDown Signed-off-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
7a6c808c04
commit
1a75906bcb
|
@ -161,17 +161,24 @@ func init() {
|
||||||
keyNames["space"] = KeyStroke{tcell.ModNone, tcell.KeyRune, ' '}
|
keyNames["space"] = KeyStroke{tcell.ModNone, tcell.KeyRune, ' '}
|
||||||
keyNames["semicolon"] = KeyStroke{tcell.ModNone, tcell.KeyRune, ';'}
|
keyNames["semicolon"] = KeyStroke{tcell.ModNone, tcell.KeyRune, ';'}
|
||||||
keyNames["enter"] = KeyStroke{tcell.ModNone, tcell.KeyEnter, 0}
|
keyNames["enter"] = KeyStroke{tcell.ModNone, tcell.KeyEnter, 0}
|
||||||
|
keyNames["c-enter"] = KeyStroke{tcell.ModCtrl, tcell.KeyEnter, 0}
|
||||||
keyNames["up"] = KeyStroke{tcell.ModNone, tcell.KeyUp, 0}
|
keyNames["up"] = KeyStroke{tcell.ModNone, tcell.KeyUp, 0}
|
||||||
|
keyNames["c-up"] = KeyStroke{tcell.ModCtrl, tcell.KeyUp, 0}
|
||||||
keyNames["down"] = KeyStroke{tcell.ModNone, tcell.KeyDown, 0}
|
keyNames["down"] = KeyStroke{tcell.ModNone, tcell.KeyDown, 0}
|
||||||
|
keyNames["c-down"] = KeyStroke{tcell.ModCtrl, tcell.KeyDown, 0}
|
||||||
keyNames["right"] = KeyStroke{tcell.ModNone, tcell.KeyRight, 0}
|
keyNames["right"] = KeyStroke{tcell.ModNone, tcell.KeyRight, 0}
|
||||||
|
keyNames["c-right"] = KeyStroke{tcell.ModCtrl, tcell.KeyRight, 0}
|
||||||
keyNames["left"] = KeyStroke{tcell.ModNone, tcell.KeyLeft, 0}
|
keyNames["left"] = KeyStroke{tcell.ModNone, tcell.KeyLeft, 0}
|
||||||
|
keyNames["c-left"] = KeyStroke{tcell.ModCtrl, tcell.KeyLeft, 0}
|
||||||
keyNames["upleft"] = KeyStroke{tcell.ModNone, tcell.KeyUpLeft, 0}
|
keyNames["upleft"] = KeyStroke{tcell.ModNone, tcell.KeyUpLeft, 0}
|
||||||
keyNames["upright"] = KeyStroke{tcell.ModNone, tcell.KeyUpRight, 0}
|
keyNames["upright"] = KeyStroke{tcell.ModNone, tcell.KeyUpRight, 0}
|
||||||
keyNames["downleft"] = KeyStroke{tcell.ModNone, tcell.KeyDownLeft, 0}
|
keyNames["downleft"] = KeyStroke{tcell.ModNone, tcell.KeyDownLeft, 0}
|
||||||
keyNames["downright"] = KeyStroke{tcell.ModNone, tcell.KeyDownRight, 0}
|
keyNames["downright"] = KeyStroke{tcell.ModNone, tcell.KeyDownRight, 0}
|
||||||
keyNames["center"] = KeyStroke{tcell.ModNone, tcell.KeyCenter, 0}
|
keyNames["center"] = KeyStroke{tcell.ModNone, tcell.KeyCenter, 0}
|
||||||
keyNames["pgup"] = KeyStroke{tcell.ModNone, tcell.KeyPgUp, 0}
|
keyNames["pgup"] = KeyStroke{tcell.ModNone, tcell.KeyPgUp, 0}
|
||||||
|
keyNames["c-pgup"] = KeyStroke{tcell.ModCtrl, tcell.KeyPgUp, 0}
|
||||||
keyNames["pgdn"] = KeyStroke{tcell.ModNone, tcell.KeyPgDn, 0}
|
keyNames["pgdn"] = KeyStroke{tcell.ModNone, tcell.KeyPgDn, 0}
|
||||||
|
keyNames["c-pgdn"] = KeyStroke{tcell.ModCtrl, tcell.KeyPgDn, 0}
|
||||||
keyNames["home"] = KeyStroke{tcell.ModNone, tcell.KeyHome, 0}
|
keyNames["home"] = KeyStroke{tcell.ModNone, tcell.KeyHome, 0}
|
||||||
keyNames["end"] = KeyStroke{tcell.ModNone, tcell.KeyEnd, 0}
|
keyNames["end"] = KeyStroke{tcell.ModNone, tcell.KeyEnd, 0}
|
||||||
keyNames["insert"] = KeyStroke{tcell.ModNone, tcell.KeyInsert, 0}
|
keyNames["insert"] = KeyStroke{tcell.ModNone, tcell.KeyInsert, 0}
|
||||||
|
|
|
@ -55,7 +55,22 @@ func TestGetBinding(t *testing.T) {
|
||||||
}, BINDING_NOT_FOUND, "")
|
}, BINDING_NOT_FOUND, "")
|
||||||
|
|
||||||
add("<C-a>", "c-a")
|
add("<C-a>", "c-a")
|
||||||
|
add("<C-Down>", ":next")
|
||||||
|
add("<C-PgUp>", ":prev")
|
||||||
|
add("<C-Enter>", ":open")
|
||||||
test([]KeyStroke{
|
test([]KeyStroke{
|
||||||
{tcell.ModCtrl, tcell.KeyCtrlA, 0},
|
{tcell.ModCtrl, tcell.KeyCtrlA, 0},
|
||||||
}, BINDING_FOUND, "c-a")
|
}, BINDING_FOUND, "c-a")
|
||||||
|
test([]KeyStroke{
|
||||||
|
{tcell.ModCtrl, tcell.KeyDown, 0},
|
||||||
|
}, BINDING_FOUND, ":next")
|
||||||
|
test([]KeyStroke{
|
||||||
|
{tcell.ModCtrl, tcell.KeyPgUp, 0},
|
||||||
|
}, BINDING_FOUND, ":prev")
|
||||||
|
test([]KeyStroke{
|
||||||
|
{tcell.ModCtrl, tcell.KeyPgDn, 0},
|
||||||
|
}, BINDING_NOT_FOUND, "")
|
||||||
|
test([]KeyStroke{
|
||||||
|
{tcell.ModCtrl, tcell.KeyEnter, 0},
|
||||||
|
}, BINDING_FOUND, ":open")
|
||||||
}
|
}
|
||||||
|
|
|
@ -522,20 +522,34 @@ following special keys are supported:
|
||||||
: ;
|
: ;
|
||||||
| tab
|
| tab
|
||||||
:
|
:
|
||||||
|
| s-tab
|
||||||
|
: Shift+Tab
|
||||||
| enter
|
| enter
|
||||||
:
|
:
|
||||||
| up
|
| up
|
||||||
:
|
:
|
||||||
|
| c-up
|
||||||
|
: Ctrl+Up
|
||||||
| down
|
| down
|
||||||
:
|
:
|
||||||
|
| c-down
|
||||||
|
: Ctrl+Down
|
||||||
| right
|
| right
|
||||||
:
|
:
|
||||||
|
| c-right
|
||||||
|
: Ctrl+Right
|
||||||
| left
|
| left
|
||||||
:
|
:
|
||||||
|
| c-left
|
||||||
|
: Ctrl+Left
|
||||||
| pgup
|
| pgup
|
||||||
:
|
:
|
||||||
|
| c-pgup
|
||||||
|
: Ctrl+PageUp
|
||||||
| pgdn
|
| pgdn
|
||||||
:
|
:
|
||||||
|
| c-pgdn
|
||||||
|
: Ctrl+PageUp
|
||||||
| home
|
| home
|
||||||
:
|
:
|
||||||
| end
|
| end
|
||||||
|
|
Loading…
Reference in New Issue