GitDiffModel class

A git diff viewer bubble.

Parses unified diff text and renders it with syntax highlighting, line numbers, and scrollable navigation via an embedded ViewportModel.

Example

final diff = GitDiffModel(width: 80, height: 24);
final loaded = diff.setDiff(rawDiffString);

// In update:
final (newDiff, cmd) = loaded.update(msg);

// In view:
print(loaded.view());
Inheritance

Constructors

GitDiffModel({int width = 80, int height = 24, bool showLineNumbers = true, bool wrapLines = true, bool zeroPadLineNumbers = false, DiffViewMode viewMode = DiffViewMode.unified, int horizontalOffset = 0, DiffStyles? styles, GitDiffKeyMap? keyMap, ViewportModel? viewport, List<DiffFile>? files, List<String>? renderedLines})
Creates a new git diff model.

Properties

files List<DiffFile>
The parsed diff files.
no setter
hashCode int
The hash code for this object.
no setterinherited
height int
Height of the diff viewer in rows.
final
horizontalOffset int
Horizontal scroll offset for side-by-side mode content.
final
keyMap GitDiffKeyMap
Key bindings for diff viewer actions.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showLineNumbers bool
Whether to display line numbers in the gutter.
final
styles DiffStyles
The styles used for rendering.
final
totalAdditions int
Total number of additions across all files.
latefinal
totalDeletions int
Total number of deletions across all files.
latefinal
viewMode DiffViewMode
Unified or side-by-side display mode.
final
viewport ViewportModel
The embedded viewport model (exposed for widget wrapping).
no setter
width int
Width of the diff viewer in columns.
final
wrapLines bool
Whether to wrap long lines that exceed the viewport width.
final
zeroPadLineNumbers bool
Whether to zero-pad line numbers (e.g. 0001) instead of space-padding (e.g. 1).
final

Methods

copyWith({int? width, int? height, bool? showLineNumbers, bool? wrapLines, bool? zeroPadLineNumbers, DiffViewMode? viewMode, int? horizontalOffset, DiffStyles? styles, GitDiffKeyMap? keyMap, ViewportModel? viewport, List<DiffFile>? files, List<String>? renderedLines}) GitDiffModel
Creates a copy with the given fields replaced.
init() Cmd?
Returns an optional command to execute on program startup.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rerender() GitDiffModel
Re-renders the existing parsed files with the current configuration.
setDiff(String rawDiff) GitDiffModel
Sets the raw unified diff content and parses it.
toString() String
A string representation of this object.
inherited
update(Msg msg) → (GitDiffModel, Cmd?)
Updates the component state in response to a message.
override
view() String
Renders the current model state for display.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited