summaryrefslogtreecommitdiff
path: root/src/Text.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 00:20:16 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:17:28 -0300
commit3b31e0484bd06658f10cd9165b76cb1ca3b198bd (patch)
treed12169502b6b3a5b38be989ca4f0afd9e78a7ebd /src/Text.zig
parent26649273cc253319fdd833923928aa883e3f884c (diff)
downloadpardes-3b31e0484bd06658f10cd9165b76cb1ca3b198bd.tar.gz
pardes-3b31e0484bd06658f10cd9165b76cb1ca3b198bd.zip
modal, normal, pdf_view, Text, syntax, edit: one key layer: an Action is the role the key named and what it was given (a count, a literal, ] or [), not a second union of sixteen sub-enums the roles were mapped onto one if at a time; a context's roles are tried in their enum order, the pending prefix and m sub-key are roles too, the text's executor and the PDF's switch flat on the role, and pdf_view.applyNormal(core, pane, action) does what a page cannot (Last, the leader, the tag, a search) instead of handing a seven-value enum back; no key does anything new; Text.normal's walked shape changes (wire semantics); helix-keys.md says how the keys are read
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Text.zig')
-rw-r--r--src/Text.zig20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Text.zig b/src/Text.zig
index 1fbf8321..1d0df183 100644
--- a/src/Text.zig
+++ b/src/Text.zig
@@ -328,12 +328,12 @@ pub fn setRanges(t: *Text, text: []const u8, in: []const modal.Selection, sticky
t.nsel = @intCast(w);
}
-pub fn multiSelAction(t: *Text, text: []const u8, kind: modal.Normal.Multi, cnt: usize) void {
+pub fn multiSelAction(t: *Text, text: []const u8, role: modal.Normal.Role, cnt: usize) void {
var rs: [max_selections]modal.Selection = undefined;
const got = ranges(t, text, 0, &rs);
const n = got.n;
const expl = (t.vsel.active and t.vsel.explicit) or t.msel.active;
- if (kind == .remove_primary) {
+ if (role == .remove_primary_sel) {
if (n < 2) return; // helix: "no selections remaining"
var out: [max_selections]modal.Selection = undefined;
var m: usize = 0;
@@ -346,12 +346,12 @@ pub fn multiSelAction(t: *Text, text: []const u8, kind: modal.Normal.Multi, cnt:
// previous one when the primary was last
return setRanges(t, text, out[0..m], &.{}, @min(got.pri, m - 1), expl);
}
- if (kind == .rotate_forward or kind == .rotate_backward) {
+ if (role == .rotate_sel_fwd or role == .rotate_sel_back) {
const turn = cnt % n;
- const pri = if (kind == .rotate_forward) (got.pri + turn) % n else (got.pri + (n - turn)) % n;
+ const pri = if (role == .rotate_sel_fwd) (got.pri + turn) % n else (got.pri + (n - turn)) % n;
return setRanges(t, text, rs[0..n], &.{}, pri, expl);
}
- if (kind == .merge) {
+ if (role == .merge_sels) {
// helix merge_selections: first.merge(last) — the ranges are
// sorted, so that is simply the whole span
const lo = @min(rs[0].anchor, rs[0].head);
@@ -360,7 +360,7 @@ pub fn multiSelAction(t: *Text, text: []const u8, kind: modal.Normal.Multi, cnt:
const one: modal.Selection = if (rev) .{ .anchor = hi, .head = lo } else .{ .anchor = lo, .head = hi };
return setRanges(t, text, &.{one}, &.{}, 0, expl);
}
- if (kind == .merge_consecutive) {
+ if (role == .merge_consecutive_sels) {
var out: [max_selections]modal.Selection = undefined;
var m: usize = 0;
var pri: usize = 0;
@@ -378,7 +378,7 @@ pub fn multiSelAction(t: *Text, text: []const u8, kind: modal.Normal.Multi, cnt:
}
return setRanges(t, text, out[0..m], &.{}, pri, expl);
}
- if (kind == .ensure_forward) {
+ if (role == .ensure_forward) {
// helix ensure_selections_forward: every range points forward
for (rs[0..n]) |*r| {
const from = @min(r.anchor, r.head);
@@ -387,7 +387,7 @@ pub fn multiSelAction(t: *Text, text: []const u8, kind: modal.Normal.Multi, cnt:
}
return setRanges(t, text, rs[0..n], &.{}, got.pri, expl);
}
- if (kind == .split_newline) {
+ if (role == .split_sel_newline) {
// helix selection::split_on_newline — one range per line the
// selection covers, the newlines themselves left out
var out: [max_selections]modal.Selection = undefined;
@@ -418,7 +418,7 @@ pub fn multiSelAction(t: *Text, text: []const u8, kind: modal.Normal.Multi, cnt:
if (m == 0) return;
return setRanges(t, text, out[0..m], &.{}, 0, true); // helix keeps primary 0
}
- if (kind == .trim) {
+ if (role == .trim_sels) {
// helix trim_selections: whitespace off both ends; ranges that are
// empty or all whitespace are dropped entirely
var out: [max_selections]modal.Selection = undefined;
@@ -450,7 +450,7 @@ pub fn multiSelAction(t: *Text, text: []const u8, kind: modal.Normal.Multi, cnt:
}
return setRanges(t, text, out[0..m], &.{}, pri, expl);
}
- const below = kind == .copy_below;
+ const below = role == .copy_sel_below;
var out: [max_selections]modal.Selection = undefined;
var m: usize = 0;
var pri: usize = 0;