mirror of
https://github.com/troglobit/libite.git
synced 2026-11-14 19:03:05 +00:00
Add printhdr(), replacement for printheader() with ANSI attribute
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
83ace4f12d
commit
72d1cb6501
2 files changed
+19
-5
No files matched your search
@@ -10,6 +10,7 @@ All notable changes to the project are documented in this file.
|
|||||||
- Add support for `strmatch()` and `strnmatch()`
|
- Add support for `strmatch()` and `strnmatch()`
|
||||||
- Add support for `yorn()`, safe yes-or-no prompt
|
- Add support for `yorn()`, safe yes-or-no prompt
|
||||||
- Add support for telnet expect/session APIs
|
- Add support for telnet expect/session APIs
|
||||||
|
- Add modified `printhdr()` which takes ANSI attribute
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- Fix `pidfile_signal()`: always return result of `kill()`, or the
|
- Fix `pidfile_signal()`: always return result of `kill()`, or the
|
||||||
|
|||||||
+18
-5
@@ -82,13 +82,26 @@ extern "C"
|
|||||||
|
|
||||||
void initscr(int *row, int *col);
|
void initscr(int *row, int *col);
|
||||||
|
|
||||||
/* Print table heading @line to @fp, with optional leading newline */
|
/* Print table heading @line to @fp, with optional leading newline
|
||||||
|
* Example:
|
||||||
|
* _________________ <-- Empty line with UNDERSCORE to frame first heading
|
||||||
|
* First heading <-- In normal/RESETATTR
|
||||||
|
* SUBHEADING <-- In REVERSE and with capital letters like 'top'
|
||||||
|
*/
|
||||||
|
static inline void printhdr(FILE *fp, const char *line, int nl, int attr)
|
||||||
|
{
|
||||||
|
if (attr < 0 || attr > 8)
|
||||||
|
attr = REVERSE;
|
||||||
|
|
||||||
|
fprintf(fp ?: stdout,
|
||||||
|
"%s\033[%dm%s%*s\033[0m\n",
|
||||||
|
nl ? "\n" : "", attr, line,
|
||||||
|
SCREEN_WIDTH - (int)strlen(line), "");
|
||||||
|
}
|
||||||
|
|
||||||
static inline void printheader(FILE *fp, const char *line, int nl)
|
static inline void printheader(FILE *fp, const char *line, int nl)
|
||||||
{
|
{
|
||||||
fprintf(fp ?: stdout,
|
printhdr(fp, line, nl, REVERSE);
|
||||||
"%s\033[7m%s%*s\033[0m\n",
|
|
||||||
nl ? "\n" : "",
|
|
||||||
line, SCREEN_WIDTH - (int)strlen(line), "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONIO_H_ */
|
#endif /* CONIO_H_ */
|
||||||
|
|||||||
Reference in new issue
Block a user