Skip to content

Commit 7faed80

Browse files
Update category comment
1 parent 2f86df5 commit 7faed80

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed

units/SDL_clipboard.inc

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,57 @@
77
}
88

99
{*
10-
* # CategoryClipboard
11-
*
12-
* SDL provides access to the system clipboard, both for reading information
13-
* from other processes and publishing information of its own.
14-
*
15-
* This is not just text! SDL apps can access and publish data by mimetype.
10+
* # CategoryClipboard
11+
*
12+
* SDL provides access to the system clipboard, both for reading information
13+
* from other processes and publishing information of its own.
14+
*
15+
* This is not just text! SDL apps can access and publish data by mimetype.
16+
*
17+
* ## Basic use (text)
18+
*
19+
* Obtaining and publishing simple text to the system clipboard is as easy as
20+
* calling SDL_GetClipboardText() and SDL_SetClipboardText(), respectively.
21+
* These deal with C strings in UTF-8 encoding. Data transmission and encoding
22+
* conversion is completely managed by SDL.
23+
*
24+
* ## Clipboard callbacks (data other than text)
25+
*
26+
* Things get more complicated when the clipboard contains something other
27+
* than text. Not only can the system clipboard contain data of any type, in
28+
* some cases it can contain the same data in different formats! For example,
29+
* an image painting app might let the user copy a graphic to the clipboard,
30+
* and offers it in .BMP, .JPG, or .PNG format for other apps to consume.
31+
*
32+
* Obtaining clipboard data ("pasting") like this is a matter of calling
33+
* SDL_GetClipboardData() and telling it the mimetype of the data you want.
34+
* But how does one know if that format is available? SDL_HasClipboardData()
35+
* can report if a specific mimetype is offered, and
36+
* SDL_GetClipboardMimeTypes() can provide the entire list of mimetypes
37+
* available, so the app can decide what to do with the data and what formats
38+
* it can support.
39+
*
40+
* Setting the clipboard ("copying") to arbitrary data is done with
41+
* SDL_SetClipboardData. The app does not provide the data in this call, but
42+
* rather the mimetypes it is willing to provide and a callback function.
43+
* During the callback, the app will generate the data. This allows massive
44+
* data sets to be provided to the clipboard, without any data being copied
45+
* before it is explicitly requested. More specifically, it allows an app to
46+
* offer data in multiple formats without providing a copy of all of them
47+
* upfront. If the app has an image that it could provide in PNG or JPG
48+
* format, it doesn't have to encode it to either of those unless and until
49+
* something tries to paste it.
50+
*
51+
* ## Primary Selection
52+
*
53+
* The X11 and Wayland video targets have a concept of the "primary selection"
54+
* in addition to the usual clipboard. This is generally highlighted (but not
55+
* explicitly copied) text from various apps. SDL offers APIs for this through
56+
* SDL_GetPrimarySelectionText() and SDL_SetPrimarySelectionText(). SDL offers
57+
* these APIs on platforms without this concept, too, but only so far that it
58+
* will keep a copy of a string that the app sets for later retrieval; the
59+
* operating system will not ever attempt to change the string externally if
60+
* it doesn't support a primary selection.
1661
}
1762

1863
{ Function prototypes }

0 commit comments

Comments
 (0)