mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-123177: Deactivate line wrap for Apple Terminal via scape codes in the new REPL (#123267)
This commit is contained in:
parent
c535a49e92
commit
fdb3f9b588
2 changed files with 10 additions and 0 deletions
|
@ -29,6 +29,7 @@ import signal
|
||||||
import struct
|
import struct
|
||||||
import termios
|
import termios
|
||||||
import time
|
import time
|
||||||
|
import platform
|
||||||
from fcntl import ioctl
|
from fcntl import ioctl
|
||||||
|
|
||||||
from . import curses
|
from . import curses
|
||||||
|
@ -334,6 +335,10 @@ class UnixConsole(Console):
|
||||||
raw.cc[termios.VTIME] = 0
|
raw.cc[termios.VTIME] = 0
|
||||||
tcsetattr(self.input_fd, termios.TCSADRAIN, raw)
|
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.screen = []
|
||||||
self.height, self.width = self.getheightwidth()
|
self.height, self.width = self.getheightwidth()
|
||||||
|
|
||||||
|
@ -362,6 +367,9 @@ class UnixConsole(Console):
|
||||||
self.flushoutput()
|
self.flushoutput()
|
||||||
tcsetattr(self.input_fd, termios.TCSADRAIN, self.__svtermstate)
|
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"):
|
if hasattr(self, "old_sigwinch"):
|
||||||
signal.signal(signal.SIGWINCH, self.old_sigwinch)
|
signal.signal(signal.SIGWINCH, self.old_sigwinch)
|
||||||
del self.old_sigwinch
|
del self.old_sigwinch
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Deactivate line wrap in the Apple Terminal via a ANSI escape code. Patch by
|
||||||
|
Pablo Galindo
|
Loading…
Add table
Add a link
Reference in a new issue