-
-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for copying raw message. #1470
base: main
Are you sure you want to change the base?
Conversation
6e5d8e5
to
a6c7240
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zulipterminal/ui_tools/views.py
Outdated
@@ -1939,14 +1939,21 @@ def __init__( | |||
|
|||
# Get rendered message header and footer | |||
msg_box = MessageBox(message, controller.model, None) | |||
msg_box.footer = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the existing behavior, since the footer stores footlinks and reactions in message boxes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I noticed that but it's still a widget_list that is being returned and since originally footer was an empty list in the FullRawMsgView
so the earlier assertion passes so didn't need to change anything in test_init
.
Adding two new assertions now to check if the widget_list element is urwid.Text and to check if the text is what it's supposed to be.
zulipterminal/ui_tools/views.py
Outdated
msg_box.footer = [ | ||
( | ||
urwid.Text( | ||
("msg_bold", "\nPress [c] to copy message to clipboard"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For specific keys, we always want to avoid hard-coding the key in the text, and rather lookup the key name via it's symbolic name: COPY_MESSAGE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that makes more sense! Making that change.
tests/ui_tools/test_popups.py
Outdated
"key", | ||
{ | ||
*keys_for_command("COPY_MESSAGE"), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this fits on one line? It's probably only the extra comma(s) that's forcing black to spread it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Changed.
zulipterminal/ui_tools/views.py
Outdated
msg_box.footer = [ | ||
( | ||
urwid.Text( | ||
("msg_bold", "\nPress [c] to copy message to clipboard"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure of the wording here, but including content
in the text seems useful, particularly if we keep the footer and header as they are in main
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How's "Press [c] to copy raw message content to clipboard" ?
zulipterminal/ui_tools/views.py
Outdated
response = controller.model.fetch_raw_message_content(message["id"]) | ||
|
||
if response is None: | ||
self.response = controller.model.fetch_raw_message_content(message["id"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're using this more widely now, it would be useful to give it a name which is clearer - so that we don't have to return here to look up what it means. That seems to be what you do when you use it on line ~1978?
You could also consider this change to be a refactor prep commit, since you've not updated test_init
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean changing the variable name to something like self.raw_message_content
?
I'll create a different refactor PR changing the variable name and then rebase this one.
docs/hotkeys.md
Outdated
@@ -64,6 +64,7 @@ | |||
|View current message in browser (from message information)|<kbd>v</kbd>| | |||
|Show/hide full rendered message (from message information)|<kbd>f</kbd>| | |||
|Show/hide full raw message (from message information)|<kbd>r</kbd>| | |||
|Copy message content to clipboard|<kbd>c</kbd>| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't have any (from ...)
suffix like the others, which could imply that it works just when a message is selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed that text. Adding (from message information)
. Or should I add something like (from raw message view)
? Although it might be confusing for new users since they might not know where raw message view is.
Using c as the key to copy messages to clipboard. Adding c to be excluded since c is already being used in same group.
a6c7240
to
c969c1e
Compare
Adding a feature to copy the text you see in the raw msg popup. Added hint text in the popup. Updated tests for the same.
c969c1e
to
17a008d
Compare
What does this PR do, and why?
Adding a key to copy raw message content since manually copying text in a terminal is pretty difficult due to the bars on the sides. Implemented using preexisting
copy_to_clipboard
function.External discussion & connections
topic
How did you test this?
Self-review checklist for each commit
Visual changes