Tk Source Code

Check-in [70ea2f72]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:better argument checking
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-438
Files: files | file ages | folders
SHA1: 70ea2f724cdcda78663a5e3887aa053092344056
User & Date: jan.nijtmans 2015-11-19 21:04:08
Context
2015-11-19
21:41
Code Formatting check-in: 52465dd9 user: jan.nijtmans tags: tip-438
21:04
better argument checking check-in: 70ea2f72 user: jan.nijtmans tags: tip-438
20:46
First test-implementation of "$t yupdate -command <command>". TODO: more testcases and documentation check-in: 602f9502 user: jan.nijtmans tags: tip-438
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkText.c.

1504
1505
1506
1507
1508
1509
1510
1511
1512






1513
1514
1515
1516
1517
1518
1519
    case TEXT_WINDOW:
	result = TkTextWindowCmd(textPtr, interp, objc, objv);
	break;
    case TEXT_XVIEW:
	result = TkTextXviewCmd(textPtr, interp, objc, objv);
	break;
    case TEXT_YUPDATE: {
	    if ((objc == 4) && !strncmp(Tcl_GetString(objv[2]), "-command", objv[3]->length)) {
		    Tcl_Obj *cmd = objv[3];






		    Tcl_IncrRefCount(cmd);
		    if (TkTextPendingyupdate(textPtr)) {
			if (textPtr->linesUpdatedCmd) {
			    Tcl_DecrRefCount(textPtr->linesUpdatedCmd);
			}
			textPtr->linesUpdatedCmd = cmd;
		    } else {






|

>
>
>
>
>
>







1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
    case TEXT_WINDOW:
	result = TkTextWindowCmd(textPtr, interp, objc, objv);
	break;
    case TEXT_XVIEW:
	result = TkTextXviewCmd(textPtr, interp, objc, objv);
	break;
    case TEXT_YUPDATE: {
	    if (objc == 4) {
		    Tcl_Obj *cmd = objv[3];
		    const char *option = Tcl_GetString(objv[2]);
		    if (strncmp(option, "-command", objv[2]->length)) {
			Tcl_AppendResult(interp, "wrong option \"", option, "\": should be \"-command\"", NULL);
		    result = TCL_ERROR;
		    goto done;
		    }
		    Tcl_IncrRefCount(cmd);
		    if (TkTextPendingyupdate(textPtr)) {
			if (textPtr->linesUpdatedCmd) {
			    Tcl_DecrRefCount(textPtr->linesUpdatedCmd);
			}
			textPtr->linesUpdatedCmd = cmd;
		    } else {

Changes to tests/textDisp.test.

4197
4198
4199
4200
4201
4202
4203








4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
    .t1 yupdate foo
} -cleanup {
    destroy .t1
} -returnCodes 1 -result {wrong # args: should be ".t1 yupdate ?-command command?"}

test textDisp-34.3 {text yupdate syntax} -body {
} -body {








    set ::x 0
    pack [text .t1] -expand 1 -fill both
    .t1 yupdate -command [list set ::x 1]
    set ::x
} -cleanup {
    destroy .t1
} -result {1}

deleteWindows
option clear

# cleanup
cleanupTests
return






>
>
>
>
>
>
>
>


|











4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
    .t1 yupdate foo
} -cleanup {
    destroy .t1
} -returnCodes 1 -result {wrong # args: should be ".t1 yupdate ?-command command?"}

test textDisp-34.3 {text yupdate syntax} -body {
} -body {
    pack [text .t1] -expand 1 -fill both
    .t1 yupdate -comx foo
} -cleanup {
    destroy .t1
} -returnCodes 1 -result {wrong option "-comx": should be "-command"}

test textDisp-34.4 {text yupdate syntax} -body {
} -body {
    set ::x 0
    pack [text .t1] -expand 1 -fill both
    .t1 yupdate -comm [list set ::x 1]
    set ::x
} -cleanup {
    destroy .t1
} -result {1}

deleteWindows
option clear

# cleanup
cleanupTests
return