How dandavison/delta works
Delta is a terminal pager and renderer for Git and unified diffs, grep results, blame output, and merge conflicts. The principal flow is Git or another producer piping text to Delta: the CLI and configuration establish rendering options, the diff state machine parses input and dispatches specialized handlers, and the painter formats the result for terminal output and paging. Additional documented capabilities include syntax highlighting, word-level highlighting, navigation, hyperlinks, line numbers, and side-by-side wrapping. Some feature implementations were not sampled; their inclusion and links rely on the README, with uncertain wiring omitted.
Main entry points: delta.rs Diff state machine · cli.rs CLI options · paint.rs Diff painter · side_by_side.rs Side-by-side view
Components 22
Invocation and configuration
- CLI options
src/cli.rs - Render configuration
src/config.rs - Git configuration
src/git_config/mod.rs - Feature selection
src/features/mod.rs - Utility commands
src/subcommands/mod.rs
Input interpretation
- Diff state machine
src/delta.rs - Diff headers
src/handlers/diff_header.rs - Hunk headers
src/handlers/hunk_header.rs - Merge conflicts
src/handlers/merge_conflict.rs - Grep output
src/handlers/grep.rs - Blame output
src/handlers/blame.rs
Rendering features
- Diff painter
src/paint.rs - Word highlighting
src/edits.rs - Side-by-side view
src/features/side_by_side.rs - Line numbers
src/features/line_numbers.rs - Diff metadata
src/features/diff_line_metadata.rs - Hyperlinks
src/features/hyperlinks.rs - Line wrapping
src/wrapping.rs - Styles and colors
src/style.rs
Terminal output
- Pager output
src/utils/bat/output.rs
Other components
- Git / diff / grep
- Terminal
Connections 21
- Git / diff / grep → CLI options: pipes input to
- CLI options → Render configuration: configures
src/cli.rs - CLI options → Git configuration: reads settings
src/cli.rs - CLI options → Feature selection: selects features
src/cli.rs - CLI options → Utility commands: dispatches
src/cli.rs - CLI options → Diff state machine: starts rendering
- Diff state machine → Diff headers: dispatches headers
src/delta.rs - Diff state machine → Hunk headers: dispatches hunks
src/delta.rs - Diff state machine → Merge conflicts: dispatches conflicts
src/delta.rs - Diff state machine → Grep output: dispatches grep
src/delta.rs - Diff state machine → Blame output: dispatches blame
- Diff state machine → Diff painter: renders through
src/delta.rs - Diff painter → Word highlighting: uses edits
src/paint.rs - Diff painter → Side-by-side view: renders panels
src/paint.rs - Side-by-side view → Line numbers: formats numbers
src/features/side_by_side.rs - Diff painter → Diff metadata: applies metadata
src/paint.rs - Diff painter → Hyperlinks: applies links
src/paint.rs - Side-by-side view → Line wrapping: wraps lines
src/features/side_by_side.rs - Diff painter → Styles and colors: applies styles
src/paint.rs - Diff state machine → Pager output: writes output
- Pager output → Terminal: pages output
src/utils/bat/output.rs