ViewportManager

Struct ViewportManager 

Source
pub struct ViewportManager { /* private fields */ }
Expand description

Manages the visible viewport into a DataView

Implementations§

Source§

impl ViewportManager

Source

pub fn get_viewport_range(&self) -> Range<usize>

Get the current viewport column range

Source

pub fn get_viewport_rows(&self) -> Range<usize>

Get the current viewport row range

Source

pub fn set_crosshair(&mut self, row: usize, col: usize)

Set crosshair position in visual coordinates

Source

pub fn set_crosshair_row(&mut self, row: usize)

Set crosshair row position in visual coordinates with automatic viewport adjustment

Source

pub fn set_crosshair_column(&mut self, col: usize)

Set crosshair column position in visual coordinates with automatic viewport adjustment

Source

pub fn get_crosshair_col(&self) -> usize

Get crosshair column position in visual coordinates

Source

pub fn get_crosshair_row(&self) -> usize

Get crosshair row position in visual coordinates

Source

pub fn get_selected_row(&self) -> usize

Get selected row (alias for crosshair_row for compatibility)

Source

pub fn get_selected_column(&self) -> usize

Get selected column (alias for crosshair_col for compatibility)

Source

pub fn get_crosshair_position(&self) -> (usize, usize)

Get crosshair position as (row, column) tuple in visual coordinates

Source

pub fn get_scroll_offset(&self) -> (usize, usize)

Get scroll offset as (row_offset, col_offset)

Source

pub fn set_scroll_offset(&mut self, row_offset: usize, col_offset: usize)

Set scroll offset and update viewport accordingly

Source

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

Source

pub fn navigate_row_up(&mut self) -> RowNavigationResult

Navigate up one row

Source

pub fn navigate_row_down(&mut self) -> RowNavigationResult

Navigate down one row

Source

pub fn new(dataview: Arc<DataView>) -> Self

Create a new ViewportManager for a DataView

Source

pub fn set_dataview(&mut self, dataview: Arc<DataView>)

Update the underlying DataView

Source

pub fn reset_crosshair(&mut self)

Reset crosshair position to origin (0, 0)

Source

pub fn get_packing_mode(&self) -> ColumnPackingMode

Get the current column packing mode

Source

pub fn set_packing_mode(&mut self, mode: ColumnPackingMode)

Set the column packing mode and recalculate widths

Source

pub fn cycle_packing_mode(&mut self) -> ColumnPackingMode

Cycle to the next packing mode

Source

pub fn set_viewport( &mut self, row_offset: usize, col_offset: usize, width: u16, height: u16, )

Update viewport position and size

Source

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

Source

pub fn scroll_by(&mut self, row_delta: isize, col_delta: isize)

Scroll viewport by relative amount

Source

pub fn get_column_widths(&mut self) -> &[u16]

Get calculated column widths for current viewport

Source

pub fn get_column_width(&mut self, col_idx: usize) -> u16

Get column width for a specific column

Source

pub fn get_visible_rows(&self) -> Vec<DataRow>

Get visible rows in the current viewport

Source

pub fn get_visible_row(&self, viewport_row: usize) -> Option<DataRow>

Get a specific visible row by viewport-relative index

Source

pub fn get_visible_columns(&self) -> Vec<String>

Get visible column headers (only non-hidden columns that are in current viewport)

Source

pub fn viewport_rows(&self) -> Range<usize>

Get the current viewport row range

Source

pub fn viewport_cols(&self) -> Range<usize>

Get the current viewport column range

Source

pub fn is_row_visible(&self, row_idx: usize) -> bool

Check if a row is visible in the viewport

Source

pub fn is_column_visible(&self, col_idx: usize) -> bool

Check if a column is visible in the viewport

Source

pub fn total_rows(&self) -> usize

Get total row count from underlying view

Source

pub fn total_columns(&self) -> usize

Get total column count from underlying view

Source

pub fn get_terminal_width(&self) -> u16

Get terminal width in characters

Source

pub fn get_terminal_height(&self) -> usize

Get terminal height in rows

Source

pub fn invalidate_cache(&mut self)

Force cache recalculation on next access

Source

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!

Source

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

Source

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

Source

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

Source

pub fn dataview(&self) -> &DataView

Get a reference to the underlying DataView

Source

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

Source

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)

Source

pub fn debug_dump(&mut self, available_width: u16) -> String

Debug dump of ViewportManager state for F5 diagnostics

Source

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

Source

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)

Source

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]

Source

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)

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn calculate_efficiency_metrics( &mut self, available_width: u16, ) -> ViewportEfficiency

Calculate viewport efficiency metrics

Source

pub fn navigate_to_first_column(&mut self) -> NavigationResult

Navigate to the first column (first scrollable column after pinned columns) This centralizes the logic for first column navigation

Source

pub fn navigate_to_last_column(&mut self) -> NavigationResult

Navigate to the last column (rightmost visible column) This centralizes the logic for last column navigation

Source

pub fn navigate_column_left( &mut self, current_display_position: usize, ) -> NavigationResult

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

Source

pub fn navigate_column_right( &mut self, current_display_position: usize, ) -> NavigationResult

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

Source

pub fn page_down(&mut self) -> RowNavigationResult

Navigate one page down in the data

Source

pub fn page_up(&mut self) -> RowNavigationResult

Navigate one page up in the data

Source

pub fn half_page_down(&mut self) -> RowNavigationResult

Navigate half page down in the data

Source

pub fn half_page_up(&mut self) -> RowNavigationResult

Navigate half page up in the data

Source

pub fn navigate_to_last_row(&mut self, total_rows: usize) -> RowNavigationResult

Navigate to the last row in the data (like vim ‘G’ command)

Source

pub fn navigate_to_first_row( &mut self, total_rows: usize, ) -> RowNavigationResult

Navigate to the first row in the data (like vim ‘gg’ command)

Source

pub fn navigate_to_viewport_top(&mut self) -> RowNavigationResult

Navigate to the top of the current viewport (H in vim)

Source

pub fn navigate_to_viewport_middle(&mut self) -> RowNavigationResult

Navigate to the middle of the current viewport (M in vim)

Source

pub fn navigate_to_viewport_bottom(&mut self) -> RowNavigationResult

Navigate to the bottom of the current viewport (L in vim)

Source

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

Source

pub fn toggle_viewport_lock(&mut self) -> (bool, String)

Toggle viewport lock - prevents scrolling and constrains cursor to current viewport

Source

pub fn is_cursor_locked(&self) -> bool

Check if cursor is locked

Source

pub fn is_viewport_locked(&self) -> bool

Check if viewport is locked

Source

pub fn lock_viewport(&mut self)

Lock the viewport to prevent scrolling

Source

pub fn unlock_viewport(&mut self)

Unlock the viewport to allow scrolling

Source

pub fn reorder_column_left( &mut self, current_column: usize, ) -> ColumnReorderResult

Move the current column left in the display order (swap with previous column)

Source

pub fn reorder_column_right( &mut self, current_column: usize, ) -> ColumnReorderResult

Move the current column right in the display order (swap with next column)

Source

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

Source

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

Source

pub fn hide_empty_columns(&mut self) -> usize

Hide all empty columns Returns the number of columns hidden

Source

pub fn unhide_all_columns(&mut self)

Unhide all columns

Source

pub fn pin_column(&mut self, column_index: usize) -> bool

Pin the specified column Returns true if the column was pinned successfully, false otherwise

Source

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)

Source

pub fn goto_line(&mut self, target_row: usize) -> RowNavigationResult

Jump to a specific line (row) with centering

Source

pub fn hide_current_column_with_result(&mut self) -> ColumnOperationResult

Hide the current column (using crosshair position) and return unified result

Source

pub fn unhide_all_columns_with_result(&mut self) -> ColumnOperationResult

Unhide all columns and return unified result

Source

pub fn reorder_column_left_with_result(&mut self) -> ColumnOperationResult

Reorder column left and return unified result

Source

pub fn reorder_column_right_with_result(&mut self) -> ColumnOperationResult

Reorder column right and return unified result

Source

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

Source

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

Source

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

Source

pub fn reorder_column(&mut self, from_index: usize, to_index: usize) -> bool

Reorder a column from one position to another

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,