summaryrefslogtreecommitdiff
path: root/internal/tui/common
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-24 09:45:02 +0200
committerPaul Buetow <paul@buetow.org>2026-02-24 09:45:02 +0200
commitf2d79f6459bbe1aa9bae2946e9773141cb184463 (patch)
treee683b901d2432ac7e28cd6e80f468da38edc280b /internal/tui/common
parent7fc16d6c98feae7aaee58666dc552384ceb4895e (diff)
tui: wire full dashboard tabs and improve overview summaries
Diffstat (limited to 'internal/tui/common')
-rw-r--r--internal/tui/common/keys.go62
-rw-r--r--internal/tui/common/styles.go61
2 files changed, 123 insertions, 0 deletions
diff --git a/internal/tui/common/keys.go b/internal/tui/common/keys.go
new file mode 100644
index 0000000..0dae542
--- /dev/null
+++ b/internal/tui/common/keys.go
@@ -0,0 +1,62 @@
+package common
+
+import "github.com/charmbracelet/bubbles/key"
+
+// KeyMap groups all key bindings shared by TUI screens.
+type KeyMap struct {
+ Tab key.Binding
+ ShiftTab key.Binding
+ One key.Binding
+ Two key.Binding
+ Three key.Binding
+ Four key.Binding
+ Five key.Binding
+ Six key.Binding
+ Export key.Binding
+ Quit key.Binding
+ Help key.Binding
+ Enter key.Binding
+ Esc key.Binding
+ Refresh key.Binding
+}
+
+// Keys contains the default shared key map.
+var Keys = DefaultKeyMap()
+
+// DefaultKeyMap builds the default key bindings used by models.
+func DefaultKeyMap() KeyMap {
+ return KeyMap{
+ Tab: key.NewBinding(key.WithKeys("tab"), key.WithHelp("tab", "next tab")),
+ ShiftTab: key.NewBinding(key.WithKeys("shift+tab"), key.WithHelp("shift+tab", "prev tab")),
+ One: key.NewBinding(key.WithKeys("1"), key.WithHelp("1", "overview")),
+ Two: key.NewBinding(key.WithKeys("2"), key.WithHelp("2", "syscalls")),
+ Three: key.NewBinding(key.WithKeys("3"), key.WithHelp("3", "files")),
+ Four: key.NewBinding(key.WithKeys("4"), key.WithHelp("4", "processes")),
+ Five: key.NewBinding(key.WithKeys("5"), key.WithHelp("5", "latency")),
+ Six: key.NewBinding(key.WithKeys("6"), key.WithHelp("6", "gaps")),
+ Export: key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "export")),
+ Quit: key.NewBinding(key.WithKeys("q", "ctrl+c"), key.WithHelp("q", "quit")),
+ Help: key.NewBinding(key.WithKeys("?"), key.WithHelp("?", "help")),
+ Enter: key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "select")),
+ Esc: key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "back")),
+ Refresh: key.NewBinding(key.WithKeys("r"), key.WithHelp("r", "refresh")),
+ }
+}
+
+// DashboardShortHelp returns compact bindings for dashboard help bars.
+func (k KeyMap) DashboardShortHelp() []key.Binding {
+ return []key.Binding{k.Tab, k.ShiftTab, k.Export, k.Help, k.Quit}
+}
+
+// DashboardFullHelp returns grouped bindings for dashboard overlays.
+func (k KeyMap) DashboardFullHelp() [][]key.Binding {
+ return [][]key.Binding{
+ {k.One, k.Two, k.Three, k.Four, k.Five, k.Six},
+ {k.Tab, k.ShiftTab, k.Export, k.Help, k.Quit},
+ }
+}
+
+// PickerShortHelp returns compact bindings for the PID picker.
+func (k KeyMap) PickerShortHelp() []key.Binding {
+ return []key.Binding{k.Enter, k.Refresh, k.Esc}
+}
diff --git a/internal/tui/common/styles.go b/internal/tui/common/styles.go
new file mode 100644
index 0000000..ed6a191
--- /dev/null
+++ b/internal/tui/common/styles.go
@@ -0,0 +1,61 @@
+package common
+
+import "github.com/charmbracelet/lipgloss"
+
+var (
+ // Palette colors shared across the TUI package.
+ ColorBackground = lipgloss.Color("235")
+ ColorPanel = lipgloss.Color("238")
+ ColorPrimary = lipgloss.Color("75")
+ ColorAccent = lipgloss.Color("222")
+ ColorMuted = lipgloss.Color("246")
+ ColorText = lipgloss.Color("255")
+ ColorDanger = lipgloss.Color("203")
+)
+
+var (
+ // ScreenStyle is the base style for full-screen models.
+ ScreenStyle = lipgloss.NewStyle().
+ Foreground(ColorText).
+ Background(ColorBackground)
+
+ // HeaderStyle is used by top-level titles and screen headers.
+ HeaderStyle = lipgloss.NewStyle().
+ Bold(true).
+ Foreground(ColorPrimary)
+
+ // TabActiveStyle is applied to the currently-selected tab.
+ TabActiveStyle = lipgloss.NewStyle().
+ Bold(true).
+ Foreground(ColorBackground).
+ Background(ColorPrimary).
+ Padding(0, 1)
+
+ // TabInactiveStyle is applied to non-selected tabs.
+ TabInactiveStyle = lipgloss.NewStyle().
+ Foreground(ColorMuted).
+ Background(ColorPanel).
+ Padding(0, 1)
+
+ // PanelStyle is used for boxed sections.
+ PanelStyle = lipgloss.NewStyle().
+ Border(lipgloss.NormalBorder()).
+ BorderForeground(ColorPanel).
+ Padding(0, 1)
+
+ // HelpBarStyle is used for keybinding hints at the bottom.
+ HelpBarStyle = lipgloss.NewStyle().
+ Foreground(ColorMuted).
+ BorderTop(true).
+ BorderForeground(ColorPanel)
+
+ // HighlightStyle emphasizes inline values.
+ HighlightStyle = lipgloss.NewStyle().
+ Bold(true).
+ Foreground(ColorAccent)
+
+ // ErrorStyle is used for fatal or warning messages.
+ ErrorStyle = lipgloss.NewStyle().
+ Bold(true).
+ Foreground(ColorDanger)
+)