Tk Source Code

Check-in [52465dd9]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

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

Overview
Comment:Code Formatting
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-438
Files: files | file ages | folders
SHA1:52465dd9bed43b74c50544b18a7500870a390c68
User & Date: jan.nijtmans 2015-11-19 21:41:31
Context
2015-11-19
21:57
Make it compile with Visual 2008 check-in: a6d84c73 user: fvogel tags: tip-438
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
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
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
....
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
    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 {
			result = Tcl_EvalObjEx(interp, cmd, TCL_EVAL_GLOBAL);
			Tcl_DecrRefCount(cmd);
		    }
		    break;
		} else if (objc != 2) {
		    Tcl_WrongNumArgs(interp, 2, objv, "?-command command?");
		    result = TCL_ERROR;
		    goto done;
		}
		if (textPtr->linesUpdatedCmd) {
		    Tcl_DecrRefCount(textPtr->linesUpdatedCmd);
		}
		textPtr->linesUpdatedCmd = NULL;
		TkTextUpdateLineMetrics(textPtr, 1,
			TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1);
	break;
    }
    case TEXT_YVIEW:
	result = TkTextYviewCmd(textPtr, interp, objc, objv);
	break;
    }

................................................................................
    if (textPtr->insertBlinkHandler != NULL) {
	Tcl_DeleteTimerHandler(textPtr->insertBlinkHandler);
    }

    textPtr->tkwin = NULL;
    textPtr->refCount--;
    Tcl_DeleteCommandFromToken(textPtr->interp, textPtr->widgetCmd);
    if (textPtr->linesUpdatedCmd != 0){
	Tcl_DecrRefCount(textPtr->linesUpdatedCmd);
	textPtr->linesUpdatedCmd = 0;
    }
    if (textPtr->refCount == 0) {
	ckfree((char *) textPtr);
    }
}
 
/*







|
|
|
|
|


|
|
|
|
|
|
|
|


|
|
|
|
|
|
|
|
|
|
|
|
|







 







|
|
|







1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
....
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
    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->afterSyncCmd) {
			Tcl_DecrRefCount(textPtr->afterSyncCmd);
		    }
			textPtr->afterSyncCmd = cmd;
		} else {
			result = Tcl_EvalObjEx(interp, cmd, TCL_EVAL_GLOBAL);
			Tcl_DecrRefCount(cmd);
		}
		break;
	} else if (objc != 2) {
		Tcl_WrongNumArgs(interp, 2, objv, "?-command command?");
		result = TCL_ERROR;
		goto done;
	}
	if (textPtr->afterSyncCmd) {
		Tcl_DecrRefCount(textPtr->afterSyncCmd);
	}
	textPtr->afterSyncCmd = NULL;
	TkTextUpdateLineMetrics(textPtr, 1,
		TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1);
	break;
    }
    case TEXT_YVIEW:
	result = TkTextYviewCmd(textPtr, interp, objc, objv);
	break;
    }

................................................................................
    if (textPtr->insertBlinkHandler != NULL) {
	Tcl_DeleteTimerHandler(textPtr->insertBlinkHandler);
    }

    textPtr->tkwin = NULL;
    textPtr->refCount--;
    Tcl_DeleteCommandFromToken(textPtr->interp, textPtr->widgetCmd);
    if (textPtr->afterSyncCmd != 0){
	Tcl_DecrRefCount(textPtr->afterSyncCmd);
	textPtr->afterSyncCmd = 0;
    }
    if (textPtr->refCount == 0) {
	ckfree((char *) textPtr);
    }
}
 
/*

Changes to generic/tkText.h.

778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
    int undo;			/* Non-zero means the undo/redo behaviour is
				 * enabled. */
    int maxUndo;		/* The maximum depth of the undo stack
				 * expressed as the maximum number of compound
				 * statements. */
    int autoSeparators;		/* Non-zero means the separators will be
				 * inserted automatically. */
    Tcl_Obj *linesUpdatedCmd; /* Command to be executed when lines are up to date */
} TkText;

/*
 * Flag values for TkText records:
 *
 * GOT_SELECTION:		Non-zero means we've already claimed the
 *				selection.







|







778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
    int undo;			/* Non-zero means the undo/redo behaviour is
				 * enabled. */
    int maxUndo;		/* The maximum depth of the undo stack
				 * expressed as the maximum number of compound
				 * statements. */
    int autoSeparators;		/* Non-zero means the separators will be
				 * inserted automatically. */
    Tcl_Obj *afterSyncCmd;	/* Command to be executed when lines are up to date */
} TkText;

/*
 * Flag values for TkText records:
 *
 * GOT_SELECTION:		Non-zero means we've already claimed the
 *				selection.

Changes to generic/tkTextDisp.c.

2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956


2957
2958
2959
2960
2961
2962
2963
	    && lineNum == dInfoPtr->lastMetricUpdateLine) {
	/*
	 * We have looped over all lines, so we're done. We must release our
	 * refCount on the widget (the timer token was already set to NULL
	 * above). If there is a registered command, run that first.
	 */

	if (textPtr->linesUpdatedCmd != NULL) {
		Tcl_Preserve((ClientData)textPtr->interp);
	    int code = Tcl_EvalObjEx(textPtr->interp, textPtr->linesUpdatedCmd, TCL_EVAL_GLOBAL);
		if (code != TCL_OK && code != TCL_CONTINUE
			&& code != TCL_BREAK) {
		    Tcl_AddErrorInfo(textPtr->interp, "\n    (text yupdate)");
		    Tcl_BackgroundError(textPtr->interp);
		}
		Tcl_Release((ClientData)textPtr->interp);


	}

	textPtr->refCount--;
	if (textPtr->refCount == 0) {
	    ckfree((char *) textPtr);
	}
	return;







|
|
|
|



|
|
>
>







2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
	    && lineNum == dInfoPtr->lastMetricUpdateLine) {
	/*
	 * We have looped over all lines, so we're done. We must release our
	 * refCount on the widget (the timer token was already set to NULL
	 * above). If there is a registered command, run that first.
	 */

	if (textPtr->afterSyncCmd != NULL) {
	    Tcl_Preserve((ClientData)textPtr->interp);
	    int code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL);
	    if (code != TCL_OK && code != TCL_CONTINUE
			&& code != TCL_BREAK) {
		    Tcl_AddErrorInfo(textPtr->interp, "\n    (text yupdate)");
		    Tcl_BackgroundError(textPtr->interp);
	    }
	    Tcl_Release((ClientData)textPtr->interp);
	    Tcl_DecrRefCount(textPtr->afterSyncCmd);
	    textPtr->afterSyncCmd = 0;
	}

	textPtr->refCount--;
	if (textPtr->refCount == 0) {
	    ckfree((char *) textPtr);
	}
	return;