Zig NEWS

Discussion on: Want to create a TUI application? - The Basics of "Uncooked" Terminal IO

Collapse
 
haoliang profile image
haoliang

insightful post! you had not mentioned the mouse support, could you give some directions?

Collapse
 
haoliang profile image
haoliang

luckily, i found some code in termion to do that.

/// A sequence of escape codes to enable terminal mouse support.
const ENTER_MOUSE_SEQUENCE: &'static str = csi!("?1000h\x1b[?1002h\x1b[?1015h\x1b[?1006h");

/// A sequence of escape codes to disable terminal mouse support.
const EXIT_MOUSE_SEQUENCE: &'static str = csi!("?1006l\x1b[?1015l\x1b[?1002l\x1b[?1000l");
Enter fullscreen mode Exit fullscreen mode
Collapse
 
jpl profile image
Jean-Pierre

Thank you

Just a remark
I tested with 0.10.0 or 0.11.0 dev 945
I have a problem with
tty = try fs.cwd().openFile("/dev/tty", .{ .read = true, .write = true });
and I returned:
tty = fs.cwd().openFile("/dev/tty", .{ .mode = .read_write}) catch unreachable;

i work with linux

Thread Thread
 
edgareatspi profile image
Edgar

I agree! For some reason, this program outright doesn't work at all on my machine. Was this article based on some older version of Zig? (I use Zig 0.14)

Thread Thread
 
jpl profile image
Jean-Pierre

exemple: ok for 0.13.0 or 0.14. dev

    const cDIR = std.fs.cwd().openDir("dspf",.{})
    catch |err| {@panic(try std.fmt.allocPrint(allocator,"err Open DIR.{any}\n", .{err}));};

    var fjson = cDIR.openFile(nameJson, .{.mode = .read_write}) catch |err| {
                @panic(try std.fmt.allocPrint(allocator,"err Open FILE.{any}\n", .{err}));};
    defer fjson.close();

Enter fullscreen mode Exit fullscreen mode