Skip to content

Commit

Permalink
hof/tui: add a couple more hotkeys for the command box (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm authored Sep 10, 2023
1 parent 5d9e8ca commit ad61850
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
11 changes: 8 additions & 3 deletions lib/tui/hoc/cmdbox/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (CB *CmdBoxWidget) RemoveCommand(command Command) {
}

func (CB *CmdBoxWidget) Mount(context map[string]interface{}) error {
tui.AddWidgetHandler(CB, "/sys/key/C-<space>", func(e events.Event) {
focuser := func(e events.Event) {
CB.Lock()
CB.curr = ""
CB.hIdx = len(CB.history)
Expand All @@ -118,7 +118,7 @@ func (CB *CmdBoxWidget) Mount(context map[string]interface{}) error {

CB.lastFocus = tui.GetFocus()
tui.SetFocus(CB.InputField)
})
}

CB.SetFinishedFunc(func(key tcell.Key) {
switch key {
Expand Down Expand Up @@ -158,11 +158,16 @@ func (CB *CmdBoxWidget) Mount(context map[string]interface{}) error {

})

tui.AddWidgetHandler(CB, "/sys/key/C-<space>", focuser)
tui.AddWidgetHandler(CB, "/sys/key/C-P", focuser)
tui.AddWidgetHandler(CB, "/sys/key/<esc>", focuser)

return nil
}
func (CB *CmdBoxWidget) Unmount() error {
tui.RemoveWidgetHandler(CB, "/sys/key/C-<space>")

tui.RemoveWidgetHandler(CB, "/sys/key/C-P")
tui.RemoveWidgetHandler(CB, "/sys/key/<esc>")
return nil
}

Expand Down
15 changes: 0 additions & 15 deletions lib/tui/modules/eval/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,6 @@ func (M *Eval) setupEventHandlers() {
eRefresh := false
switch event.Key() {

// give up focus to parent (this is meh, as it doesn't cross panel bounderies (but maybe easier after refactor?)
case tcell.KeyESC:
// TODO, re-enable this when we deal with panel/widget movements
if panel != nil {
if panel.ChildFocus() >= 0 {
tui.SetFocus(panel)
} else {
if panel.GetParent() != nil {
tui.SetFocus(panel.GetParent())
}
}
}
// all escape handled here, but need to think about items & widgets that have multiple things
handled = true

// same comment about items & widgets with multiple things (also applies to the nav.* options under Alt-<rune>
case tcell.KeyUp:
if ctrl {
Expand Down
4 changes: 3 additions & 1 deletion lib/tui/modules/eval/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ const EvalHelpText = `
[dodgerblue::bu]App Controls:[-::-]
[lime]C-<space>[-] focus the command box
[lime]C-P[-] (vs code like)
[lime]<esc>[-] (vim like)
[lime]A-<space>[-] focus the main content
[lime]A-/[-] show / hide the console
[lime]A-x[-] clear the console logs
[red]Ctrl-Alt-c[-] close [gold]_[ivory]Hofstadter[-]
[red]Ctrl-Alt-c[-] close [gold::bi]_[ivory]Hofstadter[-::-] :[
[red]:q[-] (from the command box)
[dodgerblue::bu]Panel Management:[-::-]
Expand Down

0 comments on commit ad61850

Please sign in to comment.