Add flag selectedReverseColor to reverse style of selected item#598
Add flag selectedReverseColor to reverse style of selected item#598mdom wants to merge 5 commits intorivo:masterfrom mdom:selectedReverseColor
Conversation
|
Oh, I forget to write that i would be willing to add the code if you like the idea... :) |
| - [Fast disk usage analyzer written in Go](https://github.com/dundee/gdu) | ||
| - [Multiplayer Chess On Terminal](https://github.com/qnkhuat/gochess) | ||
| - [Scriptable TUI music player](https://github.com/issadarkthing/gomu) | ||
| - [MangaDesk : TUI Client for downloading manga to your computer](https://github.com/darylhjd/mangadesk) |
There was a problem hiding this comment.
It's ok to include this here but if you want this to be accepted faster, you may want to submit a separate PR for your project.
|
|
||
| require ( | ||
| github.com/gdamore/tcell/v2 v2.2.1 | ||
| github.com/gdamore/tcell/v2 v2.3.3 |
There was a problem hiding this comment.
Can you remove the go.mod changes from this PR? I'd like to keep upgrades separate.
| github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= | ||
| github.com/gdamore/tcell/v2 v2.2.1 h1:Gt8wk0jd5pIK2CyXNo/fqwxNWf726j1lQjEDdfbnqTc= | ||
| github.com/gdamore/tcell/v2 v2.2.1/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= | ||
| github.com/gdamore/tcell/v2 v2.3.3 h1:RKoI6OcqYrr/Do8yHZklecdGzDTJH9ACKdfECbRdw3M= |
There was a problem hiding this comment.
Can you remove the go.sum changes from this PR? I'd like to keep upgrades separate.
| // The item main text color. | ||
| mainTextColor tcell.Color | ||
| // The item main text style. | ||
| mainTextStyle tcell.Style |
There was a problem hiding this comment.
This is not indented like the others. Did this go through gofmt? Is this maybe just an issue with GitHub?
|
|
||
| // NewList returns a new form. | ||
| func NewList() *List { | ||
| base := tcell.StyleDefault.Background(Styles.PrimitiveBackgroundColor) |
There was a problem hiding this comment.
While I appreciate this PR (it's something that needs to be done anyway, see #611), I'm not sure setting this background colour for all styles is the correct way to do this (unless it's ignored, see further below). Have you tried setting a list's background colour using Box.SetBackgroundColor() to something else, say, blue? What do the list items look like when you do that?
| } | ||
|
|
||
| // SetMainTextStyle sets the style of the items' main text. | ||
| func (l *List) SetMainTextStyle(style tcell.Style) *List { |
There was a problem hiding this comment.
Can you also add getters for all of these new setters, please?
| // Shortcuts. | ||
| if showShortcuts && item.Shortcut != 0 { | ||
| Print(screen, fmt.Sprintf("(%s)", string(item.Shortcut)), x-5, y, 4, AlignRight, l.shortcutColor) | ||
| printWithStyle(screen, fmt.Sprintf("(%s)", string(item.Shortcut)), x-5, y, 0, 4, AlignRight, l.shortcutStyle, false) |
There was a problem hiding this comment.
Referring to my comment above and relating to all of the printWithStyle() calls: Doesn't this override the list's overall background colour? You might want to set the last argument (maintainBackground) to true if the style's background colour is tcell.ColorDefault.
I'm working on xterm with disabled color support. This patch allows me to see the currently selected item in a list. This is probably not a good solution, there are surley be other widgets with similar problems. But i just wanted to see if the reverse code worked.
What do you think about adding a api, where i can just set styles directly for elements? Like SetSelectedStyle, SetBorderStyle, etc?