From 5b407e2b0761bdba4723c158f8778d58b20ce1ce Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Fri, 7 May 2021 22:43:11 +0300 Subject: [PATCH 1/5] Add CI --- .github/workflows/go.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..a4021c0 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,25 @@ +name: Go + +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 ./... From a25275d17b1aa390da827489ec43796857ae97fb Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Thu, 2 Sep 2021 11:18:07 +0300 Subject: [PATCH 2/5] Repeat the build --- .github/workflows/go.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a4021c0..0cafecb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,5 +1,3 @@ -name: Go - on: push: branches: [ master ] From db2b343f6adc5570ddbd661b751d9b1965d4344d Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Mon, 11 Oct 2021 13:26:52 +0300 Subject: [PATCH 3/5] Fix two tests, stop supporting Ctl as Ctrl --- keybinding.go | 2 -- keybinding_test.go | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/keybinding.go b/keybinding.go index 7384a08..8feda28 100644 --- a/keybinding.go +++ b/keybinding.go @@ -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{ diff --git a/keybinding_test.go b/keybinding_test.go index 269736d..6a30edb 100644 --- a/keybinding_test.go +++ b/keybinding_test.go @@ -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, ""}, From 5dce3cf4e6417539f3675f1248bd68b136c78ec2 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Mon, 11 Oct 2021 13:47:11 +0300 Subject: [PATCH 4/5] Document Key.Value interface{} --- keybinding.go | 1 + 1 file changed, 1 insertion(+) diff --git a/keybinding.go b/keybinding.go index 8feda28..26ff222 100644 --- a/keybinding.go +++ b/keybinding.go @@ -114,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 From 0163d516401cd92787adbf7dd43391b11f160259 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Mon, 11 Oct 2021 14:01:02 +0300 Subject: [PATCH 5/5] Add TODO --- README.md | 12 ++++++++++++ keybinding_test.go | 1 + 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 3fd74a7..8f72526 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/keybinding_test.go b/keybinding_test.go index 6a30edb..369e9dc 100644 --- a/keybinding_test.go +++ b/keybinding_test.go @@ -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 {