* Clear the entire line, leave cursor in first column. */
| 235 | * Clear the entire line, leave cursor in first column. |
| 236 | */ |
| 237 | void term_clear_line(void) |
| 238 | { |
| 239 | if (!isatty(2)) |
| 240 | return; |
| 241 | if (is_terminal_dumb()) |
| 242 | /* |
| 243 | * Fall back to print a terminal width worth of space |
| 244 | * characters (hoping that the terminal is still as wide |
| 245 | * as it was upon the first call to term_columns()). |
| 246 | */ |
| 247 | fprintf(stderr, "\r%*s\r", term_columns(), ""); |
| 248 | else |
| 249 | /* |
| 250 | * On non-dumb terminals use an escape sequence to clear |
| 251 | * the whole line, no matter how wide the terminal. |
| 252 | */ |
| 253 | fputs("\r\033[K", stderr); |
| 254 | } |
| 255 | |
| 256 | /* |
| 257 | * How many columns do we need to show this number in decimal? |
no test coverage detected