summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2024-08-25 21:38:49 (GMT)
committerGitHub <noreply@github.com>2024-08-25 21:38:49 (GMT)
commitfdb3f9b588f58f3cf95fe1dbf6e5b61ef525a351 (patch)
treee2e6636824b68f18d913c4e62af28ce9f6f5d95e /Lib/_pyrepl
parentc535a49e9260ad0fac022474f6381836051c9758 (diff)
downloadcpython-fdb3f9b588f58f3cf95fe1dbf6e5b61ef525a351.zip
cpython-fdb3f9b588f58f3cf95fe1dbf6e5b61ef525a351.tar.gz
cpython-fdb3f9b588f58f3cf95fe1dbf6e5b61ef525a351.tar.bz2
gh-123177: Deactivate line wrap for Apple Terminal via scape codes in the new REPL (#123267)
Diffstat (limited to 'Lib/_pyrepl')
-rw-r--r--Lib/_pyrepl/unix_console.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py
index 7b8f5a0..2f15037 100644
--- a/Lib/_pyrepl/unix_console.py
+++ b/Lib/_pyrepl/unix_console.py
@@ -29,6 +29,7 @@ import signal
import struct
import termios
import time
+import platform
from fcntl import ioctl
from . import curses
@@ -334,6 +335,10 @@ class UnixConsole(Console):
raw.cc[termios.VTIME] = 0
tcsetattr(self.input_fd, termios.TCSADRAIN, raw)
+ # In macOS terminal we need to deactivate line wrap via ANSI escape code
+ if platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal":
+ os.write(self.output_fd, b"\033[?7l")
+
self.screen = []
self.height, self.width = self.getheightwidth()
@@ -362,6 +367,9 @@ class UnixConsole(Console):
self.flushoutput()
tcsetattr(self.input_fd, termios.TCSADRAIN, self.__svtermstate)
+ if platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal":
+ os.write(self.output_fd, b"\033[?7h")
+
if hasattr(self, "old_sigwinch"):
signal.signal(signal.SIGWINCH, self.old_sigwinch)
del self.old_sigwinch