summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Costantini <fabien@onepost.net>2009-01-12 16:45:55 +0000
committerFabien Costantini <fabien@onepost.net>2009-01-12 16:45:55 +0000
commitcbd3151d4f0d252d43079027d28a2d938dd35829 (patch)
tree9316dcf7c810e682f6826eeabe1bb8d277571f43
parenta33d0a6d292700133efaf6806c0e28694f279719 (diff)
STR#2121: Added old fltk 1.1.x scrap buffer paste detection to Fl::paste().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6627 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_mac.cxx33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index bec0f229f..46faae1eb 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -89,6 +89,8 @@ extern void fl_fix_focus();
static void handleUpdateEvent( WindowPtr xid );
//+ int fl_handle(const EventRecord &event);
static int FSSpec2UnixPath( FSSpec *fs, char *dst );
+// converting cr lf converter function
+static void convert_crlf(char * string, size_t len);
// public variables
int fl_screen;
@@ -1810,6 +1812,12 @@ static int FSSpec2UnixPath( FSSpec *fs, char *dst )
FSRefMakePath( &fsRef, (UInt8*)dst, 1024 );
return strlen(dst);
}
+static void convert_crlf(char * s, size_t len)
+{
+ // turn all \r characters into \n:
+ for (size_t x = 0; x < len; x++) if (s[x] == '\r') s[x] = '\n';
+}
+
static DragReference currDragRef = 0;
static char *currDragData = 0L;
@@ -2502,7 +2510,10 @@ static void allocatePasteboard() {
}
#else
#endif
-// not used yet: static ScrapRef myScrap = 0;
+
+#ifndef USE_PASTEBOARD
+static ScrapRef myScrap = 0;
+#endif
/**
* create a selection
@@ -2602,10 +2613,28 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
CFRelease (mycfs);
len = strlen(fl_selection_buffer[1]);
fl_selection_length[1] = len;
- for(char *p=fl_selection_buffer[1]; p < fl_selection_buffer[1]+len; p++) if(*p == '\r') *p = '\n';
+ convert_crlf(fl_selection_buffer[1],len); // turn all \r characters into \n:
i = nFlavor+1;
break;
}
+ else if (clipboard) { // old fltk 1.1.x way
+ // see if we own the selection, if not go get it:
+ ScrapRef scrap = 0;
+ Size len = 0;
+ if (GetCurrentScrap(&scrap) == noErr &&
+ GetScrapFlavorSize(scrap, kScrapFlavorTypeText, &len) == noErr) {
+ if ( len >= fl_selection_buffer_length[1] ) {
+ fl_selection_buffer_length[1] = len + 32;
+ delete[] fl_selection_buffer[1];
+ fl_selection_buffer[1] = new char[len + 32];
+ }
+ fl_selection_length[1] = len; len++;
+ GetScrapFlavorData( scrap, kScrapFlavorTypeText, &len,
+ fl_selection_buffer[1] );
+ fl_selection_buffer[1][fl_selection_length[1]] = 0;
+ convert_crlf(fl_selection_buffer[1],len); // turn all \r characters into \n:
+ }
+ }
}
CFRelease (flavorTypeArray);
}