@@ -21,15 +21,15 @@ pub const ANSI = struct {
2121
2222 // Direct writing to any writer - the most efficient option
2323 pub fn moveToOutput (writer : anytype , x : u32 , y : u32 ) AnsiError ! void {
24- std . fmt . format ( writer , "\x1b [{d};{d}H" , .{ y , x }) catch return AnsiError .WriteFailed ;
24+ writer . print ( "\x1b [{d};{d}H" , .{ y , x }) catch return AnsiError .WriteFailed ;
2525 }
2626
2727 pub fn fgColorOutput (writer : anytype , r : u8 , g : u8 , b : u8 ) AnsiError ! void {
28- std . fmt . format ( writer , "\x1b [38;2;{d};{d};{d}m" , .{ r , g , b }) catch return AnsiError .WriteFailed ;
28+ writer . print ( "\x1b [38;2;{d};{d};{d}m" , .{ r , g , b }) catch return AnsiError .WriteFailed ;
2929 }
3030
3131 pub fn bgColorOutput (writer : anytype , r : u8 , g : u8 , b : u8 ) AnsiError ! void {
32- std . fmt . format ( writer , "\x1b [48;2;{d};{d};{d}m" , .{ r , g , b }) catch return AnsiError .WriteFailed ;
32+ writer . print ( "\x1b [48;2;{d};{d};{d}m" , .{ r , g , b }) catch return AnsiError .WriteFailed ;
3333 }
3434
3535 // Text attribute constants
@@ -51,11 +51,11 @@ pub const ANSI = struct {
5151 pub const cursorUnderlineBlink = "\x1b [3 q" ;
5252
5353 pub fn cursorColorOutputWriter (writer : anytype , r : u8 , g : u8 , b : u8 ) AnsiError ! void {
54- std . fmt . format ( writer , "\x1b ]12;#{x:0>2}{x:0>2}{x:0>2}\x07 " , .{ r , g , b }) catch return AnsiError .WriteFailed ;
54+ writer . print ( "\x1b ]12;#{x:0>2}{x:0>2}{x:0>2}\x07 " , .{ r , g , b }) catch return AnsiError .WriteFailed ;
5555 }
5656
5757 pub fn explicitWidthOutput (writer : anytype , width : u32 , text : []const u8 ) AnsiError ! void {
58- std . fmt . format ( writer , "\x1b ]66;w={d};{s}\x1b \\ " , .{ width , text }) catch return AnsiError .WriteFailed ;
58+ writer . print ( "\x1b ]66;w={d};{s}\x1b \\ " , .{ width , text }) catch return AnsiError .WriteFailed ;
5959 }
6060
6161 pub const resetCursorColor = "\x1b ]112\x07 " ;
@@ -131,12 +131,15 @@ pub const ANSI = struct {
131131 pub const setTerminalTitle = "\x1b ]0;{s}\x07 " ;
132132
133133 pub fn setTerminalTitleOutput (writer : anytype , title : []const u8 ) AnsiError ! void {
134- std . fmt . format ( writer , setTerminalTitle , .{title }) catch return AnsiError .WriteFailed ;
134+ writer . print ( setTerminalTitle , .{title }) catch return AnsiError .WriteFailed ;
135135 }
136136
137137 pub fn makeRoomForRendererOutput (writer : anytype , height : u32 ) AnsiError ! void {
138138 if (height > 1 ) {
139- writer .writeByteNTimes ('\n ' , height - 1 ) catch return AnsiError .WriteFailed ;
139+ var i : u32 = 0 ;
140+ while (i < height - 1 ) : (i += 1 ) {
141+ writer .writeByte ('\n ' ) catch return AnsiError .WriteFailed ;
142+ }
140143 }
141144 }
142145};
0 commit comments