diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-03-23 16:04:12 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2021-03-23 16:10:41 +0200 |
commit | 14de0fdeb7f84097650d0616bc850f5391642fe6 (patch) | |
tree | 3b1ec33123871fab275b17eaacfeb7a1d1d9a0af /vcl/workben | |
parent | a8c23e5e5bd36899320c93d22040a093fe7a6c04 (diff) |
Add -a option to dump all pasteboard types plus some minor cleanup
Change-Id: I1cbc11eaad16a7af9b8ff665c4c35b417b1860bc
Diffstat (limited to 'vcl/workben')
-rw-r--r-- | vcl/workben/pasteboard.mm | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/vcl/workben/pasteboard.mm b/vcl/workben/pasteboard.mm index 279d3e6cc595..6a28430831b4 100644 --- a/vcl/workben/pasteboard.mm +++ b/vcl/workben/pasteboard.mm @@ -20,10 +20,13 @@ static void usage() { std::cout << "Usage: pasteboard\n" - " --List the types on the pasteboard and in each pasteboard item.\n" + " List the types on the pasteboard and in each pasteboard item.\n" + " pasteboard -a\n" + " Output the data for all types to stdout. Note: output will\n" + " in many cases be binary. The different types are separated by a textual header.\n" " pasteboard -t type\n" - " --Output the data for the type in question to stdout. Note: output will " - "in many cases be binary.\n"; + " Output the data for the type in question to stdout. Note: output will\n" + " in many cases be binary.\n"; } int main(int argc, char** argv) @@ -32,16 +35,19 @@ int main(int argc, char** argv) int ch; - while ((ch = getopt(argc, argv, "t:")) != -1) + while ((ch = getopt(argc, argv, "at:")) != -1) { switch (ch) { + case 'a': + requestedType = @"*"; + break; case 't': requestedType = [NSString stringWithUTF8String:optarg]; break; case '?': usage(); - break; + return 0; } } @@ -56,6 +62,22 @@ int main(int argc, char** argv) NSPasteboard* pb = [NSPasteboard generalPasteboard]; + if ([requestedType isEqualToString:@"*"]) + { + NSArray<NSPasteboardType>* types = [pb types]; + for (unsigned i = 0; i < [types count]; i++) + { + NSData* data = [pb dataForType:types[i]]; + std::cout << i << ": " << [types[i] UTF8String] << ": " << std::to_string([data length]) << " bytes:\n"; + if (data != nil) + { + std::cout.write((const char*)[data bytes], [data length]); + std::cout << "\n"; + } + } + return 0; + } + if ([requestedType length] > 0) { NSData* data = [pb dataForType:requestedType]; |