Skip to content

Commit

Permalink
add html clipboard support
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Mar 6, 2024
1 parent 4fea5f4 commit 0d60ea2
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion Tools/xpbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@
return NSRTFPboardType;
}

if (XG_MIME_HTML == type
|| XG_MIME_XHTML == type)
{
return NSHTMLPboardType;
}

if (XG_MIME_PDF == type)
{
return NSPasteboardTypePDF;
Expand Down Expand Up @@ -869,6 +875,10 @@ - (void) pasteboard: (NSPasteboard*)pb provideDataForType: (NSString*)type
{
[self requestData: (xType = XG_MIME_PDF)];
}
else if ([type isEqual: NSHTMLPboardType])
{
[self requestData: (xType = XG_MIME_HTML)];
}
// FIXME: Support more types
else
{
Expand Down Expand Up @@ -1338,6 +1348,11 @@ - (void) xSelectionNotify: (XSelectionEvent*)xEvent
{
[self setData: md];
}
else if ((actual_type == XG_MIME_HTML)
|| (actual_type == XG_MIME_XHTML))
{
[self setData: md];
}
else if (actual_type == XG_MIME_TIFF)
{
[self setData: md];
Expand Down Expand Up @@ -1429,7 +1444,7 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
{
unsigned numTypes = 0;
// ATTENTION: Increase this array when adding more types
Atom xTypes[19];
Atom xTypes[21];

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

if ([types containsObject: NSHTMLPboardType])
{
xTypes[numTypes++] = XG_MIME_HTML;
xTypes[numTypes++] = XG_MIME_XHTML;
}

if ([types containsObject: NSTIFFPboardType])
{
xTypes[numTypes++] = XG_MIME_TIFF;
Expand Down Expand Up @@ -1578,6 +1599,11 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
xEvent->target = XG_MIME_PNG;
[self xProvideSelection: xEvent];
}
else if ([types containsObject: NSHTMLPboardType])
{
xEvent->target = XG_MIME_HTML;
[self xProvideSelection: xEvent];
}
}
else if (xEvent->target == XG_MULTIPLE)
{
Expand Down Expand Up @@ -1708,6 +1734,15 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
format = 8;
numItems = [data length];
}
else if (((xEvent->target == XG_MIME_HTML)
|| (xEvent->target == XG_MIME_XHTML))
&& [types containsObject: NSHTMLPboardType])
{
data = [_pb dataForType: NSHTMLPboardType];
xType = xEvent->target;
format = 8;
numItems = [data length];
}
else if ((xEvent->target == XG_MIME_TIFF)
&& [types containsObject: NSTIFFPboardType])
{
Expand Down

0 comments on commit 0d60ea2

Please sign in to comment.