diff options
Diffstat (limited to 'scripts/lxdialog/util.c')
-rw-r--r-- | scripts/lxdialog/util.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/lxdialog/util.c b/scripts/lxdialog/util.c index ce41147..f82cebb 100644 --- a/scripts/lxdialog/util.c +++ b/scripts/lxdialog/util.c @@ -177,6 +177,20 @@ void end_dialog(void) endwin(); } +/* Print the title of the dialog. Center the title and truncate + * tile if wider than dialog (- 2 chars). + **/ +void print_title(WINDOW *dialog, const char *title, int width) +{ + if (title) { + int tlen = MIN(width - 2, strlen(title)); + wattrset(dialog, title_attr); + mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); + mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); + waddch(dialog, ' '); + } +} + /* * Print a string of text in a window, automatically wrap around to the * next line if the string is too long to fit on one line. Newline |