Skip to content

Commit

Permalink
move setInputCapture to mainGrid, except ctrl+c
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnveenman authored and F1bonacc1 committed Feb 4, 2024
1 parent 047927e commit f07cfdf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/tui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ func newPcView(project app.IProject) *pcView {
pv.pages = tview.NewPages().
AddPage(PageMain, pv.mainGrid, true, true)

pv.mainGrid.SetInputCapture(pv.onMainGridKey)
pv.appView.SetRoot(pv.pages, true).EnableMouse(true).SetInputCapture(pv.onAppKey)

if len(pv.procNames) > 0 {
name := pv.procNames[0]
pv.logsText.SetTitle(name)
Expand Down Expand Up @@ -134,6 +136,15 @@ func (pv *pcView) loadShortcuts() {
}

func (pv *pcView) onAppKey(event *tcell.EventKey) *tcell.EventKey {
if event.Key() == tcell.KeyCtrlC {
pv.terminateAppView()
return nil
} else {
return event
}
}

func (pv *pcView) onMainGridKey(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case pv.shortcuts.ShortCutKeys[ActionQuit].key:
pv.terminateAppView()
Expand Down Expand Up @@ -167,8 +178,6 @@ func (pv *pcView) onAppKey(event *tcell.EventKey) *tcell.EventKey {
pv.redrawGrid()
pv.onProcRowSpanChange()
pv.updateHelpTextView()
case tcell.KeyCtrlC:
pv.terminateAppView()
case pv.shortcuts.ShortCutKeys[ActionProcessScale].key:
pv.showScale()
case pv.shortcuts.ShortCutKeys[ActionProcessInfo].key:
Expand Down

0 comments on commit f07cfdf

Please sign in to comment.