macOS: When using Apple's less as the pager for viewing scrollback strip out OSC codes as Apple's less cant parse them
Fixes #4788
This commit is contained in:
parent
795953a341
commit
95c4e26b24
@ -75,6 +75,10 @@ command.
|
||||
Detailed list of changes
|
||||
-------------------------------------
|
||||
|
||||
0.25.0 [future]
|
||||
|
||||
- macOS: When using Apple's less as the pager for viewing scrollback strip out OSC codes as Apple's less cant parse them (:iss:`4788`)
|
||||
|
||||
0.24.4 [2022-03-03]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@ -1313,6 +1313,8 @@ class Boss:
|
||||
s.close()
|
||||
|
||||
def display_scrollback(self, window: Window, data: Union[bytes, str], input_line_number: int = 0, title: str = '', report_cursor: bool = True) -> None:
|
||||
import shutil
|
||||
|
||||
def prepare_arg(x: str) -> str:
|
||||
x = x.replace('INPUT_LINE_NUMBER', str(input_line_number))
|
||||
x = x.replace('CURSOR_LINE', str(window.screen.cursor.y + 1) if report_cursor else '0')
|
||||
@ -1328,6 +1330,10 @@ class Boss:
|
||||
tab = self.active_tab
|
||||
if tab is not None:
|
||||
bdata = data.encode('utf-8') if isinstance(data, str) else data
|
||||
if is_macos and shutil.which(cmd[0]) == '/usr/bin/less':
|
||||
# the system less on macOS barfs up OSC codes, so sanitize them ourselves
|
||||
bdata = re.sub(br'\x1b\].*?\x1b\\', b'', bdata)
|
||||
|
||||
tab.new_special_window(
|
||||
SpecialWindow(cmd, bdata, title or _('History'), overlay_for=window.id, cwd=window.cwd_of_child),
|
||||
copy_colors_from=self.active_window
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user