diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-21 16:30:04 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-21 16:30:04 +0300 |
| commit | 3397e1ce2922c4ae9b814e8110e81de7d201de81 (patch) | |
| tree | c457a7cf0af271dea1a412474fad5a33c1b60be8 /src/input/model.rs | |
| parent | 2818ff492d45d17fd4f9b15478d703c6c664a8c0 (diff) | |
feat: add persistent server-client sessions
Make herdr persistent by default.
Launching herdr now starts or reattaches to a background session
server. Clients can detach and reattach while panes and agent
processes keep running. Session mode now supports multi-client attach,
auto-detect startup, and a thin-client/headless-server split.
This also refactors the large app, ui, input, pane, config,
workspace, and persistence modules into smaller focused submodules,
while preserving behavior and colocating tests with the code they
exercise.
Upgrade notes:
- persistence mode is now the default
- in-app quit detaches the current client instead of stopping the server
- use `herdr server stop` to stop the background session
- use `--no-session` for the old single-process behavior
- default socket paths now live under the config directory
Diffstat (limited to 'src/input/model.rs')
| -rw-r--r-- | src/input/model.rs | 73 |
1 files changed, 21 insertions, 52 deletions
diff --git a/src/input/model.rs b/src/input/model.rs index 5721f82b..181ba7b3 100644 --- a/src/input/model.rs +++ b/src/input/model.rs @@ -1,57 +1,5 @@ use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; -pub fn normalize_app_key_binding( - code: KeyCode, - modifiers: KeyModifiers, - shifted_codepoint: Option<u32>, -) -> (KeyCode, KeyModifiers) { - let KeyCode::Char(raw_char) = code else { - return (code, modifiers); - }; - - let shifted_char = shifted_codepoint - .and_then(char::from_u32) - .or_else(|| modifiers.contains(KeyModifiers::SHIFT).then_some(raw_char)) - .and_then(shifted_printable_char); - - let normalized_char = shifted_char.unwrap_or(raw_char); - let mut normalized_modifiers = modifiers; - if shifted_char.is_some() { - normalized_modifiers.remove(KeyModifiers::SHIFT); - } - - (KeyCode::Char(normalized_char), normalized_modifiers) -} - -fn shifted_printable_char(ch: char) -> Option<char> { - match ch { - 'a'..='z' => Some(ch.to_ascii_uppercase()), - 'A'..='Z' => Some(ch), - '`' | '~' => Some('~'), - '1' | '!' => Some('!'), - '2' | '@' => Some('@'), - '3' | '#' => Some('#'), - '4' | '$' => Some('$'), - '5' | '%' => Some('%'), - '6' | '^' => Some('^'), - '7' | '&' => Some('&'), - '8' | '*' => Some('*'), - '9' | '(' => Some('('), - '0' | ')' => Some(')'), - '-' | '_' => Some('_'), - '=' | '+' => Some('+'), - '[' | '{' => Some('{'), - ']' | '}' => Some('}'), - '\\' | '|' => Some('|'), - ';' | ':' => Some(':'), - '\'' | '"' => Some('"'), - ',' | '<' => Some('<'), - '.' | '>' => Some('>'), - '/' | '?' => Some('?'), - _ => None, - } -} - #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct TerminalKey { pub code: KeyCode, @@ -129,3 +77,24 @@ pub enum MouseProtocolEncoding { Utf8, Sgr, } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn protocol_from_zero_flags_is_legacy() { + assert_eq!( + KeyboardProtocol::from_kitty_flags(0), + KeyboardProtocol::Legacy + ); + } + + #[test] + fn protocol_from_nonzero_flags_is_kitty() { + assert_eq!( + KeyboardProtocol::from_kitty_flags(7), + KeyboardProtocol::Kitty { flags: 7 } + ); + } +} |
