1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#![allow(dead_code)]
pub enum ClipboardContentType {
#[cfg(any(target_os = "linux", target_os = "openbsd"))]
X11ContentType(X11ContentType),
#[cfg(target_os = "windows")]
WinContentType(WinContentType),
#[cfg(target_os = "macos")]
MacContent,
}
/// See: https://tronche.com/gui/x/icccm/sec-2.html#s-2
#[cfg(any(target_os = "linux", target_os = "openbsd"))]
pub enum X11ContentType {
AdobePortableDocumentFormat,
ApplePict,
/// A list of pixel values
Background,
/// A list of bitmap IDs
Bitmap,
/// The start and end of the selection in bytes
CharacterPosition,
Class,
/// Any top-level window owned by the selection owner
ClientWindow,
/// A list of colormap IDs
Colormap,
/// The start and end column numbers
ColumnNumber,
/// Compound Text
CompoundText,
Delete,
/// A list of drawable IDs
Drawable,
Eps,
EpsInterchange,
/// The full path name of a file
FileName,
/// A list of pixel values
Foreground,
HostName,
InsertProperty,
InsertSelection,
/// The number of bytes in the selection
Length,
/// The start and end line numbers
LineNumber,
/// The number of disjoint parts of the selection
ListLength,
/// The name of the selected procedure
Module,
Multiple,
Name,
/// ISO Office Document Interchange Format
Odif,
/// The operating system of the owner client
OwnerOs,
/// A list of pixmap IDs
Pixmap,
Postscript,
/// The name of the selected procedure
Procedure,
/// The process ID of the owner
Process,
/// ISO Latin-1 (+TAB+NEWLINE) text
String,
/// A list of valid target atoms
Targets,
/// The task ID of the owner
Task,
/// The text in the owner's choice of encoding
Text,
/// The timestamp used to acquire the selection
Timestamp,
/// The name of the user running the owner
User,
}
/// See https://msdn.microsoft.com/en-us/library/windows/desktop/ff729168%28v=vs.85%29.aspx
#[cfg(target_os = "windows")]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum WinContentType {
/// A handle to a bitmap (HBITMAP)
Bitmap,
/// A memory object containing a BITMAPINFO structure followed by the bitmap bits.
Dib,
/// A memory object containing a BITMAPV5HEADER structure followed by
/// the bitmap color space information and the bitmap bits.
Dib5,
/// Software Arts' Data Interchange Format.
Dif,
/// Bitmap display format associated with a private format. The hMem parameter must be a
/// handle to data that can be displayed in bitmap format in lieu of the privately
/// formatted data.
DspBitmap,
/// CF_DSPENHMETAFILE: Enhanced metafile display format associated with a private
/// format. The hMem parameter must be a handle to data that can be displayed in
/// enhanced metafile format in lieu of the privately formatted data.
DspEnhancedMetaFile,
/// CF_DSPMETAFILEPICT: Metafile-picture display format associated with a private
/// format. The hMem parameter must be a handle to data that can be displayed in
/// metafile-picture format in lieu of the privately formatted data.
DspMetaFilePict,
/// Text display format associated with a private format. The hMem parameter must
/// be a handle to data that can be displayed in text format in lieu of the
/// privately formatted data.
DspText,
/// A handle to an enhanced metafile (HENHMETAFILE).
EnhancedMetaFile,
/// Start of a range of integer values for application-defined
/// GDI object clipboard formats.
GdiObjectFirst,
/// End of a range of integer values for application-defined GDI
/// object clipboard formats.
GdiObjectLast,
/// A handle to type HDROP that identifies a list of files.
HDrop,
/// The data is a handle to the locale identifier associated
/// with text in the clipboard.
Locale,
/// Handle to a metafile picture format as defined by the METAFILEPICT structure.
MetaFilePict,
/// Text format containing characters in the OEM character set.
OemText,
/// Owner-display format
OwnerDisplay,
/// Handle to a color palette
Palette,
/// Data for the pen extensions to the Microsoft Windows for Pen Computing
PenData,
/// Start of a range of integer values for private clipboard formats
PrivateFirst,
/// End of a range of integer values for private clipboard formats
PrivateLast,
/// Represents audio data more complex than can be represented in a CF_WAVE standard wave format
Riff,
/// Microsoft Symbolic Link (SYLK) format
Sylk,
/// ANSI text format
Text,
/// Tagged-image file format
Tiff,
/// UTF16 text format
UnicodeText,
/// Represents audio data in one of the standard wave formats
Wave,
/// Custom content type, used as backup if none of the formats are known
Custom(u32),
}
#[cfg(target_os = "windows")]
impl WinContentType {
/// Toggles through the clipboard types
pub(crate) fn next(&self) -> Option<Self> {
use self::WinContentType::*;
match self {
Bitmap => Some(Dib),
Dib => Some(Dib5),
Dib5 => Some(Dif),
Dif => Some(DspBitmap),
DspBitmap => Some(DspEnhancedMetaFile),
DspEnhancedMetaFile => Some(DspMetaFilePict),
DspMetaFilePict => Some(DspText),
DspText => Some(EnhancedMetaFile),
EnhancedMetaFile => Some(GdiObjectFirst),
GdiObjectFirst => Some(GdiObjectLast),
GdiObjectLast => Some(HDrop),
HDrop => Some(Locale),
Locale => Some(MetaFilePict),
MetaFilePict => Some(OemText),
OemText => Some(OwnerDisplay),
OwnerDisplay => Some(Palette),
Palette => Some(PenData),
PenData => Some(PrivateFirst),
PrivateFirst => Some(PrivateLast),
PrivateLast => Some(Riff),
Riff => Some(Sylk),
Sylk => Some(Text),
Text => Some(Tiff),
Tiff => Some(UnicodeText),
UnicodeText => Some(Wave),
Wave => Some(Custom((*self).into())),
Custom(_) => None,
}
}
}
#[cfg(target_os = "windows")]
impl Into<u32> for WinContentType {
fn into(self) -> u32 {
use self::WinContentType::*;
use clipboard_win::formats::*;
match self {
Bitmap => CF_BITMAP,
Custom(a) => a,
Dib => CF_DIB,
Dib5 => CF_DIBV5,
Dif => CF_DIF,
DspBitmap => CF_DSPBITMAP,
DspEnhancedMetaFile => CF_DSPENHMETAFILE,
DspMetaFilePict => CF_DSPMETAFILEPICT,
DspText => CF_DSPTEXT,
EnhancedMetaFile => CF_ENHMETAFILE,
GdiObjectFirst => CF_GDIOBJFIRST,
GdiObjectLast => CF_GDIOBJLAST,
HDrop => CF_HDROP,
Locale => CF_LOCALE,
MetaFilePict => CF_METAFILEPICT,
OemText => CF_OEMTEXT,
OwnerDisplay => CF_OWNERDISPLAY,
Palette => CF_PALETTE,
PenData => CF_PENDATA,
PrivateFirst => CF_PRIVATEFIRST,
PrivateLast => CF_PRIVATELAST,
Riff => CF_RIFF,
Sylk => CF_SYLK,
Text => CF_TEXT,
Tiff => CF_TIFF,
UnicodeText => CF_UNICODETEXT,
Wave => CF_WAVE,
}
}
}