···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2019 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+2121+#import <Foundation/Foundation.h>
2222+#import <AppKit/NSPasteboard.h>
2323+#import <AppKit/NSDisplay.h>
2424+2525+int main(int argc, const char *argv[]) {
2626+ [NSAutoreleasePool new];
2727+2828+ NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
2929+ NSData *data = [handle readDataToEndOfFile];
3030+3131+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
3232+ [pasteboard setData: data forType: NSStringPboardType];
3333+3434+ // While we're the clipboard owner, make sure to process incoming requests.
3535+ NSInteger changeCount = [pasteboard changeCount];
3636+ NSDisplay *display = [NSDisplay currentDisplay];
3737+ while (changeCount == [pasteboard changeCount]) {
3838+ [display nextEventMatchingMask: NSAnyEventMask
3939+ untilDate: [NSDate distantFuture]
4040+ inMode: NSDefaultRunLoopMode
4141+ dequeue: YES];
4242+ }
4343+}
+32
src/pboard/pbpaste.m
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2016-2017 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+2121+#import <Foundation/Foundation.h>
2222+#import <AppKit/NSPasteboard.h>
2323+2424+int main(int argc, const char *argv[]) {
2525+ [NSAutoreleasePool new];
2626+2727+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
2828+ NSData *data = [pasteboard dataForType: NSStringPboardType];
2929+3030+ NSFileHandle *handle = [NSFileHandle fileHandleWithStandardOutput];
3131+ [handle writeData: data];
3232+}