Browse Source

clipboard wip

master
churchianity 1 year ago
parent
commit
2729156a0c
  1. 19
      clipboard-osx.mm
  2. 12
      clipboard-win.cpp
  3. 2
      clipboard.cpp
  4. 11
      clipboard.h

19
clipboard-osx.mm

@ -0,0 +1,19 @@
#include <AppKit/AppKit.h>
#include <Foundation/Foundation.h>
int Copy(const char* stuff) {
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
NSInteger changeCount = [pasteboard clearContents];
NSString *nsstring = [NSString stringWithUTF8String:stuff];
NSArray *objectsToCopy = @[nsstring];
BOOL OK = [pasteboard writeObjects:objectsToCopy];
if (OK) {
return 1;
}
return 0;
}

12
clipboard-win.cpp

@ -0,0 +1,12 @@
int copy(const char* stuff, int length) {
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, length);
memcpy(GlobalLock(hMem), output, length);
GlobalUnlock(hMem);
OpenClipboard(0);
EmptyClipboard();
SetClipboardData(CF_TEXT, hMem);
CloseClipboard();
return 0;
}

2
clipboard.cpp

@ -0,0 +1,2 @@

11
clipboard.h

@ -0,0 +1,11 @@
#ifndef ULE_CLIPBOARD_H
#define ULE_CLIPBOARD_H
namespace Clipboard {
void Copy(const char* stuff);
};
#endif
Loading…
Cancel
Save