pub struct TodoApp {
pub list: TodoList,
pub snapshot: TodoList,
pub state: ListState,
pub mode: AppMode,
pub input: String,
pub edit_index: Option<usize>,
pub message: Option<String>,
pub filter: usize,
pub quit_input: String,
pub cursor_pos: usize,
pub preview_scroll: u16,
}Expand description
TUI 应用状态
Fields§
§list: TodoList待办列表数据
snapshot: TodoList加载时的快照(用于对比是否真正有修改)
state: ListState列表选中状态
mode: AppMode当前模式
input: String输入缓冲区(添加/编辑模式使用)
edit_index: Option<usize>编辑时记录的原始索引
message: Option<String>状态栏消息
filter: usize过滤模式: 0=全部, 1=未完成, 2=已完成
quit_input: String强制退出输入缓冲(用于 q! 退出)
cursor_pos: usize输入模式下的光标位置(字符索引)
preview_scroll: u16预览区滚动偏移
Implementations§
Source§impl TodoApp
impl TodoApp
pub fn new() -> Self
Sourcepub fn filtered_indices(&self) -> Vec<usize>
pub fn filtered_indices(&self) -> Vec<usize>
获取当前过滤后的索引列表(映射到 list.items 的真实索引)
Sourcepub fn selected_real_index(&self) -> Option<usize>
pub fn selected_real_index(&self) -> Option<usize>
获取当前选中项在原始列表中的真实索引
Sourcepub fn toggle_done(&mut self)
pub fn toggle_done(&mut self)
切换当前选中项的完成状态
Sourcepub fn confirm_edit(&mut self)
pub fn confirm_edit(&mut self)
确认编辑
Sourcepub fn delete_selected(&mut self)
pub fn delete_selected(&mut self)
删除当前选中项
Sourcepub fn move_item_up(&mut self)
pub fn move_item_up(&mut self)
移动选中项向上(调整顺序)
Sourcepub fn move_item_down(&mut self)
pub fn move_item_down(&mut self)
移动选中项向下(调整顺序)
Sourcepub fn toggle_filter(&mut self)
pub fn toggle_filter(&mut self)
切换过滤模式
Auto Trait Implementations§
impl Freeze for TodoApp
impl RefUnwindSafe for TodoApp
impl Send for TodoApp
impl Sync for TodoApp
impl Unpin for TodoApp
impl UnsafeUnpin for TodoApp
impl UnwindSafe for TodoApp
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
Mutably borrows from an owned value. Read more
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more