aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lxdialog/util.c
diff options
context:
space:
mode:
authorSam Ravnborg <sam@mars.ravnborg.org>2005-11-19 23:38:06 +0100
committerSam Ravnborg <sam@mars.ravnborg.org>2005-11-19 23:38:06 +0100
commitfa7009d5b59b8acd8071f7b3057d36eeeaf08146 (patch)
treeba88e9f448aed4c047d8ce311ba44c8731ee96c2 /scripts/lxdialog/util.c
parentkconfig: lxdialog is now sparse clean (diff)
downloadlinux-dev-fa7009d5b59b8acd8071f7b3057d36eeeaf08146.tar.xz
linux-dev-fa7009d5b59b8acd8071f7b3057d36eeeaf08146.zip
kconfig: Add print_title helper in lxdialog
Simplify check for long title and use a helper function in util.c Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to '')
-rw-r--r--scripts/lxdialog/util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/lxdialog/util.c b/scripts/lxdialog/util.c
index ce411474d729..f82cebb9ff06 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