Skip to content

Commit

Permalink
tree: fix to tree_lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ynqa committed Feb 17, 2024
1 parent ede1e50 commit 54a5afe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ fn main() -> Result {
Node::new("baz"),
]))
.title("Select a directory or file")
.screen_lines(10)
.tree_lines(10)
.prompt()?;
println!("result: {:?}", p.run()?);
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion examples/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() -> Result {
Node::new("baz"),
]))
.title("Select a directory or file")
.screen_lines(10)
.tree_lines(10)
.prompt()?;
println!("result: {:?}", p.run()?);
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/core/tree/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub struct Renderer {
/// Style for un-selected line.
pub inactive_item_style: ContentStyle,

/// Window size.
pub screen_lines: Option<usize>,
/// Num of lines for rendering.
pub lines: Option<usize>,
}

impl Renderable for Renderer {
Expand Down Expand Up @@ -70,7 +70,7 @@ impl Renderable for Renderer {
.collect::<Vec<Graphemes>>();

let trimed = matrix.iter().map(|row| trim(width as usize, row)).collect();
Pane::new(trimed, self.tree.position(), self.screen_lines)
Pane::new(trimed, self.tree.position(), self.lines)
}

/// Default key bindings for tree.
Expand Down
6 changes: 3 additions & 3 deletions src/preset/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Tree {
unfolded_symbol: String::from("▼ "),
active_item_style: Style::new().fgc(Color::DarkCyan).build(),
inactive_item_style: Style::new().build(),
screen_lines: Default::default(),
lines: Default::default(),
},
}
}
Expand Down Expand Up @@ -63,8 +63,8 @@ impl Tree {
self
}

pub fn screen_lines(mut self, screen_lines: usize) -> Self {
self.tree_renderer.screen_lines = Some(screen_lines);
pub fn tree_lines(mut self, lines: usize) -> Self {
self.tree_renderer.lines = Some(lines);
self
}

Expand Down

0 comments on commit 54a5afe

Please sign in to comment.