linenoize icon indicating copy to clipboard operation
linenoize copied to clipboard

Not working with `std.io.getStdOut().writer()`

Open glyh opened this issue 1 year ago • 0 comments

The following won't work:

pub fn main() !void {
    const allocator = std.heap.page_allocator;

    var ln = Linenoise.init(allocator);
    defer ln.deinit();

    const stdout_file = std.io.getStdOut().writer();
    var bw = std.io.bufferedWriter(stdout_file);
    const stdout = bw.writer();

    while (try ln.linenoise("user> ")) |input| {
        defer allocator.free(input);

        try stdout.print("{s}", .{input});
        try bw.flush();

        try ln.history.add(input);
    }
}

glyh avatar Jun 25 '24 08:06 glyh