@@ -115,24 +115,21 @@ const State = struct {
115115 }
116116
117117 pub inline fn updateTerminalSize (self : * State ) ! void {
118- switch (builtin .target .os .tag ) {
119- .windows = > {
120- // windows doesn't support SIGWINCH, so we need to manually check if resize is needed
121- const newSize = try getTerminalSize ();
122- if (newSize .rows != self .size .rows or newSize .cols != self .size .cols ) {
123- try self .resize (newSize );
124- }
125- },
126- else = > {
127- // posix systems support SIGWINCH, so we only need to resize when the terminal is resized
128- if (! self .resize_needed ) return ;
129-
130- const newSize = try getTerminalSize ();
131- if (newSize .rows != self .size .rows or newSize .cols != self .size .cols ) {
132- try self .resize (newSize );
133- }
134- self .resize_needed = false ;
135- },
118+ if (comptime builtin .target .os .tag == .windows ) {
119+ // windows doesn't support SIGWINCH, so we need to manually check if resize is needed
120+ const newSize = try getTerminalSize ();
121+ if (newSize .rows != self .size .rows or newSize .cols != self .size .cols ) {
122+ try self .resize (newSize );
123+ }
124+ } else {
125+ // posix systems support SIGWINCH, so we only need to resize when the terminal is resized
126+ if (! self .resize_needed ) return ;
127+
128+ const newSize = try getTerminalSize ();
129+ if (newSize .rows != self .size .rows or newSize .cols != self .size .cols ) {
130+ try self .resize (newSize );
131+ }
132+ self .resize_needed = false ;
136133 }
137134 }
138135
@@ -165,17 +162,17 @@ fn setupSignalHandler() void {
165162 if (comptime builtin .target .os .tag == .windows ) {
166163 platform .setupSignalHandler (handleSignalWindows );
167164 } else {
168- platform .setupSignalHandler (handleSignal );
165+ platform .setupSignalHandler (handleSignalPosix );
169166 }
170167}
171168
172- export fn handleSignal (sig : c_int ) callconv (.C ) void {
169+ export fn handleSignalPosix (sig : c_int ) callconv (.C ) void {
173170 if (sig == platform .Term .SIGINT ) {
174171 // Show cursor before exit
175172 stdout .writeAll ("\x1b [2J\x1b [H" ) catch {}; // clear screen
176173 stdout .writeAll ("\x1b [?25h" ) catch {}; // show cursor
177174 std .process .exit (0 );
178- } else if (builtin .target .os .tag != .windows and sig == platform .Term .SIGWINCH ) {
175+ } else if (( comptime builtin .target .os .tag != .windows ) and sig == platform .Term .SIGWINCH ) {
179176 if (global_state ) | state | {
180177 state .resize_needed = true ;
181178 }
0 commit comments