ck_tui/
state.rs

1use crate::chunks::IndexedChunkMeta;
2use crate::config::PreviewMode;
3use ck_core::SearchMode;
4use ck_core::SearchResult;
5use ck_index::IndexStats;
6use ratatui::text::Line;
7use std::collections::HashSet;
8use std::path::PathBuf;
9use std::time::Instant;
10
11pub struct TuiState {
12    pub query: String,
13    pub mode: SearchMode,
14    pub results: Vec<SearchResult>,
15    pub selected_idx: usize,
16    pub preview_content: String,
17    pub preview_lines: Vec<Line<'static>>, // Colored preview
18    pub preview_mode: PreviewMode,
19    pub full_file_mode: bool, // false = snippet (±5 lines), true = full file
20    pub scroll_offset: usize, // For scrolling in full file mode
21    pub status_message: String,
22    pub search_path: PathBuf,
23    pub selected_files: HashSet<PathBuf>, // For multi-select
24    pub search_history: Vec<String>,      // Search history
25    pub history_index: usize,             // Current position in history
26    pub command_mode: bool,               // true when query starts with /
27    pub index_stats: Option<IndexStats>,
28    pub last_index_stats_refresh: Option<Instant>,
29    pub index_stats_error: Option<String>,
30    pub preview_cache: Option<PreviewCache>,
31    pub indexing_message: Option<String>,
32    pub indexing_progress: Option<f32>,
33    pub indexing_active: bool,
34    pub indexing_started_at: Option<Instant>,
35    pub last_indexing_update: Option<Instant>,
36    pub search_in_progress: bool,
37}
38
39pub struct PreviewCache {
40    pub file: PathBuf,
41    pub lines: Vec<String>,
42    pub is_pdf: bool,
43    pub chunks: Vec<IndexedChunkMeta>,
44}