From ab806dc38ddcd74958b999fe708ae9ea63609f72 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 18:56:04 -0300 Subject: A mouse sweep selects a stream, as acme's does, not a rectangle A B1, B2 or B3 drag over several lines took the same columns from every row, a block. acme's sweep is a stream (libframe/frselect.c:115-140, frselectpaint; acme text.c:881, textselect): the first row from the press to its end, the rows between whole, the last from its start to the release. edit.sweepCols says which columns of a row a sweep takes; the captured spans, the text a sweep yields (copy, chords, B2 and B3 operands, a terminal's automatic yank) and the highlight all follow it, in bodies, multi-row tags, terminals and text-rendered PDFs; a row the sweep runs through is highlighted to the edge, and rows after the first leave out the line numbers. Native PDF selection was already MuPDF's stream. No pane keeps a rectangle. exec-bigdrag's golden changes: its middle sweep now runs whole lines. Co-Authored-By: Claude Opus 5.5 --- src/body_layer.zig | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/body_layer.zig') diff --git a/src/body_layer.zig b/src/body_layer.zig index a0195fb8..413ab7de 100644 --- a/src/body_layer.zig +++ b/src/body_layer.zig @@ -72,7 +72,7 @@ fn paintTerminalSelection(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, rows: [ hi = @min(hi, line.len); if (lo >= hi) continue; var col = panes.File.rawDisplayCol(line, lo); - const end = panes.File.rawDisplayCol(line, hi); + const end = if (row.to_edge and hi == line.len) width else panes.File.rawDisplayCol(line, hi); while (col < end and col < width) : (col += 1) { const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(visible))); cell.default = false; @@ -103,7 +103,7 @@ fn paintSourceSelection(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, rows: []c const hi = @min(end, row.hi); if (lo >= hi) continue; var col = prefix + @as(i32, @intCast(panes.File.rawDisplayCol(line[start..], lo - start))); - const last = prefix + @as(i32, @intCast(panes.File.rawDisplayCol(line[start..], hi - start))); + const last = if (row.to_edge and hi == end) @as(i32, width) else prefix + @as(i32, @intCast(panes.File.rawDisplayCol(line[start..], hi - start))); while (col < last and col < width) : (col += 1) { const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(visible))); cell.default = false; @@ -130,13 +130,12 @@ pub fn paintPointerSelection( fg: ?[3]u8, ) void { if (pane.pointerSelection(sl)) |rows| return paintSourceSelection(p, s, pane, r, rows, bg, fg); - const r0 = @min(sl.r0, sl.r1); - const r1 = @max(sl.r0, sl.r1); - const c0 = @max(0, @min(sl.c0, sl.c1)); - const c1 = @max(0, @max(sl.c0, sl.c1)); var row: u16 = 0; while (row < r.h) : (row += 1) { - if (@as(i32, row) < r0 or @as(i32, row) > r1 or row < from_row) continue; + if (row < from_row) continue; + const cols = edit.sweepCols(sl, row) orelse continue; + const c0: i32 = if (cols.first) cols.lo else 0; + const c1: i32 = cols.hi orelse std.math.maxInt(i16); const sy = if (row < pane.tag_rows) tag_y + row else body_y + row - pane.tag_rows; // File line numbers occupy a gutter only in the body. The tag is // row zero in Sel space and starts at its real first text cell. -- cgit v1.3