diff options
Diffstat (limited to 'src/mouse.zig')
| -rw-r--r-- | src/mouse.zig | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mouse.zig b/src/mouse.zig index 69feea29..beb2e624 100644 --- a/src/mouse.zig +++ b/src/mouse.zig @@ -827,11 +827,14 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void { if (sl.r0 < pane.tag_rows) { // On the tag the caret goes where the button came up. A // click on the path, if it can be renamed, drafts a name. - const at = tagline.tagOffsetAt(p, pane, @intCast(@max(0, sl.r1)), @intCast(@max(0, sl.c1))); - if (at) |cursor| { + const row: usize = @intCast(@max(0, sl.r1)); + const col: usize = @intCast(@max(0, sl.c1)); + if (!dragged and tagline.onName(pane, row, col)) { + tagline.draftName(p, pane, col); + } else if (tagline.tagOffsetAt(p, pane, row, col)) |cursor| { pane.tag.cur_row = @intCast(cursor.row); pane.tag.cur_col = @intCast(cursor.col); - } else if (!dragged) tagline.draftName(p, pane, @intCast(@max(0, sl.c1))); + } return; } if (dragged) edit.capturePointerSelection(p, pane, sel_slot) catch {}; @@ -932,7 +935,8 @@ fn chordCutPaste(p: *Pardes, cut: bool) void { }; if (@min(pane.sel[sel_slot].r0, pane.sel[sel_slot].r1) < pane.tag_rows) { // A sweep over the tag cuts from and pastes into the tag's own text; - // the part of it over the prefix is not the tag's to cut. + // the part of it over the prefix is not the tag's to cut, so the + // sweep starts after it. const t = &pane.tag; if (!s.chorded) { s.chorded = true; @@ -941,9 +945,12 @@ fn chordCutPaste(p: *Pardes, cut: bool) void { const forward = sl.r0 < sl.r1 or (sl.r0 == sl.r1 and sl.c0 <= sl.c1); const start = if (forward) .{ sl.r0, sl.c0 } else .{ sl.r1, sl.c1 }; const end = if (forward) .{ sl.r1, sl.c1 } else .{ sl.r0, sl.c0 }; - const origin: modal.Cursor = .{ .row = 0, .col = 0 }; - const from = tagline.tagOffsetAt(p, pane, @intCast(@max(0, start[0])), @intCast(@max(0, start[1]))) orelse origin; - const to = tagline.tagOffsetAt(p, pane, @intCast(@max(0, end[0])), @intCast(@max(0, end[1]))) orelse origin; + const lead = pane.tag_lead; + const origin: modal.Cursor = .{ .row = 0, .col = lead }; + var from = tagline.tagOffsetAt(p, pane, @intCast(@max(0, start[0])), @intCast(@max(0, start[1]))) orelse origin; + var to = tagline.tagOffsetAt(p, pane, @intCast(@max(0, end[0])), @intCast(@max(0, end[1]))) orelse origin; + if (from.row == 0) from.col = @max(from.col, lead); + if (to.row == 0) to.col = @max(to.col, lead); t.cur_row = @intCast(to.row); t.cur_col = @intCast(to.col); t.cur_pinned = true; |
