Skip to content

Commit

Permalink
server: fix windows color depth detection (#1388)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjia56 committed Mar 21, 2024
1 parent 77c30b4 commit c8df32e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/python/plugin_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import prompt_toolkit.key_binding.key_processor
import prompt_toolkit.contrib.telnet.server
from prompt_toolkit.contrib.telnet.server import TelnetServer, TelnetConnection
from prompt_toolkit.output.color_depth import ColorDepth
from prompt_toolkit.shortcuts import clear_title, set_title
from ptpython.repl import embed, PythonRepl, _has_coroutine_flag
import ptpython.key_bindings
Expand All @@ -29,6 +30,10 @@
from rpc import maybe_await


# Our client is xtermjs, so no need to perform any color depth detection
ColorDepth.default = lambda *args, **kwargs: ColorDepth.DEPTH_4_BIT


# This section is a bit of a hack - prompt_toolkit has many assumptions
# that there is only one global Application, so multiple REPLs will confuse
# the library. The patches here allow us to scope a particular call stack
Expand Down Expand Up @@ -267,6 +272,7 @@ def handle_connection(conn: socket.socket):

# we're not in the main loop, so can't handle any signals anyways
repl_loop.add_signal_handler = lambda sig, cb: None
repl_loop.remove_signal_handler = lambda sig: True

def finish_setup():
telnet_port, exit_server = server_started_future.result()
Expand Down

0 comments on commit c8df32e

Please sign in to comment.