More precise view customization of selected table cells
vlanse opened this issue · comments
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.
Can you provide an example where reverting the colours gives unpleasant results?
Sure, here it is. IMO the selected line (45
) is not even readable:
![Screenshot 2024-04-04 at 21 22 37](https://private-user-images.githubusercontent.com/17192647/319725736-454cb0c9-fd1e-496a-97fd-dc2bd38a3eef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxOTAwNjIsIm5iZiI6MTcyMjE4OTc2MiwicGF0aCI6Ii8xNzE5MjY0Ny8zMTk3MjU3MzYtNDU0Y2IwYzktZmQxZS00OTZhLTk3ZmQtZGMyYmQzOGEzZWVmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI4VDE4MDI0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkwNzc3NmIxYjgwYTM2NmZhNmJjYTIzMGYxM2EyMTE3MGZhZWZlZWY2YjBjYTcwYzUzMzE1MTM2YTNlZDUxYjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.N1vP9-FLxsEjeRlkpz_uGFfyXjS1KwMUc5h7l3iPT40)
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](https://private-user-images.githubusercontent.com/17192647/319724405-ce2a2cce-cf9a-4fbf-a525-c208b5159105.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxOTAwNjIsIm5iZiI6MTcyMjE4OTc2MiwicGF0aCI6Ii8xNzE5MjY0Ny8zMTk3MjQ0MDUtY2UyYTJjY2UtY2Y5YS00ZmJmLWE1MjUtYzIwOGI1MTU5MTA1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI4VDE4MDI0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTczMTZmMDNhODg5ZTliOWEwM2FjMmI1M2NiYjE1OTNmODUzNzM3M2I0OWUzZmNkYzg5ZDhmN2RhZGI2YmMzYTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.YfA9OltRXwF3T8BeAU1KsW5cS-RqsUqglWCFpcMt8XU)
Best solution IMO would be to add underline style to selected row w/o changing the other styles.
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.
But in any case, the latest commit introduces individual styling for selected cells.