Expand description
§hjkl-buffer
Rope-backed text buffer with vim-shaped semantics: charwise/linewise/
blockwise selection, motions matching vim edge cases (no h wrap, $
clamp, sticky col on j/k), folds, viewport, and search.
Extracted from sqeel-buffer with full git history. See
MIGRATION.md for the roadmap and stability contract.
§Features
ratatui(off by default): enables the [render] module with a direct cell-writeratatui::widgets::Widgetimpl forBuffer.
Structs§
- Buffer
- In-memory text buffer + cursor + viewport + per-row span cache.
- Buffer
View - Render-time wrapper around
&Bufferthat carries the optionalSelection+ aStyleResolver. Created per draw, dropped when the frame is done — cheap, holds only refs. - Fold
- Gutter
- Configuration for the line-number gutter rendered to the left of
the text area.
widthis the total cell count reserved (including any trailing spacer); the renderer right-aligns the 1-based row number into the leftmostwidth - 1cells. - Position
- A
(row, col)location inside acrate::Buffer. - Sign
- Single-cell marker painted into the leftmost gutter column for a
document row. Used by hosts to surface LSP diagnostics, git diff
signs, etc. Higher
prioritywins when multiple signs land on the same row. - Span
- One styled byte range on a buffer row.
- Viewport
- Where the buffer is scrolled to and how big the visible area is.
Enums§
- Edit
- One unit of buffer mutation. Constructed by the caller (vim
engine, ex command, …) and handed to
Buffer::apply_edit. - Motion
Kind - Granularity of a delete; preserved through undo so a linewise delete doesn’t come back as a charwise one.
- Selection
- First-class vim selection. Each variant carries the kind directly
rather than relying on a single char-range primitive with separate
“treat as line / block” overlays — that’s the whole point of
owning the buffer model. Anchor is where the user pressed
v/V/Ctrl-V; head moves with the cursor and is updated viaSelection::extend_to. - Wrap
- Soft-wrap mode controlling how doc rows wider than the text area
turn into multiple visual rows. Default is
Wrap::None— every doc row is exactly one screen row andtop_colclips the left side, mirroring vim’sset nowrapdefault for sqeel today.
Traits§
- Style
Resolver - Resolves an opaque
crate::Span::styleid to a real ratatui style. The buffer doesn’t know about colours; the host (sqeel-vim or any future user) keeps a lookup table.
Type Aliases§
- RowSpan
- Bounds of a selection on a particular row, expressed as inclusive
char-column range.
Nonemeans the row is outside the selection.Some((0, usize::MAX))is the convention for “whole row” — the renderer caps it at the row’s actual length.