summaryrefslogtreecommitdiffstats
path: root/zellij-client/src
diff options
context:
space:
mode:
authorThomas Linford <tlinford@users.noreply.github.com>2022-05-16 15:32:17 +0200
committerGitHub <noreply@github.com>2022-05-16 15:32:17 +0200
commit6ed4bf8c0bbe9e729e13637fad093fd6b1a3fd59 (patch)
tree9cc064e98515f4df2392ad1dbfd06b8f2615d62b /zellij-client/src
parent84d8f94f3648f16c96ffca5345cece5b91f3787c (diff)
fix(input): ANSI code sent to terminal on startup and resize
* fix macos parsing issues * format * fix(ansiparser): validate first key on parse Co-authored-by: Aram Drevekenin <aram@poor.dev>
Diffstat (limited to 'zellij-client/src')
-rw-r--r--zellij-client/src/stdin_ansi_parser.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/zellij-client/src/stdin_ansi_parser.rs b/zellij-client/src/stdin_ansi_parser.rs
index efffffc8b..31e6ccbb3 100644
--- a/zellij-client/src/stdin_ansi_parser.rs
+++ b/zellij-client/src/stdin_ansi_parser.rs
@@ -17,7 +17,7 @@ impl StdinAnsiParser {
}
}
pub fn increment_expected_ansi_instructions(&mut self, to: usize) {
- self.expected_ansi_instructions = to;
+ self.expected_ansi_instructions += to;
}
pub fn decrement_expected_ansi_instructions(&mut self, by: usize) {
self.expected_ansi_instructions = self.expected_ansi_instructions.saturating_sub(by);
@@ -26,6 +26,16 @@ impl StdinAnsiParser {
self.expected_ansi_instructions
}
pub fn parse(&mut self, key: Key, raw_bytes: Vec<u8>) -> Option<AnsiStdinInstructionOrKeys> {
+ if self.current_buffer.is_empty()
+ && (key != Key::Esc && key != Key::Alt(CharOrArrow::Char(']')))
+ {
+ // the first key of a sequence is always Esc, but termwiz interprets esc + ] as Alt+]
+ self.current_buffer.push((key, raw_bytes));
+ self.expected_ansi_instructions = 0;
+ return Some(AnsiStdinInstructionOrKeys::Keys(
+ self.current_buffer.drain(..).collect(),
+ ));
+ }
if let Key::Char('t') = key {
self.current_buffer.push((key, raw_bytes));
match AnsiStdinInstructionOrKeys::pixel_dimensions_from_keys(&self.current_buffer) {
@@ -41,7 +51,7 @@ impl StdinAnsiParser {
))
}
}
- } else if let Key::Alt(CharOrArrow::Char('\\')) = key {
+ } else if let Key::Alt(CharOrArrow::Char('\\')) | Key::Ctrl('g') = key {
match AnsiStdinInstructionOrKeys::color_sequence_from_keys(&self.current_buffer) {
Ok(color_instruction) => {
self.decrement_expected_ansi_instructions(1);
@@ -67,12 +77,6 @@ impl StdinAnsiParser {
}
}
fn key_is_valid(&self, key: Key) -> bool {
- if self.current_buffer.is_empty()
- && (key != Key::Esc && key != Key::Alt(CharOrArrow::Char(']')))
- {
- // the first key of a sequence is always Esc, but termwiz interprets esc + ] as Alt+]
- return false;
- }
match key {
Key::Esc => {
// this is a UX improvement