| ... | ... | @@ -178,6 +178,22 @@ pub fn start(self: *Progress, name: []const u8, estimated_total_items: usize) *N |
| 178 | 178 | // we are in a "dumb" terminal like in acme or writing to a file |
| 179 | 179 | self.terminal = stderr; |
| 180 | 180 | } |
| 181 | self.calculateMaxWidth(); |
| 182 | self.root = Node{ |
| 183 | .context = self, |
| 184 | .parent = null, |
| 185 | .name = name, |
| 186 | .unprotected_estimated_total_items = estimated_total_items, |
| 187 | .unprotected_completed_items = 0, |
| 188 | }; |
| 189 | self.columns_written = 0; |
| 190 | self.prev_refresh_timestamp = 0; |
| 191 | self.timer = time.Timer.start() catch null; |
| 192 | self.done = false; |
| 193 | return &self.root; |
| 194 | } |
| 195 | |
| 196 | fn calculateMaxWidth(self: *Progress) void { |
| 181 | 197 | if (self.max_width == null) { |
| 182 | 198 | if (self.terminal) |terminal| { |
| 183 | 199 | // choose an optimal width and account for progress output that could have been printed |
| ... | ... | @@ -194,18 +210,6 @@ pub fn start(self: *Progress, name: []const u8, estimated_total_items: usize) *N |
| 194 | 210 | truncation_suffix.len, // make sure we can at least truncate |
| 195 | 211 | self.output_buffer.len - 1, |
| 196 | 212 | ); |
| 197 | | self.root = Node{ |
| 198 | | .context = self, |
| 199 | | .parent = null, |
| 200 | | .name = name, |
| 201 | | .unprotected_estimated_total_items = estimated_total_items, |
| 202 | | .unprotected_completed_items = 0, |
| 203 | | }; |
| 204 | | self.columns_written = 0; |
| 205 | | self.prev_refresh_timestamp = 0; |
| 206 | | self.timer = time.Timer.start() catch null; |
| 207 | | self.done = false; |
| 208 | | return &self.root; |
| 209 | 213 | } |
| 210 | 214 | |
| 211 | 215 | fn getTerminalWidth(self: Progress, file_handle: os.fd_t) !u16 { |