summaryrefslogtreecommitdiff
path: root/src/body_layer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/body_layer.zig')
-rw-r--r--src/body_layer.zig64
1 files changed, 62 insertions, 2 deletions
diff --git a/src/body_layer.zig b/src/body_layer.zig
index 56c4bc79..76aec179 100644
--- a/src/body_layer.zig
+++ b/src/body_layer.zig
@@ -227,6 +227,66 @@ pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
}
}
+fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: u16, body_h: u16, active: bool) void {
+ const prefix_width = panes.File.gutterWidth(pane);
+ const goff = pane.scroll();
+ const gcur = panes.terminal.gridCursor(pane);
+ const gcrow = if (pane.body.cur_pinned) pane.body.cur_row else @as(i32, gcur.y) + goff;
+ const typing_body = pane.focus == .body and (pane.prompt == .none or pane.prompt == .del_side or pane.prompt == .repl_choice);
+ const cur_line: i32 = if (active and typing_body) gcrow else std.math.minInt(i32);
+ // the body's first row, the way renderPane derives it
+ const body_y = p.bodyTop(pane, r);
+ const context_bg = p.theme().tag_bg;
+ for (0..@min(pane.context_rows, body_h)) |context_row| {
+ for (0..tw) |col| {
+ const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(context_row)));
+ cell.default = false;
+ cell.style.bg = .{ .rgb = context_bg };
+ cell.style.font_role = .tagline;
+ }
+ }
+ var vr: u16 = 0;
+ while (vr < body_h) : (vr += 1) {
+ const row_line: i32 = if (pane.wrap_n == 0)
+ goff + @as(i32, vr)
+ else if (vr < pane.wrap_n) pane.wrap_line[vr] else std.math.maxInt(i32);
+ const on_cursor = row_line == cur_line;
+ var c: u16 = 0;
+ while (c < prefix_width and c < tw) : (c += 1) {
+ const cell = s.at(tx + c, body_y + vr);
+ cell.default = false; // paints blank gutter rows too
+ cell.style.fg = .{ .rgb = if (on_cursor)
+ p.theme().lineno_active orelse p.theme().lineno
+ else
+ p.theme().lineno };
+ cell.style.bold = on_cursor;
+ }
+ }
+}
+
+fn drawWrapMarkers(
+ p: *Pardes,
+ s: *Surface,
+ pane: *const Pane,
+ r: pardes.Rect,
+ tx: u16,
+ tw: u16,
+ body_h: u16,
+ pane_bg: pardes.Color,
+) void {
+ if (tw <= panes.File.gutterWidth(pane) + 1) return;
+ const body_y = p.bodyTop(pane, r);
+ const marker_fg = p.chromeTheme().lineno;
+ var row: u16 = 0;
+ while (row + 1 < pane.wrap_n and row + 1 < body_h) : (row += 1) {
+ if (pane.wrap_line[row + 1] != pane.wrap_line[row]) continue;
+ s.set(tx + tw - 1, body_y + row, config.wrap_marker, .{
+ .fg = .{ .rgb = marker_fg },
+ .bg = pane_bg,
+ });
+ }
+}
+
pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rail: ?pardes.Region) !void {
const th = p.theme();
const chrome = p.chromeTheme();
@@ -276,12 +336,12 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
defer p.frames.zone(.body_color, probe_color);
// File layout is independent of whether its producer requests colors.
if (pane.file) |*f| {
- panes.File.drawGutter(p, s, pane, r, tx, tw, body_h, active);
+ drawGutter(p, s, pane, r, tx, tw, body_h, active);
panes.Query.paintMark(p, s, pane, r, body_h);
if (pane.colorAlgo() != .none)
panes.File.recolorSyntax(p, s, pane, f, r, tx, tw, body_h);
panes.Tables.paint(p, s, pane, r, tx, tw, body_h);
- panes.File.drawWrapMarkers(p, s, pane, r, tx, tw, body_h, pane_bg);
+ drawWrapMarkers(p, s, pane, r, tx, tw, body_h, pane_bg);
pane.places.paint(p, s, pane, r, body_h);
panes.Query.paint(p, s, pane, r, body_h);
} else if (pane.isTerminal()) {