-
-
Notifications
You must be signed in to change notification settings - Fork 279
views/keys/hotkeys: Add key to copy message content #1365
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
base: main
Are you sure you want to change the base?
Conversation
Adding a key to copy message content which can be then pasted. Implemented using preexisting `copy_to_clipboard` function Fixes zulip#546
@zulipbot add "PR needs review" |
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.
@Sushmey We've discussed this in the stream but I wanted to just read over what you'd done so far - though I understand the approach may change, things look fairly reasonable except for the extraction of the content 👍
elif is_command_key("COPY_MESSAGE", key): | ||
rendered_content, *_ = MessageBox.transform_content( | ||
self.msg["content"], self.controller.model.server_url | ||
) | ||
content = [] | ||
for word in rendered_content[1]: | ||
if isinstance(word, tuple): # if msg content has markup | ||
content.append(word[1]) | ||
else: | ||
content.append(word) | ||
self.controller.copy_to_clipboard("".join(content), "Message Content") |
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.
The principle here is just fine, but we do perform a few extra adjustments to content which may not follow the principles that you assume here.
That's likely what gave rise to the crash I reported in the stream.
('COPY_MESSAGE', { | ||
'keys': ['C'], | ||
'help_text': | ||
'Copy message content to clipboard', | ||
'key_category': 'msg_actions', |
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.
We've discussed this in the stream, but
c
should not need capitalization, with some adjustment, if we stick with that hotkey, though key choice right now is not important- though note that we already have
c
for copying stream email address - plus we discussed something similar for the copy non-markdown content version
- though note that we already have
- the help_text likely doesn't need to wrap? That's only been done for long lines
- we may want the COPY_MESSAGE to be more meaningful if we have two versions :)
Heads up @Sushmey, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
What does this PR do, and why?
Copying a message using terminal selection does not work across multiple lines, as it also selects text in one or both of the side bars.
It would be useful to be able to copy selected message(s) independently of how the UI is set up.
This could be for quoting in another stream, or external to ZT.
Adding a key to copy message content which can be then pasted. Implemented using preexisting
copy_to_clipboard
function.Outstanding aspect(s)
This seems to not work for quotes messages because of the nested list
Unsure as to how to navigate about specific cases like
External discussion & connections
topic
How did you test this?
Self-review checklist for each commit
Visual changes