Skip to content

Commit

Permalink
Issue #159: Toggle log/proc focus with tab
Browse files Browse the repository at this point in the history
  • Loading branch information
F1bonacc1 committed Mar 23, 2024
1 parent 91eb665 commit 86b48d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/tui/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const (
ActionThemeSelector = ActionName("theme_selector")
ActionSendToBackground = ActionName("send_to_background")
ActionFullScreen = ActionName("full_screen")
ActionFocusChange = ActionName("focus_change")
)

var defaultShortcuts = map[ActionName]tcell.Key{
Expand All @@ -61,6 +62,7 @@ var defaultShortcuts = map[ActionName]tcell.Key{
ActionThemeSelector: tcell.KeyCtrlT,
ActionSendToBackground: tcell.KeyCtrlB,
ActionFullScreen: tcell.KeyCtrlRightSq,
ActionFocusChange: tcell.KeyTab,
}

var defaultShortcutsRunes = map[ActionName]rune{
Expand Down Expand Up @@ -304,6 +306,9 @@ func getDefaultActions() *ShortCuts {
ActionFullScreen: {
Description: "Toggle Full Screen",
},
ActionFocusChange: {
Description: "Toggle Log/Process Focus",
},
},
}
for k, v := range sc.ShortCutKeys {
Expand Down
1 change: 1 addition & 0 deletions src/tui/main-grid.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (pv *pcView) createGrid() {
if !pv.isFullScreen {
pv.mainGrid.AddItem(pv.helpText, row, 0, 1, 1, 0, 0, false)
}
pv.appView.SetFocus(pv.mainGrid)
pv.autoAdjustProcTableHeight()
}

Expand Down
10 changes: 10 additions & 0 deletions src/tui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ func (pv *pcView) onMainGridKey(event *tcell.EventKey) *tcell.EventKey {
pv.isFullScreen = !pv.isFullScreen
pv.logsText.SetBorder(!pv.isFullScreen)
pv.redrawGrid()
case pv.shortcuts.ShortCutKeys[ActionFocusChange].key:
pv.changeFocus()
case tcell.KeyRune:
if event.Rune() == pv.shortcuts.ShortCutKeys[ActionProcFilter].rune {
pv.commandMode = true
Expand Down Expand Up @@ -465,6 +467,14 @@ func (pv *pcView) resume() {
go setSignal(ctxSig)
}

func (pv *pcView) changeFocus() {
if pv.procTable.HasFocus() {
pv.appView.SetFocus(pv.logsText)
} else if pv.logsText.HasFocus() {
pv.appView.SetFocus(pv.procTable)
}
}

func SetupTui(project app.IProject, options ...Option) {

pv := newPcView(project)
Expand Down

0 comments on commit 86b48d9

Please sign in to comment.