X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <Pablogsal@gmail.com>
  • Loading branch information
pablogsal authored and miss-islington committed Aug 25, 2024
commit b9f2e1ad3006dca5fee0d9697410dff3713502a8
8 changes: 8 additions & 0 deletions Lib/_pyrepl/unix_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import struct
import termios
import time
import platform
from fcntl import ioctl

from . import curses
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deactivate line wrap in the Apple Terminal via a ANSI escape code. Patch by
Pablo Galindo
X Tutup