pub struct SplitViewState {
pub active_buffer: BufferId,
pub keyed_states: HashMap<BufferId, BufferViewState>,
pub open_buffers: Vec<BufferId>,
pub tab_scroll_offset: usize,
pub layout: Option<Layout>,
pub layout_dirty: bool,
pub focus_history: Vec<BufferId>,
pub sync_group: Option<u32>,
pub composite_view: Option<BufferId>,
}Expand description
Per-split view state (independent of buffer content)
Following the Emacs model where each window (split) has its own:
- Point (cursor position) - independent per split
- Window-start (scroll position) - independent per split
- Tabs (open buffers) - independent per split
Buffer-specific state (cursors, viewport, view_mode, compose settings) is stored
in the keyed_states map, keyed by BufferId. The active buffer’s state is
accessible via Deref/DerefMut (so vs.cursors transparently accesses the
active buffer’s cursors), or explicitly via active_state()/active_state_mut().
Fields§
§active_buffer: BufferIdWhich buffer is currently active in this split
keyed_states: HashMap<BufferId, BufferViewState>Per-buffer view state map. The active buffer always has an entry.
open_buffers: Vec<BufferId>List of buffer IDs open in this split’s tab bar (in order) The currently displayed buffer is tracked in the SplitNode::Leaf
tab_scroll_offset: usizeHorizontal scroll offset for the tabs in this split
layout: Option<Layout>Computed layout for this view (from view_transform or base tokens) This is View state - each split has its own Layout
layout_dirty: boolWhether the layout needs to be rebuilt (buffer changed, transform changed, etc.)
focus_history: Vec<BufferId>Focus history stack for this split (most recent at end) Used for “Switch to Previous Tab” and for returning to previous buffer when closing
sync_group: Option<u32>Sync group ID for synchronized scrolling Splits with the same sync_group will scroll together
composite_view: Option<BufferId>When set, this split renders a composite view (e.g., side-by-side diff). The split’s buffer_id is the focused source buffer, but rendering uses the composite layout. This makes the source buffer the “active buffer” so normal keybindings work directly.
Implementations§
Source§impl SplitViewState
impl SplitViewState
Sourcepub fn with_buffer(width: u16, height: u16, buffer_id: BufferId) -> Self
pub fn with_buffer(width: u16, height: u16, buffer_id: BufferId) -> Self
Create a new split view state with an initial buffer open
Sourcepub fn active_state(&self) -> &BufferViewState
pub fn active_state(&self) -> &BufferViewState
Get the active buffer’s view state
Sourcepub fn active_state_mut(&mut self) -> &mut BufferViewState
pub fn active_state_mut(&mut self) -> &mut BufferViewState
Get a mutable reference to the active buffer’s view state
Sourcepub fn switch_buffer(&mut self, new_buffer_id: BufferId)
pub fn switch_buffer(&mut self, new_buffer_id: BufferId)
Switch the active buffer in this split.
If the new buffer has a saved state in keyed_states, it is restored.
Otherwise a default BufferViewState is created with the split’s current
viewport dimensions.
Sourcepub fn buffer_state(&self, buffer_id: BufferId) -> Option<&BufferViewState>
pub fn buffer_state(&self, buffer_id: BufferId) -> Option<&BufferViewState>
Get the view state for a specific buffer (if it exists)
Sourcepub fn buffer_state_mut(
&mut self,
buffer_id: BufferId,
) -> Option<&mut BufferViewState>
pub fn buffer_state_mut( &mut self, buffer_id: BufferId, ) -> Option<&mut BufferViewState>
Get a mutable reference to the view state for a specific buffer (if it exists)
Sourcepub fn ensure_buffer_state(
&mut self,
buffer_id: BufferId,
) -> &mut BufferViewState
pub fn ensure_buffer_state( &mut self, buffer_id: BufferId, ) -> &mut BufferViewState
Ensure a buffer has keyed state, creating a default if needed. Returns a mutable reference to the buffer’s view state.
Sourcepub fn remove_buffer_state(&mut self, buffer_id: BufferId)
pub fn remove_buffer_state(&mut self, buffer_id: BufferId)
Remove keyed state for a buffer (when buffer is closed from this split)
Sourcepub fn invalidate_layout(&mut self)
pub fn invalidate_layout(&mut self)
Mark layout as needing rebuild (call after buffer changes)
Sourcepub fn ensure_layout(
&mut self,
tokens: &[ViewTokenWire],
source_range: Range<usize>,
tab_size: usize,
) -> &Layout
pub fn ensure_layout( &mut self, tokens: &[ViewTokenWire], source_range: Range<usize>, tab_size: usize, ) -> &Layout
Ensure layout is valid, rebuilding if needed. Returns the Layout - never returns None. Following VSCode’s ViewModel pattern.
§Arguments
tokens- ViewTokenWire array (from view_transform or built from buffer)source_range- The byte range this layout coverstab_size- Tab width for rendering
Sourcepub fn get_layout(&self) -> Option<&Layout>
pub fn get_layout(&self) -> Option<&Layout>
Get the current layout if it exists and is valid
Sourcepub fn add_buffer(&mut self, buffer_id: BufferId)
pub fn add_buffer(&mut self, buffer_id: BufferId)
Add a buffer to this split’s tabs (if not already present)
Sourcepub fn remove_buffer(&mut self, buffer_id: BufferId)
pub fn remove_buffer(&mut self, buffer_id: BufferId)
Remove a buffer from this split’s tabs and clean up its keyed state
Sourcepub fn has_buffer(&self, buffer_id: BufferId) -> bool
pub fn has_buffer(&self, buffer_id: BufferId) -> bool
Check if a buffer is open in this split
Sourcepub fn push_focus(&mut self, buffer_id: BufferId)
pub fn push_focus(&mut self, buffer_id: BufferId)
Push a buffer to the focus history (LRU-style) If the buffer is already in history, it’s moved to the end
Sourcepub fn previous_buffer(&self) -> Option<BufferId>
pub fn previous_buffer(&self) -> Option<BufferId>
Get the most recently focused buffer (without removing it)
Sourcepub fn remove_from_history(&mut self, buffer_id: BufferId)
pub fn remove_from_history(&mut self, buffer_id: BufferId)
Remove a buffer from the focus history (called when buffer is closed)
Methods from Deref<Target = BufferViewState>§
Sourcepub fn ensure_cursor_visible(
&mut self,
buffer: &mut Buffer,
marker_list: &MarkerList,
)
pub fn ensure_cursor_visible( &mut self, buffer: &mut Buffer, marker_list: &MarkerList, )
Resolve fold ranges and ensure the primary cursor is visible.
This is the preferred entry point for all non-rendering callers — it
resolves hidden fold byte ranges from the marker list and passes them
to viewport.ensure_visible so that line counting skips folded lines.
Sourcepub fn apply_config_defaults(
&mut self,
line_numbers: bool,
highlight_current_line: bool,
line_wrap: bool,
wrap_indent: bool,
wrap_column: Option<usize>,
rulers: Vec<usize>,
)
pub fn apply_config_defaults( &mut self, line_numbers: bool, highlight_current_line: bool, line_wrap: bool, wrap_indent: bool, wrap_column: Option<usize>, rulers: Vec<usize>, )
Apply editor config defaults for display settings.
Sets show_line_numbers, highlight_current_line, line_wrap,
wrap_column, and rulers from the given config values. Call this after
creating a new BufferViewState (via new() or ensure_buffer_state())
to ensure the view respects the user’s settings.
Sourcepub fn activate_page_view(&mut self, page_width: Option<usize>)
pub fn activate_page_view(&mut self, page_width: Option<usize>)
Activate page view (compose mode) with an optional page width.
This sets the view mode to Compose, disables builtin line wrap (the compose plugin handles wrapping), hides line numbers, and optionally sets the compose width for centering.
Trait Implementations§
Source§impl Clone for SplitViewState
impl Clone for SplitViewState
Source§fn clone(&self) -> SplitViewState
fn clone(&self) -> SplitViewState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SplitViewState
impl Debug for SplitViewState
Source§impl Deref for SplitViewState
impl Deref for SplitViewState
Source§type Target = BufferViewState
type Target = BufferViewState
Source§fn deref(&self) -> &BufferViewState
fn deref(&self) -> &BufferViewState
Source§impl DerefMut for SplitViewState
impl DerefMut for SplitViewState
Source§fn deref_mut(&mut self) -> &mut BufferViewState
fn deref_mut(&mut self) -> &mut BufferViewState
Auto Trait Implementations§
impl Freeze for SplitViewState
impl RefUnwindSafe for SplitViewState
impl Send for SplitViewState
impl Sync for SplitViewState
impl Unpin for SplitViewState
impl UnsafeUnpin for SplitViewState
impl UnwindSafe for SplitViewState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more