diff options
Diffstat (limited to 'src/utils/copynpaste.cpp')
-rw-r--r-- | src/utils/copynpaste.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 6d1c675d3..3e37afd9d 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -43,7 +43,7 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) { bool ret = false; - if (!OpenClipboard(NULL)) + if (!OpenClipboard(nullptr)) return false; HANDLE h = GetClipboardData(CF_UNICODETEXT); @@ -54,13 +54,13 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) if (data) { int len = WideCharToMultiByte(CP_UTF8, 0, data, -1, - NULL, 0, NULL, NULL); + nullptr, 0, nullptr, nullptr); if (len > 0) { // Convert from UTF-16 to UTF-8 void *temp = calloc(len, 1); if (WideCharToMultiByte(CP_UTF8, 0, data, -1, - (LPSTR)temp, len, NULL, NULL)) + (LPSTR)temp, len, nullptr, nullptr)) { text.insert(pos, (char*)temp); pos += len-1; @@ -94,7 +94,8 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) bool sendBuffer(std::string& text) { - int wCharsLen = MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, NULL, 0); + int wCharsLen = MultiByteToWideChar(CP_UTF8, + 0, text.c_str(), -1, nullptr, 0); if (!wCharsLen) return false; @@ -284,6 +285,9 @@ bool sendBuffer(std::string& text) } #elif USE_X11 + +#include <unistd.h> + static char* getSelection2(Display *dpy, Window us, Atom selection, Atom request_target) { @@ -295,7 +299,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, if (owner == None) { //printf("No owner\n"); - return NULL; + return nullptr; } XConvertSelection(dpy, selection, request_target, XA_PRIMARY, us, CurrentTime); @@ -314,13 +318,13 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, if (e.xselection.property == None) { //printf("Couldn't convert\n"); - return NULL; + return nullptr; } long unsigned len, left, dummy; int format; Atom type; - unsigned char *data = NULL; + unsigned char *data = nullptr; ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, 0, False, AnyPropertyType, &type, &format, &len, &left, &data); @@ -328,7 +332,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, { if (ret == Success) XFree(data); - return NULL; + return nullptr; } ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, @@ -338,7 +342,7 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, if (ret != Success) { //printf("Failed to get property: %p on %lu\n", data, len); - return NULL; + return nullptr; } //printf(">>> Got %s: len=%lu left=%lu (event %i)\n", data, @@ -346,14 +350,14 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, return reinterpret_cast<char*>(data); } } - return NULL; + return nullptr; } static Atom requestAtom; static char* getSelection(Display *dpy, Window us, Atom selection) { - char *data = NULL; + char *data = nullptr; if (requestAtom != None) data = getSelection2(dpy, us, selection, requestAtom); if (!data) @@ -371,7 +375,7 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) { Display *dpy = info.info.x11.display; Window us = info.info.x11.window; - char *data = NULL; + char *data = nullptr; requestAtom = XInternAtom (dpy, "UTF8_STRING", true); @@ -428,7 +432,7 @@ bool sendBuffer(std::string& text) } close(fd[0]); } - execl("/usr/bin/xsel", "xsel", "-i", (char *)0); + execl("/usr/bin/xsel", "xsel", "-i", (char *)nullptr); exit(1); } |