Browse Source

Rename Keys.SelectAlt to Keys.Select2

merge-requests/4/head
Trevor Slocum 2 years ago
parent
commit
49536324ce
  1. 2
      button.go
  2. 2
      checkbox.go
  3. 2
      go.mod
  4. 4
      go.sum
  5. 14
      keys.go
  6. 2
      list.go
  7. 2
      table.go
  8. 2
      textview.go
  9. 2
      treeview.go

2
button.go

@ -151,7 +151,7 @@ func (b *Button) Draw(screen tcell.Screen) {
func (b *Button) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) {
return b.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p Primitive)) {
// Process key event.
if HitShortcut(event, Keys.Select, Keys.SelectAlt) {
if HitShortcut(event, Keys.Select, Keys.Select2) {
if b.selected != nil {
b.selected()
}

2
checkbox.go

@ -253,7 +253,7 @@ func (c *CheckBox) Draw(screen tcell.Screen) {
// InputHandler returns the handler for this primitive.
func (c *CheckBox) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) {
return c.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p Primitive)) {
if HitShortcut(event, Keys.Select, Keys.SelectAlt) {
if HitShortcut(event, Keys.Select, Keys.Select2) {
c.Lock()
c.checked = !c.checked
c.Unlock()

2
go.mod

@ -8,5 +8,5 @@ require (
github.com/mattn/go-runewidth v0.0.9
github.com/rivo/uniseg v0.1.0
gitlab.com/tslocum/cbind v0.1.1
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 // indirect
golang.org/x/sys v0.0.0-20200610111108-226ff32320da // indirect
)

4
go.sum

@ -23,8 +23,8 @@ gitlab.com/tslocum/cbind v0.1.1/go.mod h1:rX7vkl0pUSg/yy427MmD1FZAf99S7WwpUlxF/q
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200610111108-226ff32320da h1:bGb80FudwxpeucJUjPYJXuJ8Hk91vNtfvrymzwiei38=
golang.org/x/sys v0.0.0-20200610111108-226ff32320da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=

14
keys.go

@ -8,9 +8,10 @@ import (
// Key defines the keyboard shortcuts of an application.
// Secondary shortcuts apply when not focusing a text input.
type Key struct {
Select []string
SelectAlt []string
Cancel []string
Cancel []string
Select []string
Select2 []string
MoveUp []string
MoveUp2 []string
@ -37,9 +38,10 @@ type Key struct {
// Keys defines the keyboard shortcuts of an application.
// Secondary shortcuts apply when not focusing a text input.
var Keys = Key{
Select: []string{"Enter", "Ctrl+J"}, // Ctrl+J = keypad enter
SelectAlt: []string{"Space"},
Cancel: []string{"Escape"},
Cancel: []string{"Escape"},
Select: []string{"Enter", "Ctrl+J"}, // Ctrl+J = keypad enter
Select2: []string{"Space"},
MoveUp: []string{"Up"},
MoveUp2: []string{"k"},

2
list.go

@ -903,7 +903,7 @@ func (l *List) InputHandler() func(event *tcell.EventKey, setFocus func(p Primit
l.Unlock()
}
return
} else if HitShortcut(event, Keys.Select, Keys.SelectAlt) {
} else if HitShortcut(event, Keys.Select, Keys.Select2) {
if l.currentItem >= 0 && l.currentItem < len(l.items) {
item := l.items[l.currentItem]
if item.Enabled {

2
table.go

@ -1395,7 +1395,7 @@ func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(p Primi
pageUp()
} else if HitShortcut(event, Keys.MoveNextPage) {
pageDown()
} else if HitShortcut(event, Keys.Select, Keys.SelectAlt) {
} else if HitShortcut(event, Keys.Select, Keys.Select2) {
if (t.rowsSelectable || t.columnsSelectable) && t.selected != nil {
t.Unlock()
t.selected(t.selectedRow, t.selectedColumn)

2
textview.go

@ -1172,7 +1172,7 @@ func (t *TextView) InputHandler() func(event *tcell.EventKey, setFocus func(p Pr
return t.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p Primitive)) {
key := event.Key()
if HitShortcut(event, Keys.Cancel, Keys.Select, Keys.SelectAlt, Keys.MovePreviousField, Keys.MoveNextField) {
if HitShortcut(event, Keys.Cancel, Keys.Select, Keys.Select2, Keys.MovePreviousField, Keys.MoveNextField) {
if t.done != nil {
t.done(key)
}

2
treeview.go

@ -907,7 +907,7 @@ func (t *TreeView) InputHandler() func(event *tcell.EventKey, setFocus func(p Pr
t.movement = treePageUp
} else if HitShortcut(event, Keys.MoveNextPage) {
t.movement = treePageDown
} else if HitShortcut(event, Keys.Select, Keys.SelectAlt) {
} else if HitShortcut(event, Keys.Select, Keys.Select2) {
t.Unlock()
selectNode()
t.Lock()

Loading…
Cancel
Save