aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/mod.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs
index e4daf82d..b7fd212d 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -984,6 +984,10 @@ async fn run_client_loop(
forward_clipboard(&data);
let _ = io::stdout().flush();
}
+ ServerMessage::WindowTitle { title } => {
+ write_window_title(title.as_deref());
+ let _ = io::stdout().flush();
+ }
ServerMessage::ReloadSoundConfig => {
reload_local_client_config(
&mut state.sound_config,
@@ -1208,6 +1212,19 @@ fn forward_clipboard(data: &str) {
crate::selection::write_osc52_bytes(&bytes);
}
+fn window_title_osc(title: Option<&str>) -> Vec<u8> {
+ let title = title.unwrap_or("herdr");
+ let safe_title = title
+ .chars()
+ .filter(|ch| !matches!(*ch, '\u{1b}' | '\u{7}' | '\u{9c}'))
+ .collect::<String>();
+ format!("\x1b]0;{safe_title}\x07").into_bytes()
+}
+
+fn write_window_title(title: Option<&str>) {
+ let _ = io::stdout().write_all(&window_title_osc(title));
+}
+
// ---------------------------------------------------------------------------
// Frame output
// ---------------------------------------------------------------------------
@@ -1905,4 +1922,13 @@ mod tests {
std::env::remove_var("SSH_CONNECTION");
}
}
+
+ #[test]
+ fn window_title_osc_strips_terminators_and_defaults_to_herdr() {
+ assert_eq!(
+ window_title_osc(Some("herdr\x1b api\u{7}\u{9c}")),
+ b"\x1b]0;herdr api\x07"
+ );
+ assert_eq!(window_title_osc(None), b"\x1b]0;herdr\x07");
+ }
}