diff options
author | Kyohei Uto <kyoheiu@outlook.com> | 2022-10-13 06:01:56 +0900 |
---|---|---|
committer | Kyohei Uto <kyoheiu@outlook.com> | 2022-10-13 06:01:56 +0900 |
commit | 7806ece3a27b46d145fc7bb92fa4973f592acd2a (patch) | |
tree | 31c950e23c93a4186a2b473955ef684988cfa3d3 /src/layout.rs | |
parent | d9c0bafb085a8e47bde46739cae47a92936a488c (diff) |
Remove termion from layout.rs
Diffstat (limited to 'src/layout.rs')
-rw-r--r-- | src/layout.rs | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/layout.rs b/src/layout.rs index 22a5478..edf55f4 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -3,7 +3,7 @@ use super::errors::FxError; use super::functions::*; use super::state::{FileType, ItemInfo, BEGINNING_ROW}; use super::term::*; -use termion::{clear, color, cursor}; +use crossterm::style::Color; /// cf: https://docs.rs/image/latest/src/image/image.rs.html#84-112 pub const MAX_SIZE_TO_PREVIEW: u64 = 1_000_000_000; @@ -27,7 +27,7 @@ pub struct Layout { pub time_start_pos: u16, pub use_full: Option<bool>, pub option_name_len: Option<usize>, - pub colors: Color, + pub colors: ConfigColor, pub preview: bool, pub preview_start_column: u16, pub preview_width: u16, @@ -121,12 +121,9 @@ impl Layout { //Print preview (wrapping) for (i, line) in content.iter().enumerate() { move_to(self.preview_start_column, BEGINNING_ROW + i as u16); - print!( - "{}{}{}", - color::Fg(color::LightBlack), - line, - color::Fg(color::Reset) - ); + set_color(Some(Color::DarkGrey), None); + print!("{}", line); + reset_color(); if BEGINNING_ROW + i as u16 == self.terminal_row - 1 { break; } @@ -155,7 +152,7 @@ impl Layout { for (i, line) in output.lines().enumerate() { let next_line: u16 = BEGINNING_ROW + (i as u16) + 1; print!("{}", line); - print!("{}", cursor::Goto(self.preview_start_column, next_line)); + move_to(self.preview_start_column, next_line); } Ok(()) } @@ -163,13 +160,10 @@ impl Layout { /// Clear the preview space. fn clear_preview(&self, preview_start_column: u16) { for i in 0..self.terminal_row { - print!( - "{}", - cursor::Goto(preview_start_column, BEGINNING_ROW + i as u16) - ); - print!("{}", clear::UntilNewline); + move_to(preview_start_column, BEGINNING_ROW + i as u16); + clear_until_newline(); } - print!("{}", cursor::Goto(self.preview_start_column, BEGINNING_ROW)); + move_to(self.preview_start_column, BEGINNING_ROW); } } |