pub struct DiffViewer { /* private fields */ }Expand description
Pure diff viewer that renders into a caller-owned buffer.
Implementations§
Source§impl DiffViewer
impl DiffViewer
Sourcepub fn new(document: DiffDocument, options: DiffOptions) -> Self
pub fn new(document: DiffDocument, options: DiffOptions) -> Self
Creates a viewer with plain initial rendering state.
Sourcepub const fn document(&self) -> &DiffDocument
pub const fn document(&self) -> &DiffDocument
Returns the viewed document.
Sourcepub fn replace_file_diffs(&mut self, files: impl IntoIterator<Item = FileDiff>)
pub fn replace_file_diffs(&mut self, files: impl IntoIterator<Item = FileDiff>)
Replaces existing file diffs in place, matching them by id.
Sourcepub fn context_request(&self, change: ContextChange) -> Option<ContextRequest>
pub fn context_request(&self, change: ContextChange) -> Option<ContextRequest>
Prepares a repo refetch request for an asynchronous context update.
Sourcepub fn apply_context_update(
&mut self,
update: ContextUpdate,
area: Rect,
) -> bool
pub fn apply_context_update( &mut self, update: ContextUpdate, area: Rect, ) -> bool
Applies a completed asynchronous context update.
Sourcepub fn set_scroll(&mut self, scroll: usize)
pub fn set_scroll(&mut self, scroll: usize)
Sets the first visible rendered row.
Sourcepub fn set_collapsed_files(&mut self, collapsed_files: BTreeSet<FileId>)
pub fn set_collapsed_files(&mut self, collapsed_files: BTreeSet<FileId>)
Sets the collapsed file sections.
Sourcepub fn focused_file(&self) -> Option<FileId>
pub fn focused_file(&self) -> Option<FileId>
Returns the file containing the current focus.
Sourcepub fn apply(&mut self, action: DiffAction, area: Rect) -> ViewChange
pub fn apply(&mut self, action: DiffAction, area: Rect) -> ViewChange
Applies an action to the viewer state.
Sourcepub fn handle_input(&mut self, event: Event<()>, area: Rect) -> Control
pub fn handle_input(&mut self, event: Event<()>, area: Rect) -> Control
Applies one input event to the viewer.
Context-changing keys (., ,, x) are handled by the session loop,
which refetches diffs off the terminal thread, so they fall through here.
Sourcepub fn highlight_requests(&mut self, area: Rect) -> Vec<HighlightRequest>
pub fn highlight_requests(&mut self, area: Rect) -> Vec<HighlightRequest>
Returns highlight requests for visible source rows plus configured lookahead.
Sourcepub fn cancel_highlights(
&mut self,
requests: impl IntoIterator<Item = HighlightRequest>,
)
pub fn cancel_highlights( &mut self, requests: impl IntoIterator<Item = HighlightRequest>, )
Marks unprocessed highlight requests as requestable again.
Sourcepub fn apply_highlights(
&mut self,
results: impl IntoIterator<Item = HighlightResult>,
) -> bool
pub fn apply_highlights( &mut self, results: impl IntoIterator<Item = HighlightResult>, ) -> bool
Merges highlighted rows and returns whether a redraw is needed.
The word-diff overlay is applied here, once, so the cached Line is
ready to render with no per-frame merge work. All paths that write to the
cached highlighted rows keep this invariant: cached lines are render-ready
and already overlaid.
Sourcepub fn apply_visible_highlights<H>(
&mut self,
area: Rect,
highlighter: &mut H,
) -> boolwhere
H: DiffHighlighter + ?Sized,
pub fn apply_visible_highlights<H>(
&mut self,
area: Rect,
highlighter: &mut H,
) -> boolwhere
H: DiffHighlighter + ?Sized,
Highlights currently visible source rows through highlighter.
Event-loop owners can still use Self::highlight_requests and
Self::apply_highlights directly when highlight work runs
asynchronously.
Trait Implementations§
Source§impl Clone for DiffViewer
impl Clone for DiffViewer
Source§fn clone(&self) -> DiffViewer
fn clone(&self) -> DiffViewer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more