https://github.com/python/cpython/commit/e37b7f1a9c950a6e0c09474663726794ca9e4bc5
commit: e37b7f1a9c950a6e0c09474663726794ca9e4bc5
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: pablogsal <[email protected]>
date: 2024-08-25T22:01:56Z
summary:

[3.13] gh-123177: Deactivate line wrap for Apple Terminal via scape codes in 
the new REPL (GH-123267) (#123322)

gh-123177: Deactivate line wrap for Apple Terminal via scape codes in the new 
REPL (GH-123267)
(cherry picked from commit fdb3f9b588f58f3cf95fe1dbf6e5b61ef525a351)

Co-authored-by: Pablo Galindo Salgado <[email protected]>

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-08-23-15-59-54.gh-issue-123177.OLcaC5.rst
M Lib/_pyrepl/unix_console.py

diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py
index 18b2bba91c8c9b..bdea28527c8c62 100644
--- a/Lib/_pyrepl/unix_console.py
+++ b/Lib/_pyrepl/unix_console.py
@@ -29,6 +29,7 @@
 import struct
 import termios
 import time
+import platform
 from fcntl import ioctl
 
 from . import curses
@@ -334,6 +335,10 @@ def prepare(self):
         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 @@ def restore(self):
         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
index 00000000000000..da688effca3712
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and 
Builtins/2024-08-23-15-59-54.gh-issue-123177.OLcaC5.rst 
@@ -0,0 +1,2 @@
+Deactivate line wrap in the Apple Terminal via a ANSI escape code. Patch by
+Pablo Galindo

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to