Skip to main content

par_term_config/config/config_struct/
input_config.rs

1//! Keyboard input 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::{ModifierRemapping, OptionKeyMode};
8use serde::{Deserialize, Serialize};
9
10/// Option/Alt key behaviour, modifier remapping and physical key positions.
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct InputConfig {
13    /// Left Option key (macOS) / Left Alt key (Linux/Windows) behavior
14    /// - normal: Sends special characters (default macOS behavior)
15    /// - meta: Sets the high bit (8th bit) on the character
16    /// - esc: Sends Escape prefix before the character (most compatible for emacs/vim)
17    #[serde(default)]
18    pub left_option_key_mode: OptionKeyMode,
19
20    /// Right Option key (macOS) / Right Alt key (Linux/Windows) behavior
21    /// Can be configured independently from left Option key
22    /// - normal: Sends special characters (default macOS behavior)
23    /// - meta: Sets the high bit (8th bit) on the character
24    /// - esc: Sends Escape prefix before the character (most compatible for emacs/vim)
25    #[serde(default)]
26    pub right_option_key_mode: OptionKeyMode,
27
28    /// Modifier key remapping configuration
29    /// Allows remapping modifier keys to different functions (e.g., swap Ctrl and Caps Lock)
30    #[serde(default)]
31    pub modifier_remapping: ModifierRemapping,
32
33    /// Use physical key positions for keybindings instead of logical characters
34    /// When enabled, keybindings work based on key position (scan code) rather than
35    /// the character produced, making shortcuts consistent across keyboard layouts.
36    /// For example, Ctrl+Z will always be the bottom-left key regardless of QWERTY/AZERTY/Dvorak.
37    #[serde(default = "crate::defaults::bool_false")]
38    pub use_physical_keys: bool,
39}
40
41impl Default for InputConfig {
42    fn default() -> Self {
43        Self {
44            left_option_key_mode: OptionKeyMode::default(),
45            right_option_key_mode: OptionKeyMode::default(),
46            modifier_remapping: ModifierRemapping::default(),
47            use_physical_keys: crate::defaults::bool_false(),
48        }
49    }
50}