Skip to content

Commit 0d60ea2

Browse files
committed
add html clipboard support
1 parent 4fea5f4 commit 0d60ea2

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

Tools/xpbs.m

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@
160160
return NSRTFPboardType;
161161
}
162162

163+
if (XG_MIME_HTML == type
164+
|| XG_MIME_XHTML == type)
165+
{
166+
return NSHTMLPboardType;
167+
}
168+
163169
if (XG_MIME_PDF == type)
164170
{
165171
return NSPasteboardTypePDF;
@@ -869,6 +875,10 @@ - (void) pasteboard: (NSPasteboard*)pb provideDataForType: (NSString*)type
869875
{
870876
[self requestData: (xType = XG_MIME_PDF)];
871877
}
878+
else if ([type isEqual: NSHTMLPboardType])
879+
{
880+
[self requestData: (xType = XG_MIME_HTML)];
881+
}
872882
// FIXME: Support more types
873883
else
874884
{
@@ -1338,6 +1348,11 @@ - (void) xSelectionNotify: (XSelectionEvent*)xEvent
13381348
{
13391349
[self setData: md];
13401350
}
1351+
else if ((actual_type == XG_MIME_HTML)
1352+
|| (actual_type == XG_MIME_XHTML))
1353+
{
1354+
[self setData: md];
1355+
}
13411356
else if (actual_type == XG_MIME_TIFF)
13421357
{
13431358
[self setData: md];
@@ -1429,7 +1444,7 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
14291444
{
14301445
unsigned numTypes = 0;
14311446
// ATTENTION: Increase this array when adding more types
1432-
Atom xTypes[19];
1447+
Atom xTypes[21];
14331448

14341449
/*
14351450
* The requestor wants a list of the types we can supply it with.
@@ -1465,6 +1480,12 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
14651480
xTypes[numTypes++] = XG_MIME_TEXT_RICHTEXT;
14661481
}
14671482

1483+
if ([types containsObject: NSHTMLPboardType])
1484+
{
1485+
xTypes[numTypes++] = XG_MIME_HTML;
1486+
xTypes[numTypes++] = XG_MIME_XHTML;
1487+
}
1488+
14681489
if ([types containsObject: NSTIFFPboardType])
14691490
{
14701491
xTypes[numTypes++] = XG_MIME_TIFF;
@@ -1578,6 +1599,11 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
15781599
xEvent->target = XG_MIME_PNG;
15791600
[self xProvideSelection: xEvent];
15801601
}
1602+
else if ([types containsObject: NSHTMLPboardType])
1603+
{
1604+
xEvent->target = XG_MIME_HTML;
1605+
[self xProvideSelection: xEvent];
1606+
}
15811607
}
15821608
else if (xEvent->target == XG_MULTIPLE)
15831609
{
@@ -1708,6 +1734,15 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
17081734
format = 8;
17091735
numItems = [data length];
17101736
}
1737+
else if (((xEvent->target == XG_MIME_HTML)
1738+
|| (xEvent->target == XG_MIME_XHTML))
1739+
&& [types containsObject: NSHTMLPboardType])
1740+
{
1741+
data = [_pb dataForType: NSHTMLPboardType];
1742+
xType = xEvent->target;
1743+
format = 8;
1744+
numItems = [data length];
1745+
}
17111746
else if ((xEvent->target == XG_MIME_TIFF)
17121747
&& [types containsObject: NSTIFFPboardType])
17131748
{

0 commit comments

Comments
 (0)