Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
24-bit color support for IPython
Date: Sun, 10 Jul 2016 13:57:20 +0500
Subject: [PATCH] Add 24-bit color support option for TerminalInteractiveShell
---
IPython/terminal/interactiveshell.py | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py
index c31ce10..98e843c 100644
--- a/IPython/terminal/interactiveshell.py
+++ b/IPython/terminal/interactiveshell.py
@@ -14,7 +14,9 @@
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
@@ -146,6 +148,10 @@ def refresh_style(self):
help="Set the editor used by IPython (default to $EDITOR/vi/notepad)."
).tag(config=True)
+ true_color = Bool(False,
+ help="Enable 24-bit color support"
+ ).tag(config=True)
+
prompts_class = Type(Prompts, help='Class used to generate Prompt token for prompt_toolkit').tag(config=True)
prompts = Instance(Prompts)
@@ -235,7 +241,12 @@ 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):
"""
--
2.9.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.