summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2019-10-23 03:43:42 (GMT)
committerculler <culler>2019-10-23 03:43:42 (GMT)
commite52422e60cb9265936b53ae27a0ee159416221db (patch)
treef06a164e2a27e72c4f3e42e554e3205766c8281b
parente766ee74b4cc2341eb5799f74958467d1792c310 (diff)
downloadtk-e52422e60cb9265936b53ae27a0ee159416221db.zip
tk-e52422e60cb9265936b53ae27a0ee159416221db.tar.gz
tk-e52422e60cb9265936b53ae27a0ee159416221db.tar.bz2
Add update idletasks for the text. Replace non-BMP characters by 0xfffd when pasting.
-rw-r--r--library/text.tcl7
-rw-r--r--macosx/tkMacOSXClipboard.c23
2 files changed, 26 insertions, 4 deletions
diff --git a/library/text.tcl b/library/text.tcl
index 7525588..c4e3388 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -403,11 +403,13 @@ bind Text <<TkStartIMEMarkedText>> {
dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
}
bind Text <<TkEndIMEMarkedText>> {
- %W tag add IMEmarkedtext [dict get $::tk::Priv(IMETextMark) "%W"] insert
+ %W tag add IMEmarkedtext [dict get $::tk::Priv(IMETextMark) "%W"] insert
%W tag configure IMEmarkedtext -underline on
+ update idletasks
}
bind Text <<TkClearIMEMarkedText>> {
- %W delete IMEmarkedtext.first IMEmarkedtext.last
+ %W delete IMEmarkedtext.first IMEmarkedtext.last
+ update idletasks
}
# Macintosh only bindings:
@@ -1226,4 +1228,3 @@ proc ::tk::TextScanDrag {w x y} {
$w scan dragto $x $y
}
}
-
diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c
index 6cbcdf6..116525f 100644
--- a/macosx/tkMacOSXClipboard.c
+++ b/macosx/tkMacOSXClipboard.c
@@ -130,6 +130,7 @@ TkSelGetSelection(
&& selection == dispPtr->clipboardAtom
&& (target == XA_STRING || target == dispPtr->utf8Atom)) {
NSString *string = nil;
+ NSString *clean;
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject:
NSStringPboardType]];
@@ -137,7 +138,27 @@ TkSelGetSelection(
if (type) {
string = [pb stringForType:type];
}
- result = proc(clientData, interp, string ? [string UTF8String] : "");
+ if (string) {
+ /*
+ * Replace all non-BMP characters by the replacement character 0xfffd.
+ * This is a workaround until Tcl supports TCL_UTF_MAX > 3.
+ */
+ int i, j, len = [string length];
+ CFRange all = CFRangeMake(0, len);
+ UniChar *buffer = ckalloc(len*sizeof(UniChar));
+ CFStringGetCharacters((CFStringRef) string, all, buffer);
+ for (i = 0, j = 0 ; j < len ; i++, j++) {
+ if (CFStringIsSurrogateHighCharacter(buffer[j])) {
+ buffer[i] = 0xfffd;
+ j++;
+ } else {
+ buffer[i] = buffer[j];
+ }
+ }
+ clean = (NSString *)CFStringCreateWithCharacters(NULL, buffer, i);
+ ckfree(buffer);
+ }
+ result = proc(clientData, interp, [clean UTF8String]);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s selection doesn't exist or form \"%s\" not defined",