Skip to content

Commit

Permalink
core/views: Add footer text with hotkey hint for copying traceback.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsashank committed Sep 29, 2024
1 parent 93cff1b commit a094cec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/ui_tools/test_popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ def test_stream_info_content__sections(self) -> None:
"stream_email_present, expected_copy_text",
[
(False, "< Stream email is unavailable >"),
(True, "Press 'c' to copy Stream email address"),
(True, "Press [c] to copy Stream email address"),
],
)
def test_stream_info_content__email_copy_text(
Expand Down
11 changes: 11 additions & 0 deletions zulipterminal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ def no_prompt_exit_handler(self, signum: int, frame: Any) -> None:
self.deregister_client()

def prompting_exit_handler(self, signum: int, frame: Any) -> None:
self.view.set_footer_text()
question = urwid.Text(
("bold", " Please confirm that you wish to exit Zulip-Terminal "),
"center",
Expand Down Expand Up @@ -721,6 +722,16 @@ def _raise_exception(self, *args: Any, **kwargs: Any) -> Literal[True]:
full_traceback = "".join(traceback.format_exception(*exc))
self.show_exception_popup(message, traceback=full_traceback, width=80)
self._exception_info = None

if full_traceback != "":
text = [
"An exception occurred: ",
"Press [c] to copy traceback to clipboard.",
]
else:
text = ["Press [Esc] to exit popup."]

self.view.set_footer_text(text, "task:error")
return True # If don't raise, retain pipe

def main(self) -> None:
Expand Down
2 changes: 2 additions & 0 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,8 @@ def __init__(
def keypress(self, size: urwid_Size, key: str) -> str:
if is_command_key("COPY_TRACEBACK", key):
self.controller.copy_to_clipboard(self.traceback, "Traceback")
if is_command_key("GO_BACK", key):
self.controller.view.set_footer_text()
return super().keypress(size, key)


Expand Down

0 comments on commit a094cec

Please sign in to comment.