Skip to main content

Crate hjkl_buffer

Crate hjkl_buffer 

Source
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-write ratatui::widgets::Widget impl for Buffer.

Structs§

Buffer
In-memory text buffer + cursor + viewport + per-row span cache.
BufferView
Render-time wrapper around &Buffer that carries the optional Selection + a StyleResolver. 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. width is the total cell count reserved (including any trailing spacer); the renderer right-aligns the 1-based row number into the leftmost width - 1 cells.
Position
A (row, col) location inside a crate::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 priority wins 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.
MotionKind
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 via Selection::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 and top_col clips the left side, mirroring vim’s set nowrap default for sqeel today.

Traits§

StyleResolver
Resolves an opaque crate::Span::style id 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. None means 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.