summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/look.zig b/src/look.zig
index 6f279769..5cf26240 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -1572,8 +1572,17 @@ pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void {
.image => |target| {
if (focusPaneByPath(p, target.path, .{})) return;
const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots);
- _ = panes.Image.create(p, free, target.path, &.{}) catch |err|
+ const made = panes.Image.create(p, free, target.path, &.{}) catch |err|
return p.reportError(id, if (@import("Messages.zig").dialReason(err) != null) target.path else "look", err);
+ // One it cannot read (corrupt, truncated, not what its name says)
+ // is said, a failure, rather than shown as a blank pane.
+ if (!@import("image.zig").readable(made.image.?.raw)) {
+ made.vweight = 0;
+ p.unplaced.set(free);
+ var said: [miss_path_cap + 64]u8 = undefined;
+ var cut: [miss_path_cap + "…".len]u8 = undefined;
+ return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: not an image pardes can read", .{missText(target.path, &cut)}) catch "look: not an image pardes can read");
+ }
exec.placeNew(p, id, id, free, .doc);
},
}