aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2020-11-08 21:22:46 +0100
committerGitHub <noreply@github.com>2020-11-08 21:22:46 +0100
commitee0167f3afe616a48e454ec748c0e95ccf7ed8dd (patch)
treea99be866511764c9810cfdbe84202e2fada2a4d9 /src/screen.rs
parentfix(compatibility): better stdin reading to fix various issues (#28) (diff)
downloadsl0ppij-ee0167f3afe616a48e454ec748c0e95ccf7ed8dd.tar.gz
sl0ppij-ee0167f3afe616a48e454ec748c0e95ccf7ed8dd.tar.xz
sl0ppij-ee0167f3afe616a48e454ec748c0e95ccf7ed8dd.zip
fix(compatibility): do not interpret esc as scroll-up (#29)
Diffstat (limited to 'src/screen.rs')
-rw-r--r--src/screen.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/screen.rs b/src/screen.rs
index fd4cc159..10e6451e 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -257,9 +257,20 @@ impl Screen {
let terminal_output = self.terminals.get_mut(&pid).unwrap();
terminal_output.handle_event(event);
}
- pub fn write_to_active_terminal(&mut self, mut bytes: [u8; 10]) {
+ pub fn write_to_active_terminal(&mut self, bytes: [u8; 10]) {
if let Some(active_terminal_id) = &self.get_active_terminal_id() {
- self.os_api.write_to_tty_stdin(*active_terminal_id, &mut bytes).expect("failed to write to terminal");
+ // this is a bit of a hack and is done in order not to send trailing
+ // zeros to the terminal (because they mess things up)
+ // TODO: fix this by only sending around the exact bytes read from stdin
+ let mut trimmed_bytes = vec![];
+ for byte in bytes.iter() {
+ if *byte == 0 {
+ break;
+ } else {
+ trimmed_bytes.push(*byte);
+ }
+ }
+ self.os_api.write_to_tty_stdin(*active_terminal_id, &mut trimmed_bytes).expect("failed to write to terminal");
self.os_api.tcdrain(*active_terminal_id).expect("failed to drain terminal");
}
}