summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Costantini <fabien@onepost.net>2009-01-12 13:55:55 +0000
committerFabien Costantini <fabien@onepost.net>2009-01-12 13:55:55 +0000
commite9ef99002fbda41d56f2374e562daff473ff39f5 (patch)
tree685a88d5e6af87a140669a4999aa98f786c16b46
parent84920d7cf1d004849ebcea7eb1cdd5ca2e9abc36 (diff)
STR#2121 fix: Fixed paste from utf16 content would not work in fltk input widgets,
thanks manolo for the code fragment. Code inserted into Fl_mac.cxx, tested, regression tested with utf greg japanese example from fltk to fltk, now all test cases work fine in mac os x (10.5.5). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6625 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_mac.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index c937cfb4f..bec0f229f 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -2585,6 +2585,27 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
i = nFlavor+1;
break;
}
+ // accept the utf16 copied buffers (I.e: like in ms Word (r) and other text editors
+ else if (UTTypeConformsTo(flavorType, CFSTR("public.utf16-plain-text"))) {
+ err = PasteboardCopyItemFlavorData( myPasteboard, itemID, CFSTR("public.utf16-plain-text"), &flavorData );
+ if(err != noErr) continue;
+ len = CFDataGetLength(flavorData);
+ CFStringRef mycfs = CFStringCreateWithBytes(NULL, CFDataGetBytePtr(flavorData), len, kCFStringEncodingUnicode, false);
+ CFRelease (flavorData);
+ len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(mycfs), kCFStringEncodingUTF8) + 1;
+ if ( len > fl_selection_buffer_length[1] ) {
+ fl_selection_buffer_length[1] = len;
+ delete[] fl_selection_buffer[1];
+ fl_selection_buffer[1] = new char[len];
+ }
+ CFStringGetCString(mycfs, fl_selection_buffer[1], len, kCFStringEncodingUTF8);
+ 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';
+ i = nFlavor+1;
+ break;
+ }
}
CFRelease (flavorTypeArray);
}