Struct cursive_tree_view::TreeView
source ·
[−]Expand description
A low level tree view.
Each view provides a number of low level methods for manipulating its contained items and their structure.
All interactions are performed via relative (i.e. visual) row
indices which
makes reasoning about behaviour much easier in the context of interactive
user manipulation of the tree.
Examples
let mut tree = TreeView::new();
tree.insert_item("root".to_string(), Placement::LastChild, 0);
tree.insert_item("1".to_string(), Placement::LastChild, 0);
tree.insert_item("2".to_string(), Placement::LastChild, 1);
tree.insert_item("3".to_string(), Placement::LastChild, 2);
Implementations
Enable or disable this view.
Returns true
if this view is enabled.
Sets a callback to be used when <Enter>
is pressed while an item
is selected.
Example
tree.set_on_submit(|siv: &mut Cursive, row: usize| {
});
Sets a callback to be used when <Enter>
is pressed while an item
is selected.
Chainable variant.
Example
tree.on_submit(|siv: &mut Cursive, row: usize| {
});
Sets a callback to be used when an item is selected.
Example
tree.set_on_select(|siv: &mut Cursive, row: usize| {
});
Sets a callback to be used when an item is selected.
Chainable variant.
Example
tree.on_select(|siv: &mut Cursive, row: usize| {
});
Sets a callback to be used when an item has its children collapsed or expanded.
Example
tree.set_on_collapse(|siv: &mut Cursive, row: usize, is_collapsed: bool, children: usize| {
});
Sets a callback to be used when an item has its children collapsed or expanded.
Chainable variant.
Example
tree.on_collapse(|siv: &mut Cursive, row: usize, is_collapsed: bool, children: usize| {
});
Removes all items from this view, returning them.
Returns the index of the currently selected tree row.
None
is returned in case of the tree being empty.
Returns position on the x axis of the symbol (first character of an item) at the given row.
None
is returned in case the specified row
does not visually exist.
Returns total width (including the symbol) of the item at the given row.
None
is returned in case the specified row
does not visually exist.
Selects the row at the specified index.
Selects the row at the specified index.
Chainable variant.
Returns a immutable reference to the item at the given row.
None
is returned in case the specified row
does not visually exist.
Returns a mutable reference to the item at the given row.
None
is returned in case the specified row
does not visually exist.
Inserts a new item
at the given row
with the specified
Placement
, returning the visual row of the item
occupies after its insertion.
None
will be returned in case the item is not visible after insertion
due to one of its parents being in a collapsed state.
Inserts a new container
at the given row
with the specified
Placement
, returning the visual row of the
container occupies after its insertion.
A container is identical to a normal item except for the fact that it can always be collapsed even if it does not contain any children.
Note: If the container is not visible because one of its parents is collapsed
None
will be returned since there is no visible row for the container to occupy.
Removes the item at the given row
along with all of its children.
The returned vector contains the removed items in top to bottom order.
None
is returned in case the specified row
does not visually exist.
Removes all children of the item at the given row
.
The returned vector contains the removed children in top to bottom order.
None
is returned in case the specified row
does not visually exist.
Extracts the item at the given row
from the tree.
All of the items children will be moved up one level within the tree.
None
is returned in case the specified row
does not visually exist.
Collapses the children of the given row
.
Expands the children of the given row
.
Collapses or expands the children of the given row
.
Collapses or expands the children of the given row
.
Chained variant.
Select item n
rows down from the one currently selected.
Returns position of the parent of the item located in row
.
None
is returned if row
is not currenlty visible or if the item has no ancestors.
Trait Implementations
Draws the view with the given printer (includes bounds) and focus. Read more
Returns the minimum size the view requires with the given restrictions. Read more
Called once the size for this view has been decided. Read more
Attempt to give this view the focus. Read more
Called when an event is received (key press, mouse event, …). Read more
What part of the view is important and should be visible? Read more
Should return true
if the view content changed since the last call
to layout()
. Read more
fn call_on_any(
&mut self,
&Selector<'_>,
&'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
fn call_on_any(
&mut self,
&Selector<'_>,
&'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
Runs a closure on the view identified by the given selector. Read more
Moves the focus to the view identified by the given selector. Read more
Auto Trait Implementations
impl<T> !RefUnwindSafe for TreeView<T>
impl<T> !UnwindSafe for TreeView<T>
Blanket Implementations
Mutably borrows from an owned value. Read more
Returns a Box<View>
.
Wraps self
in a ResizedView
with the given size constraints.
Wraps self
into a fixed-size ResizedView
.
Wraps self
into a fixed-width ResizedView
.
Wraps self
into a fixed-width ResizedView
.
Wraps self
into a full-screen ResizedView
.
Wraps self
into a full-width ResizedView
.
Wraps self
into a full-height ResizedView
.
Wraps self
into a limited-size ResizedView
.
Wraps self
into a limited-width ResizedView
.
Wraps self
into a limited-height ResizedView
.
Wraps self
into a ResizedView
at least sized size
.
Wraps self
in a ResizedView
at least min_width
wide.
Wraps self
in a ResizedView
at least min_height
tall.
Wraps self
in a ScrollView
.
Calls the given closure and return the result. Read more
Calls the given closure on self
.