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

Added Color-Scheme Feature #23

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

vishal2612200
Copy link

@vishal2612200 vishal2612200 commented Apr 6, 2020

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

@NilsIrl
Copy link

NilsIrl commented Apr 9, 2020

#3

@@ -0,0 +1,47 @@
from pygments.style import Style
Copy link
Collaborator

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
Copy link
Collaborator

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')
Copy link
Collaborator

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):
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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'
Copy link
Collaborator

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):
Copy link
Collaborator

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'
Copy link
Collaborator

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])
Copy link
Collaborator

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.

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

Successfully merging this pull request may close these issues.

Add support for custom color themes
3 participants