Skip to content

Commit

Permalink
Add URL/URI-list support (without insisting on trailing cr-lf)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Mar 6, 2024
1 parent 0d60ea2 commit 085082a
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion Tools/xpbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@
return NSHTMLPboardType;
}

if (XG_MIME_URI == type)
{
return NSURLPboardType;
}

if (XG_MIME_PDF == type)
{
return NSPasteboardTypePDF;
Expand Down Expand Up @@ -879,6 +884,10 @@ - (void) pasteboard: (NSPasteboard*)pb provideDataForType: (NSString*)type
{
[self requestData: (xType = XG_MIME_HTML)];
}
else if ([type isEqual: NSURLPboardType])
{
[self requestData: (xType = XG_MIME_URI)];
}
// FIXME: Support more types
else
{
Expand Down Expand Up @@ -1353,6 +1362,10 @@ - (void) xSelectionNotify: (XSelectionEvent*)xEvent
{
[self setData: md];
}
else if (actual_type == XG_MIME_URI)
{
[self setData: md];
}
else if (actual_type == XG_MIME_TIFF)
{
[self setData: md];
Expand Down Expand Up @@ -1444,7 +1457,7 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
{
unsigned numTypes = 0;
// ATTENTION: Increase this array when adding more types
Atom xTypes[21];
Atom xTypes[22];

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

if ([types containsObject: NSURLPboardType])
{
xTypes[numTypes++] = XG_MIME_URI;
}

if ([types containsObject: NSTIFFPboardType])
{
xTypes[numTypes++] = XG_MIME_TIFF;
Expand Down Expand Up @@ -1604,6 +1622,11 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
xEvent->target = XG_MIME_HTML;
[self xProvideSelection: xEvent];
}
else if ([types containsObject: NSURLPboardType])
{
xEvent->target = XG_MIME_URI;
[self xProvideSelection: xEvent];
}
}
else if (xEvent->target == XG_MULTIPLE)
{
Expand Down Expand Up @@ -1743,6 +1766,14 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent
format = 8;
numItems = [data length];
}
else if ((xEvent->target == XG_MIME_URI)
&& [types containsObject: NSURLPboardType])
{
data = [_pb dataForType: NSURLPboardType];
xType = xEvent->target;
format = 8;
numItems = [data length];
}
else if ((xEvent->target == XG_MIME_TIFF)
&& [types containsObject: NSTIFFPboardType])
{
Expand Down

0 comments on commit 085082a

Please sign in to comment.