Conversation
| @@ -0,0 +1,47 @@ | |||
| from pygments.style import Style | |||
There was a problem hiding this comment.
The assets directory is for static assets. There should not be any Python code in it.
| from pygments.token import ( | ||
| Comment, Error, Keyword, Literal, Name, Number, Operator, String, Text | ||
| ) | ||
| from vardbg.output.video_writer.getstyle import get_style_by_name |
There was a problem hiding this comment.
Don't use absolute imports unless required. It makes maintenance harder.
| ) | ||
| from vardbg.output.video_writer.getstyle import get_style_by_name | ||
|
|
||
| scheme = get_style_by_name('wood') |
There was a problem hiding this comment.
There is no need for a separate "default" file. That can be handled as a simple alias in get_style_by_name.
|
|
||
| scheme = get_style_by_name('wood') | ||
|
|
||
| class DefaultStyle(Style): |
There was a problem hiding this comment.
This should be built on-the-fly for any style, not statically defined here.
|
|
||
| styles = { | ||
| Text: scheme['base05'], | ||
| Error: scheme['base08'], # .err |
There was a problem hiding this comment.
What are these comments for?
|
|
||
| """ | ||
|
|
||
| from pygments.util import ClassNotFound |
There was a problem hiding this comment.
Avoid from imports unless necessary to write idiomatic code.
| from pygments.util import ClassNotFound | ||
|
|
||
|
|
||
| STYLE_ENTRY_POINT = 'vardbg.assets.styles' |
There was a problem hiding this comment.
No need for an absolute package path here.
| return pkg_resources.iter_entry_points(group_name) | ||
|
|
||
| def find_plugin_styles(): | ||
| for entrypoint in iter_entry_points(STYLE_ENTRY_POINT): |
There was a problem hiding this comment.
No need for runtime scheme discovery here. For something simple like this, it's fine to just import everything in __init__.py in styles.
|
|
||
| #: Maps style names to 'submodule::dictname'. | ||
| STYLE_MAP = { | ||
| 'wood': 'wood::scheme' |
There was a problem hiding this comment.
This shouldn't be hard-coded.
| print(mod) | ||
|
|
||
| try: | ||
| mod = __import__('vardbg.assets.styles.' + mod, None, None, [cls]) |
There was a problem hiding this comment.
No need to use an internal Python function here.
Feature
- Different color scheme option
- Dynamic color selection
Dynamic color selection is done by comparing the min distance between the base color and different color_scheme colors.
If body text and background color are the same, then contrast is calculated, to resolve this issue.
Fixes #3