aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/_pyrepl/unix_console.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2024-05-07 13:54:56 +0100
committerGitHub <noreply@github.com>2024-05-07 12:54:56 +0000
commit7d90b8aadbd6993ee50a73b7536f769334718423 (patch)
treec52e6f2f5f03a3e2a6b4f57a5b2a0e321c72000a /Lib/_pyrepl/unix_console.py
parentad3d877a126bc892d1c598cf1357a2c39fd466c7 (diff)
downloadcpython-7d90b8aadbd6993ee50a73b7536f769334718423.tar.gz
cpython-7d90b8aadbd6993ee50a73b7536f769334718423.zip
gh-111201: Allow bracketed paste to work (GH-118700)
Diffstat (limited to 'Lib/_pyrepl/unix_console.py')
-rw-r--r--Lib/_pyrepl/unix_console.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py
index c22b1d5b5bc..605318c82ae 100644
--- a/Lib/_pyrepl/unix_console.py
+++ b/Lib/_pyrepl/unix_console.py
@@ -336,10 +336,13 @@ class UnixConsole(Console):
except ValueError:
pass
+ self.__enable_bracketed_paste()
+
def restore(self):
"""
Restore the console to the default state
"""
+ self.__disable_bracketed_paste()
self.__maybe_write_code(self._rmkx)
self.flushoutput()
tcsetattr(self.input_fd, termios.TCSADRAIN, self.__svtermstate)
@@ -525,6 +528,12 @@ class UnixConsole(Console):
self.__posxy = 0, 0
self.screen = []
+ def __enable_bracketed_paste(self) -> None:
+ os.write(self.output_fd, b"\x1b[?2004h")
+
+ def __disable_bracketed_paste(self) -> None:
+ os.write(self.output_fd, b"\x1b[?2004l")
+
def __setup_movement(self):
"""
Set up the movement functions based on the terminal capabilities.