| ... | ... | @@ -209,7 +209,13 @@ fn refreshWithHeldLock(self: *Progress) void { |
| 209 | 209 | unreachable; |
| 210 | 210 | |
| 211 | 211 | saved_cursor_pos = info.dwCursorPosition; |
| 212 | | const fill_chars = @intCast(windows.DWORD, info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X); |
| 212 | |
| 213 | const window_height = @intCast(windows.DWORD, info.srWindow.Bottom - info.srWindow.Top) + 1; |
| 214 | const window_width = @intCast(windows.DWORD, info.srWindow.Right - info.srWindow.Left) + 1; |
| 215 | // Number of terminal cells to clear, starting from the cursor position |
| 216 | // and ending at the window bottom right corner. |
| 217 | const fill_chars = window_width * (window_width - @intCast(windows.DWORD, info.dwCursorPosition.Y - info.srWindow.Top)) - |
| 218 | @intCast(windows.DWORD, info.dwCursorPosition.Y - info.srWindow.Top); |
| 213 | 219 | |
| 214 | 220 | var written: windows.DWORD = undefined; |
| 215 | 221 | if (windows.kernel32.FillConsoleOutputAttribute( |
| ... | ... | @@ -271,11 +277,7 @@ fn refreshWithHeldLock(self: *Progress) void { |
| 271 | 277 | const seq_after = DECRC; |
| 272 | 278 | std.mem.copy(u8, self.output_buffer[end..], seq_after); |
| 273 | 279 | end += seq_after.len; |
| 274 | | } else if (std.builtin.os.tag == .windows) { |
| 275 | | if (windows.kernel32.SetConsoleCursorPosition(file.handle, saved_cursor_pos) != windows.TRUE) { |
| 276 | | unreachable; |
| 277 | | } |
| 278 | | } else { |
| 280 | } else if (std.builtin.os.tag != .windows) { |
| 279 | 281 | self.output_buffer[end] = '\n'; |
| 280 | 282 | end += 1; |
| 281 | 283 | } |
| ... | ... | @@ -284,6 +286,12 @@ fn refreshWithHeldLock(self: *Progress) void { |
| 284 | 286 | // Stop trying to write to this file once it errors. |
| 285 | 287 | self.terminal = null; |
| 286 | 288 | }; |
| 289 | |
| 290 | if (std.builtin.os.tag == .windows) { |
| 291 | if (windows.kernel32.SetConsoleCursorPosition(file.handle, saved_cursor_pos) != windows.TRUE) |
| 292 | unreachable; |
| 293 | } |
| 294 | |
| 287 | 295 | self.prev_refresh_timestamp = self.timer.read(); |
| 288 | 296 | } |
| 289 | 297 | |