Skip to main content

DiffViewerState

Struct DiffViewerState 

Source
pub struct DiffViewerState {
    pub diff: DiffData,
    pub view_mode: DiffViewMode,
    pub scroll_y: usize,
    pub scroll_x: usize,
    pub visible_height: usize,
    pub visible_width: usize,
    pub selected_hunk: Option<usize>,
    pub show_line_numbers: bool,
    pub search: SearchState,
}
Expand description

State for the diff viewer widget

Fields§

§diff: DiffData

The diff data to display

§view_mode: DiffViewMode

Current view mode

§scroll_y: usize

Vertical scroll position

§scroll_x: usize

Horizontal scroll position

§visible_height: usize

Visible viewport height (set during render)

§visible_width: usize

Visible viewport width (set during render)

§selected_hunk: Option<usize>

Currently selected hunk index (for navigation)

§show_line_numbers: bool

Whether to show line numbers

§search: SearchState

Search state

Implementations§

Source§

impl DiffViewerState

Source

pub fn new(diff: DiffData) -> Self

Create a new diff viewer state with diff data

Source

pub fn from_unified_diff(text: &str) -> Self

Create a state from unified diff text

Source

pub fn empty() -> Self

Create an empty diff viewer state

Source

pub fn set_diff(&mut self, diff: DiffData)

Set the diff data

Source

pub fn scroll_up(&mut self)

Scroll up by one line

Source

pub fn scroll_down(&mut self)

Scroll down by one line

Source

pub fn scroll_left(&mut self)

Scroll left

Source

pub fn scroll_right(&mut self)

Scroll right

Source

pub fn page_up(&mut self)

Scroll up by one page

Source

pub fn page_down(&mut self)

Scroll down by one page

Source

pub fn go_to_top(&mut self)

Go to top

Source

pub fn go_to_bottom(&mut self)

Go to bottom

Source

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

Go to a specific line (0-indexed)

Source

pub fn next_hunk(&mut self)

Jump to the next hunk

Source

pub fn prev_hunk(&mut self)

Jump to the previous hunk

Source

pub fn jump_to_hunk(&mut self, index: usize)

Jump to a specific hunk by index

Source

pub fn next_change(&mut self)

Navigate to next change (addition or deletion)

Source

pub fn prev_change(&mut self)

Navigate to previous change (addition or deletion)

Source

pub fn toggle_view_mode(&mut self)

Toggle between side-by-side and unified view modes

Source

pub fn set_view_mode(&mut self, mode: DiffViewMode)

Set the view mode

Start search mode

Cancel search mode

Update search with current query

Source

pub fn next_match(&mut self)

Go to next search match

Source

pub fn prev_match(&mut self)

Go to previous search match

Trait Implementations§

Source§

impl Clone for DiffViewerState

Source§

fn clone(&self) -> DiffViewerState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DiffViewerState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.