~leon_plickat/nfm

38e0bb2a98fe12c0507bee8c139a0ae061c05ffd — Leon Henrik Plickat 4 months ago 771b65c
Use std lib constants for VMIN and VTIME
1 files changed, 6 insertions(+), 9 deletions(-)

M src/UserInterface.zig
M src/UserInterface.zig => src/UserInterface.zig +6 -9
@@ 280,9 280,6 @@ pub const Attr = struct {
const min_width = 20;
const min_height = 3;

const vtime = 5;
const vmin = 6;

alloc: mem.Allocator,

/// Is true when sigwinch was received.


@@ 384,15 381,15 @@ pub fn nextEvent(self: *Self) !?Event {
        // kitty mode, so we can use the same code to handle both kitty and
        // legacy.
        var termios = try os.tcgetattr(self.tty.handle);
        termios.cc[vtime] = 1;
        termios.cc[vmin] = 0;
        termios.cc[os.system.V.TIME] = 1;
        termios.cc[os.system.V.MIN] = 0;
        try os.tcsetattr(self.tty.handle, .NOW, termios);

        var esc_buffer: [8]u8 = undefined;
        const esc_read = try self.tty.read(&esc_buffer);

        termios.cc[vtime] = 0;
        termios.cc[vmin] = 0;
        termios.cc[os.system.V.TIME] = 0;
        termios.cc[os.system.V.MIN] = 0;

        try os.tcsetattr(self.tty.handle, .NOW, termios);



@@ 473,8 470,8 @@ pub fn uncook(self: *Self) !void {

    // With these settings, the read syscall will immediately return when it
    // can't get any bytes. This allows poll to drive our loop.
    raw.cc[vtime] = 0;
    raw.cc[vmin] = 0;
    raw.cc[os.system.V.TIME] = 0;
    raw.cc[os.system.V.MIN] = 0;

    try os.tcsetattr(self.tty.handle, .FLUSH, raw);