pub struct Diff { /* private fields */ }Expand description
A widget that computes and renders a colored diff between two texts.
Supports both unified (git-style) and side-by-side display.
§Example
use gilt::diff::{Diff, DiffStyle};
let diff = Diff::new("old text\n", "new text\n")
.with_labels("a/file.rs", "b/file.rs")
.with_context(3);Implementations§
Source§impl Diff
impl Diff
Sourcepub fn new(old_text: &str, new_text: &str) -> Self
pub fn new(old_text: &str, new_text: &str) -> Self
Create a new Diff with default settings (unified, 3 context lines).
Sourcepub fn with_labels(self, old: &str, new: &str) -> Self
pub fn with_labels(self, old: &str, new: &str) -> Self
Set the labels for old and new texts.
Sourcepub fn with_style(self, style: DiffStyle) -> Self
pub fn with_style(self, style: DiffStyle) -> Self
Set the display style.
Sourcepub fn with_context(self, lines: usize) -> Self
pub fn with_context(self, lines: usize) -> Self
Set the number of context lines around changes.
Sourcepub fn side_by_side(old_text: &str, new_text: &str) -> Self
pub fn side_by_side(old_text: &str, new_text: &str) -> Self
Create a side-by-side diff with default settings.
Source§impl Diff
impl Diff
Sourcepub fn measure(
&self,
_console: &Console,
_options: &ConsoleOptions,
) -> Measurement
pub fn measure( &self, _console: &Console, _options: &ConsoleOptions, ) -> Measurement
Measure the minimum and maximum widths needed to render this diff.
Trait Implementations§
Source§impl Renderable for Diff
impl Renderable for Diff
Source§fn gilt_console(
&self,
_console: &Console,
options: &ConsoleOptions,
) -> Vec<Segment>
fn gilt_console( &self, _console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Produce segments for rendering on the given console with given options.
Auto Trait Implementations§
impl Freeze for Diff
impl RefUnwindSafe for Diff
impl Send for Diff
impl Sync for Diff
impl Unpin for Diff
impl UnsafeUnpin for Diff
impl UnwindSafe for Diff
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> RenderableExt for Twhere
T: Renderable + 'static,
impl<T> RenderableExt for Twhere
T: Renderable + 'static,
Source§fn into_boxed_renderable(self) -> RenderableBox
fn into_boxed_renderable(self) -> RenderableBox
Convert this renderable into a
RenderableBox for type-erased storage. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more