Skip to content

Commit a796b95

Browse files
committed
Massive colors and themeing refactor
This massively rewrite the color and theme handling. Instead of messing with colors internally, we try – as much as possible, to yield pairs of (token types, values) and feed that to a pygments formatter. I'm going to assume this is going to break stuff, hence why I want it early in the 9.0 release cycle.
1 parent 0935e2d commit a796b95

32 files changed

+1500
-1540
lines changed

IPython/core/alias.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def init_aliases(self):
212212
if (
213213
cmd.startswith("ls ")
214214
and self.shell is not None
215-
and self.shell.colors == "NoColor"
215+
and self.shell.colors == "nocolor"
216216
):
217217
cmd = cmd.replace(" --color", "")
218218
self.soft_define_alias(name, cmd)

IPython/core/completer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@
221221
from IPython.core.error import TryNext
222222
from IPython.core.inputtransformer2 import ESC_MAGIC
223223
from IPython.core.latex_symbols import latex_symbols, reverse_latex_symbol
224-
from IPython.core.oinspect import InspectColors
225224
from IPython.testing.skipdoctest import skip_doctest
226225
from IPython.utils import generics
226+
from IPython.utils.PyColorize import theme_table
227227
from IPython.utils.decorators import sphinx_options
228228
from IPython.utils.dir2 import dir2, get_real_method
229229
from IPython.utils.docs import GENERATING_DOCUMENTATION
@@ -2240,8 +2240,7 @@ def magic_color_matches(self, text: str) -> List[str]:
22402240

22412241
if len(texts) == 2 and (texts[0] == 'colors' or texts[0] == '%colors'):
22422242
prefix = texts[1]
2243-
return [ color for color in InspectColors.keys()
2244-
if color.startswith(prefix) ]
2243+
return [color for color in theme_table.keys() if color.startswith(prefix)]
22452244
return []
22462245

22472246
@context_matcher(identifier="IPCompleter.jedi_matcher")

IPython/core/crashhandler.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# encoding: utf-8
21
"""sys.excepthook for IPython itself, leaves a detailed report on disk.
32
43
Authors:
@@ -159,11 +158,8 @@ def __call__(
159158
# infinite loop.
160159
sys.excepthook = sys.__excepthook__
161160

162-
# Report tracebacks shouldn't use color in general (safer for users)
163-
color_scheme = 'NoColor'
164161

165162
# Use this ONLY for developer debugging (keep commented out for release)
166-
# color_scheme = 'Linux' # dbg
167163
ipython_dir = getattr(self.app, "ipython_dir", None)
168164
if ipython_dir is not None:
169165
assert isinstance(ipython_dir, str)
@@ -178,7 +174,7 @@ def __call__(
178174
self.crash_report_fname = str(report_name)
179175
self.info["crash_report_fname"] = str(report_name)
180176
TBhandler = ultratb.VerboseTB(
181-
color_scheme=color_scheme,
177+
theme_name="nocolor",
182178
long_header=True,
183179
call_pdb=self.call_pdb,
184180
)

0 commit comments

Comments
 (0)