summaryrefslogtreecommitdiff
path: root/src/Text.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 00:35:15 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:17:28 -0300
commitd5158f6a69ce5a1af6372c140b07379ee0ba2446 (patch)
treeec722719840f59263e4b7dbc740681594b526274 /src/Text.zig
parent3b31e0484bd06658f10cd9165b76cb1ca3b198bd (diff)
downloadpardes-d5158f6a69ce5a1af6372c140b07379ee0ba2446.tar.gz
pardes-d5158f6a69ce5a1af6372c140b07379ee0ba2446.zip
Text, edit, normal, look, Query and their readers: the second selection form msel (whole rows r0..r1, for search-result highlights) goes; a visited search result and a query preview's place line are an explicit vsel like any other, back from the line's end (to the result's location start, the line's start for ordinary path:line rows; to the start for a preview line), and every msel branch in the edit ops, the drawing, the terminal's position tracking and the chords goes (visible: the result's highlight covers its line's characters and newline cell instead of the whole row width, with the ordinary selection colours; y, d and c on it act on that range as after x, its newline included, so a yanked result pastes as a line); selections.md and the ; Alt-; X Alt-x rows of helix-keys.md no longer describe msel; Text's walked shape changes (wire semantics)
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.zig23
1 files changed, 2 insertions, 21 deletions
diff --git a/src/Text.zig b/src/Text.zig
index 1d0df183..5e36467f 100644
--- a/src/Text.zig
+++ b/src/Text.zig
@@ -23,13 +23,6 @@ pub const Mode = enum { normal, insert, tty };
/// characters live and whether moving the cursor scrolls a body.
pub const What = enum { body, tag, input, column, workspace };
-/// A modal line selection (helix `x`): whole rows [r0, r1], absolute.
-pub const LineSel = struct {
- active: bool = false,
- r0: i32 = 0,
- r1: i32 = 0,
-};
-
pub const CharSel = struct {
active: bool = false,
row: i32 = 0,
@@ -62,7 +55,6 @@ mode: Mode = .normal,
cur_pinned: bool = false,
cur_row: i32 = 0,
cur_col: i32 = 0,
-msel: LineSel = .{},
vsel: CharSel = .{},
/// The ranges beside the primary, `nsel` of them: room for max_selections - 1
/// made when a second range appears and given back when the selection is one
@@ -178,14 +170,6 @@ pub fn insertVerticalCursor(lines: []const []const u8, c: modal.Cursor, down: bo
pub fn primaryRange(t: *Text, text: []const u8, row0: i32) modal.Selection {
const c = File.textOffset(t, text, .{ .row = @intCast(@max(0, t.cur_row - row0)), .col = @intCast(@max(0, t.cur_col)) });
- if (t.msel.active) {
- // legacy line selection (file-search results highlight): linewise
- const r0: usize = @intCast(@max(0, @min(t.msel.r0, t.msel.r1) - row0));
- const r1: usize = @intCast(@max(0, @max(t.msel.r0, t.msel.r1) - row0));
- const s = modal.lineStartOffset(text, r0);
- const e = if (r1 + 1 >= modal.cursorLineCount(text)) text.len else modal.lineStartOffset(text, r1 + 1);
- return .{ .anchor = s, .head = @max(e, modal.nextGrapheme(text, c)) };
- }
// Both ends through the line index, as the cursor's: cellRange counts
// lines from the top for each, a pass over a big file per call (the
// places' settle and every insert-mode key asked it).
@@ -230,7 +214,6 @@ pub fn setRange(t: *Text, text: []const u8, row0: i32, r0: modal.Selection, expl
.col = @intCast(ac.col),
.explicit = explicit or t.select,
};
- t.msel.active = false;
t.dropSels(); // writing ONE range means the selection IS that range
t.cur_pinned = true;
t.sticky_col = -1;
@@ -332,7 +315,7 @@ pub fn multiSelAction(t: *Text, text: []const u8, role: modal.Normal.Role, cnt:
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;
+ const expl = t.vsel.active and t.vsel.explicit;
if (role == .remove_primary_sel) {
if (n < 2) return; // helix: "no selections remaining"
var out: [max_selections]modal.Selection = undefined;
@@ -690,7 +673,7 @@ pub fn shrinkSelToLineBounds(t: *Text, text: []const u8, range: modal.Selection)
var end = lineStartOrEof(text, span.end + 1);
if (start != from) start = lineStartOrEof(text, span.start + 1);
if (end != to) end = modal.lineStartOffset(text, span.end);
- const expl = (t.vsel.active and t.vsel.explicit) or t.msel.active;
+ const expl = t.vsel.active and t.vsel.explicit;
const r: modal.Selection = if (range.head < range.anchor)
.{ .anchor = end, .head = start }
else
@@ -708,7 +691,6 @@ pub fn clampCursor(t: *Text, text: []const u8, row0: i32) void {
t.cur_col = @intCast(@min(@as(usize, @intCast(@max(0, t.cur_col))), llen));
t.cur_pinned = true;
t.vsel.active = false;
- t.msel.active = false;
t.show();
}
@@ -756,6 +738,5 @@ pub fn step(t: *Text, gpa: std.mem.Allocator, current: ?terminal.EditBuffer, bac
t.cur_col = back_to.cur_col;
t.cur_pinned = true;
t.vsel = back_to.vsel;
- t.msel.active = false;
return back_to;
}