terminal-util: add a function that shows a pretty separator line
Follow-up for #8824
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
e4915c2797
commit
cb91deaf77
@@ -1418,3 +1418,25 @@ int cat_files(const char *file, char **dropins, CatFlags flags) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_separator(void) {
|
||||
|
||||
/* Outputs a separator line that resolves to whitespace when copied from the terminal. We do that by outputting
|
||||
* one line filled with spaces with ANSI underline set, followed by a second (empty) line. */
|
||||
|
||||
if (underline_enabled()) {
|
||||
size_t i, c;
|
||||
|
||||
c = columns();
|
||||
|
||||
flockfile(stdout);
|
||||
fputs_unlocked(ANSI_UNDERLINE, stdout);
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
fputc_unlocked(' ', stdout);
|
||||
|
||||
fputs_unlocked(ANSI_NORMAL "\n\n", stdout);
|
||||
funlockfile(stdout);
|
||||
} else
|
||||
fputs("\n\n", stdout);
|
||||
}
|
||||
|
||||
@@ -166,3 +166,5 @@ typedef enum CatFlags {
|
||||
} CatFlags;
|
||||
|
||||
int cat_files(const char *file, char **dropins, CatFlags flags);
|
||||
|
||||
void print_separator(void);
|
||||
|
||||
Reference in New Issue
Block a user