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

§MAJOR BUG FIXES - Viewport Scrolling & Filter Input (v0.1.4+)

This implementation includes comprehensive fixes for critical list component issues:

§🔧 Fixed Issues

  1. Filter Input Accumulation: Characters now accumulate correctly during typing
  2. Cursor Highlighting Loss: Selection indicator persists during viewport scrolling
  3. Viewport Page Jumping: Smooth one-item-at-a-time scrolling instead of jarring page jumps
  4. Upward Scrolling Problems: Proper viewport adjustment when scrolling up

§🏗️ Architecture Changes

  • Smooth Viewport Scrolling: viewport_start field + sync_viewport_with_cursor() method
  • Proper Index Handling: Original item indices for cursor highlighting, viewport-relative for display
  • Enhanced Filter Input: Direct textinput component integration instead of manual string manipulation
  • State Management: Improved filtering state transitions to prevent input blocking

§📋 Key Design Decisions

  • Index Semantics: Render delegates receive original item indices for consistent cursor highlighting
  • Viewport Strategy: Only scroll when cursor moves outside visible bounds (context preservation)
  • Filter Integration: Maintain Filtering state during typing, only change to FilterApplied on Enter
  • Event Forwarding: Proper KeyMsg creation and forwarding to textinput component

§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 defaultitem::DefaultDelegate;
pub use defaultitem::DefaultItem;
pub use defaultitem::DefaultItemStyles;
pub use keys::ListKeyMap;
pub use style::ListStyles;

Modules§

defaultitem
Default item implementation and delegate for list components.
keys
Key bindings for list component navigation and interaction.
style
Styling system for list components.

Structs§

Model
List model containing items, filtering, pagination, and styling.

Enums§

FilterState
Current filtering state of the list.

Traits§

Item
An item that can be displayed in the list.
ItemDelegate
A delegate encapsulates the functionality for a list item.