pub struct ViewportManager { /* private fields */ }
Expand description
Manages the visible viewport into a DataView
Implementations§
Source§impl ViewportManager
impl ViewportManager
Sourcepub fn get_viewport_range(&self) -> Range<usize>
pub fn get_viewport_range(&self) -> Range<usize>
Get the current viewport column range
Sourcepub fn get_viewport_rows(&self) -> Range<usize>
pub fn get_viewport_rows(&self) -> Range<usize>
Get the current viewport row range
Sourcepub fn set_crosshair(&mut self, row: usize, col: usize)
pub fn set_crosshair(&mut self, row: usize, col: usize)
Set crosshair position in visual coordinates
Sourcepub fn set_crosshair_row(&mut self, row: usize)
pub fn set_crosshair_row(&mut self, row: usize)
Set crosshair row position in visual coordinates with automatic viewport adjustment
Sourcepub fn set_crosshair_column(&mut self, col: usize)
pub fn set_crosshair_column(&mut self, col: usize)
Set crosshair column position in visual coordinates with automatic viewport adjustment
Sourcepub fn get_crosshair_col(&self) -> usize
pub fn get_crosshair_col(&self) -> usize
Get crosshair column position in visual coordinates
Sourcepub fn get_crosshair_row(&self) -> usize
pub fn get_crosshair_row(&self) -> usize
Get crosshair row position in visual coordinates
Sourcepub fn get_selected_row(&self) -> usize
pub fn get_selected_row(&self) -> usize
Get selected row (alias for crosshair_row
for compatibility)
Sourcepub fn get_selected_column(&self) -> usize
pub fn get_selected_column(&self) -> usize
Get selected column (alias for crosshair_col
for compatibility)
Sourcepub fn get_crosshair_position(&self) -> (usize, usize)
pub fn get_crosshair_position(&self) -> (usize, usize)
Get crosshair position as (row, column) tuple in visual coordinates
Sourcepub fn get_scroll_offset(&self) -> (usize, usize)
pub fn get_scroll_offset(&self) -> (usize, usize)
Get scroll offset as (row_offset
, col_offset
)
Sourcepub fn set_scroll_offset(&mut self, row_offset: usize, col_offset: usize)
pub fn set_scroll_offset(&mut self, row_offset: usize, col_offset: usize)
Set scroll offset and update viewport accordingly
Sourcepub fn get_crosshair_viewport_position(&self) -> Option<(usize, usize)>
pub fn get_crosshair_viewport_position(&self) -> Option<(usize, usize)>
Get crosshair position relative to current viewport for rendering
Returns (row_offset
, col_offset
) within the viewport, or None if outside
Navigate up one row
Navigate down one row
Sourcepub fn set_dataview(&mut self, dataview: Arc<DataView>)
pub fn set_dataview(&mut self, dataview: Arc<DataView>)
Update the underlying DataView
Sourcepub fn reset_crosshair(&mut self)
pub fn reset_crosshair(&mut self)
Reset crosshair position to origin (0, 0)
Sourcepub fn get_packing_mode(&self) -> ColumnPackingMode
pub fn get_packing_mode(&self) -> ColumnPackingMode
Get the current column packing mode
Sourcepub fn set_packing_mode(&mut self, mode: ColumnPackingMode)
pub fn set_packing_mode(&mut self, mode: ColumnPackingMode)
Set the column packing mode and recalculate widths
Sourcepub fn cycle_packing_mode(&mut self) -> ColumnPackingMode
pub fn cycle_packing_mode(&mut self) -> ColumnPackingMode
Cycle to the next packing mode
Sourcepub fn set_viewport(
&mut self,
row_offset: usize,
col_offset: usize,
width: u16,
height: u16,
)
pub fn set_viewport( &mut self, row_offset: usize, col_offset: usize, width: u16, height: u16, )
Update viewport position and size
Sourcepub fn update_terminal_size(
&mut self,
terminal_width: u16,
terminal_height: u16,
) -> usize
pub fn update_terminal_size( &mut self, terminal_width: u16, terminal_height: u16, ) -> usize
Update viewport size based on terminal dimensions Returns the calculated visible rows for the results area
Sourcepub fn scroll_by(&mut self, row_delta: isize, col_delta: isize)
pub fn scroll_by(&mut self, row_delta: isize, col_delta: isize)
Scroll viewport by relative amount
Sourcepub fn get_column_widths(&mut self) -> &[u16]
pub fn get_column_widths(&mut self) -> &[u16]
Get calculated column widths for current viewport
Sourcepub fn get_column_width(&mut self, col_idx: usize) -> u16
pub fn get_column_width(&mut self, col_idx: usize) -> u16
Get column width for a specific column
Sourcepub fn get_visible_rows(&self) -> Vec<DataRow>
pub fn get_visible_rows(&self) -> Vec<DataRow>
Get visible rows in the current viewport
Sourcepub fn get_visible_row(&self, viewport_row: usize) -> Option<DataRow>
pub fn get_visible_row(&self, viewport_row: usize) -> Option<DataRow>
Get a specific visible row by viewport-relative index
Sourcepub fn get_visible_columns(&self) -> Vec<String>
pub fn get_visible_columns(&self) -> Vec<String>
Get visible column headers (only non-hidden columns that are in current viewport)
Sourcepub fn viewport_rows(&self) -> Range<usize>
pub fn viewport_rows(&self) -> Range<usize>
Get the current viewport row range
Sourcepub fn viewport_cols(&self) -> Range<usize>
pub fn viewport_cols(&self) -> Range<usize>
Get the current viewport column range
Sourcepub fn is_row_visible(&self, row_idx: usize) -> bool
pub fn is_row_visible(&self, row_idx: usize) -> bool
Check if a row is visible in the viewport
Sourcepub fn is_column_visible(&self, col_idx: usize) -> bool
pub fn is_column_visible(&self, col_idx: usize) -> bool
Check if a column is visible in the viewport
Sourcepub fn total_rows(&self) -> usize
pub fn total_rows(&self) -> usize
Get total row count from underlying view
Sourcepub fn total_columns(&self) -> usize
pub fn total_columns(&self) -> usize
Get total column count from underlying view
Sourcepub fn get_terminal_width(&self) -> u16
pub fn get_terminal_width(&self) -> u16
Get terminal width in characters
Sourcepub fn get_terminal_height(&self) -> usize
pub fn get_terminal_height(&self) -> usize
Get terminal height in rows
Sourcepub fn invalidate_cache(&mut self)
pub fn invalidate_cache(&mut self)
Force cache recalculation on next access
Sourcepub fn calculate_visible_column_indices(
&mut self,
available_width: u16,
) -> Vec<usize>
pub fn calculate_visible_column_indices( &mut self, available_width: u16, ) -> Vec<usize>
Calculate optimal column layout for available width
Returns a RANGE of visual column indices (0..n) that should be displayed
This works entirely in visual coordinate space - no DataTable
indices!
Sourcepub fn calculate_columns_that_fit(
&mut self,
start_col: usize,
available_width: u16,
) -> usize
pub fn calculate_columns_that_fit( &mut self, start_col: usize, available_width: u16, ) -> usize
Calculate how many columns we can fit starting from a given column index This helps determine optimal scrolling positions
Sourcepub fn get_column_widths_for(&mut self, column_indices: &[usize]) -> Vec<u16>
pub fn get_column_widths_for(&mut self, column_indices: &[usize]) -> Vec<u16>
Get calculated widths for specific columns This is useful for rendering when we know which columns will be displayed
Sourcepub fn update_column_viewport(&mut self, start_col: usize, available_width: u16)
pub fn update_column_viewport(&mut self, start_col: usize, available_width: u16)
Update viewport for column scrolling This recalculates column widths based on newly visible columns
Sourcepub fn clone_dataview(&self) -> DataView
pub fn clone_dataview(&self) -> DataView
Get a cloned copy of the underlying DataView
(for syncing with Buffer)
This is a temporary solution until we refactor Buffer to use Arc
Sourcepub fn calculate_optimal_offset_for_last_column(
&mut self,
available_width: u16,
) -> usize
pub fn calculate_optimal_offset_for_last_column( &mut self, available_width: u16, ) -> usize
Calculate the optimal scroll offset to show the last column This backtracks from the end to find the best viewport position Returns the scroll offset in terms of scrollable columns (excluding pinned)
Sourcepub fn debug_dump(&mut self, available_width: u16) -> String
pub fn debug_dump(&mut self, available_width: u16) -> String
Debug dump of ViewportManager
state for F5 diagnostics
Sourcepub fn get_column_names_ordered(&self) -> Vec<String>
pub fn get_column_names_ordered(&self) -> Vec<String>
Get column names in DataView
’s preferred order (pinned first, then display order)
This should be the single source of truth for column ordering from TUI perspective
Sourcepub fn get_visible_columns_info(
&mut self,
available_width: u16,
) -> (Vec<usize>, Vec<usize>, Vec<usize>)
pub fn get_visible_columns_info( &mut self, available_width: u16, ) -> (Vec<usize>, Vec<usize>, Vec<usize>)
Get structured information about visible columns for rendering
Returns (visible_indices
, pinned_indices
, scrollable_indices
)
Sourcepub fn calculate_column_x_positions(
&mut self,
available_width: u16,
) -> (Vec<usize>, Vec<u16>)
pub fn calculate_column_x_positions( &mut self, available_width: u16, ) -> (Vec<usize>, Vec<u16>)
Calculate the actual X positions in terminal coordinates for visible columns
Returns (column_indices
, x_positions
) where x_positions
[i] is the starting x position for column_indices
[i]
Sourcepub fn get_column_x_position(
&mut self,
column: usize,
available_width: u16,
) -> Option<u16>
pub fn get_column_x_position( &mut self, column: usize, available_width: u16, ) -> Option<u16>
Get the X position in terminal coordinates for a specific column (if visible)
Sourcepub fn calculate_visible_column_indices_ordered(
&mut self,
available_width: u16,
) -> Vec<usize>
pub fn calculate_visible_column_indices_ordered( &mut self, available_width: u16, ) -> Vec<usize>
Get visible column indices that fit in available width, preserving DataView
’s order
Sourcepub fn get_display_position_for_datatable_column(
&mut self,
datatable_column: usize,
available_width: u16,
) -> Option<usize>
pub fn get_display_position_for_datatable_column( &mut self, datatable_column: usize, available_width: u16, ) -> Option<usize>
Convert a DataTable
column index to its display position within the current visible columns
Returns None if the column is not currently visible
Sourcepub fn get_crosshair_column(
&mut self,
current_datatable_column: usize,
available_width: u16,
) -> Option<usize>
pub fn get_crosshair_column( &mut self, current_datatable_column: usize, available_width: u16, ) -> Option<usize>
Get the exact crosshair column position for rendering
This is the single source of truth for which column should be highlighted
For now, current_column
is still a DataTable
index (due to Buffer storing DataTable
indices)
This converts it to the correct display position
Sourcepub fn get_visual_display(
&mut self,
available_width: u16,
_row_indices: &[usize],
) -> (Vec<String>, Vec<Vec<String>>, Vec<u16>)
pub fn get_visual_display( &mut self, available_width: u16, _row_indices: &[usize], ) -> (Vec<String>, Vec<Vec<String>>, Vec<u16>)
Get the complete visual display data for rendering Returns (headers, rows, widths) where everything is in visual order with no gaps This method works entirely in visual coordinate space
Sourcepub fn get_visible_column_headers(
&self,
visible_indices: &[usize],
) -> Vec<String>
pub fn get_visible_column_headers( &self, visible_indices: &[usize], ) -> Vec<String>
Get the column headers for the visible columns in the correct order This ensures headers align with the data columns when columns are hidden
Sourcepub fn get_crosshair_column_for_display(
&mut self,
current_display_position: usize,
available_width: u16,
) -> Option<usize>
pub fn get_crosshair_column_for_display( &mut self, current_display_position: usize, available_width: u16, ) -> Option<usize>
Get crosshair column position for rendering when given a display position This is for the new architecture where Buffer stores display positions
Sourcepub fn calculate_efficiency_metrics(
&mut self,
available_width: u16,
) -> ViewportEfficiency
pub fn calculate_efficiency_metrics( &mut self, available_width: u16, ) -> ViewportEfficiency
Calculate viewport efficiency metrics
Navigate to the first column (first scrollable column after pinned columns) This centralizes the logic for first column navigation
Navigate to the last column (rightmost visible column) This centralizes the logic for last column navigation
Navigate one column to the left with intelligent wrapping and scrolling
This method handles everything: column movement, viewport tracking, and scrolling
IMPORTANT: current_display_position
is a logical display position (0,1,2,3…), NOT a DataTable
index
Navigate one column to the right with intelligent wrapping and scrolling
IMPORTANT: current_display_position
is a logical display position (0,1,2,3…), NOT a DataTable
index
Sourcepub fn page_down(&mut self) -> RowNavigationResult
pub fn page_down(&mut self) -> RowNavigationResult
Navigate one page down in the data
Sourcepub fn page_up(&mut self) -> RowNavigationResult
pub fn page_up(&mut self) -> RowNavigationResult
Navigate one page up in the data
Sourcepub fn half_page_down(&mut self) -> RowNavigationResult
pub fn half_page_down(&mut self) -> RowNavigationResult
Navigate half page down in the data
Sourcepub fn half_page_up(&mut self) -> RowNavigationResult
pub fn half_page_up(&mut self) -> RowNavigationResult
Navigate half page up in the data
Navigate to the last row in the data (like vim ‘G’ command)
Navigate to the first row in the data (like vim ‘gg’ command)
Navigate to the top of the current viewport (H in vim)
Navigate to the middle of the current viewport (M in vim)
Navigate to the bottom of the current viewport (L in vim)
Sourcepub fn toggle_cursor_lock(&mut self) -> (bool, String)
pub fn toggle_cursor_lock(&mut self) -> (bool, String)
Toggle viewport lock - when locked, crosshair stays at same viewport position while scrolling Toggle cursor lock - cursor stays at same viewport position while scrolling
Sourcepub fn toggle_viewport_lock(&mut self) -> (bool, String)
pub fn toggle_viewport_lock(&mut self) -> (bool, String)
Toggle viewport lock - prevents scrolling and constrains cursor to current viewport
Sourcepub fn is_cursor_locked(&self) -> bool
pub fn is_cursor_locked(&self) -> bool
Check if cursor is locked
Sourcepub fn is_viewport_locked(&self) -> bool
pub fn is_viewport_locked(&self) -> bool
Check if viewport is locked
Sourcepub fn lock_viewport(&mut self)
pub fn lock_viewport(&mut self)
Lock the viewport to prevent scrolling
Sourcepub fn unlock_viewport(&mut self)
pub fn unlock_viewport(&mut self)
Unlock the viewport to allow scrolling
Sourcepub fn reorder_column_left(
&mut self,
current_column: usize,
) -> ColumnReorderResult
pub fn reorder_column_left( &mut self, current_column: usize, ) -> ColumnReorderResult
Move the current column left in the display order (swap with previous column)
Sourcepub fn reorder_column_right(
&mut self,
current_column: usize,
) -> ColumnReorderResult
pub fn reorder_column_right( &mut self, current_column: usize, ) -> ColumnReorderResult
Move the current column right in the display order (swap with next column)
Sourcepub fn hide_column(&mut self, column_index: usize) -> bool
pub fn hide_column(&mut self, column_index: usize) -> bool
Hide the specified column Returns true if the column was hidden, false if it couldn’t be hidden
Sourcepub fn hide_column_by_name(&mut self, column_name: &str) -> bool
pub fn hide_column_by_name(&mut self, column_name: &str) -> bool
Hide a column by name Returns true if the column was hidden, false if it couldn’t be hidden
Sourcepub fn hide_empty_columns(&mut self) -> usize
pub fn hide_empty_columns(&mut self) -> usize
Hide all empty columns Returns the number of columns hidden
Sourcepub fn unhide_all_columns(&mut self)
pub fn unhide_all_columns(&mut self)
Unhide all columns
Sourcepub fn pin_column(&mut self, column_index: usize) -> bool
pub fn pin_column(&mut self, column_index: usize) -> bool
Pin the specified column Returns true if the column was pinned successfully, false otherwise
Sourcepub fn set_current_column(&mut self, visual_column: usize) -> bool
pub fn set_current_column(&mut self, visual_column: usize) -> bool
Update the current column position and automatically adjust viewport if needed This takes a VISUAL column index (0, 1, 2… in display order)
Sourcepub fn goto_line(&mut self, target_row: usize) -> RowNavigationResult
pub fn goto_line(&mut self, target_row: usize) -> RowNavigationResult
Jump to a specific line (row) with centering
Sourcepub fn hide_current_column_with_result(&mut self) -> ColumnOperationResult
pub fn hide_current_column_with_result(&mut self) -> ColumnOperationResult
Hide the current column (using crosshair position) and return unified result
Sourcepub fn unhide_all_columns_with_result(&mut self) -> ColumnOperationResult
pub fn unhide_all_columns_with_result(&mut self) -> ColumnOperationResult
Unhide all columns and return unified result
Sourcepub fn reorder_column_left_with_result(&mut self) -> ColumnOperationResult
pub fn reorder_column_left_with_result(&mut self) -> ColumnOperationResult
Reorder column left and return unified result
Sourcepub fn reorder_column_right_with_result(&mut self) -> ColumnOperationResult
pub fn reorder_column_right_with_result(&mut self) -> ColumnOperationResult
Reorder column right and return unified result
Sourcepub fn calculate_viewport_column_widths(
&mut self,
viewport_start: usize,
viewport_end: usize,
compact_mode: bool,
) -> Vec<u16>
pub fn calculate_viewport_column_widths( &mut self, viewport_start: usize, viewport_end: usize, compact_mode: bool, ) -> Vec<u16>
Calculate optimal column widths based on visible viewport rows This is a performance-optimized version that only examines visible data
Sourcepub fn calculate_optimal_column_widths(&mut self) -> Vec<u16>
pub fn calculate_optimal_column_widths(&mut self) -> Vec<u16>
Calculate optimal column widths using smart viewport-based calculations Returns the calculated widths without modifying any state
Sourcepub fn ensure_column_visible(
&mut self,
column_index: usize,
available_width: u16,
)
pub fn ensure_column_visible( &mut self, column_index: usize, available_width: u16, )
Ensure the specified column is visible by adjusting the viewport if necessary
Sourcepub fn reorder_column(&mut self, from_index: usize, to_index: usize) -> bool
pub fn reorder_column(&mut self, from_index: usize, to_index: usize) -> bool
Reorder a column from one position to another
Sourcepub fn calculate_column_widths(&mut self, available_width: u16) -> Vec<u16>
pub fn calculate_column_widths(&mut self, available_width: u16) -> Vec<u16>
Calculate column widths for the given available width This is a convenience method that returns the calculated widths for all columns
Auto Trait Implementations§
impl Freeze for ViewportManager
impl !RefUnwindSafe for ViewportManager
impl Send for ViewportManager
impl Sync for ViewportManager
impl Unpin for ViewportManager
impl !UnwindSafe for ViewportManager
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