aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/mod.rs28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs
index 0d28b47a..e19c47ca 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -1808,8 +1808,10 @@ async fn run_client_loop(
let _ = io::stdout().flush();
}
ServerMessage::WindowTitle { title } => {
- write_window_title(title.as_deref());
- let _ = io::stdout().flush();
+ let _ = crate::terminal_effects::write_window_title(
+ &mut io::stdout(),
+ title.as_deref(),
+ );
}
ServerMessage::ReloadSoundConfig => {
reload_local_client_config(
@@ -2302,19 +2304,6 @@ 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
// ---------------------------------------------------------------------------
@@ -3569,13 +3558,4 @@ 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");
- }
}