Skip to main content

CopyModeState

Struct CopyModeState 

Source
pub struct CopyModeState {
Show 14 fields pub active: bool, pub cursor_col: usize, pub cursor_absolute_line: usize, pub visual_mode: VisualMode, pub selection_anchor: Option<(usize, usize)>, pub count: Option<usize>, pub pending_operator: Option<PendingOperator>, pub marks: HashMap<char, Mark>, pub cols: usize, pub rows: usize, pub scrollback_len: usize, pub search_query: String, pub search_direction: SearchDirection, pub is_searching: bool, /* private fields */
}
Expand description

Copy mode state machine.

Uses absolute line indexing:

  • Line 0 = oldest scrollback line
  • Line scrollback_len - 1 = newest scrollback line
  • Line scrollback_len = top of visible screen (at scroll_offset=0)
  • Line scrollback_len + rows - 1 = bottom of visible screen

Fields§

§active: bool

Whether copy mode is active

§cursor_col: usize

Cursor column position

§cursor_absolute_line: usize

Cursor absolute line position

§visual_mode: VisualMode

Current visual selection mode

§selection_anchor: Option<(usize, usize)>

Selection anchor point (absolute_line, col) - set when entering visual mode

§count: Option<usize>

Count prefix for motions (e.g., 5j moves down 5 lines)

§pending_operator: Option<PendingOperator>

Pending operator waiting for a motion

§marks: HashMap<char, Mark>

Named marks (a-z)

§cols: usize

Terminal columns

§rows: usize

Terminal rows

§scrollback_len: usize

Scrollback buffer length

§search_query: String

Current search query

§search_direction: SearchDirection

Search direction

§is_searching: bool

Whether search input mode is active

Implementations§

Source§

impl CopyModeState

Source

pub fn new() -> Self

Create a new inactive copy mode state

Source

pub fn enter( &mut self, cursor_col: usize, cursor_row: usize, cols: usize, rows: usize, scrollback_len: usize, )

Enter copy mode at the given cursor position

Source

pub fn exit(&mut self)

Exit copy mode, clearing all state

Source

pub fn push_count_digit(&mut self, digit: u8)

Push a digit to the count prefix

Source

pub fn effective_count(&mut self) -> usize

Get the effective count (defaults to 1 if no count set)

Source

pub fn move_left(&mut self)

Move cursor left by count

Source

pub fn move_right(&mut self)

Move cursor right by count

Source

pub fn move_up(&mut self)

Move cursor up by count

Source

pub fn move_down(&mut self)

Move cursor down by count

Source

pub fn move_to_line_start(&mut self)

Move cursor to start of line

Source

pub fn move_to_line_end(&mut self)

Move cursor to end of line

Source

pub fn move_to_first_non_blank(&mut self, line_text: &str)

Move cursor to first non-blank character on the line

Source

pub fn move_word_forward(&mut self, line_text: &str, word_chars: &str)

Move forward to start of next word

Source

pub fn move_word_backward(&mut self, line_text: &str, word_chars: &str)

Move backward to start of previous word

Source

pub fn move_word_end(&mut self, line_text: &str, word_chars: &str)

Move forward to end of current/next word

Source

pub fn move_big_word_forward(&mut self, line_text: &str)

Move forward to start of next WORD (whitespace-delimited)

Source

pub fn move_big_word_backward(&mut self, line_text: &str)

Move backward to start of previous WORD (whitespace-delimited)

Source

pub fn move_big_word_end(&mut self, line_text: &str)

Move forward to end of current/next WORD (whitespace-delimited)

Source

pub fn half_page_up(&mut self)

Move half page up

Source

pub fn half_page_down(&mut self)

Move half page down

Source

pub fn page_up(&mut self)

Move full page up

Source

pub fn page_down(&mut self)

Move full page down

Source

pub fn goto_top(&mut self)

Go to top of buffer (line 0)

Source

pub fn goto_bottom(&mut self)

Go to bottom of buffer (last line)

Source

pub fn goto_line(&mut self, line: usize)

Go to specific absolute line (for count+G)

Source

pub fn toggle_visual_char(&mut self)

Toggle character-wise visual mode

Source

pub fn toggle_visual_line(&mut self)

Toggle line-wise visual mode

Source

pub fn toggle_visual_block(&mut self)

Toggle block/rectangular visual mode

Source

pub fn compute_selection(&self, scroll_offset: usize) -> Option<Selection>

Compute a Selection from the current visual mode state.

The selection coordinates are in screen-relative terms (row = line - viewport_top) for rendering. scroll_offset is the current viewport scroll position.

Source

pub fn set_mark(&mut self, name: char)

Set a named mark at the current cursor position

Source

pub fn goto_mark(&mut self, name: char) -> bool

Jump to a named mark, returning true if the mark exists

Start search input mode

Source

pub fn search_input(&mut self, ch: char)

Add a character to the search query

Source

pub fn search_backspace(&mut self)

Remove the last character from the search query

Cancel search mode without executing

Source

pub fn screen_cursor_pos(&self, scroll_offset: usize) -> Option<(usize, usize)>

Get the cursor position in screen coordinates, if visible.

Returns (col, row) where row is relative to the viewport top. Returns None if the cursor is outside the visible viewport.

Source

pub fn required_scroll_offset(&self, current_offset: usize) -> Option<usize>

Calculate the scroll offset needed to make the cursor visible.

Returns Some(new_offset) if scrolling is needed, None if cursor is already visible.

Source

pub fn update_dimensions( &mut self, cols: usize, rows: usize, scrollback_len: usize, )

Update the scrollback length (call when terminal state changes)

Source

pub fn status_text(&self) -> String

Get a status line description of the current mode

Trait Implementations§

Source§

impl Default for CopyModeState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,