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] {
'@' => 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 {

View file

@ -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;