aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ansi.rs6
-rw-r--r--src/term.rs24
2 files changed, 24 insertions, 6 deletions
diff --git a/src/ansi.rs b/src/ansi.rs
index 389ab94f..cd61c6d5 100644
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -551,13 +551,11 @@ impl Parser {
match raw[0] {
'@' => handler.insert_blank(arg_or_default!(args[0], 1)),
'A' => {
- debug_csi!();
handler.move_up(arg_or_default!(args[0], 1));
},
'B' | 'e' => handler.move_down(arg_or_default!(args[0], 1)),
'c' => handler.identify_terminal(),
'C' | 'a' => {
- debug_csi!();
handler.move_forward(arg_or_default!(args[0], 1))
},
'D' => handler.move_backward(arg_or_default!(args[0], 1)),
@@ -572,7 +570,7 @@ impl Parser {
handler.clear_tabs(mode);
},
- 'G' | '`' => handler.goto_col(arg_or_default!(args[0], 1)),
+ 'G' | '`' => handler.goto_col(arg_or_default!(args[0], 1) - 1),
'H' | 'f' => {
let y = arg_or_default!(args[0], 1);
let x = arg_or_default!(args[1], 1);
@@ -613,7 +611,7 @@ impl Parser {
'X' => handler.erase_chars(arg_or_default!(args[0], 1)),
'P' => handler.delete_chars(arg_or_default!(args[0], 1)),
'Z' => handler.move_backward_tabs(arg_or_default!(args[0], 1)),
- 'd' => handler.goto_row(arg_or_default!(args[0], 1)),
+ 'd' => handler.goto_row(arg_or_default!(args[0], 1) - 1),
'h' => {
let mode = Mode::from_primitive(args[0]);
match mode {
diff --git a/src/term.rs b/src/term.rs
index 2838c668..5b00acfd 100644
--- a/src/term.rs
+++ b/src/term.rs
@@ -149,6 +149,11 @@ impl Term {
/// Set character in current cursor position
fn set_char(&mut self, c: char) {
+ if self.cursor.x == self.grid.num_cols() as u16 {
+ self.cursor.y += 1;
+ self.cursor.x = 0;
+ }
+
let cell = &mut self.grid[self.cursor];
cell.c = c;
cell.fg = self.fg;
@@ -175,8 +180,17 @@ impl ansi::Handler for Term {
println!("goto: x={}, y={}", x, y);
self.cursor.goto(x as u16, y as u16);
}
- fn goto_row(&mut self, y: i64) { println!("goto_row: {}", y); }
- fn goto_col(&mut self, x: i64) { println!("goto_col: {}", x); }
+ fn goto_row(&mut self, y: i64) {
+ println!("goto_row: {}", y);
+ let x = self.cursor_x();
+ self.cursor.goto(x, y as u16);
+ }
+ fn goto_col(&mut self, x: i64) {
+ println!("goto_col: {}", x);
+ let y = self.cursor_y();
+ self.cursor.goto(x as u16, y);
+ }
+
fn insert_blank(&mut self, num: i64) { println!("insert_blank: {}", num); }
fn move_up(&mut self, rows: i64) {
@@ -325,6 +339,12 @@ impl ansi::Handler for Term {
Attr::Background(named_color) => {
self.bg = COLORS[named_color as usize];
},
+ Attr::ForegroundSpec(rgb) => {
+ self.fg = rgb;
+ },
+ Attr::BackgroundSpec(rgb) => {
+ self.bg = rgb;
+ },
Attr::Reset => {
self.fg = DEFAULT_FG;
self.bg = DEFAULT_BG;