DRYer
This commit is contained in:
parent
f62acab715
commit
03f9f29ce4
2 changed files with 13 additions and 11 deletions
|
|
@ -301,6 +301,16 @@ def remove_both(line: str) -> str:
|
|||
return remove_wrap_markers
|
||||
|
||||
|
||||
def cmd_output(screen: Screen, which: CommandOutput = CommandOutput.last_run, as_ansi: bool = False, add_wrap_markers: bool = False) -> str:
|
||||
lines: List[str] = []
|
||||
search_in_pager_hist = screen.cmd_output(which, lines.append, as_ansi, add_wrap_markers)
|
||||
if search_in_pager_hist:
|
||||
pht = pagerhist(screen, as_ansi, add_wrap_markers, True)
|
||||
if pht:
|
||||
lines.insert(0, pht)
|
||||
return ''.join(lines)
|
||||
|
||||
|
||||
def process_remote_print(msg: bytes) -> str:
|
||||
from base64 import standard_b64decode
|
||||
from .cli import green
|
||||
|
|
@ -1069,13 +1079,7 @@ def as_text(
|
|||
return as_text(self.screen, as_ansi, add_history, add_wrap_markers, alternate_screen, add_cursor)
|
||||
|
||||
def cmd_output(self, which: CommandOutput = CommandOutput.last_run, as_ansi: bool = False, add_wrap_markers: bool = False) -> str:
|
||||
lines: List[str] = []
|
||||
search_in_pager_hist = self.screen.cmd_output(which, lines.append, as_ansi, add_wrap_markers)
|
||||
if search_in_pager_hist:
|
||||
pht = pagerhist(self.screen, as_ansi, add_wrap_markers, True)
|
||||
if pht:
|
||||
lines.insert(0, pht)
|
||||
return ''.join(lines)
|
||||
return cmd_output(self.screen, which, as_ansi, add_wrap_markers)
|
||||
|
||||
@property
|
||||
def cwd_of_child(self) -> Optional[str]:
|
||||
|
|
|
|||
|
|
@ -240,7 +240,5 @@ def screen_contents(self):
|
|||
return '\n'.join(lines)
|
||||
|
||||
def last_cmd_output(self, as_ansi=False, add_wrap_markers=False):
|
||||
lines = []
|
||||
from kitty.window import CommandOutput
|
||||
self.screen.cmd_output(CommandOutput.last_run, lines.append, as_ansi, add_wrap_markers)
|
||||
return ''.join(lines)
|
||||
from kitty.window import cmd_output
|
||||
return cmd_output(self.screen, as_ansi=as_ansi, add_wrap_markers=add_wrap_markers)
|
||||
|
|
|
|||
Loading…
Reference in a new issue