diff options
| author | gmorer <gmorer@users.noreply.github.com> | 2023-10-13 09:24:22 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-13 11:24:22 +0200 |
| commit | ccc40a4a26b8e8a77288e55ab6777c64af816469 (patch) | |
| tree | a67d9afbbd6bd6916161fea325a2512d42a5624a /zellij-client/src/lib.rs | |
| parent | docs(changelog): session resurrection (diff) | |
| download | sl0ppij-ccc40a4a26b8e8a77288e55ab6777c64af816469.tar.gz sl0ppij-ccc40a4a26b8e8a77288e55ab6777c64af816469.tar.xz sl0ppij-ccc40a4a26b8e8a77288e55ab6777c64af816469.zip | |
feat(client): terminal synchronized output (#2798)
Diffstat (limited to 'zellij-client/src/lib.rs')
| -rw-r--r-- | zellij-client/src/lib.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index 71659264..6cb85511 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -16,7 +16,7 @@ use std::sync::{Arc, Mutex}; use std::thread; use zellij_utils::errors::FatalError; -use crate::stdin_ansi_parser::{AnsiStdinInstruction, StdinAnsiParser}; +use crate::stdin_ansi_parser::{AnsiStdinInstruction, StdinAnsiParser, SyncOutput}; use crate::{ command_is_executing::CommandIsExecuting, input_handler::input_loop, os_input_output::ClientOsApi, stdin_handler::stdin_loop, @@ -47,6 +47,7 @@ pub(crate) enum ClientInstruction { DoneParsingStdinQuery, Log(Vec<String>), SwitchSession(ConnectToSession), + SetSynchronizedOutput(Option<SyncOutput>), } impl From<ServerToClientMsg> for ClientInstruction { @@ -82,6 +83,7 @@ impl From<&ClientInstruction> for ClientContext { ClientInstruction::StartedParsingStdinQuery => ClientContext::StartedParsingStdinQuery, ClientInstruction::DoneParsingStdinQuery => ClientContext::DoneParsingStdinQuery, ClientInstruction::SwitchSession(..) => ClientContext::SwitchSession, + ClientInstruction::SetSynchronizedOutput(..) => ClientContext::SetSynchronisedOutput, } } } @@ -381,6 +383,10 @@ pub fn start_client( let mut exit_msg = String::new(); let mut loading = true; let mut pending_instructions = vec![]; + let mut synchronised_output = match os_input.env_variable("TERM").as_deref() { + Some("alacritty") => Some(SyncOutput::DCS), + _ => None, + }; let mut stdout = os_input.get_stdout_writer(); stdout @@ -439,9 +445,19 @@ pub fn start_client( }, ClientInstruction::Render(output) => { let mut stdout = os_input.get_stdout_writer(); + if let Some(sync) = synchronised_output { + stdout + .write_all(sync.start_seq()) + .expect("cannot write to stdout"); + } stdout .write_all(output.as_bytes()) .expect("cannot write to stdout"); + if let Some(sync) = synchronised_output { + stdout + .write_all(sync.end_seq()) + .expect("cannot write to stdout"); + } stdout.flush().expect("could not flush"); }, ClientInstruction::UnblockInputThread => { @@ -462,6 +478,9 @@ pub fn start_client( os_input.send_to_server(ClientToServerMsg::ClientExited); break; }, + ClientInstruction::SetSynchronizedOutput(enabled) => { + synchronised_output = enabled; + }, _ => {}, } } |
