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

Implement backtab for tcell widgets #362

Merged
merged 2 commits into from
Jan 29, 2024
Merged
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
6 changes: 3 additions & 3 deletions container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ func TestMouse(t *testing.T) {
),
Right(
PlaceWidget(fakewidget.New(widgetapi.Options{WantKeyboard: widgetapi.KeyScopeFocused})),
KeyFocusPrevious(keyboard.KeyTab),
KeyFocusPrevious(keyboard.KeyBacktab),
),
),
)
Expand All @@ -1949,7 +1949,7 @@ func TestMouse(t *testing.T) {
return c, nil
},
events: []terminalapi.Event{
&terminalapi.Keyboard{Key: keyboard.KeyTab},
&terminalapi.Keyboard{Key: keyboard.KeyBacktab},
},
want: func(size image.Point) *faketerm.Terminal {
ft := faketerm.MustNew(size)
Expand All @@ -1966,7 +1966,7 @@ func TestMouse(t *testing.T) {
&widgetapi.Meta{Focused: true},
widgetapi.Options{WantKeyboard: widgetapi.KeyScopeFocused},
&fakewidget.Event{
Ev: &terminalapi.Keyboard{Key: keyboard.KeyTab},
Ev: &terminalapi.Keyboard{Key: keyboard.KeyBacktab},
Meta: &widgetapi.EventMeta{Focused: true},
},
)
Expand Down
2 changes: 1 addition & 1 deletion container/focus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ func TestFocusTrackerNextAndPrevious(t *testing.T) {

const (
keyNext keyboard.Key = keyboard.KeyTab
keyPrevious keyboard.Key = '~'
keyPrevious keyboard.Key = keyboard.KeyBacktab
)

tests := []struct {
Expand Down
2 changes: 2 additions & 0 deletions keyboard/keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var buttonNames = map[Key]string{
KeyCtrlG: "KeyCtrlG",
KeyBackspace: "KeyBackspace",
KeyTab: "KeyTab",
KeyBacktab: "KeyBacktab",
KeyCtrlJ: "KeyCtrlJ",
KeyCtrlK: "KeyCtrlK",
KeyCtrlL: "KeyCtrlL",
Expand Down Expand Up @@ -130,6 +131,7 @@ const (
KeyCtrlG
KeyBackspace
KeyTab
KeyBacktab
KeyCtrlJ
KeyCtrlK
KeyCtrlL
Expand Down
1 change: 1 addition & 0 deletions terminal/tcell/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var tcellToTd = map[tcell.Key]keyboard.Key{
tcell.KeyCtrlZ: keyboard.KeyCtrlZ,
tcell.KeyBackspace: keyboard.KeyBackspace,
tcell.KeyTab: keyboard.KeyTab,
tcell.KeyBacktab: keyboard.KeyBacktab,
tcell.KeyEscape: keyboard.KeyEsc,
tcell.KeyCtrlBackslash: keyboard.KeyCtrlBackslash,
tcell.KeyCtrlRightSq: keyboard.KeyCtrlRsqBracket,
Expand Down
1 change: 1 addition & 0 deletions terminal/tcell/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func TestKeyboardKeys(t *testing.T) {
{key: tcell.KeyBackspace, want: keyboard.KeyCtrlH},
{key: tcell.KeyCtrlH, want: keyboard.KeyBackspace},
{key: tcell.KeyTab, want: keyboard.KeyTab},
{key: tcell.KeyBacktab, want: keyboard.KeyBacktab},
{key: tcell.KeyTab, want: keyboard.KeyCtrlI},
{key: tcell.KeyCtrlI, want: keyboard.KeyTab},
{key: tcell.KeyCtrlJ, want: keyboard.KeyCtrlJ},
Expand Down
1 change: 1 addition & 0 deletions widgets/textinput/formdemo/formdemo.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func newForm(cancel context.CancelFunc) (*form, error) {
func formLayout(c *container.Container, f *form) error {
return c.Update("root",
container.KeyFocusNext(keyboard.KeyTab),
container.KeyFocusPrevious(keyboard.KeyBacktab),
container.KeyFocusGroupsNext(keyboard.KeyArrowDown, 1),
container.KeyFocusGroupsPrevious(keyboard.KeyArrowUp, 1),
container.KeyFocusGroupsNext(keyboard.KeyArrowRight, 2),
Expand Down
Loading