summaryrefslogtreecommitdiffstats
path: root/src/layout.rs
diff options
context:
space:
mode:
authorKyohei Uto <im@kyoheiu.dev>2022-10-26 05:14:11 +0900
committerKyohei Uto <im@kyoheiu.dev>2022-10-26 05:14:11 +0900
commitaafb063028fed5c0125373c0ce4bcbfea05b0859 (patch)
tree92784a7c43fe39f9c31663738fa9dc242e7a85b6 /src/layout.rs
parenta8c7837d6cc38983274766b8393cf1a366f59477 (diff)
Fix: Remove extra char of current dir info
Diffstat (limited to 'src/layout.rs')
-rw-r--r--src/layout.rs77
1 files changed, 37 insertions, 40 deletions
diff --git a/src/layout.rs b/src/layout.rs
index 6065143..f1a1528 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -103,8 +103,9 @@ impl Layout {
/// Print item name at the top.
fn print_file_name(&self, item: &ItemInfo) {
- move_to(self.preview_start_column, 1);
+ move_to(self.preview_start_column - 1, 1);
clear_until_newline();
+ move_right(1);
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();
@@ -143,29 +144,27 @@ impl Layout {
//Print preview (wrapping)
match self.split {
Split::Vertical => {
- for (i, line) in content.iter().enumerate() {
- move_to(self.preview_start_column, BEGINNING_ROW + i as u16);
- set_color(&TermColor::ForeGround(&Colorname::LightBlack));
- print!("{}", line);
- reset_color();
- if BEGINNING_ROW + i as u16 == self.terminal_row - 1 {
- break;
+ for (i, line) in content.iter().enumerate() {
+ move_to(self.preview_start_column, BEGINNING_ROW + i as u16);
+ set_color(&TermColor::ForeGround(&Colorname::LightBlack));
+ print!("{}", line);
+ reset_color();
+ if BEGINNING_ROW + i as u16 == self.terminal_row - 1 {
+ break;
+ }
+ }
}
- }
-
- },
Split::Horizontal => {
- for (i, line) in content.iter().enumerate() {
- let row = self.preview_start_row + i as u16;
- move_to(1, row);
- set_color(&TermColor::ForeGround(&Colorname::LightBlack));
- print!("{}", line);
- reset_color();
- if row == self.terminal_row - 1 {
- break;
- }
- }
-
+ for (i, line) in content.iter().enumerate() {
+ let row = self.preview_start_row + i as u16;
+ move_to(1, row);
+ set_color(&TermColor::ForeGround(&Colorname::LightBlack));
+ print!("{}", line);
+ reset_color();
+ if row == self.terminal_row - 1 {
+ break;
+ }
+ }
}
}
}
@@ -174,11 +173,11 @@ impl Layout {
fn preview_image(&self, item: &ItemInfo, y: u16) -> Result<(), FxError> {
let wxh = match self.split {
Split::Vertical => {
- format!(
- "--size={}x{}",
- self.preview_width,
- self.terminal_row - BEGINNING_ROW
- )
+ format!(
+ "--size={}x{}",
+ self.preview_width,
+ self.terminal_row - BEGINNING_ROW
+ )
}
Split::Horizontal => todo!(),
};
@@ -197,20 +196,18 @@ impl Layout {
match self.split {
Split::Vertical => {
- for (i, line) in output.lines().enumerate() {
- print!("{}", line);
- let next_line: u16 = BEGINNING_ROW + (i as u16) + 1;
- move_to(self.preview_start_column, next_line);
- }
-
- },
+ for (i, line) in output.lines().enumerate() {
+ print!("{}", line);
+ let next_line: u16 = BEGINNING_ROW + (i as u16) + 1;
+ move_to(self.preview_start_column, next_line);
+ }
+ }
Split::Horizontal => {
- for (i, line) in output.lines().enumerate() {
- print!("{}", line);
- let next_line: u16 = self.preview_start_row + (i as u16) + 1;
- move_to(1, next_line);
- }
-
+ for (i, line) in output.lines().enumerate() {
+ print!("{}", line);
+ let next_line: u16 = self.preview_start_row + (i as u16) + 1;
+ move_to(1, next_line);
+ }
}
}
Ok(())