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

fix(keys): spacebar now sends a KeySpace #289

Merged
merged 5 commits into from Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions key.go
Expand Up @@ -137,7 +137,6 @@ const (
keyGS KeyType = 29 // group separator
keyRS KeyType = 30 // record separator
keyUS KeyType = 31 // unit separator
keySP KeyType = 32 // space
keyDEL KeyType = 127 // delete. on most systems this is mapped to backspace, I hear
)

Expand All @@ -148,7 +147,6 @@ const (
KeyEnter KeyType = keyCR
KeyBackspace KeyType = keyDEL
KeyTab KeyType = keyHT
KeySpace KeyType = keySP
KeyEsc KeyType = keyESC
KeyEscape KeyType = keyESC

Expand Down Expand Up @@ -200,6 +198,7 @@ const (
KeyPgUp
KeyPgDown
KeyDelete
KeySpace
KeyF1
KeyF2
KeyF3
Expand Down Expand Up @@ -256,13 +255,13 @@ var keyNames = map[KeyType]string{
keyGS: "ctrl+]",
keyRS: "ctrl+^",
keyUS: "ctrl+_",
keySP: "space",
keyDEL: "backspace",

KeyRunes: "runes",
KeyUp: "up",
KeyDown: "down",
KeyRight: "right",
KeySpace: " ",
KeyLeft: "left",
KeyShiftTab: "shift+tab",
KeyHome: "home",
Expand Down
10 changes: 5 additions & 5 deletions key_test.go
Expand Up @@ -8,10 +8,10 @@ import (
func TestKeyString(t *testing.T) {
t.Run("alt+space", func(t *testing.T) {
if got := KeyMsg(Key{
Type: keySP,
Type: KeySpace,
Alt: true,
}).String(); got != "alt+space" {
t.Fatalf(`expected a "alt+space", got %q`, got)
}).String(); got != "alt+ " {
t.Fatalf(`expected a "alt+ ", got %q`, got)
}
})

Expand All @@ -35,8 +35,8 @@ func TestKeyString(t *testing.T) {

func TestKeyTypeString(t *testing.T) {
t.Run("space", func(t *testing.T) {
if got := keySP.String(); got != "space" {
t.Fatalf(`expected a "space", got %q`, got)
if got := KeySpace.String(); got != " " {
t.Fatalf(`expected a " ", got %q`, got)
}
})

Expand Down