diff options
| -rw-r--r-- | FL/Fl.H | 5 | ||||
| -rw-r--r-- | src/Fl_cocoa.mm | 3 | ||||
| -rw-r--r-- | src/Fl_win32.cxx | 2 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 7 |
4 files changed, 15 insertions, 2 deletions
@@ -837,8 +837,9 @@ public: // cut/paste: /** Copies the data pointed to by \p stuff to the selection buffer - (\p destination is 0) or - the clipboard (\p destination is 1). + (\p destination is 0), the clipboard (\p destination is 1), or + both (\p destination is 2). Copying to both is only relevant on X11, + on other platforms it maps to the clipboard (1). \p len is the number of relevant bytes in \p stuff. \p type is always Fl::clipboard_plain_text. The selection buffer is used for diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index a06111ffb..381c35172 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -3457,6 +3457,9 @@ static void resize_selection_buffer(int len, int clipboard) { */ void Fl::copy(const char *stuff, int len, int clipboard, const char *type) { if (!stuff || len<0) return; + if (clipboard >= 2) + clipboard = 1; // Only on X11 do multiple clipboards make sense. + resize_selection_buffer(len+1, clipboard); memcpy(fl_selection_buffer[clipboard], stuff, len); fl_selection_buffer[clipboard][len] = 0; // needed for direct paste diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 830a6c81d..624de69d9 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -664,6 +664,8 @@ void fl_update_clipboard(void) { // call this when you create a selection: void Fl::copy(const char *stuff, int len, int clipboard, const char *type) { if (!stuff || len<0) return; + if (clipboard >= 2) + clipboard = 1; // Only on X11 do multiple clipboards make sense. // Convert \n -> \r\n (for old apps like Notepad, DOS) Lf2CrlfConvert buf(stuff, len); diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 9dee09514..094f271a5 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -994,6 +994,13 @@ static int get_xwinprop(Window wnd, Atom prop, long max_length, void Fl::copy(const char *stuff, int len, int clipboard, const char *type) { if (!stuff || len<0) return; + + if (clipboard >= 2) { + copy(stuff, len, 0, type); + copy(stuff, len, 1, type); + return; + } + if (len+1 > fl_selection_buffer_length[clipboard]) { delete[] fl_selection_buffer[clipboard]; fl_selection_buffer[clipboard] = new char[len+100]; |
