mirror of
https://github.com/fltk/fltk.git
synced 2026-05-22 23:37:02 +08:00
Add support for Fl::copy(..clipboard = 2..)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10731 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user