Skip to content

Commit

Permalink
Add toggle header feature
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanaReddy0M committed Jan 31, 2023
1 parent e5a3693 commit e52dc7c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/view/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func (a *App) Init() error {
}
a.Content.Stack.AddListener(a.Menu())
a.App.Init()
a.layout(ctx)
a.SetInputCapture(a.keyboard)
a.bindKeys()
//a.layout(ctx)
//a.tempLayout(ctx)
return nil
}
Expand Down Expand Up @@ -687,6 +689,7 @@ func (a *App) tempLayout(ctx context.Context) {

main := tview.NewFlex().SetDirection(tview.FlexRow)
main.SetBorder(true)

main.AddItem(a.statusIndicator(), 1, 1, false)
main.AddItem(a.Content, 0, 10, true)
main.AddItem(flash, 1, 1, false)
Expand Down Expand Up @@ -755,6 +758,14 @@ func (a *App) buildHeader() tview.Primitive {
return header
}

func (a *App) keyboard(evt *tcell.EventKey) *tcell.EventKey {
if k, ok := a.HasAction(ui.AsKey(evt)); ok && !a.Content.IsTopDialog() {
return k.Action(evt)
}

return evt
}

func (a *App) bindKeys() {
a.AddActions(ui.KeyActions{
tcell.KeyCtrlE: ui.NewKeyAction("ToggleHeader", a.toggleHeaderCmd, false),
Expand Down

0 comments on commit e52dc7c

Please sign in to comment.