diff options
| author | Alfonso Siciliano <alfsiciliano@gmail.com> | 2022-01-19 08:28:42 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2022-01-19 08:28:42 +0000 |
| commit | 8ea2d22e6d54d492b6b169014841eb27d4617459 (patch) | |
| tree | c2393e1a598c453f173432d516ee79db28d97971 | |
| parent | 0ce7909cd0ba35148bddd8309534cb96e9e20f48 (diff) | |
| download | src-8ea2d22e6d54d492b6b169014841eb27d4617459.tar.gz src-8ea2d22e6d54d492b6b169014841eb27d4617459.zip | |
bsddialog: Fix for terminals without colours
When running the installer, in particular disextract (which is so far
the only part converted to bsddialog), on serial console or vt100 or
actually any terminal without color support, it failed to start.
This change makes bsddialog fallback on the black and white theme.
This is incorporated in newer version of bsddialog which will be
imported soon.
PR: 261272
Reported by: thj
Differential Revision: https://reviews.freebsd.org/D33920
| -rw-r--r-- | contrib/bsddialog/lib/libbsddialog.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/contrib/bsddialog/lib/libbsddialog.c b/contrib/bsddialog/lib/libbsddialog.c index aea3b152adfd..ed4001382e31 100644 --- a/contrib/bsddialog/lib/libbsddialog.c +++ b/contrib/bsddialog/lib/libbsddialog.c @@ -57,11 +57,12 @@ extern struct bsddialog_theme t; int bsddialog_init(void) { int i, j, c, error; + enum bsddialog_default_theme theme; set_error_string(""); - if(initscr() == NULL) - RETURN_ERROR("Cannot init ncurses (initscr)"); + if (initscr() == NULL) + RETURN_ERROR("Cannot init curses (initscr)"); error = OK; error += keypad(stdscr, TRUE); @@ -69,9 +70,9 @@ int bsddialog_init(void) error += cbreak(); error += noecho(); curs_set(0); - if(error != OK) { + if (error != OK) { bsddialog_end(); - RETURN_ERROR("Cannot init ncurses (keypad and cursor)"); + RETURN_ERROR("Cannot init curses (keypad and cursor)"); } c = 1; @@ -81,12 +82,13 @@ int bsddialog_init(void) error += init_pair(c, i, j); c++; } - if(error != OK) { - bsddialog_end(); - RETURN_ERROR("Cannot init ncurses (colors)"); - } - if (bsddialog_set_default_theme(BSDDIALOG_THEME_DEFAULT) != 0) { + if (error == OK) + theme = BSDDIALOG_THEME_DEFAULT; + else + theme = BSDDIALOG_THEME_BLACKWHITE; + + if (bsddialog_set_default_theme(theme) != 0) { bsddialog_end(); return (BSDDIALOG_ERROR); } |
