From bcda5404011714622ec22a37c4b7837defe4377e Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 14 Apr 2014 19:14:30 +0300 Subject: [PATCH] Hide title if more than NCOLS --- lib/draw/curses.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/draw/curses.c b/lib/draw/curses.c index 5673c90..2cc84af 100644 --- a/lib/draw/curses.c +++ b/lib/draw/curses.c @@ -206,8 +206,12 @@ static void _bmDrawCursesRender(const bmMenu *menu) const unsigned int lines = curses.getmaxy(curses.stdscr); curses.erase(); - unsigned int titleLen = (menu->title ? strlen(menu->title) + 1 : 0); unsigned int ncols = curses.getmaxx(curses.stdscr); + unsigned int titleLen = (menu->title ? strlen(menu->title) + 1 : 0); + + if (titleLen >= ncols) + titleLen = 0; + unsigned int ccols = ncols - titleLen - 1; unsigned int dcols = 0, doffset = menu->cursor; @@ -219,7 +223,7 @@ static void _bmDrawCursesRender(const bmMenu *menu) _bmDrawCursesDrawLine(0, 0, "%*s%s", titleLen, "", (menu->filter ? menu->filter + doffset : "")); - if (menu->title) { + if (menu->title && titleLen > 0) { curses.attron(COLOR_PAIR(1)); curses.mvprintw(0, 0, menu->title); curses.attroff(COLOR_PAIR(1));