Module list

Module list 

Source
Expand description

List component with filtering, pagination, contextual help, and customizable rendering.

This module exposes a generic Model<I: Item> plus supporting traits and submodules:

  • Item: Implement for your item type; must be Display + Clone and return a filter_value()
  • ItemDelegate: Controls item render, height, spacing, and update
  • Submodules: defaultitem, keys, and style

§Architecture Overview

This list component uses several key architectural patterns for smooth interaction:

§🎯 Core Design Principles

  1. Viewport-Based Scrolling: Maintains smooth, context-preserving navigation
  2. Index Consistency: Uses original item indices for cursor tracking across all states
  3. Real-Time Filtering: Integrates textinput component for responsive filter interaction
  4. State-Driven UI: Clear separation between filtering, navigation, and display states

§🏗️ Key Components

  • Viewport Management: viewport_start field tracks visible window position
  • Index Strategy: Delegates receive original indices for consistent highlighting
  • Filter Integration: Direct textinput forwarding preserves all input features
  • State Coordination: Filtering states control UI behavior and key handling

§📋 Implementation Strategy

  • Viewport Scrolling: Only adjusts view when cursor moves outside visible bounds
  • Index Semantics: Render delegates use original positions for cursor comparison
  • Filter States: Filtering during typing, FilterApplied after acceptance
  • Event Handling: KeyMsg forwarding maintains textinput component consistency

§Filtering States

The list supports fuzzy filtering with three states:

  • Unfiltered: No filter active
  • Filtering: User is typing a filter; input is shown in the header
  • FilterApplied: Filter accepted; only matching items are displayed

When filtering is active, fuzzy match indices are stored per item and delegates can use them to apply character-level highlighting (see defaultitem).

§Help Integration

The list implements help::KeyMap, so you can embed help::Model and get contextual help automatically based on the current filtering state.

Re-exports§

pub use keys::ListKeyMap;
pub use style::ListStyles;
pub use defaultitem::DefaultDelegate;
pub use defaultitem::DefaultItem;
pub use defaultitem::DefaultItemStyles;

Modules§

defaultitem
Default item implementation and delegate for basic list functionality.
keys
Key bindings and keyboard input handling for list navigation.
style
Visual styling and theming for list components.

Structs§

FilterStateInfo
Core traits and types for list functionality.
Model
The main list component model.

Enums§

FilterState
Core traits and types for list functionality.

Traits§

Item
Core traits and types for list functionality.
ItemDelegate
Core traits and types for list functionality.