summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 00:05:42 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:16:28 -0300
commit8d647e9c9fc747c14a222a53f9e3db1ba7a07d01 (patch)
tree9f935408a95fab551b5882c834fbf19352fdbc67 /src
parenta92951b11ab3aa2cdf759b3b743f8af006c21b95 (diff)
downloadpardes-8d647e9c9fc747c14a222a53f9e3db1ba7a07d01.tar.gz
pardes-8d647e9c9fc747c14a222a53f9e3db1ba7a07d01.zip
pardes, normal, edit: multi_on goes: outside a replay the replay state means one range, its first pass (index 0, count 1, first true), so setYank, registerValue, pushUndo and the open-lines and Tab checks read it plainly; Pardes's walked shape changes, so a client and a daemon from either side refuse each other (wire semantics)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
-rw-r--r--src/edit.zig13
-rw-r--r--src/normal.zig7
-rw-r--r--src/pardes.zig10
3 files changed, 14 insertions, 16 deletions
diff --git a/src/edit.zig b/src/edit.zig
index 5d46b80d..33b0f050 100644
--- a/src/edit.zig
+++ b/src/edit.zig
@@ -41,16 +41,15 @@ pub fn setYank(p: *Pardes, text: []const u8) void {
'*' => name = '+',
else => {},
}
- const one = !p.multi_on;
- p.registers.put(p.gpa, name, text, if (one) 0 else p.multi_index, if (one) 1 else p.multi_count, one or p.multi_first);
- if (name == '+' and (one or p.multi_first)) p.emit(.{ .set_clipboard = {} });
+ p.registers.put(p.gpa, name, text, p.multi_index, p.multi_count, p.multi_first);
+ if (name == '+' and p.multi_first) p.emit(.{ .set_clipboard = {} });
}
/// Value `i` of register `name` as the command at range `i` reads it, the
/// computed registers included: `#` is the range's number from 1, `.` its
/// text, `%` the file's name, `_` nothing. Scratch- or register-owned.
pub fn registerValue(p: *Pardes, t: *Text, name: u21) ?[]const u8 {
- const i = if (p.multi_on) p.multi_index else 0;
+ const i = p.multi_index;
return switch (name) {
'_' => null,
'#' => std.fmt.allocPrint(p.scratch.allocator(), "{d}", .{i + 1}) catch null,
@@ -671,7 +670,7 @@ pub fn enterInsert(p: *Pardes, t: *Text, where: InsertAt, cnt: usize) void {
t.cur_row = @as(i32, @intCast(if (below) row + 1 else row)) + eb.row0;
t.cur_col = @intCast(ind.len);
t.cur_pinned = true;
- if (cnt > 1 and !p.multi_on) opened: {
+ if (cnt > 1 and p.multi_count == 1) opened: {
const t2 = flatSurface(p, t) catch break :opened;
var rs: [Text.max_selections]modal.Selection = undefined;
const m = @min(cnt, Text.max_selections);
@@ -1006,7 +1005,7 @@ fn insertEdit(p: *Pardes, t: *Text, key: Key) void {
},
Key.tab => {
const ln = modal.lineSlice(text, c.row);
- if (!p.multi_on and c.col > 0 and c.col <= ln.len and ln[c.col - 1] == '.') dot: {
+ if (p.multi_count == 1 and c.col > 0 and c.col <= ln.len and ln[c.col - 1] == '.') dot: {
if (t.what != .body) break :dot;
const f = (t.pane() orelse break :dot).file orelse break :dot;
if (f.output != null or !lsp.speaks(f.path)) break :dot;
@@ -1985,7 +1984,7 @@ pub fn surroundReplace(p: *Pardes, t: *Text, from: u21, to: u21) void {
pub fn pushUndo(p: *Pardes, t: *Text) void {
// one keystroke, one undo step — even when it edited at ten cursors.
- if (p.multi_on and !p.multi_first) return;
+ if (!p.multi_first) return;
switch (t.what) {
// A B1 chord took its one undo point when it began (mouse.zig).
.body => if (p.chord_hold) return,
diff --git a/src/normal.zig b/src/normal.zig
index 34f5ef58..9e47cf45 100644
--- a/src/normal.zig
+++ b/src/normal.zig
@@ -48,7 +48,6 @@ fn normalInput(key: Key) modal.Normal.Input {
}
pub fn multiOnce(p: *Pardes) bool {
- if (!p.multi_on) return true;
p.multi_stop = true;
return p.multi_first;
}
@@ -527,7 +526,6 @@ pub fn replaySels(p: *Pardes, t: *Text, what: Replay) void {
// each pass's result: cursor and anchor cells as distances from the
// end of the surface text, plus the range's own j/k goal column
var res: [Text.max_selections]struct { cur: usize, anc: usize, sticky: i32 } = undefined;
- p.multi_on = true;
p.multi_stop = false;
var passes: usize = 0;
var i: usize = n;
@@ -569,8 +567,9 @@ pub fn replaySels(p: *Pardes, t: *Text, what: Replay) void {
co;
res[i] = .{ .cur = text.len - @min(co, text.len), .anc = text.len - @min(ao, text.len), .sticky = t.sticky_col };
}
- p.multi_on = false;
- p.multi_first = false;
+ p.multi_first = true;
+ p.multi_index = 0;
+ p.multi_count = 1;
if (p.multi_stop) {
p.multi_stop = false;
if (owner != null) {
diff --git a/src/pardes.zig b/src/pardes.zig
index bc0266c5..e46eb5f7 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -3946,12 +3946,12 @@ pub const Pardes = struct {
pdf_hover_preview: if (pdf_enabled) ?look.PdfWordPreview else void = if (pdf_enabled) null else {},
wheel_guard: u8 = 0,
ctrl_w_pending: bool = false,
- multi_on: bool = false,
- multi_first: bool = false,
+ /// While a key is replayed across the ranges (normal.replaySels): which
+ /// range this pass is, in document order, how many there are, and
+ /// whether this is the first pass; outside a replay, the one range and
+ /// its first pass. A register value belongs to its range by this index.
+ multi_first: bool = true,
multi_stop: bool = false,
- /// While a key is replayed across the ranges: which range this pass is,
- /// in document order, and how many there are. A register value belongs
- /// to its range by this index.
multi_index: usize = 0,
multi_count: usize = 1,
/// The register the running normal command names (`"<reg>`); 0 for the