add: WriteChars action (#825)

* Behaves like the `Write` action, but one can specify
  strings themselves instead of their bytecodes.

  Usage:

  WriteChars: "cargo make test",
This commit is contained in:
a-kenji 2021-11-01 08:52:55 +01:00 committed by GitHub
parent 13f3e747e4
commit d2b81293df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -50,6 +50,17 @@ fn route_action(
.send_to_screen(ScreenInstruction::WriteCharacter(val, client_id)) .send_to_screen(ScreenInstruction::WriteCharacter(val, client_id))
.unwrap(); .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) => { Action::SwitchToMode(mode) => {
let palette = session.palette; let palette = session.palette;
// TODO: use the palette from the client and remove it from the server os api // TODO: use the palette from the client and remove it from the server os api

View file

@ -28,6 +28,8 @@ pub enum Action {
Quit, Quit,
/// Write to the terminal. /// Write to the terminal.
Write(Vec<u8>), Write(Vec<u8>),
/// Write Characters to the terminal.
WriteChars(String),
/// Switch to the specified input mode. /// Switch to the specified input mode.
SwitchToMode(InputMode), SwitchToMode(InputMode),
/// Resize focus pane in specified direction. /// Resize focus pane in specified direction.