Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for themes #81

Closed
tconbeer opened this issue Jun 1, 2023 · 3 comments · Fixed by #188
Closed

Improve support for themes #81

tconbeer opened this issue Jun 1, 2023 · 3 comments · Fixed by #188
Labels
enhancement New feature or request

Comments

@tconbeer
Copy link
Owner

tconbeer commented Jun 1, 2023

Follow-up to #80

right now setting a theme just impacts the query editor pane, and it looks bad for most themes:

image

We could carry the theme colors throughout, with a lot of work.

Unfortunately, these are Pygments themes, which don't line up for Textual's planned support for themes (e.g., light/dark etc.)

@tconbeer tconbeer added the enhancement New feature or request label Jul 26, 2023
@tconbeer tconbeer mentioned this issue Aug 22, 2023
@tconbeer
Copy link
Owner Author

It actually might not be bad to grab colors from the pygments style:
https://pygments.org/docs/styles/

@tconbeer
Copy link
Owner Author

tconbeer commented Aug 22, 2023

>>> from pygments.styles import get_style_by_name
>>> mo = get_style_by_name('monokai')
>>> mo.background_color
'#272822'
>>> mo.highlight_color
'#49483e'
>>> mo.styles
{Token: '#f8f8f2', Token.Text.Whitespace: '', Token.Error: '#960050 bg:#1e0010', Token.Other: '', Token.Comment: '#75715e', Token.Comment.Multiline: '', Token.Comment.Preproc: '', Token.Comment.Single: '', Token.Comment.Special: '', Token.Keyword: '#66d9ef', Token.Keyword.Constant: '', Token.Keyword.Declaration: '', Token.Keyword.Namespace: '#f92672', Token.Keyword.Pseudo: '', Token.Keyword.Reserved: '', Token.Keyword.Type: '', Token.Operator: '#f92672', Token.Operator.Word: '', Token.Punctuation: '#f8f8f2', Token.Name: '#f8f8f2', Token.Name.Attribute: '#a6e22e', Token.Name.Builtin: '', Token.Name.Builtin.Pseudo: '', Token.Name.Class: '#a6e22e', Token.Name.Constant: '#66d9ef', Token.Name.Decorator: '#a6e22e', Token.Name.Entity: '', Token.Name.Exception: '#a6e22e', Token.Name.Function: '#a6e22e', Token.Name.Property: '', Token.Name.Label: '', Token.Name.Namespace: '', Token.Name.Other: '#a6e22e', Token.Name.Tag: '#f92672', Token.Name.Variable: '', Token.Name.Variable.Class: '', Token.Name.Variable.Global: '', Token.Name.Variable.Instance: '', Token.Literal.Number: '#ae81ff', Token.Literal.Number.Float: '', Token.Literal.Number.Hex: '', Token.Literal.Number.Integer: '', Token.Literal.Number.Integer.Long: '', Token.Literal.Number.Oct: '', Token.Literal: '#ae81ff', Token.Literal.Date: '#e6db74', Token.Literal.String: '#e6db74', Token.Literal.String.Backtick: '', Token.Literal.String.Char: '', Token.Literal.String.Doc: '', Token.Literal.String.Double: '', Token.Literal.String.Escape: '#ae81ff', Token.Literal.String.Heredoc: '', Token.Literal.String.Interpol: '', Token.Literal.String.Other: '', Token.Literal.String.Regex: '', Token.Literal.String.Single: '', Token.Literal.String.Symbol: '', Token.Generic: '', Token.Generic.Deleted: '#f92672', Token.Generic.Emph: 'italic', Token.Generic.Error: '', Token.Generic.Heading: '', Token.Generic.Inserted: '#a6e22e', Token.Generic.Output: '#66d9ef', Token.Generic.Prompt: 'bold #f92672', Token.Generic.Strong: 'bold', Token.Generic.Subheading: '#75715e', Token.Generic.Traceback: '', Token.Text: '', Token.Escape: '', Token.Name.Function.Magic: '', Token.Name.Variable.Magic: '', Token.Literal.String.Affix: '', Token.Literal.String.Delimiter: '', Token.Literal.Number.Bin: '', Token.Punctuation.Marker: '', Token.Comment.Hashbang: '', Token.Comment.PreprocFile: ''}
>>> {k:v for k, v in mo.styles.items() if v}
{Token: '#f8f8f2', Token.Error: '#960050 bg:#1e0010', Token.Comment: '#75715e', Token.Keyword: '#66d9ef', Token.Keyword.Namespace: '#f92672', Token.Operator: '#f92672', Token.Punctuation: '#f8f8f2', Token.Name: '#f8f8f2', Token.Name.Attribute: '#a6e22e', Token.Name.Class: '#a6e22e', Token.Name.Constant: '#66d9ef', Token.Name.Decorator: '#a6e22e', Token.Name.Exception: '#a6e22e', Token.Name.Function: '#a6e22e', Token.Name.Other: '#a6e22e', Token.Name.Tag: '#f92672', Token.Literal.Number: '#ae81ff', Token.Literal: '#ae81ff', Token.Literal.Date: '#e6db74', Token.Literal.String: '#e6db74', Token.Literal.String.Escape: '#ae81ff', Token.Generic.Deleted: '#f92672', Token.Generic.Emph: 'italic', Token.Generic.Inserted: '#a6e22e', Token.Generic.Output: '#66d9ef', Token.Generic.Prompt: 'bold #f92672', Token.Generic.Strong: 'bold', Token.Generic.Subheading: '#75715e'}
>>> gh = get_style_by_name('github-dark')
>>> gh.styles
{Token: '#e6edf3', Token.Error: '#f85149', Token.Keyword: '#ff7b72', Token.Keyword.Constant: '#79c0ff', Token.Keyword.Pseudo: '#79c0ff', Token.Name: '#e6edf3', Token.Name.Class: 'bold #f0883e', Token.Name.Constant: 'bold #79c0ff', Token.Name.Decorator: 'bold #d2a8ff', Token.Name.Entity: '#ffa657', Token.Name.Exception: 'bold #f0883e', Token.Name.Function: 'bold #d2a8ff', Token.Name.Label: 'bold #79c0ff', Token.Name.Namespace: '#ff7b72', Token.Name.Property: '#79c0ff', Token.Name.Tag: '#7ee787', Token.Name.Variable: '#79c0ff', Token.Literal: '#a5d6ff', Token.Literal.Date: '#79c0ff', Token.Literal.String: '#a5d6ff', Token.Literal.String.Affix: '#79c0ff', Token.Literal.String.Delimiter: '#79c0ff', Token.Literal.String.Escape: '#79c0ff', Token.Literal.String.Heredoc: '#79c0ff', Token.Literal.String.Regex: '#79c0ff', Token.Literal.Number: '#a5d6ff', Token.Comment: 'italic #8b949e', Token.Comment.Preproc: 'bold #8b949e', Token.Comment.Special: 'bold italic #8b949e', Token.Operator: 'bold #ff7b72', Token.Generic: '#e6edf3', Token.Generic.Deleted: 'bg:#490202 #ffa198', Token.Generic.Emph: 'italic', Token.Generic.Error: '#ffa198', Token.Generic.Heading: 'bold #79c0ff', Token.Generic.Inserted: 'bg:#0f5323 #56d364', Token.Generic.Output: '#8b949e', Token.Generic.Prompt: '#8b949e', Token.Generic.Strong: 'bold', Token.Generic.Subheading: '#79c0ff', Token.Generic.Traceback: '#ff7b72', Token.Generic.Underline: 'underline', Token.Text.Whitespace: '#6e7681', Token.Text: '', Token.Escape: '', Token.Other: '', Token.Keyword.Declaration: '', Token.Keyword.Namespace: '', Token.Keyword.Reserved: '', Token.Keyword.Type: '', Token.Name.Attribute: '', Token.Name.Builtin: '', Token.Name.Builtin.Pseudo: '', Token.Name.Function.Magic: '', Token.Name.Other: '', Token.Name.Variable.Class: '', Token.Name.Variable.Global: '', Token.Name.Variable.Instance: '', Token.Name.Variable.Magic: '', Token.Literal.String.Backtick: '', Token.Literal.String.Char: '', Token.Literal.String.Doc: '', Token.Literal.String.Double: '', Token.Literal.String.Interpol: '', Token.Literal.String.Other: '', Token.Literal.String.Single: '', Token.Literal.String.Symbol: '', Token.Literal.Number.Bin: '', Token.Literal.Number.Float: '', Token.Literal.Number.Hex: '', Token.Literal.Number.Integer: '', Token.Literal.Number.Integer.Long: '', Token.Literal.Number.Oct: '', Token.Operator.Word: '', Token.Punctuation: '', Token.Punctuation.Marker: '', Token.Comment.Hashbang: '', Token.Comment.Multiline: '', Token.Comment.PreprocFile: '', Token.Comment.Single: ''}

@tconbeer
Copy link
Owner Author

tconbeer commented Aug 22, 2023

The keys of the styles dict are the Token class and its members:

from pygments.token import Token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant