Skip to content

Commit 2031dc0

Browse files
authored
Merge pull request #1550 from dbcli/RW/support-truecolor-prompt-toolkit
Support Truecolor in prompt_toolkit sessions
2 parents 0c6288f + 7bdc71b commit 2031dc0

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Features
99
* Optionally defer auto-completions until a minimum number of characters is typed.
1010
* Make the completion interface more responsive using a background thread.
1111
* Option to suppress control-d exit behavior.
12+
* Better support Truecolor terminals.
1213

1314

1415
Bug Fixes

mycli/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from prompt_toolkit.key_binding.key_processor import KeyPressEvent
4343
from prompt_toolkit.layout.processors import ConditionalProcessor, HighlightMatchingBracketProcessor
4444
from prompt_toolkit.lexers import PygmentsLexer
45+
from prompt_toolkit.output import ColorDepth
4546
from prompt_toolkit.shortcuts import CompleteStyle, PromptSession
4647
import pymysql
4748
from pymysql.constants.ER import HANDSHAKE_ERROR
@@ -1168,6 +1169,7 @@ def one_iteration(text: str | None = None) -> None:
11681169
editing_mode = EditingMode.EMACS
11691170

11701171
self.prompt_app = PromptSession(
1172+
color_depth=ColorDepth.DEPTH_24_BIT if 'truecolor' in os.getenv('COLORTERM', '').lower() else None,
11711173
lexer=PygmentsLexer(MyCliLexer),
11721174
reserve_space_for_menu=self.get_reserved_space(),
11731175
message=get_message,

0 commit comments

Comments
 (0)