mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-06 09:30:11 +01:00
util: add two macros for clearing a line
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1280>
This commit is contained in:
parent
4a67ddc111
commit
e8d24f818b
2 changed files with 8 additions and 9 deletions
|
|
@ -98,6 +98,9 @@
|
|||
#define ANSI_RGB(r, g, b) "\x1B[38;2;" #r ";" #g ";" #b "m"
|
||||
#define ANSI_RGB_BG(r, g, b) "\x1B[48;2;" #r ";" #g ";" #b "m"
|
||||
|
||||
#define ANSI_CLEAR_LINE "\x1B[2K"
|
||||
#define ANSI_CLEAR_EOL "\x1B[0K"
|
||||
|
||||
#define CASE_RETURN_STRING(a) case a: return #a
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -78,18 +78,14 @@ LIBINPUT_ATTRIBUTE_PRINTF(1, 2)
|
|||
static void
|
||||
print_line(const char *format, ...)
|
||||
{
|
||||
char empty[] =
|
||||
" ";
|
||||
const int width = 80;
|
||||
int n;
|
||||
char buf[256];
|
||||
|
||||
va_list args;
|
||||
|
||||
printf("\r");
|
||||
|
||||
va_start(args, format);
|
||||
n = vprintf(format, args);
|
||||
vsnprintf(buf, sizeof(buf), format, args);
|
||||
va_end(args);
|
||||
printf("%.*s\n", width - n, empty);
|
||||
|
||||
printf(ANSI_CLEAR_LINE "%s\n", buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue