Skip to content

Commit

Permalink
Report all available types in debug
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Mar 4, 2024
1 parent e66906e commit 6a221b4
Showing 1 changed file with 44 additions and 26 deletions.
70 changes: 44 additions & 26 deletions Tools/xpbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -869,11 +869,15 @@ - (Atom) xPb
*/
- (NSArray*) availableTypes
{
NSMutableArray *types;
NSData *data;
unsigned int count;
unsigned int i;
Atom *targets;
NSMutableArray *types;
NSData *data;
NSMutableString *txt = nil;
NSMutableString *rtf = nil;
NSMutableString *std = nil;
NSMutableString *bad = nil;
unsigned int count;
unsigned int i;
Atom *targets;

NSDebugLLog(@"Pbs", @"%@ availableTypes called", [[self osPb] name]);

Expand All @@ -887,20 +891,23 @@ - (NSArray*) availableTypes
targets = (Atom*)[data bytes];
types = [NSMutableArray arrayWithCapacity: count];

NSDebugLLog(@"Pbs", @"%@ availableTypes: %d types available",
[[self osPb] name], count);

for (i = 0; i < count; i++)
{
Atom type;
Atom type;
char *name;

type = targets[i];
name = XGetAtomName(xDisplay, type);

if ((type == XG_UTF8_STRING)
|| (type == XA_STRING)
|| (type == XG_TEXT)
|| (type == XG_MIME_PLAIN))
|| (type == XA_STRING)
|| (type == XG_TEXT)
|| (type == XG_MIME_PLAIN))
{
if (nil == txt)
txt = [NSMutableString stringWithFormat: @" string:%s", name];
else
[txt appendFormat: @",%s", name];
[types addObject: NSStringPboardType];
}
else if (type == XG_FILE_NAME)
Expand All @@ -911,36 +918,47 @@ - (NSArray*) availableTypes
|| (type == XG_MIME_APP_RTF)
|| (type == XG_MIME_TEXT_RICHTEXT))
{
if (nil == rtf)
rtf = [NSMutableString stringWithFormat: @" rich-text:%s", name];
else
[rtf appendFormat: @",%s", name];
[types addObject: NSRTFPboardType];
}
else if (type == XG_MIME_TIFF)
{
[types addObject: NSTIFFPboardType];
}
else if ((type == XG_TARGETS)
|| (type == XG_TIMESTAMP)
|| (type == XG_OWNER_OS)
|| (type == XG_USER)
|| (type == XG_HOST_NAME)
|| (type == XG_HOSTNAME)
|| (type == XG_MULTIPLE))
{
// Standard types
|| (type == XG_TIMESTAMP)
|| (type == XG_OWNER_OS)
|| (type == XG_USER)
|| (type == XG_HOST_NAME)
|| (type == XG_HOSTNAME)
|| (type == XG_MULTIPLE))
{
// Standard types
if (nil == std)
std = [NSMutableString stringWithFormat: @" standard:%s", name];
else
[std appendFormat: @",%s", name];
}
// FIXME: Support more types
else
{
char *name = XGetAtomName(xDisplay, type);

if (nil == bad)
bad = [NSMutableString stringWithFormat: @" unsupported:%s", name];
else
[bad appendFormat: @",%s", name];
// FIXME: We should rather add this type to the
// pasteboard as a string.
NSDebugLLog(@"Pbs", @"Unsupported selection type '%s' available",
name);
XFree(name);
}
XFree(name);
}

NSDebugLLog(@"Pbs", @"Available types: %@ ", types);
NSDebugLLog(@"Pbs", @"%@ availableTypes: %d types available: %@%@%@%@%@",
[[self osPb] name], count, types,
(txt ? txt : @""), (rtf ? rtf : @""), (std ? std : @""), (bad ? bad : @""));

return types;
}

Expand Down

0 comments on commit 6a221b4

Please sign in to comment.