Skip to content

Commit

Permalink
Add help screen to main app
Browse files Browse the repository at this point in the history
  • Loading branch information
senorprogrammer committed May 23, 2019
1 parent ed4fbf0 commit 5db30c0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
23 changes: 15 additions & 8 deletions wtf/focus_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ const (
// FocusTracker is used by the app to track which onscreen widget currently has focus,
// and to move focus between widgets.
type FocusTracker struct {
App *tview.Application
Idx int
Widgets []Wtfable
config *config.Config
App *tview.Application
Idx int
IsFocused bool
Widgets []Wtfable

config *config.Config
}

func NewFocusTracker(app *tview.Application, widgets []Wtfable, config *config.Config) FocusTracker {
focusTracker := FocusTracker{
App: app,
Idx: -1,
Widgets: widgets,
config: config,
App: app,
Idx: -1,
IsFocused: false,
Widgets: widgets,

config: config,
}

focusTracker.assignHotKeys()
Expand Down Expand Up @@ -57,6 +61,7 @@ func (tracker *FocusTracker) FocusOn(char string) bool {
tracker.focus(tracker.Idx)

hasFocusable = true
tracker.IsFocused = true
break
}
}
Expand Down Expand Up @@ -149,6 +154,8 @@ func (tracker *FocusTracker) blur(idx int) {
view.Blur()

view.SetBorderColor(ColorFor(widget.BorderColor()))

tracker.IsFocused = false
}

func (tracker *FocusTracker) decrement() {
Expand Down

0 comments on commit 5db30c0

Please sign in to comment.