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

Add option to use 24bit color in prompt toolkit #9736

Merged
merged 2 commits into from Jul 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions IPython/terminal/interactiveshell.py
Expand Up @@ -14,7 +14,7 @@
from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
from prompt_toolkit.filters import (HasFocus, Condition, IsDone)
from prompt_toolkit.history import InMemoryHistory
from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_prompt_layout
from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_prompt_layout, create_output
from prompt_toolkit.interface import CommandLineInterface
from prompt_toolkit.key_binding.manager import KeyBindingManager
from prompt_toolkit.layout.processors import ConditionalProcessor, HighlightMatchingBracketProcessor
Expand Down Expand Up @@ -142,6 +142,13 @@ def refresh_style(self):
help="Override highlighting format for specific tokens"
).tag(config=True)

true_color = Bool(False,
help=("Use 24bit colors instead of 256 colors in prompt highlighting. "
"If your terminal supports true color, the following command "
"should print 'TRUECOLOR' in orange: "
"printf \"\\x1b[38;2;255;100;0mTRUECOLOR\\x1b[0m\\n\"")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be print(...) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's a bash command :-)

On Tue, Jul 12, 2016 at 9:10 AM, Doug Blank notifications@github.com
wrote:

In IPython/terminal/interactiveshell.py
#9736 (comment):

@@ -142,6 +142,13 @@ def refresh_style(self):
help="Override highlighting format for specific tokens"
).tag(config=True)

  • true_color = Bool(False,
  •    help=("Use 24bit colors instead of 256 colors in prompt highlighting. "
    
  •          "If your terminal supports true color, the following command "
    
  •          "should print 'TRUECOLOR' in orange: "
    
  •          "printf \"\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n\"")
    

Should that be print(...) ?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/ipython/ipython/pull/9736/files/7304bca3a12c141bba350addd435ec9d3d0e607e#r70445461,
or mute the thread
https://github.com/notifications/unsubscribe/AAUez8m342vTnu_N6Oai946CMJID10wuks5qU6BGgaJpZM4JJ5SV
.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Thanks!

).tag(config=True)

editor = Unicode(get_default_editor(),
help="Set the editor used by IPython (default to $EDITOR/vi/notepad)."
).tag(config=True)
Expand Down Expand Up @@ -235,7 +242,9 @@ def prompt():
**self._layout_options()
)
self._eventloop = create_eventloop(self.inputhook)
self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self._eventloop)
self.pt_cli = CommandLineInterface(
self._pt_app, eventloop=self._eventloop,
output=create_output(true_color=self.true_color))

def _make_style_from_name(self, name):
"""
Expand Down
9 changes: 9 additions & 0 deletions docs/source/whatsnew/pr/truecolor-feature.rst
@@ -0,0 +1,9 @@
prompt_toolkit uses pygments styles for syntax highlighting. By default, the
colors specified in the style are approximated using a standard 256-color
palette. prompt_toolkit also supports 24bit, a.k.a. "true", a.k.a. 16-million
color escape sequences which enable compatible terminals to display the exact
colors specified instead of an approximation. This true_color option exposes
that capability in prompt_toolkit to the IPython shell.

Here is a good source for the current state of true color support in various
terminal emulators and software projects: https://gist.github.com/XVilka/8346728