Skip to content

Commit 95df188

Browse files
rsashankneiljp
authored andcommitted
keys/views: Add ExceptionView class and COPY_TRACEBACK key.
Added ExceptionView class that allows users to copy traceback from the exception has occured popup with a newly introduced hotkey 'c' (COPY_TRACEBACK).
1 parent 7116761 commit 95df188

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

docs/hotkeys.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
|Show/hide Markdown Help Menu|<kbd>Meta</kbd> + <kbd>m</kbd>|
1010
|Show/hide About Menu|<kbd>Meta</kbd> + <kbd>?</kbd>|
1111
|Copy information from About Menu to clipboard|<kbd>c</kbd>|
12+
|Copy traceback from Exception Popup to clipboard|<kbd>c</kbd>|
1213
|Redraw screen|<kbd>Ctrl</kbd> + <kbd>l</kbd>|
1314
|Quit|<kbd>Ctrl</kbd> + <kbd>c</kbd>|
1415
|New footer hotkey hint|<kbd>Tab</kbd>|

tools/lint-hotkeys

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SCRIPT_NAME = PurePath(__file__).name
2323
HELP_TEXT_STYLE = re.compile(r"^[a-zA-Z /()',&@#:_-]*$")
2424

2525
# Exclude keys from duplicate keys checking
26-
KEYS_TO_EXCLUDE = ["q", "e", "m", "r", "Esc"]
26+
KEYS_TO_EXCLUDE = ["q", "e", "m", "r", "Esc", "c"]
2727

2828

2929
def main(fix: bool) -> None:

zulipterminal/config/keys.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class KeyBinding(TypedDict):
5656
'help_text': 'Copy information from About Menu to clipboard',
5757
'key_category': 'general',
5858
},
59+
'COPY_TRACEBACK': {
60+
'keys': ['c'],
61+
'help_text': 'Copy traceback from Exception Popup to clipboard',
62+
'excluded_from_random_tips': True,
63+
'key_category': 'general',
64+
},
5965
'EXIT_POPUP': {
6066
'keys': ['esc'],
6167
'help_text': 'Close popup',

zulipterminal/ui_tools/views.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,24 @@ def __init__(
10761076
super().__init__(controller, widgets, "EXIT_POPUP", width, title)
10771077

10781078

1079+
class ExceptionView(NoticeView):
1080+
def __init__(
1081+
self,
1082+
controller: Any,
1083+
notice_text: Any,
1084+
width: int,
1085+
title: str,
1086+
traceback: str,
1087+
) -> None:
1088+
self.traceback = traceback
1089+
super().__init__(controller, notice_text, width, title)
1090+
1091+
def keypress(self, size: urwid_Size, key: str) -> str:
1092+
if is_command_key("COPY_TRACEBACK", key):
1093+
self.controller.copy_to_clipboard(self.traceback, "Traceback")
1094+
return super().keypress(size, key)
1095+
1096+
10791097
class AboutView(PopUpView):
10801098
def __init__(
10811099
self,

0 commit comments

Comments
 (0)