feat: add group chat colors (green) in sidebar with wattrset fix#513
Open
arcesannemannmartin wants to merge 2 commits intod99kris:masterfrom
Open
feat: add group chat colors (green) in sidebar with wattrset fix#513arcesannemannmartin wants to merge 2 commits intod99kris:masterfrom
arcesannemannmartin wants to merge 2 commits intod99kris:masterfrom
Conversation
added 2 commits
April 15, 2026 18:45
…ing keys This fixes a crash (std::out_of_range) that occurred when combining color config changes in 4 files (uicolorconfig.cpp, uimodel.h, uimodel.cpp, uilistview.cpp). The crash happened in libncutil.so during color initialization because: 1. UiColorConfig::m_Config is a static global initialized with the default Config constructor (empty map) 2. Static variables with complex init (like lambdas calling UiColorConfig::GetColorPair) could run before UiColorConfig::Init() 3. These calls would hit Config::Get() which used m_Map.at(key) 4. Since the map was empty (default ctor), std::out_of_range was thrown The fix makes Config::Get() return empty string for missing keys with a warning, instead of crashing. This makes the code more defensive without breaking existing functionality.
- uicolorconfig: add list_color_group_fg and list_color_group_unread_fg keys - uimodel: add GetChatInfoIsGroupLocked() to check if chat is a group - uilistview: use wattrset (not wattron) to apply colors correctly; green for groups, orange for unread groups - ncurses color fix: wattrset replaces all attrs; wattron adds bits which caused color stacking
Owner
|
Hi @arcesannemannmartin - thanks for contributing. I will try find some time to review and feedback soon. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds green color for group chats in the sidebar, and orange for unread group chats. Also fixes a ncurses color stacking bug.
Root Cause Fix
wattron()ADDS attribute bits using OR — when using multiple COLOR_PAIR values, bits combine unpredictably causing all items to turn green.Fix: Use
wattrset()which REPLACES all attributes at once, combined with highlight attrs.Changes
src/uicolorconfig.cpp: addlist_color_group_fgandlist_color_group_unread_fgkeyssrc/uimodel.h/cpp: addGetChatInfoIsGroupLocked()to check if chat is a groupsrc/uilistview.cpp: apply colors withwattrset; green for groups, orange for unread groups~/.config/nchat/color.conf: add group color definitionsTesting
LD_LIBRARY_PATH=/home/martinarces/nchat/build/lib timeout 5 ./build/bin/nchat # exit 124 = timeout without crashRelated
859c19d5fix: make Config::Get return empty string instead of crashing on missing keys