mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2024-11-25 09:33:50 +01:00
78 lines
3.0 KiB
Diff
78 lines
3.0 KiB
Diff
diff -up fltk-1.3.3/src/Fl_cocoa.mm.clip fltk-1.3.3/src/Fl_cocoa.mm
|
|
--- fltk-1.3.3/src/Fl_cocoa.mm.clip 2014-11-02 22:06:07.000000000 +0100
|
|
+++ fltk-1.3.3/src/Fl_cocoa.mm 2015-04-20 13:45:03.526688921 +0200
|
|
@@ -3061,6 +3061,14 @@ static void clipboard_check(void)
|
|
fl_trigger_clipboard_notify(1);
|
|
}
|
|
|
|
+static void resize_selection_buffer(int len, int clipboard) {
|
|
+ if (len <= fl_selection_buffer_length[clipboard])
|
|
+ return;
|
|
+ delete[] fl_selection_buffer[clipboard];
|
|
+ fl_selection_buffer[clipboard] = new char[len+100];
|
|
+ fl_selection_buffer_length[clipboard] = len+100;
|
|
+}
|
|
+
|
|
/*
|
|
* create a selection
|
|
* stuff: pointer to selected data
|
|
@@ -3069,11 +3077,7 @@ static void clipboard_check(void)
|
|
*/
|
|
void Fl::copy(const char *stuff, int len, int clipboard, const char *type) {
|
|
if (!stuff || len<0) return;
|
|
- if (len+1 > fl_selection_buffer_length[clipboard]) {
|
|
- delete[] fl_selection_buffer[clipboard];
|
|
- fl_selection_buffer[clipboard] = new char[len+100];
|
|
- fl_selection_buffer_length[clipboard] = len+100;
|
|
- }
|
|
+ resize_selection_buffer(len+1, clipboard);
|
|
memcpy(fl_selection_buffer[clipboard], stuff, len);
|
|
fl_selection_buffer[clipboard][len] = 0; // needed for direct paste
|
|
fl_selection_length[clipboard] = len;
|
|
@@ -3087,7 +3091,7 @@ void Fl::copy(const char *stuff, int len
|
|
}
|
|
}
|
|
|
|
-static int get_plain_text_from_clipboard(char **buffer, int previous_length)
|
|
+static int get_plain_text_from_clipboard(int clipboard)
|
|
{
|
|
NSInteger length = 0;
|
|
NSPasteboard *clip = [NSPasteboard generalPasteboard];
|
|
@@ -3109,21 +3113,17 @@ static int get_plain_text_from_clipboard
|
|
len = strlen(aux_c) + 1;
|
|
}
|
|
else len = [data length] + 1;
|
|
- if ( len >= previous_length ) {
|
|
- length = len;
|
|
- delete[] *buffer;
|
|
- *buffer = new char[len];
|
|
- }
|
|
+ resize_selection_buffer(len, clipboard);
|
|
if (![found isEqualToString:utf8_format]) {
|
|
- strcpy(*buffer, aux_c);
|
|
- free(aux_c);
|
|
+ strcpy(fl_selection_buffer[clipboard], aux_c);
|
|
+ free(aux_c);
|
|
}
|
|
else {
|
|
- [data getBytes:*buffer];
|
|
+ [data getBytes:fl_selection_buffer[clipboard]];
|
|
}
|
|
- (*buffer)[len - 1] = 0;
|
|
+ fl_selection_buffer[clipboard][len - 1] = 0;
|
|
length = len - 1;
|
|
- convert_crlf(*buffer, len - 1); // turn all \r characters into \n:
|
|
+ convert_crlf(fl_selection_buffer[clipboard], len - 1); // turn all \r characters into \n:
|
|
Fl::e_clipboard_type = Fl::clipboard_plain_text;
|
|
}
|
|
}
|
|
@@ -3218,7 +3218,7 @@ void Fl::paste(Fl_Widget &receiver, int
|
|
if (clipboard) {
|
|
Fl::e_clipboard_type = "";
|
|
if (strcmp(type, Fl::clipboard_plain_text) == 0) {
|
|
- fl_selection_length[1] = get_plain_text_from_clipboard( &fl_selection_buffer[1], fl_selection_length[1]);
|
|
+ fl_selection_length[1] = get_plain_text_from_clipboard(1);
|
|
}
|
|
else if (strcmp(type, Fl::clipboard_image) == 0) {
|
|
Fl::e_clipboard_data = get_image_from_clipboard( );
|