par_term_config/config/config_struct/selection_config.rs
1//! Selection and clipboard settings.
2//!
3//! Extracted from the top-level [`super::Config`] struct via `#[serde(flatten)]`.
4//! All fields serialise at the top level of the YAML config file -- existing
5//! config files remain 100% compatible.
6
7use crate::types::DroppedFileQuoteStyle;
8use serde::{Deserialize, Serialize};
9
10/// Copy-on-select, paste behaviour and dropped-file quoting.
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct SelectionConfig {
13 /// Automatically copy selected text to clipboard
14 #[serde(default = "crate::defaults::bool_true")]
15 pub auto_copy_selection: bool,
16
17 /// Include trailing newline when copying lines
18 /// Note: Inverted logic from old strip_trailing_newline_on_copy
19 #[serde(
20 default = "crate::defaults::bool_false",
21 alias = "strip_trailing_newline_on_copy"
22 )]
23 pub copy_trailing_newline: bool,
24
25 /// Paste on middle mouse button click
26 #[serde(default = "crate::defaults::bool_true")]
27 pub middle_click_paste: bool,
28
29 /// Delay in milliseconds between pasted lines (0 = no delay)
30 /// Useful for slow terminals or remote connections that can't handle rapid paste
31 #[serde(default = "crate::defaults::paste_delay_ms")]
32 pub paste_delay_ms: u64,
33
34 /// When `true` (default), log a warning when clipboard paste content contains
35 /// control characters that were stripped by the paste sanitizer.
36 ///
37 /// Control characters in paste content (ESC, C0, C1) can inject terminal escape
38 /// sequences and execute commands when pasted into a shell. The sanitizer always
39 /// strips them; this flag controls whether a warning is logged so users can
40 /// investigate unexpected behaviour.
41 ///
42 /// Set to `false` to suppress warnings for pastes that regularly contain
43 /// control characters (e.g., when pasting binary content intentionally).
44 #[serde(default = "crate::defaults::bool_true")]
45 pub warn_paste_control_chars: bool,
46
47 /// Quote style for dropped file paths
48 /// - single_quotes: Wrap in single quotes (safest for most shells)
49 /// - double_quotes: Wrap in double quotes
50 /// - backslash: Escape special characters with backslashes
51 /// - none: Insert path as-is (not recommended)
52 #[serde(default)]
53 pub dropped_file_quote_style: DroppedFileQuoteStyle,
54}
55
56impl Default for SelectionConfig {
57 fn default() -> Self {
58 Self {
59 auto_copy_selection: crate::defaults::bool_true(),
60 copy_trailing_newline: crate::defaults::bool_false(),
61 middle_click_paste: crate::defaults::bool_true(),
62 paste_delay_ms: crate::defaults::paste_delay_ms(),
63 warn_paste_control_chars: crate::defaults::bool_true(),
64 dropped_file_quote_style: DroppedFileQuoteStyle::default(),
65 }
66 }
67}