~leon_plickat/nfm

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH nfm v2] Set window title using OSC 2

Details
Message ID
<20220616195918.24798-1-mail@hmachet.com>
DKIM signature
missing
Download raw message
Patch: +25 -0
Views title:
  * nav => "nfm: $CWD"
  * bm, fs => "nfm: <view name>"

Implements: https://todo.sr.ht/~leon_plickat/nfm/26
---
v1 -> v2:
  Rebased and modifed to work with dirmap re-design

src/nfm.zig  | 22 ++++++++++++++++++++++
 src/view.zig |  3 +++
 2 files changed, 25 insertions(+)

diff --git a/src/nfm.zig b/src/nfm.zig
index bc5fe5870bc6..ccd45160f409 100644
--- a/src/nfm.zig
+++ b/src/nfm.zig
@@ -100,10 +100,32 @@ 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 => {
                var buf: [100]u8 = undefined;
                const title = blk: {
                    break :blk fmt.bufPrint(&buf, "nfm: {s}", .{self.dirmap.cwd.name}) catch {
                        break :blk try fmt.bufPrint(
                            &buf,
                            "nfm: {s}",
                            .{self.dirmap.cwd.name[0 .. buf.len - 5]},
                        );
                    };
                };
                try self.ui.term.setWindowTitle(title);
            },
            .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] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CKRTQJSOWZEI.GUKQEBTRZHP4@cirno>
In-Reply-To
<20220616195918.24798-1-mail@hmachet.com> (view parent)
DKIM signature
missing
Download raw message
nfm/patches: FAILED in 54s

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

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

✓ #781954 SUCCESS nfm/patches/alpine.yml  https://builds.sr.ht/~leon_plickat/job/781954
✗ #781955 FAILED  nfm/patches/freebsd.yml https://builds.sr.ht/~leon_plickat/job/781955
Reply to thread Export thread (mbox)