### Run Container Example (Rust) Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md This snippet provides the command to execute the container component example. It allows users to observe the container's behavior and how it holds other components. ```rust cargo run --example container ``` -------------------------------- ### Run Checkbox Example (Rust) Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md This snippet shows the command to run the checkbox component example. It's used to see the checkbox functionality in a live environment. ```rust cargo run --example checkbox ``` -------------------------------- ### Run Chart Example (Rust) Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md This snippet demonstrates how to run the chart component example using Cargo. It shows the command to execute for viewing the chart in action. ```rust cargo run --example chart ``` -------------------------------- ### Run Table Example Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md This command demonstrates the functionality of the Table component, allowing users to view and interact with a scrollable table of data. ```bash cargo run --example table ``` -------------------------------- ### Run Textarea Example Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md This command demonstrates the functionality of the Textarea component, allowing users to view and interact with a scrollable text area. ```bash cargo run --example textarea ``` -------------------------------- ### Spinner Component Example (Rust) Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Provides an example of the Spinner component, used to indicate loading states. It explains how to configure the spinner's character sequence and colors. ```rust cargo run --example spinner ``` -------------------------------- ### Sparkline Component Example (Rust) Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Shows how to implement a Sparkline chart to visualize data. This includes setting the dataset, title, colors, and width for the chart. ```rust cargo run --example sparkline ``` -------------------------------- ### Span Component Example (Rust) Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Illustrates the use of the Span component for displaying in-line text with various styles. It covers setting text content, alignment, and foreground/background colors. ```rust cargo run --example span ``` -------------------------------- ### Select Component Example (Rust) Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Demonstrates the usage of the Select component, allowing users to choose a single option from a list. It details how to set options, handle user input for selection, and retrieve the selected value. ```rust cargo run --example select ``` -------------------------------- ### Tui-Realm Radio Button Group Example Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Demonstrates the Radio component for creating selectable option groups. It allows navigation between options using arrow keys and returns the index of the selected item. ```rust cargo run --example radio ``` -------------------------------- ### Tui-Realm Paragraph Component Example Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Illustrates the Paragraph component, which renders text content with automatic word wrapping and supports styling. It functions as a block element, similar to HTML paragraphs. ```rust cargo run --example paragraph ``` -------------------------------- ### Tui-Realm List Component Example Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Demonstrates the use of the List component, which displays rows of text with scrolling capabilities. It requires the component to be active to scroll and supports various commands for navigation and state management. ```rust cargo run --example list ``` -------------------------------- ### Tui-Realm Progress Bar Component Example Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Shows how to use the Progress Bar component to display a visual gauge of progress, optionally with a label. The `Value` property expects a float between 0.0 and 1.0. ```rust cargo run --example progress_bar ``` -------------------------------- ### BarChart Component Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Documentation for the BarChart component, including its interactive modes, properties, and commands. ```APIDOC ## BarChart Component ### Description A chart with bars that can operate in "active" (default) or "disabled" mode. In disabled mode, the chart is not interactive. When displaying more data than can fit, users must update the data to show remaining entries. In active mode, any number of entries can be added, and navigation is possible using arrow keys, HOME, and END. ### Properties - `Background(Color)`: Sets the background color of the chart. - `Custom($BAR_CHART_BARS_GAP, Size)`: Sets the gap between bars. - `Custom($BAR_CHART_BARS_STYLE, Style)`: Sets the style for the bars. - `Custom($BAR_CHART_LABEL_STYLE, Style)`: Sets the style for the data labels. - `Custom($BAR_CHART_MAX_BARS, Length)`: Defines the maximum number of bars to display. If not provided, it defaults to the maximum allowed by the area width. - `Custom($BAR_CHART_VALUES_STYLE, Style)`: Sets the style for the data values. - `Dataset(Payload(LinkedList(Tup2(String, U64))))`: Sets the data for the chart as a list of tuples, where each tuple contains a label (String) and a value (U64). - `Disabled(Flag)`: Sets the chart to disabled mode, making it non-interactive. - `Foreground(Color)`: Sets the foreground color of the chart. - `Title(Title)`: Sets the title for the chart. - `Width(Size)`: Defines the width of the bars. ``` -------------------------------- ### Input Component: Text Input with Cursor Navigation Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md The Input component allows users to enter text with features like setting input length, type (number, password, text), and cursor navigation using arrow keys. It returns the input as a String or Number based on its type when its state is invoked. It supports various properties for customization like background, foreground, borders, placeholder, and title. ```rust use tui_realm_stdlib::input::{Input, InputType}; use tui_realm_stdlib::state::State; use tui_realm_stdlib::StateValue; use tui_realm_stdlib::types::{Color, Borders, InputLength}; fn main() { let mut input = Input::new(State::One(StateValue::String(""))); // Set input properties input .background(Color::Blue) .borders(Borders::new(true, true, true, true)) .input_length(InputLength::new(Some(5))) .input_type(InputType::Text) .title("Enter text:"); // Example of handling input events (conceptual) // let event = // ... get keyboard event ... // input.on_event(event); // Get current value // let current_value = input.state().unwrap().get_string(); // println!("Current input: {}", current_value); } ``` -------------------------------- ### Add tui-realm-stdlib to Cargo.toml Source: https://github.com/veeso/tui-realm-stdlib/blob/main/README.md This snippet shows how to add the tui-realm-stdlib crate to your project's Cargo.toml file. It also demonstrates how to specify a different backend like 'termion' if not using the default 'crossterm'. Ensure you have tui-realm version 2.0 or higher. ```toml tui-realm-stdlib = "3" ``` ```toml tui-realm-stdlib = { version = "3", default-features = false, features = [ "termion" ] } ``` ```toml tuirealm = "3" ``` -------------------------------- ### Canvas Component Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md Documentation for the Canvas component, used for drawing shapes within the terminal interface. ```APIDOC ## Canvas Component ### Description The Canvas component allows for drawing various shapes directly onto the terminal. It does not support any commands or have a state. ### Properties - `Background(Color)`: Sets the background color of the canvas. - `Borders(Borders)`: Configures the properties of the borders around the canvas. - `Custom($CANVAS_X_BOUNDS, Payload(Tup2(F64, F64)))`: Related to the viewport's X-axis bounds. Refer to tui-rs documentation for details. - `Custom($CANVAS_Y_BOUNDS, Payload(Tup2(F64, F64)))`: Related to the viewport's Y-axis bounds. Refer to tui-rs documentation for details. - `Foreground(Color)`: Sets the foreground color of the canvas. - `Shape(Payload(Vec(Shape)))`: Defines the shapes to be drawn on the canvas. This property accepts a vector of `Shape` objects. - `Title(Title)`: Sets the title for the canvas. ``` -------------------------------- ### Label Component: Displaying Text with Modifiers Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md The Label component is used to display simple text. It allows for customization of text alignment, colors (background and foreground), and text modifiers like bold or italic. It does not have commands or return any state. ```rust use tui_realm_stdlib::label::Label; use tui_realm_stdlib::types::{Color, Alignment, TextModifiers}; fn main() { let mut label = Label::new("Hello, Realm!"); // Set label properties label .background(Color::Black) .foreground(Color::Green) .alignment(Alignment::Center) .text_props(TextModifiers::BOLD | TextModifiers::ITALIC); } ``` -------------------------------- ### BarChart: Chart with bars Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md A chart component that displays data using bars. It supports active and disabled modes, allowing for interactive navigation or static display. Custom properties control bar spacing, styles, and the maximum number of bars shown. The dataset is provided as a list of (label, value) tuples. ```rust Component::new::() .prop(Attribute::Custom(Box::new(CustomProps::BarChartBarsGap), AttrValue::U32(2))) .prop(Attribute::Custom(Box::new(CustomProps::BarChartBarsStyle), AttrValue::Style(Style::default().fg(Color::Yellow)))) .prop(Attribute::Custom(Box::new(CustomProps::BarChartValuesStyle), AttrValue::Style(Style::default().fg(Color::Blue)))) .prop(Attribute::Custom(Box::new(CustomProps::BarChartLabelStyle), AttrValue::Style(Style::default().fg(Color::Green)))) .prop(Attribute::Title("My BarChart".to_string())) .prop(Attribute::Width(30)) .prop(Attribute::Dataset(Payload::new(vec![ ("Item 1".to_string(), 10), ("Item 2".to_string(), 25), ("Item 3".to_string(), 15), ("Item 4".to_string(), 30), ]))) ``` -------------------------------- ### Line Gauge Component: Progress Bar with Label Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md The Line Gauge component displays a progress bar, optionally with a label above it. It supports various styles for the line gauge itself. The progress value must be between 0.0 and 1.0. Properties include background, foreground, borders, text, text properties, title, value, and style. ```rust use tui_realm_stdlib::line_gauge::LineGauge; use tui_realm_stdlib::types::{Color, Borders, TextModifiers}; fn main() { let mut line_gauge = LineGauge::new(0.5); // Set line gauge properties line_gauge .background(Color::White) .borders(Borders::new(true, true, true, true)) .foreground(Color::Blue) .text("Progress:") .text_props(TextModifiers::BOLD) .title("Task Progress") .value(0.75); // Set progress to 75% // Example of setting line gauge style // line_gauge.style(LineGaugeStyle::Double); } ``` -------------------------------- ### Canvas: Draw shapes on the terminal Source: https://github.com/veeso/tui-realm-stdlib/blob/main/docs/components.md A component for drawing various shapes directly onto the terminal. It allows customization of background and foreground colors, borders, and defining shapes to be rendered. The component does not have built-in commands for interaction. ```rust Component::new::() .prop(Attribute::Width(50)) .prop(Attribute::Height(20)) .prop(Attribute::Title("My Canvas".to_string())) .prop(Attribute::Background(Color::Rgb(43, 43, 43))) .prop(Attribute::Foreground(Color::Rgb(203, 203, 203))) .prop(Attribute::Borders(Borders::default())) .prop(Attribute::Shape(Payload::new(vec![Shape::Rectangle(Rectangle::new((0, 0), (10, 10))), Shape::Circle(Circle::new((15, 15), 5))]))) .prop(Attribute::Custom(Box::new(CustomProps::CanvasXBounds), AttrValue::Payload(Payload::new((0f64, 10f64))))) .prop(Attribute::Custom(Box::new(CustomProps::CanvasYBounds), AttrValue::Payload(Payload::new((0f64, 10f64))))) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.