From d2b81293df36efae1a9a21497f1f46095dff963a Mon Sep 17 00:00:00 2001 From: a-kenji Date: Mon, 1 Nov 2021 08:52:55 +0100 Subject: [PATCH] add: `WriteChars` action (#825) * Behaves like the `Write` action, but one can specify strings themselves instead of their bytecodes. Usage: WriteChars: "cargo make test", --- zellij-server/src/route.rs | 11 +++++++++++ zellij-utils/src/input/actions.rs | 2 ++ 2 files changed, 13 insertions(+) diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs index 9b1201b6..bb9e733d 100644 --- a/zellij-server/src/route.rs +++ b/zellij-server/src/route.rs @@ -50,6 +50,17 @@ fn route_action( .send_to_screen(ScreenInstruction::WriteCharacter(val, client_id)) .unwrap(); } + Action::WriteChars(val) => { + session + .senders + .send_to_screen(ScreenInstruction::ClearScroll(client_id)) + .unwrap(); + let val = Vec::from(val.as_bytes()); + session + .senders + .send_to_screen(ScreenInstruction::WriteCharacter(val, client_id)) + .unwrap(); + } Action::SwitchToMode(mode) => { let palette = session.palette; // TODO: use the palette from the client and remove it from the server os api diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index 8446bf0d..c1277db1 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -28,6 +28,8 @@ pub enum Action { Quit, /// Write to the terminal. Write(Vec), + /// Write Characters to the terminal. + WriteChars(String), /// Switch to the specified input mode. SwitchToMode(InputMode), /// Resize focus pane in specified direction.