Design discussion for Clipboard functionality
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 9h 45m
- Merged PRs (30d)
- 58
Description
I would like to have a cross-platform functionality in Toga which allows us to copy data into the system clipboard and paste data from the system clipboard.
I already made a working proof-of-concept for the data type "Text" for Windows and Android (see PR #1191) as a base for discussion. The PR implements the Clipboard class with following methods:
* get_text()
* set_text(text)
It is not clear, though, how to handle data types other than Text because there are a lot of differences between Windows and Android, and other platforms will probably add to this diversity.
On Windows, you can only have 1 clipboard item, but you can store this item in several different data types at the same time (see https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.dataformats?view=net-5.0):
Bitmap, CommaSeparatedValue, Dib, Dif, EnhancedMetafile, FileDrop, Html, Locale, MetafilePict, OemText, Palette, PenData, Riff, Rtf, Serializable, StringFormat, SymbolicLink, Text, Tiff, UnicodeText, WaveAudio
So, you could have an image in the clipboard in the formats Bitmap, EnhancedMetafile and Tiff.
On Android, you can have several clipboard items, but every item has just 1 specific data type being one of: Text, URI or Intent (https://developer.android.com/guide/topics/text/copy-paste)
When you use URI, you must provide a Content Provider which will be responsible to actually access the data. The data itself is NOT in the clipboard. In the clipboard, you only have the URI and the Content Provider.
So, the question is:
How should we design the Clipboard feature, so that it is usable on all platforms with a uniform interface?
Contributor guide
Research direction
Start by reading the Clipboard proof of concept in PR #1191, including its get_text() and set_text() methods, then review the Windows and Android constraints described in this issue. The work is complete when the project agrees on a uniform cross-platform interface for text and other clipboard data types and records that design for implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop, mobile-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100