Skip to content

Commit e37b7f1

Browse files
[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 fdb3f9b) Co-authored-by: Pablo Galindo Salgado <[email protected]>
1 parent bbed982 commit e37b7f1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Lib/_pyrepl/unix_console.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import struct
3030
import termios
3131
import time
32+
import platform
3233
from fcntl import ioctl
3334

3435
from . import curses
@@ -334,6 +335,10 @@ def prepare(self):
334335
raw.cc[termios.VTIME] = 0
335336
tcsetattr(self.input_fd, termios.TCSADRAIN, raw)
336337

338+
# In macOS terminal we need to deactivate line wrap via ANSI escape code
339+
if platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal":
340+
os.write(self.output_fd, b"\033[?7l")
341+
337342
self.screen = []
338343
self.height, self.width = self.getheightwidth()
339344

@@ -362,6 +367,9 @@ def restore(self):
362367
self.flushoutput()
363368
tcsetattr(self.input_fd, termios.TCSADRAIN, self.__svtermstate)
364369

370+
if platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal":
371+
os.write(self.output_fd, b"\033[?7h")
372+
365373
if hasattr(self, "old_sigwinch"):
366374
signal.signal(signal.SIGWINCH, self.old_sigwinch)
367375
del self.old_sigwinch
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deactivate line wrap in the Apple Terminal via a ANSI escape code. Patch by
2+
Pablo Galindo

0 commit comments

Comments
 (0)