Skip to content

Commit

Permalink
Merge pull request #187 from ymtdzzz/feature/clear_related_panes
Browse files Browse the repository at this point in the history
Clear the related panes on `Ctrl+L`
  • Loading branch information
ymtdzzz authored Dec 21, 2024
2 parents aa884af + 9ec1a66 commit 1948626
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tuiexporter/internal/tui/component/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type TUIPages struct {
logs *tview.Flex
debuglog *tview.Flex
modal *tview.Flex
clearFns []func()
current string
setFocusFn func(p tview.Primitive)
// This is used when other components trigger to draw the timeline
Expand Down Expand Up @@ -104,6 +105,12 @@ func (p *TUIPages) switchToPage(name string) {
p.current = name
}

func (p *TUIPages) clearPanes() {
for _, fn := range p.clearFns {
fn()
}
}

func (p *TUIPages) registerPages(store *telemetry.Store) {
modal, _ := p.createModalPage("")
p.modal = modal
Expand Down Expand Up @@ -137,6 +144,9 @@ func (p *TUIPages) createTracePage(store *telemetry.Store) *tview.Flex {
tableContainer := tview.NewFlex().SetDirection(tview.FlexRow)

details := tview.NewFlex().SetDirection(tview.FlexRow)
p.clearFns = append(p.clearFns, func() {
details.Clear()
})
details.SetTitle("Details (d)").SetBorder(true)
detailspro := DEFAULT_PROPORTION_TRACE_DETAILS
tablepro := DEFAULT_PROPORTION_TRACE_TABLE
Expand Down Expand Up @@ -184,6 +194,7 @@ func (p *TUIPages) createTracePage(store *telemetry.Store) *tview.Flex {
table.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Key() == tcell.KeyCtrlL {
store.Flush()
p.clearPanes()
return nil
} else if event.Key() == tcell.KeyCtrlS {
if sortType == telemetry.SORT_TYPE_NONE {
Expand Down Expand Up @@ -378,6 +389,9 @@ func (p *TUIPages) createMetricsPage(store *telemetry.Store) *tview.Flex {

side := tview.NewFlex().SetDirection(tview.FlexRow)
details := tview.NewFlex().SetDirection(tview.FlexRow)
p.clearFns = append(p.clearFns, func() {
details.Clear()
})
details.SetTitle("Details (d)").SetBorder(true)
sidepro := DEFAULT_PROPORTION_METRIC_SIDE
tablepro := DEFAULT_PROPORTION_METRIC_TABLE
Expand Down Expand Up @@ -411,6 +425,9 @@ func (p *TUIPages) createMetricsPage(store *telemetry.Store) *tview.Flex {
})

chart := tview.NewFlex().SetDirection(tview.FlexRow)
p.clearFns = append(p.clearFns, func() {
chart.Clear()
})
chart.SetTitle("Chart (c)").SetBorder(true)

side.AddItem(details, 0, 5, false).
Expand All @@ -425,6 +442,7 @@ func (p *TUIPages) createMetricsPage(store *telemetry.Store) *tview.Flex {
table.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Key() == tcell.KeyCtrlL {
store.Flush()
p.clearPanes()
return nil
}
return event
Expand Down Expand Up @@ -530,6 +548,9 @@ func (p *TUIPages) createLogPage(store *telemetry.Store) *tview.Flex {
tableContainer := tview.NewFlex().SetDirection(tview.FlexRow)

details := tview.NewFlex().SetDirection(tview.FlexRow)
p.clearFns = append(p.clearFns, func() {
details.Clear()
})
details.SetTitle("Details (d)").SetBorder(true)
detailspro := DEFAULT_PROPORTION_LOG_DETAILS
tablepro := DEFAULT_PROPORTION_LOG_TABLE
Expand Down Expand Up @@ -563,6 +584,9 @@ func (p *TUIPages) createLogPage(store *telemetry.Store) *tview.Flex {
})

body := tview.NewTextView()
p.clearFns = append(p.clearFns, func() {
body.Clear()
})
body.SetBorder(true).SetTitle("Body (b)")
registerCommandList(commands, body, nil, KeyMaps{})

Expand All @@ -575,6 +599,7 @@ func (p *TUIPages) createLogPage(store *telemetry.Store) *tview.Flex {
table.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Key() == tcell.KeyCtrlL {
store.Flush()
p.clearPanes()
return nil
}

Expand Down

0 comments on commit 1948626

Please sign in to comment.