Skip to content

Commit

Permalink
Fix the rest of the colors used on Windows so they are more visible
Browse files Browse the repository at this point in the history
This applies a hack similar to the one in
7b7d560 to change the prompt colors
and exception colors so they are more visible as shown in issue ipython#10238

Fixes: ipython#10238
  • Loading branch information
segevfiner committed Feb 8, 2017
1 parent b8cfbfe commit baeb642
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions IPython/core/excolors.py
Expand Up @@ -3,6 +3,7 @@
Color schemes for exception handling code in IPython.
"""

import os
import warnings

#*****************************************************************************
Expand Down Expand Up @@ -155,6 +156,12 @@ def exception_colors():
Normal = C.Normal,
))

# Hack: the 'neutral' colours are not very visible on a dark background on
# Windows. Since Windows command prompts have a dark background by default, and
# relatively few users are likely to alter that, we will use the 'Linux' colours,
# designed for a dark background, as the default on Windows.
if os.name == "nt":
ex_colors.add_scheme(ex_colors['Linux'].copy('Neutral'))

return ex_colors

Expand Down
10 changes: 10 additions & 0 deletions IPython/terminal/interactiveshell.py
Expand Up @@ -286,6 +286,16 @@ def _make_style_from_name_or_cls(self, name_or_cls):
Token.OutPrompt: '#990000',
Token.OutPromptNum: '#ff0000 bold',
})

# Hack: Due to limited color support on the Windows console
# the prompt colors will be wrong without this
if os.name == 'nt':
style_overrides.update({
Token.Prompt: '#ansidarkgreen',
Token.PromptNum: '#ansigreen bold',
Token.OutPrompt: '#ansidarkred',
Token.OutPromptNum: '#ansired bold',
})
elif legacy =='nocolor':
style_cls=_NoStyle
style_overrides = {}
Expand Down

0 comments on commit baeb642

Please sign in to comment.