summaryrefslogtreecommitdiffstats
path: root/src/layout.rs
diff options
context:
space:
mode:
authorKyohei Uto <kyoheiu@outlook.com>2022-10-13 05:49:14 +0900
committerKyohei Uto <kyoheiu@outlook.com>2022-10-13 05:49:14 +0900
commitd9c0bafb085a8e47bde46739cae47a92936a488c (patch)
tree28ff841bd948021c5f397ae8a2c0e6cf6cb4bce3 /src/layout.rs
parent525e0846355283b28249bdb7f3b29507686d0859 (diff)
Add color function
Diffstat (limited to 'src/layout.rs')
-rw-r--r--src/layout.rs18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/layout.rs b/src/layout.rs
index 2f22b50..22a5478 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -2,6 +2,7 @@ use super::config::*;
use super::errors::FxError;
use super::functions::*;
use super::state::{FileType, ItemInfo, BEGINNING_ROW};
+use super::term::*;
use termion::{clear, color, cursor};
/// cf: https://docs.rs/image/latest/src/image/image.rs.html#84-112
@@ -65,10 +66,7 @@ impl Layout {
} else {
let help = format_txt(CHAFA_WARNING, self.terminal_column - 1, false);
for (i, line) in help.iter().enumerate() {
- print!(
- "{}",
- cursor::Goto(self.preview_start_column, BEGINNING_ROW + i as u16)
- );
+ move_to(self.preview_start_column, BEGINNING_ROW + i as u16);
print!("{}", line,);
if BEGINNING_ROW + i as u16 == self.terminal_row - 1 {
break;
@@ -87,11 +85,8 @@ impl Layout {
/// Print item name at the top.
fn print_file_name(&self, item: &ItemInfo) {
- print!(
- "{}{}",
- cursor::Goto(self.preview_start_column, 1),
- clear::UntilNewline
- );
+ move_to(self.preview_start_column, 1);
+ clear_until_newline();
let mut file_name = format!("[{}]", item.file_name);
if file_name.len() > self.preview_width.into() {
file_name = file_name.chars().take(self.preview_width.into()).collect();
@@ -125,10 +120,7 @@ impl Layout {
//Print preview (wrapping)
for (i, line) in content.iter().enumerate() {
- print!(
- "{}",
- cursor::Goto(self.preview_start_column, BEGINNING_ROW + i as u16)
- );
+ move_to(self.preview_start_column, BEGINNING_ROW + i as u16);
print!(
"{}{}{}",
color::Fg(color::LightBlack),