summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/body_layer.zig19
-rw-r--r--src/draw.zig7
2 files changed, 12 insertions, 14 deletions
diff --git a/src/body_layer.zig b/src/body_layer.zig
index b514cabe..2fc1454c 100644
--- a/src/body_layer.zig
+++ b/src/body_layer.zig
@@ -111,15 +111,12 @@ fn paintSourceSelection(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, rows: []c
}
}
+/// A pointer sweep over pane `pane`'s rows in `r`, its tag's and its body's.
pub fn paintPointerSelection(
p: *Pardes,
s: *Surface,
pane: *Pane,
r: Rect,
- tx: u16,
- tw: u16,
- tag_y: u16,
- body_y: u16,
sl: Pane.Sel,
/// Rows of the selection above this are left alone.
from_row: u16,
@@ -127,6 +124,8 @@ pub fn paintPointerSelection(
fg: ?[3]u8,
) void {
if (pane.pointerSelection(sl)) |rows| return paintSourceSelection(p, s, pane, r, rows, bg, fg);
+ const tag_y = p.tagTop(pane, r);
+ const body_y = p.bodyTop(pane, r);
var row: u16 = 0;
while (row < r.h) : (row += 1) {
if (row < from_row) continue;
@@ -138,8 +137,9 @@ pub fn paintPointerSelection(
// row zero in Sel space and starts at its real first text cell.
const scroll: i32 = if (row < pane.tag_rows) pane.tag_scroll else 0;
const col: i32 = if (pane.file != null and row >= pane.tag_rows) @max(c0, @as(i32, panes.File.gutterWidth(pane))) else @max(0, c0 - scroll);
- const row_x = if (row < pane.tag_rows) r.x + @min(TAG_TEXT_INSET, r.w) else tx;
- const row_width = if (row < pane.tag_rows) r.w -| TAG_TEXT_INSET else tw;
+ const inset = if (row < pane.tag_rows) TAG_TEXT_INSET else config.GUTTER;
+ const row_x = r.x + @min(inset, r.w);
+ const row_width = r.w -| inset;
const end = @min(c1 - scroll + 1, row_width);
if (col < end) s.tint(row_x + @as(u16, @intCast(col)), sy, @intCast(end - col), bg, fg);
}
@@ -234,7 +234,6 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
const chrome = p.chromeTheme();
const tx = r.x + config.GUTTER;
const tw = r.w - config.GUTTER;
- const tag_y = p.tagTop(pane, r);
// Below the notice bands: they are stacked at the top of the body the
// way tree-sitter context rows are, so the body starts under them
// rather than being painted over by them.
@@ -258,7 +257,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
// the rows, which paint over it.
const sweep = pane.sel[pardes.sel_slot];
if (sweep.state != .none and (sweep.state != .done or pardes.sel_slot == 0) and @min(sweep.r0, sweep.r1) < pane.tag_rows)
- paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, sweep, pane.tag_rows, th.sel_bg, th.sel_fg);
+ paintPointerSelection(p, s, pane, r, sweep, pane.tag_rows, th.sel_bg, th.sel_fg);
{
// The rows themselves. `bodyText` above is only the string BUILD;
// this is what writes it into the surface.
@@ -303,7 +302,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
if (preview.file_word) |word|
panes.File.paintWordSelection(p, s, pane, r, word.row, word.lo, word.hi, preview_bg)
else if (preview.sel) |sel|
- paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, sel, pane.tag_rows, preview_bg, null);
+ paintPointerSelection(p, s, pane, r, sel, pane.tag_rows, preview_bg, null);
}
}
const modal_hover = if (p.look_hover_preview) |preview|
@@ -316,7 +315,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
// A select sweep over the tag is the tag's selection, painted there
// in the tag's own selection colours.
if (b == pardes.sel_slot and @min(sl.r0, sl.r1) < pane.tag_rows) continue;
- paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, sl, pane.tag_rows, sel_btn[b], buttonInks(th)[b]);
+ paintPointerSelection(p, s, pane, r, sl, pane.tag_rows, sel_btn[b], buttonInks(th)[b]);
}
const preview = normal.selRegexArmed(pane) != null;
const show_prim = (pane.body.mode == .normal and pane.body.vsel.active) or preview or
diff --git a/src/draw.zig b/src/draw.zig
index bfcb8509..5b8377e0 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -1320,7 +1320,6 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
const tx = r.x + @min(TAG_TEXT_INSET, r.w);
const tw = r.w -| TAG_TEXT_INSET;
const tag_y = p.tagTop(pane, r);
- const body_y = p.bodyTop(pane, r);
const rows = pane.tag_rows;
const page_rgb = th.bg orelse th.tag_bg;
// Focus is visible along the tag without changing its live text grid.
@@ -1426,12 +1425,12 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
for (pane.sel, 0..) |selection, button| {
if (selection.state == .none or (selection.state == .done and button != 0)) continue;
if (button != pardes.sel_slot or @min(selection.r0, selection.r1) >= rows) continue;
- body_layer.paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, selection, 0, th.tag_sel_bg orelse th.sel_bg, th.sel_fg);
+ body_layer.paintPointerSelection(p, s, pane, r, selection, 0, th.tag_sel_bg orelse th.sel_bg, th.sel_fg);
}
if (p.look_hover_preview) |preview| {
if (preview.pane == id and preview.serial == pane.serial) if (preview.sel) |sel| if (@min(sel.r0, sel.r1) < rows) {
const preview_bg = colors.mix(page_rgb, colors.mix(page_rgb, th.sel_bg));
- body_layer.paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, sel, 0, preview_bg, null);
+ body_layer.paintPointerSelection(p, s, pane, r, sel, 0, preview_bg, null);
};
}
const sel_btn = body_layer.buttonTints(th);
@@ -1439,7 +1438,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
for (pane.sel, 0..) |selection, button| {
if (selection.state == .none or (selection.state == .done and button != 0)) continue;
if (button == pardes.sel_slot or @min(selection.r0, selection.r1) >= rows) continue;
- body_layer.paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, selection, 0, sel_btn[button], sel_ink[button]);
+ body_layer.paintPointerSelection(p, s, pane, r, selection, 0, sel_btn[button], sel_ink[button]);
}
}