use crate::app::tab::Tab; use crate::app::theme::Theme; use eframe::egui; use std::sync::{Arc, Mutex}; use std::thread; #[derive(Clone, PartialEq)] pub enum UnsavedAction { Quit, CloseTab(usize), } #[derive(Clone)] pub struct TextProcessingResult { pub line_count: usize, pub longest_line_index: usize, // Which line is the longest (0-based) pub longest_line_length: usize, // Character count of the longest line pub longest_line_pixel_width: f32, // Actual pixel width of the longest line } impl Default for TextProcessingResult { fn default() -> Self { Self { line_count: 1, longest_line_index: 0, longest_line_length: 0, longest_line_pixel_width: 0.0, } } } #[derive()] pub struct TextEditor { pub(crate) tabs: Vec, pub(crate) active_tab_index: usize, pub(crate) tab_counter: usize, // Counter for numbering new tabs pub(crate) show_about: bool, pub(crate) show_shortcuts: bool, pub(crate) show_find: bool, pub(crate) show_preferences: bool, pub(crate) pending_unsaved_action: Option, pub(crate) force_quit_confirmed: bool, pub(crate) clean_quit_requested: bool, pub(crate) show_line_numbers: bool, pub(crate) word_wrap: bool, pub(crate) auto_hide_toolbar: bool, pub(crate) auto_hide_tab_bar: bool, pub(crate) theme: Theme, pub(crate) line_side: bool, pub(crate) font_family: String, pub(crate) font_size: f32, pub(crate) font_size_input: Option, pub(crate) zoom_factor: f32, pub(crate) menu_interaction_active: bool, pub(crate) tab_bar_rect: Option, pub(crate) menu_bar_stable_until: Option, pub(crate) text_processing_result: Arc>, pub(crate) processing_thread_handle: Option>, pub(crate) find_query: String, pub(crate) find_matches: Vec<(usize, usize)>, // (start_pos, end_pos) byte positions pub(crate) current_match_index: Option, pub(crate) case_sensitive_search: bool, pub(crate) prev_show_find: bool, // Track previous state to detect transitions // Cursor tracking for smart scrolling pub(crate) previous_cursor_position: Option, // Track previous content for incremental processing pub(crate) previous_content: String, pub(crate) previous_cursor_char_index: Option, pub(crate) current_cursor_line: usize, // Track current line number incrementally pub(crate) previous_cursor_line: usize, // Track previous line for comparison pub(crate) font_settings_changed: bool, // Flag to trigger text reprocessing when font changes }