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

Issue with colors on Windows since IPython 5 #10238

Closed
segevfiner opened this issue Feb 3, 2017 · 1 comment
Closed

Issue with colors on Windows since IPython 5 #10238

segevfiner opened this issue Feb 3, 2017 · 1 comment
Milestone

Comments

@segevfiner
Copy link
Contributor

@segevfiner segevfiner commented Feb 3, 2017

I'm having some issues with colors in IPython 5 on Windows that I'm currently working around using configuration.

Prompt Numbers

The prompt numbers are not using a bright color like they used to in IPython versions before 5. They use the same color as the In/Out text, I'm currently using this to override this: (Copied and modified from IPython/terminal/interactiveshell.py:275-286

c.TerminalInteractiveShell.highlighting_style_overrides = {
    Token.Number: '#007700',
    Token.Operator: 'noinherit',
    Token.String: '#BB6622',
    Token.Name.Function: '#2080D0',
    Token.Name.Class: 'bold #2080D0',
    Token.Name.Namespace: 'bold #2080D0',
    Token.Prompt: '#ansidarkgreen',
    Token.PromptNum: '#ansigreen bold',
    Token.OutPrompt: '#ansidarkred',
    Token.OutPromptNum: '#ansired bold',
}

Before

ipython5-prompt-before

After

ipython5-prompt-after

Tracebacks highlighting

The highlighting used for tracebacks is weird, the code is highlighted like it used to before IPython 5 (I guess it's because of this: 7b7d560), But the text that decorates the traceback is using dark colors that are a bit hard on the eyes. I'm using this to override this:

c.InteractiveShell.colors = 'Linux'  # Use Linux colors instead of Neutral
c.TerminalInteractiveShell.highlighting_style = 'default'  # Use default instead of monokai

The traceback coloring is defined here: IPython/core/excolors.py

Before

ipython5-tb-before

After

ipython5-tb-after

Live highlighting is different from tracebacks

(Not Windows related, but I want to mention this since it appears in the screenshots)
The highlighting used for code in prompts is different from the one used in tracebacks (It's even a different library 😛 ), but I think this bit is known already. It shouldn't be too difficult to create a Pygments style which would make them the same but I haven't bothered with this.

System Info

{'commit_hash': u'be4827b',
 'commit_source': 'installation',
 'default_encoding': 'cp862',
 'ipython_path': 'C:\\Python27\\lib\\site-packages\\IPython',
 'ipython_version': '5.2.1',
 'os_name': 'nt',
 'platform': 'Windows-10-10.0.14393',
 'sys_executable': 'C:\\Python27\\python.exe',
 'sys_platform': 'win32',
 'sys_version': '2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)]'}

prompt-toolkit 1.0.13

@Carreau
Copy link
Member

@Carreau Carreau commented Feb 7, 2017

Yes we are kinda aware of this.
This is because there are a slow effort to highlight things using Pygments. Unfortunately:
Old version of pygments do not really support short escape sequences that map your terminal setting.
And even if Pygments support it, most coloring themes do not use these short escape sequences.

The problem is in these case we can't get the "Correct" color as it depends on the system

colors

Marking as "wishlist" as it requires a lot of refactoring to be able to get short escape sequences everywhere.

@Carreau Carreau added this to the wishlist milestone Feb 7, 2017
segevfiner added a commit to segevfiner/ipython that referenced this issue Feb 8, 2017
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
segevfiner added a commit to segevfiner/ipython that referenced this issue Feb 8, 2017
If this fix is acceptable it would be nice if this is backported to
IPython 5 as this is very visible. Every user I see using IPython on
Windows sees this and most don't seem to understand that they can change
it. And on top of that this is especially annoying when using IPython on
a computer you don't own or a VM. Having to reconfigure on each one...

Fixes: ipython#10238
segevfiner added a commit to segevfiner/ipython that referenced this issue Feb 8, 2017
@minrk minrk modified the milestones: 6.0, wishlist May 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.