[GH-ISSUE #934] More precise view customization of selected table cells #683

Closed
opened 2026-03-04 01:07:01 +03:00 by kerem · 4 comments
Owner

Originally created by @vlanse on GitHub (Jan 7, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/934

Currently selected style could by only set "globally" for table, so it overrides cell style completely when it is selected. There are cases when this such behavior is not ok, e.g. when content of table cells is displayed with different colors of cells depending on some params. When such a row with different cell colors is selected now, color differentiation is removed completely

I know that when selection style is not set, colors are "reverted", but this approach gives visually unpleasant results, at least in some cases.

Suggestion is to allow per-cell customization of appearance of selected cells, so selected style could be (optionally) set on a per-cell basis.

Originally created by @vlanse on GitHub (Jan 7, 2024). Original GitHub issue: https://github.com/rivo/tview/issues/934 Currently selected style could by only set "globally" for table, so it overrides cell style completely when it is selected. There are cases when this such behavior is not ok, e.g. when content of table cells is displayed with different colors of cells depending on some params. When such a row with different cell colors is selected now, color differentiation is removed completely I know that when selection style is not set, colors are "reverted", but this approach gives visually unpleasant results, at least in some cases. Suggestion is to allow per-cell customization of appearance of selected cells, so selected style could be (optionally) set on a per-cell basis.
kerem closed this issue 2026-03-04 01:07:01 +03:00
Author
Owner

@rivo commented on GitHub (Apr 4, 2024):

Can you provide an example where reverting the colours gives unpleasant results?

<!-- gh-comment-id:2037642071 --> @rivo commented on GitHub (Apr 4, 2024): Can you provide an example where reverting the colours gives unpleasant results?
Author
Owner

@vlanse commented on GitHub (Apr 4, 2024):

Sure, here it is. IMO the selected line (45) is not even readable:

Screenshot 2024-04-04 at 21 22 37

What I want is just to add the underline style to the selected row, but right now it could not be achieved, as you can see below, the color differentiation between the cells is lost (same line 45 selected below):

Screenshot 2024-04-04 at 21 17 31

Best solution IMO would be to add underline style to selected row w/o changing the other styles.

<!-- gh-comment-id:2037913281 --> @vlanse commented on GitHub (Apr 4, 2024): Sure, here it is. IMO the selected line (`45`) is not even readable: <img width="825" alt="Screenshot 2024-04-04 at 21 22 37" src="https://github.com/rivo/tview/assets/17192647/454cb0c9-fd1e-496a-97fd-dc2bd38a3eef"> What I want is just to add the underline style to the selected row, but right now it could not be achieved, as you can see below, the color differentiation between the cells is lost (same line `45` selected below): <img width="818" alt="Screenshot 2024-04-04 at 21 17 31" src="https://github.com/rivo/tview/assets/17192647/ce2a2cce-cf9a-4fbf-a525-c208b5159105"> Best solution IMO would be to add underline style to selected row w/o changing the other styles.
Author
Owner

@rivo commented on GitHub (Apr 6, 2024):

It seems to me that you're setting the cell's background colour to tcell.ColorDefault. And your default terminal color is some kind of grey. So swapping the colours leads to the background colour to be red (or green) and the foreground colour to be grey. Yes, that leads to low contrast.

I would suggest not to use tcell.ColorDefault here (or anywhere, for that matter). In your example, set it to tcell.ColorBlack. That's the default already so you don't really have to set anything here anyway.

<!-- gh-comment-id:2041084808 --> @rivo commented on GitHub (Apr 6, 2024): It seems to me that you're setting the cell's background colour to `tcell.ColorDefault`. And your default terminal color is some kind of grey. So swapping the colours leads to the background colour to be red (or green) and the foreground colour to be grey. Yes, that leads to low contrast. I would suggest not to use `tcell.ColorDefault` here (or anywhere, for that matter). In your example, set it to `tcell.ColorBlack`. That's the default already so you don't really have to set anything here anyway.
Author
Owner

@rivo commented on GitHub (Apr 6, 2024):

But in any case, the latest commit introduces individual styling for selected cells.

<!-- gh-comment-id:2041101509 --> @rivo commented on GitHub (Apr 6, 2024): But in any case, the latest commit introduces individual styling for selected cells.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#683
No description provided.