summaryrefslogtreecommitdiffstats
path: root/ui/ncurses/nc-scr.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-10-09 16:48:38 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-10-09 17:40:41 +0800
commit47bc66a0c744f68a84147b0bd616ab25a242fb70 (patch)
tree13aad60595c03209847954c0222a37db81f7a85f /ui/ncurses/nc-scr.c
parent8ec7ea724de780a6a428a8485b2760bf1d9e0a4e (diff)
downloadtalos-petitboot-47bc66a0c744f68a84147b0bd616ab25a242fb70.tar.gz
talos-petitboot-47bc66a0c744f68a84147b0bd616ab25a242fb70.zip
ui/ncurses: Display sysinfo type & identifier
Hook into the sysinfo updates to display the type & id at the top of the petitboot main menu. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui/ncurses/nc-scr.c')
-rw-r--r--ui/ncurses/nc-scr.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ui/ncurses/nc-scr.c b/ui/ncurses/nc-scr.c
index ff20d63..9a3f3df 100644
--- a/ui/ncurses/nc-scr.c
+++ b/ui/ncurses/nc-scr.c
@@ -22,6 +22,7 @@
#include <assert.h>
#include <stdarg.h>
+#include <string.h>
#include "log/log.h"
#include "talloc/talloc.h"
@@ -70,11 +71,23 @@ static void nc_scr_status_draw(struct nc_scr *scr)
void nc_scr_frame_draw(struct nc_scr *scr)
{
- DBGS("title '%s'\n", scr->frame.title);
+ int ltitle_len, rtitle_len;
+
+ DBGS("ltitle '%s'\n", scr->frame.ltitle);
+ DBGS("rtitle '%s'\n", scr->frame.rtitle);
DBGS("help '%s'\n", scr->frame.help);
DBGS("status '%s'\n", scr->frame.status);
- mvwaddstr(scr->main_ncw, nc_scr_pos_title, 1, scr->frame.title);
+ ltitle_len = strlen(scr->frame.ltitle);
+ rtitle_len = scr->frame.rtitle ? strlen(scr->frame.rtitle) : 0;
+
+ /* if both ltitle and rtitle don't fit, trim rtitle */
+ if (ltitle_len + rtitle_len + nc_scr_pos_lrtitle_space > COLS - 2)
+ rtitle_len = COLS - 2 - ltitle_len - nc_scr_pos_lrtitle_space;
+
+ mvwaddstr(scr->main_ncw, nc_scr_pos_title, 1, scr->frame.ltitle);
+ mvwaddnstr(scr->main_ncw, nc_scr_pos_title, COLS - rtitle_len - 1,
+ scr->frame.rtitle, rtitle_len);
mvwhline(scr->main_ncw, nc_scr_pos_title_sep, 1, ACS_HLINE, COLS - 2);
mvwhline(scr->main_ncw, LINES - nc_scr_pos_help_sep, 1, ACS_HLINE,
OpenPOWER on IntegriCloud