Skip to content
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 copy and paste shortcuts to multiline mode #201

Merged
merged 1 commit into from Feb 1, 2024
Merged

add copy and paste shortcuts to multiline mode #201

merged 1 commit into from Feb 1, 2024

Conversation

guhitb
Copy link
Contributor

@guhitb guhitb commented Jan 28, 2024

Added copy and paste keybindings to multiline mode.

  • i - focus the textarea
  • y - copy last response to clipboard
  • p - paste clipboard to textarea

These keybindings are only proccessed while the textarea is unfocused.

It uses this library https://github.com/atotto/clipboard.

Using the shortcuts to copy and paste between tgpt windows:

tgptcopyfast.mp4

main.go Outdated
clip, err := clipboard.ReadAll()
msg.Runes = []rune(clip)
if err != nil {
panic("could not write to clipboard")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not read from clipboard*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if pasting works on your machine now? golang-design/clipboard says it only depends on X11, the previous library depended on xclip.

@aandrew-me
Copy link
Owner

Definitely can be very useful, appreciate it

@aandrew-me
Copy link
Owner

Also I noticed that the repo hasn't been updated in a long time, there is another package with more recent updates - https://github.com/golang-design/clipboard
Maybe a better choice?

@aandrew-me
Copy link
Owner

Undo the last commit, do a force push and I will merge it

@guhitb
Copy link
Contributor Author

guhitb commented Jan 31, 2024

Okay, I think I did that but have trouble figuring out git sometimes. Did you mean to merge into one commit, or to remove the change to golang-design/clipboard and go back to using atotto/clipboard?

@aandrew-me
Copy link
Owner

Okay, I think I did that but have trouble figuring out git sometimes. Did you mean to merge into one commit, or to remove the change to golang-design/clipboard and go back to using atotto/clipboard?

Yes go back to using atotto/clipboard

@aandrew-me
Copy link
Owner

Here is the content of your old main.go file, I made small changes related to error messages
main.txt

changed clipboard library

added copy and paste shortcuts to multiline mode

changed clipboard library

reverted

removed deps

removed old code
@guhitb
Copy link
Contributor Author

guhitb commented Jan 31, 2024

Alright, I think this is correct now. Thanks for linking that file.

  • printing clipboard errors instead of panicing
  • back to using atotto/clipboard

@aandrew-me aandrew-me merged commit 3296073 into aandrew-me:main Feb 1, 2024
@aandrew-me
Copy link
Owner

I changed shortcut from y to c, so that its more intuitive. (c for copy, p for paste)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants