fix an issue with CR processing

This eliminates the zsh reversed % artifact issue.

Added a feature flag to turn on diagnostics even in release mode;

`cargo run --release --features debug-escape-sequences`
This commit is contained in:
Wez Furlong committed 2018-01-31 19:00:15 -08:00
1 parent 659ce4fc2d
commit a49e4b653b
4 files changed
+20 -4

No files matched your search

+3
View File
@@ -33,3 +33,6 @@ features = [
"keysyms",
]
version = "0.2.0"
[features]
debug-escape-sequences = ["term/debug-escape-sequences"]
+3
View File
@@ -10,3 +10,6 @@ unicode-segmentation = "1.2.0"
unicode-width = "0.1.4"
vte = "0.3.2"
[features]
# When enabled, print the results of parsing the input stream to stdout
debug-escape-sequences = []
+3 -1
View File
@@ -1,3 +1,5 @@
macro_rules! debug {
($($arg:tt)*) => (if cfg!(debug_assertions) { println!($($arg)*) })
($($arg:tt)*) => (if cfg!(feature="debug-escape-sequences") {
println!($($arg)*)
})
}
+11 -3
View File
@@ -772,6 +772,7 @@ impl Terminal {
impl vte::Perform for TerminalState {
/// Draw a character to the screen
fn print(&mut self, c: char) {
debug!("print {:x} {}", c as u32, c);
if self.wrap_next {
// TODO: remember that this was a wrapped line in the attributes?
self.new_line(true);
@@ -793,14 +794,14 @@ impl vte::Perform for TerminalState {
}
fn execute(&mut self, byte: u8) {
debug!("execute {:02x}", byte);
match byte {
b'\n' | 0x0b /* VT */ | 0x0c /* FF */ => {
self.new_line(true /* TODO: depend on terminal mode */)
}
b'\r' => {
b'\r' => /* CR */ {
let row = self.cursor_y;
self.screen_mut().dirty_line(row);
self.cursor_x = 0;
self.set_cursor_pos(0, row);
}
0x08 /* BS */ => {
self.delta_cursor_pos(-1, 0);
@@ -964,6 +965,13 @@ impl vte::Perform for TerminalState {
}
fn esc_dispatch(&mut self, params: &[i64], intermediates: &[u8], _ignore: bool, byte: u8) {
debug!(
"ESC params={:?}, intermediates={:?} b={:02x} {}",
params,
intermediates,
byte,
byte as char
);
// Sequences from both of these sections show up in this handler:
// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-C1-_8-Bit_-Control-Characters
// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Controls-beginning-with-ESC