]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-123177: Deactivate line wrap for Apple Terminal via scape codes in the new REPL...
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Sun, 25 Aug 2024 21:38:49 +0000 (22:38 +0100)
committerGitHub <noreply@github.com>
Sun, 25 Aug 2024 21:38:49 +0000 (22:38 +0100)
Lib/_pyrepl/unix_console.py
Misc/NEWS.d/next/Core and Builtins/2024-08-23-15-59-54.gh-issue-123177.OLcaC5.rst [new file with mode: 0644]

index 7b8f5a0298b75f573fe5c5505eedcf0372c78b4e..2f15037129773a1328494519524f44bf091c294a 100644 (file)
@@ -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
diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-08-23-15-59-54.gh-issue-123177.OLcaC5.rst b/Misc/NEWS.d/next/Core and Builtins/2024-08-23-15-59-54.gh-issue-123177.OLcaC5.rst
new file mode 100644 (file)
index 0000000..da688ef
--- /dev/null
@@ -0,0 +1,2 @@
+Deactivate line wrap in the Apple Terminal via a ANSI escape code. Patch by
+Pablo Galindo