par-term-config 0.11.0

Configuration system for par-term terminal emulator
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
//! Default values that do not belong to a single focused subsystem.

// ── Primitive helpers ──────────────────────────────────────────────────────

/// Serde default returning `false`.
pub fn bool_false() -> bool {
    false
}

/// Serde default returning `true`.
pub fn bool_true() -> bool {
    true
}

/// Serde default returning `0`.
pub fn zero() -> usize {
    0
}

/// Default mDNS service discovery timeout in seconds.
pub fn mdns_timeout() -> u32 {
    3
}

// ── Update ─────────────────────────────────────────────────────────────────

/// Default update check frequency.
pub fn update_check_frequency() -> crate::types::UpdateCheckFrequency {
    crate::types::UpdateCheckFrequency::Daily
}

// ── Keybindings ────────────────────────────────────────────────────────────

pub fn keybindings() -> Vec<crate::types::KeyBinding> {
    // macOS: Cmd+key is safe because Cmd is separate from Ctrl (terminal control codes).
    // Windows/Linux: Ctrl+key conflicts with terminal control codes (Ctrl+C=SIGINT, Ctrl+D=EOF, etc.)
    // so we use Ctrl+Shift+key following standard terminal emulator conventions
    // (WezTerm, Kitty, Alacritty, GNOME Terminal, Windows Terminal).
    #[cfg(target_os = "macos")]
    let bindings = vec![
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Shift+B".to_string(),
            action: "toggle_background_shader".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Shift+U".to_string(),
            action: "toggle_cursor_shader".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Shift+V".to_string(),
            action: "paste_special".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Shift+R".to_string(),
            action: "toggle_session_logging".to_string(),
        },
        // Split pane shortcuts (Cmd+D / Cmd+Shift+D matches iTerm2)
        crate::types::KeyBinding {
            key: "CmdOrCtrl+D".to_string(),
            action: "split_horizontal".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Shift+D".to_string(),
            action: "split_vertical".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Shift+W".to_string(),
            action: "close_pane".to_string(),
        },
        // Pane navigation shortcuts
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+Left".to_string(),
            action: "navigate_pane_left".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+Right".to_string(),
            action: "navigate_pane_right".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+Up".to_string(),
            action: "navigate_pane_up".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+Down".to_string(),
            action: "navigate_pane_down".to_string(),
        },
        // Pane resize shortcuts
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+Shift+Left".to_string(),
            action: "resize_pane_left".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+Shift+Right".to_string(),
            action: "resize_pane_right".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+Shift+Up".to_string(),
            action: "resize_pane_up".to_string(),
        },
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+Shift+Down".to_string(),
            action: "resize_pane_down".to_string(),
        },
        // Broadcast input mode
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+I".to_string(),
            action: "toggle_broadcast_input".to_string(),
        },
        // Throughput mode toggle
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Shift+T".to_string(),
            action: "toggle_throughput_mode".to_string(),
        },
        // tmux session picker
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Alt+T".to_string(),
            action: "toggle_tmux_session_picker".to_string(),
        },
        // Copy mode (vi-style keyboard-driven selection) - matches iTerm2
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Shift+C".to_string(),
            action: "toggle_copy_mode".to_string(),
        },
        // Command history fuzzy search
        crate::types::KeyBinding {
            key: "CmdOrCtrl+R".to_string(),
            action: "toggle_command_history".to_string(),
        },
        // Reopen recently closed tab
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Z".to_string(),
            action: "reopen_closed_tab".to_string(),
        },
        // SSH Quick Connect
        crate::types::KeyBinding {
            key: "CmdOrCtrl+Shift+S".to_string(),
            action: "ssh_quick_connect".to_string(),
        },
    ];

    #[cfg(not(target_os = "macos"))]
    let bindings = vec![
        crate::types::KeyBinding {
            key: "Ctrl+Shift+B".to_string(),
            action: "toggle_background_shader".to_string(),
        },
        crate::types::KeyBinding {
            key: "Ctrl+Shift+U".to_string(),
            action: "toggle_cursor_shader".to_string(),
        },
        // Ctrl+Shift+V is standard paste on Linux terminals, so use Ctrl+Alt+V for paste special
        crate::types::KeyBinding {
            key: "Ctrl+Alt+V".to_string(),
            action: "paste_special".to_string(),
        },
        crate::types::KeyBinding {
            key: "Ctrl+Shift+R".to_string(),
            action: "toggle_session_logging".to_string(),
        },
        // Split pane shortcuts
        // Ctrl+D is EOF/logout - use Ctrl+Shift+D for horizontal split
        crate::types::KeyBinding {
            key: "Ctrl+Shift+D".to_string(),
            action: "split_horizontal".to_string(),
        },
        // Ctrl+Shift+E for vertical split (Tilix/Terminator convention)
        crate::types::KeyBinding {
            key: "Ctrl+Shift+E".to_string(),
            action: "split_vertical".to_string(),
        },
        // Ctrl+Shift+W is standard close tab - use Ctrl+Shift+X for close pane
        crate::types::KeyBinding {
            key: "Ctrl+Shift+X".to_string(),
            action: "close_pane".to_string(),
        },
        // Pane navigation shortcuts
        crate::types::KeyBinding {
            key: "Ctrl+Alt+Left".to_string(),
            action: "navigate_pane_left".to_string(),
        },
        crate::types::KeyBinding {
            key: "Ctrl+Alt+Right".to_string(),
            action: "navigate_pane_right".to_string(),
        },
        crate::types::KeyBinding {
            key: "Ctrl+Alt+Up".to_string(),
            action: "navigate_pane_up".to_string(),
        },
        crate::types::KeyBinding {
            key: "Ctrl+Alt+Down".to_string(),
            action: "navigate_pane_down".to_string(),
        },
        // Pane resize shortcuts
        crate::types::KeyBinding {
            key: "Ctrl+Alt+Shift+Left".to_string(),
            action: "resize_pane_left".to_string(),
        },
        crate::types::KeyBinding {
            key: "Ctrl+Alt+Shift+Right".to_string(),
            action: "resize_pane_right".to_string(),
        },
        crate::types::KeyBinding {
            key: "Ctrl+Alt+Shift+Up".to_string(),
            action: "resize_pane_up".to_string(),
        },
        crate::types::KeyBinding {
            key: "Ctrl+Alt+Shift+Down".to_string(),
            action: "resize_pane_down".to_string(),
        },
        // Broadcast input mode
        crate::types::KeyBinding {
            key: "Ctrl+Alt+I".to_string(),
            action: "toggle_broadcast_input".to_string(),
        },
        // Ctrl+Shift+T is standard new tab - use Ctrl+Shift+M for throughput mode
        crate::types::KeyBinding {
            key: "Ctrl+Shift+M".to_string(),
            action: "toggle_throughput_mode".to_string(),
        },
        // tmux session picker
        crate::types::KeyBinding {
            key: "Ctrl+Alt+T".to_string(),
            action: "toggle_tmux_session_picker".to_string(),
        },
        // Copy mode (vi-style keyboard-driven selection)
        // Ctrl+Shift+C is standard copy on Linux, so use Ctrl+Shift+Space
        crate::types::KeyBinding {
            key: "Ctrl+Shift+Space".to_string(),
            action: "toggle_copy_mode".to_string(),
        },
        // Command history fuzzy search
        // Ctrl+R conflicts with terminal reverse search, so use Ctrl+Shift+R
        // Note: Ctrl+Shift+R is session logging on Linux; users can reassign
        crate::types::KeyBinding {
            key: "Ctrl+Alt+R".to_string(),
            action: "toggle_command_history".to_string(),
        },
        // Reopen recently closed tab
        crate::types::KeyBinding {
            key: "Ctrl+Shift+Z".to_string(),
            action: "reopen_closed_tab".to_string(),
        },
        // SSH Quick Connect
        crate::types::KeyBinding {
            key: "Ctrl+Shift+S".to_string(),
            action: "ssh_quick_connect".to_string(),
        },
    ];

    bindings
}

// ── Command separator ──────────────────────────────────────────────────────

/// Default command separator line thickness in pixels.
pub fn command_separator_thickness() -> f32 {
    1.0 // 1 pixel line
}

/// Default command separator line opacity (0.0–1.0).
pub fn command_separator_opacity() -> f32 {
    0.4 // Subtle by default
}

// ── Cursor shadow / boost ──────────────────────────────────────────────────

/// Default cursor drop shadow pixel offset as `[x, y]`.
pub fn cursor_shadow_offset() -> [f32; 2] {
    [2.0, 2.0] // 2 pixels offset in both directions
}

/// Default cursor drop shadow blur radius in pixels.
pub fn cursor_shadow_blur() -> f32 {
    3.0 // 3 pixel blur radius
}

/// Default cursor brightness boost amount (0.0 = disabled).
pub fn cursor_boost() -> f32 {
    0.0 // Disabled by default
}

// ── Badge ──────────────────────────────────────────────────────────────────

/// Default badge format string.
pub fn badge_format() -> String {
    "\\(session.username)@\\(session.hostname)".to_string()
}

/// Default badge text opacity (0.0–1.0).
pub fn badge_color_alpha() -> f32 {
    0.5 // 50% opacity (semi-transparent)
}

/// Default badge top margin in pixels.
pub fn badge_top_margin() -> f32 {
    0.0 // 0 pixels from top
}

/// Default badge right margin in pixels.
pub fn badge_right_margin() -> f32 {
    16.0 // 16 pixels from right
}

/// Default badge maximum width as a fraction of terminal width (0.0–1.0).
pub fn badge_max_width() -> f32 {
    0.5 // 50% of terminal width
}

/// Default badge maximum height as a fraction of terminal height (0.0–1.0).
pub fn badge_max_height() -> f32 {
    0.2 // 20% of terminal height
}

// ── Progress bar ───────────────────────────────────────────────────────────

/// Default progress bar height in pixels.
pub fn progress_bar_height() -> f32 {
    4.0 // Height in pixels
}

/// Default progress bar opacity (0.0–1.0).
pub fn progress_bar_opacity() -> f32 {
    0.8
}

// ── Unicode ────────────────────────────────────────────────────────────────

/// Default Unicode version for character width calculations.
pub fn unicode_version() -> crate::types::UnicodeVersion {
    crate::types::UnicodeVersion::Auto
}

/// Default treatment of ambiguous-width Unicode characters.
pub fn ambiguous_width() -> crate::types::AmbiguousWidth {
    crate::types::AmbiguousWidth::Narrow
}

/// Default Unicode normalization form applied to terminal input.
pub fn normalization_form() -> crate::types::NormalizationForm {
    crate::types::NormalizationForm::NFC
}

// ── Pane layout ────────────────────────────────────────────────────────────

/// Default split-pane divider visual width in pixels (`None` = use theme default).
pub fn pane_divider_width() -> Option<f32> {
    Some(2.0) // 2 pixel divider between panes
}

/// Default split-pane divider drag hit area width in pixels.
pub fn pane_divider_hit_width() -> f32 {
    5.0 // 5 pixel hit area for drag-to-resize (larger than visual for easier grabbing)
}

/// Default padding in pixels inside each pane (between content and border/divider).
pub fn pane_padding() -> f32 {
    1.0 // 1 pixel padding inside panes (space between content and border/divider)
}

/// Default minimum pane size in terminal cells (applies to both columns and rows).
pub fn pane_min_size() -> usize {
    10 // Minimum pane size in cells (columns or rows)
}

/// Default pane background opacity (1.0 = fully opaque).
pub fn pane_background_opacity() -> f32 {
    1.0 // Fully opaque by default
}

/// Default opacity for inactive (unfocused) panes (0.0–1.0).
pub fn inactive_pane_opacity() -> f32 {
    0.7 // 70% opacity for inactive panes
}

/// Default maximum number of panes allowed per tab.
pub fn max_panes() -> usize {
    16 // Maximum panes per tab
}

/// Default pane title bar height in pixels.
pub fn pane_title_height() -> f32 {
    20.0 // 20 pixel title bar height for panes
}

/// Default focused pane border width in pixels.
pub fn pane_focus_width() -> f32 {
    1.0 // 1 pixel border around focused pane
}

// ── tmux integration ───────────────────────────────────────────────────────

pub fn tmux_path() -> String {
    // First, try to find tmux in the user's PATH environment variable
    if let Ok(path_env) = std::env::var("PATH") {
        let separator = if cfg!(windows) { ';' } else { ':' };
        let executable = if cfg!(windows) { "tmux.exe" } else { "tmux" };

        for dir in path_env.split(separator) {
            let candidate = std::path::Path::new(dir).join(executable);
            if candidate.exists() {
                return candidate.to_string_lossy().to_string();
            }
        }
    }

    // Fall back to common paths for environments where PATH might be incomplete
    // (e.g., macOS app bundles launched from Finder)
    #[cfg(target_os = "macos")]
    {
        let macos_paths = [
            "/opt/homebrew/bin/tmux", // Homebrew on Apple Silicon
            "/usr/local/bin/tmux",    // Homebrew on Intel / MacPorts
        ];
        for path in macos_paths {
            if std::path::Path::new(path).exists() {
                return path.to_string();
            }
        }
    }

    #[cfg(target_os = "linux")]
    {
        let linux_paths = [
            "/usr/bin/tmux",       // Most distros
            "/usr/local/bin/tmux", // Manual install
            "/snap/bin/tmux",      // Snap package
        ];
        for path in linux_paths {
            if std::path::Path::new(path).exists() {
                return path.to_string();
            }
        }
    }

    // Final fallback - let the OS try to find it
    "tmux".to_string()
}

/// Default tmux session name to connect to (`None` = no default).
pub fn tmux_default_session() -> Option<String> {
    None // No default session name
}

/// Default tmux session to auto-attach on startup (`None` = disabled).
pub fn tmux_auto_attach_session() -> Option<String> {
    None // No auto-attach session
}

/// Default tmux prefix key string (standard Ctrl+B).
pub fn tmux_prefix_key() -> String {
    "C-b".to_string() // Standard tmux prefix (Ctrl+B)
}

/// Default custom action prefix key (empty = disabled).
pub fn custom_action_prefix_key() -> String {
    String::new() // Disabled by default
}

/// Default tmux status bar refresh interval in milliseconds.
pub fn tmux_status_bar_refresh_ms() -> u64 {
    1000 // Default: 1 second refresh interval
}

/// Default tmux status bar left-side format string.
pub fn tmux_status_bar_left() -> String {
    "[{session}] {windows}".to_string()
}

/// Default tmux status bar right-side format string.
pub fn tmux_status_bar_right() -> String {
    "{pane} | {time:%H:%M}".to_string()
}