### Development Setup Source: https://github.com/ratatui/tui-widgets/blob/main/CONTRIBUTING.md Steps to clone the repository and run initial tests. This is the standard setup for Rust projects. ```shell git clone https://github.com/ratatui/tui-widgets cd tui-widgets cargo test ``` -------------------------------- ### Run Card Widget Example Source: https://github.com/ratatui/tui-widgets/blob/main/tui-cards/README.md Shows the command to run the example provided with the tui-cards crate to see the card widget in action. ```shell cargo run --example card ``` -------------------------------- ### Basic Scrollable Widget Implementation Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollview/README.md Demonstrates how to create a scrollable view containing line numbers and text content. This example shows the basic setup for a StatefulWidget that utilizes ScrollView. ```rust use std::iter; use ratatui::layout::Size; use ratatui::prelude::*; use ratatui::widgets::* use tui_scrollview::{ScrollView, ScrollViewState}; struct MyScrollableWidget; impl StatefulWidget for MyScrollableWidget { type State = ScrollViewState; fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) { // 100 lines of text let line_numbers = (1..=100).map(|i| format!(‘{:>3} ‘, i)).collect::(); let content = iter::repeat("Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n") .take(100) .collect::(); let content_size = Size::new(100, 30); let mut scroll_view = ScrollView::new(content_size); // the layout doesn't have to be hardcoded like this, this is just an example scroll_view.render_widget(Paragraph::new(line_numbers), Rect::new(0, 0, 5, 100)); scroll_view.render_widget(Paragraph::new(content), Rect::new(5, 0, 95, 100)); scroll_view.render(buf.area, buf, state); } } ``` -------------------------------- ### Install tui-prompts Source: https://github.com/ratatui/tui-widgets/blob/main/tui-prompts/README.md Add the ratatui, tui-prompts, and crossterm crates to your project dependencies. ```shell cargo add ratatui tui-prompts crossterm ``` -------------------------------- ### Install tui-bar-graph Source: https://github.com/ratatui/tui-widgets/blob/main/tui-bar-graph/README.md Add the ratatui and tui-bar-graph crates to your Cargo.toml file. ```shell cargo add ratatui tui-bar-graph ``` -------------------------------- ### Install tui-big-text Source: https://github.com/ratatui/tui-widgets/blob/main/tui-big-text/README.md Add the ratatui and tui-big-text crates to your project dependencies. ```shell cargo add ratatui tui-big-text ``` -------------------------------- ### Install tui-popup Source: https://github.com/ratatui/tui-widgets/blob/main/tui-popup/README.md Add the tui-popup crate to your project dependencies. ```shell cargo add tui-popup ``` -------------------------------- ### Text Prompt Example Source: https://github.com/ratatui/tui-widgets/blob/main/tui-prompts/README.md Demonstrates how to use the TextPrompt widget for username, password, and invisible input fields. It requires defining a state for each prompt and rendering them within a split UI layout. ```rust use ratatui::layout::{Constraint, Direction, Layout, Rect}; use ratatui::Frame; use tui_prompts::{Prompt, TextPrompt, TextRenderStyle, TextState}; struct App<'a> { username_state: TextState<'a>, password_state: TextState<'a>, invisible_state: TextState<'a>, } impl<'a> App<'a> { fn draw_ui(&mut self, frame: &mut Frame) { let (username_area, password_area, invisible_area) = split_layout(frame.area()); TextPrompt::from("Username") .draw(frame, username_area, &mut self.username_state); TextPrompt::from("Password") .with_render_style(TextRenderStyle::Password) .draw(frame, password_area, &mut self.password_state); TextPrompt::from("Invisible") .with_render_style(TextRenderStyle::Invisible) .draw(frame, invisible_area, &mut self.invisible_state); } } fn split_layout(area: Rect) -> (Rect, Rect, Rect) { let rows = Layout::default() .direction(Direction::Vertical) .constraints([ Constraint::Length(1), Constraint::Length(1), Constraint::Length(1), ]) .split(area); (rows[0], rows[1], rows[2]) } ``` -------------------------------- ### Install tui-scrollbar Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/README.md Add the tui-scrollbar crate to your project dependencies using cargo. ```shell cargo add tui-scrollbar ``` -------------------------------- ### Basic QR Code Widget Usage in Ratatui Source: https://github.com/ratatui/tui-widgets/blob/main/tui-qrcode/README.md This example demonstrates how to integrate the QrCodeWidget into a Ratatui application. It sets up a terminal, renders a QR code for a given URL, and allows the user to exit by pressing any key. ```rust use qrcode::QrCode; use ratatui::crossterm::event; use ratatui::{DefaultTerminal, Frame}; use tui_qrcode::{Colors, QrCodeWidget}; fn main() -> color_eyre::Result<()> { color_eyre::install()?; let terminal = ratatui::init(); let result = run(terminal); ratatui::restore(); result } fn run(mut terminal: DefaultTerminal) -> color_eyre::Result<()> { loop { terminal.draw(render)?; if matches!(event::read()?, event::Event::Key(_)) { break Ok(()) } } } fn render(frame: &mut Frame) { let qr_code = QrCode::new("https://ratatui.rs").expect("failed to create QR code"); let widget = QrCodeWidget::new(qr_code).colors(Colors::Inverted); frame.render_widget(widget, frame.area()); } ``` -------------------------------- ### Install tui-scrollview Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollview/README.md Add the tui-scrollview crate to your project dependencies using cargo. ```shell cargo add tui-scrollview ``` -------------------------------- ### BigText Widget Alignment Configuration Source: https://github.com/ratatui/tui-widgets/blob/main/tui-big-text/README.md Examples demonstrating how to set text alignment for BigText widgets. Available alignments are left, center, and right. ```rust BigText::builder().left_aligned(); ``` ```rust BigText::builder().centered(); ``` ```rust BigText::builder().right_aligned(); ``` -------------------------------- ### Render a Vertical ScrollBar Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/README.md A minimal example demonstrating how to render a vertical ScrollBar into a buffer with a fixed track size and offset. Use this as a template when only a thumb and track are needed. ```rust use ratatui_core::buffer::Buffer; use ratatui_core::layout::Rect; use ratatui_core::widgets::Widget; use tui_scrollbar::{ScrollBar, ScrollBarArrows, ScrollLengths}; let area = Rect::new(0, 0, 1, 6); let lengths = ScrollLengths { content_len: 120, viewport_len: 30, }; let scrollbar = ScrollBar::vertical(lengths) .arrows(ScrollBarArrows::Both) .offset(45); let mut buffer = Buffer::empty(area); scrollbar.render(area, &mut buffer); ``` -------------------------------- ### Install tui-qrcode and qrcode Source: https://github.com/ratatui/tui-widgets/blob/main/tui-qrcode/README.md Add the tui-qrcode and qrcode crates to your Cargo.toml. It's recommended to disable the default features of the qrcode crate as they are not needed for terminal rendering. ```shell cargo add qrcode tui-qrcode --no-default-features ``` -------------------------------- ### BigText Widget Pixel Size Configuration Source: https://github.com/ratatui/tui-widgets/blob/main/tui-big-text/README.md Examples showing how to configure the PixelSize for BigText widgets. PixelSize controls how many character cells represent a single pixel of the font. ```rust BigText::builder().pixel_size(PixelSize::Full); ``` ```rust BigText::builder().pixel_size(PixelSize::HalfHeight); ``` ```rust BigText::builder().pixel_size(PixelSize::Quadrant); ``` -------------------------------- ### Scrollbar Arrow Configuration Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Configuration options for scrollbar arrow placement, allowing 'None', 'Start', 'End', or 'Both'. ```rust Add `ScrollBarArrows` (or similar) to configure arrow placement (`None`, `Start`, `End`, `Both`). ``` -------------------------------- ### Cargo.toml Feature Flag for Crossterm Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Example from tui-popup's Cargo.toml showing how a 'crossterm' feature flag is used to gate mouse event handling. ```toml [features] crossterm = [] ``` -------------------------------- ### Scrollbar Glyph Assertions in tui-scrollview Tests Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Example of test assertions in tui-scrollview that check for specific scrollbar glyphs, indicating the visual design inherited from Ratatui. ```rust assert_eq!(buffer.get_string(rect.x, rect.y, rect.width, rect.height, true), "▲█║▼"); ``` -------------------------------- ### Create and Render a Card Widget Source: https://github.com/ratatui/tui-widgets/blob/main/tui-cards/README.md Demonstrates how to create a new Card widget with a specific rank and suit, and then render it within a Ratatui frame. ```rust use tui_cards::{Card, Rank, Suit}; let card = Card::new(Rank::Ace, Suit::Spades); frame.render_widget(&card, frame.area()); ``` -------------------------------- ### Basic BigText Widget Rendering Source: https://github.com/ratatui/tui-widgets/blob/main/tui-big-text/README.md Demonstrates how to create a BigText widget with custom text lines, styling, and pixel size, then render it to the frame. ```rust use ratatui::prelude::{Frame, Style, Stylize}; use tui_big_text::{BigText, PixelSize}; fn render(frame: &mut Frame) { let big_text = BigText::builder() .pixel_size(PixelSize::Full) .style(Style::new().blue()) .lines(vec![ "Hello".red().into(), "World".white().into(), "~~~~~".into(), ]) .build(); frame.render_widget(big_text, frame.size()); } ``` -------------------------------- ### Create and Render BoxChar Widget Source: https://github.com/ratatui/tui-widgets/blob/main/tui-box-text/README.md Demonstrates how to create a BoxChar widget and render it into a given area. This is the primary usage pattern for the widget. ```rust use tui_box_text::BoxChar; let letter = BoxChar::new('A'); frame.render_widget(&letter, frame.area()); ``` -------------------------------- ### Render a Basic Popup Source: https://github.com/ratatui/tui-widgets/blob/main/tui-popup/README.md Build and render a simple popup widget with a title and custom style. ```rust use ratatui::style::{Style, Stylize}; use ratatui::Frame; use tui_popup::Popup; fn render_popup(frame: &mut Frame) { let popup = Popup::new("Press any key to exit") .title("tui-popup demo") .style(Style::new().white().on_blue()); frame.render_widget(popup, frame.area()); } ``` -------------------------------- ### Render Owned Popup with Value Bodies Source: https://github.com/ratatui/tui-widgets/blob/main/BREAKING_CHANGES.md Demonstrates rendering an owned `Popup` with value bodies, which remains functional. ```rust frame.render_widget(Popup::new("Hello"), area); frame.render_stateful_widget(Popup::new("Hello"), area, &mut state); ``` -------------------------------- ### Automated Documentation Generation Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Command to generate documentation for the tui-scrollbar package with all features enabled. ```bash cargo doc --all-features --workspace ``` -------------------------------- ### Automated Verification Command (All Features) Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Command to run all unit tests for the tui-scrollbar package with all features enabled. ```bash cargo test -p tui-scrollbar --all-features -- --nocapture ``` -------------------------------- ### Render Popup by Reference with Reference-Compatible Bodies Source: https://github.com/ratatui/tui-widgets/blob/main/BREAKING_CHANGES.md Shows rendering a `Popup` by reference when its body implements `Widget` for references. ```rust let popup = Popup::new(Text::from("Hello")); frame.render_widget(&popup, area); frame.render_stateful_widget(&popup, area, &mut state); ``` -------------------------------- ### Render a Bar Graph Widget Source: https://github.com/ratatui/tui-widgets/blob/main/tui-bar-graph/README.md Create and render a BarGraph widget with custom data, bar style, and color mode. Ensure the necessary imports are included. ```rust use tui_bar_graph::{BarGraph, BarStyle, ColorMode}; let data = vec![0.0, 0.1, 0.2, 0.3, 0.4, 0.5]; let bar_graph = BarGraph::new(data) .with_gradient(colorgrad::preset::turbo()) .with_bar_style(BarStyle::Braille) .with_color_mode(ColorMode::VerticalGradient); frame.render_widget(bar_graph, area); ``` -------------------------------- ### Run All Tests Source: https://github.com/ratatui/tui-widgets/blob/main/CONTRIBUTING.md Executes all tests within the workspace, including all features. Ensures comprehensive test coverage. ```shell cargo test --all-features --workspace ``` -------------------------------- ### Run Clippy for Linting Source: https://github.com/ratatui/tui-widgets/blob/main/CONTRIBUTING.md Executes Clippy, a Rust linter, across all targets and features of the workspace. Helps identify code style and potential errors. ```shell cargo clippy --all-targets --all-features --workspace ``` -------------------------------- ### Render Popup with Scrollable Paragraph Content Source: https://github.com/ratatui/tui-widgets/blob/main/tui-popup/README.md Display a popup containing a scrollable Paragraph widget, demonstrating content wrapping. ```rust use ratatui::prelude::*; use ratatui::text::{Span, Text}; use ratatui::widgets::Paragraph; use tui_popup::{KnownSizeWrapper, Popup}; fn render_scrollable_popup(frame: &mut Frame, scroll: u16) { let lines: Text = (0..10).map(|i| Span::raw(format!("Line {}", i))).collect(); let paragraph = Paragraph::new(lines).scroll((scroll, 0)); let sized_paragraph = KnownSizeWrapper { inner: paragraph, width: 21, height: 5, }; let popup = Popup::new(sized_paragraph) .title("scroll: ↑/↓ quit: Esc") .style(Style::new().white().on_blue()); frame.render_widget(popup, frame.area()); } ``` -------------------------------- ### Scrollbar Metrics Calculation Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Illustrates the calculation of scrollbar metrics, focusing on viewport and content lengths to determine thumb size and positioning. ```rust `viewport_len = bar_cells * SUBCELL` `content_len` computed to target a fixed thumb size per axis. ``` -------------------------------- ### Fix: Render &Popup with Text Body Source: https://github.com/ratatui/tui-widgets/blob/main/BREAKING_CHANGES.md Illustrates the fix for rendering a `&Popup` with a `&str`/`String` body by wrapping the body in `Text`. ```rust let popup = Popup::new("Hello"); frame.render_widget(&popup, area); // Fix: wrap the body in `Text` to enable `&Popup` rendering. let popup = Popup::new(Text::from("Hello")); frame.render_widget(&popup, area); ``` -------------------------------- ### Mouse Event Handling Feature Flag in tui-popup Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Demonstrates how tui-popup uses a feature flag for crossterm mouse handling, serving as a pattern for the new scrollbar crate. ```rust tui_popup::PopupState::handle_mouse_event(&mut popup_state, event, last_frame_rect); ``` -------------------------------- ### Format Code Source: https://github.com/ratatui/tui-widgets/blob/main/CONTRIBUTING.md Applies code formatting to all files in the project using Cargo fmt. Ensures consistent code style throughout the codebase. ```shell cargo fmt --all ``` -------------------------------- ### Update PopupState Mouse Event Input Source: https://github.com/ratatui/tui-widgets/blob/main/BREAKING_CHANGES.md Demonstrates the change in `PopupState::handle_mouse_event` to accept `crossterm::event::MouseEvent`. ```diff -use ratatui::crossterm::event::MouseEvent; +use crossterm::event::MouseEvent; ``` -------------------------------- ### Render a Stateful Popup Source: https://github.com/ratatui/tui-widgets/blob/main/tui-popup/README.md Render a popup widget that manages its state, allowing for movement. ```rust use ratatui::style::{Style, Stylize}; use ratatui::Frame; use tui_popup::{Popup, PopupState}; fn render_stateful_popup(frame: &mut Frame, popup_state: &mut PopupState) { let popup = Popup::new("Press any key to exit") .title("tui-popup demo") .style(Style::new().white().on_blue()); frame.render_stateful_widget(popup, frame.area(), popup_state); } ``` -------------------------------- ### Update tui-prompts Event Imports Source: https://github.com/ratatui/tui-widgets/blob/main/BREAKING_CHANGES.md Shows the change in import paths for `crossterm::event` types in `tui-prompts`. ```diff -use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers}; +use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers}; ``` -------------------------------- ### Layout Integration for Vertical ScrollBar Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/README.md Demonstrates reserving a column for a vertical ScrollBar alongside main content using Ratatui's Layout system. The same pattern can be applied horizontally by splitting rows. ```rust use ratatui_core::buffer::Buffer; use ratatui_core::layout::{Constraint, Layout, Rect}; use ratatui_core::widgets::Widget; use tui_scrollbar::{ScrollBar, ScrollLengths}; let area = Rect::new(0, 0, 12, 6); let [content_area, bar_area] = area.layout(&Layout::horizontal([ Constraint::Fill(1), Constraint::Length(1), ])); let lengths = ScrollLengths { content_len: 400, viewport_len: 80, }; let scrollbar = ScrollBar::vertical(lengths).offset(0); let mut buffer = Buffer::empty(area); scrollbar.render(bar_area, &mut buffer); ``` -------------------------------- ### Check Code Formatting Source: https://github.com/ratatui/tui-widgets/blob/main/CONTRIBUTING.md Uses Cargo fmt to check for code formatting issues across the entire project without modifying files. Reports any deviations from the standard format. ```shell cargo fmt --all -- --check ``` -------------------------------- ### Handle Mouse Events for Popup Dragging Source: https://github.com/ratatui/tui-widgets/blob/main/tui-popup/README.md Enable dragging the popup using mouse events by updating the PopupState. ```rust use crossterm::event::{Event, MouseButton, MouseEventKind}; use tui_popup::PopupState; fn handle_mouse(event: Event, popup_state: &mut PopupState) { if let Event::Mouse(event) = event { match event.kind { MouseEventKind::Down(MouseButton::Left) => { popup_state.mouse_down(event.column, event.row) } MouseEventKind::Up(MouseButton::Left) => { popup_state.mouse_up(event.column, event.row); } MouseEventKind::Drag(MouseButton::Left) => { popup_state.mouse_drag(event.column, event.row); } _ => {} } } } ``` -------------------------------- ### Scrollbar Widget Imports in tui-scrollview Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Shows how the tui-scrollview crate currently imports and uses the scrollbar widget and its state from ratatui_widgets. ```rust use ratatui_widgets::scrollbar::{Scrollbar, ScrollbarOrientation, ScrollbarState }; ``` -------------------------------- ### PopupState Mouse Event Handling Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Excerpt from tui-popup's PopupState showing the method for handling mouse events, which is a pattern for the new scrollbar crate. ```rust pub fn handle_mouse_event( &mut self, event: MouseEvent, last_frame_rect: Rect, ) -> bool { // ... implementation ... false } ``` -------------------------------- ### Adding New Crate to CI Checks Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Configuration snippet for GitHub Actions CI to include README checks for new crates using cargo rdme. ```yaml - name: Check READMEs run: cargo rdme --check ``` -------------------------------- ### Cargo.toml Features for Crossterm Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Configuration in Cargo.toml to enable the 'crossterm' feature for backend-agnostic interaction APIs. ```toml [features] crossterm = ["dep:crossterm"] ``` -------------------------------- ### Handle Keyboard Input for Popup State Source: https://github.com/ratatui/tui-widgets/blob/main/tui-popup/README.md Manage popup movement using keyboard input by updating the PopupState. ```rust use crossterm::event::{KeyCode, KeyEvent}; use ratatui::style::{Style, Stylize}; use ratatui::Frame; use tui_popup::{Popup, PopupState}; fn render_stateful_popup(frame: &mut Frame, popup_state: &mut PopupState) { let popup = Popup::new("Press any key to exit") .title("tui-popup demo") .style(Style::new().white().on_blue()); frame.render_stateful_widget(popup, frame.area(), popup_state); } fn handle_key(event: KeyEvent, state: &mut PopupState) { match event.code { KeyCode::Up => state.move_up(1), KeyCode::Down => state.move_down(1), KeyCode::Left => state.move_left(1), KeyCode::Right => state.move_right(1), _ => {} } } ``` -------------------------------- ### Automated Verification Command (Crossterm) Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Command to run unit tests for the tui-scrollbar package with the 'crossterm' feature enabled. ```bash cargo test -p tui-scrollbar --features crossterm -- --nocapture ``` -------------------------------- ### Remove Stateful Widget Rendering by Reference Source: https://github.com/ratatui/tui-widgets/blob/main/BREAKING_CHANGES.md Shows the change from `render_stateful_widget_ref` to `render_stateful_widget` for rendering popups. ```diff -frame.render_stateful_widget_ref(&popup, area, &mut state); +frame.render_stateful_widget(&popup, area, &mut state); ``` -------------------------------- ### Scrollbar Rendering with Arrows Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Logic for rendering scrollbar arrows first, then computing an inner track area for the thumb and track. ```rust Render arrows first. Compute an inner track area (area minus arrows) for `ScrollMetrics`. Offset cell indices so thumb/track rendering stays aligned inside the inner track. ``` -------------------------------- ### Compute Scroll Metrics Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/README.md Calculate thumb geometry without rendering using ScrollMetrics. Useful for testing or inspecting thumb sizing directly. ```rust use tui_scrollbar::{ScrollLengths, ScrollMetrics, SUBCELL}; let track_cells = 12; let viewport_len = track_cells * SUBCELL; let content_len = viewport_len * 6; let lengths = ScrollLengths { content_len, viewport_len, }; let metrics = ScrollMetrics::new(lengths, 0, track_cells as u16); assert!(metrics.thumb_len() >= SUBCELL); ``` -------------------------------- ### Scrollbar Lengths Struct Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Demonstrates the use of the `ScrollLengths` struct for explicitly defining content and viewport lengths, improving API ergonomics. ```rust Use `ScrollLengths { content_len, viewport_len }` to avoid ambiguous parameter ordering. ``` -------------------------------- ### Scrollbar Interaction API Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Defines the backend-agnostic `ScrollBarInteraction` and the `handle_event` method for managing scrollbar interactions. ```rust ScrollBarInteraction that tracks drag capture only (no stored `Rect`). ScrollBar::handle_event(area, event, model, &mut interaction) -> Option. ``` -------------------------------- ### Handling Tiny Areas in Scrollbars Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Behavior for scrollbars in extremely small areas, prioritizing arrow rendering and skipping thumb rendering if no inner track space is available. ```rust If there is no room for an inner track, render arrows only and skip thumb rendering. ``` -------------------------------- ### Crossterm Mouse Event Handling Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Adapter function behind `cfg(feature = "crossterm")` that converts crossterm mouse events for the core scrollbar interaction API. ```rust Converts `crossterm::event::MouseEvent` into the backend-agnostic event type. Calls the core `handle_event(...)`. ``` -------------------------------- ### Rendering Scrollbars in tui-scrollview Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Illustrates the current method of rendering vertical and horizontal scrollbars within the tui-scrollview crate using ScrollbarState and Scrollbar. ```rust ScrollbarState::new(content_len, viewport_len) .position(offset) .orientation(ScrollbarOrientation::Vertical) .into_inner() .render(frame, area, &mut scrollbar_state); ``` -------------------------------- ### Update Crossterm Dependency for tui-popup Source: https://github.com/ratatui/tui-widgets/blob/main/BREAKING_CHANGES.md Specifies the required `crossterm` dependency version for `tui-popup`. ```toml [dependencies] crossterm = "0.29" ``` -------------------------------- ### Scrollbar Hit Testing with Arrows Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Logic for detecting pointer events on arrow cells to emit step commands and mapping pointer positions within the inner track. ```rust Detect pointer events on arrow cells and emit a step command. Map pointer positions in the inner track to `ScrollMetrics`. ``` -------------------------------- ### Scrollbar Interaction Loop Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/README.md Handles mouse events for a scrollbar, updating the scroll offset based on user interaction. This pattern requires mouse capture to be enabled and assumes the scrollbar's Rect is available from the layout. ```rust use ratatui_core::layout::Rect; use tui_scrollbar::{ScrollBar, ScrollBarInteraction, ScrollCommand, ScrollLengths}; let bar_area = Rect::new(0, 0, 1, 10); let lengths = ScrollLengths { content_len: 400, viewport_len: 80, }; let scrollbar = ScrollBar::vertical(lengths).offset(0); let mut interaction = ScrollBarInteraction::new(); let mut offset = 0; if let Event::Mouse(event) = event::read()? { if let Some(ScrollCommand::SetOffset(next)) = scrollbar.handle_mouse_event(bar_area, event, &mut interaction) { offset = next; } } ``` -------------------------------- ### Commit Message Header Format Source: https://github.com/ratatui/tui-widgets/blob/main/CONTRIBUTING.md Defines the structure for commit message headers, including type, scope, and a short summary. Follows Conventional Commits specification. ```text (): │ │ │ │ │ └─⫸ Summary in present tense. Not capitalized. No period at the end. │ │ │ └─⫸ Commit Scope │ └─⫸ Commit Type: feat|fix|build|ci|docs|perf |refactor|test|chore ``` -------------------------------- ### Custom Glyph Set for Scrollbar Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/README.md Configure a ScrollBar to use a specific glyph set, such as the standard Unicode set, to avoid legacy symbols. ```rust use tui_scrollbar::{GlyphSet, ScrollBar, ScrollLengths}; let lengths = ScrollLengths { content_len: 10, viewport_len: 5, }; let scrollbar = ScrollBar::vertical(lengths).glyph_set(GlyphSet::unicode()); ``` -------------------------------- ### Horizontal Right Glyphs Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Defines the glyphs used for the right part of a horizontal scrollbar. These include standard block characters and symbols for fractional representation. ```rust `horizontal_right`: `['▕','🮇','🮈','▐','🮉','🮊','🮋','█']` ``` -------------------------------- ### Vertical Upper Glyphs Source: https://github.com/ratatui/tui-widgets/blob/main/tui-scrollbar/docs/scrollbar-implementation-plan.md Defines the glyphs used for the upper part of a vertical scrollbar. These include standard block characters and symbols for fractional representation. ```rust `vertical_upper`: `['▔','🮂','🮃','▀','🮄','🮅','🮆','█']` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.