Skip to content

Commit 0442344

Browse files
committed
Write terminal control codes to stdout instead of stderr.
1 parent d6407ba commit 0442344

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

cmd2/cmd2.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5626,11 +5626,9 @@ def async_alert(self, alert_msg: str, new_prompt: str | None = None) -> None: #
56265626
cursor_offset=rl_get_point(),
56275627
alert_msg=alert_msg,
56285628
)
5629-
if rl_type == RlType.GNU:
5630-
sys.stderr.write(terminal_str)
5631-
sys.stderr.flush()
5632-
elif rl_type == RlType.PYREADLINE:
5633-
readline.rl.mode.console.write(terminal_str)
5629+
5630+
sys.stdout.write(terminal_str)
5631+
sys.stdout.flush()
56345632

56355633
# Redraw the prompt and input lines below the alert
56365634
rl_force_redisplay()
@@ -5688,9 +5686,6 @@ def need_prompt_refresh(self) -> bool: # pragma: no cover
56885686
def set_window_title(title: str) -> None: # pragma: no cover
56895687
"""Set the terminal window title.
56905688
5691-
NOTE: This function writes to stderr. Therefore, if you call this during a command run by a pyscript,
5692-
the string which updates the title will appear in that command's CommandResult.stderr data.
5693-
56945689
:param title: the new window title
56955690
"""
56965691
if not vt100_support:
@@ -5699,8 +5694,8 @@ def set_window_title(title: str) -> None: # pragma: no cover
56995694
from .terminal_utils import set_title_str
57005695

57015696
try:
5702-
sys.stderr.write(set_title_str(title))
5703-
sys.stderr.flush()
5697+
sys.stdout.write(set_title_str(title))
5698+
sys.stdout.flush()
57045699
except AttributeError:
57055700
# Debugging in Pycharm has issues with setting terminal title
57065701
pass

0 commit comments

Comments
 (0)