Skip to content

Commit

Permalink
fix: add default values to keyboard config (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Dec 12, 2023
1 parent f9643d3 commit 46321da
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 14 additions & 1 deletion rio-backend/src/config/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,26 @@ pub fn default_window_height() -> i32 {
400
}

#[inline]
pub fn default_disable_ctlseqs_alt() -> bool {
#[cfg(target_os = "macos")]
{
true
}

#[cfg(not(target_os = "macos"))]
{
false
}
}

pub fn default_config_file_content() -> String {
r#"
# Editor
#
# Default editor is "vi".
#
# Whenever the key binding `OpenConfigEditor` is triggered it will
# Whenever the key binding `OpenConfigEditor` is triggered it will
# use the value of the editor along with the rio configuration path.
# editor = 'vi'
Expand Down
9 changes: 7 additions & 2 deletions rio-backend/src/config/keyboard.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
use serde::{Deserialize, Serialize};

use super::defaults::default_disable_ctlseqs_alt;

#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
pub struct Keyboard {
// Enable kitty keyboard protocol
#[serde(rename = "use-kitty-keyboard-protocol")]
#[serde(default = "bool::default", rename = "use-kitty-keyboard-protocol")]
pub use_kitty_keyboard_protocol: bool,
// Disable ctlseqs with ALT keys
// For example: Terminal.app does not deal with ctlseqs with ALT keys
#[serde(rename = "disable-ctlseqs-alt")]
#[serde(
default = "default_disable_ctlseqs_alt",
rename = "disable-ctlseqs-alt"
)]
pub disable_ctlseqs_alt: bool,
}

Expand Down

0 comments on commit 46321da

Please sign in to comment.