[GH-ISSUE #73] Ability to disable default style. #52

Closed
opened 2026-03-04 01:01:29 +03:00 by kerem · 6 comments
Owner

Originally created by @lesovsky on GitHub (Mar 11, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/73

Hi,

Is it possible to disable default color style and use console-defined style?

In most cases people use their own color themes in their terminals and IMO programs have to use colors used by terminal and colors defined by programs should be optional. In my experience, changing style automatically from console-defined to program-defined might give unexpected visual appearance in some circumstances.

image

Originally created by @lesovsky on GitHub (Mar 11, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/73 Hi, Is it possible to disable default color style and use console-defined style? In most cases people use their own color themes in their terminals and IMO programs have to use colors used by terminal and colors defined by programs should be optional. In my experience, changing style automatically from console-defined to program-defined might give unexpected visual appearance in some circumstances. ![image](https://user-images.githubusercontent.com/953312/37251407-603445fe-2531-11e8-94db-23ae2673ff3c.png)
kerem closed this issue 2026-03-04 01:01:29 +03:00
Author
Owner

@rivo commented on GitHub (Mar 11, 2018):

Please see Styles on how to change the default styles.

I don't know if terminal applications have access to any individually predefined colors? This would be a tcell topic. Maybe you can find out?

<!-- gh-comment-id:372099816 --> @rivo commented on GitHub (Mar 11, 2018): Please see [`Styles`](https://godoc.org/github.com/rivo/tview#pkg-variables) on how to change the default styles. I don't know if terminal applications have access to any individually predefined colors? This would be a [`tcell`](https://github.com/gdamore/tcell) topic. Maybe you can find out?
Author
Owner

@lesovsky commented on GitHub (Mar 11, 2018):

I've already familiarized with Styles variable, and as I understand it defines primitive's default color scheme automatically at program startup and thus overrides colors defined by terminal.

Anyway, I going to dig into tcell and try to find out how it works with colors.

Thanks!

<!-- gh-comment-id:372132596 --> @lesovsky commented on GitHub (Mar 11, 2018): I've already familiarized with `Styles` variable, and as I understand it defines primitive's default color scheme automatically at program startup and thus overrides colors defined by terminal. Anyway, I going to dig into `tcell` and try to find out how it works with colors. Thanks!
Author
Owner

@lesovsky commented on GitHub (Mar 13, 2018):

Could you provide simple example how to work with Styles? I trying to manipulate with struct variables such as Styles.PrimaryTextColor , Styles.PrimitiveBackgroundColor, but see no color changes in primitives.

<!-- gh-comment-id:372603684 --> @lesovsky commented on GitHub (Mar 13, 2018): Could you provide simple example how to work with `Styles`? I trying to manipulate with struct variables such as `Styles.PrimaryTextColor` , `Styles.PrimitiveBackgroundColor`, but see no color changes in primitives.
Author
Owner

@lesovsky commented on GitHub (Mar 13, 2018):

ok, i see, styles have to be changed before primitives initialization.

<!-- gh-comment-id:372613476 --> @lesovsky commented on GitHub (Mar 13, 2018): ok, i see, styles have to be changed before primitives initialization.
Author
Owner

@lesovsky commented on GitHub (Mar 13, 2018):

Well, I've completely solved the issue.
Before initializing primitives, it needs to setup Styles variable, in particular Styles.PrimaryTextColor and Styles.PrimitiveBackgroundColor shoul be set to tcell.ColorDefault. Thus program will get terminal colors for foreground text and background. Probably, adjusting other Style's variables to tcell.ColorDefault will make the same behaviour but I didn't check.

<!-- gh-comment-id:372634587 --> @lesovsky commented on GitHub (Mar 13, 2018): Well, I've completely solved the issue. Before initializing primitives, it needs to setup `Styles` variable, in particular `Styles.PrimaryTextColor` and `Styles.PrimitiveBackgroundColor` shoul be set to `tcell.ColorDefault`. Thus program will get terminal colors for foreground text and background. Probably, adjusting other Style's variables to `tcell.ColorDefault` will make the same behaviour but I didn't check.
Author
Owner

@rivo commented on GitHub (Mar 13, 2018):

Yes, tcell.ColorDefault basically means "transparent". I haven't checked myself how this affects the drawing of primitive backgrounds but if you say you were able to achieve the desired effect, then I assume that's the solution.

The Styles struct is really only meant to be set once in the beginning, to define the overall style of your application. These are the defaults that are used during instantiation of primitives. (That's why they don't have an effect afterwards anymore.)

<!-- gh-comment-id:372737140 --> @rivo commented on GitHub (Mar 13, 2018): Yes, `tcell.ColorDefault` basically means "transparent". I haven't checked myself how this affects the drawing of primitive backgrounds but if you say you were able to achieve the desired effect, then I assume that's the solution. The `Styles` struct is really only meant to be set once in the beginning, to define the overall style of your application. These are the defaults that are used during instantiation of primitives. (That's why they don't have an effect afterwards anymore.)
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#52
No description provided.