pub struct DiffReviewState { /* private fields */ }Expand description
Persistent state for crate::DiffReviewWidget.
Implementations§
Source§impl DiffReviewState
impl DiffReviewState
pub fn command_for_key(&self, key: KeyEvent) -> Option<DiffReviewCommand>
pub fn command_context(&self) -> CommandContext
pub fn set_capabilities(&mut self, capabilities: ReviewCapabilities)
pub fn command_enabled(&self, command: &DiffReviewCommand) -> bool
pub fn handle_command( &mut self, command: impl Into<DiffReviewCommand>, ) -> InputOutcome<DiffReviewEvent>
Source§impl DiffReviewState
impl DiffReviewState
pub fn interaction_phase(&self) -> InteractionPhase
pub fn handle_input( &mut self, input: ReviewInput, ) -> InputOutcome<DiffReviewEvent>
Source§impl DiffReviewState
impl DiffReviewState
Sourcepub fn new(document: Arc<DiffDocument>) -> Self
pub fn new(document: Arc<DiffDocument>) -> Self
Creates ready state from an immutable document snapshot.
Sourcepub fn with_theme(document: Arc<DiffDocument>, theme: ReviewTheme) -> Self
pub fn with_theme(document: Arc<DiffDocument>, theme: ReviewTheme) -> Self
Creates ready state with a shared neutral theme.
pub const fn session(&self) -> &ReviewSession
pub const fn session_mut(&mut self) -> &mut ReviewSession
pub const fn scope(&self) -> DiffScope
pub fn set_scope(&mut self, scope: DiffScope)
Sourcepub const fn document(&self) -> &Arc<DiffDocument> ⓘ
pub const fn document(&self) -> &Arc<DiffDocument> ⓘ
Returns the current immutable snapshot.
Sourcepub const fn review_mut(&mut self) -> &mut Review
pub const fn review_mut(&mut self) -> &mut Review
Returns mutable review access for host-driven operations.
pub const fn presentation(&self) -> &DiffPresentation
Sourcepub const fn status(&self) -> &DiffReviewStatus
pub const fn status(&self) -> &DiffReviewStatus
Returns the current load status.
Sourcepub fn selected_file(&self) -> Option<usize>
pub fn selected_file(&self) -> Option<usize>
Returns the selected file index, when the document has files.
Sourcepub fn selected_row(&self) -> Option<usize>
pub fn selected_row(&self) -> Option<usize>
Returns the selected presentation-row index, when rows exist.
pub const fn selected_side(&self) -> DiffSide
Sourcepub const fn theme(&self) -> &ReviewTheme
pub const fn theme(&self) -> &ReviewTheme
Returns the active renderer-neutral theme.
Sourcepub const fn highlight_stats(&self) -> HighlightStats
pub const fn highlight_stats(&self) -> HighlightStats
Returns syntax cache and work counters.
Sourcepub const fn scroll_offset(&self) -> usize
pub const fn scroll_offset(&self) -> usize
Returns the first visible rendered-row index in the selected file.
Sourcepub const fn is_dirty(&self) -> bool
pub const fn is_dirty(&self) -> bool
Returns whether anything since the last frame changed what a redraw would show.
Hosts may skip drawing crate::DiffReviewWidget while this is false,
which keeps pointer motion in a terminal reporting all mouse movement
from costing a frame each. Rendering the widget clears it.
Sourcepub const fn mark_dirty(&mut self)
pub const fn mark_dirty(&mut self)
Marks the state as needing a redraw, for changes the widget cannot observe on its own, such as a terminal resize.
pub const fn layout(&self) -> Layout
Sourcepub const fn cursor_position(&self) -> Option<Position>
pub const fn cursor_position(&self) -> Option<Position>
Returns the terminal cursor position for an active comment draft.
Hosts may pass this to Frame::set_cursor_position after rendering.
Sourcepub fn set_document(&mut self, document: Arc<DiffDocument>)
pub fn set_document(&mut self, document: Arc<DiffDocument>)
Replaces the complete document while retaining and reconciling review comments.
Sourcepub fn set_loading(&mut self)
pub fn set_loading(&mut self)
Marks the state as waiting for a host snapshot.
Sourcepub fn set_repository_pending(&mut self)
pub fn set_repository_pending(&mut self)
Marks a repository mutation as in flight while retaining the current snapshot.
Sourcepub fn clear_repository_pending(&mut self)
pub fn clear_repository_pending(&mut self)
Clears a pending repository mutation without replacing the snapshot.
Sourcepub fn set_repository_error(&mut self, message: impl Into<String>)
pub fn set_repository_error(&mut self, message: impl Into<String>)
Shows a repository mutation error while retaining the current snapshot.
Sourcepub fn set_background_error(&mut self, message: Option<String>)
pub fn set_background_error(&mut self, message: Option<String>)
Reconciles background refresh health independently of command completion.
Sourcepub fn repository_pending(&self) -> bool
pub fn repository_pending(&self) -> bool
Whether a host command is still in flight.
Sourcepub fn repository_error(&self) -> Option<&str>
pub fn repository_error(&self) -> Option<&str>
The command error, or otherwise the current background refresh failure.
pub fn set_theme(&mut self, theme: ReviewTheme)
pub const fn options(&self) -> &ReviewOptions
pub fn keybindings(&self) -> &[KeyBinding<DiffReviewCommand>]
pub fn set_keybindings( &mut self, bindings: impl Into<Vec<KeyBinding<DiffReviewCommand>>>, )
pub fn set_options(&mut self, options: ReviewOptions)
pub fn theme_choices(&self) -> &[ThemeChoice]
pub fn set_theme_choices(&mut self, themes: impl Into<Arc<[ThemeChoice]>>)
pub fn reveal_selected_gap(&mut self, amount: RevealAmount) -> bool
pub fn toggle_full_file(&mut self) -> bool
Sourcepub fn set_view_mode(&mut self, mode: ViewMode)
pub fn set_view_mode(&mut self, mode: ViewMode)
Selects automatic, unified, or split presentation.
Sourcepub fn clear_review(&mut self)
pub fn clear_review(&mut self)
Clears all queued comments and any active draft.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DiffReviewState
impl RefUnwindSafe for DiffReviewState
impl Send for DiffReviewState
impl Sync for DiffReviewState
impl Unpin for DiffReviewState
impl UnsafeUnpin for DiffReviewState
impl UnwindSafe for DiffReviewState
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
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