-
Notifications
You must be signed in to change notification settings - Fork 90
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
Added Color-Scheme Feature #23
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,47 @@ | |||
from pygments.style import Style |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these comments for?
|
||
""" | ||
|
||
from pygments.util import ClassNotFound |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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