@@ -790,8 +790,24 @@ void NWindow::close()
790790
791791 if (curses_window_)
792792 {
793+
794+
795+ try {
796+ // eliminate red color flash as palette changes during shutdown.
797+ if (color_palette_->DesktopBackground != color_palette_->Black ) {
798+ if (max_colors_ > 8 ) {
799+ auto defaultColor = make_color_pair (color_palette_->White , color_palette_->Black );
800+ wbkgd (root_curses_window_, defaultColor.attribute ());
801+ }
802+ }
803+ }
804+ catch (const std::exception& ignore)
805+ {
806+ (void )ignore; // ran out of colors? ignore.
807+ }
808+
793809 clear_window ();
794- // q restore_colors();
810+
795811 del_panel (curses_panel_);
796812 delwin (curses_window_);
797813
@@ -1320,8 +1336,10 @@ void NWindow::init_root_window()
13201336 init_color (COLOR_WHITE, color_palette_->White );
13211337
13221338 if (color_palette_->DesktopBackground != color_palette_->Black ) {
1323- auto desktopColor = make_color_pair (color_palette_->DesktopBackground , color_palette_->DesktopBackground );
1324- wbkgd (root_curses_window_, desktopColor.attribute ());
1339+ if (max_colors_ > 8 ) {
1340+ auto desktopColor = make_color_pair (color_palette_->DesktopBackground , color_palette_->DesktopBackground );
1341+ wbkgd (root_curses_window_, desktopColor.attribute ());
1342+ }
13251343 }
13261344
13271345
@@ -4630,7 +4648,7 @@ std::string NCheckboxElement::unchecked_text() const
46304648 {
46314649 if (window ()->console_font ())
46324650 {
4633- return " ☐ " ; // u2610
4651+ return " ☐ " ; // u2610
46344652 }
46354653 if (use_raspberry_pi_fallback () && (!window ()->console_font ()))
46364654 {
@@ -5742,22 +5760,22 @@ void NPopupMenuWindow::handle_cancelled()
57425760static const std::string CHECKMARK_PREFIX = " ✓ " ;
57435761static const std::string ASCII_CHECKMARK_PREFIX = " X " ;
57445762
5745- static std::string checkmark_prefix (bool is_unicode ) {
5746- if (is_unicode )
5763+ static std::string checkmark_prefix (NWindow* window ) {
5764+ if (window-> can_display_character (L ' ✓ ' ) )
57475765 {
57485766 return CHECKMARK_PREFIX;
57495767 }
57505768 return ASCII_CHECKMARK_PREFIX;
57515769}
5752- int NPopupMenuWindow::measure_prefix (const NMenuItem& item, bool is_unicode_locale )
5770+ int NPopupMenuWindow::measure_prefix (std::shared_ptr<NWindow> window, const NMenuItem& menuItem )
57535771{
5754- if (item .display_check )
5772+ if (menuItem .display_check )
57555773 {
5756- return this -> measure_text (checkmark_prefix (is_unicode_locale ));
5774+ return measure_text (checkmark_prefix (this ));
57575775 }
5758- else if (item .icon .length () != 0 )
5776+ else if (menuItem .icon .length () != 0 )
57595777 {
5760- return this -> measure_text (item .icon ) + 2 ;
5778+ return measure_text (menuItem .icon ) + 2 ;
57615779 }
57625780 else {
57635781 return 1 ;
@@ -5782,7 +5800,7 @@ void NPopupMenuWindow::Init(NWindow::ptr parentWindow, const std::vector<NMenuIt
57825800
57835801 int prefixWidth = 0 ;
57845802 for (auto & item : menu_items) {
5785- prefixWidth = std::max (prefixWidth, measure_prefix (item, parentWindow-> is_unicode_locale () ));
5803+ prefixWidth = std::max (prefixWidth, measure_prefix (parentWindow, item ));
57865804 }
57875805
57885806 for (auto & item : menu_items)
@@ -5838,7 +5856,7 @@ void NPopupMenuWindow::Init(NWindow::ptr parentWindow, const std::vector<NMenuIt
58385856 if (item.display_check ) {
58395857 if (item.checked )
58405858 {
5841- prefix = checkmark_prefix (parentWindow-> is_unicode_locale ());
5859+ prefix = checkmark_prefix (parentWindow. get ());
58425860 }
58435861 }
58445862 else if (item.icon .length () != 0 )
@@ -5947,9 +5965,9 @@ void NSubmenuMenuItemElement::open(bool value)
59475965 if (this_)
59485966 {
59495967 this_->on_cancelled .fire (this_);
5968+ this_->popup_window_ = nullptr ; // don't call close()
5969+ this_->open (false );
59505970 }
5951- this_->popup_window_ = nullptr ; // don't call close()
5952- this_->open (false );
59535971 }
59545972 );
59555973 }
@@ -5969,7 +5987,7 @@ void NSubmenuMenuItemElement::open(bool value)
59695987void NSubmenuMenuItemElement::handle_attached (NWindow* window)
59705988{
59715989 super::handle_attached (window);
5972- if (window->is_unicode_locale ( ))
5990+ if (window->can_display_character (L ' ⏵ ' ))
59735991 {
59745992 this ->suffix (" ⏵ " );
59755993 }
@@ -6200,23 +6218,24 @@ NMessageWindow::ptr NMessageWindow::create(
62006218
62016219void NMessageWindow::init (NWindow::ptr parent_window, NMessageType message_type, const std::string& message, int text_block_width)
62026220{
6203- if (parent_window->is_unicode_locale ())
6221+ std::string iconText;
6222+
6223+ switch (message_type)
62046224 {
6205- // with an icon.
6206- std::string iconText;
6225+ case NMessageType::Error:
6226+ iconText = " 🛑︎\uFE0E " ; // (\uFe0E = display b&w variant)
6227+ break ;
6228+ case NMessageType::Warning:
6229+ iconText = " ⚠️" ;
6230+ break ;
6231+ case NMessageType::Info:
6232+ iconText = " 🛈" ;
6233+ break ;
6234+ }
62076235
6208- switch (message_type)
6209- {
6210- case NMessageType::Error:
6211- iconText = " 🛑︎\uFE0E " ; // (\uFe0E = display b&w variant)
6212- break ;
6213- case NMessageType::Warning:
6214- iconText = " ⚠️" ;
6215- break ;
6216- case NMessageType::Info:
6217- iconText = " 🛈" ;
6218- break ;
6219- }
6236+ if (parent_window->can_display_character (utf8_char32_at (iconText,0 )))
6237+ {
6238+ // with an icon.
62206239
62216240 this ->add_child (
62226241 NVerticalStackElement::create ()
0 commit comments