Skip to content

Commit

Permalink
✨ Add support for copying to a remote clipboard
Browse files Browse the repository at this point in the history
Where possible anyway. The idea here is we're use the newly-added textual
copy_to_clipboard method to get the bookmark as far as it'll go, and then we
use pyperclip anyway to get it to the "local" clipboard, which will mean
that even on terminals that don't support OSC 52, it should get somewhere
useful anyway.
  • Loading branch information
davep committed Apr 19, 2024
1 parent e09afbf commit e1a9a3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Tinboard ChangeLog

## WiP

**Released: WiP**

- When copying a bookmark to the clipboard, a best effort is now made to
ensure it'll also make it over a remote connection.

## v0.12.0

**Released: 2024-04-18**
Expand Down
7 changes: 7 additions & 0 deletions tinboard/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,13 @@ def copy_bookmark_to_clipboard(self) -> None:
if (bookmark := self.query_one(Bookmarks).current_bookmark) is None:
self.app.bell()
elif bookmark.data.href:
# Use Textual's own "copy to clipboard" as this will help push
# it through remote connections.
self.app.copy_to_clipboard(bookmark.data.href)
# Having done that, try and use pyperclip anyway, because it's
# possible we're within a terminal that doesn't support the
# above, but this will at best finally get it there, and at
# worst overwrite the clipboard with the same data.
try:
to_clipboard(bookmark.data.href)
except PyperclipException:
Expand Down

0 comments on commit e1a9a3f

Please sign in to comment.