Views title:
* nav => "nfm: $CWD"
* bm, fs => "nfm: <view name>"
Implements: https://todo.sr.ht/~leon_plickat/nfm/26
---
v2 -> v3:
Update zig-spoon to use new setWindowTitle()
deps/zig-spoon | 2 +-
src/nfm.zig | 10 ++++++++++
src/view.zig | 3 +++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/deps/zig-spoon b/deps/zig-spoon
index 64d0536d01af..41657f29002c 160000
--- a/deps/zig-spoon
+++ b/deps/zig-spoon
@@ -1 +1 @@
-Subproject commit 64d0536d01afa3ad8cd7da05d952b2ed355547db
+Subproject commit 41657f29002c74473fb7b5dafd7341bbe73e3150
diff --git a/src/nfm.zig b/src/nfm.zig
index bc5fe5870bc6..74f8a5543adf 100644
--- a/src/nfm.zig
+++ b/src/nfm.zig
@@ -100,10 +100,20 @@ pub const Context = struct {
}
};
+ try self.updateWindowTitle();
+
self.ui.list_dirty = true;
self.ui.title_dirty = true;
}
+ pub fn updateWindowTitle(self: *Context) !void {
+ switch (self.view) {
+ .nav => try self.ui.term.setWindowTitle("nfm: {s}", .{self.dirmap.cwd.name}),
+ .fs => try self.ui.term.setWindowTitle("nfm: Filesystem", .{}),
+ .bm => try self.ui.term.setWindowTitle("nfm: Bookmarks", .{}),
+ }
+ }
+
pub fn runU21(self: *Context, command: []const u21, comptime name: []const u8) !void {
const cmd = try util.codepointSliceToUtf8SlizeZAlloc(self.gpa, command);
defer self.gpa.free(cmd);
diff --git a/src/view.zig b/src/view.zig
index 8a89406a9c50..3ae90fe0e37d 100644
--- a/src/view.zig
+++ b/src/view.zig
@@ -43,6 +43,7 @@ pub const View = union(enum) {
pub fn setNav(self: *Self) void {
self.reset();
self.* = .nav;
+ context.updateWindowTitle() catch return;
}
pub fn setFs(self: *Self) !void {
@@ -52,11 +53,13 @@ pub const View = union(enum) {
.cursor = 0,
.scroll_offset = 0,
} };
+ try context.updateWindowTitle();
}
pub fn setBm(self: *Self) void {
self.reset();
self.* = .bm;
+ context.updateWindowTitle() catch return;
}
fn reset(self: *Self) void {
--
2.36.1