pub struct DiffView { /* private fields */ }Expand description
A git-style diff: added lines on a green tint, removed lines on a red one (the shared
success / danger colours, contrast-checked in both themes), old and new line numbers, a header
per hunk, and the unchanged runs between hunks folded to one line (“⋯ 12 unchanged lines”,
a click shows them). Each hunk keeps CONTEXT unchanged lines around its changes.
DiffView::json compares JSON by key (sorted keys, long arrays as one summary line: see
crate::diff). DiffView::reviewable adds Accept / Reject to each hunk; a choice emits
HunkDecision and stays shown. The header counts the lines and copies the diff as text.
Implementations§
Source§impl DiffView
impl DiffView
Sourcepub fn new(id: impl Into<SharedString>, diff: Diff) -> Self
pub fn new(id: impl Into<SharedString>, diff: Diff) -> Self
A view of diff. id names its elements (unique in the window).
Sourcepub fn text(id: impl Into<SharedString>, old: &str, new: &str) -> Self
pub fn text(id: impl Into<SharedString>, old: &str, new: &str) -> Self
The line diff of two texts.
Sourcepub fn json(id: impl Into<SharedString>, old: &str, new: &str) -> Self
pub fn json(id: impl Into<SharedString>, old: &str, new: &str) -> Self
Two JSON documents compared by key (Diff::json): reordered keys are not changes, long
arrays are one line.
Sourcepub fn title(self, title: impl Into<SharedString>) -> Self
pub fn title(self, title: impl Into<SharedString>) -> Self
A title in the header (a file name: session.json).
Sourcepub fn reviewable(self, reviewable: bool) -> Self
pub fn reviewable(self, reviewable: bool) -> Self
Accept / Reject buttons on each hunk (an agent’s proposed change under review).
Sourcepub fn set_diff(&mut self, diff: Diff, cx: &mut Context<'_, Self>)
pub fn set_diff(&mut self, diff: Diff, cx: &mut Context<'_, Self>)
Shows another diff (the decisions and unfolded runs are cleared).
Sourcepub fn decisions(&self) -> &[Option<bool>]
pub fn decisions(&self) -> &[Option<bool>]
The decision on each hunk so far (None: not decided).
Sourcepub fn decide(&mut self, hunk: usize, accept: bool, cx: &mut Context<'_, Self>)
pub fn decide(&mut self, hunk: usize, accept: bool, cx: &mut Context<'_, Self>)
Accepts or rejects hunk and tells the owner.
Sourcepub fn toggle_gap(&mut self, gap: usize, cx: &mut Context<'_, Self>)
pub fn toggle_gap(&mut self, gap: usize, cx: &mut Context<'_, Self>)
Shows (or folds again) the unchanged run Diff::gaps[gap].
Trait Implementations§
impl EventEmitter<HunkDecision> for DiffView
Auto Trait Implementations§
impl Forget for DiffView
impl Freeze for DiffView
impl Move for DiffView
impl RefUnwindSafe for DiffView
impl Send for DiffView
impl Sync for DiffView
impl Unpin for DiffView
impl UnsafeUnpin for DiffView
impl UnwindSafe for DiffView
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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 more