Skip to content

style: use reverse attribute for selected widget states#1154

Draft
ljluestc wants to merge 1 commit into
rivo:masterfrom
ljluestc:private-issue-1133-reverse-attributes
Draft

style: use reverse attribute for selected widget states#1154
ljluestc wants to merge 1 commit into
rivo:masterfrom
ljluestc:private-issue-1133-reverse-attributes

Conversation

@ljluestc

@ljluestc ljluestc commented May 4, 2026

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: close #1133

Selected-state rendering in several widgets is currently implemented by swapping foreground and background colors directly. This can produce inconsistent visuals across themes and terminals, and requires each widget to duplicate style inversion logic.

The issue proposes using reverse video attributes for selected items instead of manually inverting explicit foreground/background pairs.

What changed and how does it work?

This PR updates selected-item styling to use reverse attributes:

  1. Replace selected style definitions that manually swap foreground/background with tcell.StyleDefault.Reverse(true) (or equivalent style composition preserving existing text attributes).
  2. Apply the same pattern consistently across widgets that support selected-item rendering (for example TreeView nodes, List items, Form focus, and other applicable selected states).
  3. Preserve existing non-selected styles and color configuration behavior.
  4. Keep explicit per-widget selected style overrides functioning as before.
  5. Add/update tests (where available) to validate selected rendering behavior remains consistent.

Why this approach?

  • Uses terminal-native reverse rendering semantics.
  • Reduces duplicated color inversion logic across components.
  • Improves consistency across themes and terminal capabilities.
  • Keeps the change focused to selected-state style behavior.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test
    • Launch demo/screens for List, Form, and TreeView.
    • Move selection across items and verify selected rows use reverse video.
    • Verify custom color theme still applies for non-selected content.
  • No need to test

Documentation

  • Affects user behaviors
  • Additional docs required

Release note

Use reverse video attributes for selected widget items instead of manual foreground/background inversion to improve cross-terminal consistency.

Co-Authored-By: Oz <oz-agent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use reverse attributes on selected items instead of inverting foreground and background

1 participant