pub struct StateCoordinator {
pub state_container: AppStateContainer,
pub shadow_state: Rc<RefCell<ShadowStateManager>>,
pub viewport_manager: Rc<RefCell<Option<ViewportManager>>>,
pub hybrid_parser: HybridParser,
}
Expand description
StateCoordinator
manages and synchronizes all state components in the TUI
This centralizes state management and reduces coupling in the main TUI
Fields§
§state_container: AppStateContainer
Core application state
shadow_state: Rc<RefCell<ShadowStateManager>>
Shadow state for tracking mode transitions
viewport_manager: Rc<RefCell<Option<ViewportManager>>>
Viewport manager for display state
hybrid_parser: HybridParser
SQL parser with schema information
Implementations§
Source§impl StateCoordinator
impl StateCoordinator
Sourcepub fn sync_mode_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
mode: AppMode,
trigger: &str,
)
pub fn sync_mode_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, mode: AppMode, trigger: &str, )
Static version of sync_mode
that works with references
Sourcepub fn update_parser_with_refs(
state_container: &AppStateContainer,
parser: &mut HybridParser,
)
pub fn update_parser_with_refs( state_container: &AppStateContainer, parser: &mut HybridParser, )
Static version of update_parser_for_current_buffer
pub fn new( state_container: AppStateContainer, shadow_state: Rc<RefCell<ShadowStateManager>>, viewport_manager: Rc<RefCell<Option<ViewportManager>>>, hybrid_parser: HybridParser, ) -> Self
Sourcepub fn sync_mode(&mut self, mode: AppMode, trigger: &str)
pub fn sync_mode(&mut self, mode: AppMode, trigger: &str)
Synchronize mode across all state containers
This ensures AppStateContainer
, Buffer, and ShadowState
are all in sync
Sourcepub fn set_mode_via_shadow_state(&mut self, mode: AppMode, trigger: &str)
pub fn set_mode_via_shadow_state(&mut self, mode: AppMode, trigger: &str)
Alternative mode setter that goes through shadow state
Sourcepub fn sync_after_buffer_switch(&mut self)
pub fn sync_after_buffer_switch(&mut self)
Synchronize all state after buffer switch This should be called after any buffer switch operation
Sourcepub fn update_parser_for_current_buffer(&mut self)
pub fn update_parser_for_current_buffer(&mut self)
Update parser schema from current buffer’s DataView
Sourcepub fn enter_search_mode(&mut self, mode: SearchMode) -> String
pub fn enter_search_mode(&mut self, mode: SearchMode) -> String
Enter a search mode with proper state synchronization
Sourcepub fn cancel_search(&mut self) -> (Option<String>, Option<usize>)
pub fn cancel_search(&mut self) -> (Option<String>, Option<usize>)
Cancel search and properly restore state This handles all the complex state synchronization when Escape is pressed during search
Sourcepub fn cancel_search_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
vim_search_adapter: Option<&RefCell<VimSearchAdapter>>,
)
pub fn cancel_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, )
Static version for delegation pattern with vim search adapter
Sourcepub fn should_handle_next_match(
state_container: &AppStateContainer,
vim_search_adapter: Option<&RefCell<VimSearchAdapter>>,
) -> bool
pub fn should_handle_next_match( state_container: &AppStateContainer, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, ) -> bool
Check if ‘n’ key should navigate to next search match Returns true only if there’s an active search (not cancelled with Escape)
Sourcepub fn should_handle_previous_match(
state_container: &AppStateContainer,
vim_search_adapter: Option<&RefCell<VimSearchAdapter>>,
) -> bool
pub fn should_handle_previous_match( state_container: &AppStateContainer, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, ) -> bool
Check if ‘N’ key should navigate to previous search match Returns true only if there’s an active search (not cancelled with Escape)
Sourcepub fn complete_search_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
vim_search_adapter: Option<&RefCell<VimSearchAdapter>>,
mode: AppMode,
trigger: &str,
)
pub fn complete_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, mode: AppMode, trigger: &str, )
Complete a search operation (after Apply/Enter is pressed) This keeps the pattern for n/N navigation but marks search as complete
Sourcepub fn apply_text_filter_with_refs(
state_container: &mut AppStateContainer,
pattern: &str,
) -> usize
pub fn apply_text_filter_with_refs( state_container: &mut AppStateContainer, pattern: &str, ) -> usize
Apply text filter and coordinate all state updates Returns the number of matching rows
Sourcepub fn apply_fuzzy_filter_with_refs(
state_container: &mut AppStateContainer,
viewport_manager: &RefCell<Option<ViewportManager>>,
) -> (usize, Vec<usize>)
pub fn apply_fuzzy_filter_with_refs( state_container: &mut AppStateContainer, viewport_manager: &RefCell<Option<ViewportManager>>, ) -> (usize, Vec<usize>)
Apply fuzzy filter and coordinate all state updates
Returns (match_count
, filter_indices
)
Sourcepub fn reset_table_state_with_refs(
state_container: &mut AppStateContainer,
viewport_manager: &RefCell<Option<ViewportManager>>,
)
pub fn reset_table_state_with_refs( state_container: &mut AppStateContainer, viewport_manager: &RefCell<Option<ViewportManager>>, )
Reset all table-related state to initial values This is typically called when switching data sources or after queries
Sourcepub fn add_dataview_with_refs(
state_container: &mut AppStateContainer,
viewport_manager: &RefCell<Option<ViewportManager>>,
dataview: DataView,
source_name: &str,
config: &Config,
) -> Result<(), Error>
pub fn add_dataview_with_refs( state_container: &mut AppStateContainer, viewport_manager: &RefCell<Option<ViewportManager>>, dataview: DataView, source_name: &str, config: &Config, ) -> Result<(), Error>
Add a new DataView
and coordinate all necessary state updates
This centralizes the complex logic of adding a new data source
Sourcepub fn set_sql_query_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
parser: &mut HybridParser,
table_name: &str,
raw_table_name: &str,
config: &Config,
) -> String
pub fn set_sql_query_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, parser: &mut HybridParser, table_name: &str, raw_table_name: &str, config: &Config, ) -> String
Set SQL query and update all related state This centralizes the complex logic of setting up SQL query state
Sourcepub fn handle_execute_query_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
query: &str,
) -> Result<bool, Error>
pub fn handle_execute_query_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, query: &str, ) -> Result<bool, Error>
Handle query execution and all related state changes Returns true if application should exit
Sourcepub fn switch_to_results_after_query(&mut self)
pub fn switch_to_results_after_query(&mut self)
Switch to Results mode after successful query execution
Sourcepub fn switch_to_results_after_query_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
)
pub fn switch_to_results_after_query_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, )
Static version for delegation
Sourcepub fn apply_filter_search_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
pattern: &str,
)
pub fn apply_filter_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, pattern: &str, )
Apply filter search with proper state coordination
Sourcepub fn apply_fuzzy_filter_search_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
pattern: &str,
)
pub fn apply_fuzzy_filter_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, pattern: &str, )
Apply fuzzy filter search with proper state coordination
Sourcepub fn apply_column_search_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
pattern: &str,
)
pub fn apply_column_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, pattern: &str, )
Apply column search with proper state coordination
Sourcepub fn start_history_search_with_refs(
state_container: &mut AppStateContainer,
shadow_state: &RefCell<ShadowStateManager>,
current_input: String,
) -> (String, usize)
pub fn start_history_search_with_refs( state_container: &mut AppStateContainer, shadow_state: &RefCell<ShadowStateManager>, current_input: String, ) -> (String, usize)
Start history search with proper state transitions
Sourcepub fn goto_first_row_with_refs(
state_container: &mut AppStateContainer,
vim_search_adapter: Option<&RefCell<VimSearchAdapter>>,
viewport_manager: Option<&RefCell<Option<ViewportManager>>>,
)
pub fn goto_first_row_with_refs( state_container: &mut AppStateContainer, vim_search_adapter: Option<&RefCell<VimSearchAdapter>>, viewport_manager: Option<&RefCell<Option<ViewportManager>>>, )
Coordinate goto first row with vim search state
Sourcepub fn goto_last_row_with_refs(state_container: &mut AppStateContainer)
pub fn goto_last_row_with_refs(state_container: &mut AppStateContainer)
Coordinate goto last row
Sourcepub fn goto_row_with_refs(state_container: &mut AppStateContainer, row: usize)
pub fn goto_row_with_refs(state_container: &mut AppStateContainer, row: usize)
Coordinate goto specific row
Sourcepub fn state_container(&self) -> &AppStateContainer
pub fn state_container(&self) -> &AppStateContainer
Get reference to AppStateContainer
Sourcepub fn state_container_mut(&mut self) -> &mut AppStateContainer
pub fn state_container_mut(&mut self) -> &mut AppStateContainer
Get mutable reference to AppStateContainer
Sourcepub fn current_buffer(&self) -> Option<&Buffer>
pub fn current_buffer(&self) -> Option<&Buffer>
Get reference to current buffer
Sourcepub fn current_buffer_mut(&mut self) -> Option<&mut Buffer>
pub fn current_buffer_mut(&mut self) -> Option<&mut Buffer>
Get mutable reference to current buffer
Sourcepub fn buffers(&self) -> &BufferManager
pub fn buffers(&self) -> &BufferManager
Get reference to buffer manager
Sourcepub fn buffers_mut(&mut self) -> &mut BufferManager
pub fn buffers_mut(&mut self) -> &mut BufferManager
Get mutable reference to buffer manager
Sourcepub fn parser(&self) -> &HybridParser
pub fn parser(&self) -> &HybridParser
Get reference to hybrid parser
Sourcepub fn parser_mut(&mut self) -> &mut HybridParser
pub fn parser_mut(&mut self) -> &mut HybridParser
Get mutable reference to hybrid parser
Auto Trait Implementations§
impl !Freeze for StateCoordinator
impl !RefUnwindSafe for StateCoordinator
impl !Send for StateCoordinator
impl !Sync for StateCoordinator
impl Unpin for StateCoordinator
impl !UnwindSafe for StateCoordinator
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
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>
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>
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