Skip to content

Feature: configurable colors for selected items (list_color_selected etc.) #555

Description

@erdivartanovich

First off — thanks for nchat, it themes beautifully into terminal-palette setups since empty/named colors inherit the terminal.

Problem

The currently selected item (chat list row, list dialog item, selected message) can only be styled via the *_attr_selected attributes (reverse/bold/italic/underline). There is no way to give the selection an explicit color. For theming pipelines that derive all UI colors from a wallpaper palette (pywal and similar), reverse video is the one element that can't be made palette-consistent — it produces a bright foreground-colored block regardless of theme.

Proposal

Add optional selected-color parameters, empty by default (= exactly today's behavior, zero migration needed since Config::Load merges defaults):

list_color_selected_bg= / _fg=
dialog_color_selected_bg= / _fg=
history_name_color_selected_bg= / _fg=
history_text_color_selected_bg= / _fg=

When set, the selected item uses this color pair in addition to its _attr_selected attribute. Precedence for the highlighted item: selected color over unread (list), shaded (dialog) and sent/recv/usercolor (history) — documented in README.

Working patch

I have a tested implementation ready on my fork (~79 lines, one commit):
https://github.com/erdivartanovich/nchat/tree/feature/selected-colors

Design notes:

  • new UiColorConfig::HasColor(param) gates every swap, so unset keys never allocate a pair and never touch the existing render paths
  • color-pair swaps use paired wattroff/wattron to avoid COLOR_PAIR bit OR-ing (the gotcha noted in feat: add group chat colors (green) in sidebar with wattrset fix #513)
  • builds warning-clean (-DHAS_TELEGRAM=OFF -DHAS_WHATSAPP=OFF -DHAS_DUMMY=ON), formatted with ./make.sh src
  • verified with the dummy protocol: defaults render byte-identical to master; with e.g. list_color_selected_bg=red the selected row emits the expected SGR
  • existing theme files keep working unchanged (missing keys fall back to defaults); happy to also update the 14 theme dumps if you prefer them explicit

Per CONTRIBUTING.md I'm opening this issue first — happy to submit the PR if you're open to the feature, and to adjust naming/scope to your preference.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions