Skip to main content

DiffReviewState

Struct DiffReviewState 

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

Persistent state for crate::DiffReviewWidget.

Implementations§

Source§

impl DiffReviewState

Source§

impl DiffReviewState

Source§

impl DiffReviewState

Source

pub fn new(document: Arc<DiffDocument>) -> Self

Creates ready state from an immutable document snapshot.

Source

pub fn with_theme(document: Arc<DiffDocument>, theme: ReviewTheme) -> Self

Creates ready state with a shared neutral theme.

Source

pub fn loading() -> Self

Creates loading state with an empty placeholder document.

Source

pub const fn session(&self) -> &ReviewSession

Source

pub const fn session_mut(&mut self) -> &mut ReviewSession

Source

pub const fn scope(&self) -> DiffScope

Source

pub fn set_scope(&mut self, scope: DiffScope)

Source

pub const fn document(&self) -> &Arc<DiffDocument>

Returns the current immutable snapshot.

Source

pub const fn review(&self) -> &Review

Returns the structured review.

Source

pub const fn review_mut(&mut self) -> &mut Review

Returns mutable review access for host-driven operations.

Source

pub const fn presentation(&self) -> &DiffPresentation

Source

pub const fn status(&self) -> &DiffReviewStatus

Returns the current load status.

Source

pub const fn focus(&self) -> FocusPane

Returns the focused pane.

Source

pub fn selected_file(&self) -> Option<usize>

Returns the selected file index, when the document has files.

Source

pub fn selected_row(&self) -> Option<usize>

Returns the selected presentation-row index, when rows exist.

Source

pub const fn selected_side(&self) -> DiffSide

Source

pub const fn theme(&self) -> &ReviewTheme

Returns the active renderer-neutral theme.

Source

pub const fn highlight_stats(&self) -> HighlightStats

Returns syntax cache and work counters.

Source

pub const fn scroll_offset(&self) -> usize

Returns the first visible rendered-row index in the selected file.

Source

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.

Source

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.

Source

pub const fn view_mode(&self) -> ViewMode

Returns the requested view mode.

Source

pub const fn layout(&self) -> Layout

Source

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.

Source

pub fn set_document(&mut self, document: Arc<DiffDocument>)

Replaces the complete document while retaining and reconciling review comments.

Source

pub fn set_loading(&mut self)

Marks the state as waiting for a host snapshot.

Source

pub fn set_error(&mut self, message: impl Into<String>)

Shows a host-provided loading error.

Source

pub fn set_repository_pending(&mut self)

Marks a repository mutation as in flight while retaining the current snapshot.

Source

pub fn clear_repository_pending(&mut self)

Clears a pending repository mutation without replacing the snapshot.

Source

pub fn set_repository_error(&mut self, message: impl Into<String>)

Shows a repository mutation error while retaining the current snapshot.

Source

pub fn set_background_error(&mut self, message: Option<String>)

Reconciles background refresh health independently of command completion.

Source

pub fn repository_pending(&self) -> bool

Whether a host command is still in flight.

Source

pub fn repository_error(&self) -> Option<&str>

The command error, or otherwise the current background refresh failure.

Source

pub fn set_theme(&mut self, theme: ReviewTheme)

Source

pub const fn options(&self) -> &ReviewOptions

Source

pub fn keybindings(&self) -> &[KeyBinding<DiffReviewCommand>]

Source

pub fn set_keybindings( &mut self, bindings: impl Into<Vec<KeyBinding<DiffReviewCommand>>>, )

Source

pub fn set_options(&mut self, options: ReviewOptions)

Source

pub fn theme_choices(&self) -> &[ThemeChoice]

Source

pub fn set_theme_choices(&mut self, themes: impl Into<Arc<[ThemeChoice]>>)

Source

pub fn reveal_selected_gap(&mut self, amount: RevealAmount) -> bool

Source

pub fn toggle_full_file(&mut self) -> bool

Source

pub fn set_view_mode(&mut self, mode: ViewMode)

Selects automatic, unified, or split presentation.

Source

pub fn clear_review(&mut self)

Clears all queued comments and any active draft.

Trait Implementations§

Source§

impl Debug for DiffReviewState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.