diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-05 19:34:01 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-05 19:34:01 +0200 |
| commit | 5fe164e91e40e8a3f749f4143f7562f940bf9f67 (patch) | |
| tree | d77b03c737628fa58171de28eb89720c96f203b2 /internal/tui/pidpicker/model.go | |
| parent | a44f6ee30c11963552b5b90a19698873aa9b6b6d (diff) | |
feat(tui): detect terminal theme and apply palettes
Diffstat (limited to 'internal/tui/pidpicker/model.go')
| -rw-r--r-- | internal/tui/pidpicker/model.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/tui/pidpicker/model.go b/internal/tui/pidpicker/model.go index 187be52..87c200c 100644 --- a/internal/tui/pidpicker/model.go +++ b/internal/tui/pidpicker/model.go @@ -50,6 +50,14 @@ var ( errorStyle = common.ErrorStyle ) +func syncPickerStyles() { + screenStyle = common.ScreenStyle + headerStyle = common.HeaderStyle + helpBarStyle = common.HelpBarStyle + highlightStyle = common.HighlightStyle + errorStyle = common.ErrorStyle +} + type processesLoadedMsg struct { processes []ProcessInfo err error @@ -67,6 +75,7 @@ type Model struct { height int keys KeyMap lastErr error + isDark bool } // New creates a PID picker model with default shared key bindings. @@ -81,12 +90,14 @@ func NewWithKeys(keys KeyMap) Model { // NewPIDWithKeys creates a PID picker model with the provided key bindings. func NewPIDWithKeys(keys KeyMap) Model { + syncPickerStyles() input := textinput.New() input.Prompt = "Filter: " input.Placeholder = "pid, comm, or cmdline" input.Focus() input.CharLimit = 0 input.SetWidth(40) + input.SetStyles(textinput.DefaultStyles(true)) return Model{ input: input, @@ -94,6 +105,7 @@ func NewPIDWithKeys(keys KeyMap) Model { filtered: []ProcessInfo{}, mode: PickerModePID, targetPID: -1, + isDark: true, } } @@ -268,6 +280,14 @@ func (m Model) View() tea.View { return tea.NewView(screenStyle.Render(b.String())) } +// SetDarkMode updates picker theme and text input styles. +func (m Model) SetDarkMode(isDark bool) Model { + m.isDark = isDark + syncPickerStyles() + m.input.SetStyles(textinput.DefaultStyles(isDark)) + return m +} + func (m Model) renderRows() string { lines := make([]string, 0, len(m.filtered)+1) allLabel := allPIDsLabel |
