Skip to main content

DiffView

Struct DiffView 

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

A diff viewer widget that displays text differences.

Supports unified and side-by-side display modes with color-coded added, removed, and unchanged lines.

Implementations§

Source§

impl DiffView

Source

pub fn new(old_text: &str, new_text: &str) -> Self

Create a new diff view comparing old and new text.

Source

pub fn with_mode(self, mode: DiffMode) -> Self

Set the display mode.

Source

pub fn with_unchanged_style(self, style: Style) -> Self

Set the style for unchanged lines.

Source

pub fn with_added_style(self, style: Style) -> Self

Set the style for added lines.

Source

pub fn with_removed_style(self, style: Style) -> Self

Set the style for removed lines.

Source

pub fn with_border(self, border: BorderStyle) -> Self

Set the border style.

Source

pub fn set_texts(&mut self, old_text: &str, new_text: &str)

Set new texts and recompute the diff.

Source

pub fn set_mode(&mut self, mode: DiffMode)

Switch display mode.

Source

pub fn mode(&self) -> DiffMode

Get the current display mode.

Source

pub fn line_count(&self) -> usize

Get the total number of display lines for the current mode.

Source

pub fn scroll_offset(&self) -> usize

Get the scroll offset.

Trait Implementations§

Source§

impl InteractiveWidget for DiffView

Source§

fn handle_event(&mut self, event: &Event) -> EventResult

Handle an input event. Returns whether the event was consumed.
Source§

impl Widget for DiffView

Source§

fn render(&self, area: Rect, buf: &mut ScreenBuffer)

Render this widget into the given area of the buffer.

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, 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, 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.