summaryrefslogtreecommitdiff
path: root/src/normal.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 05:53:16 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit3dd2072fc525cdadf4f55a69f745c73c0b8c2b21 (patch)
treebbde59afec92eab134c9d8db248ff9369530d952 /src/normal.zig
parent2b04f877c29cf1e95c2fc8154de1da322c7299a3 (diff)
downloadpardes-3dd2072fc525cdadf4f55a69f745c73c0b8c2b21.tar.gz
pardes-3dd2072fc525cdadf4f55a69f745c73c0b8c2b21.zip
edit: the edits of a text take the editing context (docs/next-editor.md, R2, second slice): enterInsert, exitInsert, handleInsert, insertKey, insertEdit, insertTab, pasteRegister, pasteText, normalDelete, normalYank, normalChange, deleteSelection, setEditCells, normalReplaceChar, chordReplace, replaceWithText, normalCase, normalJoin, normalRotateContents, normalAlign, normalIndent, normalToggleComment, normalAdjustNumber, addNewline, textobjectSelect and the three surrounds take `e: Editor`; insertEdit's splice end is `stop` and a comment extension `x` where they were `e`; 71 calls in 8 files hand `p.editor()`; core-test 810 of 949, shell-test 989 of 992, hxdiff 658 / parity 738 / hxgolf 124 with 0 mismatches, replicas pass
Diffstat (limited to 'src/normal.zig')
-rw-r--r--src/normal.zig58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/normal.zig b/src/normal.zig
index a344269c..29addd66 100644
--- a/src/normal.zig
+++ b/src/normal.zig
@@ -460,7 +460,7 @@ pub fn replaySels(p: *Pardes, t: *Text, what: Replay) void {
t.sticky_col = list[i].sticky;
(switch (what) {
.normal => |normal_action| executeNormalAction(p, t, normal_action),
- .insert => |insert_key| edit.insertKey(p, t, insert_key),
+ .insert => |insert_key| edit.insertKey(p.editor(), t, insert_key),
}) catch |err| p.reportError(p.view().active, "edit", err);
if (p.multi_stop) break;
if (i == pri) {
@@ -956,7 +956,7 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) edit.Error!
pane.clearPointerSelection(sel_slot);
pane.sel[sel_slot].state = .none;
};
- if (raw_selection and a.role == .yank) return edit.normalYank(p, t);
+ if (raw_selection and a.role == .yank) return edit.normalYank(p.editor(), t);
edit.pinPaneCursor(p.editor(), t);
const text = try edit.flatSurface(p.editor(), t);
const range = t.primaryRange(text, 0);
@@ -1038,19 +1038,19 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) edit.Error!
t.find_ch = a.char;
return findMove(t, text, range, a.char, t.find_op.?, a.count);
},
- .replace_prefix => return edit.normalReplaceChar(p, t, a.char),
+ .replace_prefix => return edit.normalReplaceChar(p.editor(), t, a.char),
// `mm`
.match_prefix => {
const lines = try edit.paneCursorLines(p.editor(), t);
const mc = modal.matchBracket(lines, modal.positionAt(text, cur)) orelse return;
return pointMove(t, text, range, modal.offsetAt(text, mc));
},
- .match_inside, .match_around => return edit.textobjectSelect(p, t, text, a.char, a.role == .match_around),
- .surround_add => return edit.surroundAdd(p, t, a.char),
- .surround_delete => return edit.surroundDelete(p, t, a.char),
- .surround_replace => return edit.surroundReplace(p, t, a.from, a.char),
+ .match_inside, .match_around => return edit.textobjectSelect(p.editor(), t, text, a.char, a.role == .match_around),
+ .surround_add => return edit.surroundAdd(p.editor(), t, a.char),
+ .surround_delete => return edit.surroundDelete(p.editor(), t, a.char),
+ .surround_replace => return edit.surroundReplace(p.editor(), t, a.from, a.char),
.goto_paragraph => return t.setRange(text, 0, modal.moveParagraph(text, range, a.count, a.forward, t.select), false),
- .add_newline => return edit.addNewline(p, t, a.forward, a.count),
+ .add_newline => return edit.addNewline(p.editor(), t, a.forward, a.count),
.goto_diagnostic, .goto_diagnostic_end => {
// Once a Diagnostics query fed them, the diagnostics are this
// text's places: ]d and [d step them as n and N do, ]D and [D
@@ -1107,7 +1107,7 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) edit.Error!
.open_below => .open_below,
else => .open_above,
};
- return edit.enterInsert(p, t, where, a.count);
+ return edit.enterInsert(p.editor(), t, where, a.count);
},
.select_mode => {
if (t.select) {
@@ -1137,24 +1137,24 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) edit.Error!
// the body wherever it is pressed, as acme's Look from a tag does.
inline .select_regex, .split_regex, .keep_regex, .remove_regex => |role| return startSelRegex(p, pane, t, @field(modal.Normal.RegexMode, @tagName(role)[0 .. @tagName(role).len - "_regex".len])),
inline .expand_node, .shrink_node, .next_sibling, .prev_sibling, .all_siblings, .all_children, .parent_node_end, .parent_node_start => |role| return nodeSelect(p, pane, t, @field(modal.Normal.NodeWalk, @tagName(role))),
- .delete => return edit.normalDelete(p, t, true),
- .delete_noyank => return edit.normalDelete(p, t, false),
- .change => return edit.normalChange(p, t),
- .yank => return edit.normalYank(p, t),
- .replace_with_yank => return edit.pasteRegister(p, t, .replace, a.count),
- .paste_after => return edit.pasteRegister(p, t, .after, a.count),
- .paste_before => return edit.pasteRegister(p, t, .before, a.count),
- .switch_case => return edit.normalCase(p, t, .toggle),
- .to_lowercase => return edit.normalCase(p, t, .lower),
- .to_uppercase => return edit.normalCase(p, t, .upper),
- .join_lines => return edit.normalJoin(p, t, false),
- .join_select_space => return edit.normalJoin(p, t, true),
- .rotate_contents_fwd => return edit.normalRotateContents(p, t, true, a.count),
- .rotate_contents_back => return edit.normalRotateContents(p, t, false, a.count),
- .align_selections => return edit.normalAlign(p, t),
- .indent => return edit.normalIndent(p, t, a.count, true),
- .unindent => return edit.normalIndent(p, t, a.count, false),
- .comment_toggle => return edit.normalToggleComment(p, t),
+ .delete => return edit.normalDelete(p.editor(), t, true),
+ .delete_noyank => return edit.normalDelete(p.editor(), t, false),
+ .change => return edit.normalChange(p.editor(), t),
+ .yank => return edit.normalYank(p.editor(), t),
+ .replace_with_yank => return edit.pasteRegister(p.editor(), t, .replace, a.count),
+ .paste_after => return edit.pasteRegister(p.editor(), t, .after, a.count),
+ .paste_before => return edit.pasteRegister(p.editor(), t, .before, a.count),
+ .switch_case => return edit.normalCase(p.editor(), t, .toggle),
+ .to_lowercase => return edit.normalCase(p.editor(), t, .lower),
+ .to_uppercase => return edit.normalCase(p.editor(), t, .upper),
+ .join_lines => return edit.normalJoin(p.editor(), t, false),
+ .join_select_space => return edit.normalJoin(p.editor(), t, true),
+ .rotate_contents_fwd => return edit.normalRotateContents(p.editor(), t, true, a.count),
+ .rotate_contents_back => return edit.normalRotateContents(p.editor(), t, false, a.count),
+ .align_selections => return edit.normalAlign(p.editor(), t),
+ .indent => return edit.normalIndent(p.editor(), t, a.count, true),
+ .unindent => return edit.normalIndent(p.editor(), t, a.count, false),
+ .comment_toggle => return edit.normalToggleComment(p.editor(), t),
.undo => return edit.undoStep(p.editor(), t, true),
.redo => return edit.undoStep(p.editor(), t, false),
// Language shortcuts run the same builtins as tags and leader commands.
@@ -1165,8 +1165,8 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) edit.Error!
.goto_type_definition => return p.lspRequest(v.active, .type_definition, ""),
.goto_implementation => return p.lspRequest(v.active, .implementation, ""),
.format => return p.lspRequest(v.active, .format, ""),
- .increment => return edit.normalAdjustNumber(p, t, @intCast(a.count)),
- .decrement => return edit.normalAdjustNumber(p, t, -@as(i64, @intCast(a.count))),
+ .increment => return edit.normalAdjustNumber(p.editor(), t, @intCast(a.count)),
+ .decrement => return edit.normalAdjustNumber(p.editor(), t, -@as(i64, @intCast(a.count))),
.leader => if (p.macro.replaying == 0) {
v.prefix = .leader;
v.leader_n = 0;