tree (cellium v0.1.0)

View Source

Tree widget module for rendering hierarchical data.

This module provides an interactive tree widget that handles keyboard events for navigation, expansion, and selection.

Usage

Basic tree:

{tree, [{id, my_tree}, {nodes, [
    {"Root", [
        {"Child 1", []},
        {"Child 2", [
            {"Grandchild", []}
        ]}
    ]}
]}]}

Properties

  • nodes (list): The tree structure.
  • expanded_ids (list): IDs of nodes that are currently expanded.
  • selected_index (integer): The index of the currently selected visible item.
  • scroll_offset (integer): The index of the first item to display.

Summary

Functions

Handles keyboard events for the tree.

Creates a new tree widget.

Creates a new tree widget with the specified nodes.

Renders the tree widget.

Functions

handle_event/2

-spec handle_event(term(), map()) -> map().

Handles keyboard events for the tree.

new(Id)

-spec new(term()) -> map().

Creates a new tree widget.

new(Id, Nodes)

-spec new(term(), list()) -> map().

Creates a new tree widget with the specified nodes.

render(Widget, Buffer)

-spec render(map(), map()) -> map().

Renders the tree widget.

render_focused(Widget, Buffer)

-spec render_focused(map(), map()) -> map().