summaryrefslogtreecommitdiff
path: root/src/mouse.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-08 12:03:46 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:15 -0300
commit1ecb9b720840ea8e4753823fa8cddcf5d6a3a4d2 (patch)
tree973976c63f560201638d453b4b8b277d9cb40040 /src/mouse.zig
parent13d5613b77c62c425c3a124a34c0c2528cc6251f (diff)
downloadpardes-1ecb9b720840ea8e4753823fa8cddcf5d6a3a4d2.tar.gz
pardes-1ecb9b720840ea8e4753823fa8cddcf5d6a3a4d2.zip
Add a readable static Callstack pane and align tagline text
Diffstat (limited to 'src/mouse.zig')
-rw-r--r--src/mouse.zig26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/mouse.zig b/src/mouse.zig
index 733479dd..536a4fdb 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -100,7 +100,7 @@ pub const HeaderSweep = struct {
/// as a pane tag's sweep stays on its tag.
fn headerPoint(p: *Pardes, column: ?usize, mcol: u16, mrow: u16, clamp: bool) ?struct { t: *panes.Text, text: []const u8, line: u16, at: usize } {
const t = if (column) |c| &p.col_tags[c] else &p.global_tag;
- const x = if (column) |c| p.col_x[c] + TAG_TEXT_INSET else 0;
+ const x = if (column) |c| p.col_x[c] + TAG_TEXT_INSET else TAG_TEXT_INSET;
const focused = p.header_focus and p.header_column == column;
const text = edit.flatSurface(p, t) catch return null;
const base = if (column != null) p.topBarHeight() else 0;
@@ -588,7 +588,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
p.header_drag = false;
return;
};
- const x = if (p.header_column) |c| p.col_x[c] + TAG_TEXT_INSET else 0;
+ const x = if (p.header_column) |c| p.col_x[c] + TAG_TEXT_INSET else TAG_TEXT_INSET;
const text = edit.flatSurface(p, t) catch return;
// `row` is the header's row on screen, `line` the line of its text
// shown there.
@@ -612,7 +612,8 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
pane.closePrompt();
};
var column: ?usize = null;
- var x: u16 = 0;
+ var x: u16 = TAG_TEXT_INSET;
+ if (mcol < x) return;
if (mrow >= p.topBarHeight()) {
for (0..p.ncol) |c| if (mcol >= p.col_x[c] and mcol < p.col_x[c] + p.col_w[c]) {
column = c;
@@ -1047,7 +1048,7 @@ fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand:
const top = lead[0] - @as(i32, pane.tag_rows);
if (top < 0) break :lead null;
const w = pane.wrapAt(top);
- const col = edit.paneByteAtDisplay(p, &pane.body, w.line, w.at, lead[1] - panes.File.gutterWidth(pane));
+ const col = edit.paneByteAtDisplay(p, &pane.body, w.line, w.at, lead[1] - panes.File.gutterWidth(pane) - w.pad);
break :lead .{
.row = @intCast(@max(0, w.line)),
.col = @intCast(@max(0, col)),
@@ -1154,7 +1155,7 @@ fn sweepPoint(p: *Pardes, pane: *panes.Pane, r: i32, c: i32) ?modal.Cursor {
if (visible < 0) return null;
const w = pane.wrapAt(visible);
if (w.line < 0) return null;
- const col = edit.paneByteAtDisplay(p, &pane.body, w.line, w.at, c - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0));
+ const col = edit.paneByteAtDisplay(p, &pane.body, w.line, w.at, c - w.pad - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0));
return .{ .row = @intCast(w.line), .col = @intCast(@max(0, col)) };
}
@@ -1268,7 +1269,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
&pane.body,
w.line,
w.at,
- sl.c1 - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0),
+ sl.c1 - w.pad - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0),
);
pane.body.cur_pinned = true;
if (edit.clampFileCursor(&pane.body)) pane.ensureCursorVisible();
@@ -1312,7 +1313,14 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
pane.sel[b] = expanded
else if (operand.text == null)
pane.sel[b].state = .none;
- if (s.button == config.look_button and clk.r0 >= pane.tag_rows and pane.body.mode != .tty) {
+ if (s.button == config.look_button and clk.r0 >= pane.tag_rows and pane.body.mode != .tty and operand.expanded != null) {
+ // This click chose a new word. An old keyboard anchor
+ // must not stretch to it; borrowed selections retain
+ // their original cursor and extent.
+ pane.body.vsel.active = false;
+ pane.body.msel.active = false;
+ pane.body.nsel = 0;
+ pane.body.select = false;
pane.body.cur_row = operand.row;
pane.body.cur_col = operand.col;
if (edit.clampFileCursor(&pane.body)) pane.ensureCursorVisible();
@@ -1431,8 +1439,8 @@ fn chordCutPaste(p: *Pardes, cut: bool) void {
const w1 = pane.wrapAt(@max(0, sl.r1 - @as(i32, pane.tag_rows)));
const row0 = w0.line;
const row1 = w1.line;
- const col0 = edit.paneByteAtDisplay(p, &pane.body, w0.line, w0.at, sl.c0 - pfx);
- const col1 = edit.paneByteAtDisplay(p, &pane.body, w1.line, w1.at, sl.c1 - pfx);
+ const col0 = edit.paneByteAtDisplay(p, &pane.body, w0.line, w0.at, sl.c0 - pfx - w0.pad);
+ const col1 = edit.paneByteAtDisplay(p, &pane.body, w1.line, w1.at, sl.c1 - pfx - w1.pad);
pane.body.cur_row = row1;
pane.body.cur_col = col1;
pane.body.cur_pinned = true;