1package domain
2
3import "time"
4
5// MinBarInterval is the minimum supported bar refresh interval.
6const MinBarInterval = time.Second
7
8// DefaultWordSeparators matches tmux's practical shell-oriented word boundaries.
9const DefaultWordSeparators = " -_@"
10
11// ThemeMode selects how vev derives its color scheme.
12type ThemeMode int
13
14const (
15 // ThemeAuto follows the attached client's reported color scheme.
16 ThemeAuto ThemeMode = iota
17 // ThemeDark forces vev's built-in dark palette.
18 ThemeDark
19 // ThemeLight forces vev's built-in light palette.
20 ThemeLight
21)
22
23// ConfigEntry preserves one parsed config key/value in file order.
24type ConfigEntry struct {
25 Key string
26 Value string
27}
28
29// SnapshotConfig contains user-configurable snapshot restore settings.
30type SnapshotConfig struct {
31 RestoreProcesses []string
32 RestoreProcessesSet bool
33}
34
35// defaultSnapshotRestoreProcesses is the default allowlist for process restore.
36var defaultSnapshotRestoreProcesses = []string{
37 "vi", "vim", "nvim", "emacs", "man", "less", "more", "tail", "top", "htop", "btop",
38 "claude", "codex", "pi", "opencode",
39}
40
41// DefaultSnapshotRestoreProcesses returns a copy of the default process restore allowlist.
42func DefaultSnapshotRestoreProcesses() []string {
43 return append([]string(nil), defaultSnapshotRestoreProcesses...)
44}
45
46// BarConfig contains user-configurable bar right-anchor settings.
47type BarConfig struct {
48 TopRight string
49 BottomRight string
50 Interval time.Duration
51}
52
53// CopyConfig contains copy-mode selection and mouse motion settings.
54type CopyConfig struct {
55 WordSeparators string
56 ReduceMotion bool
57}
58
59// PaletteConfig contains palette placement settings. A false AnchorSet uses the
60// adaptive automatic placement.
61type PaletteConfig struct {
62 Anchor Anchor
63 AnchorSet bool
64}
65
66// FloatingConfig contains launch and sizing settings for per-tab floating panes.
67type FloatingConfig struct {
68 Command string
69 Width int
70 Height int
71}
72
73// NavConfig contains directional navigation overflow settings.
74type NavConfig struct {
75 OverflowTabs bool
76 OverflowSessions bool
77}
78
79// TabsConfig contains tab label display settings.
80type TabsConfig struct {
81 // TerminalTitle includes the focused pane's OSC terminal title in tab
82 // labels (top bar and session picker). The process name always shows.
83 TerminalTitle bool
84}
85
86// EphemeralConfig contains numbered-session lifetime settings.
87type EphemeralConfig struct {
88 // CloseOnExit removes an ephemeral session once its last attachment ends
89 // definitively: a closed client process (Detach{Closed}), or an expired
90 // park or suspension. A user detach keeps it.
91 CloseOnExit bool
92}
93
94// KeyboardConfig contains outer-terminal keyboard settings.
95type KeyboardConfig struct {
96 // KittyProtocol enables the kitty keyboard protocol on outer terminals
97 // that support it, which makes Ctrl+1..9 recent-session switching work.
98 KittyProtocol bool
99}
100
101// ScrollbackConfig is vev's per-pane retention policy. The terminal library
102// only enforces these application-selected limits. Zero megabytes disables
103// history; zero lines removes the additional line ceiling.
104type ScrollbackConfig struct {
105 Megabytes uint64
106 Lines int
107}
108
109const DefaultScrollbackMegabytes uint64 = 50
110const DefaultScrollbackLines = 10_000
111const MaxScrollbackMegabytes uint64 = 4096
112const MaxScrollbackLines = 1_000_000
113
114func DefaultScrollbackConfig() ScrollbackConfig {
115 return ScrollbackConfig{Megabytes: DefaultScrollbackMegabytes, Lines: DefaultScrollbackLines}
116}
117
118func (c ScrollbackConfig) Valid() bool {
119 return c.Megabytes <= MaxScrollbackMegabytes && c.Lines >= 0 && c.Lines <= MaxScrollbackLines
120}
121
122// Config is the user-editable vev configuration after parsing. Unknown binding
123// keys are preserved here (in BindingEntries, in file order) so the usecase
124// layer can decide which actions it understands.
125type Config struct {
126 WebListen string
127 WebOrigin string
128 Theme ThemeMode
129 ThemePalette bool
130 ThemeAccent ThemeAccent
131 Bar BarConfig
132 BindingEntries []ConfigEntry
133 Codes map[string]string
134 Snapshot SnapshotConfig
135 Copy CopyConfig
136 Palette PaletteConfig
137 Floating FloatingConfig
138 Nav NavConfig
139 Tabs TabsConfig
140 Ephemeral EphemeralConfig
141 Keyboard KeyboardConfig
142 Scrollback ScrollbackConfig
143}
144
145// Warning describes a non-fatal config problem. Parsers and reloaders should
146// warn and continue with defaults rather than aborting startup.
147type Warning struct {
148 Line int
149 Msg string
150}
151
152// Defaults returns vev's default configuration.
153func Defaults() Config {
154 return Config{
155 Theme: ThemeAuto,
156 ThemePalette: true,
157 ThemeAccent: ThemeAccent{Mode: ThemeAccentAuto},
158 Bar: BarConfig{
159 Interval: 5 * time.Second,
160 },
161 BindingEntries: []ConfigEntry{},
162 Codes: map[string]string{},
163 Snapshot: SnapshotConfig{
164 RestoreProcesses: DefaultSnapshotRestoreProcesses(),
165 },
166 Copy: CopyConfig{
167 WordSeparators: DefaultWordSeparators,
168 },
169 Palette: PaletteConfig{
170 Anchor: AnchorCenter,
171 AnchorSet: true,
172 },
173 Floating: FloatingConfig{
174 Width: 80,
175 Height: 80,
176 },
177 Tabs: TabsConfig{
178 TerminalTitle: true,
179 },
180 Ephemeral: EphemeralConfig{
181 CloseOnExit: true,
182 },
183 Keyboard: KeyboardConfig{
184 KittyProtocol: true,
185 },
186 Scrollback: DefaultScrollbackConfig(),
187 }
188}