pub struct ListViewerState {
pub state: ViewState,
pub num_cols: i32,
pub top_item: i32,
pub focused: i32,
pub range: i32,
pub indent: i32,
pub h_scroll_bar: Option<ViewId>,
pub v_scroll_bar: Option<ViewId>,
pub find_mode: FindMode,
pub query: String,
/* private fields */
}Expand description
The shared state of every list-viewer. A concrete list widget embeds one and
exposes it via ListViewer::lv/ListViewer::lv_mut.
§Turbo Vision heritage
The data half of TListViewer (tlstview.cpp) — its instance fields.
Fields§
§state: ViewStateView state (geometry, flags, …) — the View composition target.
num_cols: i32The number of columns (>= 1) the items are laid out in.
Controls the column-major item layout: relative to the first visible
row top_item, column j holds items
top_item + j * size.y .. top_item + (j + 1) * size.y. Must be >= 1; the constructor clamps
smaller values to 1 and fires a debug_assert.
top_item: i32The item index drawn at the top-left cell (the scroll offset).
Adjusted by focus_item to keep focused visible. Read it to find
out which item is at the top of the current view; set it directly only
when constructing a pre-scrolled list before insertion.
focused: i32The index of the item that holds the keyboard cursor.
Changed by keyboard nav, mouse clicks, and the scrollbar read-sync.
Read it to find the current selection; move it by calling
focus_item or focus_item_num (both keep top_item in sync).
range: i32The total number of items in the list.
Set this by calling set_range, which also resets focused if it
now falls past the end and (re)publishes the vertical bar’s range.
Reading it directly is fine; writing it directly is not (the bar and
focused would be left inconsistent).
indent: i32Cached horizontal-bar value — draw cannot reach the sibling bar,
so the value is cached here and refreshed by the read-sync
(apply_scroll).
h_scroll_bar: Option<ViewId>The horizontal scrollbar, identified by ViewId (None if absent).
Pass the bar’s id when constructing via ListViewerState::new.
After insertion call update_steps to publish the initial step sizes.
The pump then brokers all subsequent reads and writes through the
apply_scroll / Deferred::SyncListViewer seam — do NOT read or
write the bar directly from event handlers.
v_scroll_bar: Option<ViewId>The vertical scrollbar, identified by ViewId (None if absent).
Same wiring rules as h_scroll_bar: pass the id
at construction, call update_steps after insertion, and let the pump
broker all bar ↔ list synchronization.
find_mode: FindModeFind mode (opt-in). Off keeps the classic prefix lookup; the other
variants enable the accumulated-query find-and-highlight.
query: StringThe accumulated find query (find mode only; always empty when Off).
Implementations§
Source§impl ListViewerState
impl ListViewerState
Sourcepub fn new(
bounds: Rect,
num_cols: i32,
h_scroll_bar: Option<ViewId>,
v_scroll_bar: Option<ViewId>,
) -> Self
pub fn new( bounds: Rect, num_cols: i32, h_scroll_bar: Option<ViewId>, v_scroll_bar: Option<ViewId>, ) -> Self
Create list-viewer state for bounds, with num_cols columns and
optional scroll bar ids.
Call this before inserting the widget into its parent group. Because
there is no Context at construction time, bar step sizes cannot be
published yet — call update_steps immediately after the widget is
inserted (the same two-step pattern the scroller uses). The state starts
at the top of an empty list (top_item = 0, focused = 0, range = 0).
Sets ofFirstClick and ofSelectable on the embedded ViewState.
num_cols < 1 is clamped to 1 with a debug_assert.
Auto Trait Implementations§
impl Freeze for ListViewerState
impl RefUnwindSafe for ListViewerState
impl Send for ListViewerState
impl Sync for ListViewerState
impl Unpin for ListViewerState
impl UnsafeUnpin for ListViewerState
impl UnwindSafe for ListViewerState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.