-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When the TTY is too narrow to contain the output, the assumption that a carriage return and whitespace while erase the line no longer holds. Prior to printing, check the number of columns available in the TTY. See alire-project/alire#1329 for a demonstration of the issue.
- Loading branch information
Showing
3 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdbool.h> | ||
#include <sys/ioctl.h> | ||
#include <termios.h> | ||
|
||
bool ioctl_failure = false; | ||
|
||
int simple_logging_term_width(void) | ||
{ | ||
struct winsize x; | ||
int r; | ||
|
||
if (ioctl_failure) return -1; | ||
r = ioctl(2, TIOCGWINSZ, &x); | ||
|
||
if (r != 0) { | ||
ioctl_failure = true; | ||
return -1; | ||
} else { | ||
return x.ws_col; | ||
} | ||
} |