terminal-util: add a function that shows a pretty separator line

Follow-up for #8824
This commit is contained in:
Lennart Poettering
2018-05-11 08:15:33 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent e4915c2797
commit cb91deaf77
4 changed files with 27 additions and 4 deletions
+22
View File
@@ -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);
}
+2
View File
@@ -166,3 +166,5 @@ typedef enum CatFlags {
} CatFlags;
int cat_files(const char *file, char **dropins, CatFlags flags);
void print_separator(void);