summaryrefslogtreecommitdiff
path: root/core/Output.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Output.zig')
-rw-r--r--core/Output.zig27
1 files changed, 16 insertions, 11 deletions
diff --git a/core/Output.zig b/core/Output.zig
index 32a00863..fe1543fe 100644
--- a/core/Output.zig
+++ b/core/Output.zig
@@ -986,26 +986,31 @@ pub fn openConfig(p: *Pardes, id: usize) !void {
}
/// The messages' history (the log ring), the newest first, each with its
-/// kind's glyph, a live error's places under it (SPC h m).
-pub fn openMessages(p: *Pardes, id: usize) !void {
- var out: std.Io.Writer.Allocating = .init(p.gpa);
- errdefer out.deinit();
+/// kind's glyph, a live error's places under it: the +Messages' text and
+/// the Messages picker's rows (SPC h m).
+pub fn messagesText(p: *Pardes, w: *std.Io.Writer) !void {
var i: usize = p.messages.len;
while (i > 0) {
i -= 1;
const m = p.messages.at(i).?;
- try out.writer.print("{s} ", .{m.kind.glyph()});
- if (m.serial != 0) try out.writer.print("{d}: ", .{m.serial});
- try out.writer.writeAll(m.slice());
- if (m.repeats > 1) try out.writer.print(" (x{d})", .{m.repeats});
- try out.writer.writeByte('\n');
+ try w.print("{s} ", .{m.kind.glyph()});
+ if (m.serial != 0) try w.print("{d}: ", .{m.serial});
+ try w.writeAll(m.slice());
+ if (m.repeats > 1) try w.print(" (x{d})", .{m.repeats});
+ try w.writeByte('\n');
for (p.messages.live[0..p.messages.live_len]) |*s| {
if (s.kind != .@"error" or s.places_len == 0 or !std.mem.eql(u8, pardes.Messages.Message.body(s.text.slice()), pardes.Messages.Message.body(m.slice()))) continue;
- for (s.places[0..s.places_len]) |*place| try out.writer.print(" {s}:{d}:{d} {s}\n", .{ place.path.slice(), place.line, place.col, place.text.slice() });
+ for (s.places[0..s.places_len]) |*place| try w.print(" {s}:{d}:{d} {s}\n", .{ place.path.slice(), place.line, place.col, place.text.slice() });
break;
}
}
- if (p.messages.len == 0) try out.writer.writeAll("nothing has been said yet\n");
+ if (p.messages.len == 0) try w.writeAll("nothing has been said yet\n");
+}
+
+pub fn openMessages(p: *Pardes, id: usize) !void {
+ var out: std.Io.Writer.Allocating = .init(p.gpa);
+ errdefer out.deinit();
+ try messagesText(p, &out.writer);
const content = try out.toOwnedSlice();
return openRead(p, id, .{ .cmd = .Messages }, "", content);
}