Tk Source Code

Check-in [43e89771]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add update idletasks for the text. Replace non-BMP characters by 0xfffd when pasting.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-39de9677aa
Files: files | file ages | folders
SHA3-256: 43e89771798465bfee04ace7658df72f2054905c942183c636940a04dd5de526
User & Date: culler 2019-10-23 03:43:42
References
2019-11-11
01:04 Ticket [00a27923] text/entry dysfunctional when pasting an emoji on MacOSX status still Open with 3 other changes artifact: ba8b5eba user: chrstphrchvz
00:58 Ticket [a1795648] Tk 8.6: prevent issues when encountering non-BMP Unicode characters status still Open with 3 other changes artifact: 0f033744 user: chrstphrchvz
2019-10-25
02:02 Ticket [92b887ca] Aqua: certain keys do not repeat when held status still Open with 4 other changes artifact: 8c64177a user: marc_culler
Context
2019-10-23
21:52
Rework and simplify services so the TkService object won't interfere with IME. It didn't need to be a subclass of NSView, or be in the Responder chain. check-in: e21c087a user: culler tags: bug-39de9677aa
03:43
Add update idletasks for the text. Replace non-BMP characters by 0xfffd when pasting. check-in: 43e89771 user: culler tags: bug-39de9677aa
01:20
Add IME bindings for ttk::entry. check-in: e48b918d user: culler tags: bug-39de9677aa
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to library/text.tcl.

399
400
401
402
403
404
405
406
407

408
409
410

411
412
413
414
415
416
417

# Bindings for IME text input.

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 configure IMEmarkedtext -underline on

}
bind Text <<TkClearIMEMarkedText>> {
    %W delete IMEmarkedtext.first IMEmarkedtext.last    

}

# Macintosh only bindings:

if {[tk windowingsystem] eq "aqua"} {
bind Text <Control-v> {
    tk::TextScrollPages %W 1







|

>


|
>







399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419

# Bindings for IME text input.

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 configure IMEmarkedtext -underline on
    update idletasks
}
bind Text <<TkClearIMEMarkedText>> {
    %W delete IMEmarkedtext.first IMEmarkedtext.last
    update idletasks
}

# Macintosh only bindings:

if {[tk windowingsystem] eq "aqua"} {
bind Text <Control-v> {
    tk::TextScrollPages %W 1
1222
1223
1224
1225
1226
1227
1228
1229
    if {($x != $Priv(x)) || ($y != $Priv(y))} {
	set Priv(mouseMoved) 1
    }
    if {[info exists Priv(mouseMoved)] && $Priv(mouseMoved)} {
	$w scan dragto $x $y
    }
}








<
1224
1225
1226
1227
1228
1229
1230

    if {($x != $Priv(x)) || ($y != $Priv(y))} {
	set Priv(mouseMoved) 1
    }
    if {[info exists Priv(mouseMoved)] && $Priv(mouseMoved)} {
	$w scan dragto $x $y
    }
}

Changes to macosx/tkMacOSXClipboard.c.

126
127
128
129
130
131
132

133
134
135
136
137
138
139




















140
141
142
143
144
145
146
147
    int haveExternalClip =
	    ([[NSPasteboard generalPasteboard] changeCount] != changeCount);

    if (dispPtr && (haveExternalClip || dispPtr->clipboardActive)
	        && selection == dispPtr->clipboardAtom
	        && (target == XA_STRING || target == dispPtr->utf8Atom)) {
	NSString *string = nil;

	NSPasteboard *pb = [NSPasteboard generalPasteboard];
	NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject:
		NSStringPboardType]];

	if (type) {
	    string = [pb stringForType:type];
	}




















	result = proc(clientData, interp, string ? [string UTF8String] : "");
    } else {
	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
		"%s selection doesn't exist or form \"%s\" not defined",
		Tk_GetAtomName(tkwin, selection),
		Tk_GetAtomName(tkwin, target)));
	Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL);
    }







>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
    int haveExternalClip =
	    ([[NSPasteboard generalPasteboard] changeCount] != changeCount);

    if (dispPtr && (haveExternalClip || dispPtr->clipboardActive)
	        && 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]];

	if (type) {
	    string = [pb stringForType:type];
	}
	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",
		Tk_GetAtomName(tkwin, selection),
		Tk_GetAtomName(tkwin, target)));
	Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL);
    }