@@ -4,11 +4,6 @@ const posix = std.posix;
44
55const Terminal = @This ();
66
7- /// Get a basic Io instance for synchronous operations
8- fn getIo () std.Io {
9- return std .Options .debug_io ;
10- }
11-
127pub const RawMode = struct {
138 original_termios : if (builtin .os .tag != .windows ) posix .termios else void ,
149
@@ -17,7 +12,7 @@ pub const RawMode = struct {
1712 // Windows terminal setup would go here
1813 return RawMode { .original_termios = {} };
1914 } else {
20- const stdin = std .Io . File . stdin ();
15+ const stdin = std .io . getStdIn ();
2116 const original = try posix .tcgetattr (stdin .handle );
2217 var raw = original ;
2318
@@ -40,7 +35,7 @@ pub const RawMode = struct {
4035 if (builtin .os .tag == .windows ) {
4136 return ;
4237 }
43- const stdin = std .Io . File . stdin ();
38+ const stdin = std .io . getStdIn ();
4439 posix .tcsetattr (stdin .handle , .FLUSH , self .original_termios ) catch {};
4540 }
4641};
@@ -68,8 +63,8 @@ pub const KeyPress = struct {
6863 char : ? u8 = null ,
6964};
7065
71- stdin : std.Io .File ,
72- stdout : std.Io .File ,
66+ stdin : std.fs .File ,
67+ stdout : std.fs .File ,
7368supports_unicode : bool ,
7469supports_color : bool ,
7570width : usize ,
@@ -81,8 +76,8 @@ pub fn init() Terminal {
8176 const size = detectTerminalSize ();
8277
8378 return .{
84- .stdin = std .Io . File . stdin (),
85- .stdout = std .Io . File . stdout (),
79+ .stdin = std .io . getStdIn (),
80+ .stdout = std .io . getStdOut (),
8681 .supports_unicode = supports_unicode ,
8782 .supports_color = supports_color ,
8883 .width = size .width ,
@@ -123,7 +118,6 @@ const TerminalSize = struct {
123118};
124119
125120/// Manually defined winsize struct for ioctl TIOCGWINSZ.
126- /// In Zig 0.16+, std.posix.system.winsize / std.c.winsize is no longer pub.
127121const Winsize = extern struct {
128122 row : u16 ,
129123 col : u16 ,
@@ -138,7 +132,7 @@ fn detectTerminalSize() TerminalSize {
138132 }
139133
140134 // Try to get terminal size via ioctl
141- const stdout = std .Io . File . stdout ();
135+ const stdout = std .io . getStdOut ();
142136 var ws : Winsize = undefined ;
143137
144138 const result = posix .system .ioctl (stdout .handle , posix .T .IOCGWINSZ , @intFromPtr (& ws ));
@@ -195,12 +189,12 @@ pub fn readKey(self: *Terminal) !?KeyPress {
195189}
196190
197191pub fn write (self : * Terminal , text : []const u8 ) ! void {
198- try self .stdout .writeStreamingAll ( getIo (), text );
192+ try self .stdout .writeAll ( text );
199193}
200194
201195pub fn writeLine (self : * Terminal , text : []const u8 ) ! void {
202- try self .stdout .writeStreamingAll ( getIo (), text );
203- try self .stdout .writeStreamingAll ( getIo (), "\n " );
196+ try self .stdout .writeAll ( text );
197+ try self .stdout .writeAll ( "\n " );
204198}
205199
206200pub fn clearScreen (self : * Terminal ) ! void {
0 commit comments