summaryrefslogtreecommitdiff
path: root/core/Output.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Output.zig')
-rw-r--r--core/Output.zig51
1 files changed, 35 insertions, 16 deletions
diff --git a/core/Output.zig b/core/Output.zig
index 380fadb1..fe1543fe 100644
--- a/core/Output.zig
+++ b/core/Output.zig
@@ -491,16 +491,23 @@ pub fn fillRows(p: *Pardes, id: usize, dir: []const u8, from: Origin, name: ?[]c
pub fn openJumps(p: *Pardes, id: usize) !void {
var out: std.Io.Writer.Allocating = .init(p.gpa);
errdefer out.deinit();
+ try jumpsText(p, &out.writer);
+ try refillOrOpen(p, id, .{ .cmd = .Jumplist }, try out.toOwnedSlice());
+}
+
+/// The live view's jump list as a +Jumps lists it, a place a row, the
+/// oldest first (its picker's rows too, Pick.zig).
+pub fn jumpsText(p: *Pardes, w: *std.Io.Writer) !void {
for (p.view().jumps.list[0..p.view().jumps.n]) |j| {
// A closed file's entry: marked, and a look at it opens it again.
if (j.serial == 0) {
const e = p.recentByHash(j.path_hash) orelse continue;
// A kind's place has no Look's column.
if (j.place.len > 0) {
- try out.writer.print("{s}:{d} (closed)\n", .{ e.path, @max(1, j.line) });
+ try w.print("{s}:{d} (closed)\n", .{ e.path, @max(1, j.line) });
continue;
}
- try out.writer.print("{s}:{d}:{d} (closed)\n", .{ e.path, @max(1, j.line), @max(1, j.col) });
+ try w.print("{s}:{d}:{d} (closed)\n", .{ e.path, @max(1, j.line), @max(1, j.col) });
continue;
}
const jp = p.panes[j.pane] orelse continue;
@@ -520,13 +527,12 @@ pub fn openJumps(p: *Pardes, id: usize) !void {
var cut = @min(what.len, 120);
while (cut > 0 and cut < what.len and what[cut] & 0xc0 == 0x80) cut -= 1;
if (j.line == 0)
- try out.writer.print("{s} {s}\n", .{ loc, what[0..cut] })
+ try w.print("{s} {s}\n", .{ loc, what[0..cut] })
else if (j.place.len > 0)
- try out.writer.print("{s}:{d} {s}\n", .{ loc, j.line, what[0..cut] })
+ try w.print("{s}:{d} {s}\n", .{ loc, j.line, what[0..cut] })
else
- try out.writer.print("{s}:{d}:{d} {s}\n", .{ loc, j.line, j.col, what[0..cut] });
+ try w.print("{s}:{d}:{d} {s}\n", .{ loc, j.line, j.col, what[0..cut] });
}
- try refillOrOpen(p, id, .{ .cmd = .Jumplist }, try out.toOwnedSlice());
}
/// The state file's dumps (Db.listDumps: label, date, size, pane count,
@@ -979,19 +985,32 @@ pub fn openConfig(p: *Pardes, id: usize) !void {
return openRead(p, id, .{ .cmd = .DumpConfig }, "", content);
}
-/// The message-row log, oldest first — the lines that were said in passing and
-/// then cleared by the next keystroke.
+/// The messages' history (the log ring), the newest first, each with its
+/// 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 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 w.print(" {s}:{d}:{d} {s}\n", .{ place.path.slice(), place.line, place.col, place.text.slice() });
+ break;
+ }
+ }
+ 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();
- var i: usize = 0;
- while (p.messages.at(i)) |m| : (i += 1) {
- 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');
- }
- if (i == 0) try out.writer.writeAll("nothing has been said yet\n");
+ try messagesText(p, &out.writer);
const content = try out.toOwnedSlice();
return openRead(p, id, .{ .cmd = .Messages }, "", content);
}