Add visual mode, node registers, search and the jump list (stage 8c)
The rest of vim, on nodes. Visual mode takes in what lies between where it started and the cursor: on the canvas, every node the rectangle from one end's box to the other's touches; in the outline and the Note view, the nodes in between in reading order. V takes whole branches, Ctrl+click and Ctrl+drag pick with the mouse, and the operators take exactly what's selected: d, y, > and <, M, and the pickers on every node at once. Registers now hold text or nodes, so yy, dd and x keep what they take and p, P and ]p paste it, layout and links included. "+ is the system clipboard through arboard: nodes go there as Markdown in the user's format (## headings, a --- tag list, the body), and come back whole while the clipboard still holds them. clipboard = "unnamedplus" makes plain yanks use it, as in vim. . repeats the last change made with keys, with the text typed after it. / opens a Telescope-style search: fuzzy matches over titles, tags and bodies, best first, with the note of the one you're on beside them; n and N go on with it, and :find searches straight away. Each pane keeps a jump list for Ctrl-o and Ctrl-i that crosses documents and reopens closed ones. Capital marks lead into any document and, like the small ones, are kept in memory.ron. gd follows a cross-link, and :marks, :jumps and :registers list what they hold. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
abe3dc1d84
commit
7bec5bf3fc
45 files changed
+3922
-272
No files matched your search
+21
-5
@@ -19,12 +19,12 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
use super::App;
|
||||
use super::action::{DocAction, Keep, Message, SaveWhich, Tone};
|
||||
use super::buffer::Buffer;
|
||||
use super::documents::{Access, BufferId, DocFile, Documents, Open, Trouble};
|
||||
use super::mode::Mode;
|
||||
use super::popup::Popup;
|
||||
use super::{App, Pane};
|
||||
use crate::config::paths::Paths;
|
||||
use crate::model::{CanvasPos, DocUid, Document, NodeId, Title};
|
||||
use crate::storage::backup::{self, Day};
|
||||
@@ -185,6 +185,7 @@ impl App {
|
||||
if open.buffer.doc().contains(cursor) {
|
||||
open.buffer.apply(DocAction::MoveCursor { to: cursor, jump: false });
|
||||
}
|
||||
open.buffer.keep_marks(place.marks.iter().map(|(&name, &id)| (name, NodeId::new(id))));
|
||||
open.camera =
|
||||
Some(Camera { origin: CanvasPos::new(place.x, place.y), zoom: zoom_named(&place.zoom) });
|
||||
}
|
||||
@@ -216,6 +217,7 @@ impl App {
|
||||
zoom: camera.zoom.name().to_lowercase(),
|
||||
x: camera.origin.x,
|
||||
y: camera.origin.y,
|
||||
marks: open.buffer.marks().iter().map(|(&name, id)| (name, id.get())).collect(),
|
||||
};
|
||||
self.memory.places.insert(open.buffer.doc().uid().to_string(), place);
|
||||
}
|
||||
@@ -556,7 +558,7 @@ impl App {
|
||||
let next = self.shared.docs.at(index.saturating_sub(1));
|
||||
let camera = self.shared.docs.get(next).camera;
|
||||
for (_, pane) in self.panes.iter_mut().filter(|(_, pane)| pane.buffer == id) {
|
||||
*pane = Pane::new(next, pane.view.kind(), camera);
|
||||
pane.show(next, pane.view.kind(), camera);
|
||||
}
|
||||
Some(Message::done(format!("closed {name}")))
|
||||
}
|
||||
@@ -618,9 +620,20 @@ impl App {
|
||||
None
|
||||
}
|
||||
|
||||
/// The focused pane shows document `id`, in the same kind of view. Its
|
||||
/// canvas camera stays with the document it showed.
|
||||
/// The focused pane shows document `id`, in the same kind of view: a
|
||||
/// jump, so `Ctrl-o` comes back.
|
||||
pub(super) fn show(&mut self, id: BufferId) {
|
||||
if self.buffer() != id {
|
||||
let from = self.place_here();
|
||||
self.jumping(from);
|
||||
self.switch_to(id);
|
||||
}
|
||||
}
|
||||
|
||||
/// The focused pane shows document `id`, in the same kind of view. Its
|
||||
/// canvas camera stays with the document it showed, and a selection
|
||||
/// ends.
|
||||
pub(super) fn switch_to(&mut self, id: BufferId) {
|
||||
let pane = self.panes.current_mut();
|
||||
if pane.buffer == id {
|
||||
return;
|
||||
@@ -629,7 +642,10 @@ impl App {
|
||||
self.shared.docs.get_mut(pane.buffer).camera = Some(camera);
|
||||
}
|
||||
let camera = self.shared.docs.get(id).camera;
|
||||
*pane = Pane::new(id, pane.view.kind(), camera);
|
||||
pane.show(id, pane.view.kind(), camera);
|
||||
if let Mode::Visual(_) = self.shared.mode {
|
||||
self.shared.mode = Mode::Normal;
|
||||
}
|
||||
}
|
||||
|
||||
/// The message for a change refused because the document is read-only.
|
||||
|
||||
Reference in new issue
Block a user