summaryrefslogtreecommitdiffstats
path: root/src/layout.rs
diff options
context:
space:
mode:
authorKyohei Uto <im@kyoheiu.dev>2022-10-25 16:22:03 +0900
committerKyohei Uto <im@kyoheiu.dev>2022-10-26 04:50:59 +0900
commitb32355eff5a82c1f380c445da6cc688d8b86fbb3 (patch)
treeac24d27e0c0dfd87638273631814195d1af104eb /src/layout.rs
parentfc6703518898e2904cd67ecce460766bb5be7329 (diff)
Fix preview_contents
Diffstat (limited to 'src/layout.rs')
-rw-r--r--src/layout.rs43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/layout.rs b/src/layout.rs
index 3e3c1ac..6065143 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -141,6 +141,8 @@ 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));
@@ -150,15 +152,36 @@ impl Layout {
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;
+ }
+ }
+
+ }
+ }
}
/// Print text preview on the right half of the terminal (Experimental).
fn preview_image(&self, item: &ItemInfo, y: u16) -> Result<(), FxError> {
- let wxh = format!(
+ let wxh = match self.split {
+ Split::Vertical => {
+ format!(
"--size={}x{}",
self.preview_width,
self.terminal_row - BEGINNING_ROW
- );
+ )
+ }
+ Split::Horizontal => todo!(),
+ };
let file_path = item.file_path.to_str();
if file_path.is_none() {
@@ -171,11 +194,25 @@ impl Layout {
.output()?
.stdout;
let output = String::from_utf8(output).unwrap();
+
+ match self.split {
+ Split::Vertical => {
for (i, line) in output.lines().enumerate() {
- let next_line: u16 = BEGINNING_ROW + (i as u16) + 1;
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);
+ }
+
+ }
+ }
Ok(())
}