Add vim-style editor features: hybrid line numbers, cursor-centered viewport, and rendered markdown #10

Manually merged
mdoorn merged 4 commits from feat/010-add-vim-style-editor-features-hybrid-line-numb into master 2026-03-23 17:15:18 +01:00
Owner

Add vim-style editor features: hybrid line numbers, cursor-centered viewport, and rendered markdown

Along the way:

  • Improve markdown rendering with LaTeX-style typography and fix empty line height in word-wrap
  • Add three-layer markdown mode: Read, Normal, and Edit
  • Add vim-style buffer search (/) and project-wide search (//)

Touches 16 files: Cargo.lock, ck-editor/Cargo.toml, ck-editor/src/buffer/mod.rs, ck-editor/src/view/gutter.rs, ck-editor/src/view/input.rs, ck-editor/src/view/mod.rs and 10 more.

Add vim-style editor features: hybrid line numbers, cursor-centered viewport, and rendered markdown Along the way: - Improve markdown rendering with LaTeX-style typography and fix empty line height in word-wrap - Add three-layer markdown mode: Read, Normal, and Edit - Add vim-style buffer search (/) and project-wide search (//) Touches 16 files: `Cargo.lock`, `ck-editor/Cargo.toml`, `ck-editor/src/buffer/mod.rs`, `ck-editor/src/view/gutter.rs`, `ck-editor/src/view/input.rs`, `ck-editor/src/view/mod.rs` and 10 more.
mdoorn approved these changes 2026-03-21 15:28:33 +01:00
mdoorn left a comment

Reads well. One question on ck-editor/src/view/render_markdown.rs, nothing blocking.

Reads well. One question on `ck-editor/src/view/render_markdown.rs`, nothing blocking.
@ -582,1 +582,4 @@
/// Search forward for `pattern` starting after `from`. Wraps around.
/// Returns the position of the first char of the match, or None.
pub fn search_forward(&self, from: Position, pattern: &str) -> Option<Position> {
Owner

search_forward is public. Does anything outside the crate call it, or is it pub because that was easier? Every public item is a promise.

`search_forward` is public. Does anything outside the crate call it, or is it pub because that was easier? Every public item is a promise.
@ -0,0 +407,4 @@
..Default::default()
};
// Pad with thin spaces for visual breathing room
self.job.append("\u{2009}", 0.0, format.clone());
Owner

append is cloned on what looks like a hot path. Is the ownership forced here, or can this borrow?

`append` is cloned on what looks like a hot path. Is the ownership forced here, or can this borrow?
Author
Owner

It can borrow. The clone of append was left over from before the lifetime was threaded through ck-editor/src/view/render_markdown.rs, and it is gone.

It can borrow. The clone of `append` was left over from before the lifetime was threaded through `ck-editor/src/view/render_markdown.rs`, and it is gone.
Author
Owner

Nothing outside calls search_forward. It is pub(crate) in ck-editor/src/buffer/mod.rs now.

Nothing outside calls `search_forward`. It is pub(crate) in `ck-editor/src/buffer/mod.rs` now.
- Gutter shows both relative offset and absolute line number (like vim number + relativenumber)
- Viewport is cursor-driven with no ScrollArea: cursor stays centered, top/bottom zones clamp naturally
- Scroll wheel moves cursor instead of viewport, j/k scrolling works correctly
- Markdown files render as rich text in Navigate mode (pulldown-cmark), raw source with word-wrap in Edit mode
- Added markdown theme tokens to EditorTheme for headings, code blocks, blockquotes, links
- Centre content in a 680px A4-ish column with 48px page padding
- Larger heading sizes (28/22/18px) with clear hierarchy and underline rules on H1/H2
- Body text at 15px proportional with 1.6x line height for readability
- Styled blockquotes with left border bar and tinted background
- Code blocks with rounded corners, generous padding, monospace font
- Centred horizontal rules at 60% width
- Fix empty lines in word-wrap mode collapsing to zero height (clamp to line_height)
Markdown files now have three states cycled with Esc:
- Read: rendered rich markdown (Esc → Normal, i/a/o → Edit)
- Normal: raw source with cursor and vim navigation (Esc → Read)
- Edit: raw source with text insertion (Esc → Normal)

Header shows READ/NAV/EDT indicator to reflect the active layer.
Buffer search: press / in Navigate mode to search within the current file.
Highlights all matches with galley-aware positioning that handles word-wrap
correctly. n/N for next/previous match, Escape or :noh to clear highlights.

Project search: press // (slash twice) to open a modal searching all project
files with results showing file:line and matched text.
mdoorn manually merged commit b4d15d5d23 into master 2026-03-23 17:15:18 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
northgale/ckeditor!10
No description provided.