1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Minor updates to terminal handling

Properly handles goto_col and goto_row. Additionally, input wrapping is
handled.

Truecolor specs are now set appropriately.
This commit is contained in:
Joe Wilm 2016-06-06 15:13:45 -07:00
parent e5aeae69aa
commit 6636cf6b9f
No known key found for this signature in database
GPG key ID: 39B57C6972F518DA
2 changed files with 24 additions and 6 deletions

View file

@ -551,13 +551,11 @@ impl Parser {
match raw[0] { match raw[0] {
'@' => handler.insert_blank(arg_or_default!(args[0], 1)), '@' => handler.insert_blank(arg_or_default!(args[0], 1)),
'A' => { 'A' => {
debug_csi!();
handler.move_up(arg_or_default!(args[0], 1)); handler.move_up(arg_or_default!(args[0], 1));
}, },
'B' | 'e' => handler.move_down(arg_or_default!(args[0], 1)), 'B' | 'e' => handler.move_down(arg_or_default!(args[0], 1)),
'c' => handler.identify_terminal(), 'c' => handler.identify_terminal(),
'C' | 'a' => { 'C' | 'a' => {
debug_csi!();
handler.move_forward(arg_or_default!(args[0], 1)) handler.move_forward(arg_or_default!(args[0], 1))
}, },
'D' => handler.move_backward(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); 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' => { 'H' | 'f' => {
let y = arg_or_default!(args[0], 1); let y = arg_or_default!(args[0], 1);
let x = arg_or_default!(args[1], 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)), 'X' => handler.erase_chars(arg_or_default!(args[0], 1)),
'P' => handler.delete_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)), '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' => { 'h' => {
let mode = Mode::from_primitive(args[0]); let mode = Mode::from_primitive(args[0]);
match mode { match mode {

View file

@ -149,6 +149,11 @@ impl Term {
/// Set character in current cursor position /// Set character in current cursor position
fn set_char(&mut self, c: char) { 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]; let cell = &mut self.grid[self.cursor];
cell.c = c; cell.c = c;
cell.fg = self.fg; cell.fg = self.fg;
@ -175,8 +180,17 @@ impl ansi::Handler for Term {
println!("goto: x={}, y={}", x, y); println!("goto: x={}, y={}", x, y);
self.cursor.goto(x as u16, y as u16); self.cursor.goto(x as u16, y as u16);
} }
fn goto_row(&mut self, y: i64) { println!("goto_row: {}", y); } fn goto_row(&mut self, y: i64) {
fn goto_col(&mut self, x: i64) { println!("goto_col: {}", x); } 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 insert_blank(&mut self, num: i64) { println!("insert_blank: {}", num); }
fn move_up(&mut self, rows: i64) { fn move_up(&mut self, rows: i64) {
@ -325,6 +339,12 @@ impl ansi::Handler for Term {
Attr::Background(named_color) => { Attr::Background(named_color) => {
self.bg = COLORS[named_color as usize]; self.bg = COLORS[named_color as usize];
}, },
Attr::ForegroundSpec(rgb) => {
self.fg = rgb;
},
Attr::BackgroundSpec(rgb) => {
self.bg = rgb;
},
Attr::Reset => { Attr::Reset => {
self.fg = DEFAULT_FG; self.fg = DEFAULT_FG;
self.bg = DEFAULT_BG; self.bg = DEFAULT_BG;