Struct cursive_tree_view::TreeView [] [src]

pub struct TreeView<T: Display + Debug> { /* fields omitted */ }

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);

Methods

impl<T: Display + Debug> TreeView<T>
[src]

Creates a new, empty TreeView.

Disables this view.

A disabled view cannot be selected.

Re-enables this view.

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.

Removes all items from this view, returning them.

Returns the number of items in this tree.

Returns true if this tree has no items.

Returns the index of the currently selected tree row.

None is returned in case of the tree being empty.

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.

Trait Implementations

impl<T: Display + Debug> View for TreeView<T>
[src]

Draws the view with the given printer (includes bounds) and focus.

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

This view is offered focus. Will it take it? Read more

Called when a key was pressed. Read more

Returns true if the view content changed since last layout phase. Read more

Finds the view identified by the given selector. Read more

Moves the focus to the view identified by the given selector. Read more