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

Support colorscheme with only basic ANSI color sequences #63

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

Conversation

presidento
Copy link

Many terminals allow to customize the appearance. The basic colors can be overridden, but the ANSI 256 colors not.

For example, there can be solarized, light, and dark themes for the terminal having the basic colors fine-tuned for it.

(I also have to switch frequently between light and dark mode, based on the environment lightning.)

Mate Farkas added 4 commits August 31, 2023 12:47
In many terminals they can be stylized, so
it can be used for solarized, dark and light
terminal settings, as well.
@cknd
Copy link
Owner

cknd commented Nov 24, 2023

Hi, sorry for the long delay and thank you for the contribution! Sounds like a great solution to the colorscheme selection problem. I also like the idea of moving more of the logic into the colorscheme objects themselves

When I checked out your branch and ran demo.py with any of the old colorschemes (like darkbg), I got an error:

  File "/home/cknd/private/stackprinter/stackprinter/frame_formatting.py", line 129, in __call__
    return self._format_frame(finfo)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cknd/private/stackprinter/stackprinter/frame_formatting.py", line 294, in _format_frame
    colormap = self._pick_colors(source_map, fi.name2lines, assignments, fi.lineno)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cknd/private/stackprinter/stackprinter/frame_formatting.py", line 360, in _pick_colors
    colormap[name] = self._pick_color(name, value, highlight)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cknd/private/stackprinter/stackprinter/frame_formatting.py", line 375, in _pick_color
    return self.colors.get_random(seed, highlight)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cknd/private/stackprinter/stackprinter/colorschemes.py", line 67, in get_random
    self.rng.seed(seed)
    ^^^^^^^^
AttributeError: 'darkbg' object has no attribute 'rng'

@presidento
Copy link
Author

Thanks, I fixed that.

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.

2 participants