From ae5a551ea90e295489c9b93879ddd911615e0536 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 19 Nov 2015 21:41:31 +0000 Subject: Code Formatting --- generic/tkText.c | 54 ++++++++++++++++++++++++++-------------------------- generic/tkText.h | 2 +- generic/tkTextDisp.c | 14 ++++++++------ 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 9cae716..15c6e73 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -1508,36 +1508,36 @@ TextWidgetObjCmd( 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); + 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); } - Tcl_IncrRefCount(cmd); - if (TkTextPendingyupdate(textPtr)) { - if (textPtr->linesUpdatedCmd) { - Tcl_DecrRefCount(textPtr->linesUpdatedCmd); - } - textPtr->linesUpdatedCmd = cmd; - } else { + 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->linesUpdatedCmd) { - Tcl_DecrRefCount(textPtr->linesUpdatedCmd); } - textPtr->linesUpdatedCmd = NULL; - TkTextUpdateLineMetrics(textPtr, 1, - TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1); + 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: @@ -2016,9 +2016,9 @@ DestroyText( textPtr->tkwin = NULL; textPtr->refCount--; Tcl_DeleteCommandFromToken(textPtr->interp, textPtr->widgetCmd); - if (textPtr->linesUpdatedCmd != 0){ - Tcl_DecrRefCount(textPtr->linesUpdatedCmd); - textPtr->linesUpdatedCmd = 0; + if (textPtr->afterSyncCmd != 0){ + Tcl_DecrRefCount(textPtr->afterSyncCmd); + textPtr->afterSyncCmd = 0; } if (textPtr->refCount == 0) { ckfree((char *) textPtr); diff --git a/generic/tkText.h b/generic/tkText.h index 192ab12..2aa8d59 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -782,7 +782,7 @@ typedef struct TkText { * 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 */ + Tcl_Obj *afterSyncCmd; /* Command to be executed when lines are up to date */ } TkText; /* diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index d31d2f3..a18e2b9 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -2945,15 +2945,17 @@ AsyncUpdateLineMetrics( * 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 + 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_Release((ClientData)textPtr->interp); + Tcl_DecrRefCount(textPtr->afterSyncCmd); + textPtr->afterSyncCmd = 0; } textPtr->refCount--; -- cgit v0.12