diff options
Diffstat (limited to 'src/Messages.zig')
| -rw-r--r-- | src/Messages.zig | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Messages.zig b/src/Messages.zig index f5767857..f400df54 100644 --- a/src/Messages.zig +++ b/src/Messages.zig @@ -454,7 +454,7 @@ pub fn reportFailure(p: *Pardes, id: usize, text: []const u8) void { /// so it does not paint under them, and the paint pass so it can stack /// them instead of letting the last one win the row. pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { - collectBands(p, pane, r, id); + pane.notices = bands(p, p.view(), pane, pane.tag_rows, r, id); // 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 @@ -470,26 +470,28 @@ pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { } } -fn collectBands(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { - pane.notices.len = 0; - if (r.w <= config.GUTTER or r.h <= pane.tag_rows) return; +/// The bands pane `id` shows in view `v`, 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). +pub fn bands(p: *const Pardes, v: *const Pardes.View, pane: *const Pane, tag_rows: u16, r: Rect, id: usize) Pane.Notices { + var n: Pane.Notices = .{}; + if (r.w <= config.GUTTER or r.h <= tag_rows) return n; // Oldest message line on top, so lines already up do not move when a // new one lands under them; when rows run out the oldest go first. - for (pane.msg_older[0..pane.msg_older_len], 0..) |line, i| pane.notices.pushAt(.older, @intCast(i), line.slot); - if (pane.msg_len > 0) pane.notices.pushAt(.message, 0, pane.msg_slot); - if (id == p.view().active and p.view().prefix == .leader) pane.notices.push(.leader); + for (pane.msg_older[0..pane.msg_older_len], 0..) |line, i| n.pushAt(.older, @intCast(i), line.slot); + if (pane.msg_len > 0) n.pushAt(.message, 0, pane.msg_slot); + if (id == v.active and v.prefix == .leader) n.push(.leader); // Del's question shows once its delay is up: answered before that, it // was never there. const del_waiting = pane.prompt == .del_side and pane.question_due_ns > p.clock.now_ns; - if (pane.promptText()) |text| if (text.len > 0 and !del_waiting) pane.notices.push(.prompt); + if (pane.promptText()) |text| if (text.len > 0 and !del_waiting) n.push(.prompt); // A pane only has so many rows to give. When they do not all fit the // LAST ones survive, because the prompt is last and it is the one // carrying the cursor: a prompt you cannot see is a prompt you type // into blind. A two-row pane spends its only body row on one notice, // which is what the single shared row used to do anyway. - const room: u8 = @intCast(@min(@as(u16, Pane.Notices.max), r.h - pane.tag_rows)); - const n = &pane.notices; - if (n.span() <= room) return; + const room: u8 = @intCast(@min(@as(u16, Pane.Notices.max), r.h - tag_rows)); + if (n.span() <= room) return n; // Too short for the gaps: close them up in screen order, and if even // that does not fit, the top bands go. var i: usize = 1; @@ -508,6 +510,7 @@ fn collectBands(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { n.row[k] = @intCast(k); } n.len -= @intCast(drop); + return n; } test "errors are said in words, and a ZON failure names its line" { |
