mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add help screen to main app
This commit is contained in:
parent
ed4fbf01d0
commit
5db30c0e8d
9
main.go
9
main.go
@ -55,6 +55,15 @@ func keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If no specific widget has focus, then allow key presses to fall through to the app
|
||||
if !focusTracker.IsFocused {
|
||||
switch string(event.Rune()) {
|
||||
case "/":
|
||||
fmt.Println(">> OUCH")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return event
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,9 @@ const (
|
||||
type FocusTracker struct {
|
||||
App *tview.Application
|
||||
Idx int
|
||||
IsFocused bool
|
||||
Widgets []Wtfable
|
||||
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
@ -28,7 +30,9 @@ func NewFocusTracker(app *tview.Application, widgets []Wtfable, config *config.C
|
||||
focusTracker := FocusTracker{
|
||||
App: app,
|
||||
Idx: -1,
|
||||
IsFocused: false,
|
||||
Widgets: widgets,
|
||||
|
||||
config: config,
|
||||
}
|
||||
|
||||
@ -57,6 +61,7 @@ func (tracker *FocusTracker) FocusOn(char string) bool {
|
||||
tracker.focus(tracker.Idx)
|
||||
|
||||
hasFocusable = true
|
||||
tracker.IsFocused = true
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -149,6 +154,8 @@ func (tracker *FocusTracker) blur(idx int) {
|
||||
view.Blur()
|
||||
|
||||
view.SetBorderColor(ColorFor(widget.BorderColor()))
|
||||
|
||||
tracker.IsFocused = false
|
||||
}
|
||||
|
||||
func (tracker *FocusTracker) decrement() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user