Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@ keybinding.Parse("ctrl+c")
// get a list of keybindings
keybinding.ParseAll("ctrl+A, ctrl+B, CTRL+ALT+C")
```

# TODO

* [ ] improve error messages, for example parsing invalid string `ctl + A`
```
-unsupported keybinding: KeyCtlA
+error parsing `ctl + A`: KeyCtlA is not defined
```

* [ ] uppercase single letter shortcuts are different from lowercase

* [ ] do case insensitive detection for special key names
3 changes: 1 addition & 2 deletions keybinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ var translate = map[string]string{
"~": "Tilde",
"pageup": "Pgup",
"pagedown": "Pgdn",
"pgup": "Pgup",
"pgdown": "Pgdn",
"up": "ArrowUp",
"down": "ArrowDown",
"right": "ArrowRight",
"left": "ArrowLeft",
"ctl": "Ctrl",
}

var display = map[string]string{
Expand Down Expand Up @@ -116,6 +114,7 @@ var supportedKeybindings = map[string]gocui.Key{

// Key contains all relevant information about the key
type Key struct {
// Value is either `rune` for single key or `gocui.Key`
Value interface{}
Modifier gocui.Modifier
Tokens []string
Expand Down
5 changes: 3 additions & 2 deletions keybinding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func TestParse(t *testing.T) {
}{
{"ctrl + A", gocui.KeyCtrlA, gocui.ModNone, ""},
{"Ctrl + a", gocui.KeyCtrlA, gocui.ModNone, ""},
{"Ctl + a", gocui.KeyCtrlA, gocui.ModNone, ""},
{"ctl + A", gocui.KeyCtrlA, gocui.ModNone, ""},
{"Ctl + a", 0, gocui.ModNone, "unsupported keybinding: KeyCtlA"},
{"ctl + A", 0, gocui.ModNone, "unsupported keybinding: KeyCtlA"},
{"f2", gocui.KeyF2, gocui.ModNone, ""},
{"ctrl + [", gocui.KeyCtrlLsqBracket, gocui.ModNone, ""},
{" ctrl + ] ", gocui.KeyCtrlRsqBracket, gocui.ModNone, ""},
Expand All @@ -36,6 +36,7 @@ func TestParse(t *testing.T) {
{"ctrl + alt + !", 0, gocui.ModAlt, "unsupported keybinding: KeyCtrl! (+1)"},
{"q", rune('q'), gocui.ModNone, ""},
{" q", rune('q'), gocui.ModNone, ""},
{" Q", rune('q'), gocui.ModNone, ""},
}

for idx, trial := range table {
Expand Down