diff options
Diffstat (limited to 'core/edit.zig')
| -rw-r--r-- | core/edit.zig | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/core/edit.zig b/core/edit.zig index ac78fd32..ce13b5ed 100644 --- a/core/edit.zig +++ b/core/edit.zig @@ -2133,6 +2133,9 @@ fn stepOwn(e: Editor, t: *Text, back: bool) error{OutOfMemory}!void { const PointerTextSelection = struct { sel: Pane.Sel, on_tag: bool, + /// On a row of a message's detail (Pane.textRow): that body row as + /// drawn; the selection is on the line it explains. + ghost: ?u16 = null, }; pub fn pointerTextSelection(p: *const Pardes, id: usize, col: u16, row: u16, body_hit: ?Mouse.BodyHit, tag_hit: ?TagHit) ?PointerTextSelection { @@ -2151,16 +2154,21 @@ pub fn pointerTextSelection(p: *const Pardes, id: usize, col: u16, row: u16, bod if (!on_tag) if (body_hit) |supplied| { const mapped_hit = mouse.bodyHitForPane(p, id, supplied, false) orelse return null; const c = @as(i32, mapped_hit.col) - config.GUTTER; - const v = @as(i32, mapped_hit.row) + pane.tag_rows; - return .{ .sel = .{ .state = .dragging, .c0 = c, .c1 = c, .r0 = v, .r1 = v }, .on_tag = false }; + const drawn: i32 = mapped_hit.row; + const v = pane.textRow(drawn) + pane.tag_rows; + const ghost = pane.ghost_rows > 0 and drawn > pane.ghost_at and drawn <= pane.ghost_at + pane.ghost_rows; + return .{ .sel = .{ .state = .dragging, .c0 = c, .c1 = c, .r0 = v, .r1 = v }, .on_tag = false, .ghost = if (ghost) mapped_hit.row else null }; }; const tag_col = if (on_tag) Layer.columnAt(p, .pane, id, tag_hit, false, row - tag_y) else null; const c: i32 = (if (tag_col) |value| @as(i32, value) else @as(i32, col) - @as(i32, r.x + (if (on_tag) TAG_TEXT_INSET else config.GUTTER))) + (if (on_tag) @as(i32, pane.tag_scroll) else 0); - const v: i32 = if (on_tag) @as(i32, row) - @as(i32, tag_y) else @as(i32, row) - @as(i32, body_y) + @as(i32, pane.tag_rows); + const drawn: i32 = @as(i32, row) - @as(i32, body_y); + const v: i32 = if (on_tag) @as(i32, row) - @as(i32, tag_y) else pane.textRow(drawn) + @as(i32, pane.tag_rows); + const ghost = !on_tag and pane.ghost_rows > 0 and drawn > pane.ghost_at and drawn <= pane.ghost_at + pane.ghost_rows; return .{ .sel = .{ .state = .dragging, .c0 = c, .c1 = c, .r0 = v, .r1 = v }, .on_tag = on_tag, + .ghost = if (ghost) @intCast(drawn) else null, }; } |
