summaryrefslogtreecommitdiff
path: root/internal/tui/dashboard/model.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-24 08:38:19 +0200
committerPaul Buetow <paul@buetow.org>2026-02-24 08:38:19 +0200
commitb01e24374398eb3d343e9472f3262668039db56c (patch)
tree139a9e02946f635adaeedb8a61fa150c874c17ff /internal/tui/dashboard/model.go
parent24b401ac9c6a1f80b5ba7f446f1fd3e3ddf02b5c (diff)
tui: add dashboard syscalls table tab
Diffstat (limited to 'internal/tui/dashboard/model.go')
-rw-r--r--internal/tui/dashboard/model.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go
index 1178dc9..a7dec14 100644
--- a/internal/tui/dashboard/model.go
+++ b/internal/tui/dashboard/model.go
@@ -31,8 +31,9 @@ type Model struct {
width int
height int
- refreshEvery time.Duration
- keys tui.KeyMap
+ refreshEvery time.Duration
+ keys tui.KeyMap
+ syscallsOffset int
}
// NewModel creates a dashboard model with default refresh cadence.
@@ -81,6 +82,19 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (m Model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
+ if m.activeTab == TabSyscalls {
+ switch msg.String() {
+ case "down", "j":
+ m.syscallsOffset++
+ return m, nil
+ case "up", "k":
+ if m.syscallsOffset > 0 {
+ m.syscallsOffset--
+ }
+ return m, nil
+ }
+ }
+
switch {
case key.Matches(msg, m.keys.Tab):
m.activeTab = nextTab(m.activeTab)
@@ -114,7 +128,7 @@ func (m Model) View() string {
var b strings.Builder
b.WriteString(renderTabBar(m.activeTab, m.width))
b.WriteString("\n")
- b.WriteString(renderActiveTab(m.activeTab, m.latest, m.width, m.height))
+ b.WriteString(renderActiveTab(m.activeTab, m.latest, m.width, m.height, m.syscallsOffset))
b.WriteString("\n")
b.WriteString(renderHelpBar(m.keys))
return tui.ScreenStyle.Render(b.String())
@@ -124,7 +138,7 @@ func tickCmd(d time.Duration) tea.Cmd {
return tea.Tick(d, func(time.Time) tea.Msg { return refreshTickMsg{} })
}
-func renderActiveTab(tab Tab, snap *statsengine.Snapshot, width, height int) string {
+func renderActiveTab(tab Tab, snap *statsengine.Snapshot, width, height, syscallsOffset int) string {
_ = width
_ = height
@@ -136,7 +150,7 @@ func renderActiveTab(tab Tab, snap *statsengine.Snapshot, width, height int) str
case TabOverview:
return renderOverview(snap, width, height)
case TabSyscalls:
- return tui.PanelStyle.Render(fmt.Sprintf("Syscalls: %d rows", len(snap.Syscalls())))
+ return renderSyscallsWithOffset(snap, width, height, syscallsOffset)
case TabFiles:
return tui.PanelStyle.Render(fmt.Sprintf("Files: %d rows", len(snap.Files())))
case TabProcesses: