summaryrefslogtreecommitdiff
path: root/internal/tui/pidpicker
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tui/pidpicker')
-rw-r--r--internal/tui/pidpicker/model.go20
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