summaryrefslogtreecommitdiff
path: root/core/Messages.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Messages.zig')
-rw-r--r--core/Messages.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/Messages.zig b/core/Messages.zig
index c9166aed..e995659a 100644
--- a/core/Messages.zig
+++ b/core/Messages.zig
@@ -920,6 +920,11 @@ pub fn reportFailure(p: *Pardes, id: usize, text: []const u8) void {
/// them instead of letting the last one win the row.
pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect) void {
pane.notices = bands(p, pane, pane.tag_rows, r);
+ // A message's detail under the caret's line, where the body draws it
+ // and a click's row is read (Pane.textRow): the step's, as the bands.
+ const under = if (r.h > pane.tag_rows) detailUnder(p, pane, p.panes[p.view().active] == pane, r.h - pane.tag_rows) else null;
+ pane.ghost_at = if (under) |d| d.row else 0;
+ pane.ghost_rows = if (under) |d| d.rows else 0;
// Each band's chip at the right edge, as wide as its own text and a
// blank cell either side, the pane's width at most: a click finds it
// whether or not a frame has drawn it. An overlay over the body's top
@@ -934,6 +939,29 @@ pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect) void {
}
}
+/// A message's detail under the caret's line (SPEC ยง10.2), as a body of
+/// `body_h` rows shows it: the row of that line's last row, how many of the
+/// detail's lines fit under it, the message (the first naming the line, as
+/// the words after it are); only in the pane with the keyboard, in its body.
+/// Bounded by the live messages' places and the rows shown.
+pub fn detailUnder(p: *const Pardes, pane: *Pane, active: bool, body_h: u16) ?struct { row: u16, rows: u16, said: *const Said } {
+ if (!active or pane.focus != .body or p.messages.live_len == 0) return null;
+ const f = pane.file orelse return null;
+ const caret = @max(0, pane.body.cur_row);
+ const said = found: for (p.messages.live[0..p.messages.live_len]) |*s| {
+ for (s.places[0..s.places_len]) |*place| if (place.line == caret + 1 and std.mem.eql(u8, place.path.slice(), f.path)) break :found s;
+ } else return null;
+ if (said.detail_len == 0) return null;
+ var row: u16 = 0;
+ while (row < body_h) : (row += 1) {
+ if (pane.wrapAt(p.settings.tab, row).line != caret) continue;
+ if (row + 1 < body_h and pane.wrapAt(p.settings.tab, row + 1).line == caret) continue;
+ const k: u16 = @intCast(@min(said.detail_len, body_h - row - 1));
+ return if (k == 0) null else .{ .row = row, .rows = k, .said = said };
+ }
+ return null;
+}
+
/// The bands a pane shows over `r` below its `tag_rows`: the live view's
/// each step, and any view's for its kind's facts (Kind.viewOf), made from
/// what a dump keeps (the bands are derived).