From ad61850ee0369d5d50c8270aeb2d228895dbb9c1 Mon Sep 17 00:00:00 2001 From: Tony Worm <1390600+verdverm@users.noreply.github.com> Date: Sun, 10 Sep 2023 07:06:24 -0400 Subject: [PATCH] hof/tui: add a couple more hotkeys for the command box (#326) --- lib/tui/hoc/cmdbox/index.go | 11 ++++++++--- lib/tui/modules/eval/events.go | 15 --------------- lib/tui/modules/eval/help.go | 4 +++- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/lib/tui/hoc/cmdbox/index.go b/lib/tui/hoc/cmdbox/index.go index 19340b865..c3fa1d3cf 100644 --- a/lib/tui/hoc/cmdbox/index.go +++ b/lib/tui/hoc/cmdbox/index.go @@ -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-", func(e events.Event) { + focuser := func(e events.Event) { CB.Lock() CB.curr = "" CB.hIdx = len(CB.history) @@ -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 { @@ -158,11 +158,16 @@ func (CB *CmdBoxWidget) Mount(context map[string]interface{}) error { }) + tui.AddWidgetHandler(CB, "/sys/key/C-", focuser) + tui.AddWidgetHandler(CB, "/sys/key/C-P", focuser) + tui.AddWidgetHandler(CB, "/sys/key/", focuser) + return nil } func (CB *CmdBoxWidget) Unmount() error { tui.RemoveWidgetHandler(CB, "/sys/key/C-") - + tui.RemoveWidgetHandler(CB, "/sys/key/C-P") + tui.RemoveWidgetHandler(CB, "/sys/key/") return nil } diff --git a/lib/tui/modules/eval/events.go b/lib/tui/modules/eval/events.go index c1985f1fc..54271d6c3 100644 --- a/lib/tui/modules/eval/events.go +++ b/lib/tui/modules/eval/events.go @@ -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- case tcell.KeyUp: if ctrl { diff --git a/lib/tui/modules/eval/help.go b/lib/tui/modules/eval/help.go index fe129e386..59071b5ff 100644 --- a/lib/tui/modules/eval/help.go +++ b/lib/tui/modules/eval/help.go @@ -22,10 +22,12 @@ const EvalHelpText = ` [dodgerblue::bu]App Controls:[-::-] [lime]C-[-] focus the command box + [lime]C-P[-] (vs code like) + [lime][-] (vim like) [lime]A-[-] 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:[-::-]