Created
October 21, 2010 20:33
-
-
Save bmeck/639285 to your computer and use it in GitHub Desktop.
should print out simple clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CODE | |
/* test.cc | |
* Compile with: g++ `pkg-config --cflags --libs x11` test.cc -o test | |
* Run with: ./test | |
*/ | |
#include <stdio.h>//printf | |
#include <string.h>//strlen | |
#include <stdlib.h>//atexit | |
#define Cursor X11_Cursor | |
#include <X11/Xlib.h> // Every Xlib program must include this | |
#undef Cursor//F U Mac OS | |
Display* xconn; | |
const char* Clipboard_GetText() { | |
int size; | |
const char* str = XFetchBytes(xconn,&size); | |
return str; | |
} | |
bool Clipboard_SetText(const char* str) { | |
XStoreBytes(xconn,str,strlen(str)); | |
return true; | |
} | |
void cleanup(void) { | |
XFree(xconn); | |
} | |
int main() { | |
//atexit ( *cleanup ); | |
xconn = XOpenDisplay(NULL); | |
//Clipboard_SetText("MWAHAHAHA"); | |
//just spew it out for now | |
printf("%s\n",Clipboard_GetText()); | |
cleanup(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment