Support colorscheme with only basic ANSI color sequences
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.)
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'
Thanks, I fixed that.