~leon_plickat/public-inbox

zig-spoon: Add Term.setWindowTitle() v3 APPLIED

Hugo Machet: 1
 Add Term.setWindowTitle()

 3 files changed, 13 insertions(+), 0 deletions(-)
#743976 alpine.yml success
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/public-inbox/patches/31550/mbox | git am -3
Learn more about email & git

[PATCH zig-spoon v3] Add Term.setWindowTitle() Export this patch

---
v2 -> v3:
* Add title to input-demo example
* Use writeAll() instead of print(), I'm curious to know why?
* Remove the fix in moveCursorTo();

 example/input-demo.zig |  1 +
 example/menu.zig       |  1 +
 lib/Term.zig           | 11 +++++++++++
 3 files changed, 13 insertions(+)

diff --git a/example/input-demo.zig b/example/input-demo.zig
index 4e4478cda582..15f91d87584c 100644
--- a/example/input-demo.zig
+++ b/example/input-demo.zig
@@ -35,6 +35,7 @@ pub fn main() !void {
    try term.hideCursor();

    try term.fetchSize();
    try term.setWindowTitle("zig-spoon example: input-demo");
    try term.updateContent();

    while (loop) {
diff --git a/example/menu.zig b/example/menu.zig
index d34abef3bd18..bd65e5ab2e5b 100644
--- a/example/menu.zig
+++ b/example/menu.zig
@@ -33,6 +33,7 @@ pub fn main() !void {
    try term.hideCursor();

    try term.fetchSize();
    try term.setWindowTitle("zig-spoon example: menu");
    try term.updateContent();

    var buf: [16]u8 = undefined;
diff --git a/lib/Term.zig b/lib/Term.zig
index 467df2024294..1465b0904088 100644
--- a/lib/Term.zig
+++ b/lib/Term.zig
@@ -180,6 +180,17 @@ pub fn clear(self: *Self) !void {
    try writer.writeAll(spells.clear);
}

/// Set window title using OSC 2.
/// Should not be called inside a rendering function.
pub fn setWindowTitle(self: *Self, title: []const u8) !void {
    const writer = self.stdout.writer();
    defer self.stdout.flush() catch {};

    try writer.writeAll("\x1b]2;");
    try writer.writeAll(title);
    try writer.writeAll("\x1b\\");
}

/// Move the cursor to the specified cell.
pub fn moveCursorTo(self: *Self, row: usize, col: usize) !void {
    const writer = self.stdout.writer();
-- 
2.36.0
zig-spoon/patches/alpine.yml: SUCCESS in 33s

[Add Term.setWindowTitle()][0] v3 from [Hugo Machet][1]

[0]: https://lists.sr.ht/~leon_plickat/public-inbox/patches/31550
[1]: mailto:mail@hmachet.com

✓ #743976 SUCCESS zig-spoon/patches/alpine.yml https://builds.sr.ht/~leon_plickat/job/743976
Thanks!

On Mon Apr 25, 2022 at 1:14 PM CEST, Hugo Machet wrote: