~leon_plickat/nfm

nfm: Set window title using OSC 2 v3 PROPOSED

Hugo Machet: 1
 Set window title using OSC 2

 3 files changed, 14 insertions(+), 1 deletions(-)
#781975 alpine.yml failed
#781976 freebsd.yml failed
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~leon_plickat/nfm/patches/33062/mbox | git am -3
Learn more about email & git

[PATCH nfm v3] Set window title using OSC 2 Export this patch

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
nfm/patches: FAILED in 52s

[Set window title using OSC 2][0] v3 from [Hugo Machet][1]

[0]: https://lists.sr.ht/~leon_plickat/nfm/patches/33062
[1]: mailto:mail@hmachet.com

✗ #781975 FAILED nfm/patches/alpine.yml  https://builds.sr.ht/~leon_plickat/job/781975
✗ #781976 FAILED nfm/patches/freebsd.yml https://builds.sr.ht/~leon_plickat/job/781976
Thanks!


Friendly greetings,
Leon Henrik Plickat