From eb3fa653566d6bf130804d7d800f960d72819597 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Jun 2016 21:04:51 +0000 Subject: Possible solution for [1217222] - [.text edit undo/redo] return ranges of modified characters --- generic/tkText.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/generic/tkText.c b/generic/tkText.c index b610844..d101364 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2781,6 +2781,7 @@ TextPushUndoAction( Tcl_Obj *markSet2InsertObj = NULL; Tcl_Obj *insertCmdObj = Tcl_NewObj(); Tcl_Obj *deleteCmdObj = Tcl_NewObj(); + Tcl_Obj *returnCmdObj = Tcl_NewObj(); /* * Get the index positions. @@ -2830,6 +2831,11 @@ TextPushUndoAction( Tcl_ListObjAppendElement(NULL, deleteCmdObj, index1Obj); Tcl_ListObjAppendElement(NULL, deleteCmdObj, index2Obj); + Tcl_ListObjAppendElement(NULL, returnCmdObj, + Tcl_NewStringObj("list", 4)); + Tcl_ListObjAppendElement(NULL, returnCmdObj, index1Obj); + Tcl_ListObjAppendElement(NULL, returnCmdObj, index2Obj); + /* * Note: we don't wish to use textPtr->widgetCmd in these callbacks * because if we delete the textPtr, but peers still exist, we will then @@ -2847,11 +2853,13 @@ TextPushUndoAction( insertCmdObj, NULL); TkUndoMakeCmdSubAtom(NULL, markSet2InsertObj, iAtom); TkUndoMakeCmdSubAtom(NULL, seeInsertObj, iAtom); + TkUndoMakeCmdSubAtom(NULL, returnCmdObj, iAtom); dAtom = TkUndoMakeSubAtom(&TextUndoRedoCallback, textPtr->sharedTextPtr, deleteCmdObj, NULL); TkUndoMakeCmdSubAtom(NULL, markSet1InsertObj, dAtom); TkUndoMakeCmdSubAtom(NULL, seeInsertObj, dAtom); + TkUndoMakeCmdSubAtom(NULL, returnCmdObj, dAtom); Tcl_DecrRefCount(seeInsertObj); Tcl_DecrRefCount(index1Obj); -- cgit v0.12 From 940954ce6034eac3de51350f4d546ed7279e7ec9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 8 Jun 2016 08:34:52 +0000 Subject: Updated documentation regarding return values for [.text edit undo/redo] --- doc/text.n | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/text.n b/doc/text.n index e2bb01f..9633e37 100644 --- a/doc/text.n +++ b/doc/text.n @@ -1305,8 +1305,9 @@ of the widget to \fIboolean\fR. \fIpathName \fBedit redo\fR . When the \fB\-undo\fR option is true, reapplies the last undone edits provided -no other edits were done since then. Generates an error when the redo stack is -empty. Does nothing when the \fB\-undo\fR option is false. +no other edits were done since then, and returns a list of indices indicating +what ranges were changed by the redo operation. Generates an error when the +redo stack is empty. Does nothing when the \fB\-undo\fR option is false. .TP \fIpathName \fBedit reset\fR . @@ -1319,9 +1320,10 @@ Inserts a separator (boundary) on the undo stack. Does nothing when the .TP \fIpathName \fBedit undo\fR . -Undoes the last edit action when the \fB\-undo\fR option is true. An edit -action is defined as all the insert and delete commands that are recorded on -the undo stack in between two separators. Generates an error when the undo +Undoes the last edit action when the \fB\-undo\fR option is true, and returns a +list of indices indicating what ranges were changed by the undo operation. An +edit action is defined as all the insert and delete commands that are recorded +on the undo stack in between two separators. Generates an error when the undo stack is empty. Does nothing when the \fB\-undo\fR option is false. .RE .TP -- cgit v0.12 From abdebd5b836480c1552c478a871c77b4668135ed Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 8 Jun 2016 09:38:29 +0000 Subject: It is not possible to rely only on the interp result. A list of indices has to be built as a return value to undo/redo because there can be several edits between two separators and all such edits have to report which range of text they changed. Note: this commit does not deal with refcounts, it is very likely wrong in that respect. --- generic/tkText.c | 31 +++++++++++++++++++------------ generic/tkUndo.c | 26 ++++++++++++++++++++++---- generic/tkUndo.h | 4 ++-- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index d101364..60e726f 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -395,8 +395,8 @@ static int DumpSegment(TkText *textPtr, Tcl_Interp *interp, const char *key, const char *value, Tcl_Obj *command, const TkTextIndex *index, int what); -static int TextEditUndo(TkText *textPtr); -static int TextEditRedo(TkText *textPtr); +static int TextEditUndo(TkText *textPtr, Tcl_Obj *rangesObj); +static int TextEditRedo(TkText *textPtr, Tcl_Obj *rangesObj); static Tcl_Obj * TextGetText(const TkText *textPtr, const TkTextIndex *index1, const TkTextIndex *index2, int visibleOnly); @@ -5060,7 +5060,7 @@ DumpSegment( * Undo the last change. * * Results: - * None. + * The ranges of text that were changed by the undo operation. * * Side effects: * Apart from manipulating the undo and redo stacks, the state of the @@ -5071,7 +5071,8 @@ DumpSegment( static int TextEditUndo( - TkText *textPtr) /* Overall information about text widget. */ + TkText *textPtr, /* Overall information about text widget. */ + Tcl_Obj *rangesObj) /* Ranges of text that were changed. */ { int status; @@ -5090,7 +5091,7 @@ TextEditUndo( textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_UNDO; } - status = TkUndoRevert(textPtr->sharedTextPtr->undoStack); + status = TkUndoRevert(textPtr->sharedTextPtr->undoStack, rangesObj); if (textPtr->sharedTextPtr->dirtyMode != TK_TEXT_DIRTY_FIXED) { textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; @@ -5108,7 +5109,7 @@ TextEditUndo( * Redo the last undone change. * * Results: - * None. + * The ranges of text that were changed by the undo operation. * * Side effects: * Apart from manipulating the undo and redo stacks, the state of the @@ -5119,7 +5120,8 @@ TextEditUndo( static int TextEditRedo( - TkText *textPtr) /* Overall information about text widget. */ + TkText *textPtr, /* Overall information about text widget. */ + Tcl_Obj *rangesObj) /* Ranges of text that were changed. */ { int status; @@ -5138,7 +5140,7 @@ TextEditRedo( textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_REDO; } - status = TkUndoApply(textPtr->sharedTextPtr->undoStack); + status = TkUndoApply(textPtr->sharedTextPtr->undoStack, rangesObj); if (textPtr->sharedTextPtr->dirtyMode != TK_TEXT_DIRTY_FIXED) { textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; @@ -5174,6 +5176,7 @@ TextEditCmd( int index, setModified, oldModified; int canRedo = 0; int canUndo = 0; + Tcl_Obj *rangesObj = Tcl_NewObj(); static const char *const editOptionStrings[] = { "canundo", "canredo", "modified", "redo", "reset", "separator", @@ -5257,11 +5260,13 @@ TextEditCmd( return TCL_ERROR; } canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); - if (TextEditRedo(textPtr)) { + if (TextEditRedo(textPtr, rangesObj)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to redo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", NULL); return TCL_ERROR; - } + } else { + Tcl_SetObjResult(interp, rangesObj); + } canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); if (!canUndo || !canRedo) { GenerateUndoStackEvent(textPtr); @@ -5292,11 +5297,13 @@ TextEditCmd( return TCL_ERROR; } canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); - if (TextEditUndo(textPtr)) { + if (TextEditUndo(textPtr, rangesObj)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL); return TCL_ERROR; - } + } else { + Tcl_SetObjResult(interp, rangesObj); + } canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); if (!canRedo || !canUndo) { GenerateUndoStackEvent(textPtr); diff --git a/generic/tkUndo.c b/generic/tkUndo.c index c66905d..f364326 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -556,7 +556,8 @@ TkUndoInsertUndoSeparator( * Undo a compound action on the stack. * * Results: - * A Tcl status code + * A Tcl status code. Also, the passed Tcl_(List)Obj is appended by the + * interp results from evaluation of each element of the undo stack. * * Side effects: * None. @@ -566,7 +567,8 @@ TkUndoInsertUndoSeparator( int TkUndoRevert( - TkUndoRedoStack *stack) + TkUndoRedoStack *stack, + Tcl_Obj *retObj) { TkUndoAtom *elem; @@ -598,6 +600,13 @@ TkUndoRevert( EvaluateActionList(stack->interp, elem->revert); + /* + * The interp result is appended to the returned object for each + * element of the undo stack (not for each sub-atom). + */ + + Tcl_ListObjAppendList(NULL, retObj, Tcl_GetObjResult(stack->interp)); + TkUndoPushStack(&stack->redoStack, elem); elem = TkUndoPopStack(&stack->undoStack); } @@ -619,7 +628,8 @@ TkUndoRevert( * Redo a compound action on the stack. * * Results: - * A Tcl status code + * A Tcl status code. Also, the passed Tcl_(List)Obj is appended by the + * interp results from evaluation of each element of the redo stack. * * Side effects: * None. @@ -629,7 +639,8 @@ TkUndoRevert( int TkUndoApply( - TkUndoRedoStack *stack) + TkUndoRedoStack *stack, + Tcl_Obj *retObj) { TkUndoAtom *elem; @@ -660,6 +671,13 @@ TkUndoApply( EvaluateActionList(stack->interp, elem->apply); + /* + * The interp result is appended to the returned object for each + * element of the redo stack (not for each sub-atom). + */ + + Tcl_ListObjAppendList(NULL, retObj, Tcl_GetObjResult(stack->interp)); + TkUndoPushStack(&stack->undoStack, elem); elem = TkUndoPopStack(&stack->redoStack); } diff --git a/generic/tkUndo.h b/generic/tkUndo.h index 490ede9..505e0f0 100644 --- a/generic/tkUndo.h +++ b/generic/tkUndo.h @@ -109,7 +109,7 @@ MODULE_SCOPE TkUndoSubAtom *TkUndoMakeSubAtom(TkUndoProc *funcPtr, TkUndoSubAtom *subAtomList); MODULE_SCOPE void TkUndoPushAction(TkUndoRedoStack *stack, TkUndoSubAtom *apply, TkUndoSubAtom *revert); -MODULE_SCOPE int TkUndoRevert(TkUndoRedoStack *stack); -MODULE_SCOPE int TkUndoApply(TkUndoRedoStack *stack); +MODULE_SCOPE int TkUndoRevert(TkUndoRedoStack *stack, Tcl_Obj *retObj); +MODULE_SCOPE int TkUndoApply(TkUndoRedoStack *stack, Tcl_Obj *retObj); #endif /* _TKUNDO */ -- cgit v0.12 From d60b9e28ecea5421fcb384737837748d9cd677df Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 8 Jun 2016 13:23:22 +0000 Subject: Added test case text-27.26 for [.text edit undo/redo] return values --- tests/text.test | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/text.test b/tests/text.test index 0ec69d0..abbcfe5 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6562,6 +6562,36 @@ test text-27.25 {<> virtual event} -setup { } -cleanup { destroy .t } -result {0 0 1 2 3 4 4 5 6 6 7 8 8 9} +test text-27.26 {edit undo and edit redo return ranges} -setup { + destroy .t + set res {} +} -body { + text .t -undo true -autoseparators false + .t insert end "Hello " + .t edit separator + .t insert end "World!\n" + .t insert 1.6 "GREAT " + .t insert end "Another edit here!!" + lappend res [.t edit undo] + lappend res [.t edit redo] + .t edit separator + .t delete 1.6 + .t delete 1.9 1.10 + .t insert 1.9 L + lappend res [.t edit undo] + lappend res [.t edit redo] + .t replace 1.6 1.10 Tcl/Tk + .t replace 2.8 2.12 "one bites the dust" + lappend res [.t edit undo] + lappend res [.t edit redo] +} -cleanup { + destroy .t +} -result [list {2.0 2.19 1.6 1.12 1.6 2.0} \ + {1.6 2.0 1.6 1.12 2.0 2.19} \ + {1.9 1.10 1.9 1.10 1.6 1.7} \ + {1.6 1.7 1.9 1.10 1.9 1.10} \ + {2.8 2.26 2.8 2.12 1.6 1.12 1.6 1.10} \ + {1.6 1.10 1.6 1.12 2.8 2.12 2.8 2.26} ] test text-28.1 {bug fix - 624372, ControlUtfProc long lines} -body { -- cgit v0.12 From 77f4d07ef5cfb838fee58aeadf50fa3d948d273d Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 4 Jul 2016 21:26:53 +0000 Subject: Return indices making sense at undo/redo return time. The returned ranges are optimized (no duplicates, no overlapping ranges). Works but needs polishing. --- generic/tkText.c | 124 +++++++++++++++++++++++++++++++++++++++++++------------ generic/tkUndo.c | 26 ++---------- generic/tkUndo.h | 4 +- library/text.tcl | 67 ++++++++++++++++++++++++++++++ 4 files changed, 171 insertions(+), 50 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 8698825..f34b221 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -398,8 +398,8 @@ static int DumpSegment(TkText *textPtr, Tcl_Interp *interp, const char *key, const char *value, Tcl_Obj *command, const TkTextIndex *index, int what); -static int TextEditUndo(TkText *textPtr, Tcl_Obj *rangesObj); -static int TextEditRedo(TkText *textPtr, Tcl_Obj *rangesObj); +static int TextEditUndo(TkText *textPtr); +static int TextEditRedo(TkText *textPtr); static Tcl_Obj * TextGetText(const TkText *textPtr, const TkTextIndex *index1, const TkTextIndex *index2, int visibleOnly); @@ -2774,6 +2774,10 @@ TextPushUndoAction( { TkUndoSubAtom *iAtom, *dAtom; int canUndo, canRedo; + static int undoMarkId = -1; + char lMarkName[20] = "tk::undoMarkL"; + char rMarkName[20] = "tk::undoMarkR"; + char stringUndoMarkId[7] = ""; /* * Create the helpers. @@ -2784,7 +2788,10 @@ TextPushUndoAction( Tcl_Obj *markSet2InsertObj = NULL; Tcl_Obj *insertCmdObj = Tcl_NewObj(); Tcl_Obj *deleteCmdObj = Tcl_NewObj(); - Tcl_Obj *returnCmdObj = Tcl_NewObj(); + Tcl_Obj *markSetLUndoMarkCmdObj = Tcl_NewObj(); + Tcl_Obj *markSetRUndoMarkCmdObj = NULL; + Tcl_Obj *markGravityLUndoMarkCmdObj = Tcl_NewObj(); + Tcl_Obj *markGravityRUndoMarkCmdObj = NULL; /* * Get the index positions. @@ -2834,10 +2841,39 @@ TextPushUndoAction( Tcl_ListObjAppendElement(NULL, deleteCmdObj, index1Obj); Tcl_ListObjAppendElement(NULL, deleteCmdObj, index2Obj); - Tcl_ListObjAppendElement(NULL, returnCmdObj, - Tcl_NewStringObj("list", 4)); - Tcl_ListObjAppendElement(NULL, returnCmdObj, index1Obj); - Tcl_ListObjAppendElement(NULL, returnCmdObj, index2Obj); + Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj, + Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), -1)); + Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj, + Tcl_NewStringObj("mark", 4)); + Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj, + Tcl_NewStringObj("set", 3)); + markSetRUndoMarkCmdObj = Tcl_DuplicateObj(markSetLUndoMarkCmdObj); + undoMarkId++; + sprintf(stringUndoMarkId, "%d", undoMarkId); + strcat(lMarkName, stringUndoMarkId); + strcat(rMarkName, stringUndoMarkId); + Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj, + Tcl_NewStringObj(lMarkName, -1)); + Tcl_ListObjAppendElement(NULL, markSetRUndoMarkCmdObj, + Tcl_NewStringObj(rMarkName, -1)); + Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj, index1Obj); + Tcl_ListObjAppendElement(NULL, markSetRUndoMarkCmdObj, index2Obj); + + Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj, + Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), -1)); + Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj, + Tcl_NewStringObj("mark", 4)); + Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj, + Tcl_NewStringObj("gravity", 7)); + markGravityRUndoMarkCmdObj = Tcl_DuplicateObj(markGravityLUndoMarkCmdObj); + Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj, + Tcl_NewStringObj(lMarkName, -1)); + Tcl_ListObjAppendElement(NULL, markGravityRUndoMarkCmdObj, + Tcl_NewStringObj(rMarkName, -1)); + Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj, + Tcl_NewStringObj("left", 4)); + Tcl_ListObjAppendElement(NULL, markGravityRUndoMarkCmdObj, + Tcl_NewStringObj("right", 5)); /* * Note: we don't wish to use textPtr->widgetCmd in these callbacks @@ -2856,13 +2892,19 @@ TextPushUndoAction( insertCmdObj, NULL); TkUndoMakeCmdSubAtom(NULL, markSet2InsertObj, iAtom); TkUndoMakeCmdSubAtom(NULL, seeInsertObj, iAtom); - TkUndoMakeCmdSubAtom(NULL, returnCmdObj, iAtom); + TkUndoMakeCmdSubAtom(NULL, markSetLUndoMarkCmdObj, iAtom); + TkUndoMakeCmdSubAtom(NULL, markSetRUndoMarkCmdObj, iAtom); + TkUndoMakeCmdSubAtom(NULL, markGravityLUndoMarkCmdObj, iAtom); + TkUndoMakeCmdSubAtom(NULL, markGravityRUndoMarkCmdObj, iAtom); dAtom = TkUndoMakeSubAtom(&TextUndoRedoCallback, textPtr->sharedTextPtr, deleteCmdObj, NULL); TkUndoMakeCmdSubAtom(NULL, markSet1InsertObj, dAtom); TkUndoMakeCmdSubAtom(NULL, seeInsertObj, dAtom); - TkUndoMakeCmdSubAtom(NULL, returnCmdObj, dAtom); + TkUndoMakeCmdSubAtom(NULL, markSetLUndoMarkCmdObj, dAtom); + TkUndoMakeCmdSubAtom(NULL, markSetRUndoMarkCmdObj, dAtom); + TkUndoMakeCmdSubAtom(NULL, markGravityLUndoMarkCmdObj, dAtom); + TkUndoMakeCmdSubAtom(NULL, markGravityRUndoMarkCmdObj, dAtom); Tcl_DecrRefCount(seeInsertObj); Tcl_DecrRefCount(index1Obj); @@ -5063,7 +5105,7 @@ DumpSegment( * Undo the last change. * * Results: - * The ranges of text that were changed by the undo operation. + * None. * * Side effects: * Apart from manipulating the undo and redo stacks, the state of the @@ -5074,10 +5116,11 @@ DumpSegment( static int TextEditUndo( - TkText *textPtr, /* Overall information about text widget. */ - Tcl_Obj *rangesObj) /* Ranges of text that were changed. */ + TkText *textPtr) /* Overall information about text widget. */ { int status; + Tcl_Obj *cmdObj; + int code; if (!textPtr->sharedTextPtr->undo) { return TCL_OK; @@ -5094,13 +5137,29 @@ TextEditUndo( textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_UNDO; } - status = TkUndoRevert(textPtr->sharedTextPtr->undoStack, rangesObj); + status = TkUndoRevert(textPtr->sharedTextPtr->undoStack); if (textPtr->sharedTextPtr->dirtyMode != TK_TEXT_DIRTY_FIXED) { textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; } textPtr->sharedTextPtr->undo = 1; + /* + * Convert undo/redo temporary marks set by TkUndoRevert() into + * indices left in the interp result. + */ + + cmdObj = Tcl_ObjPrintf("::tk::TextUndoRedoProcessMarks %s", + Tk_PathName(textPtr->tkwin)); + Tcl_IncrRefCount(cmdObj); + code = Tcl_EvalObjEx(textPtr->interp, cmdObj, TCL_EVAL_GLOBAL); + if (code != TCL_OK) { + Tcl_AddErrorInfo(textPtr->interp, + "\n (on undoing)"); + Tcl_BackgroundException(textPtr->interp, code); + } + Tcl_DecrRefCount(cmdObj); + return status; } @@ -5112,7 +5171,7 @@ TextEditUndo( * Redo the last undone change. * * Results: - * The ranges of text that were changed by the undo operation. + * None. * * Side effects: * Apart from manipulating the undo and redo stacks, the state of the @@ -5123,10 +5182,11 @@ TextEditUndo( static int TextEditRedo( - TkText *textPtr, /* Overall information about text widget. */ - Tcl_Obj *rangesObj) /* Ranges of text that were changed. */ + TkText *textPtr) /* Overall information about text widget. */ { int status; + Tcl_Obj *cmdObj; + int code; if (!textPtr->sharedTextPtr->undo) { return TCL_OK; @@ -5143,12 +5203,29 @@ TextEditRedo( textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_REDO; } - status = TkUndoApply(textPtr->sharedTextPtr->undoStack, rangesObj); + status = TkUndoApply(textPtr->sharedTextPtr->undoStack); if (textPtr->sharedTextPtr->dirtyMode != TK_TEXT_DIRTY_FIXED) { textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; } textPtr->sharedTextPtr->undo = 1; + + /* + * Convert undo/redo temporary marks set by TkUndoApply() into + * indices left in the interp result. + */ + + cmdObj = Tcl_ObjPrintf("::tk::TextUndoRedoProcessMarks %s", + Tk_PathName(textPtr->tkwin)); + Tcl_IncrRefCount(cmdObj); + code = Tcl_EvalObjEx(textPtr->interp, cmdObj, TCL_EVAL_GLOBAL); + if (code != TCL_OK) { + Tcl_AddErrorInfo(textPtr->interp, + "\n (on undoing)"); + Tcl_BackgroundException(textPtr->interp, code); + } + Tcl_DecrRefCount(cmdObj); + return status; } @@ -5179,7 +5256,6 @@ TextEditCmd( int index, setModified, oldModified; int canRedo = 0; int canUndo = 0; - Tcl_Obj *rangesObj = Tcl_NewObj(); static const char *const editOptionStrings[] = { "canundo", "canredo", "modified", "redo", "reset", "separator", @@ -5263,13 +5339,11 @@ TextEditCmd( return TCL_ERROR; } canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); - if (TextEditRedo(textPtr, rangesObj)) { + if (TextEditRedo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to redo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", NULL); return TCL_ERROR; - } else { - Tcl_SetObjResult(interp, rangesObj); - } + } canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); if (!canUndo || !canRedo) { GenerateUndoStackEvent(textPtr); @@ -5300,13 +5374,11 @@ TextEditCmd( return TCL_ERROR; } canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); - if (TextEditUndo(textPtr, rangesObj)) { + if (TextEditUndo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL); return TCL_ERROR; - } else { - Tcl_SetObjResult(interp, rangesObj); - } + } canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); if (!canRedo || !canUndo) { GenerateUndoStackEvent(textPtr); diff --git a/generic/tkUndo.c b/generic/tkUndo.c index f364326..c66905d 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -556,8 +556,7 @@ TkUndoInsertUndoSeparator( * Undo a compound action on the stack. * * Results: - * A Tcl status code. Also, the passed Tcl_(List)Obj is appended by the - * interp results from evaluation of each element of the undo stack. + * A Tcl status code * * Side effects: * None. @@ -567,8 +566,7 @@ TkUndoInsertUndoSeparator( int TkUndoRevert( - TkUndoRedoStack *stack, - Tcl_Obj *retObj) + TkUndoRedoStack *stack) { TkUndoAtom *elem; @@ -600,13 +598,6 @@ TkUndoRevert( EvaluateActionList(stack->interp, elem->revert); - /* - * The interp result is appended to the returned object for each - * element of the undo stack (not for each sub-atom). - */ - - Tcl_ListObjAppendList(NULL, retObj, Tcl_GetObjResult(stack->interp)); - TkUndoPushStack(&stack->redoStack, elem); elem = TkUndoPopStack(&stack->undoStack); } @@ -628,8 +619,7 @@ TkUndoRevert( * Redo a compound action on the stack. * * Results: - * A Tcl status code. Also, the passed Tcl_(List)Obj is appended by the - * interp results from evaluation of each element of the redo stack. + * A Tcl status code * * Side effects: * None. @@ -639,8 +629,7 @@ TkUndoRevert( int TkUndoApply( - TkUndoRedoStack *stack, - Tcl_Obj *retObj) + TkUndoRedoStack *stack) { TkUndoAtom *elem; @@ -671,13 +660,6 @@ TkUndoApply( EvaluateActionList(stack->interp, elem->apply); - /* - * The interp result is appended to the returned object for each - * element of the redo stack (not for each sub-atom). - */ - - Tcl_ListObjAppendList(NULL, retObj, Tcl_GetObjResult(stack->interp)); - TkUndoPushStack(&stack->undoStack, elem); elem = TkUndoPopStack(&stack->redoStack); } diff --git a/generic/tkUndo.h b/generic/tkUndo.h index 505e0f0..490ede9 100644 --- a/generic/tkUndo.h +++ b/generic/tkUndo.h @@ -109,7 +109,7 @@ MODULE_SCOPE TkUndoSubAtom *TkUndoMakeSubAtom(TkUndoProc *funcPtr, TkUndoSubAtom *subAtomList); MODULE_SCOPE void TkUndoPushAction(TkUndoRedoStack *stack, TkUndoSubAtom *apply, TkUndoSubAtom *revert); -MODULE_SCOPE int TkUndoRevert(TkUndoRedoStack *stack, Tcl_Obj *retObj); -MODULE_SCOPE int TkUndoApply(TkUndoRedoStack *stack, Tcl_Obj *retObj); +MODULE_SCOPE int TkUndoRevert(TkUndoRedoStack *stack); +MODULE_SCOPE int TkUndoApply(TkUndoRedoStack *stack); #endif /* _TKUNDO */ diff --git a/library/text.tcl b/library/text.tcl index 2bf1b2b..cc78bc2 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -1202,3 +1202,70 @@ proc ::tk::TextScanDrag {w x y} { $w scan dragto $x $y } } + +# ::tk::TextUndoRedoProcessMarks -- +# +# This proc is executed after an undo or redo action. +# It processes the list of undo/redo marks temporarily set in the +# text widget to positions delimiting where changes happened, and +# returns a flat list of ranges. The temporary marks are removed +# from the text widget. +# +# Arguments: +# w - The text widget + +proc ::tk::TextUndoRedoProcessMarks {w} { + set indices {} + set undoMarks {} + # only consider the temporary marks set by an undo/redo action + foreach mark [$w mark names] { + if {[string range $mark 0 11] eq "tk::undoMark"} { + lappend undoMarks $mark + } + } + # the number of undo/redo marks is always even + set nUndoMarks [llength $undoMarks] + set n [expr {$nUndoMarks / 2}] + set undoMarks [lsort -dictionary $undoMarks] + set Lmarks [lrange $undoMarks 0 [expr {$n - 1}]] + set Rmarks [lrange $undoMarks $n [llength $undoMarks]] + foreach Lmark $Lmarks Rmark $Rmarks { + lappend indices [$w index $Lmark] [$w index $Rmark] + $w mark unset $Lmark $Rmark + } +#puts "Unoptimized indices: $indices" + # process ranges to: + # - remove those already fully included in another range + # - merge overlapping ranges + set ind [lsort -dictionary -stride 2 $indices] + set indices {} + for {set i 0} {$i < $nUndoMarks} {incr i 2} { + set il1 [lindex $ind $i] + set ir1 [lindex $ind [expr {$i + 1}]] + lappend indices $il1 $ir1 +#puts " range1: $il1 $ir1" + for {set j [expr {$i + 2}]} {$j < $nUndoMarks} {incr j 2} { + set il2 [lindex $ind $j] + set ir2 [lindex $ind [expr {$j + 1}]] +#puts " range2: $il2 $ir2" + if {[$w compare $il2 > $ir1]} { + # second range starts after the end of first range + set j $nUndoMarks + } else { + if {[$w compare $ir2 > $ir1]} { + # second range overlaps with first range + set indices [lreplace $indices end-1 end] + lappend indices $il1 $ir2 + } else { + # second range is fully included in first range + } + set ind [lreplace $ind $j [expr {$j + 1}]] + incr j -2 + incr nUndoMarks -2 + } +#puts " indices: $indices" + } + } +#puts "OPTIMIZED indices: $indices" + return $indices +} -- cgit v0.12 From 19daddfc9fecac5b38d749263e8553bc9b44d415 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 5 Jul 2016 20:02:59 +0000 Subject: Better comments explaining the algorithm in ::tk::TextUndoRedoProcessMarks --- library/text.tcl | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/library/text.tcl b/library/text.tcl index cc78bc2..f241abd 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -1217,13 +1217,17 @@ proc ::tk::TextScanDrag {w x y} { proc ::tk::TextUndoRedoProcessMarks {w} { set indices {} set undoMarks {} + # only consider the temporary marks set by an undo/redo action foreach mark [$w mark names] { if {[string range $mark 0 11] eq "tk::undoMark"} { lappend undoMarks $mark } } - # the number of undo/redo marks is always even + + # transform marks into indices + # the number of undo/redo marks is always even, each right mark + # completes a left mark to give a range set nUndoMarks [llength $undoMarks] set n [expr {$nUndoMarks / 2}] set undoMarks [lsort -dictionary $undoMarks] @@ -1233,39 +1237,51 @@ proc ::tk::TextUndoRedoProcessMarks {w} { lappend indices [$w index $Lmark] [$w index $Rmark] $w mark unset $Lmark $Rmark } -#puts "Unoptimized indices: $indices" + # process ranges to: # - remove those already fully included in another range # - merge overlapping ranges set ind [lsort -dictionary -stride 2 $indices] set indices {} + for {set i 0} {$i < $nUndoMarks} {incr i 2} { set il1 [lindex $ind $i] set ir1 [lindex $ind [expr {$i + 1}]] lappend indices $il1 $ir1 -#puts " range1: $il1 $ir1" + for {set j [expr {$i + 2}]} {$j < $nUndoMarks} {incr j 2} { set il2 [lindex $ind $j] set ir2 [lindex $ind [expr {$j + 1}]] -#puts " range2: $il2 $ir2" + if {[$w compare $il2 > $ir1]} { # second range starts after the end of first range + # -> further second ranges do not need to be considered + # because ranges were sorted by increasing first index set j $nUndoMarks + } else { if {[$w compare $ir2 > $ir1]} { - # second range overlaps with first range + # second range overlaps first range + # -> merge them into a single range set indices [lreplace $indices end-1 end] lappend indices $il1 $ir2 + } else { # second range is fully included in first range + # -> ignore it + } + # in both cases above, the second range shall be + # trimmed out from the list of ranges set ind [lreplace $ind $j [expr {$j + 1}]] incr j -2 incr nUndoMarks -2 + } -#puts " indices: $indices" + } + } -#puts "OPTIMIZED indices: $indices" + return $indices } -- cgit v0.12 From 77f55a8fc19b9564340f53bc04e96c0217bf24a9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 5 Jul 2016 20:03:53 +0000 Subject: Removed unintended whitespace change --- generic/tkText.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkText.c b/generic/tkText.c index f34b221..4195238 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5339,7 +5339,7 @@ TextEditCmd( return TCL_ERROR; } canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); - if (TextEditRedo(textPtr)) { + if (TextEditRedo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to redo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", NULL); return TCL_ERROR; -- cgit v0.12 From 5718d28895a5ea6c26d0dc5e8421b3ff31fe7785 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 5 Jul 2016 20:07:01 +0000 Subject: Added more tests, and fixed test result of text-27.26 since now indices are relative to the text widget state at undo/redo return time, and also because they are optimized (no overlaps) --- tests/text.test | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/tests/text.test b/tests/text.test index a3f9afe..65c3225 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6601,12 +6601,42 @@ test text-27.26 {edit undo and edit redo return ranges} -setup { lappend res [.t edit redo] } -cleanup { destroy .t -} -result [list {2.0 2.19 1.6 1.12 1.6 2.0} \ - {1.6 2.0 1.6 1.12 2.0 2.19} \ - {1.9 1.10 1.9 1.10 1.6 1.7} \ - {1.6 1.7 1.9 1.10 1.9 1.10} \ - {2.8 2.26 2.8 2.12 1.6 1.12 1.6 1.10} \ - {1.6 1.10 1.6 1.12 2.8 2.12 2.8 2.26} ] +} -result [list {1.6 2.0} \ + {1.6 2.19} \ + {1.6 1.7 1.10 1.12} \ + {1.6 1.7 1.9 1.11} \ + {1.6 1.16 2.8 2.19} \ + {1.6 1.16 2.8 2.30} ] +test text-27.27 {edit undo and edit redo return ranges} -setup { + destroy .t + set res {} +} -body { + text .t -undo true -autoseparators false + for {set i 3} {$i >= 1} {incr i -1} { + .t insert 1.0 "Line $i\n" + } + lappend res [.t edit undo] + lappend res [.t edit redo] +} -cleanup { + destroy .t +} -result [list {1.0 2.0} \ + {1.0 4.0} ] +test text-27.28 {edit undo and edit redo do not leave \ + spurious temporary marks behind them} -setup { + destroy .t + set res {} +} -body { + pack [text .t -undo true -autoseparators false] + .t insert end "Hello World.\n" + .t edit separator + .t insert end "Again hello.\n" + .t edit undo + lappend res [lsearch [.t mark names] tk::undoMark*] + .t edit undo + lappend res [lsearch [.t mark names] tk::undoMark*] +} -cleanup { + destroy .t +} -result [list -1 -1] test text-28.1 {bug fix - 624372, ControlUtfProc long lines} -body { -- cgit v0.12 From e28d7bfd6199766d14e5583fcf905289c6737c36 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 5 Jul 2016 20:36:25 +0000 Subject: Fixed copy/paste error in test text-27.28 - one wants to test undo and redo, not twice undo --- tests/text.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/text.test b/tests/text.test index 65c3225..2e4177d 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6632,7 +6632,7 @@ test text-27.28 {edit undo and edit redo do not leave \ .t insert end "Again hello.\n" .t edit undo lappend res [lsearch [.t mark names] tk::undoMark*] - .t edit undo + .t edit redo lappend res [lsearch [.t mark names] tk::undoMark*] } -cleanup { destroy .t -- cgit v0.12 From bf98687ae68fe39f9b67d9cd3c1553bfdd43bf7b Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 6 Jul 2016 17:00:05 +0000 Subject: The undo marks identifier is now a member of textPtr->sharedTextPtr. This makes results of test text-8.22 independant of previous undo/redo actions on other text widgets. --- generic/tkText.c | 5 ++--- generic/tkText.h | 2 ++ tests/text.test | 14 +++++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 4195238..6b90a23 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2774,7 +2774,6 @@ TextPushUndoAction( { TkUndoSubAtom *iAtom, *dAtom; int canUndo, canRedo; - static int undoMarkId = -1; char lMarkName[20] = "tk::undoMarkL"; char rMarkName[20] = "tk::undoMarkR"; char stringUndoMarkId[7] = ""; @@ -2848,8 +2847,8 @@ TextPushUndoAction( Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj, Tcl_NewStringObj("set", 3)); markSetRUndoMarkCmdObj = Tcl_DuplicateObj(markSetLUndoMarkCmdObj); - undoMarkId++; - sprintf(stringUndoMarkId, "%d", undoMarkId); + textPtr->sharedTextPtr->undoMarkId++; + sprintf(stringUndoMarkId, "%d", textPtr->sharedTextPtr->undoMarkId); strcat(lMarkName, stringUndoMarkId); strcat(rMarkName, stringUndoMarkId); Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj, diff --git a/generic/tkText.h b/generic/tkText.h index 5d88784..430c96b 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -580,6 +580,8 @@ typedef struct TkSharedText { * statements. */ int autoSeparators; /* Non-zero means the separators will be * inserted automatically. */ + int undoMarkId; /* Counts undo marks temporarily used during + undo and redo operations. */ int isDirty; /* Flag indicating the 'dirtyness' of the * text widget. If the flag is not zero, * unsaved modifications have been applied to diff --git a/tests/text.test b/tests/text.test index 2e4177d..1a68239 100644 --- a/tests/text.test +++ b/tests/text.test @@ -1458,7 +1458,19 @@ Line 7" rename .t {} rename test.t .t destroy .t -} -result {{edit undo} {delete 2.1 2.4} {mark set insert 2.1} {see insert} {insert 2.1 ef} {mark set insert 2.3} {see insert}} +} -result [list {edit undo} {delete 2.1 2.4} {mark set insert 2.1} {see insert} \ + {mark set tk::undoMarkL3 2.1} {mark set tk::undoMarkR3 2.4} \ + {mark gravity tk::undoMarkL3 left} {mark gravity tk::undoMarkR3 right} \ + {insert 2.1 ef} {mark set insert 2.3} {see insert} \ + {mark set tk::undoMarkL2 2.1} {mark set tk::undoMarkR2 2.3} \ + {mark gravity tk::undoMarkL2 left} {mark gravity tk::undoMarkR2 right} \ + {mark names} \ + {index tk::undoMarkL2} {index tk::undoMarkR2} \ + {mark unset tk::undoMarkL2 tk::undoMarkR2} \ + {index tk::undoMarkL3} {index tk::undoMarkR3} \ + {mark unset tk::undoMarkL3 tk::undoMarkR3} \ + {compare 2.1 > 2.3} {compare 2.6 > 2.3} ] + test text-8.23 {TextWidgetCmd procedure, "replace" option with undo} -setup { text .t } -body { -- cgit v0.12 From 1052e56fe96f3ece407a6374714af0302c9a5e3c Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 7 Jul 2016 06:39:26 +0000 Subject: Added comments justifying why we can rely on finding all the needed marks still in the text widget at the time they are transformed into indices. --- library/text.tcl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/text.tcl b/library/text.tcl index f241abd..02a8939 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -1228,6 +1228,19 @@ proc ::tk::TextUndoRedoProcessMarks {w} { # transform marks into indices # the number of undo/redo marks is always even, each right mark # completes a left mark to give a range + # this is true because: + # - undo/redo only deals with insertions and deletions of text + # - insertions may move marks but not delete them + # - when deleting text, marks located inside the deleted range + # are not erased but moved to the start of the deletion range + # . this is done in TkBTreeDeleteIndexRange ("This segment + # refuses to die...") + # . because MarkDeleteProc does nothing else than returning + # a value indicating that marks are not deleted by this + # deleteProc + # . mark deletion rather happen through [.text mark unset xxx] + # which was not used _up to this point of the code_ (it + # is a bit later just before exiting the present proc) set nUndoMarks [llength $undoMarks] set n [expr {$nUndoMarks / 2}] set undoMarks [lsort -dictionary $undoMarks] -- cgit v0.12 From 87ca801378d1a85bc3c5ae50263cdec51f80cff7 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Aug 2016 12:12:27 +0000 Subject: Consider the Extended flag for both KeyPress and KeyRelease events coming from the extended (keypad) keys. I can't see why implementation of TIP #158 [b8333852a2] considered the extended flag only for KeyPress, and forced clearing it in the state integer for KeyRelease. --- win/tkWinX.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/win/tkWinX.c b/win/tkWinX.c index 6c44059..567b281 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1321,11 +1321,7 @@ GetState( state &= ~mask; } if (HIWORD(lParam) & KF_EXTENDED) { - if (message == WM_SYSKEYDOWN || message == WM_KEYDOWN) { - state |= EXTENDED_MASK; - } else { - state &= ~EXTENDED_MASK; - } + state |= EXTENDED_MASK; } } return state; -- cgit v0.12 From 4fa07b0a11a1de74bd15b1ae9dcec8be210fcd34 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Aug 2016 12:22:13 +0000 Subject: Left and right Control and Alt keys are distinguished using the Extended flag (the previously implemented trick only worked for KeyPress, not for KeyRelease). --- win/tkWinKey.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/win/tkWinKey.c b/win/tkWinKey.c index ed546f7..10cc7b8 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -335,18 +335,24 @@ KeycodeToKeysym( /* * Windows only gives us an undifferentiated VK_CONTROL code (for * example) when either Control key is pressed. To distinguish between - * left and right, we have to query the state of one of the two to - * determine which was actually pressed. So if the keycode indicates - * Control, Shift, or Menu (the key that everybody else calls Alt), do - * this extra test. If the right-side key was pressed, return the - * appropriate keycode. Otherwise, we fall through and rely on the - * keymap table to hold the correct keysym value. + * left and right, we use the Extended flag. Indeed, the right Control + * and Alt (aka Menu) keys are such extended keys (which their left + * counterparts are not). + * Regarding the shift case, Windows does not set the Extended flag for + * the neither the left nor the right shift key. As a consequence another + * way to distinguish between the two keys is to query the state of one + * of the two to determine which was actually pressed. So if the keycode + * indicates Shift, do this extra test. If the right-side key was + * pressed, return the appropriate keycode. Otherwise, we fall through + * and rely on the keymap table to hold the correct keysym value. + * Note: this little trick only works for KeyPress, not for KeyRelease, + * for reasons stated in bug [2945130] */ case VK_CONTROL: - if (GetKeyState(VK_RCONTROL) & 0x80) { - return XK_Control_R; - } + if (state & EXTENDED_MASK) { + return XK_Control_R; + } break; case VK_SHIFT: if (GetKeyState(VK_RSHIFT) & 0x80) { @@ -354,9 +360,9 @@ KeycodeToKeysym( } break; case VK_MENU: - if (GetKeyState(VK_RMENU) & 0x80) { - return XK_Alt_R; - } + if (state & EXTENDED_MASK) { + return XK_Alt_R; + } break; } return keymap[keycode]; -- cgit v0.12 From 53641c0fb520f426b05a61602b586bb18b15e01b Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 13 Aug 2016 20:03:33 +0000 Subject: Fixed [a2abc45ee6] - Cursor at wrong position after event generate -warp on secondary screen --- generic/tkBind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 3b05066..d3fdc96 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3460,7 +3460,7 @@ HandleEventGenerate( Tcl_DoWhenIdle(DoWarp, dispPtr); dispPtr->flags |= TK_DISPLAY_IN_WARP; } - dispPtr->warpWindow = Tk_IdToWindow(Tk_Display(mainWin), + dispPtr->warpWindow = Tk_IdToWindow(dispPtr->display, event.general.xmotion.window); dispPtr->warpMainwin = mainWin; dispPtr->warpX = event.general.xmotion.x; -- cgit v0.12 From 24e47b1d059cf68f776b57faf187e4e022ad2a13 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 19 Aug 2016 20:31:26 +0000 Subject: Fixed [fa32290898] - Can't dismiss ttk::menubutton menu until mouse has hovered over it --- library/menu.tcl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/menu.tcl b/library/menu.tcl index a7aaa3f..b5dd88e 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -607,6 +607,10 @@ proc ::tk::MenuButtonDown menu { if {![winfo viewable $menu]} { return } + if {[$menu index active] eq "none"} { + set Priv(window) {} + return + } $menu postcascade active if {$Priv(postedMb) ne "" && [winfo viewable $Priv(postedMb)]} { grab -global $Priv(postedMb) -- cgit v0.12 From 6fb89b6069a9896acc6a2dc61f6b4f86e1b4e92c Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 19 Aug 2016 21:47:34 +0000 Subject: Fixed [2cf3d6942c] - Test button-5.24 fails. First, use {Helvetica -12} as font for the button text instead of {Helvetica -12 bold} since it's the former and not the latter that is tested against in constraints.tcl regarding the 'font' constraint. Second, don't force -width to a fixed value, otherwise width results can be wrong. Third, adjust the test results in width according to the two previous changes. --- tests/button.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/button.test b/tests/button.test index 708fc30..194e877 100644 --- a/tests/button.test +++ b/tests/button.test @@ -3435,15 +3435,15 @@ test button-5.23 {ConfigureButton - -height option} -constraints { test button-5.24 {ConfigureButton - computing geometry} -constraints { fonts } -body { - button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} - .b configure -text "Sample text" -width 10 -height 2 + button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} + .b configure -text "Sample text" -height 2 pack .b set result "[winfo reqwidth .b] [winfo reqheight .b]" .b configure -bitmap questhead lappend result [winfo reqwidth .b] [winfo reqheight .b] } -cleanup { destroy .b -} -result {104 46 20 12} +} -result {96 46 30 12} test button-5.25 {ConfigureButton - computing geometry} -setup { button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} -- cgit v0.12 From d27dd9b903416ca1a90206b913495225ac79133c Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 23 Aug 2016 18:27:14 +0000 Subject: Improved further test button-5.24: the test no longer depends on default values for -padx and -pady and it now computes the expected size of the button --- tests/button.test | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/tests/button.test b/tests/button.test index 194e877..d4db317 100644 --- a/tests/button.test +++ b/tests/button.test @@ -3435,15 +3435,47 @@ test button-5.23 {ConfigureButton - -height option} -constraints { test button-5.24 {ConfigureButton - computing geometry} -constraints { fonts } -body { - button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} - .b configure -text "Sample text" -height 2 + button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ + -padx 30 -pady 20 + # 1. button with text + .b configure -text "Sample text" pack .b - set result "[winfo reqwidth .b] [winfo reqheight .b]" - .b configure -bitmap questhead - lappend result [winfo reqwidth .b] [winfo reqheight .b] -} -cleanup { - destroy .b -} -result {96 46 30 12} + set textwidth [font measure [.b cget -font] -displayof .b [.b cget -text]] + set expectedwidth [expr {$textwidth + 2*[.b cget -borderwidth] \ + + 2*[.b cget -highlightthickness] + 2*[.b cget -padx]}] + incr expectedwidth 2 ; # added (hardcoded) in tkUnixButton.c + set result [expr $expectedwidth == [winfo reqwidth .b]] + set linespace [lindex [font metrics [.b cget -font] -displayof .b] 5] + set expectedheight [expr {$linespace + 2*[.b cget -borderwidth] \ + + 2*[.b cget -highlightthickness] + 2*[.b cget -pady]}] + incr expectedheight 2 ; # added (hardcoded) in tkUnixButton.c + lappend result [expr $expectedheight == [winfo reqheight .b]] + # 2. button with a bitmap image + # there is no access to characteristics the predefined bitmaps, + # so define one as an image (copied from questhead.xbm) + set myquesthead [image create bitmap -data { + #define myquesthead_width 20 + #define myquesthead_height 22 + static unsigned char myquesthead_bits[] = { + 0xf8, 0x1f, 0x00, 0xac, 0x2a, 0x00, 0x56, 0x55, 0x00, 0xeb, 0xaf, 0x00, + 0xf5, 0x5f, 0x01, 0xfb, 0xbf, 0x00, 0x75, 0x5d, 0x01, 0xfb, 0xbe, 0x02, + 0x75, 0x5d, 0x05, 0xab, 0xbe, 0x0a, 0x55, 0x5f, 0x07, 0xab, 0xaf, 0x00, + 0xd6, 0x57, 0x01, 0xac, 0xab, 0x00, 0xd8, 0x57, 0x00, 0xb0, 0xaa, 0x00, + 0x50, 0x55, 0x00, 0xb0, 0x0b, 0x00, 0xd0, 0x17, 0x00, 0xb0, 0x0b, 0x00, + 0x58, 0x15, 0x00, 0xa8, 0x2a, 0x00}; + }] + .b configure -image $myquesthead + set expectedwidth [expr {[image width $myquesthead] + 2*[.b cget -borderwidth] \ + + 2*[.b cget -highlightthickness]}] + incr expectedwidth 2 ; # added (hardcoded) in tkUnixButton.c + lappend result [expr $expectedwidth == [winfo reqwidth .b]] + set expectedheight [expr {[image height $myquesthead] + 2*[.b cget -borderwidth] \ + + 2*[.b cget -highlightthickness]}] + incr expectedheight 2 ; # added (hardcoded) in tkUnixButton.c + lappend result [expr $expectedheight == [winfo reqheight .b]] +} -cleanup { + destroy .b +} -result {1 1 1 1} test button-5.25 {ConfigureButton - computing geometry} -setup { button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} -- cgit v0.12 From 1e6f41e17ea6b546ea891d57ed147b09a8c2f7cd Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 23 Aug 2016 19:30:19 +0000 Subject: Added non regression test case menu-38.1 --- tests/menu.test | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/menu.test b/tests/menu.test index aaadc86..a97aa25 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -3878,6 +3878,35 @@ test menu-37.1 {menubar menues cannot be posted - bug 2160206} -setup { destroy .m } -result {1 {a menubar menu cannot be posted}} +test menu-38.1 {Can't dismiss ttk::menubutton menu until mouse has hovered over it - bug fa32290898} -setup { +} -body { + toplevel .top + ttk::menubutton .top.mb -text "Some menu"; + menu .top.mb.m; + .top.mb.m add command -label "Item 1"; + .top.mb.m add command -label "Item 2"; + .top.mb configure -menu .top.mb.m; + pack .top.mb + update + # simulate mouse click on the menubutton, which posts its menu + event generate .top.mb -warp 1 + update + after 50 + event generate .top.mb + update + # simulate mouse click on the menu again, i.e. without + # entering/leaving the posted menu + event generate .top.mb + update + after 50 + event generate .top.mb + update + # the menu shall have been unposted by the second click + winfo ismapped .top.mb.m +} -cleanup { + destroy .top.mb.m .top.m .top +} -result {0} + # cleanup imageFinish -- cgit v0.12 From 9900ef4bf9c3880f8d01968600aa70ab2897b8a6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 23 Aug 2016 20:16:55 +0000 Subject: Patch [6c0d7aec67] from Christian Werner on upstream Androwish to better handle unicode text input for Windows 8 by dealing with wParam VK_PACKET in WM_KEYDOWN and WM_SYSKEYDOWN events. This was observed on a Windows 8.1 tablet when the on-screen virtual keyboard is used to enter Emojis for example. The changes allow to enter Emojis when Tcl/Tk is built with TCL_UTF_MAX>3. --- win/tkWinX.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/win/tkWinX.c b/win/tkWinX.c index 7e25826..96a8720 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -911,15 +911,24 @@ Tk_TranslateWinEvent( Tk_PointerEvent(hwnd, (short) LOWORD(lParam), (short) HIWORD(lParam)); return 1; + case WM_SYSKEYDOWN: + case WM_KEYDOWN: + if (wParam == VK_PACKET) { + /* + * This will trigger WM_CHAR event(s) with unicode data. + */ + *resultPtr = + PostMessageW(hwnd, message, HIWORD(lParam), LOWORD(lParam)); + return 1; + } + /* else fall through */ case WM_CLOSE: case WM_SETFOCUS: case WM_KILLFOCUS: case WM_DESTROYCLIPBOARD: case WM_UNICHAR: case WM_CHAR: - case WM_SYSKEYDOWN: case WM_SYSKEYUP: - case WM_KEYDOWN: case WM_KEYUP: case WM_MOUSEWHEEL: GenerateXEvent(hwnd, message, wParam, lParam); @@ -1197,17 +1206,50 @@ GenerateXEvent( event.type = KeyPress; event.xany.send_event = -1; event.xkey.keycode = 0; - event.xkey.nbytes = 1; - event.xkey.trans_chars[0] = (char) wParam; - - if (IsDBCSLeadByte((BYTE) wParam)) { + if ((int)wParam & 0xff00) { + int i, ch1 = wParam & 0xffff; + char buffer[TCL_UTF_MAX+1]; +#if TCL_UTF_MAX >= 4 MSG msg; - if ((PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0) + if ((((int)wParam & 0xfc00) == 0xd800) + && (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0) && (msg.message == WM_CHAR)) { + MSG msg; + int ch2; + GetMessage(&msg, NULL, 0, 0); - event.xkey.nbytes = 2; - event.xkey.trans_chars[1] = (char) msg.wParam; + ch2 = wParam & 0xffff; +#if TCL_UTF_MAX == 4 + event.xkey.nbytes = Tcl_UniCharToUtf(ch1, buffer); + event.xkey.nbytes += Tcl_UniCharToUtf(ch2, buffer); +#else + ch1 = ((ch1 & 0x3ff) << 10) | (ch2 & 0x3ff); + ch1 += 0x10000; + event.xkey.nbytes = Tcl_UniCharToUtf(ch1, buffer); +#endif + } else +#endif + { + event.xkey.nbytes = Tcl_UniCharToUtf(ch1, buffer); + } + for (i=0; i 0xffff) ? + 0xfffd : (int)wParam, buffer); +#else +#if TCL_UTF_MAX == 4 + if ((int)wParam > 0xffff) { + Tcl_UniChar uch; + + uch = (((int)wParam - 0x10000) >> 10) & 0x3ff; + event.xkey.nbytes = Tcl_UniCharToUtf(uch | 0xd800, buffer); + uch = ((int)wParam - 0x10000) & 0x3ff; + event.xkey.nbytes += Tcl_UniCharToUtf(uch | 0xdc00, + buffer + event.xkey.nbytes); + } else +#endif event.xkey.nbytes = Tcl_UniCharToUtf((int)wParam, buffer); +#endif for (i=0; i Date: Mon, 29 Aug 2016 17:42:45 +0000 Subject: Constrained test menu-38.1 to Unix or Mac platforms since this test hangs on Windows and the corresponding bug was reported for Linux and Mac only --- tests/menu.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/menu.test b/tests/menu.test index a97aa25..05356e3 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -3879,7 +3879,7 @@ test menu-37.1 {menubar menues cannot be posted - bug 2160206} -setup { } -result {1 {a menubar menu cannot be posted}} test menu-38.1 {Can't dismiss ttk::menubutton menu until mouse has hovered over it - bug fa32290898} -setup { -} -body { +} -constraints {macOrUnix} -body { toplevel .top ttk::menubutton .top.mb -text "Some menu"; menu .top.mb.m; -- cgit v0.12 From d257de6d2ca3b8c1b8494276d2bdfd5ef137e7ba Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Aug 2016 10:24:09 +0000 Subject: Enhance TkpGetString() to handle Unicode characters, even when TCL_UTF_MAX==3. --- win/tkWinFont.c | 2 +- win/tkWinKey.c | 16 ++++++++++++---- win/tkWinX.c | 10 ++++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 9172b00..940bc10 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -2188,7 +2188,7 @@ FontMapLoadPage( { FontFamily *familyPtr; Tcl_Encoding encoding; - char src[TCL_UTF_MAX], buf[16]; + char src[XMaxTransChars], buf[16]; USHORT *startCount, *endCount; int i, j, bitOffset, end, segCount; diff --git a/win/tkWinKey.c b/win/tkWinKey.c index ed546f7..a49898f 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -102,7 +102,7 @@ TkpGetString( */ int unichar; - char buf[TCL_UTF_MAX]; + char buf[XMaxTransChars]; int len; unichar = keyEv->trans_chars[1] & 0xff; @@ -115,10 +115,18 @@ TkpGetString( } else if (keyEv->send_event == -3) { /* * Special case for WM_UNICHAR. xkey.trans_chars[] already contains a - * UTF-8 char. + * UTF-8 char, except when nbytes == 0 (then it didn't fit there). */ - Tcl_DStringAppend(dsPtr, keyEv->trans_chars, keyEv->nbytes); + if (keyEv->nbytes) { + Tcl_DStringAppend(dsPtr, keyEv->trans_chars, keyEv->nbytes); + } else if (keyEv->keycode > 0xffff) { + char buf[XMaxTransChars]; + Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf); + Tcl_DStringAppend(dsPtr, buf, 3); + Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) & 0x3ff) | 0xdc00, buf); + Tcl_DStringAppend(dsPtr, buf, 3); + } } else { /* * This is an event generated from generic code. It has no nchars or @@ -129,7 +137,7 @@ TkpGetString( if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256)) || (keysym == XK_Return) || (keysym == XK_Tab)) { - char buf[TCL_UTF_MAX]; + char buf[XMaxTransChars]; int len; len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf); diff --git a/win/tkWinX.c b/win/tkWinX.c index 2180f52..6b8bdff 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1252,8 +1252,14 @@ GenerateXEvent( event.xany.send_event = -3; event.xkey.keycode = wParam; event.xkey.nbytes = Tcl_UniCharToUtf((int)wParam, buffer); - for (i=0; i 0xffff) && (event.xkey.nbytes < 4)) { + /* trans_chars buffer is not big enough to hold 2 surrogate + characters, so don't store anything */ + event.xkey.nbytes = 0; + } else { + for (i=0; i Date: Tue, 30 Aug 2016 19:46:35 +0000 Subject: Made text widget's default undo false again. --- generic/tkText.c | 2 +- tests/text.test | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 5ad527a..ab77d99 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -547,7 +547,7 @@ CreateWidget( Tcl_InitHashTable(&sharedPtr->windowTable, TCL_STRING_KEYS); Tcl_InitHashTable(&sharedPtr->imageTable, TCL_STRING_KEYS); sharedPtr->undoStack = TkUndoInitStack(interp,0); - sharedPtr->undo = 1; + sharedPtr->undo = 0; sharedPtr->isDirty = 0; sharedPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; sharedPtr->autoSeparators = 1; diff --git a/tests/text.test b/tests/text.test index 720afbe..f640817 100644 --- a/tests/text.test +++ b/tests/text.test @@ -29,6 +29,15 @@ test text-1.1 {configuration option: "autoseparators"} -setup { } -cleanup { destroy .t } -result {1} +test text-1.1b {configuration option: "autoseparators", default} -setup { + text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} + pack .t + update +} -body { + .t cget -autoseparators +} -cleanup { + destroy .t +} -result {1} test text-1.2 {configuration option: "autoseparators"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -428,6 +437,15 @@ test text-1.43 {configuration option: "maxundo"} -setup { } -cleanup { destroy .t } -result {5} +test text-1.43b {configuration option: "maxundo", default} -setup { + text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} + pack .t + update +} -body { + .t cget -maxundo +} -cleanup { + destroy .t +} -result {0} test text-1.44 {configuration option: "maxundo"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -732,6 +750,15 @@ test text-1.75 {configuration option: "undo"} -setup { } -cleanup { destroy .t } -result {1} +test text-1.75b {configuration option: "undo", default} -setup { + text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} + pack .t + update +} -body { + .t cget -undo +} -cleanup { + destroy .t +} -result {0} test text-1.76 {configuration option: "undo"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -6396,8 +6423,23 @@ test text-27.16a {undo configuration options with peers} -body { lappend res [.t edit canundo] lappend res [.tt edit canundo] } -cleanup { - destroy .t + destroy .t .tt } -result {1 1 0 0 100 100 1 1} +test text-27.16b {undo configuration options with peers, defaults} -body { + text .t + .t peer create .tt + set res [.t cget -undo] + lappend res [.tt cget -undo] + lappend res [.t cget -autoseparators] + lappend res [.tt cget -autoseparators] + lappend res [.t cget -maxundo] + lappend res [.tt cget -maxundo] + .t insert end "The undo stack is common between peers" + lappend res [.t edit canundo] + lappend res [.tt edit canundo] +} -cleanup { + destroy .t .tt +} -result {0 0 1 1 0 0 0 0} test text-27.17 {bug fix 1536735 - undo with empty text} -body { text .t -undo 1 set r [.t edit modified] -- cgit v0.12 From 34d8945d9d1dbbb3f599cabcad75ec0305f7615d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 31 Aug 2016 08:50:23 +0000 Subject: Fix use of XMaxTransChars in stead of TCL_UTF_MAX in some places. This should prevent possible buffer overflow when TCL_UTF_MAX=6 Micro-optimizations in tkEntry and ttkEntry --- generic/tkEntry.c | 3 ++- generic/ttk/ttkEntry.c | 3 ++- win/tkWinFont.c | 2 +- win/tkWinKey.c | 4 ++-- win/tkWinX.c | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index ea8d7f1..c0ce47b 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1943,7 +1943,8 @@ EntryComputeGeometry( entryPtr->displayString = p; for (i = entryPtr->numChars; --i >= 0; ) { - p += Tcl_UniCharToUtf(ch, p); + memcpy(p, buf, size); + p += size; } *p = '\0'; } diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index f395649..533637d 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -290,7 +290,8 @@ static char *EntryDisplayString(const char *showChar, int numChars) p = displayString = ckalloc(numChars * size + 1); while (numChars--) { - p += Tcl_UniCharToUtf(ch, p); + memcpy(p, buf, size); + p += size; } *p = '\0'; diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 9172b00..940bc10 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -2188,7 +2188,7 @@ FontMapLoadPage( { FontFamily *familyPtr; Tcl_Encoding encoding; - char src[TCL_UTF_MAX], buf[16]; + char src[XMaxTransChars], buf[16]; USHORT *startCount, *endCount; int i, j, bitOffset, end, segCount; diff --git a/win/tkWinKey.c b/win/tkWinKey.c index ed546f7..5591133 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -102,7 +102,7 @@ TkpGetString( */ int unichar; - char buf[TCL_UTF_MAX]; + char buf[XMaxTransChars]; int len; unichar = keyEv->trans_chars[1] & 0xff; @@ -129,7 +129,7 @@ TkpGetString( if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256)) || (keysym == XK_Return) || (keysym == XK_Tab)) { - char buf[TCL_UTF_MAX]; + char buf[XMaxTransChars]; int len; len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf); diff --git a/win/tkWinX.c b/win/tkWinX.c index 6c44059..99102cb 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1215,13 +1215,13 @@ GenerateXEvent( break; case WM_UNICHAR: { - char buffer[TCL_UTF_MAX+1]; + char buffer[XMaxTransChars]; int i; event.type = KeyPress; event.xany.send_event = -3; event.xkey.keycode = wParam; event.xkey.nbytes = Tcl_UniCharToUtf((int)wParam, buffer); - for (i=0; i Date: Thu, 1 Sep 2016 12:56:25 +0000 Subject: don't forget to set the keycode ;-) --- win/tkWinX.c | 1 + 1 file changed, 1 insertion(+) diff --git a/win/tkWinX.c b/win/tkWinX.c index f4908e0..e8715b3 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1225,6 +1225,7 @@ GenerateXEvent( event.xany.send_event = -3; event.xkey.nbytes = Tcl_UniCharToUtf(ch1, buffer); if ((ch1 <= 0xffff) || (event.xkey.nbytes == XMaxTransChars)) { + event.xkey.keycode = ch1; for (i=0; i Date: Thu, 1 Sep 2016 13:21:49 +0000 Subject: (experiment) don't fill trans_chars any more when send_event == -3. Results in many simplifications while it still should work the same --- win/tkWinKey.c | 15 ++++++++------ win/tkWinX.c | 64 ++++------------------------------------------------------ 2 files changed, 13 insertions(+), 66 deletions(-) diff --git a/win/tkWinKey.c b/win/tkWinKey.c index a49898f..64f8cd4 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -113,15 +113,18 @@ TkpGetString( Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { + + char buf[XMaxTransChars]; + int len; + /* - * Special case for WM_UNICHAR. xkey.trans_chars[] already contains a - * UTF-8 char, except when nbytes == 0 (then it didn't fit there). + * Special case for WM_UNICHAR. */ - if (keyEv->nbytes) { - Tcl_DStringAppend(dsPtr, keyEv->trans_chars, keyEv->nbytes); - } else if (keyEv->keycode > 0xffff) { - char buf[XMaxTransChars]; + len = Tcl_UniCharToUtf(keyEv->keycode, buf); + if ((keyEv->keycode <= 0xffff) || (len == XMaxTransChars)) { + Tcl_DStringAppend(dsPtr, buf, len); + } else { Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf); Tcl_DStringAppend(dsPtr, buf, 3); Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) & 0x3ff) | 0xdc00, buf); diff --git a/win/tkWinX.c b/win/tkWinX.c index e8715b3..ccccf56 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1210,8 +1210,7 @@ GenerateXEvent( event.xany.send_event = -1; event.xkey.keycode = 0; if ((int)wParam & 0xff00) { - int i, ch1 = wParam & 0xffff; - char buffer[XMaxTransChars]; + int ch1 = wParam & 0xffff; if ((ch1 & 0xfc00) == 0xd800) { tsdPtr->surrogateBuffer = ch1; @@ -1223,32 +1222,8 @@ GenerateXEvent( tsdPtr->surrogateBuffer = 0; } event.xany.send_event = -3; - event.xkey.nbytes = Tcl_UniCharToUtf(ch1, buffer); - if ((ch1 <= 0xffff) || (event.xkey.nbytes == XMaxTransChars)) { - event.xkey.keycode = ch1; - for (i=0; i>10) | 0xd800; - event.xkey.nbytes = Tcl_UniCharToUtf(event.xkey.keycode, buffer); - for (i=0; i 0xffff) && (event.xkey.nbytes < XMaxTransChars)) { -#if USE_EXTRA_EVENTS - /* trans_chars buffer is not big enough to hold 2 surrogate - characters, so split it in two separate events */ - - event.xkey.keycode = ((int)(wParam - 0x10000)>>10) | 0xd800; - event.xkey.nbytes = Tcl_UniCharToUtf(event.xkey.keycode, buffer); - for (i=0; i Date: Thu, 1 Sep 2016 13:43:28 +0000 Subject: unnecessary macro --- win/tkWinX.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/win/tkWinX.c b/win/tkWinX.c index ccccf56..1e66620 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -29,8 +29,6 @@ # pragma comment (lib, "advapi32.lib") #endif -#define USE_EXTRA_EVENTS 0 /* Set this to 1 if you want to generate - additional events for surrogates */ /* * The zmouse.h file includes the definition for WM_MOUSEWHEEL. */ -- cgit v0.12 From 7b67948f1e6c9ab9d8f4d56557ad8e4655862f66 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 1 Sep 2016 20:10:57 +0000 Subject: Cherrypicked [c8256e859a] - Fix from pspjuth to restore the default false value of -undo which was unintentionally changed by [3ff41efa17] --- generic/tkText.c | 2 +- tests/text.test | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 8be8881..4821993 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -547,7 +547,7 @@ CreateWidget( Tcl_InitHashTable(&sharedPtr->windowTable, TCL_STRING_KEYS); Tcl_InitHashTable(&sharedPtr->imageTable, TCL_STRING_KEYS); sharedPtr->undoStack = TkUndoInitStack(interp,0); - sharedPtr->undo = 1; + sharedPtr->undo = 0; sharedPtr->isDirty = 0; sharedPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; sharedPtr->autoSeparators = 1; diff --git a/tests/text.test b/tests/text.test index 720afbe..f640817 100644 --- a/tests/text.test +++ b/tests/text.test @@ -29,6 +29,15 @@ test text-1.1 {configuration option: "autoseparators"} -setup { } -cleanup { destroy .t } -result {1} +test text-1.1b {configuration option: "autoseparators", default} -setup { + text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} + pack .t + update +} -body { + .t cget -autoseparators +} -cleanup { + destroy .t +} -result {1} test text-1.2 {configuration option: "autoseparators"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -428,6 +437,15 @@ test text-1.43 {configuration option: "maxundo"} -setup { } -cleanup { destroy .t } -result {5} +test text-1.43b {configuration option: "maxundo", default} -setup { + text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} + pack .t + update +} -body { + .t cget -maxundo +} -cleanup { + destroy .t +} -result {0} test text-1.44 {configuration option: "maxundo"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -732,6 +750,15 @@ test text-1.75 {configuration option: "undo"} -setup { } -cleanup { destroy .t } -result {1} +test text-1.75b {configuration option: "undo", default} -setup { + text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} + pack .t + update +} -body { + .t cget -undo +} -cleanup { + destroy .t +} -result {0} test text-1.76 {configuration option: "undo"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -6396,8 +6423,23 @@ test text-27.16a {undo configuration options with peers} -body { lappend res [.t edit canundo] lappend res [.tt edit canundo] } -cleanup { - destroy .t + destroy .t .tt } -result {1 1 0 0 100 100 1 1} +test text-27.16b {undo configuration options with peers, defaults} -body { + text .t + .t peer create .tt + set res [.t cget -undo] + lappend res [.tt cget -undo] + lappend res [.t cget -autoseparators] + lappend res [.tt cget -autoseparators] + lappend res [.t cget -maxundo] + lappend res [.tt cget -maxundo] + .t insert end "The undo stack is common between peers" + lappend res [.t edit canundo] + lappend res [.tt edit canundo] +} -cleanup { + destroy .t .tt +} -result {0 0 1 1 0 0 0 0} test text-27.17 {bug fix 1536735 - undo with empty text} -body { text .t -undo 1 set r [.t edit modified] -- cgit v0.12 From cd3f26e03f6641611c85b280c2bca0cadfe39f7a Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 3 Sep 2016 15:27:17 +0000 Subject: Fixed [8c4216dca9] - listbox-4.1 unreliably fails on Debian 8 --- tests/listbox.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/listbox.test b/tests/listbox.test index 407420c..87a6d98 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -1222,6 +1222,7 @@ test listbox-4.1 {ConfigureListbox procedure} -constraints { pack .l update } -body { + update set x [getsize .] .l configure -setgrid 0 update -- cgit v0.12 From 778972909cae6ab5469fab15eb866a63355c2d47 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 3 Sep 2016 16:57:56 +0000 Subject: Fixed [eb26817783] - listbox-13.3 fails on Linux --- tests/listbox.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/listbox.test b/tests/listbox.test index 407420c..be8d582 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2306,7 +2306,7 @@ test listbox-13.3 {ListboxScanTo procedure} -constraints { .l scan dragto [expr 5+$width] [expr 10+$height] update lappend x [format {%.6g %.6g} {*}[.l xview]] [format {%.6g %.6g} {*}[.l yview]] -} -result {{0.8 1} {0.75 1} {0.64 0.84} {0.25 0.5}} +} -result {{0.8 1} {0.75 1} {0.6 0.8} {0.25 0.5}} test listbox-14.1 {NearestListboxElement procedure, partial last line} -body { -- cgit v0.12 From 4e79e6a36da48f58d7704b5d5a4fb1fd9f5b2479 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 8 Sep 2016 08:57:12 +0000 Subject: fix comment (Thanks, Christian!) --- generic/tkText.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkText.c b/generic/tkText.c index ab77d99..0e41ac8 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -3042,7 +3042,7 @@ CountIndices( * If 'viewUpdate' is true, we may adjust the window contents' * y-position, and scrollbar setting. * - * If 'viewUpdate' is false, true we can guarantee that textPtr->topIndex + * If 'viewUpdate' is true we can guarantee that textPtr->topIndex * points to a valid TkTextLine after this function returns. However, if * 'viewUpdate' is false, then there is no such guarantee (since * topIndex.linePtr can be garbage). The caller is expected to take -- cgit v0.12 From 41d3c8f67e62fe307c46c91e5a42b71e39c59334 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 16 Sep 2016 07:49:21 +0000 Subject: Patch from Christian Werner, for evaluation --- generic/tkEntry.c | 16 +++++++- generic/tkFont.c | 41 ++++++++++++++++++++ generic/tkInt.h | 4 ++ generic/tkText.c | 8 ++++ generic/tkTextIndex.c | 12 +++++- generic/tkUtil.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++ generic/ttk/ttkEntry.c | 16 +++++++- unix/tkUnixFont.c | 6 ++- unix/tkUnixRFont.c | 12 +++++- win/tkWinFont.c | 37 ++++++++++++++---- win/tkWinKey.c | 3 +- 11 files changed, 241 insertions(+), 16 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index a66cf18..5faf4ef 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1926,7 +1926,6 @@ EntryComputeGeometry( */ if (entryPtr->showChar != NULL) { - Tcl_UniChar ch; char buf[4]; int size; @@ -1936,8 +1935,15 @@ EntryComputeGeometry( * characters might end up looking like one valid UTF character in the * resulting string. */ +#if TCL_UTF_MAX == 4 + int ch; + + TkUtfToUniChar32(entryPtr->showChar, &ch); +#else + Tcl_UniChar ch; Tcl_UtfToUniChar(entryPtr->showChar, &ch); +#endif size = Tcl_UniCharToUtf(ch, buf); entryPtr->numDisplayBytes = entryPtr->numChars * size; @@ -3414,7 +3420,11 @@ ExpandPercents( * list element. */ int number, length; register const char *string; +#if TCL_UTF_MAX == 4 + int ch; +#else Tcl_UniChar ch; +#endif char numStorage[2*TCL_INTEGER_SPACE]; while (1) { @@ -3447,7 +3457,11 @@ ExpandPercents( before++; /* skip over % */ if (*before != '\0') { +#if TCL_UTF_MAX == 4 + before += TkUtfToUniChar32(before, &ch); +#else before += Tcl_UtfToUniChar(before, &ch); +#endif } else { ch = '%'; } diff --git a/generic/tkFont.c b/generic/tkFont.c index 1ffac16..3088959 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -497,7 +497,11 @@ Tk_FontObjCmd( const char *s; Tk_Font tkfont; Tcl_Obj *optPtr, *charPtr, *resultPtr; +#if TCL_UTF_MAX == 4 int uniChar = 0; +#else + Tcl_UniChar uniChar = 0; +#endif const TkFontAttributes *faPtr; TkFontAttributes fa; @@ -562,6 +566,10 @@ Tk_FontObjCmd( */ if (charPtr != NULL) { +#if TCL_UTF_MAX == 4 + Tcl_UniChar *ucPtr; +#endif + if (Tcl_GetCharLength(charPtr) != 1) { resultPtr = Tcl_NewStringObj( "expected a single character but got \"", -1); @@ -572,7 +580,18 @@ Tk_FontObjCmd( Tcl_SetErrorCode(interp, "TK", "VALUE", "FONT_SAMPLE", NULL); return TCL_ERROR; } +#if TCL_UTF_MAX == 4 + ucPtr = Tcl_GetUnicodeFromObj(charPtr, NULL); + uniChar = *ucPtr; + if (((uniChar & 0xFC00) == 0xD800) && (ucPtr[1] != 0x000)) { + if ((ucPtr[1] & 0xFC00) == 0xDC00) { + uniChar = ((uniChar & 0x3FF) << 10) + (ucPtr[1] & 0x3FF); + uniChar += 0x10000; + } + } +#else uniChar = Tcl_GetUniChar(charPtr, 0); +#endif } /* @@ -1694,7 +1713,11 @@ Tk_PostscriptFontName( } else if (strcasecmp(family, "ZapfDingbats") == 0) { family = "ZapfDingbats"; } else { +#if TCL_UTF_MAX == 4 + int ch; +#else Tcl_UniChar ch; +#endif /* * Inline, capitalize the first letter of each word, lowercase the @@ -1712,7 +1735,11 @@ Tk_PostscriptFontName( src++; upper = 1; } +#if TCL_UTF_MAX == 4 + src += TkUtfToUniChar32(src, &ch); +#else src += Tcl_UtfToUniChar(src, &ch); +#endif if (upper) { ch = (Tcl_UniChar) Tcl_UniCharToUpper(ch); upper = 0; @@ -3249,7 +3276,11 @@ Tk_TextLayoutToPostscript( int i, j, len; const char *p, *glyphname; char uindex[5], c, *ps; +#if TCL_UTF_MAX == 4 + int ch; +#else Tcl_UniChar ch; +#endif Tcl_AppendToObj(psObj, "[(", -1); for (i = 0; i < layoutPtr->numChunks; i++, chunkPtr++) { @@ -3272,7 +3303,11 @@ Tk_TextLayoutToPostscript( * international postscript fonts. */ +#if TCL_UTF_MAX == 4 + p += TkUtfToUniChar32(p, &ch); +#else p += Tcl_UtfToUniChar(p, &ch); +#endif if ((ch == '(') || (ch == ')') || (ch == '\\') || (ch < 0x20)) { /* * Tricky point: the "03" is necessary in the sprintf below, @@ -3298,6 +3333,11 @@ Tk_TextLayoutToPostscript( * use the full glyph name. */ +#if TCL_UTF_MAX > 3 + if (ch > 0xffff) { + goto noMapping; + } +#endif sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { @@ -3318,6 +3358,7 @@ Tk_TextLayoutToPostscript( * No known mapping for the character into the space of * PostScript glyphs. Ignore it. :-( */ +noMapping: ; #ifdef TK_DEBUG_POSTSCRIPT_OUTPUT fprintf(stderr, "Warning: no mapping to PostScript " diff --git a/generic/tkInt.h b/generic/tkInt.h index 0b502e4..367ef3a 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1232,6 +1232,10 @@ MODULE_SCOPE Status TkParseColor (Display * display, MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion); #endif +#if TCL_UTF_MAX == 4 +MODULE_SCOPE int TkUtfToUniChar32(const char *src, int *chPtr); +#endif + /* * Unsupported commands. */ diff --git a/generic/tkText.c b/generic/tkText.c index 1227e7b..834e842 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -4508,7 +4508,11 @@ TkTextGetTabs( Tcl_Obj **objv; TkTextTabArray *tabArrayPtr; TkTextTab *tabPtr; +#if TCL_UTF_MAX == 4 + int ch; +#else Tcl_UniChar ch; +#endif double prevStop, lastStop; /* * Map these strings to TkTextTabAlign values. @@ -4615,7 +4619,11 @@ TkTextGetTabs( * There may be a more efficient way of getting this. */ +#if TCL_UTF_MAX == 4 + TkUtfToUniChar32(Tcl_GetString(objv[i+1]), &ch); +#else Tcl_UtfToUniChar(Tcl_GetString(objv[i+1]), &ch); +#endif if (!Tcl_UniCharIsAlpha(ch)) { continue; } diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 92ca03b..f64a6d2 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -2298,9 +2298,13 @@ StartEnd( int chSize = 1; if (segPtr->typePtr == &tkTextCharType) { +#if TCL_UTF_MAX == 4 + int ch; + chSize = TkUtfToUniChar32(segPtr->body.chars + offset, &ch); +#else Tcl_UniChar ch; - chSize = Tcl_UtfToUniChar(segPtr->body.chars + offset, &ch); +#endif if (!Tcl_UniCharIsWordChar(ch)) { break; } @@ -2343,9 +2347,13 @@ StartEnd( int chSize = 1; if (segPtr->typePtr == &tkTextCharType) { +#if TCL_UTF_MAX == 4 + int ch; + TkUtfToUniChar32(segPtr->body.chars + offset, &ch); +#else Tcl_UniChar ch; - Tcl_UtfToUniChar(segPtr->body.chars + offset, &ch); +#endif if (!Tcl_UniCharIsWordChar(ch)) { break; } diff --git a/generic/tkUtil.c b/generic/tkUtil.c index d4c4d2d..fb796fd 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -1192,6 +1192,108 @@ TkSendVirtualEvent( Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); } + +#if TCL_UTF_MAX == 4 +/* + *--------------------------------------------------------------------------- + * + * TkUtfToUniChar32 -- + * + * Copied from Tcl_UtfToUniChar but using int instead of Tcl_UniChar! + * + * Extract the Tcl_UniChar represented by the UTF-8 string. Bad UTF-8 + * sequences are converted to valid Tcl_UniChars and processing + * continues. Equivalent to Plan 9 chartorune(). + * + * The caller must ensure that the source buffer is long enough that this + * routine does not run off the end and dereference non-existent memory + * looking for trail bytes. If the source buffer is known to be '\0' + * terminated, this cannot happen. Otherwise, the caller should call + * Tcl_UtfCharComplete() before calling this routine to ensure that + * enough bytes remain in the string. + * + * Results: + * *chPtr is filled with the Tcl_UniChar, and the return value is the + * number of bytes from the UTF-8 string that were consumed. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +int +TkUtfToUniChar32( + const char *src, /* The UTF-8 string. */ + int *chPtr) /* Filled with the Tcl_UniChar represented by + * the UTF-8 string. */ +{ + int byte; + + /* + * Unroll 1 to 3 byte UTF-8 sequences, use loop to handle longer ones. + */ + + byte = *((unsigned char *) src); + if (byte < 0xC0) { + /* + * Handles properly formed UTF-8 characters between 0x01 and 0x7F. + * Also treats \0 and naked trail bytes 0x80 to 0xBF as valid + * characters representing themselves. + */ + + *chPtr = byte; + return 1; + } else if (byte < 0xE0) { + if ((src[1] & 0xC0) == 0x80) { + /* + * Two-byte-character lead-byte followed by a trail-byte. + */ + + *chPtr = ((byte & 0x1F) << 6) | (src[1] & 0x3F); + return 2; + } + + /* + * A two-byte-character lead-byte not followed by trail-byte + * represents itself. + */ + } else if (byte < 0xF0) { + if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80)) { + /* + * Three-byte-character lead byte followed by two trail bytes. + */ + + *chPtr = ((byte & 0x0F) << 12) + | ((src[1] & 0x3F) << 6) | (src[2] & 0x3F); + return 3; + } + + /* + * A three-byte-character lead-byte not followed by two trail-bytes + * represents itself. + */ + } else if (byte < 0xF8) { + if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80) && ((src[3] & 0xC0) == 0x80)) { + /* + * Four-byte-character lead byte followed by three trail bytes. + */ + + *chPtr = ((byte & 0x0E) << 18) | ((src[1] & 0x3F) << 12) + | ((src[2] & 0x3F) << 6) | (src[3] & 0x3F); + return 4; + } + + /* + * A three-byte-character lead-byte not followed by two trail-bytes + * represents itself. + */ + } + + *chPtr = byte; + return 1; +} +#endif /* * Local Variables: * mode: c diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index d80e1fd..63ebc5f 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -282,10 +282,16 @@ static char *EntryDisplayString(const char *showChar, int numChars) { char *displayString, *p; int size; - Tcl_UniChar ch; char buf[4]; +#if TCL_UTF_MAX == 4 + int ch; + + TkUtfToUniChar32(showChar, &ch); +#else + Tcl_UniChar ch; Tcl_UtfToUniChar(showChar, &ch); +#endif size = Tcl_UniCharToUtf(ch, buf); p = displayString = ckalloc(numChars * size + 1); @@ -406,7 +412,11 @@ ExpandPercents( int number, length; const char *string; int stringLength; +#if TCL_UTF_MAX == 4 + int ch; +#else Tcl_UniChar ch; +#endif char numStorage[2*TCL_INTEGER_SPACE]; while (*template) { @@ -430,7 +440,11 @@ ExpandPercents( */ ++template; /* skip over % */ if (*template != '\0') { +#if TCL_UTF_MAX == 4 + template += TkUtfToUniChar32(template, &ch); +#else template += Tcl_UtfToUniChar(template, &ch); +#endif } else { ch = '%'; } diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index a6826b5..b10fddd 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -35,9 +35,13 @@ static const char *const encodingList[] = { * family": the foundry, face name, and charset. */ +#if TCL_UTF_MAX > 3 +#define FONTMAP_SHIFT 12 +#define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT)) +#else #define FONTMAP_SHIFT 10 - #define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT)) +#endif #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT) typedef struct FontFamily { diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 01bbb30..ee87657 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -54,6 +54,12 @@ typedef struct ThreadSpecificData { Region clipRegion; /* The clipping region, or None. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; + +#if TCL_UTF_MAX == 4 +#define UtfToUniChar(src, chPtr) TkUtfToUniChar32(src, chPtr) +#else +#define UtfToUniChar(src, chPtr) Tcl_UtfToUniChar(src, chPtr) +#endif /* * Package initialization: @@ -668,9 +674,13 @@ Tk_MeasureChars( curByte = 0; sawNonSpace = 0; while (numBytes > 0) { +#if TCL_UTF_MAX == 4 + int unichar; +#else Tcl_UniChar unichar; +#endif - clen = Tcl_UtfToUniChar(source, &unichar); + clen = UtfToUniChar(source, &unichar); c = (FcChar32) unichar; if (clen <= 0) { diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 10ea1b9..e413e7d 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -26,9 +26,13 @@ * Under Windows, a "font family" is uniquely identified by its face name. */ -#define FONTMAP_SHIFT 10 - -#define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT)) +#if TCL_UTF_MAX > 3 +#define FONTMAP_SHIFT 12 +#define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT)) +#else +#define FONTMAP_SHIFT 10 +#define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT)) +#endif #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT) typedef struct FontFamily { @@ -229,6 +233,11 @@ static inline HFONT SelectFont(HDC hdc, WinFont *fontPtr, SubFont *subFontPtr, double angle); static inline void SwapLong(PULONG p); static inline void SwapShort(USHORT *p); +#if TCL_UTF_MAX == 4 +#define UtfToUniChar(src, chPtr) TkUtfToUniChar32(src, chPtr) +#else +#define UtfToUniChar(src, chPtr) Tcl_UtfToUniChar(src, chPtr) +#endif static int CALLBACK WinFontCanUseProc(ENUMLOGFONT *lfPtr, NEWTEXTMETRIC *tmPtr, int fontType, LPARAM lParam); @@ -828,7 +837,11 @@ Tk_MeasureChars( HFONT oldFont; WinFont *fontPtr; int curX, moretomeasure; +#if TCL_UTF_MAX == 4 + int ch; +#else Tcl_UniChar ch; +#endif SIZE size; FontFamily *familyPtr; Tcl_DString runString; @@ -859,7 +872,7 @@ Tk_MeasureChars( start = source; end = start + numBytes; for (p = start; p < end; ) { - next = p + Tcl_UtfToUniChar(p, &ch); + next = p + UtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { familyPtr = lastSubFontPtr->familyPtr; @@ -921,7 +934,7 @@ Tk_MeasureChars( familyPtr = lastSubFontPtr->familyPtr; Tcl_DStringInit(&runString); for (p = start; p < end; ) { - next = p + Tcl_UtfToUniChar(p, &ch); + next = p + UtfToUniChar(p, &ch); Tcl_UtfToExternal(NULL, familyPtr->encoding, p, (int) (next - p), 0, NULL, buf, sizeof(buf), NULL, &dstWrote, NULL); @@ -970,13 +983,17 @@ Tk_MeasureChars( */ const char *lastWordBreak = NULL; +#if TCL_UTF_MAX == 4 + int ch2; +#else Tcl_UniChar ch2; +#endif end = p; p = source; ch = ' '; while (p < end) { - next = p + Tcl_UtfToUniChar(p, &ch2); + next = p + UtfToUniChar(p, &ch2); if ((ch != ' ') && (ch2 == ' ')) { lastWordBreak = p; } @@ -1443,7 +1460,11 @@ MultiFontTextOut( * string when drawing. */ double angle) { +#if TCL_UTF_MAX == 4 + int ch; +#else Tcl_UniChar ch; +#endif SIZE size; HFONT oldFont; FontFamily *familyPtr; @@ -1458,7 +1479,7 @@ MultiFontTextOut( end = source + numBytes; for (p = source; p < end; ) { - next = p + Tcl_UtfToUniChar(p, &ch); + next = p + UtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { if (p > source) { @@ -2188,7 +2209,7 @@ FontMapLoadPage( { FontFamily *familyPtr; Tcl_Encoding encoding; - char src[XMaxTransChars], buf[16]; + char src[TCL_UTF_MAX], buf[16]; USHORT *startCount, *endCount; int i, j, bitOffset, end, segCount; diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 2698c4d..815ff3b 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -113,7 +113,6 @@ TkpGetString( Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { - char buf[XMaxTransChars]; int len; @@ -122,7 +121,7 @@ TkpGetString( */ len = Tcl_UniCharToUtf(keyEv->keycode, buf); - if ((keyEv->keycode <= 0xffff) || (len == XMaxTransChars)) { + if ((keyEv->keycode <= 0xffff) || (len > 3)) { Tcl_DStringAppend(dsPtr, buf, len); } else { Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf); -- cgit v0.12 From 7a5d64437977cc14b7b79e336b3b2a20785348e5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 16 Sep 2016 12:17:59 +0000 Subject: Rename TkUtfToUniChar32 to TkUtfToUniChar2, and various simplifications needing less #ifdef's --- generic/tkEntry.c | 16 +------- generic/tkFont.c | 47 +++--------------------- generic/tkInt.h | 6 ++- generic/tkText.c | 10 +---- generic/tkTextDisp.c | 4 +- generic/tkTextIndex.c | 16 ++------ generic/tkUtil.c | 99 +++++++++++--------------------------------------- generic/ttk/ttkEntry.c | 16 +------- unix/tkUnixFont.c | 5 --- unix/tkUnixRFont.c | 12 +----- win/tkWinFont.c | 32 +++------------- win/tkWinKey.c | 3 +- 12 files changed, 49 insertions(+), 217 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 5faf4ef..a66cf18 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1926,6 +1926,7 @@ EntryComputeGeometry( */ if (entryPtr->showChar != NULL) { + Tcl_UniChar ch; char buf[4]; int size; @@ -1935,15 +1936,8 @@ EntryComputeGeometry( * characters might end up looking like one valid UTF character in the * resulting string. */ -#if TCL_UTF_MAX == 4 - int ch; - - TkUtfToUniChar32(entryPtr->showChar, &ch); -#else - Tcl_UniChar ch; Tcl_UtfToUniChar(entryPtr->showChar, &ch); -#endif size = Tcl_UniCharToUtf(ch, buf); entryPtr->numDisplayBytes = entryPtr->numChars * size; @@ -3420,11 +3414,7 @@ ExpandPercents( * list element. */ int number, length; register const char *string; -#if TCL_UTF_MAX == 4 - int ch; -#else Tcl_UniChar ch; -#endif char numStorage[2*TCL_INTEGER_SPACE]; while (1) { @@ -3457,11 +3447,7 @@ ExpandPercents( before++; /* skip over % */ if (*before != '\0') { -#if TCL_UTF_MAX == 4 - before += TkUtfToUniChar32(before, &ch); -#else before += Tcl_UtfToUniChar(before, &ch); -#endif } else { ch = '%'; } diff --git a/generic/tkFont.c b/generic/tkFont.c index 3088959..4a45691 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -497,11 +497,7 @@ Tk_FontObjCmd( const char *s; Tk_Font tkfont; Tcl_Obj *optPtr, *charPtr, *resultPtr; -#if TCL_UTF_MAX == 4 int uniChar = 0; -#else - Tcl_UniChar uniChar = 0; -#endif const TkFontAttributes *faPtr; TkFontAttributes fa; @@ -566,32 +562,19 @@ Tk_FontObjCmd( */ if (charPtr != NULL) { -#if TCL_UTF_MAX == 4 - Tcl_UniChar *ucPtr; -#endif + const char *string = Tcl_GetString(charPtr); + int len = TkUtfToUniChar2(string, &uniChar); - if (Tcl_GetCharLength(charPtr) != 1) { + if (len != charPtr->length) { resultPtr = Tcl_NewStringObj( "expected a single character but got \"", -1); - Tcl_AppendLimitedToObj(resultPtr, Tcl_GetString(charPtr), + Tcl_AppendLimitedToObj(resultPtr, string, -1, 40, "..."); Tcl_AppendToObj(resultPtr, "\"", -1); Tcl_SetObjResult(interp, resultPtr); Tcl_SetErrorCode(interp, "TK", "VALUE", "FONT_SAMPLE", NULL); return TCL_ERROR; } -#if TCL_UTF_MAX == 4 - ucPtr = Tcl_GetUnicodeFromObj(charPtr, NULL); - uniChar = *ucPtr; - if (((uniChar & 0xFC00) == 0xD800) && (ucPtr[1] != 0x000)) { - if ((ucPtr[1] & 0xFC00) == 0xDC00) { - uniChar = ((uniChar & 0x3FF) << 10) + (ucPtr[1] & 0x3FF); - uniChar += 0x10000; - } - } -#else - uniChar = Tcl_GetUniChar(charPtr, 0); -#endif } /* @@ -1713,11 +1696,7 @@ Tk_PostscriptFontName( } else if (strcasecmp(family, "ZapfDingbats") == 0) { family = "ZapfDingbats"; } else { -#if TCL_UTF_MAX == 4 int ch; -#else - Tcl_UniChar ch; -#endif /* * Inline, capitalize the first letter of each word, lowercase the @@ -1735,11 +1714,7 @@ Tk_PostscriptFontName( src++; upper = 1; } -#if TCL_UTF_MAX == 4 - src += TkUtfToUniChar32(src, &ch); -#else - src += Tcl_UtfToUniChar(src, &ch); -#endif + src += TkUtfToUniChar2(src, &ch); if (upper) { ch = (Tcl_UniChar) Tcl_UniCharToUpper(ch); upper = 0; @@ -3276,11 +3251,7 @@ Tk_TextLayoutToPostscript( int i, j, len; const char *p, *glyphname; char uindex[5], c, *ps; -#if TCL_UTF_MAX == 4 int ch; -#else - Tcl_UniChar ch; -#endif Tcl_AppendToObj(psObj, "[(", -1); for (i = 0; i < layoutPtr->numChunks; i++, chunkPtr++) { @@ -3303,11 +3274,7 @@ Tk_TextLayoutToPostscript( * international postscript fonts. */ -#if TCL_UTF_MAX == 4 - p += TkUtfToUniChar32(p, &ch); -#else - p += Tcl_UtfToUniChar(p, &ch); -#endif + p += TkUtfToUniChar2(p, &ch); if ((ch == '(') || (ch == ')') || (ch == '\\') || (ch < 0x20)) { /* * Tricky point: the "03" is necessary in the sprintf below, @@ -3333,11 +3300,9 @@ Tk_TextLayoutToPostscript( * use the full glyph name. */ -#if TCL_UTF_MAX > 3 if (ch > 0xffff) { goto noMapping; } -#endif sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { diff --git a/generic/tkInt.h b/generic/tkInt.h index 367ef3a..6d86e08 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1232,8 +1232,10 @@ MODULE_SCOPE Status TkParseColor (Display * display, MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion); #endif -#if TCL_UTF_MAX == 4 -MODULE_SCOPE int TkUtfToUniChar32(const char *src, int *chPtr); +#if TCL_UTF_MAX > 4 +# define TkUtfToUniChar2 Tcl_UtfToUniChar +#else + MODULE_SCOPE int TkUtfToUniChar2(const char *src, int *chPtr); #endif /* diff --git a/generic/tkText.c b/generic/tkText.c index 834e842..dacadbe 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -4508,11 +4508,7 @@ TkTextGetTabs( Tcl_Obj **objv; TkTextTabArray *tabArrayPtr; TkTextTab *tabPtr; -#if TCL_UTF_MAX == 4 int ch; -#else - Tcl_UniChar ch; -#endif double prevStop, lastStop; /* * Map these strings to TkTextTabAlign values. @@ -4619,11 +4615,7 @@ TkTextGetTabs( * There may be a more efficient way of getting this. */ -#if TCL_UTF_MAX == 4 - TkUtfToUniChar32(Tcl_GetString(objv[i+1]), &ch); -#else - Tcl_UtfToUniChar(Tcl_GetString(objv[i+1]), &ch); -#endif + TkUtfToUniChar2(Tcl_GetString(objv[i+1]), &ch); if (!Tcl_UniCharIsAlpha(ch)) { continue; } diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 5faab36..026023e 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7581,8 +7581,8 @@ TkTextCharLayoutProc( if (bytesThatFit < maxBytes) { if ((bytesThatFit == 0) && noCharsYet) { - Tcl_UniChar ch; - int chLen = Tcl_UtfToUniChar(p, &ch); + int ch; + int chLen = TkUtfToUniChar2(p, &ch); #if TK_LAYOUT_WITH_BASE_CHUNKS bytesThatFit = CharChunkMeasureChars(chunkPtr, line, diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index f64a6d2..b794cdb 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -2298,13 +2298,9 @@ StartEnd( int chSize = 1; if (segPtr->typePtr == &tkTextCharType) { -#if TCL_UTF_MAX == 4 int ch; - chSize = TkUtfToUniChar32(segPtr->body.chars + offset, &ch); -#else - Tcl_UniChar ch; - chSize = Tcl_UtfToUniChar(segPtr->body.chars + offset, &ch); -#endif + + chSize = TkUtfToUniChar2(segPtr->body.chars + offset, &ch); if (!Tcl_UniCharIsWordChar(ch)) { break; } @@ -2347,13 +2343,9 @@ StartEnd( int chSize = 1; if (segPtr->typePtr == &tkTextCharType) { -#if TCL_UTF_MAX == 4 + int ch; - TkUtfToUniChar32(segPtr->body.chars + offset, &ch); -#else - Tcl_UniChar ch; - Tcl_UtfToUniChar(segPtr->body.chars + offset, &ch); -#endif + TkUtfToUniChar2(segPtr->body.chars + offset, &ch); if (!Tcl_UniCharIsWordChar(ch)) { break; } diff --git a/generic/tkUtil.c b/generic/tkUtil.c index fb796fd..a266cb3 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -1193,24 +1193,15 @@ TkSendVirtualEvent( Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); } -#if TCL_UTF_MAX == 4 +#if TCL_UTF_MAX <= 4 /* *--------------------------------------------------------------------------- * - * TkUtfToUniChar32 -- + * TkUtfToUniChar2 -- * - * Copied from Tcl_UtfToUniChar but using int instead of Tcl_UniChar! - * - * Extract the Tcl_UniChar represented by the UTF-8 string. Bad UTF-8 - * sequences are converted to valid Tcl_UniChars and processing - * continues. Equivalent to Plan 9 chartorune(). - * - * The caller must ensure that the source buffer is long enough that this - * routine does not run off the end and dereference non-existent memory - * looking for trail bytes. If the source buffer is known to be '\0' - * terminated, this cannot happen. Otherwise, the caller should call - * Tcl_UtfCharComplete() before calling this routine to ensure that - * enough bytes remain in the string. + * Almost the same as Tcl_UtfToUniChar but using int instead of Tcl_UniChar. + * This function is capable of collapsing a upper/lower pair to a single + * unicode character. So, up to 6 bytes (two UTF-8 characters) might be read. * * Results: * *chPtr is filled with the Tcl_UniChar, and the return value is the @@ -1223,75 +1214,29 @@ TkSendVirtualEvent( */ int -TkUtfToUniChar32( +TkUtfToUniChar2( const char *src, /* The UTF-8 string. */ int *chPtr) /* Filled with the Tcl_UniChar represented by * the UTF-8 string. */ { - int byte; - - /* - * Unroll 1 to 3 byte UTF-8 sequences, use loop to handle longer ones. - */ - - byte = *((unsigned char *) src); - if (byte < 0xC0) { - /* - * Handles properly formed UTF-8 characters between 0x01 and 0x7F. - * Also treats \0 and naked trail bytes 0x80 to 0xBF as valid - * characters representing themselves. - */ - - *chPtr = byte; - return 1; - } else if (byte < 0xE0) { - if ((src[1] & 0xC0) == 0x80) { - /* - * Two-byte-character lead-byte followed by a trail-byte. - */ - - *chPtr = ((byte & 0x1F) << 6) | (src[1] & 0x3F); - return 2; + Tcl_UniChar uniChar = 0; + + int len = Tcl_UtfToUniChar(src, &uniChar); + if ((uniChar & 0xfc00) == 0xd800) { + Tcl_UniChar high = uniChar; + /* This can only happen when Tcl is compiled with TCL_UTF_MAX=4, + * or when a high surrogate character is detected */ + int len2 = Tcl_UtfToUniChar(src+len, &uniChar); + if ((uniChar & 0xfc00) == 0xdc00) { + *chPtr = ((high & 0x3ff) << 10) | (uniChar & 0x3ff) | 0x10000; + len += len2; + } else { + *chPtr = high; } - - /* - * A two-byte-character lead-byte not followed by trail-byte - * represents itself. - */ - } else if (byte < 0xF0) { - if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80)) { - /* - * Three-byte-character lead byte followed by two trail bytes. - */ - - *chPtr = ((byte & 0x0F) << 12) - | ((src[1] & 0x3F) << 6) | (src[2] & 0x3F); - return 3; - } - - /* - * A three-byte-character lead-byte not followed by two trail-bytes - * represents itself. - */ - } else if (byte < 0xF8) { - if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80) && ((src[3] & 0xC0) == 0x80)) { - /* - * Four-byte-character lead byte followed by three trail bytes. - */ - - *chPtr = ((byte & 0x0E) << 18) | ((src[1] & 0x3F) << 12) - | ((src[2] & 0x3F) << 6) | (src[3] & 0x3F); - return 4; - } - - /* - * A three-byte-character lead-byte not followed by two trail-bytes - * represents itself. - */ + } else { + *chPtr = uniChar; } - - *chPtr = byte; - return 1; + return len; } #endif /* diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 63ebc5f..d80e1fd 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -282,16 +282,10 @@ static char *EntryDisplayString(const char *showChar, int numChars) { char *displayString, *p; int size; - char buf[4]; -#if TCL_UTF_MAX == 4 - int ch; - - TkUtfToUniChar32(showChar, &ch); -#else Tcl_UniChar ch; + char buf[4]; Tcl_UtfToUniChar(showChar, &ch); -#endif size = Tcl_UniCharToUtf(ch, buf); p = displayString = ckalloc(numChars * size + 1); @@ -412,11 +406,7 @@ ExpandPercents( int number, length; const char *string; int stringLength; -#if TCL_UTF_MAX == 4 - int ch; -#else Tcl_UniChar ch; -#endif char numStorage[2*TCL_INTEGER_SPACE]; while (*template) { @@ -440,11 +430,7 @@ ExpandPercents( */ ++template; /* skip over % */ if (*template != '\0') { -#if TCL_UTF_MAX == 4 - template += TkUtfToUniChar32(template, &ch); -#else template += Tcl_UtfToUniChar(template, &ch); -#endif } else { ch = '%'; } diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index b10fddd..681d1d1 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -35,13 +35,8 @@ static const char *const encodingList[] = { * family": the foundry, face name, and charset. */ -#if TCL_UTF_MAX > 3 #define FONTMAP_SHIFT 12 #define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT)) -#else -#define FONTMAP_SHIFT 10 -#define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT)) -#endif #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT) typedef struct FontFamily { diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index ee87657..0ea1ec6 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -54,12 +54,6 @@ typedef struct ThreadSpecificData { Region clipRegion; /* The clipping region, or None. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; - -#if TCL_UTF_MAX == 4 -#define UtfToUniChar(src, chPtr) TkUtfToUniChar32(src, chPtr) -#else -#define UtfToUniChar(src, chPtr) Tcl_UtfToUniChar(src, chPtr) -#endif /* * Package initialization: @@ -674,13 +668,9 @@ Tk_MeasureChars( curByte = 0; sawNonSpace = 0; while (numBytes > 0) { -#if TCL_UTF_MAX == 4 int unichar; -#else - Tcl_UniChar unichar; -#endif - clen = UtfToUniChar(source, &unichar); + clen = TkUtfToUniChar2(source, &unichar); c = (FcChar32) unichar; if (clen <= 0) { diff --git a/win/tkWinFont.c b/win/tkWinFont.c index e413e7d..30638ca 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -26,13 +26,8 @@ * Under Windows, a "font family" is uniquely identified by its face name. */ -#if TCL_UTF_MAX > 3 #define FONTMAP_SHIFT 12 #define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT)) -#else -#define FONTMAP_SHIFT 10 -#define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT)) -#endif #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT) typedef struct FontFamily { @@ -233,11 +228,6 @@ static inline HFONT SelectFont(HDC hdc, WinFont *fontPtr, SubFont *subFontPtr, double angle); static inline void SwapLong(PULONG p); static inline void SwapShort(USHORT *p); -#if TCL_UTF_MAX == 4 -#define UtfToUniChar(src, chPtr) TkUtfToUniChar32(src, chPtr) -#else -#define UtfToUniChar(src, chPtr) Tcl_UtfToUniChar(src, chPtr) -#endif static int CALLBACK WinFontCanUseProc(ENUMLOGFONT *lfPtr, NEWTEXTMETRIC *tmPtr, int fontType, LPARAM lParam); @@ -837,11 +827,7 @@ Tk_MeasureChars( HFONT oldFont; WinFont *fontPtr; int curX, moretomeasure; -#if TCL_UTF_MAX == 4 int ch; -#else - Tcl_UniChar ch; -#endif SIZE size; FontFamily *familyPtr; Tcl_DString runString; @@ -872,7 +858,7 @@ Tk_MeasureChars( start = source; end = start + numBytes; for (p = start; p < end; ) { - next = p + UtfToUniChar(p, &ch); + next = p + TkUtfToUniChar2(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { familyPtr = lastSubFontPtr->familyPtr; @@ -934,7 +920,7 @@ Tk_MeasureChars( familyPtr = lastSubFontPtr->familyPtr; Tcl_DStringInit(&runString); for (p = start; p < end; ) { - next = p + UtfToUniChar(p, &ch); + next = p + TkUtfToUniChar2(p, &ch); Tcl_UtfToExternal(NULL, familyPtr->encoding, p, (int) (next - p), 0, NULL, buf, sizeof(buf), NULL, &dstWrote, NULL); @@ -983,17 +969,13 @@ Tk_MeasureChars( */ const char *lastWordBreak = NULL; -#if TCL_UTF_MAX == 4 int ch2; -#else - Tcl_UniChar ch2; -#endif end = p; p = source; ch = ' '; while (p < end) { - next = p + UtfToUniChar(p, &ch2); + next = p + TkUtfToUniChar2(p, &ch2); if ((ch != ' ') && (ch2 == ' ')) { lastWordBreak = p; } @@ -1460,11 +1442,7 @@ MultiFontTextOut( * string when drawing. */ double angle) { -#if TCL_UTF_MAX == 4 int ch; -#else - Tcl_UniChar ch; -#endif SIZE size; HFONT oldFont; FontFamily *familyPtr; @@ -1479,7 +1457,7 @@ MultiFontTextOut( end = source + numBytes; for (p = source; p < end; ) { - next = p + UtfToUniChar(p, &ch); + next = p + TkUtfToUniChar2(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { if (p > source) { @@ -2209,7 +2187,7 @@ FontMapLoadPage( { FontFamily *familyPtr; Tcl_Encoding encoding; - char src[TCL_UTF_MAX], buf[16]; + char src[XMaxTransChars], buf[16]; USHORT *startCount, *endCount; int i, j, bitOffset, end, segCount; diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 815ff3b..2698c4d 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -113,6 +113,7 @@ TkpGetString( Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { + char buf[XMaxTransChars]; int len; @@ -121,7 +122,7 @@ TkpGetString( */ len = Tcl_UniCharToUtf(keyEv->keycode, buf); - if ((keyEv->keycode <= 0xffff) || (len > 3)) { + if ((keyEv->keycode <= 0xffff) || (len == XMaxTransChars)) { Tcl_DStringAppend(dsPtr, buf, len); } else { Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf); -- cgit v0.12 From bdb580aa2563588e6e1f5090bb9b89369e2f2d4f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 19 Sep 2016 10:14:52 +0000 Subject: More simplifications --- generic/tkEntry.c | 8 ++++---- generic/tkFont.c | 6 +++--- generic/tkInt.h | 6 ++++-- generic/tkText.c | 6 +++--- generic/tkTextDisp.c | 2 +- generic/tkTextIndex.c | 4 ++-- generic/tkUtil.c | 37 +++++++++++++++++++++++++++++++++++-- generic/ttk/ttkEntry.c | 14 +++++++------- unix/tkUnixFont.c | 20 ++++++++++++++------ unix/tkUnixRFont.c | 2 +- win/tkWinFont.c | 8 ++++---- win/tkWinKey.c | 38 +++++--------------------------------- win/tkWinX.c | 13 ++++++------- 13 files changed, 89 insertions(+), 75 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index a66cf18..34f11d2 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1926,8 +1926,8 @@ EntryComputeGeometry( */ if (entryPtr->showChar != NULL) { - Tcl_UniChar ch; - char buf[4]; + int ch; + char buf[6]; int size; /* @@ -1937,8 +1937,8 @@ EntryComputeGeometry( * resulting string. */ - Tcl_UtfToUniChar(entryPtr->showChar, &ch); - size = Tcl_UniCharToUtf(ch, buf); + TkUtfToUniChar(entryPtr->showChar, &ch); + size = TkUniCharToUtf(ch, buf); entryPtr->numDisplayBytes = entryPtr->numChars * size; p = ckalloc(entryPtr->numDisplayBytes + 1); diff --git a/generic/tkFont.c b/generic/tkFont.c index 4a45691..1947666 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -563,7 +563,7 @@ Tk_FontObjCmd( if (charPtr != NULL) { const char *string = Tcl_GetString(charPtr); - int len = TkUtfToUniChar2(string, &uniChar); + int len = TkUtfToUniChar(string, &uniChar); if (len != charPtr->length) { resultPtr = Tcl_NewStringObj( @@ -1714,7 +1714,7 @@ Tk_PostscriptFontName( src++; upper = 1; } - src += TkUtfToUniChar2(src, &ch); + src += TkUtfToUniChar(src, &ch); if (upper) { ch = (Tcl_UniChar) Tcl_UniCharToUpper(ch); upper = 0; @@ -3274,7 +3274,7 @@ Tk_TextLayoutToPostscript( * international postscript fonts. */ - p += TkUtfToUniChar2(p, &ch); + p += TkUtfToUniChar(p, &ch); if ((ch == '(') || (ch == ')') || (ch == '\\') || (ch < 0x20)) { /* * Tricky point: the "03" is necessary in the sprintf below, diff --git a/generic/tkInt.h b/generic/tkInt.h index 6d86e08..1615a81 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1233,9 +1233,11 @@ MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion); #endif #if TCL_UTF_MAX > 4 -# define TkUtfToUniChar2 Tcl_UtfToUniChar +# define TkUtfToUniChar Tcl_UtfToUniChar +# define TkUniCharToUtf Tcl_UniCharToUtf #else - MODULE_SCOPE int TkUtfToUniChar2(const char *src, int *chPtr); + MODULE_SCOPE int TkUtfToUniChar(const char *, int *); + MODULE_SCOPE int TkUniCharToUtf(int, char *); #endif /* diff --git a/generic/tkText.c b/generic/tkText.c index dacadbe..8ae17a5 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -4615,7 +4615,7 @@ TkTextGetTabs( * There may be a more efficient way of getting this. */ - TkUtfToUniChar2(Tcl_GetString(objv[i+1]), &ch); + TkUtfToUniChar(Tcl_GetString(objv[i+1]), &ch); if (!Tcl_UniCharIsAlpha(ch)) { continue; } @@ -5966,7 +5966,7 @@ SearchCore( CLANG_ASSERT(pattern); do { - Tcl_UniChar ch; + int ch; const char *p; int lastFullLine = lastOffset; @@ -6196,7 +6196,7 @@ SearchCore( } } else { firstOffset = p - startOfLine + - Tcl_UtfToUniChar(startOfLine+matchOffset,&ch); + TkUtfToUniChar(startOfLine+matchOffset,&ch); } } } while (searchSpecPtr->all); diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 026023e..eb917cf 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7582,7 +7582,7 @@ TkTextCharLayoutProc( if (bytesThatFit < maxBytes) { if ((bytesThatFit == 0) && noCharsYet) { int ch; - int chLen = TkUtfToUniChar2(p, &ch); + int chLen = TkUtfToUniChar(p, &ch); #if TK_LAYOUT_WITH_BASE_CHUNKS bytesThatFit = CharChunkMeasureChars(chunkPtr, line, diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index b794cdb..7aebc84 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -2300,7 +2300,7 @@ StartEnd( if (segPtr->typePtr == &tkTextCharType) { int ch; - chSize = TkUtfToUniChar2(segPtr->body.chars + offset, &ch); + chSize = TkUtfToUniChar(segPtr->body.chars + offset, &ch); if (!Tcl_UniCharIsWordChar(ch)) { break; } @@ -2345,7 +2345,7 @@ StartEnd( if (segPtr->typePtr == &tkTextCharType) { int ch; - TkUtfToUniChar2(segPtr->body.chars + offset, &ch); + TkUtfToUniChar(segPtr->body.chars + offset, &ch); if (!Tcl_UniCharIsWordChar(ch)) { break; } diff --git a/generic/tkUtil.c b/generic/tkUtil.c index a266cb3..19b343e 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -1197,7 +1197,7 @@ TkSendVirtualEvent( /* *--------------------------------------------------------------------------- * - * TkUtfToUniChar2 -- + * TkUtfToUniChar -- * * Almost the same as Tcl_UtfToUniChar but using int instead of Tcl_UniChar. * This function is capable of collapsing a upper/lower pair to a single @@ -1214,7 +1214,7 @@ TkSendVirtualEvent( */ int -TkUtfToUniChar2( +TkUtfToUniChar( const char *src, /* The UTF-8 string. */ int *chPtr) /* Filled with the Tcl_UniChar represented by * the UTF-8 string. */ @@ -1238,6 +1238,39 @@ TkUtfToUniChar2( } return len; } + +/* + *--------------------------------------------------------------------------- + * + * TkUniCharToUtf -- + * + * Almost the same as Tcl_UniCharToUtf but producing surrogates if + * TCL_UTF_MAX==3. + * + * Results: + * *buf is filled with the UTF-8 string, and the return value is the + * number of bytes produced. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +int TkUniCharToUtf(int ch, char *buf) +{ + int size = Tcl_UniCharToUtf(ch, buf); + if ((ch > 0xffff) && (size < 4)) { + /* Hey, this is wrong, we must be running TCL_UTF_MAX==3 + * The best thing we can do is spit out 2 surrogates */ + ch -= 0x10000; + size = Tcl_UniCharToUtf(((ch >> 10) | 0xd800), buf); + size += Tcl_UniCharToUtf(((ch & 0x3ff) | 0xdc00), buf+size); + } + return size; +} + + #endif /* * Local Variables: diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index d80e1fd..a25574a 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -282,11 +282,11 @@ static char *EntryDisplayString(const char *showChar, int numChars) { char *displayString, *p; int size; - Tcl_UniChar ch; - char buf[4]; + int ch; + char buf[6]; - Tcl_UtfToUniChar(showChar, &ch); - size = Tcl_UniCharToUtf(ch, buf); + TkUtfToUniChar(showChar, &ch); + size = TkUniCharToUtf(ch, buf); p = displayString = ckalloc(numChars * size + 1); while (numChars--) { @@ -406,7 +406,7 @@ ExpandPercents( int number, length; const char *string; int stringLength; - Tcl_UniChar ch; + int ch; char numStorage[2*TCL_INTEGER_SPACE]; while (*template) { @@ -430,7 +430,7 @@ ExpandPercents( */ ++template; /* skip over % */ if (*template != '\0') { - template += Tcl_UtfToUniChar(template, &ch); + template += TkUtfToUniChar(template, &ch); } else { ch = '%'; } @@ -480,7 +480,7 @@ ExpandPercents( string = Tk_PathName(entryPtr->core.tkwin); break; default: - length = Tcl_UniCharToUtf(ch, numStorage); + length = TkUniCharToUtf(ch, numStorage); numStorage[length] = '\0'; string = numStorage; break; diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 681d1d1..ce4eca9 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -405,7 +405,7 @@ ControlUtfProc( { const char *srcStart, *srcEnd; char *dstStart, *dstEnd; - Tcl_UniChar ch; + int ch; int result; static char hexChars[] = "0123456789abcdef"; static char mapChars[] = { @@ -426,9 +426,9 @@ ControlUtfProc( result = TCL_CONVERT_NOSPACE; break; } - src += Tcl_UtfToUniChar(src, &ch); + src += TkUtfToUniChar(src, &ch); dst[0] = '\\'; - if ((ch < sizeof(mapChars)) && (mapChars[ch] != 0)) { + if (((size_t) ch < sizeof(mapChars)) && (mapChars[ch] != 0)) { dst[1] = mapChars[ch]; dst += 2; } else if (ch < 256) { @@ -436,13 +436,21 @@ ControlUtfProc( dst[2] = hexChars[(ch >> 4) & 0xf]; dst[3] = hexChars[ch & 0xf]; dst += 4; - } else { + } else if (ch < 0x10000) { dst[1] = 'u'; dst[2] = hexChars[(ch >> 12) & 0xf]; dst[3] = hexChars[(ch >> 8) & 0xf]; dst[4] = hexChars[(ch >> 4) & 0xf]; dst[5] = hexChars[ch & 0xf]; dst += 6; + } else { + /* TODO we can do better here */ + dst[1] = 'u'; + dst[2] = 'f'; + dst[3] = 'f'; + dst[4] = 'f'; + dst[5] = 'd'; + dst += 6; } } *srcReadPtr = src - srcStart; @@ -1027,7 +1035,7 @@ Tk_MeasureChars( curByte = 0; } else if (maxLength < 0) { const char *p, *end, *next; - Tcl_UniChar ch; + int ch; SubFont *thisSubFontPtr; FontFamily *familyPtr; Tcl_DString runString; @@ -1043,7 +1051,7 @@ Tk_MeasureChars( curX = 0; end = source + numBytes; for (p = source; p < end; ) { - next = p + Tcl_UtfToUniChar(p, &ch); + next = p + TkUtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { familyPtr = lastSubFontPtr->familyPtr; diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 0ea1ec6..cf4127d 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -670,7 +670,7 @@ Tk_MeasureChars( while (numBytes > 0) { int unichar; - clen = TkUtfToUniChar2(source, &unichar); + clen = TkUtfToUniChar(source, &unichar); c = (FcChar32) unichar; if (clen <= 0) { diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 30638ca..7c6c0ba 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -858,7 +858,7 @@ Tk_MeasureChars( start = source; end = start + numBytes; for (p = start; p < end; ) { - next = p + TkUtfToUniChar2(p, &ch); + next = p + TkUtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { familyPtr = lastSubFontPtr->familyPtr; @@ -920,7 +920,7 @@ Tk_MeasureChars( familyPtr = lastSubFontPtr->familyPtr; Tcl_DStringInit(&runString); for (p = start; p < end; ) { - next = p + TkUtfToUniChar2(p, &ch); + next = p + TkUtfToUniChar(p, &ch); Tcl_UtfToExternal(NULL, familyPtr->encoding, p, (int) (next - p), 0, NULL, buf, sizeof(buf), NULL, &dstWrote, NULL); @@ -975,7 +975,7 @@ Tk_MeasureChars( p = source; ch = ' '; while (p < end) { - next = p + TkUtfToUniChar2(p, &ch2); + next = p + TkUtfToUniChar(p, &ch2); if ((ch != ' ') && (ch2 == ' ')) { lastWordBreak = p; } @@ -1457,7 +1457,7 @@ MultiFontTextOut( end = source + numBytes; for (p = source; p < end; ) { - next = p + TkUtfToUniChar2(p, &ch); + next = p + TkUtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { if (p > source) { diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 2698c4d..7fee101 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -88,6 +88,8 @@ TkpGetString( * result. */ { XKeyEvent *keyEv = &eventPtr->xkey; + int len; + char buf[6]; Tcl_DStringInit(dsPtr); if (keyEv->send_event == -1) { @@ -95,41 +97,14 @@ TkpGetString( Tcl_ExternalToUtfDString(TkWinGetKeyInputEncoding(), keyEv->trans_chars, keyEv->nbytes, dsPtr); } - } else if (keyEv->send_event == -2) { - /* - * Special case for win2000 multi-lingal IME input. xkey.trans_chars[] - * already contains a UNICODE char. - */ - - int unichar; - char buf[XMaxTransChars]; - int len; - - unichar = keyEv->trans_chars[1] & 0xff; - unichar <<= 8; - unichar |= keyEv->trans_chars[0] & 0xff; - - len = Tcl_UniCharToUtf((Tcl_UniChar) unichar, buf); - - Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { - char buf[XMaxTransChars]; - int len; - /* - * Special case for WM_UNICHAR. + * Special case for WM_UNICHAR and win2000 multi-lingal IME input */ - len = Tcl_UniCharToUtf(keyEv->keycode, buf); - if ((keyEv->keycode <= 0xffff) || (len == XMaxTransChars)) { - Tcl_DStringAppend(dsPtr, buf, len); - } else { - Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf); - Tcl_DStringAppend(dsPtr, buf, 3); - Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) & 0x3ff) | 0xdc00, buf); - Tcl_DStringAppend(dsPtr, buf, 3); - } + len = TkUniCharToUtf(keyEv->keycode, buf); + Tcl_DStringAppend(dsPtr, buf, len); } else { /* * This is an event generated from generic code. It has no nchars or @@ -140,9 +115,6 @@ TkpGetString( if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256)) || (keysym == XK_Return) || (keysym == XK_Tab)) { - char buf[XMaxTransChars]; - int len; - len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf); Tcl_DStringAppend(dsPtr, buf, len); } diff --git a/win/tkWinX.c b/win/tkWinX.c index 6be54e2..ce73aac 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1580,8 +1580,8 @@ HandleIMEComposition( /* * Set up the fields pertinent to key event. * - * We set send_event to the special value of -2, so that TkpGetString - * in tkWinKey.c knows that trans_chars[] already contains a UNICODE + * We set send_event to the special value of -3, so that TkpGetString + * in tkWinKey.c knows that keycode already contains a UNICODE * char and there's no need to do encoding conversion. * * Note that the event *must* be zeroed out first; Tk plays cunning @@ -1592,7 +1592,7 @@ HandleIMEComposition( memset(&event, 0, sizeof(XEvent)); event.xkey.serial = winPtr->display->request++; - event.xkey.send_event = -2; + event.xkey.send_event = -3; event.xkey.display = winPtr->display; event.xkey.window = winPtr->window; event.xkey.root = RootWindow(winPtr->display, winPtr->screenNum); @@ -1600,8 +1600,7 @@ HandleIMEComposition( event.xkey.state = TkWinGetModifierState(); event.xkey.time = TkpGetMS(); event.xkey.same_screen = True; - event.xkey.keycode = 0; - event.xkey.nbytes = 2; + event.xkey.nbytes = 0; for (i=0; i Date: Mon, 19 Sep 2016 18:52:19 +0000 Subject: Permit static linking to the MSVCRT as a stand-alone option. Enable WinXP SDK compatibility. --- win/rules.vc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/win/rules.vc b/win/rules.vc index 0d8cd6b..503df50 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -159,7 +159,7 @@ DEBUGFLAGS = $(DEBUGFLAGS) -RTC1 DEBUGFLAGS = $(DEBUGFLAGS) -GZ !endif -COMPILERFLAGS =-W3 -DUNICODE -D_UNICODE +COMPILERFLAGS =-W3 -DUNICODE -D_UNICODE -D_USING_V110_SDK71_=1 # In v13 -GL and -YX are incompatible. !if [nmakehlp -c -YX] @@ -230,6 +230,10 @@ STATIC_BUILD = 1 !else STATIC_BUILD = 0 !endif +!if [nmakehlp -f $(OPTS) "nomsvcrt"] +!message *** Doing nomsvcrt +MSVCRT = 0 +!else !if [nmakehlp -f $(OPTS) "msvcrt"] !message *** Doing msvcrt MSVCRT = 1 @@ -240,6 +244,7 @@ MSVCRT = 1 MSVCRT = 0 !endif !endif +!endif !if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD) !message *** Doing staticpkg TCL_USE_STATIC_PACKAGES = 1 -- cgit v0.12 From 3da9b75d3711e0538834813e7246990dff8e8c3a Mon Sep 17 00:00:00 2001 From: oehhar Date: Wed, 21 Sep 2016 08:31:16 +0000 Subject: Tri-state buttons not working for non-native themes. Bug [3217462] --- library/ttk/clamTheme.tcl | 8 ++++++-- library/ttk/defaults.tcl | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index f184ea0..398a524 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -17,6 +17,8 @@ namespace eval ttk::theme::clam { -lightest "#ffffff" -selectbg "#4a6984" -selectfg "#ffffff" + -altindicator "#9fbdd8" + -disabledaltindicator "#c0c0c0" } ttk::style theme settings clam { @@ -80,9 +82,11 @@ namespace eval ttk::theme::clam { -indicatormargin {1 1 4 1} \ -padding 2 ; ttk::style map TCheckbutton -indicatorbackground \ - [list disabled $colors(-frame) pressed $colors(-frame)] + [list disabled $colors(-frame) pressed $colors(-frame) \ + {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator)] ttk::style map TRadiobutton -indicatorbackground \ - [list disabled $colors(-frame) pressed $colors(-frame)] + [list disabled $colors(-frame) pressed $colors(-frame) \ + {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator)] ttk::style configure TMenubutton \ -width -11 -padding 5 -relief raised diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl index 05a46bd..2ab6c9c 100644 --- a/library/ttk/defaults.tcl +++ b/library/ttk/defaults.tcl @@ -15,6 +15,9 @@ namespace eval ttk::theme::default { -darker "#c3c3c3" -disabledfg "#a3a3a3" -indicator "#4a6984" + -disabledindicator "#a3a3a3" + -altindicator "#9fbdd8" + -disabledaltindicator "#c0c0c0" } ttk::style theme settings default { @@ -45,12 +48,20 @@ namespace eval ttk::theme::default { ttk::style configure TCheckbutton \ -indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1 ttk::style map TCheckbutton -indicatorcolor \ - [list pressed $colors(-activebg) selected $colors(-indicator)] + [list pressed $colors(-activebg) \ + {!disabled selected} $colors(-indicator) {disabled selected} $colors(-disabledindicator) \ + {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator)] + ttk::style map TCheckbutton -indicatorrelief \ + [list alternate raised] ttk::style configure TRadiobutton \ -indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1 ttk::style map TRadiobutton -indicatorcolor \ - [list pressed $colors(-activebg) selected $colors(-indicator)] + [list pressed $colors(-activebg) \ + {!disabled selected} $colors(-indicator) {disabled selected} $colors(-disabledindicator) \ + {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator)] + ttk::style map TRadiobutton -indicatorrelief \ + [list alternate raised] ttk::style configure TMenubutton \ -relief raised -padding "10 3" -- cgit v0.12 From 713d51c8519164eee84302b30e4f36706e2e1952 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 21 Sep 2016 12:40:22 +0000 Subject: Make it more likely that compiles with VS2012/VS2013 actually work on Windows XP. See: [https://tedwvc.wordpress.com/2014/01/01/how-to-target-xp-with-vc2012-or-vc2013-and-continue-to-use-the-windows-8-x-sdk/] --- win/Makefile.in | 2 +- win/rules.vc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/win/Makefile.in b/win/Makefile.in index 1d18b60..632e216 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -171,7 +171,7 @@ NO_DEPRECATED_FLAGS = #CFLAGS = $(CFLAGS_DEBUG) #CFLAGS = $(CFLAGS_OPTIMIZE) #CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE) -CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ $(NO_DEPRECATED_FLAGS) +CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ $(NO_DEPRECATED_FLAGS) -D_ATL_XP_TARGETING # Special compiler flags to use when building man2tcl on Windows. MAN2TCLFLAGS = @MAN2TCLFLAGS@ diff --git a/win/rules.vc b/win/rules.vc index a43fac6..e38fd1a 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -159,7 +159,7 @@ DEBUGFLAGS = $(DEBUGFLAGS) -RTC1 DEBUGFLAGS = $(DEBUGFLAGS) -GZ !endif -COMPILERFLAGS =-W3 +COMPILERFLAGS =-W3 /D_ATL_XP_TARGETING # In v13 -GL and -YX are incompatible. !if [nmakehlp -c -YX] -- cgit v0.12 From 17993a942afc2c375f311dd73083e4f1d3339dab Mon Sep 17 00:00:00 2001 From: patthoyts Date: Wed, 21 Sep 2016 23:41:44 +0000 Subject: [3126428] Repaint ttk labels and buttons when the image is changed. In Tk the images associated with labels and buttons have their image changed callback set to cause the widget to be redrawn if the image is changed in any way. However, this has not been done for the ttk equivalent widgets. --- generic/ttk/ttkButton.c | 13 +++++++++++-- generic/ttk/ttkImage.c | 36 +++++++++++++++++++++++++++++++++--- generic/ttk/ttkTheme.h | 2 ++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index bc44f25..c00754b 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -136,6 +136,15 @@ BaseCleanup(void *recordPtr) TtkFreeImageSpec(basePtr->base.imageSpec); } +static void +BaseImageChanged( + ClientData clientData, int x, int y, int width, int height, + int imageWidth, int imageHeight) +{ + Base *basePtr = (Base *)clientData; + TtkResizeWidget(&basePtr->core); +} + static int BaseConfigure(Tcl_Interp *interp, void *recordPtr, int mask) { Base *basePtr = recordPtr; @@ -149,8 +158,8 @@ static int BaseConfigure(Tcl_Interp *interp, void *recordPtr, int mask) } if (basePtr->base.imageObj) { - imageSpec = TtkGetImageSpec( - interp, basePtr->core.tkwin, basePtr->base.imageObj); + imageSpec = TtkGetImageSpecEx( + interp, basePtr->core.tkwin, basePtr->base.imageObj, BaseImageChanged, basePtr); if (!imageSpec) { goto error; } diff --git a/generic/ttk/ttkImage.c b/generic/ttk/ttkImage.c index 2b12864..c435a50 100644 --- a/generic/ttk/ttkImage.c +++ b/generic/ttk/ttkImage.c @@ -25,6 +25,8 @@ struct TtkImageSpec { int mapCount; /* #state-specific overrides */ Ttk_StateSpec *states; /* array[mapCount] of states ... */ Tk_Image *images; /* ... per-state images to use */ + Tk_ImageChangedProc *imageChanged; + ClientData imageChangedClientData; }; /* NullImageChanged -- @@ -34,15 +36,41 @@ static void NullImageChanged(ClientData clientData, int x, int y, int width, int height, int imageWidth, int imageHeight) { /* No-op */ } +/* ImageSpecImageChanged -- + * Image changes should trigger a repaint. + */ +static void ImageSpecImageChanged(ClientData clientData, + int x, int y, int width, int height, int imageWidth, int imageHeight) +{ + Ttk_ImageSpec *imageSpec = (Ttk_ImageSpec *)clientData; + if (imageSpec->imageChanged != NULL) { + imageSpec->imageChanged(imageSpec->imageChangedClientData, + x, y, width, height, + imageWidth, imageHeight); + } +} + /* TtkGetImageSpec -- * Constructs a Ttk_ImageSpec * from a Tcl_Obj *. - * Result must be released using TtkFreeImageSpec. + * Result must be released using TtkFreeImageSpec. * - * TODO: Need a variant of this that takes a user-specified ImageChanged proc */ Ttk_ImageSpec * TtkGetImageSpec(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) { + return TtkGetImageSpecEx(interp, tkwin, objPtr, NULL, NULL); +} + +/* TtkGetImageSpecEx -- + * Constructs a Ttk_ImageSpec * from a Tcl_Obj *. + * Result must be released using TtkFreeImageSpec. + * imageChangedProc will be called when not NULL when + * the image changes to allow widgets to repaint. + */ +Ttk_ImageSpec * +TtkGetImageSpecEx(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, + Tk_ImageChangedProc *imageChangedProc, ClientData imageChangedClientData) +{ Ttk_ImageSpec *imageSpec = 0; int i = 0, n = 0, objc; Tcl_Obj **objv; @@ -52,6 +80,8 @@ TtkGetImageSpec(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) imageSpec->mapCount = 0; imageSpec->states = 0; imageSpec->images = 0; + imageSpec->imageChanged = imageChangedProc; + imageSpec->imageChangedClientData = imageChangedClientData; if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { goto error; @@ -73,7 +103,7 @@ TtkGetImageSpec(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) /* Get base image: */ imageSpec->baseImage = Tk_GetImage( - interp, tkwin, Tcl_GetString(objv[0]), NullImageChanged, NULL); + interp, tkwin, Tcl_GetString(objv[0]), ImageSpecImageChanged, imageSpec); if (!imageSpec->baseImage) { goto error; } diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h index 7bf2a7f..9251dea 100644 --- a/generic/ttk/ttkTheme.h +++ b/generic/ttk/ttkTheme.h @@ -372,6 +372,8 @@ MODULE_SCOPE void Ttk_RegisterNamedColor(Ttk_ResourceCache, const char *, XColor typedef struct TtkImageSpec Ttk_ImageSpec; TTKAPI Ttk_ImageSpec *TtkGetImageSpec(Tcl_Interp *, Tk_Window, Tcl_Obj *); +TTKAPI Ttk_ImageSpec *TtkGetImageSpecEx(Tcl_Interp *, Tk_Window, Tcl_Obj *, + Tk_ImageChangedProc *, ClientData); TTKAPI void TtkFreeImageSpec(Ttk_ImageSpec *); TTKAPI Tk_Image TtkSelectImage(Ttk_ImageSpec *, Ttk_State); -- cgit v0.12 From 1b5c660e330eddb121d8400dafafffa917beeb46 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Thu, 22 Sep 2016 13:42:38 +0000 Subject: Correct expansion of the spinbox textarea for the vista theme. The spinbox textarea should stretch to fill the widget and does so with all except the vista theme. Added a test to check for this expansion to avoid regression. Fix identified Kumba on StackOverflow ( https://stackoverflow.com/a/36393680/291641 ) --- library/ttk/vistaTheme.tcl | 2 +- tests/ttk/spinbox.test | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/library/ttk/vistaTheme.tcl b/library/ttk/vistaTheme.tcl index 99410cb..3f75f51 100644 --- a/library/ttk/vistaTheme.tcl +++ b/library/ttk/vistaTheme.tcl @@ -133,7 +133,7 @@ namespace eval ttk::theme::vista { Spinbox.background -sticky news -children { Spinbox.padding -sticky news -children { Spinbox.innerbg -sticky news -children { - Spinbox.textarea -expand 1 -sticky {} + Spinbox.textarea -expand 1 } } Spinbox.uparrow -side top -sticky ens diff --git a/tests/ttk/spinbox.test b/tests/ttk/spinbox.test index 32b77af..08f2bda 100644 --- a/tests/ttk/spinbox.test +++ b/tests/ttk/spinbox.test @@ -199,6 +199,27 @@ test spinbox-2.4 "current command -- value not in list" -constraints nyi -setup destroy .sb } -result -1 +test spinbox-3.0 "textarea should expand to fill widget" -setup { + set SBV 5 + set ::spinbox_test {} + ttk::spinbox .sb -from 0 -to 10 -textvariable SBV +} -body { + grid .sb -sticky ew + grid columnconfigure . 0 -weight 1 + bind . { + after idle { + wm geometry . "210x80" + after 100 {set ::spinbox_test [.sb identify element 5 5]} + } + bind . {} + } + after 500 {set ::spinbox_wait 1} ; vwait ::spinbox_wait + set ::spinbox_test +} -cleanup { + destroy .sb + unset -nocomplain ::spinbox_test SBV +} -result {textarea} + # nostomp: NB intentional difference between ttk::spinbox and tk::spinbox; # see also #1439266 # -- cgit v0.12 From 86e95cea7354485132002aeb8674a218a3cb675f Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 24 Sep 2016 16:57:23 +0000 Subject: Improved formatting --- library/ttk/clamTheme.tcl | 24 ++++++++++++------------ library/ttk/defaults.tcl | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index 398a524..eddacdd 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -7,18 +7,18 @@ namespace eval ttk::theme::clam { variable colors array set colors { - -disabledfg "#999999" - -frame "#dcdad5" - -window "#ffffff" - -dark "#cfcdc8" - -darker "#bab5ab" - -darkest "#9e9a91" - -lighter "#eeebe7" - -lightest "#ffffff" - -selectbg "#4a6984" - -selectfg "#ffffff" - -altindicator "#9fbdd8" - -disabledaltindicator "#c0c0c0" + -disabledfg "#999999" + -frame "#dcdad5" + -window "#ffffff" + -dark "#cfcdc8" + -darker "#bab5ab" + -darkest "#9e9a91" + -lighter "#eeebe7" + -lightest "#ffffff" + -selectbg "#4a6984" + -selectfg "#ffffff" + -altindicator "#9fbdd8" + -disabledaltindicator "#c0c0c0" } ttk::style theme settings clam { diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl index 2ab6c9c..548d5fe 100644 --- a/library/ttk/defaults.tcl +++ b/library/ttk/defaults.tcl @@ -5,19 +5,19 @@ namespace eval ttk::theme::default { variable colors array set colors { - -frame "#d9d9d9" - -foreground "#000000" - -window "#ffffff" - -text "#000000" - -activebg "#ececec" - -selectbg "#4a6984" - -selectfg "#ffffff" - -darker "#c3c3c3" - -disabledfg "#a3a3a3" - -indicator "#4a6984" + -frame "#d9d9d9" + -foreground "#000000" + -window "#ffffff" + -text "#000000" + -activebg "#ececec" + -selectbg "#4a6984" + -selectfg "#ffffff" + -darker "#c3c3c3" + -disabledfg "#a3a3a3" + -indicator "#4a6984" -disabledindicator "#a3a3a3" - -altindicator "#9fbdd8" - -disabledaltindicator "#c0c0c0" + -altindicator "#9fbdd8" + -disabledaltindicator "#c0c0c0" } ttk::style theme settings default { -- cgit v0.12 From daea4e2ae99a82f91e3b19d8798b07263623b74f Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 24 Sep 2016 18:27:11 +0000 Subject: Fixed clam theme for all states --- library/ttk/clamTheme.tcl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index eddacdd..f465922 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -82,11 +82,13 @@ namespace eval ttk::theme::clam { -indicatormargin {1 1 4 1} \ -padding 2 ; ttk::style map TCheckbutton -indicatorbackground \ - [list disabled $colors(-frame) pressed $colors(-frame) \ - {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator)] + [list pressed $colors(-frame) \ + {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator) \ + disabled $colors(-frame)] ttk::style map TRadiobutton -indicatorbackground \ - [list disabled $colors(-frame) pressed $colors(-frame) \ - {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator)] + [list pressed $colors(-frame) \ + {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator) \ + disabled $colors(-frame)] ttk::style configure TMenubutton \ -width -11 -padding 5 -relief raised -- cgit v0.12 From 3e694f4b61010dbd0214355d77014613d5aa0611 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 24 Sep 2016 18:28:40 +0000 Subject: Long lines are ugly --- library/ttk/clamTheme.tcl | 6 ++++-- library/ttk/defaults.tcl | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index f465922..e6cabb7 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -83,11 +83,13 @@ namespace eval ttk::theme::clam { -padding 2 ; ttk::style map TCheckbutton -indicatorbackground \ [list pressed $colors(-frame) \ - {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator) \ + {!disabled alternate} $colors(-altindicator) \ + {disabled alternate} $colors(-disabledaltindicator) \ disabled $colors(-frame)] ttk::style map TRadiobutton -indicatorbackground \ [list pressed $colors(-frame) \ - {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator) \ + {!disabled alternate} $colors(-altindicator) \ + {disabled alternate} $colors(-disabledaltindicator) \ disabled $colors(-frame)] ttk::style configure TMenubutton \ diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl index 548d5fe..f07cbf7 100644 --- a/library/ttk/defaults.tcl +++ b/library/ttk/defaults.tcl @@ -49,8 +49,10 @@ namespace eval ttk::theme::default { -indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1 ttk::style map TCheckbutton -indicatorcolor \ [list pressed $colors(-activebg) \ - {!disabled selected} $colors(-indicator) {disabled selected} $colors(-disabledindicator) \ - {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator)] + {!disabled selected} $colors(-indicator) \ + {disabled selected} $colors(-disabledindicator) \ + {!disabled alternate} $colors(-altindicator) \ + {disabled alternate} $colors(-disabledaltindicator)] ttk::style map TCheckbutton -indicatorrelief \ [list alternate raised] @@ -58,8 +60,10 @@ namespace eval ttk::theme::default { -indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1 ttk::style map TRadiobutton -indicatorcolor \ [list pressed $colors(-activebg) \ - {!disabled selected} $colors(-indicator) {disabled selected} $colors(-disabledindicator) \ - {!disabled alternate} $colors(-altindicator) {disabled alternate} $colors(-disabledaltindicator)] + {!disabled selected} $colors(-indicator) \ + {disabled selected} $colors(-disabledindicator) \ + {!disabled alternate} $colors(-altindicator) \ + {disabled alternate} $colors(-disabledaltindicator)] ttk::style map TRadiobutton -indicatorrelief \ [list alternate raised] -- cgit v0.12 From eb9183790f07065eb2210b29d6fc9276e49481e1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 24 Sep 2016 21:50:11 +0000 Subject: Fixed typo --- doc/ttk_vsapi.n | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ttk_vsapi.n b/doc/ttk_vsapi.n index 334836c..4d5c3eb 100644 --- a/doc/ttk_vsapi.n +++ b/doc/ttk_vsapi.n @@ -61,7 +61,7 @@ corresponding Visual Styles API state value. This permits the element appearance to respond to changes in the widget state such as becoming active or being pressed. The list should be as described for the \fBttk::style map\fR command but note that the -last pair in the list should be the default state and is typically and +last pair in the list should be the default state and is typically an empty list and 1. Unfortunately all the Visual Styles parts have different state values and these must be looked up either in the Microsoft documentation or more likely in the header files. The -- cgit v0.12 From e05a73a1dc281d212fc7f4f6b35e0bc5f4204d9c Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 25 Sep 2016 19:20:24 +0000 Subject: Fixed [3217462fff] for the alt and classic themes --- library/ttk/altTheme.tcl | 9 +++++++-- library/ttk/classicTheme.tcl | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl index d57227c..e792539 100644 --- a/library/ttk/altTheme.tcl +++ b/library/ttk/altTheme.tcl @@ -14,6 +14,7 @@ namespace eval ttk::theme::alt { -disabledfg "#a3a3a3" -selectbg "#4a6984" -selectfg "#ffffff" + -altindicator "#aaaaaa" } ttk::style theme settings alt { @@ -46,9 +47,13 @@ namespace eval ttk::theme::alt { ttk::style configure TCheckbutton -indicatorcolor "#ffffff" -padding 2 ttk::style configure TRadiobutton -indicatorcolor "#ffffff" -padding 2 ttk::style map TCheckbutton -indicatorcolor \ - [list disabled $colors(-frame) pressed $colors(-frame)] + [list pressed $colors(-frame) \ + alternate $colors(-altindicator) \ + disabled $colors(-frame)] ttk::style map TRadiobutton -indicatorcolor \ - [list disabled $colors(-frame) pressed $colors(-frame)] + [list pressed $colors(-frame) \ + alternate $colors(-altindicator) \ + disabled $colors(-frame)] ttk::style configure TMenubutton \ -width -11 -padding "3 3" -relief raised diff --git a/library/ttk/classicTheme.tcl b/library/ttk/classicTheme.tcl index 7e3eff5..e510361 100644 --- a/library/ttk/classicTheme.tcl +++ b/library/ttk/classicTheme.tcl @@ -15,6 +15,7 @@ namespace eval ttk::theme::classic { -selectfg "#000000" -disabledfg "#a3a3a3" -indicator "#b03060" + -altindicator "#b05e5e" } ttk::style theme settings classic { @@ -49,14 +50,18 @@ namespace eval ttk::theme::classic { ttk::style configure TCheckbutton -indicatorrelief raised ttk::style map TCheckbutton \ -indicatorcolor [list \ - pressed $colors(-frame) selected $colors(-indicator)] \ + pressed $colors(-frame) \ + selected $colors(-indicator) \ + alternate $colors(-altindicator)] \ -indicatorrelief {selected sunken pressed sunken} \ ; ttk::style configure TRadiobutton -indicatorrelief raised ttk::style map TRadiobutton \ -indicatorcolor [list \ - pressed $colors(-frame) selected $colors(-indicator)] \ + pressed $colors(-frame) \ + selected $colors(-indicator) \ + alternate $colors(-altindicator)] \ -indicatorrelief {selected sunken pressed sunken} \ ; -- cgit v0.12 From 7de0edbbb725a1ffbfebb1f41a85853cd402db36 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 25 Sep 2016 20:13:53 +0000 Subject: New attempt to fix [720879afe9] - WM_CHAR message handling. Patch from Christian Werner backported from http://www.androwish.org/index.html/info/a0da5845594cec28 --- win/tkWinX.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/win/tkWinX.c b/win/tkWinX.c index bb60a2d..e13bb4f 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -92,7 +92,7 @@ static Tcl_ThreadDataKey dataKey; static void GenerateXEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static unsigned int GetState(UINT message, WPARAM wParam, LPARAM lParam); -static void GetTranslatedKey(XKeyEvent *xkey); +static void GetTranslatedKey(XKeyEvent *xkey, UINT type); static void UpdateInputLanguage(int charset); static int HandleIMEComposition(HWND hwnd, LPARAM lParam); @@ -1157,7 +1157,8 @@ GenerateXEvent( event.type = KeyPress; event.xany.send_event = -1; event.xkey.keycode = wParam; - GetTranslatedKey(&event.xkey); + GetTranslatedKey(&event.xkey, (message == WM_KEYDOWN) ? WM_CHAR : + WM_SYSCHAR); break; case WM_SYSKEYUP: @@ -1229,9 +1230,10 @@ GenerateXEvent( if (IsDBCSLeadByte((BYTE) wParam)) { MSG msg; - if ((PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0) + if ((PeekMessage(&msg, NULL, WM_CHAR, WM_CHAR, + PM_NOREMOVE) != 0) && (msg.message == WM_CHAR)) { - GetMessage(&msg, NULL, 0, 0); + GetMessage(&msg, NULL, WM_CHAR, WM_CHAR); event.xkey.nbytes = 2; event.xkey.trans_chars[1] = (char) msg.wParam; } @@ -1370,19 +1372,20 @@ GetState( static void GetTranslatedKey( - XKeyEvent *xkey) + XKeyEvent *xkey, + UINT type) { MSG msg; xkey->nbytes = 0; while ((xkey->nbytes < XMaxTransChars) - && PeekMessageA(&msg, NULL, 0, 0, PM_NOREMOVE)) { - if ((msg.message != WM_CHAR) && (msg.message != WM_SYSCHAR)) { + && (PeekMessageA(&msg, NULL, type, type, PM_NOREMOVE) != 0)) { + if (msg.message != type) { break; } - GetMessageA(&msg, NULL, 0, 0); + GetMessageA(&msg, NULL, type, type); /* * If this is a normal character message, we may need to strip off the -- cgit v0.12 From 6fc7c3942a4f1f84b585a5570818f98299254c51 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 26 Sep 2016 11:45:14 +0000 Subject: Introduce two utility functions for handling Unicode surrogate pairs, and use it in tkWinKey.c. No change in functionality. --- generic/tkInt.h | 8 ++++++ generic/tkUtil.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ win/tkWinKey.c | 21 +++------------ 3 files changed, 92 insertions(+), 17 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index dd5dcad..f360f08 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1232,6 +1232,14 @@ MODULE_SCOPE Status TkParseColor (Display * display, MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion); #endif +#if TCL_UTF_MAX > 4 +# define TkUtfToUniChar Tcl_UtfToUniChar +# define TkUniCharToUtf Tcl_UniCharToUtf +#else + MODULE_SCOPE int TkUtfToUniChar(const char *, int *); + MODULE_SCOPE int TkUniCharToUtf(int, char *); +#endif + /* * Unsupported commands. */ diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 6563165..e686826 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -1192,6 +1192,86 @@ TkSendVirtualEvent( Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); } + +#if TCL_UTF_MAX <= 4 +/* + *--------------------------------------------------------------------------- + * + * TkUtfToUniChar -- + * + * Almost the same as Tcl_UtfToUniChar but using int instead of Tcl_UniChar. + * This function is capable of collapsing a upper/lower surrogate pair to a + * single unicode character. So, up to 6 bytes might be consumed. + * + * Results: + * *chPtr is filled with the Tcl_UniChar, and the return value is the + * number of bytes from the UTF-8 string that were consumed. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +int +TkUtfToUniChar( + const char *src, /* The UTF-8 string. */ + int *chPtr) /* Filled with the Tcl_UniChar represented by + * the UTF-8 string. */ +{ + Tcl_UniChar uniChar = 0; + + int len = Tcl_UtfToUniChar(src, &uniChar); + if ((uniChar & 0xfc00) == 0xd800) { + Tcl_UniChar high = uniChar; + /* This can only happen if Tcl is compiled with TCL_UTF_MAX=4, + * or when a high surrogate character is detected in UTF-8 form */ + int len2 = Tcl_UtfToUniChar(src+len, &uniChar); + if ((uniChar & 0xfc00) == 0xdc00) { + *chPtr = (((high & 0x3ff) << 10) | (uniChar & 0x3ff)) + 0x10000; + len += len2; + } else { + *chPtr = high; + } + } else { + *chPtr = uniChar; + } + return len; +} + +/* + *--------------------------------------------------------------------------- + * + * TkUniCharToUtf -- + * + * Almost the same as Tcl_UniCharToUtf but producing surrogates if + * TCL_UTF_MAX==3. So, up to 6 bytes might be produced. + * + * Results: + * *buf is filled with the UTF-8 string, and the return value is the + * number of bytes produced. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +int TkUniCharToUtf(int ch, char *buf) +{ + int size = Tcl_UniCharToUtf(ch, buf); + if ((ch > 0xffff) && (ch <= 0x10ffff) && (size < 4)) { + /* Hey, this is wrong, we must be running TCL_UTF_MAX==3 + * The best thing we can do is spit out 2 surrogates */ + ch -= 0x10000; + size = Tcl_UniCharToUtf(((ch >> 10) | 0xd800), buf); + size += Tcl_UniCharToUtf(((ch & 0x3ff) | 0xdc00), buf+size); + } + return size; +} + + +#endif /* * Local Variables: * mode: c diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 2698c4d..a567653 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -88,6 +88,8 @@ TkpGetString( * result. */ { XKeyEvent *keyEv = &eventPtr->xkey; + char buf[6]; + int len; Tcl_DStringInit(dsPtr); if (keyEv->send_event == -1) { @@ -102,8 +104,6 @@ TkpGetString( */ int unichar; - char buf[XMaxTransChars]; - int len; unichar = keyEv->trans_chars[1] & 0xff; unichar <<= 8; @@ -114,22 +114,12 @@ TkpGetString( Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { - char buf[XMaxTransChars]; - int len; - /* * Special case for WM_UNICHAR. */ - len = Tcl_UniCharToUtf(keyEv->keycode, buf); - if ((keyEv->keycode <= 0xffff) || (len == XMaxTransChars)) { - Tcl_DStringAppend(dsPtr, buf, len); - } else { - Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf); - Tcl_DStringAppend(dsPtr, buf, 3); - Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) & 0x3ff) | 0xdc00, buf); - Tcl_DStringAppend(dsPtr, buf, 3); - } + len = TkUniCharToUtf(keyEv->keycode, buf); + Tcl_DStringAppend(dsPtr, buf, len); } else { /* * This is an event generated from generic code. It has no nchars or @@ -140,9 +130,6 @@ TkpGetString( if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256)) || (keysym == XK_Return) || (keysym == XK_Tab)) { - char buf[XMaxTransChars]; - int len; - len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf); Tcl_DStringAppend(dsPtr, buf, len); } -- cgit v0.12 From 6864f7029a8095dec62bdc53e31f4e3c30c31b0b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 27 Sep 2016 09:58:34 +0000 Subject: Fix [720879afe9] - WM_CHAR message handling. Patch from Christian Werner backported from http://www.androwish.org/index.html/info/a0da5845594cec28 --- win/tkWinX.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/win/tkWinX.c b/win/tkWinX.c index cbd6032..af28e41 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -137,7 +137,7 @@ static Tcl_ThreadDataKey dataKey; static void GenerateXEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static unsigned int GetState(UINT message, WPARAM wParam, LPARAM lParam); -static void GetTranslatedKey(XKeyEvent *xkey); +static void GetTranslatedKey(XKeyEvent *xkey, UINT type); static void UpdateInputLanguage(int charset); static int HandleIMEComposition(HWND hwnd, LPARAM lParam); @@ -1187,7 +1187,8 @@ GenerateXEvent( event.type = KeyPress; event.xany.send_event = -1; event.xkey.keycode = wParam; - GetTranslatedKey(&event.xkey); + GetTranslatedKey(&event.xkey, (message == WM_KEYDOWN) ? WM_CHAR : + WM_SYSCHAR); break; case WM_SYSKEYUP: @@ -1243,9 +1244,10 @@ GenerateXEvent( if (IsDBCSLeadByte((BYTE) wParam)) { MSG msg; - if ((PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0) + if ((PeekMessage(&msg, NULL, WM_CHAR, WM_CHAR, + PM_NOREMOVE) != 0) && (msg.message == WM_CHAR)) { - GetMessage(&msg, NULL, 0, 0); + GetMessage(&msg, NULL, WM_CHAR, WM_CHAR); event.xkey.nbytes = 2; event.xkey.trans_chars[1] = (char) msg.wParam; } @@ -1392,19 +1394,20 @@ GetState( static void GetTranslatedKey( - XKeyEvent *xkey) + XKeyEvent *xkey, + UINT type) { MSG msg; xkey->nbytes = 0; while ((xkey->nbytes < XMaxTransChars) - && PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - if ((msg.message != WM_CHAR) && (msg.message != WM_SYSCHAR)) { + && PeekMessage(&msg, NULL, type, type, PM_NOREMOVE)) { + if (msg.message != type) { break; } - GetMessage(&msg, NULL, 0, 0); + GetMessage(&msg, NULL, type, type); /* * If this is a normal character message, we may need to strip off the -- cgit v0.12 From 506ee2fc81bb27e237860565c11a1494ab8c7b38 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 27 Sep 2016 14:41:50 +0000 Subject: Internal code simplification: Store Unicode character in keycode field in stead of trans_chars. No behavior change, just use a different internal event type. --- win/tkWinKey.c | 15 --------------- win/tkWinX.c | 15 ++++++--------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/win/tkWinKey.c b/win/tkWinKey.c index a567653..89b5d29 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -97,21 +97,6 @@ TkpGetString( Tcl_ExternalToUtfDString(TkWinGetKeyInputEncoding(), keyEv->trans_chars, keyEv->nbytes, dsPtr); } - } else if (keyEv->send_event == -2) { - /* - * Special case for win2000 multi-lingal IME input. xkey.trans_chars[] - * already contains a UNICODE char. - */ - - int unichar; - - unichar = keyEv->trans_chars[1] & 0xff; - unichar <<= 8; - unichar |= keyEv->trans_chars[0] & 0xff; - - len = Tcl_UniCharToUtf((Tcl_UniChar) unichar, buf); - - Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { /* diff --git a/win/tkWinX.c b/win/tkWinX.c index e13bb4f..5771a29 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1573,18 +1573,18 @@ HandleIMEComposition( n = ImmGetCompositionString(hIMC, GCS_RESULTSTR, NULL, 0); if (n > 0) { - char *buff = ckalloc(n); + WCHAR *buff = (WCHAR *) ckalloc(n); TkWindow *winPtr; XEvent event; int i; - n = ImmGetCompositionString(hIMC, GCS_RESULTSTR, buff, (unsigned) n); + n = ImmGetCompositionString(hIMC, GCS_RESULTSTR, buff, (unsigned) n) / 2; /* * Set up the fields pertinent to key event. * - * We set send_event to the special value of -2, so that TkpGetString - * in tkWinKey.c knows that trans_chars[] already contains a UNICODE + * We set send_event to the special value of -3, so that TkpGetString + * in tkWinKey.c knows that keycode already contains a UNICODE * char and there's no need to do encoding conversion. * * Note that the event *must* be zeroed out first; Tk plays cunning @@ -1595,7 +1595,7 @@ HandleIMEComposition( memset(&event, 0, sizeof(XEvent)); event.xkey.serial = winPtr->display->request++; - event.xkey.send_event = -2; + event.xkey.send_event = -3; event.xkey.display = winPtr->display; event.xkey.window = winPtr->window; event.xkey.root = RootWindow(winPtr->display, winPtr->screenNum); @@ -1603,8 +1603,6 @@ HandleIMEComposition( event.xkey.state = TkWinGetModifierState(); event.xkey.time = TkpGetMS(); event.xkey.same_screen = True; - event.xkey.keycode = 0; - event.xkey.nbytes = 2; for (i=0; i Date: Tue, 27 Sep 2016 15:44:50 +0000 Subject: clearify comment --- win/tkWinKey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 89b5d29..31faea0 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -100,7 +100,7 @@ TkpGetString( } else if (keyEv->send_event == -3) { /* - * Special case for WM_UNICHAR. + * Special case for WM_UNICHAR and win2000 multi-lingal IME input */ len = TkUniCharToUtf(keyEv->keycode, buf); -- cgit v0.12 From c5b90c42e5d068154fabc02c7b294203ced16e97 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 28 Sep 2016 15:54:09 +0000 Subject: Fixed [1082213fff] - word wrapping should trim excess spaces --- generic/tkTextDisp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index a135084..892b935 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7612,6 +7612,18 @@ TkTextCharLayoutProc( bytesThatFit++; } + if (wrapMode == TEXT_WRAPMODE_WORD) { + while (p[bytesThatFit] == ' ') { + /* + * Space characters that would go at the beginning of the + * next line are allocated to the present line. This gives + * the effect of trimming white spaces at the beginning of + * wrapped lines. + */ + + bytesThatFit++; + } + } if (bytesThatFit == 0) { #if TK_LAYOUT_WITH_BASE_CHUNKS chunkPtr->clientData = NULL; -- cgit v0.12 From 2ae5179d81bf1d478a7f7baca04997655f0cf425 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 28 Sep 2016 19:18:45 +0000 Subject: Slightly better fix --- generic/tkTextDisp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 892b935..e3fc5c9 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7604,26 +7604,26 @@ TkTextCharLayoutProc( nextX = maxX; bytesThatFit++; } - if (p[bytesThatFit] == '\n') { - /* - * A newline character takes up no space, so if the previous - * character fits then so does the newline. - */ - - bytesThatFit++; - } if (wrapMode == TEXT_WRAPMODE_WORD) { while (p[bytesThatFit] == ' ') { /* * Space characters that would go at the beginning of the - * next line are allocated to the present line. This gives - * the effect of trimming white spaces at the beginning of - * wrapped lines. + * next line are allocated to the current line. This gives + * the effect of trimming white spaces that would otherwise + * be seen at the beginning of wrapped lines. */ bytesThatFit++; } } + if (p[bytesThatFit] == '\n') { + /* + * A newline character takes up no space, so if the previous + * character fits then so does the newline. + */ + + bytesThatFit++; + } if (bytesThatFit == 0) { #if TK_LAYOUT_WITH_BASE_CHUNKS chunkPtr->clientData = NULL; -- cgit v0.12 From be3a29538266c07c2c4805144dd6f1b31eb4b06e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 29 Sep 2016 12:40:28 +0000 Subject: remove unintended failing test-case, added in previous commit --- tests/entry.test | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/entry.test b/tests/entry.test index 1be1d2d..d27ffb5 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -2920,11 +2920,6 @@ test entry-16.4 {EntryVisibleRange procedure} -body { } -cleanup { destroy .e } -result {0.000000 1.000000} -test entry-16.5 {Unicode handling in entry widget} -body { - entry .e -show abc -} -cleanup { - destroy .e -} -result {0.000000 1.000000} test entry-17.1 {EntryUpdateScrollbar procedure} -body { -- cgit v0.12 From f45db70f36cc88a14f21aaab17b5ce769370c566 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 29 Sep 2016 16:12:16 +0000 Subject: Explained why only spaces are trimmed and not tabs --- generic/tkTextDisp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index e3fc5c9..6d7820a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7611,6 +7611,9 @@ TkTextCharLayoutProc( * next line are allocated to the current line. This gives * the effect of trimming white spaces that would otherwise * be seen at the beginning of wrapped lines. + * Note that testing for '\t' is useless here because the + * chunk always includes at most one trailing \t, see + * LayoutDLine. */ bytesThatFit++; -- cgit v0.12 From 129b1157bd8453512bfed2fe7c9c8e36bdd7c3fc Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 29 Sep 2016 16:26:31 +0000 Subject: Restored successful test text-19.16 --- tests/text.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/text.test b/tests/text.test index f640817..3e5b4b6 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3828,7 +3828,7 @@ test text-19.16 {DeleteChars procedure, updates affecting topIndex} -setup { wm geometry .top +0+0 update } -body { - .top.t insert end "abc def\n01 2345 678 9101112\nLine 3\nLine 4\nLine 5\n6\n7\n8\n" + .top.t insert end "abc def\n01 2a345 678 9101112\nLine 3\nLine 4\nLine 5\n6\n7\n8\n" .top.t yview 2.4 .top.t delete 2.5 set x [.top.t index @0,0] -- cgit v0.12 From 296b6203712e0a79f4e8facc83cb5518adb8b292 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 30 Sep 2016 07:34:36 +0000 Subject: Fix UNIX build, and eliminate possible warning in Makefile --- generic/tkFont.c | 13 ++++++++----- win/Makefile.in | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index 51b2fce..bec8807 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -13,7 +13,6 @@ #include "tkInt.h" #include "tkFont.h" -#include /* * The following structure is used to keep track of all the fonts that exist @@ -1716,11 +1715,15 @@ Tk_PostscriptFontName( upper = 1; } src += TkUtfToUniChar(src, &ch); - if (upper) { - ch = Tcl_UniCharToUpper(ch); - upper = 0; + if (ch <= 0xffff) { + if (upper) { + ch = Tcl_UniCharToUpper(ch); + upper = 0; + } else { + ch = Tcl_UniCharToLower(ch); + } } else { - ch = Tcl_UniCharToLower(ch); + upper = 0; } dest += TkUniCharToUtf(ch, dest); } diff --git a/win/Makefile.in b/win/Makefile.in index cc90b71..7e48213 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -27,6 +27,7 @@ exec_prefix = @exec_prefix@ bindir = @bindir@ libdir = @libdir@ includedir = @includedir@ +datarootdir = @datarootdir@ mandir = @mandir@ # The following definition can be set to non-null for special systems -- cgit v0.12 From f85b666de3d6de93f6c60d612e1c4abf5c671a90 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 30 Sep 2016 09:29:39 +0000 Subject: Add a few "const" keywords, just for 'correctness' --- unix/tkUnixFont.c | 6 +++--- unix/tkUnixRFont.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 1b0f175..e694573 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -171,7 +171,7 @@ static Tcl_ThreadDataKey dataKey; * encodings into the names expected by the Tcl encoding package. */ -static EncodingAlias encodingAliases[] = { +static const EncodingAlias encodingAliases[] = { {"gb2312-raw", "gb2312*"}, {"big5", "big5*"}, {"cns11643-1", "cns11643*-1"}, @@ -408,8 +408,8 @@ ControlUtfProc( char *dstStart, *dstEnd; int ch; int result; - static char hexChars[] = "0123456789abcdef"; - static char mapChars[] = { + static const char hexChars[] = "0123456789abcdef"; + static const char mapChars[] = { 0, 0, 0, 0, 0, 0, 0, 'a', 'b', 't', 'n', 'v', 'f', 'r' }; diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index cf4127d..36c4540 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -69,7 +69,7 @@ void TkpFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { - static Tcl_Config cfg[] = { + static const Tcl_Config cfg[] = { { "fontsystem", "xft" }, { 0,0 } }; -- cgit v0.12 From 3abe9cb4a4c78af20618a71024884dc7f600b4f0 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 30 Sep 2016 14:18:12 +0000 Subject: Added explanatory comment --- generic/tkTextDisp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6d7820a..4f511a4 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7542,6 +7542,9 @@ TkTextCharLayoutProc( * (b) at least one pixel of the character is visible, we have not * already exceeded the character limit, and the next character is a * white space character. + * In the specific case of 'word' wrapping mode however, include all space + * characters following the characters that fit in the space we've got, + * even if no pixel of them is visible. */ p = segPtr->body.chars + byteOffset; -- cgit v0.12 From dd206481f5375b42c4add97e7b3dbf4f7caf357b Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 30 Sep 2016 14:19:28 +0000 Subject: Restored successful tests textDisp-*.* --- tests/textDisp.test | 76 ++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index 99401c2..d3de2d8 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -253,8 +253,8 @@ test textDisp-2.5 {LayoutDLine, word wrap} {textfonts} { .t configure -wrap word .t delete 1.0 end .t insert 1.0 "This isx some sample text for testing." - list [.t bbox 1.13] [.t bbox 1.14] [.t bbox 1.19] -} [list [list 96 5 49 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 40 [expr {$fixedDiff + 18}] 7 $fixedHeight]] + list [.t bbox 1.13] [.t bbox 1.19] [.t bbox 1.20] [.t bbox 1.21] +} [list [list 96 5 $fixedWidth $fixedHeight] [list 138 5 $fixedWidth $fixedHeight] [list 145 5 0 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] $fixedWidth $fixedHeight]] test textDisp-2.6 {LayoutDLine, word wrap} { .t configure -wrap word .t delete 1.0 end @@ -353,16 +353,16 @@ test textDisp-2.16 {LayoutDLine, justification} {textfonts} { .t tag configure x -justify center .t tag add x 1.1 1.20 .t tag add x 1.21 1.end - list [.t bbox 1.0] [.t bbox 1.20] [.t bbox 1.36] [.t bbox 2.0] -} [list [list 5 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 43 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]] + list [.t bbox 1.0] [.t bbox 1.20] [.t bbox 1.41] [.t bbox 2.0] +} [list [list 5 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 61 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]] test textDisp-2.17 {LayoutDLine, justification} {textfonts} { .t configure -wrap word .t delete 1.0 end - .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines" + .t insert 1.0 "Lots of very long words, enough to force word wrap\nThen\nmore lines" .t tag configure x -justify center - .t tag add x 1.20 - list [.t bbox 1.0] [.t bbox 1.20] [.t bbox 1.36] [.t bbox 2.0] -} [list [list 5 5 7 $fixedHeight] [list 19 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]] + .t tag add x 1.18 + list [.t bbox 1.0] [.t bbox 1.18] [.t bbox 1.35] [.t bbox 2.0] +} [list [list 5 5 7 $fixedHeight] [list 15 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]] test textDisp-2.18 {LayoutDLine, justification} {textfonts} { .t configure -wrap none .t delete 1.0 end @@ -2337,7 +2337,7 @@ test textDisp-17.10 {TkTextScanCmd procedure, word wrapping} {textfonts} { set x [.t index @0,0] .t scan dragto 0 [expr {70 + $fixedDiff}] list $x [.t index @0,0] -} {9.15 8.31} +} {9.0 8.0} .t configure -xscrollcommand scroll -yscrollcommand {} test textDisp-18.1 {GetXView procedure} { .t configure -wrap none @@ -2563,7 +2563,7 @@ test textDisp-19.10.1 {Widget manipulation causes height miscount} { .t insert end "\nLine $i" } .t insert end "\nThis last line wraps around four " - .t insert end "times with a bit left on the last line." + .t insert end "times with a little bit left on the last line." .t yview insert update .t count -update -ypixels 1.0 end @@ -2577,7 +2577,7 @@ test textDisp-19.11 {GetYView procedure} { .t insert end "\nLine $i" } .t insert end "\nThis last line wraps around four " - .t insert end "times with a bit left on the last line." + .t insert end "times with a little bit left on the last line." .t yview insert update .t count -update -ypixels 1.0 end @@ -2599,7 +2599,7 @@ test textDisp-19.11.5.1 {TextWidgetCmd procedure, "count -displaylines"} { .t count -displaylines 16.0 16.5 } {0} test textDisp-19.11.6 {TextWidgetCmd procedure, "count -displaylines"} { - .t count -displaylines 16.0 16.20 + .t count -displaylines 16.0 16.24 } {1} test textDisp-19.11.7 {TextWidgetCmd procedure, "count -displaylines"} { .t count -displaylines 16.0 16.40 @@ -2652,14 +2652,14 @@ test textDisp-19.11.17 {TextWidgetCmd procedure, "index +displaylines"} { [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \ [.t index "13.0 +2d lines"] [.t index "13.1 +3d lines"] \ [.t index "13.0 +4d lines"] -} {15.5 16.0 15.0 16.0 16.15 16.33} +} {15.5 16.0 15.0 16.0 16.21 16.39} test textDisp-19.11.18 {TextWidgetCmd procedure, "index +displaylines"} { .t tag remove elide 1.0 end .t tag add elide "12.0" "14.0" list [.t index "15.5 -2d lines"] \ [.t index "16.0 -2d lines"] [.t index "15.0 -2d lines"] \ - [.t index "16.0 -3d lines"] [.t index "16.17 -4d lines"] \ - [.t index "16.36 -5d lines"] + [.t index "16.0 -3d lines"] [.t index "16.23 -4d lines"] \ + [.t index "16.42 -5d lines"] } {11.5 14.0 11.0 11.0 11.2 11.3} test textDisp-19.11.19 {TextWidgetCmd procedure, "count -displaylines"} { .t tag remove elide 1.0 end @@ -2673,14 +2673,14 @@ test textDisp-19.11.20 {TextWidgetCmd procedure, "index +displaylines"} { [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \ [.t index "13.0 +2d lines"] [.t index "13.0 +3d lines"] \ [.t index "13.0 +4d lines"] -} {16.38 16.50 16.33 16.50 16.67 17.0} +} {16.44 16.57 16.39 16.57 16.74 17.0} test textDisp-19.11.21 {TextWidgetCmd procedure, "index +displaylines"} { .t tag remove elide 1.0 end .t tag add elide "12.0" "16.0 +1displaylines" - list [.t index "16.38 -2d lines"] \ - [.t index "16.50 -3d lines"] [.t index "16.33 -2d lines"] \ - [.t index "16.53 -4d lines"] [.t index "16.69 -4d lines"] \ - [.t index "17.1 -5d lines"] + list [.t index "16.44 -2d lines"] \ + [.t index "16.57 -3d lines"] [.t index "16.39 -2d lines"] \ + [.t index "16.60 -4d lines"] [.t index "16.76 -4d lines"] \ + [.t index "17.0 -5d lines"] } {11.5 11.0 11.0 10.3 11.2 11.0} test textDisp-19.11.22 {TextWidgetCmd procedure, "index +displaylines"} { .t tag remove elide 1.0 end @@ -2688,7 +2688,7 @@ test textDisp-19.11.22 {TextWidgetCmd procedure, "index +displaylines"} { [.t index "end -3d lines"] [.t index "1.0 -2d lines"] \ [.t index "1.0 +4d lines"] [.t index "1.0 +50d lines"] \ [.t index "end -50d lines"] -} {17.0 16.33 1.0 5.0 17.0 1.0} +} {17.0 16.39 1.0 5.0 17.0 1.0} test textDisp-19.11.23 {TextWidgetCmd procedure, "index +displaylines"} { .t tag remove elide 1.0 end .t tag add elide "12.3" "16.0 +1displaylines" @@ -2697,7 +2697,7 @@ test textDisp-19.11.23 {TextWidgetCmd procedure, "index +displaylines"} { [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \ [.t index "13.0 +2d lines"] [.t index "13.0 +3d lines"] \ [.t index "13.0 +4d lines"] -} {16.17 16.33 16.28 16.46 16.28 16.49 16.65 16.72} +} {16.23 16.44 16.39 16.57 16.39 16.60 16.77 16.79} .t tag remove elide 1.0 end test textDisp-19.11.24 {TextWidgetCmd procedure, "index +/-displaylines"} { list [.t index "11.5 + -1 display lines"] \ @@ -2746,7 +2746,7 @@ test textDisp-19.14 {GetYView procedure} { .t insert end "\nLine $i" } .t insert end "\nThis last line wraps around four " - .t insert end "times with a bit left on the last line." + .t insert end "times with a little bit left on the last line." # Need to update so everything is calculated. update ; .t count -update -ypixels 1.0 end update ; after 10 ; update @@ -2766,7 +2766,7 @@ test textDisp-19.15 {GetYView procedure} { .t insert end "\nLine $i" } .t insert end "\nThis last line wraps around four " - .t insert end "times with a bit left on the last line." + .t insert end "times with a bit little left on the last line." update .t configure -yscrollcommand scrollError proc bgerror args { @@ -2794,7 +2794,7 @@ test textDisp-19.16 {count -ypixels} { .t insert end "\nLine $i" } .t insert end "\nThis last line wraps around four " - .t insert end "times with a bit left on the last line." + .t insert end "times with a little bit left on the last line." # Need to update so everything is calculated. update ; .t count -update -ypixels 1.0 end ; update set res {} @@ -2879,18 +2879,18 @@ test textDisp-20.1 {FindDLine} {textfonts} { test textDisp-20.2 {FindDLine} {textfonts} { .t yview 100.0 .t yview -pickplace 53.0 - list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.15] -} [list [list 3 [expr {-1 - $fixedDiff/2}] 105 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {-1 - $fixedDiff/2}] 105 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {12 + $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]] + list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.21] +} [list [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {12 + $fixedDiff/2}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]] test textDisp-20.3 {FindDLine} {textfonts} { .t yview 100.0 .t yview 49.0 - list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 57.0] -} [list [list 3 [expr {$fixedDiff + 16}] 105 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {2*$fixedDiff + 29}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] + list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 57.0] +} [list [list 3 [expr {$fixedDiff + 16}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {2*$fixedDiff + 29}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] test textDisp-20.4 {FindDLine} {textfonts} { .t yview 100.0 .t yview 42.0 - list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40] -} [list [list 3 [expr {8*$fixedDiff + 107}] 105 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] + list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 50.40] +} [list [list 3 [expr {8*$fixedDiff + 107}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] .t config -wrap none test textDisp-20.5 {FindDLine} {textfonts} { .t yview 100.0 @@ -2903,7 +2903,7 @@ test textDisp-21.1 {TkTextPixelIndex} {textfonts} { .t yview 48.0 list [.t index @-10,-10] [.t index @6,6] [.t index @22,6] \ [.t index @102,6] [.t index @38,[expr {$fixedHeight * 4 + 3}]] [.t index @44,67] -} {48.0 48.0 48.2 48.7 50.40 50.40} +} {48.0 48.0 48.2 48.7 50.45 50.45} .t insert end \n test textDisp-21.2 {TkTextPixelIndex} {textfonts} { .t yview 195.0 @@ -2959,7 +2959,7 @@ test textDisp-22.1 {TkTextCharBbox} {textfonts} { .t yview 48.0 list [.t bbox 47.2] [.t bbox 48.0] [.t bbox 50.5] [.t bbox 50.40] \ [.t bbox 58.0] -} [list {} [list 3 3 7 $fixedHeight] [list 38 [expr {3+2*$fixedHeight}] 7 $fixedHeight] [list 38 [expr {3+4*$fixedHeight}] 7 $fixedHeight] {}] +} [list {} [list 3 3 7 $fixedHeight] [list 38 [expr {3+2*$fixedHeight}] 7 $fixedHeight] [list 3 [expr {3+4*$fixedHeight}] 7 $fixedHeight] {}] test textDisp-22.2 {TkTextCharBbox} {textfonts} { .t config -wrap none .t yview 48.0 @@ -3083,13 +3083,13 @@ test textDisp-23.1 {TkTextDLineInfo} {textfonts} { .t yview 48.0 list [.t dlineinfo 47.3] [.t dlineinfo 48.0] [.t dlineinfo 50.40] \ [.t dlineinfo 56.0] -} [list {} [list 3 3 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {4*$fixedDiff + 55}] 126 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] +} [list {} [list 3 3 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {4*$fixedDiff + 55}] 91 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] test textDisp-23.2 {TkTextDLineInfo} {textfonts} { .t config -bd 4 -wrap word update .t yview 48.0 .t dlineinfo 50.40 -} [list 7 [expr {4*$fixedDiff + 59}] 126 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] +} [list 7 [expr {4*$fixedDiff + 59}] 91 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] .t config -bd 0 test textDisp-23.3 {TkTextDLineInfo} {textfonts} { .t config -wrap none @@ -3284,11 +3284,11 @@ test textDisp-24.17 {TkTextCharLayoutProc, -wrap word} {textfonts} { test textDisp-24.18 {TkTextCharLayoutProc, -wrap word} {textfonts} { .t configure -wrap word .t delete 1.0 end - .t insert 1.0 "xThis is a line that wraps around" + .t insert 1.0 "xxThis is a line that wraps around" wm geom . {} update - list [.t bbox 1.14] [.t bbox 1.15] [.t bbox 1.16] -} [list [list 101 3 7 $fixedHeight] [list 108 3 35 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]] + list [.t bbox 1.15] [.t bbox 1.16] [.t bbox 1.17] +} [list [list 108 3 7 $fixedHeight] [list 115 3 28 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]] test textDisp-24.19 {TkTextCharLayoutProc, -wrap word} {textfonts} { .t configure -wrap word .t delete 1.0 end -- cgit v0.12 From cf08e658b359e7fa77150a04e08e85b4994a69c8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 30 Sep 2016 18:59:22 +0000 Subject: Fixed typo in comment --- generic/tkTextTag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index a212615..dd3127d 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -30,7 +30,7 @@ static const char *const wrapStrings[] = { /* * The 'TkTextTabStyle' enum in tkText.h is used to define a type for the * -tabstyle option of the Text widget. These values are used as indices into - * the string table below. Tags are allowed an empty wrap value, but the + * the string table below. Tags are allowed an empty tabstyle value, but the * widget as a whole is not. */ -- cgit v0.12 From abb71b05a096ad7a349e8bae21ec1a9fad7aec87 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 30 Sep 2016 19:13:55 +0000 Subject: Fixed [1080198fff] by clearly stating in the man page that the -wrap option for tags only applies to a displayline if it applies to the first non-elided character on that display line --- doc/text.n | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/text.n b/doc/text.n index 481580d..2e9d205 100644 --- a/doc/text.n +++ b/doc/text.n @@ -609,9 +609,11 @@ specified by the \fB\-foreground\fR tag option is used. \fB\-wrap \fImode\fR . \fIMode\fR specifies how to handle lines that are wider than the text's -window. It has the same legal values as the \fB\-wrap\fR option for the text -widget: \fBnone\fR, \fBchar\fR, or \fBword\fR. If this tag option is -specified, it overrides the \fB\-wrap\fR option for the text widget. +window. This option only applies to a displayline if it applies to the +first non-elided character on that display line. It has the same legal +values as the \fB\-wrap\fR option for the text widget: \fBnone\fR, +\fBchar\fR, or \fBword\fR. If this tag option is specified, it +overrides the \fB\-wrap\fR option for the text widget. .PP If a character has several tags associated with it, and if their display options conflict, then the options of the highest priority tag are used. If a -- cgit v0.12 From 828f2c0dd8dccab4a455c82bcf4550036926032c Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 5 Oct 2016 13:48:53 +0000 Subject: Changed themes 'classic' and 'default' according to comments from Christian Gollwitzer in [3217462fff] --- library/ttk/classicTheme.tcl | 12 ++++++------ library/ttk/defaults.tcl | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/library/ttk/classicTheme.tcl b/library/ttk/classicTheme.tcl index e510361..3cb2b18 100644 --- a/library/ttk/classicTheme.tcl +++ b/library/ttk/classicTheme.tcl @@ -51,18 +51,18 @@ namespace eval ttk::theme::classic { ttk::style map TCheckbutton \ -indicatorcolor [list \ pressed $colors(-frame) \ - selected $colors(-indicator) \ - alternate $colors(-altindicator)] \ - -indicatorrelief {selected sunken pressed sunken} \ + alternate $colors(-altindicator) \ + selected $colors(-indicator)] \ + -indicatorrelief {alternate raised selected sunken pressed sunken} \ ; ttk::style configure TRadiobutton -indicatorrelief raised ttk::style map TRadiobutton \ -indicatorcolor [list \ pressed $colors(-frame) \ - selected $colors(-indicator) \ - alternate $colors(-altindicator)] \ - -indicatorrelief {selected sunken pressed sunken} \ + alternate $colors(-altindicator) \ + selected $colors(-indicator)] \ + -indicatorrelief {alternate raised selected sunken pressed sunken} \ ; ttk::style configure TMenubutton -relief raised -padding "3m 1m" diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl index f07cbf7..853ed20 100644 --- a/library/ttk/defaults.tcl +++ b/library/ttk/defaults.tcl @@ -49,10 +49,10 @@ namespace eval ttk::theme::default { -indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1 ttk::style map TCheckbutton -indicatorcolor \ [list pressed $colors(-activebg) \ - {!disabled selected} $colors(-indicator) \ - {disabled selected} $colors(-disabledindicator) \ {!disabled alternate} $colors(-altindicator) \ - {disabled alternate} $colors(-disabledaltindicator)] + {disabled alternate} $colors(-disabledaltindicator) \ + {!disabled selected} $colors(-indicator) \ + {disabled selected} $colors(-disabledindicator)] ttk::style map TCheckbutton -indicatorrelief \ [list alternate raised] @@ -60,10 +60,10 @@ namespace eval ttk::theme::default { -indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1 ttk::style map TRadiobutton -indicatorcolor \ [list pressed $colors(-activebg) \ - {!disabled selected} $colors(-indicator) \ - {disabled selected} $colors(-disabledindicator) \ {!disabled alternate} $colors(-altindicator) \ - {disabled alternate} $colors(-disabledaltindicator)] + {disabled alternate} $colors(-disabledaltindicator) \ + {!disabled selected} $colors(-indicator) \ + {disabled selected} $colors(-disabledindicator)] ttk::style map TRadiobutton -indicatorrelief \ [list alternate raised] -- cgit v0.12 From 5f5b571ffeda160176a575beb298a510a46b4751 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 5 Oct 2016 14:45:53 +0000 Subject: 'clam' theme: darker blue for the inside of the box in alternate state --- library/ttk/clamTheme.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index e6cabb7..f4ad43b 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -17,8 +17,8 @@ namespace eval ttk::theme::clam { -lightest "#ffffff" -selectbg "#4a6984" -selectfg "#ffffff" - -altindicator "#9fbdd8" - -disabledaltindicator "#c0c0c0" + -altindicator "#5895bc" + -disabledaltindicator "#a0a0a0" } ttk::style theme settings clam { -- cgit v0.12 From 549f2d1d605a90214702cc88d5516ac24e6996b2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 5 Oct 2016 15:46:23 +0000 Subject: 'xpnative' and 'vista' (and 'aqua') themes: 'alternate on' changed to be identical to 'alternate', for radiobuttons --- win/ttkWinXPTheme.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 08569a3..3de1504 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -208,6 +208,8 @@ static Ttk_StateTable checkbox_statemap[] = */ static Ttk_StateTable radiobutton_statemap[] = { +{RBS_UNCHECKEDDISABLED, TTK_STATE_ALTERNATE|TTK_STATE_DISABLED, 0}, +{RBS_UNCHECKEDNORMAL, TTK_STATE_ALTERNATE, 0}, {RBS_CHECKEDDISABLED, TTK_STATE_SELECTED|TTK_STATE_DISABLED, 0}, {RBS_CHECKEDPRESSED, TTK_STATE_SELECTED|TTK_STATE_PRESSED, 0}, {RBS_CHECKEDHOT, TTK_STATE_SELECTED|TTK_STATE_ACTIVE, 0}, -- cgit v0.12 From b7e25f799f6e491a801ccb44e4eb7dbf8df9a530 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 9 Oct 2016 18:35:38 +0000 Subject: Fixed typo --- doc/text.n | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/text.n b/doc/text.n index 2e9d205..ae9b857 100644 --- a/doc/text.n +++ b/doc/text.n @@ -609,7 +609,7 @@ specified by the \fB\-foreground\fR tag option is used. \fB\-wrap \fImode\fR . \fIMode\fR specifies how to handle lines that are wider than the text's -window. This option only applies to a displayline if it applies to the +window. This option only applies to a display line if it applies to the first non-elided character on that display line. It has the same legal values as the \fB\-wrap\fR option for the text widget: \fBnone\fR, \fBchar\fR, or \fBword\fR. If this tag option is specified, it -- cgit v0.12 From 8bb0c09912bcf8aaa8d5366525d7895c0fe96ad7 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 12 Oct 2016 18:30:14 +0000 Subject: Fixed typo --- tests/filebox.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/filebox.test b/tests/filebox.test index 7b9fa2c..2573825 100644 --- a/tests/filebox.test +++ b/tests/filebox.test @@ -463,7 +463,7 @@ foreach mode $modes { } # The rest of the tests need to be executed on Unix only. - # The test whether the dialog box widgets were implemented correctly. + # They test whether the dialog box widgets were implemented correctly. # These tests are not # needed on the other platforms because they use native file dialogs. } -- cgit v0.12 From 5aa32dcd815719855c977ec975dd97e391cbf8b3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 12 Oct 2016 18:34:49 +0000 Subject: Fixed [3588460fff] - -typevariable buggy in X11. Patch from Christian Gollwitzer --- library/tkfbox.tcl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index a52465a..f73fdc5 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -310,6 +310,7 @@ proc ::tk::dialog::file::Config {dataName type argList} { # 5. Parse the -filetypes option # + set data(origfiletypes) $data(-filetypes) set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)] if {![winfo exists $data(-parent)]} { @@ -1119,7 +1120,9 @@ proc ::tk::dialog::file::Done {w {selectFilePath ""}} { && [info exists data(filterType)] && $data(filterType) ne "" } then { upvar #0 $data(-typevariable) typeVariable - set typeVariable [lindex $data(filterType) 0] + set typeVariable [lindex $data(origfiletypes) \ + [lsearch -exact $data(-filetypes) $data(filterType)] 0] + } } bind $data(okBtn) {} -- cgit v0.12 From 910bf2864599dfd5aa2aa00cd5fc225c01c17146 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 12 Oct 2016 19:18:50 +0000 Subject: Fixed failing test filebox-3.5.0 --- tests/filebox.test | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/filebox.test b/tests/filebox.test index 2573825..41382a2 100644 --- a/tests/filebox.test +++ b/tests/filebox.test @@ -281,7 +281,11 @@ foreach mode $modes { -initialfile $fileName -initialdir $fileDir \ -typevariable tv] if {[info exists tv]} { - regexp {^(.*) \(.*\)$} $tv dummy typeName + if {$mode == 0} { + set typeName $tv + } else { + regexp {^(.*) \(.*\)$} $tv dummy typeName + } } else { set typeName "-unset-" } -- cgit v0.12 From e749f909676946687b224b350e984f013f57760e Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 21 Oct 2016 13:51:49 +0000 Subject: Fixed [3588460fff] - -typevariable buggy in X11, this time when tk_strictMotif is true. --- library/xmfbox.tcl | 16 +++++----------- tests/filebox.test | 6 +----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/library/xmfbox.tcl b/library/xmfbox.tcl index aa66f7f..f1daea0 100644 --- a/library/xmfbox.tcl +++ b/library/xmfbox.tcl @@ -156,7 +156,7 @@ proc ::tk::MotifFDialog_FileTypes {w} { # The filetypes radiobuttons # set data(fileType) $data(-defaulttype) # Default type to first entry - set initialTypeName [lindex $data(-filetypes) 0 0] + set initialTypeName [lindex $data(origfiletypes) 0 0] if {$data(-typevariable) ne ""} { upvar #0 $data(-typevariable) typeVariable if {[info exists typeVariable]} { @@ -165,7 +165,7 @@ proc ::tk::MotifFDialog_FileTypes {w} { } set ix 0 set data(fileType) 0 - foreach fltr $data(-filetypes) { + foreach fltr $data(origfiletypes) { set fname [lindex $fltr 0] if {[string first $initialTypeName $fname] == 0} { set data(fileType) $ix @@ -185,7 +185,7 @@ proc ::tk::MotifFDialog_FileTypes {w} { set cnt 0 if {$data(-filetypes) ne {}} { foreach type $data(-filetypes) { - set title [lindex [lindex $type 0] 0] + set title [lindex $type 0] set filter [lindex $type 1] radiobutton $f.b$cnt \ -text $title \ @@ -210,7 +210,6 @@ proc ::tk::MotifFDialog_SetFilter {w type} { variable ::tk::Priv set data(filter) [lindex $type 1] - set Priv(selectFileType) [lindex [lindex $type 0] 0] MotifFDialog_Update $w } @@ -299,6 +298,7 @@ proc ::tk::MotifFDialog_Config {dataName type argList} { # file dialog, but we check for validity of the value to make sure # the application code also runs fine with the TK file dialog. # + set data(origfiletypes) $data(-filetypes) set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)] if {![info exists data(filter)]} { @@ -870,7 +870,7 @@ proc ::tk::MotifFDialog_ActivateSEnt {w} { if {[info exists data(-typevariable)] && $data(-typevariable) ne "" && [info exists data(-filetypes)] && $data(-filetypes) ne ""} { upvar #0 $data(-typevariable) typeVariable - set typeVariable [lindex $data(-filetypes) $data(fileType) 0] + set typeVariable [lindex $data(origfiletypes) $data(fileType) 0] } if {$data(-multiple) != 0} { @@ -980,9 +980,3 @@ proc ::tk::ListBoxKeyAccel_Reset {w} { unset -nocomplain Priv(lbAccel,$w) } -proc ::tk_getFileType {} { - variable ::tk::Priv - - return $Priv(selectFileType) -} - diff --git a/tests/filebox.test b/tests/filebox.test index 41382a2..2f87c3e 100644 --- a/tests/filebox.test +++ b/tests/filebox.test @@ -281,11 +281,7 @@ foreach mode $modes { -initialfile $fileName -initialdir $fileDir \ -typevariable tv] if {[info exists tv]} { - if {$mode == 0} { - set typeName $tv - } else { - regexp {^(.*) \(.*\)$} $tv dummy typeName - } + set typeName $tv } else { set typeName "-unset-" } -- cgit v0.12 From a390fb7c79591cae68644f80ac0057f3c81ce5c5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 23 Oct 2016 14:05:20 +0000 Subject: Fix [e36963bfe8]: event generate and diaeresis --- win/tkWinKey.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 31faea0..1ebf312 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -179,18 +179,18 @@ KeycodeToKeysym( { BYTE keys[256]; int result, deadkey, shift; - char buf[4]; + TCHAR buf[4]; unsigned int scancode = MapVirtualKey(keycode, 0); /* - * Do not run keycodes of lock keys through ToAscii(). One of ToAscii()'s + * Do not run keycodes of lock keys through ToUnicode(). One of ToUnicode()'s * side effects is to handle the lights on the keyboard, and we don't want * to mess that up. */ if (noascii || keycode == VK_CAPITAL || keycode == VK_SCROLL || keycode == VK_NUMLOCK) { - goto skipToAscii; + goto skipToUnicode; } /* @@ -231,24 +231,24 @@ KeycodeToKeysym( keys[VK_NUMLOCK] = 1; } - result = ToAscii(keycode, scancode, keys, (LPWORD) buf, 0); + result = ToUnicode(keycode, scancode, keys, buf, 4, 0); if (result < 0) { /* * Win95/98: This was a dead char, which is now remembered by the - * keyboard. Call ToAscii() again to forget it. + * keyboard. Call ToUnicode() again to forget it. * WinNT: This was a dead char, overwriting any previously remembered - * key. Calling ToAscii() again does not affect anything. + * key. Calling ToUnicode() again does not affect anything. */ - ToAscii(keycode, scancode, keys, (LPWORD) buf, 0); + ToUnicode(keycode, scancode, keys, buf, 4, 0); return XK_Multi_key; } if (result == 2) { /* * This was a dead char, and there were one previously remembered by - * the keyboard. Call ToAscii() again with proper parameters to + * the keyboard. Call ToUnicode() again with proper parameters to * restore it. * * Get information about the old char @@ -273,26 +273,26 @@ KeycodeToKeysym( if (shift & 4) { keys[VK_MENU] = 0x80; } - ToAscii(deadkey, scancode, keys, (LPWORD) buf, 0); + ToUnicode(deadkey, scancode, keys, buf, 4, 0); return XK_Multi_key; } /* - * Keycode mapped to a valid Latin-1 character. Since the keysyms for - * alphanumeric characters map onto Latin-1, we just return it. + * Keycode mapped to a valid Unicode character. Since the keysyms for + * alphanumeric characters map onto Unicode, we just return it. * * We treat 0x7F as a special case mostly for backwards compatibility. In * versions of Tk<=8.2, Control-Backspace returned "XK_BackSpace" as the X * Keysym. This was due to the fact that we did not initialize the keys - * array properly when we passed it to ToAscii, above. We had previously + * array properly when we passed it to ToUnicode, above. We had previously * not been setting the state bit for the Control key. When we fixed that, * we found that Control-Backspace on Windows is interpreted as ASCII-127 * (0x7F), which corresponds to the Delete key. * * Upon discovering this, we realized we had two choices: return XK_Delete * or return XK_BackSpace. If we returned XK_Delete, that could be - * considered "more correct" (although the correctness would be dependant - * on whether you believe that ToAscii is doing the right thing in that + * considered "more correct" (although the correctness would be dependent + * on whether you believe that ToUnicode is doing the right thing in that * case); however, this would break backwards compatibility, and worse, it * would limit application programmers; they would effectively be unable * to bind to on Windows. We therefore chose instead @@ -302,15 +302,15 @@ KeycodeToKeysym( * XK_BackSpace). */ - if (result == 1 && UCHAR(buf[0]) >= 0x20 && UCHAR(buf[0]) != 0x7F) { - return (KeySym) UCHAR(buf[0]); + if (result == 1 && buf[0] >= 0x20 && buf[0] != 0x7F) { + return (KeySym) buf[0]; } /* * Keycode is a non-alphanumeric key, so we have to do the lookup. */ - skipToAscii: + skipToUnicode: if (keycode > MAX_KEYCODE) { return NoSymbol; } @@ -565,7 +565,7 @@ TkpSetKeycodeAndState( } } if (keySym >= 0x20) { - result = VkKeyScan((char) keySym); + result = VkKeyScan((TCHAR) keySym); if (result != -1) { shift = result >> 8; if (shift & 1) @@ -618,7 +618,7 @@ XKeysymToKeycode( } } if (keysym >= 0x20) { - result = VkKeyScan((char) keysym); + result = VkKeyScan((TCHAR) keysym); if (result != -1) { return (KeyCode) (result & 0xff); } -- cgit v0.12 From f9816042fed0405176e42b8e150e111e698d0c3c Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 30 Oct 2016 13:54:12 +0000 Subject: Added test event-8 to test the fix for for [e36963bfe8] --- tests/event.test | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/event.test b/tests/event.test index 756dbe5..7fce6c7 100644 --- a/tests/event.test +++ b/tests/event.test @@ -822,6 +822,41 @@ test event-7.2(double-click) {A double click on a lone character deleteWindows } -result {4 A 4 A} +test event-8 {event generate with keysyms corresponding to + multi-byte virtual keycodes - bug + e36963bfe8df9f5e528134707a91b9c0051de723} -setup { + deleteWindows + set res [list ] +} -body { + set t [toplevel .t] + set e [entry $t.e] + pack $e + tkwait visibility $e + bind $e {lappend res keycode: %k keysym: %K} + focus -force $e + update + event generate $e + # The value now contained in $res depends on the actual + # physical keyboard layout and keycode generated, from + # the hardware on which the test suite happens to run. + # We don't need (and we can't really) check correctness + # of the (system-dependent) keycode received, however + # Tk should be able to associate this keycode to a + # (system-independent) known keysym, unless the system + # running the test does not have a keyboard with a + # diaeresis key. + if {[expr {[lindex $res 3] ne "??"}]} { + # keyboard has a physical diaeresis key and bug is fixed + return "OK" + } else { + return "Test failed, unless the keyboard tied to the system \ + on which this test is run does NOT have a diaeresis \ + physical key - in this case, test is actually void." + } +} -cleanup { + deleteWindows +} -result {OK} + # cleanup unset -nocomplain keypress_lookup rename _init_keypress_lookup {} -- cgit v0.12 From 3938426eec1ec1156da28475d2802ea2aa706fe5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 30 Oct 2016 18:01:51 +0000 Subject: Revert unintentional removal of ::tk_getFileType that happened in [374cb204] --- library/xmfbox.tcl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/xmfbox.tcl b/library/xmfbox.tcl index f1daea0..14d2be5 100644 --- a/library/xmfbox.tcl +++ b/library/xmfbox.tcl @@ -210,6 +210,7 @@ proc ::tk::MotifFDialog_SetFilter {w type} { variable ::tk::Priv set data(filter) [lindex $type 1] + set Priv(selectFileType) [lindex [lindex $type 0] 0] MotifFDialog_Update $w } @@ -980,3 +981,9 @@ proc ::tk::ListBoxKeyAccel_Reset {w} { unset -nocomplain Priv(lbAccel,$w) } +proc ::tk_getFileType {} { + variable ::tk::Priv + + return $Priv(selectFileType) +} + -- cgit v0.12 From 0ac9408c31c8eaeafab81b43654706393ff5f86d Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 30 Oct 2016 20:16:38 +0000 Subject: Added test grid-23 (currently failing) showing bug [6aea69fccb] - grid configure -in problem --- tests/grid.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/grid.test b/tests/grid.test index c1d9d06..cba69db 100644 --- a/tests/grid.test +++ b/tests/grid.test @@ -1998,6 +1998,25 @@ test grid-22.5 {remove} { grid info .c } {-in . -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx {3 5} -pady {4 7} -sticky ns} grid_reset 22.5 + +test grid-23 {grid configure -in leaked from previous master - bug + 6aea69fccbb266b7f0437686379fbe5b55442958} { + frame .f + frame .g + pack .f .g + text .t + grid .t -in .f + pack forget .f + update + grid .t -in .g + # .t is now managed by .g; following lines must have no effect on .t + pack .f + update + pack forget .f + update + winfo ismapped .t ; # must return 1 +} {1} +grid_reset 23 # cleanup cleanupTests -- cgit v0.12 From 700f29364eb3fe91c5eca604342acbba3c0ce7e8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 30 Oct 2016 20:23:37 +0000 Subject: Fixed [6aea69fccb] - grid configure -in problem. Patch by Koen Danckaert. --- generic/tkGrid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 2a88b76..62c9c59 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -3314,6 +3314,9 @@ ConfigureSlaves( } if (slavePtr->masterPtr != NULL && slavePtr->masterPtr != masterPtr) { + if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { + Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); + } Unlink(slavePtr); slavePtr->masterPtr = NULL; } -- cgit v0.12 From dbd5092cb00d45365d9260c2c767757fa4219ede Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 2 Nov 2016 20:07:14 +0000 Subject: Removed proc ::tk_getFileType since it is used nowhere in Tk, is undocumented, is superseded by the -typevariable option of file dialogs, and was anyway only available if tk_strictMotif is true. --- library/tclIndex | 1 - library/xmfbox.tcl | 7 ------- 2 files changed, 8 deletions(-) diff --git a/library/tclIndex b/library/tclIndex index b3f37fa..919fa8a 100644 --- a/library/tclIndex +++ b/library/tclIndex @@ -247,7 +247,6 @@ set auto_index(::tk::ListBoxKeyAccel_Unset) [list source [file join $dir xmfbox. set auto_index(::tk::ListBoxKeyAccel_Key) [list source [file join $dir xmfbox.tcl]] set auto_index(::tk::ListBoxKeyAccel_Goto) [list source [file join $dir xmfbox.tcl]] set auto_index(::tk::ListBoxKeyAccel_Reset) [list source [file join $dir xmfbox.tcl]] -set auto_index(tk_getFileType) [list source [file join $dir xmfbox.tcl]] set auto_index(::tk::unsupported::ExposePrivateCommand) [list source [file join $dir unsupported.tcl]] set auto_index(::tk::unsupported::ExposePrivateVariable) [list source [file join $dir unsupported.tcl]] set auto_index(::tk::fontchooser) [list source [file join $dir fontchooser.tcl]] diff --git a/library/xmfbox.tcl b/library/xmfbox.tcl index 14d2be5..f1daea0 100644 --- a/library/xmfbox.tcl +++ b/library/xmfbox.tcl @@ -210,7 +210,6 @@ proc ::tk::MotifFDialog_SetFilter {w type} { variable ::tk::Priv set data(filter) [lindex $type 1] - set Priv(selectFileType) [lindex [lindex $type 0] 0] MotifFDialog_Update $w } @@ -981,9 +980,3 @@ proc ::tk::ListBoxKeyAccel_Reset {w} { unset -nocomplain Priv(lbAccel,$w) } -proc ::tk_getFileType {} { - variable ::tk::Priv - - return $Priv(selectFileType) -} - -- cgit v0.12 From 2da9e225ec7604a5ad4e4dc46e76d090d733b87c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 4 Nov 2016 15:38:45 +0000 Subject: More internal use of size_t, so refcounts can be bigger than before (2^31 -> 2^32 on 32-bit platforms, even more on 64-bit) --- generic/tkConfig.c | 21 ++++++++++----------- generic/tkConsole.c | 12 ++++++------ generic/tkFont.c | 5 ++--- unix/tkUnixFont.c | 15 +++++++-------- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 9c159e6..093bd35 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -91,7 +91,7 @@ typedef struct TkOption { */ typedef struct OptionTable { - int refCount; /* Counts the number of uses of this table + size_t refCount; /* Counts the number of uses of this table * (the number of times Tk_CreateOptionTable * has returned it). This can be greater than * 1 if it is shared along several option @@ -103,7 +103,7 @@ typedef struct OptionTable { * templates, this points to the table * corresponding to the next template in the * chain. */ - int numOptions; /* The number of items in the options array + size_t numOptions; /* The number of items in the options array * below. */ Option options[1]; /* Information about the individual options in * the table. This must be the last field in @@ -177,7 +177,7 @@ Tk_CreateOptionTable( OptionTable *tablePtr; const Tk_OptionSpec *specPtr, *specPtr2; Option *optionPtr; - int numOptions, i; + size_t numOptions, i; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -330,10 +330,9 @@ Tk_DeleteOptionTable( { OptionTable *tablePtr = (OptionTable *) optionTable; Option *optionPtr; - int count; + size_t count; - tablePtr->refCount--; - if (tablePtr->refCount > 0) { + if (tablePtr->refCount-- > 1) { return; } @@ -978,7 +977,7 @@ GetOption( Option *bestPtr, *optionPtr; OptionTable *tablePtr2; const char *p1, *p2; - int count; + size_t count; /* * Search through all of the option tables in the chain to find the best @@ -1539,7 +1538,7 @@ Tk_FreeConfigOptions( { OptionTable *tablePtr; Option *optionPtr; - int count; + size_t count; Tcl_Obj **oldPtrPtr, *oldPtr; char *oldInternalPtr; const Tk_OptionSpec *specPtr; @@ -1733,7 +1732,7 @@ Tk_GetOptionInfo( Tcl_Obj *resultPtr; OptionTable *tablePtr = (OptionTable *) optionTable; Option *optionPtr; - int count; + size_t count; /* * If information is only wanted for a single configuration spec, then @@ -2096,9 +2095,9 @@ TkDebugConfig( if (tablePtr == (OptionTable *) Tcl_GetHashValue(hashEntryPtr)) { for ( ; tablePtr != NULL; tablePtr = tablePtr->nextPtr) { Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(tablePtr->refCount)); + Tcl_NewWideIntObj(tablePtr->refCount)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(tablePtr->numOptions)); + Tcl_NewWideIntObj(tablePtr->numOptions)); Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj( tablePtr->options[0].specPtr->optionName, -1)); } diff --git a/generic/tkConsole.c b/generic/tkConsole.c index 8bfbe9b..fc60d5f 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -24,7 +24,7 @@ typedef struct ConsoleInfo { Tcl_Interp *consoleInterp; /* Interpreter displaying the console. */ Tcl_Interp *interp; /* Interpreter controlled by console. */ - int refCount; + size_t refCount; } ConsoleInfo; /* @@ -452,7 +452,7 @@ Tk_CreateConsoleWindow( if (mainWindow) { Tk_DeleteEventHandler(mainWindow, StructureNotifyMask, ConsoleEventProc, info); - if (--info->refCount <= 0) { + if (info->refCount-- <= 1) { ckfree(info); } } @@ -592,7 +592,7 @@ ConsoleClose( ConsoleInfo *info = data->info; if (info) { - if (--info->refCount <= 0) { + if (info->refCount-- <= 1) { /* * Assuming the Tcl_Interp * fields must already be NULL. */ @@ -881,7 +881,7 @@ InterpDeleteProc( Tcl_DeleteThreadExitHandler(DeleteConsoleInterp, info->consoleInterp); info->consoleInterp = NULL; } - if (--info->refCount <= 0) { + if (info->refCount-- <= 1) { ckfree(info); } } @@ -912,7 +912,7 @@ ConsoleDeleteProc( if (info->consoleInterp) { Tcl_DeleteInterp(info->consoleInterp); } - if (--info->refCount <= 0) { + if (info->refCount-- <= 1) { ckfree(info); } } @@ -949,7 +949,7 @@ ConsoleEventProc( Tcl_EvalEx(consoleInterp, "tk::ConsoleExit", -1, TCL_EVAL_GLOBAL); } - if (--info->refCount <= 0) { + if (info->refCount-- <= 1) { ckfree(info); } } diff --git a/generic/tkFont.c b/generic/tkFont.c index 7f2715b..a00c627 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -41,7 +41,7 @@ typedef struct TkFontInfo { */ typedef struct NamedFont { - int refCount; /* Number of users of named font. */ + size_t refCount; /* Number of users of named font. */ int deletePending; /* Non-zero if font should be deleted when * last reference goes away. */ TkFontAttributes fa; /* Desired attributes for named font. */ @@ -1434,8 +1434,7 @@ Tk_FreeFont( */ nfPtr = Tcl_GetHashValue(fontPtr->namedHashPtr); - nfPtr->refCount--; - if ((nfPtr->refCount == 0) && nfPtr->deletePending) { + if ((nfPtr->refCount-- <= 1) && nfPtr->deletePending) { Tcl_DeleteHashEntry(fontPtr->namedHashPtr); ckfree(nfPtr); } diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index e694573..c96e562 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -19,8 +19,8 @@ * The preferred font encodings. */ -static const char *const encodingList[] = { - "iso8859-1", "jis0208", "jis0212", NULL +static const char encodingList[][10] = { + "iso8859-1", "jis0208", "jis0212" }; /* @@ -42,7 +42,7 @@ static const char *const encodingList[] = { typedef struct FontFamily { struct FontFamily *nextPtr; /* Next in list of all known font families. */ - int refCount; /* How many SubFonts are referring to this + size_t refCount; /* How many SubFonts are referring to this * FontFamily. When the refCount drops to * zero, this FontFamily may be freed. */ /* @@ -1916,8 +1916,7 @@ FreeFontFamily( if (familyPtr == NULL) { return; } - familyPtr->refCount--; - if (familyPtr->refCount > 0) { + if (familyPtr->refCount-- > 1) { return; } Tcl_FreeEncoding(familyPtr->encoding); @@ -2686,7 +2685,7 @@ RankAttributes( penalty += 150 * diff; } if (gotPtr->xa.charset != wantPtr->xa.charset) { - int i; + size_t i; const char *gotAlias, *wantAlias; penalty += 65000; @@ -2694,7 +2693,7 @@ RankAttributes( wantAlias = GetEncodingAlias(wantPtr->xa.charset); if (strcmp(gotAlias, wantAlias) != 0) { penalty += 30000; - for (i = 0; encodingList[i] != NULL; i++) { + for (i = 0; i < sizeof(encodingList)/sizeof(encodingList[0]); i++) { if (strcmp(gotAlias, encodingList[i]) == 0) { penalty -= 30000; break; @@ -3012,7 +3011,7 @@ static const char * GetEncodingAlias( const char *name) /* The name to look up. */ { - EncodingAlias *aliasPtr; + const EncodingAlias *aliasPtr; for (aliasPtr = encodingAliases; aliasPtr->aliasPattern != NULL; ) { if (Tcl_StringMatch(name, aliasPtr->aliasPattern)) { -- cgit v0.12 From f9626b8791b204e2abc39cfc211befbaa74d7202 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 7 Nov 2016 14:15:04 +0000 Subject: Add another few Xlib stubs for Win32. Cherry-picked from [http://www.androwish.org/index.html/info/862eb620a096fddc|AndroWish]. Thanks to Christian Werner. --- .fossil-settings/crlf-glob | 6 +++ generic/tkInt.decls | 70 +++++++++++++++++++++----- generic/tkIntXlibDecls.h | 121 ++++++++++++++++++++++++++++++++++++++++++--- generic/tkStubInit.c | 26 ++++++++++ macosx/tkMacOSXDraw.c | 5 +- win/tkWinDraw.c | 89 +++++++++++++++++++++++++++++++-- win/tkWinWindow.c | 41 ++++++++++++++- win/tkWinX.c | 5 +- xlib/X11/Xutil.h | 4 +- xlib/xgc.c | 15 +++--- 10 files changed, 346 insertions(+), 36 deletions(-) create mode 100644 .fossil-settings/crlf-glob diff --git a/.fossil-settings/crlf-glob b/.fossil-settings/crlf-glob new file mode 100644 index 0000000..7175730 --- /dev/null +++ b/.fossil-settings/crlf-glob @@ -0,0 +1,6 @@ +win/buildall.vc.bat +win/makefile.bc +win/makefile.vc +win/mkd.bat +win/rmd.bat +win/rules.vc diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 586b407..a13d8d7 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1422,28 +1422,76 @@ declare 106 win { # New in Tk 8.6 declare 107 win { - int XFlush(Display *display) + int XFlush(Display *display) } declare 108 win { - int XGrabServer(Display *display) + int XGrabServer(Display *display) } declare 109 win { - int XUngrabServer(Display *display) + int XUngrabServer(Display *display) } declare 110 win { - int XFree(void *data) + int XFree(void *data) } declare 111 win { - int XNoOp(Display *display) + int XNoOp(Display *display) } declare 112 win { - XAfterFunction XSynchronize(Display *display, Bool onoff) + XAfterFunction XSynchronize(Display *display, Bool onoff) } declare 113 win { - int XSync(Display *display, Bool discard) + int XSync(Display *display, Bool discard) } declare 114 win { - VisualID XVisualIDFromVisual(Visual *visual) + VisualID XVisualIDFromVisual(Visual *visual) +} + +# For tktreectrl +declare 120 win { + int XOffsetRegion(Region rgn, int dx, int dy) +} +declare 121 win { + int XUnionRegion(Region srca, Region srcb, Region dr_return) +} + +# For 3dcanvas +declare 122 win { + Window XCreateWindow(Display *display, Window parent, int x, int y, + unsigned int width, unsigned int height, + unsigned int border_width, int depth, unsigned int clazz, + Visual *visual, unsigned long value_mask, + XSetWindowAttributes *attributes) +} + +# Various, e.g. for stub-enabled BLT +declare 129 win { + int XLowerWindow(Display *d, Window w) +} +declare 130 win { + int XFillArcs(Display *d, Drawable dr, GC gc, XArc *a, int n) +} +declare 131 win { + int XDrawArcs(Display *d, Drawable dr, GC gc, XArc *a, int n) +} +declare 132 win { + int XDrawRectangles(Display *d, Drawable dr, GC gc, XRectangle *r, int n) +} +declare 133 win { + int XDrawSegments(Display *d, Drawable dr, GC gc, XSegment *s, int n) +} +declare 134 win { + int XDrawPoint(Display *d, Drawable dr, GC gc, int x, int y) +} +declare 135 win { + int XDrawPoints(Display *d, Drawable dr, GC gc, XPoint *p, int n, int m) +} +declare 136 win { + int XReparentWindow(Display *d, Window w, Window p, int x, int y) +} +declare 137 win { + int XPutImage(Display *d, Drawable dr, GC gc, XImage *im, + int sx, int sy, int dx, int dy, + unsigned int w, unsigned int h) } ################################ @@ -1725,7 +1773,7 @@ declare 79 aqua { XTextProperty *text_prop_return) } declare 80 aqua { - void XDrawSegments(Display *display, Drawable d, GC gc, + int XDrawSegments(Display *display, Drawable d, GC gc, XSegment *segments, int nsegments) } declare 81 aqua { @@ -1743,10 +1791,10 @@ declare 84 aqua { void XClearWindow(Display *d, Window w) } declare 85 aqua { - void XDrawPoint(Display *display, Drawable d, GC gc, int x, int y) + int XDrawPoint(Display *display, Drawable d, GC gc, int x, int y) } declare 86 aqua { - void XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points, + int XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode) } declare 87 aqua { diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 6ac7ccb..8e7d650 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -356,6 +356,57 @@ EXTERN XAfterFunction XSynchronize(Display *display, Bool onoff); EXTERN int XSync(Display *display, Bool discard); /* 114 */ EXTERN VisualID XVisualIDFromVisual(Visual *visual); +/* Slot 115 is reserved */ +/* Slot 116 is reserved */ +/* Slot 117 is reserved */ +/* Slot 118 is reserved */ +/* Slot 119 is reserved */ +/* 120 */ +EXTERN int XOffsetRegion(Region rgn, int dx, int dy); +/* 121 */ +EXTERN int XUnionRegion(Region srca, Region srcb, + Region dr_return); +/* 122 */ +EXTERN Window XCreateWindow(Display *display, Window parent, int x, + int y, unsigned int width, + unsigned int height, + unsigned int border_width, int depth, + unsigned int clazz, Visual *visual, + unsigned long value_mask, + XSetWindowAttributes *attributes); +/* Slot 123 is reserved */ +/* Slot 124 is reserved */ +/* Slot 125 is reserved */ +/* Slot 126 is reserved */ +/* Slot 127 is reserved */ +/* Slot 128 is reserved */ +/* 129 */ +EXTERN int XLowerWindow(Display *d, Window w); +/* 130 */ +EXTERN int XFillArcs(Display *d, Drawable dr, GC gc, XArc *a, + int n); +/* 131 */ +EXTERN int XDrawArcs(Display *d, Drawable dr, GC gc, XArc *a, + int n); +/* 132 */ +EXTERN int XDrawRectangles(Display *d, Drawable dr, GC gc, + XRectangle *r, int n); +/* 133 */ +EXTERN int XDrawSegments(Display *d, Drawable dr, GC gc, + XSegment *s, int n); +/* 134 */ +EXTERN int XDrawPoint(Display *d, Drawable dr, GC gc, int x, + int y); +/* 135 */ +EXTERN int XDrawPoints(Display *d, Drawable dr, GC gc, + XPoint *p, int n, int m); +/* 136 */ +EXTERN int XReparentWindow(Display *d, Window w, Window p, + int x, int y); +/* 137 */ +EXTERN int XPutImage(Display *d, Drawable dr, GC gc, XImage *im, + int sx, int sy, int dx, int dy, + unsigned int w, unsigned int h); #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ /* 0 */ @@ -584,7 +635,7 @@ EXTERN void XSetWMClientMachine(Display *display, Window w, EXTERN Status XStringListToTextProperty(char **list, int count, XTextProperty *text_prop_return); /* 80 */ -EXTERN void XDrawSegments(Display *display, Drawable d, GC gc, +EXTERN int XDrawSegments(Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 81 */ EXTERN void XForceScreenSaver(Display *display, int mode); @@ -598,10 +649,10 @@ EXTERN int XFillRectangle(Display *display, Drawable d, GC gc, /* 84 */ EXTERN void XClearWindow(Display *d, Window w); /* 85 */ -EXTERN void XDrawPoint(Display *display, Drawable d, GC gc, +EXTERN int XDrawPoint(Display *display, Drawable d, GC gc, int x, int y); /* 86 */ -EXTERN void XDrawPoints(Display *display, Drawable d, GC gc, +EXTERN int XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); /* 87 */ EXTERN int XWarpPointer(Display *display, Window src_w, @@ -742,6 +793,29 @@ typedef struct TkIntXlibStubs { XAfterFunction (*xSynchronize) (Display *display, Bool onoff); /* 112 */ int (*xSync) (Display *display, Bool discard); /* 113 */ VisualID (*xVisualIDFromVisual) (Visual *visual); /* 114 */ + void (*reserved115)(void); + void (*reserved116)(void); + void (*reserved117)(void); + void (*reserved118)(void); + void (*reserved119)(void); + int (*xOffsetRegion) (Region rgn, int dx, int dy); /* 120 */ + int (*xUnionRegion) (Region srca, Region srcb, Region dr_return); /* 121 */ + Window (*xCreateWindow) (Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth, unsigned int clazz, Visual *visual, unsigned long value_mask, XSetWindowAttributes *attributes); /* 122 */ + void (*reserved123)(void); + void (*reserved124)(void); + void (*reserved125)(void); + void (*reserved126)(void); + void (*reserved127)(void); + void (*reserved128)(void); + int (*xLowerWindow) (Display *d, Window w); /* 129 */ + int (*xFillArcs) (Display *d, Drawable dr, GC gc, XArc *a, int n); /* 130 */ + int (*xDrawArcs) (Display *d, Drawable dr, GC gc, XArc *a, int n); /* 131 */ + int (*xDrawRectangles) (Display *d, Drawable dr, GC gc, XRectangle *r, int n); /* 132 */ + int (*xDrawSegments) (Display *d, Drawable dr, GC gc, XSegment *s, int n); /* 133 */ + int (*xDrawPoint) (Display *d, Drawable dr, GC gc, int x, int y); /* 134 */ + int (*xDrawPoints) (Display *d, Drawable dr, GC gc, XPoint *p, int n, int m); /* 135 */ + int (*xReparentWindow) (Display *d, Window w, Window p, int x, int y); /* 136 */ + int (*xPutImage) (Display *d, Drawable dr, GC gc, XImage *im, int sx, int sy, int dx, int dy, unsigned int w, unsigned int h); /* 137 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ int (*xSetDashes) (Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); /* 0 */ @@ -824,13 +898,13 @@ typedef struct TkIntXlibStubs { XVisualInfo * (*xGetVisualInfo) (Display *display, long vinfo_mask, XVisualInfo *vinfo_template, int *nitems_return); /* 77 */ void (*xSetWMClientMachine) (Display *display, Window w, XTextProperty *text_prop); /* 78 */ Status (*xStringListToTextProperty) (char **list, int count, XTextProperty *text_prop_return); /* 79 */ - void (*xDrawSegments) (Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 80 */ + int (*xDrawSegments) (Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 80 */ void (*xForceScreenSaver) (Display *display, int mode); /* 81 */ int (*xDrawLine) (Display *d, Drawable dr, GC g, int x1, int y1, int x2, int y2); /* 82 */ int (*xFillRectangle) (Display *display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height); /* 83 */ void (*xClearWindow) (Display *d, Window w); /* 84 */ - void (*xDrawPoint) (Display *display, Drawable d, GC gc, int x, int y); /* 85 */ - void (*xDrawPoints) (Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); /* 86 */ + int (*xDrawPoint) (Display *display, Drawable d, GC gc, int x, int y); /* 85 */ + int (*xDrawPoints) (Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); /* 86 */ int (*xWarpPointer) (Display *display, Window src_w, Window dest_w, int src_x, int src_y, unsigned int src_width, unsigned int src_height, int dest_x, int dest_y); /* 87 */ void (*xQueryColor) (Display *display, Colormap colormap, XColor *def_in_out); /* 88 */ void (*xQueryColors) (Display *display, Colormap colormap, XColor *defs_in_out, int ncolors); /* 89 */ @@ -1081,6 +1155,41 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; (tkIntXlibStubsPtr->xSync) /* 113 */ #define XVisualIDFromVisual \ (tkIntXlibStubsPtr->xVisualIDFromVisual) /* 114 */ +/* Slot 115 is reserved */ +/* Slot 116 is reserved */ +/* Slot 117 is reserved */ +/* Slot 118 is reserved */ +/* Slot 119 is reserved */ +#define XOffsetRegion \ + (tkIntXlibStubsPtr->xOffsetRegion) /* 120 */ +#define XUnionRegion \ + (tkIntXlibStubsPtr->xUnionRegion) /* 121 */ +#define XCreateWindow \ + (tkIntXlibStubsPtr->xCreateWindow) /* 122 */ +/* Slot 123 is reserved */ +/* Slot 124 is reserved */ +/* Slot 125 is reserved */ +/* Slot 126 is reserved */ +/* Slot 127 is reserved */ +/* Slot 128 is reserved */ +#define XLowerWindow \ + (tkIntXlibStubsPtr->xLowerWindow) /* 129 */ +#define XFillArcs \ + (tkIntXlibStubsPtr->xFillArcs) /* 130 */ +#define XDrawArcs \ + (tkIntXlibStubsPtr->xDrawArcs) /* 131 */ +#define XDrawRectangles \ + (tkIntXlibStubsPtr->xDrawRectangles) /* 132 */ +#define XDrawSegments \ + (tkIntXlibStubsPtr->xDrawSegments) /* 133 */ +#define XDrawPoint \ + (tkIntXlibStubsPtr->xDrawPoint) /* 134 */ +#define XDrawPoints \ + (tkIntXlibStubsPtr->xDrawPoints) /* 135 */ +#define XReparentWindow \ + (tkIntXlibStubsPtr->xReparentWindow) /* 136 */ +#define XPutImage \ + (tkIntXlibStubsPtr->xPutImage) /* 137 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ #define XSetDashes \ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index f08d7f4..9411c26 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -62,6 +62,9 @@ TkCreateXEventSource(void) # define TkUnixContainerId 0 # define TkUnixDoOneXEvent 0 # define TkUnixSetMenubar 0 +# define XCreateWindow 0 +# define XOffsetRegion 0 +# define XUnionRegion 0 # define TkWmCleanup (void (*)(TkDisplay *)) TkpSync # define TkSendCleanup (void (*)(TkDisplay *)) TkpSync # define TkpTestsendCmd 0 @@ -698,6 +701,29 @@ static const TkIntXlibStubs tkIntXlibStubs = { XSynchronize, /* 112 */ XSync, /* 113 */ XVisualIDFromVisual, /* 114 */ + 0, /* 115 */ + 0, /* 116 */ + 0, /* 117 */ + 0, /* 118 */ + 0, /* 119 */ + XOffsetRegion, /* 120 */ + XUnionRegion, /* 121 */ + XCreateWindow, /* 122 */ + 0, /* 123 */ + 0, /* 124 */ + 0, /* 125 */ + 0, /* 126 */ + 0, /* 127 */ + 0, /* 128 */ + XLowerWindow, /* 129 */ + XFillArcs, /* 130 */ + XDrawArcs, /* 131 */ + XDrawRectangles, /* 132 */ + XDrawSegments, /* 133 */ + XDrawPoint, /* 134 */ + XDrawPoints, /* 135 */ + XReparentWindow, /* 136 */ + XPutImage, /* 137 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ XSetDashes, /* 0 */ diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index f48538d..f85d6ac 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -880,7 +880,7 @@ XDrawLines( *---------------------------------------------------------------------- */ -void +int XDrawSegments( Display *display, Drawable d, @@ -894,7 +894,7 @@ XDrawSegments( display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { double o = (lw % 2) ? .5 : 0; @@ -911,6 +911,7 @@ XDrawSegments( } } TkMacOSXRestoreDrawingContext(&dc); + return Success; } /* diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index ba4176c..bb903db 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -486,7 +486,7 @@ XCopyPlane( /* *---------------------------------------------------------------------- * - * TkPutImage -- + * TkPutImage, XPutImage -- * * Copies a subimage from an in-memory image to a rectangle of of the * specified drawable. @@ -599,6 +599,21 @@ TkPutImage( TkWinReleaseDrawableDC(d, dc, &state); return Success; } + +int +XPutImage( + Display *display, + Drawable d, /* Destination drawable. */ + GC gc, + XImage *image, /* Source image. */ + int src_x, int src_y, /* Offset of subimage. */ + int dest_x, int dest_y, /* Position of subimage origin in drawable. */ + unsigned int width, unsigned int height) + /* Dimensions of subimage. */ +{ + return TkPutImage(NULL, 0, display, d, gc, image, + src_x, src_y, dest_x, dest_y, width, height); +} /* *---------------------------------------------------------------------- @@ -940,7 +955,7 @@ XFillPolygon( /* *---------------------------------------------------------------------- * - * XDrawRectangle -- + * XDrawRectangle, XDrawRectangles -- * * Draws a rectangle. * @@ -985,11 +1000,31 @@ XDrawRectangle( TkWinReleaseDrawableDC(d, dc, &state); return Success; } + +int +XDrawRectangles( + Display *display, + Drawable d, + GC gc, + XRectangle rects[], + int nrects) +{ + int n, ret; + + for (n = 0; n < nrects; n++) { + ret = XDrawRectangle(display, d, gc, rects[n].x, rects[n].y, + rects[n].width, rects[n].height); + if (ret != Success) { + break; + } + } + return ret; +} /* *---------------------------------------------------------------------- * - * XDrawArc -- + * XDrawArc, XDrawArcs -- * * Draw an arc. * @@ -1015,11 +1050,34 @@ XDrawArc( return DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 0); } + +int +XDrawArcs( + Display *display, + Drawable d, + GC gc, + XArc *arcs, + int narcs) +{ + int n, ret; + + display->request++; + + for (n = 0; n < narcs; n++) { + ret = DrawOrFillArc(display, d, gc, arcs[n].x, arcs[n].y, + arcs[n].width, arcs[n].height, + arcs[n].angle1, arcs[n].angle2, 0); + if (ret != Success) { + break; + } + } + return ret; +} /* *---------------------------------------------------------------------- * - * XFillArc -- + * XFillArc, XFillArcs -- * * Draw a filled arc. * @@ -1045,6 +1103,29 @@ XFillArc( return DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 1); } + +int +XFillArcs( + Display *display, + Drawable d, + GC gc, + XArc *arcs, + int narcs) +{ + int n, ret; + + display->request++; + + for (n = 0; n < narcs; n++) { + ret = DrawOrFillArc(display, d, gc, arcs[n].x, arcs[n].y, + arcs[n].width, arcs[n].height, + arcs[n].angle1, arcs[n].angle2, 1); + if (ret != Success) { + break; + } + } + return ret; +} /* *---------------------------------------------------------------------- diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index ade15bc..385e72b 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -590,7 +590,7 @@ XResizeWindow( /* *---------------------------------------------------------------------- * - * XRaiseWindow -- + * XRaiseWindow, XLowerWindow -- * * Change the stacking order of a window. * @@ -614,6 +614,18 @@ XRaiseWindow( SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); return Success; } + +int +XLowerWindow( + Display *display, + Window w) +{ + HWND window = Tk_GetHWND(w); + + display->request++; + SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + return Success; +} /* *---------------------------------------------------------------------- @@ -753,6 +765,33 @@ XChangeWindowAttributes( /* *---------------------------------------------------------------------- * + * XReparentWindow -- + * + * TODO: currently placeholder to satisfy Xlib stubs. + * + * Results: + * None. + * + * Side effects: + * TODO. + * + *---------------------------------------------------------------------- + */ + +int +XReparentWindow( + Display *display, + Window w, + Window parent, + int x, + int y) +{ + return BadWindow; +} + +/* + *---------------------------------------------------------------------- + * * TkWinSetWindowPos -- * * Adjust the stacking order of a window relative to a second window (or diff --git a/win/tkWinX.c b/win/tkWinX.c index b2424ce..098fc6d 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -125,16 +125,13 @@ TkGetServerInfo( OSVERSIONINFOW os; if (!buffer[0]) { - HANDLE handle = LoadLibraryW(L"NTDLL"); + HANDLE handle = GetModuleHandle(TEXT("NTDLL")); int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion"); os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); if (!getversion || getversion(&os)) { GetVersionExW(&os); } - if (handle) { - FreeLibrary(handle); - } /* Write the first character last, preventing multi-thread issues. */ sprintf(buffer+1, "indows %d.%d %d %s", (int)os.dwMajorVersion, (int)os.dwMinorVersion, (int)os.dwBuildNumber, diff --git a/xlib/X11/Xutil.h b/xlib/X11/Xutil.h index 58124b0..bf372fb 100644 --- a/xlib/X11/Xutil.h +++ b/xlib/X11/Xutil.h @@ -535,7 +535,7 @@ extern Status XMatchVisualInfo( #endif ); -extern void XOffsetRegion( +extern int XOffsetRegion( #if NeedFunctionPrototypes Region /* r */, int /* dx */, @@ -814,7 +814,7 @@ extern void XUnionRectWithRegion( #endif ); -extern void XUnionRegion( +extern int XUnionRegion( #if NeedFunctionPrototypes Region /* sra */, Region /* srb */, diff --git a/xlib/xgc.c b/xlib/xgc.c index e097d2e..1e720fb 100644 --- a/xlib/xgc.c +++ b/xlib/xgc.c @@ -520,7 +520,7 @@ XDrawImageString( } #endif -void +int XDrawPoint( Display *display, Drawable d, @@ -528,10 +528,10 @@ XDrawPoint( int x, int y) { - XDrawLine(display, d, gc, x, y, x, y); + return XDrawLine(display, d, gc, x, y, x, y); } -void +int XDrawPoints( Display *display, Drawable d, @@ -541,15 +541,17 @@ XDrawPoints( int mode) { int i; + int result = Success; - for (i=0; i Date: Tue, 8 Nov 2016 10:45:07 +0000 Subject: Add XDrawSegments/XDrawPoint/XDrawPoints to internal stub table, and fix their signature matching X11. --- generic/tkFrame.c | 6 +-- generic/tkInt.decls | 32 +++++++++----- generic/tkIntXlibDecls.h | 99 +++++++++++++++++++++++++++++++++++++++++--- generic/tkStubInit.c | 21 ++++++++++ macosx/tkMacOSXDraw.c | 16 ++++--- macosx/tkMacOSXWindowEvent.c | 22 +++++----- macosx/tkMacOSXXStubs.c | 4 +- xlib/X11/Xutil.h | 4 +- xlib/xgc.c | 20 +++++---- 9 files changed, 172 insertions(+), 52 deletions(-) diff --git a/generic/tkFrame.c b/generic/tkFrame.c index e38fe87..0c3c016 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -781,7 +781,7 @@ FrameWidgetObjCmd( || ((c == 'v') && (strncmp(arg, "-visual", (unsigned)length) == 0))) { - #ifdef SUPPORT_CONFIG_EMBEDDED +#ifdef SUPPORT_CONFIG_EMBEDDED if (c == 'u') { CONST char *string = Tcl_GetString(objv[i+1]); if (TkpUseWindow(interp, framePtr->tkwin, @@ -800,7 +800,7 @@ FrameWidgetObjCmd( " option after widget is created", NULL); result = TCL_ERROR; goto done; - #endif +#endif } } result = ConfigureFrame(interp, framePtr, objc-2, objv+2); @@ -1939,7 +1939,7 @@ TkMapTopFrame (tkwin) return; } /* - * The option table has already been created so + * The option table has already been created so * the cached pointer will be returned. */ optionTable = Tk_CreateOptionTable(framePtr->interp, optionSpecs[framePtr->type]); diff --git a/generic/tkInt.decls b/generic/tkInt.decls index f24d48c..c2d018c 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1361,28 +1361,38 @@ declare 106 win { # new for 8.4.20+/8.5.12+ Cygwin only declare 107 win { - int XFlush(Display *display) + int XFlush(Display *display) } declare 108 win { - int XGrabServer(Display *display) + int XGrabServer(Display *display) } declare 109 win { - int XUngrabServer(Display *display) + int XUngrabServer(Display *display) } declare 110 win { - int XFree(void *data) + int XFree(void *data) } declare 111 win { - int XNoOp(Display *display) + int XNoOp(Display *display) } declare 112 win { - XAfterFunction XSynchronize(Display *display, Bool onoff) + XAfterFunction XSynchronize(Display *display, Bool onoff) } declare 113 win { - int XSync(Display *display, Bool discard) + int XSync(Display *display, Bool discard) } declare 114 win { - VisualID XVisualIDFromVisual(Visual *visual) + VisualID XVisualIDFromVisual(Visual *visual) +} + +declare 133 win { + int XDrawSegments(Display *d, Drawable dr, GC gc, XSegment *s, int n) +} +declare 134 win { + int XDrawPoint(Display *d, Drawable dr, GC gc, int x, int y) +} +declare 135 win { + int XDrawPoints(Display *d, Drawable dr, GC gc, XPoint *p, int n, int m) } ################################ @@ -1664,7 +1674,7 @@ declare 79 aqua { XTextProperty *text_prop_return) } declare 80 aqua { - void XDrawSegments(Display *display, Drawable d, GC gc, + int XDrawSegments(Display *display, Drawable d, GC gc, XSegment *segments, int nsegments) } declare 81 aqua { @@ -1682,10 +1692,10 @@ declare 84 aqua { void XClearWindow(Display *d, Window w) } declare 85 aqua { - void XDrawPoint(Display *display, Drawable d, GC gc, int x, int y) + int XDrawPoint(Display *display, Drawable d, GC gc, int x, int y) } declare 86 aqua { - void XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points, + int XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode) } declare 87 aqua { diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index b978561..a897241 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -698,6 +698,42 @@ EXTERN int XSync(Display *display, Bool discard); /* 114 */ EXTERN VisualID XVisualIDFromVisual(Visual *visual); #endif +/* Slot 115 is reserved */ +/* Slot 116 is reserved */ +/* Slot 117 is reserved */ +/* Slot 118 is reserved */ +/* Slot 119 is reserved */ +/* Slot 120 is reserved */ +/* Slot 121 is reserved */ +/* Slot 122 is reserved */ +/* Slot 123 is reserved */ +/* Slot 124 is reserved */ +/* Slot 125 is reserved */ +/* Slot 126 is reserved */ +/* Slot 127 is reserved */ +/* Slot 128 is reserved */ +/* Slot 129 is reserved */ +/* Slot 130 is reserved */ +/* Slot 131 is reserved */ +/* Slot 132 is reserved */ +#ifndef XDrawSegments_TCL_DECLARED +#define XDrawSegments_TCL_DECLARED +/* 133 */ +EXTERN int XDrawSegments(Display *d, Drawable dr, GC gc, + XSegment *s, int n); +#endif +#ifndef XDrawPoint_TCL_DECLARED +#define XDrawPoint_TCL_DECLARED +/* 134 */ +EXTERN int XDrawPoint(Display *d, Drawable dr, GC gc, int x, + int y); +#endif +#ifndef XDrawPoints_TCL_DECLARED +#define XDrawPoints_TCL_DECLARED +/* 135 */ +EXTERN int XDrawPoints(Display *d, Drawable dr, GC gc, + XPoint *p, int n, int m); +#endif #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ #ifndef XSetDashes_TCL_DECLARED @@ -1168,7 +1204,7 @@ EXTERN Status XStringListToTextProperty(char **list, int count, #ifndef XDrawSegments_TCL_DECLARED #define XDrawSegments_TCL_DECLARED /* 80 */ -EXTERN void XDrawSegments(Display *display, Drawable d, GC gc, +EXTERN int XDrawSegments(Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); #endif #ifndef XForceScreenSaver_TCL_DECLARED @@ -1197,13 +1233,13 @@ EXTERN void XClearWindow(Display *d, Window w); #ifndef XDrawPoint_TCL_DECLARED #define XDrawPoint_TCL_DECLARED /* 85 */ -EXTERN void XDrawPoint(Display *display, Drawable d, GC gc, +EXTERN int XDrawPoint(Display *display, Drawable d, GC gc, int x, int y); #endif #ifndef XDrawPoints_TCL_DECLARED #define XDrawPoints_TCL_DECLARED /* 86 */ -EXTERN void XDrawPoints(Display *display, Drawable d, GC gc, +EXTERN int XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); #endif #ifndef XWarpPointer_TCL_DECLARED @@ -1360,6 +1396,27 @@ typedef struct TkIntXlibStubs { XAfterFunction (*xSynchronize) (Display *display, Bool onoff); /* 112 */ int (*xSync) (Display *display, Bool discard); /* 113 */ VisualID (*xVisualIDFromVisual) (Visual *visual); /* 114 */ + VOID *reserved115; + VOID *reserved116; + VOID *reserved117; + VOID *reserved118; + VOID *reserved119; + VOID *reserved120; + VOID *reserved121; + VOID *reserved122; + VOID *reserved123; + VOID *reserved124; + VOID *reserved125; + VOID *reserved126; + VOID *reserved127; + VOID *reserved128; + VOID *reserved129; + VOID *reserved130; + VOID *reserved131; + VOID *reserved132; + int (*xDrawSegments) (Display *d, Drawable dr, GC gc, XSegment *s, int n); /* 133 */ + int (*xDrawPoint) (Display *d, Drawable dr, GC gc, int x, int y); /* 134 */ + int (*xDrawPoints) (Display *d, Drawable dr, GC gc, XPoint *p, int n, int m); /* 135 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ int (*xSetDashes) (Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); /* 0 */ @@ -1442,13 +1499,13 @@ typedef struct TkIntXlibStubs { XVisualInfo * (*xGetVisualInfo) (Display *display, long vinfo_mask, XVisualInfo *vinfo_template, int *nitems_return); /* 77 */ void (*xSetWMClientMachine) (Display *display, Window w, XTextProperty *text_prop); /* 78 */ Status (*xStringListToTextProperty) (char **list, int count, XTextProperty *text_prop_return); /* 79 */ - void (*xDrawSegments) (Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 80 */ + int (*xDrawSegments) (Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 80 */ void (*xForceScreenSaver) (Display *display, int mode); /* 81 */ int (*xDrawLine) (Display *d, Drawable dr, GC g, int x1, int y1, int x2, int y2); /* 82 */ int (*xFillRectangle) (Display *display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height); /* 83 */ void (*xClearWindow) (Display *d, Window w); /* 84 */ - void (*xDrawPoint) (Display *display, Drawable d, GC gc, int x, int y); /* 85 */ - void (*xDrawPoints) (Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); /* 86 */ + int (*xDrawPoint) (Display *display, Drawable d, GC gc, int x, int y); /* 85 */ + int (*xDrawPoints) (Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); /* 86 */ int (*xWarpPointer) (Display *display, Window src_w, Window dest_w, int src_x, int src_y, unsigned int src_width, unsigned int src_height, int dest_x, int dest_y); /* 87 */ void (*xQueryColor) (Display *display, Colormap colormap, XColor *def_in_out); /* 88 */ void (*xQueryColors) (Display *display, Colormap colormap, XColor *defs_in_out, int ncolors); /* 89 */ @@ -1927,6 +1984,36 @@ extern TkIntXlibStubs *tkIntXlibStubsPtr; #define XVisualIDFromVisual \ (tkIntXlibStubsPtr->xVisualIDFromVisual) /* 114 */ #endif +/* Slot 115 is reserved */ +/* Slot 116 is reserved */ +/* Slot 117 is reserved */ +/* Slot 118 is reserved */ +/* Slot 119 is reserved */ +/* Slot 120 is reserved */ +/* Slot 121 is reserved */ +/* Slot 122 is reserved */ +/* Slot 123 is reserved */ +/* Slot 124 is reserved */ +/* Slot 125 is reserved */ +/* Slot 126 is reserved */ +/* Slot 127 is reserved */ +/* Slot 128 is reserved */ +/* Slot 129 is reserved */ +/* Slot 130 is reserved */ +/* Slot 131 is reserved */ +/* Slot 132 is reserved */ +#ifndef XDrawSegments +#define XDrawSegments \ + (tkIntXlibStubsPtr->xDrawSegments) /* 133 */ +#endif +#ifndef XDrawPoint +#define XDrawPoint \ + (tkIntXlibStubsPtr->xDrawPoint) /* 134 */ +#endif +#ifndef XDrawPoints +#define XDrawPoints \ + (tkIntXlibStubsPtr->xDrawPoints) /* 135 */ +#endif #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ #ifndef XSetDashes diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 90a124f..3573db0 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -730,6 +730,27 @@ TkIntXlibStubs tkIntXlibStubs = { XSynchronize, /* 112 */ XSync, /* 113 */ XVisualIDFromVisual, /* 114 */ + NULL, /* 115 */ + NULL, /* 116 */ + NULL, /* 117 */ + NULL, /* 118 */ + NULL, /* 119 */ + NULL, /* 120 */ + NULL, /* 121 */ + NULL, /* 122 */ + NULL, /* 123 */ + NULL, /* 124 */ + NULL, /* 125 */ + NULL, /* 126 */ + NULL, /* 127 */ + NULL, /* 128 */ + NULL, /* 129 */ + NULL, /* 130 */ + NULL, /* 131 */ + NULL, /* 132 */ + XDrawSegments, /* 133 */ + XDrawPoint, /* 134 */ + XDrawPoints, /* 135 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ XSetDashes, /* 0 */ diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index f376591..bb1938a 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -148,7 +148,7 @@ BitmapRepFromDrawableRect( cg_image = CGBitmapContextCreateImage( (CGContextRef) cg_context); sub_cg_image = CGImageCreateWithImageInRect(cg_image, image_rect); if ( sub_cg_image ) { - /*This can be dealloc'ed prematurely if set for autorelease, causing crashes.*/ + /*This can be dealloc'ed prematurely if set for autorelease, causing crashes.*/ bitmap_rep = [NSBitmapImageRep alloc]; [bitmap_rep initWithCGImage:sub_cg_image]; } @@ -163,7 +163,7 @@ BitmapRepFromDrawableRect( width,height); if ( [view lockFocusIfCanDraw] ) { - /*This can be dealloc'ed prematurely if set for autorelease, causing crashes.*/ + /*This can be dealloc'ed prematurely if set for autorelease, causing crashes.*/ bitmap_rep = [NSBitmapImageRep alloc]; bitmap_rep = [bitmap_rep initWithFocusedViewRect:view_rect]; [view unlockFocus]; @@ -786,9 +786,6 @@ DrawCGImage( CGContextDrawImage(context, dstBounds, image); CGContextRestoreGState(context); #endif /* TK_MAC_DEBUG_IMAGE_DRAWING */ - /*if (CGImageIsMask(image)) { - CGContextRestoreGState(context); - }*/ if (subImage) { CFRelease(subImage); } @@ -875,7 +872,7 @@ XDrawLines( *---------------------------------------------------------------------- */ -void +int XDrawSegments( Display *display, Drawable d, @@ -889,7 +886,7 @@ XDrawSegments( display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { double o = (lw % 2) ? .5 : 0; @@ -906,6 +903,7 @@ XDrawSegments( } } TkMacOSXRestoreDrawingContext(&dc); + return Success; } /* @@ -1828,7 +1826,7 @@ TkMacOSXGetClipRgn( { MacDrawable *macDraw = (MacDrawable *) drawable; HIShapeRef clipRgn = NULL; - + if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macDraw->winPtr); #ifdef TK_MAC_DEBUG_DRAWING @@ -1905,7 +1903,7 @@ TkpClipDrawableToRect( { MacDrawable *macDraw = (MacDrawable *) d; NSView *view = TkMacOSXDrawableView(macDraw); - + if (macDraw->drawRgn) { CFRelease(macDraw->drawRgn); macDraw->drawRgn = NULL; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index fce3801..75949ba 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -17,7 +17,7 @@ #include "tkMacOSXWm.h" #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" - + /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_EVENTS @@ -365,10 +365,10 @@ GenerateUpdates( event.xexpose.count = 0; Tk_HandleEvent(&event); - #ifdef TK_MAC_DEBUG_DRAWING +#ifdef TK_MAC_DEBUG_DRAWING NSLog(@"Expose %p {{%d, %d}, {%d, %d}}", event.xany.window, event.xexpose.x, event.xexpose.y, event.xexpose.width, event.xexpose.height); - #endif +#endif /* * Generate updates for the children of this window @@ -395,7 +395,7 @@ GenerateUpdates( /* * TODO: Here we should handle out of process embedding. */ - } + } return 1; } @@ -770,7 +770,7 @@ Tk_MacOSXIsAppInFront(void) /* * Custom content view for use in Tk NSWindows. - * + * * Since Tk handles all drawing of widgets, we only use the AppKit event loop * as a source of input events. To do this, we overload the NSView drawRect * method with a method which generates Expose events for Tk but does no @@ -812,7 +812,7 @@ ConfigureRestrictProc( { const NSRect *rectsBeingDrawn; NSInteger rectsBeingDrawnCount; - + [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; #ifdef TK_MAC_DEBUG_DRAWING @@ -822,7 +822,7 @@ ConfigureRestrictProc( NSCompositeSourceOver); #endif - + CGFloat height = [self bounds].size.height; HIMutableShapeRef drawShape = HIShapeCreateMutable(); @@ -841,9 +841,9 @@ ConfigureRestrictProc( NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode, nil]]; } - + CFRelease(drawShape); - + } -(void) setFrameSize: (NSSize)newsize @@ -863,13 +863,13 @@ ConfigureRestrictProc( * don't clobber the AutoreleasePool set up by the caller. */ [NSApp setPoolProtected:YES]; - + /* * Try to prevent flickers and flashes. */ [w disableFlushWindow]; NSDisableScreenUpdates(); - + /* Disable Tk drawing until the window has been completely configured.*/ TkMacOSXSetDrawingEnabled(winPtr, 0); diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index a16daa8..e928298 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -555,7 +555,7 @@ XClearWindow( } /* -void +int XDrawPoint( Display* display, Drawable d, @@ -565,7 +565,7 @@ XDrawPoint( { } -void +int XDrawPoints( Display* display, Drawable d, diff --git a/xlib/X11/Xutil.h b/xlib/X11/Xutil.h index 58124b0..bf372fb 100644 --- a/xlib/X11/Xutil.h +++ b/xlib/X11/Xutil.h @@ -535,7 +535,7 @@ extern Status XMatchVisualInfo( #endif ); -extern void XOffsetRegion( +extern int XOffsetRegion( #if NeedFunctionPrototypes Region /* r */, int /* dx */, @@ -814,7 +814,7 @@ extern void XUnionRectWithRegion( #endif ); -extern void XUnionRegion( +extern int XUnionRegion( #if NeedFunctionPrototypes Region /* sra */, Region /* srb */, diff --git a/xlib/xgc.c b/xlib/xgc.c index 8975373..b18cb9e 100644 --- a/xlib/xgc.c +++ b/xlib/xgc.c @@ -521,7 +521,7 @@ XDrawImageString( } #endif -void +int XDrawPoint( Display *display, Drawable d, @@ -529,10 +529,10 @@ XDrawPoint( int x, int y) { - XDrawLine(display, d, gc, x, y, x, y); + return XDrawLine(display, d, gc, x, y, x, y); } -void +int XDrawPoints( Display *display, Drawable d, @@ -541,16 +541,19 @@ XDrawPoints( int npoints, int mode) { - int i; + int res = Success; - for (i=0; i 0) { + res = XDrawLine(display, d, gc, + points[0].x, points[0].y, points[0].x, points[0].y); + if (res != Success) break; + ++points; } + return res; } #if !defined(MAC_OSX_TK) -void +int XDrawSegments( Display *display, Drawable d, @@ -558,6 +561,7 @@ XDrawSegments( XSegment *segments, int nsegments) { + return Success; } #endif -- cgit v0.12 From 79c47400ba2c83d6e7b6213f5d2d79994796a2fb Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 8 Nov 2016 15:46:42 +0000 Subject: Mark "event-8" testcase nonPortable --- tests/event.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/event.test b/tests/event.test index 7fce6c7..39beab4 100644 --- a/tests/event.test +++ b/tests/event.test @@ -824,7 +824,7 @@ test event-7.2(double-click) {A double click on a lone character test event-8 {event generate with keysyms corresponding to multi-byte virtual keycodes - bug - e36963bfe8df9f5e528134707a91b9c0051de723} -setup { + e36963bfe8df9f5e528134707a91b9c0051de723} -constraints nonPortable -setup { deleteWindows set res [list ] } -body { -- cgit v0.12 From 7e6a8b0a249f5e75c648e579156e3b30c8866eeb Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 9 Nov 2016 10:58:53 +0000 Subject: Workaround for possible build problem on Windows/MacOSX: Some (older) versions of X11/Xutil.h have a wrong signature for XOffsetRegion/XUnionRegion, so move them out of the way temporarly. --- generic/tkIntXlibDecls.h | 6 ++++++ macosx/tkMacOSXPort.h | 1 - xlib/xutil.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 8e7d650..de44068 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -23,7 +23,13 @@ # include #endif +/* Some (older) versions of X11/Xutil.h have a wrong signature of those + two functions, so move them out of the way temporarly. */ +#define XOffsetRegion _XOffsetRegion +#define XUnionRegion _XUnionRegion #include "X11/Xutil.h" +#undef XOffsetRegion +#undef XUnionRegion #ifdef BUILD_tk #undef TCL_STORAGE_CLASS diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index 0c3b347..bd48bd5 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -53,7 +53,6 @@ #include #include #include -#include "tkIntXlibDecls.h" /* * The following macro defines the type of the mask arguments to diff --git a/xlib/xutil.c b/xlib/xutil.c index 0514d7a..7b69e18 100644 --- a/xlib/xutil.c +++ b/xlib/xutil.c @@ -12,6 +12,7 @@ #include #include +#include #include #include -- cgit v0.12 From 3b8a1a19064c05bb314d93d5ce9e2d51efbb5e44 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 9 Nov 2016 13:41:27 +0000 Subject: Bring all win32 version stuff to one place. Should work the same (should still work on XP, although I don't know if we really want that). --- win/tkWin.h | 12 +++++++++--- win/tkWinMenu.c | 17 ++++++----------- win/tkWinX.c | 10 ---------- win/ttkWinXPTheme.c | 6 +----- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/win/tkWin.h b/win/tkWin.h index 4d278d7..86be2e9 100644 --- a/win/tkWin.h +++ b/win/tkWin.h @@ -18,14 +18,20 @@ * the SystemParametersInfo API doesn't like to receive structures that * are larger than it expects which affects the font assignments. * - * WINVER = 0x0500 means Windows 2000 and above + * NTDDI_VERSION = 0x0600 means Windows Vista and above */ +#ifndef NTDDI_VERSION +#define NTDDI_VERSION 0x06000000 +#endif #ifndef WINVER -#define WINVER 0x0500 +#define WINVER 0x0600 #endif #ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 +#define _WIN32_WINNT 0x0600 +#endif +#ifndef _WIN32_IE +#define _WIN32_IE 0x0600 #endif #ifndef _TK diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 8e14669..0975633 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -3203,12 +3203,7 @@ SetDefaults( int pointSize; HFONT menuFont; /* See: [Bug #3239768] tk8.4.19 (and later) WIN32 menu font support */ - struct { - NONCLIENTMETRICS metrics; -#if (WINVER < 0x0600) - int padding; -#endif - } nc; + NONCLIENTMETRICS metrics; OSVERSIONINFOW os; /* @@ -3227,17 +3222,17 @@ SetDefaults( } Tcl_DStringInit(&menuFontDString); - nc.metrics.cbSize = sizeof(nc); + metrics.cbSize = sizeof(metrics); os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); GetVersionExW(&os); if (os.dwMajorVersion < 6) { - nc.metrics.cbSize -= sizeof(int); + metrics.cbSize -= sizeof(int); } - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, nc.metrics.cbSize, - &nc.metrics, 0); - menuFont = CreateFontIndirect(&nc.metrics.lfMenuFont); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, + &metrics, 0); + menuFont = CreateFontIndirect(&metrics.lfMenuFont); SelectObject(scratchDC, menuFont); GetTextMetricsA(scratchDC, &tm); GetTextFaceA(scratchDC, LF_FACESIZE, faceName); diff --git a/win/tkWinX.c b/win/tkWinX.c index cfd64af..d41b6c1 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -13,16 +13,6 @@ #include "tkWinInt.h" -/* - * The w32api 1.1 package (included in Mingw 1.1) does not define _WIN32_IE by - * default. Define it here to gain access to the InitCommonControlsEx API in - * commctrl.h. - */ - -#ifndef _WIN32_IE -#define _WIN32_IE 0x0550 /* IE 5.5 */ -#endif - #include #ifdef _MSC_VER # pragma comment (lib, "comctl32.lib") diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 3de1504..909660a 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -15,14 +15,12 @@ * shellcc/platform/commctls/userex/refentry.asp > */ +#include #ifndef HAVE_UXTHEME_H /* Stub for platforms that lack the XP theme API headers: */ -#include int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) { return TCL_OK; } #else -#define WINVER 0x0501 /* Requires Windows XP APIs */ - #include #include #if defined(HAVE_VSSYM32_H) || _MSC_VER > 1500 @@ -31,8 +29,6 @@ int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) { return TCL_OK; } # include #endif -#include - #include "ttk/ttkTheme.h" typedef HTHEME (STDAPICALLTYPE OpenThemeDataProc)(HWND hwnd, -- cgit v0.12 From 014b4675af8c2a789caf37365b6ff284c3981006 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 13 Nov 2016 15:14:38 +0000 Subject: Added test combobox-3 to check [f60c54bec6] --- tests/ttk/combobox.test | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/ttk/combobox.test b/tests/ttk/combobox.test index 43f3cf1..c134bfc 100644 --- a/tests/ttk/combobox.test +++ b/tests/ttk/combobox.test @@ -45,6 +45,15 @@ test combobox-2.4 "current -- value not in list" -body { test combobox-2.end "Cleanup" -body { destroy .cb } +test combobox-3 "Read postoffset value dynamically from current style" -body { + ttk::combobox .cb -values [list a b c] -style "DerivedStyle.TCombobox" + pack .cb -expand true -fill both + ttk::style configure DerivedStyle.TCombobox -postoffset [list 25 0 0 0] + ttk::combobox::Post .cb + winfo x .cb.popdown +} -result 25 -cleanup { + destroy .cb +} test combobox-1890211 "ComboboxSelected event after listbox unposted" -body { # whitebox test... -- cgit v0.12 From c3149fa0b5bd697ccb9d9afafc37b3aa55739af1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 13 Nov 2016 15:15:46 +0000 Subject: Fix for [f60c54bec6] Combobox does not retrieve -postoffset value from correct style. Thanks to Daniele Panza. --- library/ttk/combobox.tcl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl index 03821a2..6ceccef 100644 --- a/library/ttk/combobox.tcl +++ b/library/ttk/combobox.tcl @@ -368,7 +368,8 @@ proc ttk::combobox::PlacePopdown {cb popdown} { set y [winfo rooty $cb] set w [winfo width $cb] set h [winfo height $cb] - set postoffset [ttk::style lookup TCombobox -postoffset {} {0 0 0 0}] + set style [$cb cget -style] + set postoffset [ttk::style lookup $style -postoffset {} {0 0 0 0}] foreach var {x y w h} delta $postoffset { incr $var $delta } -- cgit v0.12 From 690db09c143da53cd3adebb52f8eac12db5c767c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 18 Nov 2016 13:12:18 +0000 Subject: constrain new test-case to UNIX only, since on Windows the test-result appears to depend on the window's border. --- tests/ttk/combobox.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ttk/combobox.test b/tests/ttk/combobox.test index c134bfc..35ded6c 100644 --- a/tests/ttk/combobox.test +++ b/tests/ttk/combobox.test @@ -45,7 +45,7 @@ test combobox-2.4 "current -- value not in list" -body { test combobox-2.end "Cleanup" -body { destroy .cb } -test combobox-3 "Read postoffset value dynamically from current style" -body { +test combobox-3 "Read postoffset value dynamically from current style" -constraints unix -body { ttk::combobox .cb -values [list a b c] -style "DerivedStyle.TCombobox" pack .cb -expand true -fill both ttk::style configure DerivedStyle.TCombobox -postoffset [list 25 0 0 0] -- cgit v0.12 From 5d9e5480a505739f553519d15fd0270185127b50 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 22 Nov 2016 09:14:08 +0000 Subject: Fix [86a7468862]. Make test combobox-3 pass (hopefully) on all platforms. --- tests/ttk/combobox.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ttk/combobox.test b/tests/ttk/combobox.test index 35ded6c..7ea0c5c 100644 --- a/tests/ttk/combobox.test +++ b/tests/ttk/combobox.test @@ -45,12 +45,12 @@ test combobox-2.4 "current -- value not in list" -body { test combobox-2.end "Cleanup" -body { destroy .cb } -test combobox-3 "Read postoffset value dynamically from current style" -constraints unix -body { +test combobox-3 "Read postoffset value dynamically from current style" -body { ttk::combobox .cb -values [list a b c] -style "DerivedStyle.TCombobox" pack .cb -expand true -fill both ttk::style configure DerivedStyle.TCombobox -postoffset [list 25 0 0 0] ttk::combobox::Post .cb - winfo x .cb.popdown + expr {[winfo rootx .cb.popdown] - [winfo rootx .cb]} } -result 25 -cleanup { destroy .cb } -- cgit v0.12 From 39cfdaa0524f329527d9ee22d9229ce476560f05 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 30 Nov 2016 21:51:25 +0000 Subject: Fixed [3ee76e41c2] - New textTag test failures --- tests/textTag.test | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/tests/textTag.test b/tests/textTag.test index 2df8c5a..a2b2d73 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -11,6 +11,19 @@ namespace import ::tcltest::* eval tcltest::configure $argv tcltest::loadTestedCommands +set textWidgetFont {Courier 12} +set bigFont {Helvetica 24} + +# what is needed is a specific font *size* because in some tests (that +# will be constrained by haveFontSizes), a tag applying the $bigFont +# will be set to some characters, which action has the effect of +# changing what character is under the mouse pointer, which is the +# purpose of the tests +testConstraint haveFontSizes [expr { + [font actual $textWidgetFont -size] == 12 && + [font actual $bigFont -size] == 24 } +] + destroy .t text .t -width 20 -height 10 @@ -19,7 +32,6 @@ update .t debug on wm geometry . {} -set bigFont {Helvetica 24} # The statements below reset the main window; it's needed if the window # manager is mwm, to make mwm forget about a previous minimum size setting. @@ -1313,9 +1325,13 @@ test textTag-16.1 {TkTextPickCurrent procedure} -setup { lappend x [.t index current] } -result {2.1 3.2 3.2 3.2 3.2 3.2 4.3} -test textTag-16.2 {TkTextPickCurrent procedure} -setup { +test textTag-16.2 {TkTextPickCurrent procedure} -constraints { + haveFontSizes +} -setup { .t tag delete {*}[.t tag names] event generate {} -warp 1 -x -1 -y -1; update + set curFont [.t cget -font] + .t configure -font $textWidgetFont } -body { .t tag configure big -font $bigFont event gen .t -state 0x100 -x $x1 -y $y1 @@ -1326,6 +1342,7 @@ test textTag-16.2 {TkTextPickCurrent procedure} -setup { lappend x [.t index current] } -cleanup { .t tag delete big + .t configure -font $curFont } -result {3.2 3.1} test textTag-16.3 {TkTextPickCurrent procedure} -setup { @@ -1381,11 +1398,15 @@ test textTag-16.4 {TkTextPickCurrent procedure} -setup { .t tag delete {*}[.t tag names] } -result {enter-a enter-b enter-c | leave-c leave-b} -test textTag-16.5 {TkTextPickCurrent procedure} -setup { +test textTag-16.5 {TkTextPickCurrent procedure} -constraints { + haveFontSizes +} -setup { foreach i {big a b c d} { .t tag remove $i 1.0 end } event generate {} -warp 1 -x -1 -y -1; update + set curFont [.t cget -font] + .t configure -font $textWidgetFont } -body { .t tag configure big -font $bigFont event gen .t -x $x1 -y $y1 @@ -1395,13 +1416,18 @@ test textTag-16.5 {TkTextPickCurrent procedure} -setup { .t index current } -cleanup { .t tag delete a big + .t configure -font $curFont } -result {3.2} -test textTag-16.6 {TkTextPickCurrent procedure} -setup { +test textTag-16.6 {TkTextPickCurrent procedure} -constraints { + haveFontSizes +} -setup { foreach i {big a b c d} { .t tag remove $i 1.0 end } event generate {} -warp 1 -x -1 -y -1; update + set curFont [.t cget -font] + .t configure -font $textWidgetFont } -body { .t tag configure big -font $bigFont event gen .t -x $x1 -y $y1 @@ -1412,13 +1438,18 @@ test textTag-16.6 {TkTextPickCurrent procedure} -setup { .t index current } -cleanup { .t tag delete a big + .t configure -font $curFont } -result {3.1} -test textTag-16.7 {TkTextPickCurrent procedure} -setup { +test textTag-16.7 {TkTextPickCurrent procedure} -constraints { + haveFontSizes +} -setup { foreach i {big a b c d} { .t tag remove $i 1.0 end } event generate {} -warp 1 -x -1 -y -1; update + set curFont [.t cget -font] + .t configure -font $textWidgetFont } -body { .t tag configure big -font $bigFont .t tag bind a {.t tag add big 3.0 3.2} @@ -1432,6 +1463,7 @@ test textTag-16.7 {TkTextPickCurrent procedure} -setup { .t index current } -cleanup { .t tag delete a big + .t configure -font $curFont } -result {3.1} -- cgit v0.12 From 9d9cee0288f4ef2d88ddaa3a3f41c34751d851fd Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 1 Dec 2016 19:27:08 +0000 Subject: Also the fact that the actually used fonts must be fixed-width needs to be checked when assessing the value of the haveFontSizes constraint --- tests/textTag.test | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/textTag.test b/tests/textTag.test index a2b2d73..6489c3a 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -12,16 +12,18 @@ eval tcltest::configure $argv tcltest::loadTestedCommands set textWidgetFont {Courier 12} -set bigFont {Helvetica 24} +set bigFont {Courier 24} -# what is needed is a specific font *size* because in some tests (that -# will be constrained by haveFontSizes), a tag applying the $bigFont -# will be set to some characters, which action has the effect of -# changing what character is under the mouse pointer, which is the -# purpose of the tests +# what is needed is a font that is both fixed-width and featuring a +# specific size because in some tests (that will be constrained by +# haveFontSizes), a tag applying the $bigFont will be set to some +# characters, which action has the effect of changing what character +# is under the mouse pointer, which is the purpose of the tests testConstraint haveFontSizes [expr { - [font actual $textWidgetFont -size] == 12 && - [font actual $bigFont -size] == 24 } + [font metrics $textWidgetFont -fixed] && + [font actual $textWidgetFont -size] == 12 && + [font metrics $bigFont -fixed] && + [font actual $bigFont -size] == 24 } ] destroy .t -- cgit v0.12 From cabe11c363724790cf77f9a1c39b27703d0093b9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 1 Dec 2016 21:45:34 +0000 Subject: When changing the text font, (x,y) coordinates previously saved in the (xi,yi) doublets are no longer relevant. Save coordinates for each of the two font possibilities, and use the right ones in each test. --- tests/textTag.test | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/tests/textTag.test b/tests/textTag.test index 6489c3a..ca34bc7 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -1210,7 +1210,8 @@ test textTag-14.4 {SortTags} -setup { } -result {x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29} - +set curFont [.t cget -font] +set curWrap [.t cget -wrap] set c [.t bbox 2.1] set x1 [expr [lindex $c 0] + [lindex $c 2]/2] set y1 [expr [lindex $c 1] + [lindex $c 3]/2] @@ -1220,6 +1221,15 @@ set y2 [expr [lindex $c 1] + [lindex $c 3]/2] set c [.t bbox 4.3] set x3 [expr [lindex $c 0] + [lindex $c 2]/2] set y3 [expr [lindex $c 1] + [lindex $c 3]/2] +.t configure -font $textWidgetFont -wrap none +update +set c [.t bbox 2.1] +set x4 [expr [lindex $c 0] + [lindex $c 2]/2] +set y4 [expr [lindex $c 1] + [lindex $c 3]/2] +set c [.t bbox 3.2] +set x5 [expr [lindex $c 0] + [lindex $c 2]/2] +set y5 [expr [lindex $c 1] + [lindex $c 3]/2] +.t configure -font $curFont -wrap $curWrap test textTag-15.1 {TkTextBindProc} -setup { .t tag delete x y @@ -1333,18 +1343,18 @@ test textTag-16.2 {TkTextPickCurrent procedure} -constraints { .t tag delete {*}[.t tag names] event generate {} -warp 1 -x -1 -y -1; update set curFont [.t cget -font] - .t configure -font $textWidgetFont + .t configure -font $textWidgetFont -wrap none } -body { .t tag configure big -font $bigFont - event gen .t -state 0x100 -x $x1 -y $y1 - event gen .t -x $x2 -y $y2 + event gen .t -state 0x100 -x $x4 -y $y4 + event gen .t -x $x5 -y $y5 set x [.t index current] .t tag add big 3.0 update lappend x [.t index current] } -cleanup { .t tag delete big - .t configure -font $curFont + .t configure -font $curFont -wrap $curWrap } -result {3.2 3.1} test textTag-16.3 {TkTextPickCurrent procedure} -setup { @@ -1408,17 +1418,17 @@ test textTag-16.5 {TkTextPickCurrent procedure} -constraints { } event generate {} -warp 1 -x -1 -y -1; update set curFont [.t cget -font] - .t configure -font $textWidgetFont + .t configure -font $textWidgetFont -wrap none } -body { .t tag configure big -font $bigFont - event gen .t -x $x1 -y $y1 + event gen .t -x $x4 -y $y4 .t tag bind a {.t tag add big 3.0 3.2} .t tag add a 3.2 - event gen .t -x $x2 -y $y2 + event gen .t -x $x5 -y $y5 .t index current } -cleanup { .t tag delete a big - .t configure -font $curFont + .t configure -font $curFont -wrap $curWrap } -result {3.2} test textTag-16.6 {TkTextPickCurrent procedure} -constraints { @@ -1429,18 +1439,18 @@ test textTag-16.6 {TkTextPickCurrent procedure} -constraints { } event generate {} -warp 1 -x -1 -y -1; update set curFont [.t cget -font] - .t configure -font $textWidgetFont + .t configure -font $textWidgetFont -wrap none } -body { .t tag configure big -font $bigFont - event gen .t -x $x1 -y $y1 + event gen .t -x $x4 -y $y4 .t tag bind a {.t tag add big 3.0 3.2} .t tag add a 3.2 - event gen .t -x $x2 -y $y2 + event gen .t -x $x5 -y $y5 update .t index current } -cleanup { .t tag delete a big - .t configure -font $curFont + .t configure -font $curFont -wrap $curWrap } -result {3.1} test textTag-16.7 {TkTextPickCurrent procedure} -constraints { @@ -1451,21 +1461,21 @@ test textTag-16.7 {TkTextPickCurrent procedure} -constraints { } event generate {} -warp 1 -x -1 -y -1; update set curFont [.t cget -font] - .t configure -font $textWidgetFont + .t configure -font $textWidgetFont -wrap none } -body { .t tag configure big -font $bigFont .t tag bind a {.t tag add big 3.0 3.2} .t tag add a 3.2 - event gen .t -x $x1 -y $y1 + event gen .t -x $x4 -y $y4 .t tag bind a {.t tag add big 3.0 3.2} .t tag add a 2.1 - event gen .t -x $x2 -y $y2 + event gen .t -x $x5 -y $y5 update .t index current } -cleanup { .t tag delete a big - .t configure -font $curFont + .t configure -font $curFont -wrap $curWrap } -result {3.1} -- cgit v0.12 From 954d42e47de744904aac4b8d78c7f7b4048e8a17 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 2 Dec 2016 06:35:22 +0000 Subject: Remove superfluous lines (the default font of the text widget is already saved in $curFont before the tests start). --- tests/textTag.test | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/textTag.test b/tests/textTag.test index ca34bc7..93feb27 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -1342,7 +1342,6 @@ test textTag-16.2 {TkTextPickCurrent procedure} -constraints { } -setup { .t tag delete {*}[.t tag names] event generate {} -warp 1 -x -1 -y -1; update - set curFont [.t cget -font] .t configure -font $textWidgetFont -wrap none } -body { .t tag configure big -font $bigFont @@ -1417,7 +1416,6 @@ test textTag-16.5 {TkTextPickCurrent procedure} -constraints { .t tag remove $i 1.0 end } event generate {} -warp 1 -x -1 -y -1; update - set curFont [.t cget -font] .t configure -font $textWidgetFont -wrap none } -body { .t tag configure big -font $bigFont @@ -1438,7 +1436,6 @@ test textTag-16.6 {TkTextPickCurrent procedure} -constraints { .t tag remove $i 1.0 end } event generate {} -warp 1 -x -1 -y -1; update - set curFont [.t cget -font] .t configure -font $textWidgetFont -wrap none } -body { .t tag configure big -font $bigFont @@ -1460,7 +1457,6 @@ test textTag-16.7 {TkTextPickCurrent procedure} -constraints { .t tag remove $i 1.0 end } event generate {} -warp 1 -x -1 -y -1; update - set curFont [.t cget -font] .t configure -font $textWidgetFont -wrap none } -body { .t tag configure big -font $bigFont -- cgit v0.12 From fd7ab722c98be2bee1064d8721bbcae710a74f14 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 2 Dec 2016 12:57:58 +0000 Subject: [76e2d9c095] Repair broken test border-3.1 --- tests/border.test | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/border.test b/tests/border.test index 2ca64c1..d6ff5c7 100644 --- a/tests/border.test +++ b/tests/border.test @@ -127,16 +127,18 @@ test border-2.2 {Tk_Free3DBorder - unlinking from list} -constraints { destroy .b .t2 .t3 .t } -result {{{4 1} {3 0} {2 0} {1 0}} {{4 1} {2 0} {1 0}} {{4 1} {2 0}} {{2 0}} {}} + test border-3.1 {FreeBorderObjProc} -constraints { testborder } -setup { set result {} + proc copy {s} {return [string index $s 0][string range $s 1 end]} } -body { - set x [join purple] + set x [copy purple] button .b -bg $x -text .b1 - set y [join purple] + set y [copy purple] .b configure -bg $y - set z [join purple] + set z [copy purple] .b configure -bg $z lappend result [testborder purple] set x red @@ -148,6 +150,7 @@ test border-3.1 {FreeBorderObjProc} -constraints { set y bogus return $result } -cleanup { + rename copy {} destroy .b } -result {{{1 3}} {{1 2}} {{1 1}} {}} -- cgit v0.12 From c9609fa27feeb754fbbaa92539825a04d2c4d7f6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 2 Dec 2016 20:58:36 +0000 Subject: Fix [ad98f10b3a] and [bd0017bf79] - bitmap-4.1 and cursor-4.1 tests failures. Also, apply again the same pattern to fix color-4.1 that was also failing (when the colorsFree constraint was met) despite there was no such report (yet). Thanks to dgp. --- tests/bitmap.test | 9 ++++++--- tests/color.test | 16 +++++++++++----- tests/cursor.test | 9 ++++++--- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/bitmap.test b/tests/bitmap.test index bd9c47f..6996f88 100644 --- a/tests/bitmap.test +++ b/tests/bitmap.test @@ -84,12 +84,14 @@ test bitmap-3.1 {Tk_FreeBitmapFromObj - reference counts} -constraints { test bitmap-4.1 {FreeBitmapObjProc} -constraints { testbitmap +} -setup { + proc copy {s} {return [string index $s 0][string range $s 1 end]} } -body { - set x [join questhead] + set x [copy questhead] button .b -bitmap $x - set y [join questhead] + set y [copy questhead] .b configure -bitmap $y - set z [join questhead] + set z [copy questhead] .b configure -bitmap $z set result {} lappend result [testbitmap questhead] @@ -102,6 +104,7 @@ test bitmap-4.1 {FreeBitmapObjProc} -constraints { set y bogus return $result } -cleanup { + rename copy {} destroy .b } -result {{{1 3}} {{1 2}} {{1 1}} {}} diff --git a/tests/color.test b/tests/color.test index 237ec01..0b328cf 100644 --- a/tests/color.test +++ b/tests/color.test @@ -255,13 +255,17 @@ test color-3.4 {Tk_FreeColorFromObj - unlinking from list} colorsFree { lappend result [testcolor purple] } {{{4 1} {3 0} {2 0} {1 0}} {{4 1} {2 0} {1 0}} {{4 1} {2 0}} {{2 0}} {}} -test color-4.1 {FreeColorObjProc} colorsFree { +test color-4.1 {FreeColorObjProc} -constraints { + colorsFree +} -setup { + proc copy {s} {return [string index $s 0][string range $s 1 end]} +} -body { destroy .b - set x [format purple] + set x [copy purple] button .b -foreground $x -text .b1 - set y [format purple] + set y [copy purple] .b configure -foreground $y - set z [format purple] + set z [copy purple] .b configure -foreground $z set result {} lappend result [testcolor purple] @@ -273,7 +277,9 @@ test color-4.1 {FreeColorObjProc} colorsFree { lappend result [testcolor purple] set y bogus set result -} {{{1 3}} {{1 2}} {{1 1}} {}} +} -cleanup { + rename copy {} +} -result {{{1 3}} {{1 2}} {{1 1}} {}} destroy .t diff --git a/tests/cursor.test b/tests/cursor.test index 95c7b99..8d7ebb0 100644 --- a/tests/cursor.test +++ b/tests/cursor.test @@ -144,12 +144,14 @@ test cursor-3.1 {Tk_FreeCursorFromObj - reference counts} -constraints { test cursor-4.1 {FreeCursorObjProc} -constraints { testcursor +} -setup { + proc copy {s} {return [string index $s 0][string range $s 1 end]} } -body { - set x [join heart] + set x [copy heart] button .b -cursor $x - set y [join heart] + set y [copy heart] .b configure -cursor $y - set z [join heart] + set z [copy heart] .b configure -cursor $z set result {} lappend result [testcursor heart] @@ -162,6 +164,7 @@ test cursor-4.1 {FreeCursorObjProc} -constraints { set y bogus set result } -cleanup { + rename copy {} destroy .b } -result {{{1 3}} {{1 2}} {{1 1}} {}} -- cgit v0.12 From e63cc287cacc144a9a0a5c405d49cca44b37e574 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 8 Dec 2016 20:46:48 +0000 Subject: Micro-optimization in tkTextDisp.c --- generic/tkTextDisp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index a6e665a..1c4925d 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -8981,13 +8981,13 @@ RemoveFromBaseChunk( bciPtr = baseCharChunkPtr->clientData; +#ifdef DEBUG_LAYOUT_WITH_BASE_CHUNKS if ((ciPtr->baseOffset + ciPtr->numBytes) != Tcl_DStringLength(&bciPtr->baseChars)) { -#ifdef DEBUG_LAYOUT_WITH_BASE_CHUNKS fprintf(stderr,"RemoveFromBaseChunk called with wrong chunk " "(not last)\n"); -#endif } +#endif Tcl_DStringSetLength(&bciPtr->baseChars, ciPtr->baseOffset); -- cgit v0.12 From 6130ca3ef131a8459a378ee9e3fa67484d6fe178 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 15 Dec 2016 16:07:06 +0000 Subject: Proposed fix for [7d967c68a09e07e355358af40f36dd5dd84c7022|7d967c68]: Tk applications segmentation fault when ibus-daemon IME is restarted --- generic/tkEvent.c | 13 ++++++++++++- generic/tkInt.h | 6 ++++++ generic/tkWindow.c | 11 +++++++++-- unix/tkUnixEvent.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 95aeda1..d058e7c 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -356,6 +356,7 @@ CreateXIC( /* XCreateIC failed. */ return; } + winPtr->ximGeneration = dispPtr->ximGeneration; /* * Adjust the window's event mask if the IM requires it. @@ -1288,6 +1289,14 @@ Tk_HandleEvent( */ #ifdef TK_USE_INPUT_METHODS + /* + * If the XIC has been invalidated, it must be recreated. + */ + if (winPtr->dispPtr->ximGeneration != winPtr->ximGeneration) { + winPtr->flags &= ~TK_CHECKED_IC; + winPtr->inputContext = NULL; + } + if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM)) { if (!(winPtr->flags & (TK_CHECKED_IC|TK_ALREADY_DEAD))) { winPtr->flags |= TK_CHECKED_IC; @@ -1295,7 +1304,9 @@ Tk_HandleEvent( CreateXIC(winPtr); } } - if (eventPtr->type == FocusIn && winPtr->inputContext != NULL) { + if ((eventPtr->type == FocusIn) && + (winPtr->dispPtr->inputMethod != NULL) && + (winPtr->inputContext != NULL)) { XSetICFocus(winPtr->inputContext); } } diff --git a/generic/tkInt.h b/generic/tkInt.h index 1615a81..f00d833 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -508,6 +508,9 @@ typedef struct TkDisplay { int iconDataSize; /* Size of default iconphoto image data. */ unsigned char *iconDataPtr; /* Default iconphoto image data, if set. */ +#ifdef TK_USE_INPUT_METHODS + int ximGeneration; /* Used to invalidate XIC */ +#endif /* TK_USE_INPUT_METHODS */ } TkDisplay; /* @@ -809,6 +812,9 @@ typedef struct TkWindow { int minReqWidth; /* Minimum requested width. */ int minReqHeight; /* Minimum requested height. */ char *geometryMaster; +#ifdef TK_USE_INPUT_METHODS + int ximGeneration; /* Used to invalidate XIC */ +#endif /* TK_USE_INPUT_METHODS */ } TkWindow; /* diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 5855b7c..85c5590 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -355,6 +355,9 @@ CreateTopLevelWindow( * Set the flags specified in the call. */ +#ifdef TK_USE_INPUT_METHODS + winPtr->ximGeneration = 0; +#endif /*TK_USE_INPUT_METHODS*/ winPtr->flags |= flags; /* @@ -472,6 +475,9 @@ GetScreen( dispPtr->cursorFont = None; dispPtr->warpWindow = NULL; dispPtr->multipleAtom = None; +#ifdef TK_USE_INPUT_METHODS + dispPtr->ximGeneration = 0; +#endif /*TK_USE_INPUT_METHODS*/ /* * By default we do want to collapse motion events in @@ -1442,10 +1448,11 @@ Tk_DestroyWindow( UnlinkWindow(winPtr); TkEventDeadWindow(winPtr); #ifdef TK_USE_INPUT_METHODS - if (winPtr->inputContext != NULL) { + if (winPtr->inputContext != NULL && + winPtr->ximGeneration == winPtr->dispPtr->ximGeneration) { XDestroyIC(winPtr->inputContext); - winPtr->inputContext = NULL; } + winPtr->inputContext = NULL; #endif /* TK_USE_INPUT_METHODS */ if (winPtr->tagPtr != NULL) { TkFreeBindingTags(winPtr); diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index f3beb16..111d430 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -38,6 +38,8 @@ static void DisplayFileProc(ClientData clientData, int flags); static void DisplaySetupProc(ClientData clientData, int flags); static void TransferXEventsToTcl(Display *display); #ifdef TK_USE_INPUT_METHODS +static void InstantiateIMCallback(Display *, XPointer client_data, XPointer call_data); +static void DestroyIMCallback(XIM im, XPointer client_data, XPointer call_data); static void OpenIM(TkDisplay *dispPtr); #endif @@ -179,6 +181,8 @@ TkpOpenDisplay( dispPtr->flags |= use_xkb; #ifdef TK_USE_INPUT_METHODS OpenIM(dispPtr); + XRegisterIMInstantiateCallback(dispPtr->display, NULL, NULL, NULL, + InstantiateIMCallback, (XPointer) dispPtr); #endif Tcl_CreateFileHandler(ConnectionNumber(display), TCL_READABLE, DisplayFileProc, dispPtr); @@ -664,6 +668,35 @@ TkpSync( } #ifdef TK_USE_INPUT_METHODS +static void +InstantiateIMCallback( + Display *display, + XPointer client_data, + XPointer call_data) +{ + TkDisplay *dispPtr; + + dispPtr = (TkDisplay *) client_data; + OpenIM(dispPtr); + XUnregisterIMInstantiateCallback(dispPtr->display, NULL, NULL, NULL, + InstantiateIMCallback, (XPointer) dispPtr); +} + +static void +DestroyIMCallback( + XIM im, + XPointer client_data, + XPointer call_data) +{ + TkDisplay *dispPtr; + + dispPtr = (TkDisplay *) client_data; + dispPtr->inputMethod = NULL; + ++dispPtr->ximGeneration; + XRegisterIMInstantiateCallback(dispPtr->display, NULL, NULL, NULL, + InstantiateIMCallback, (XPointer) dispPtr); +} + /* *-------------------------------------------------------------- * @@ -693,11 +726,23 @@ OpenIM( return; } + ++dispPtr->ximGeneration; dispPtr->inputMethod = XOpenIM(dispPtr->display, NULL, NULL, NULL); if (dispPtr->inputMethod == NULL) { return; } + /* Require X11R6 */ + { + XIMCallback destroy_cb; + + destroy_cb.callback = DestroyIMCallback; + destroy_cb.client_data = (XPointer) dispPtr; + if (XSetIMValues(dispPtr->inputMethod, XNDestroyCallback, + &destroy_cb, NULL)) + goto error; + } + if ((XGetIMValues(dispPtr->inputMethod, XNQueryInputStyle, &stylePtr, NULL) != NULL) || (stylePtr == NULL)) { goto error; @@ -744,6 +789,7 @@ error: if (dispPtr->inputMethod) { XCloseIM(dispPtr->inputMethod); dispPtr->inputMethod = NULL; + ++dispPtr->ximGeneration; } } #endif /* TK_USE_INPUT_METHODS */ -- cgit v0.12 From bc3690ab244a2bff5ea3ca032bc3cb6047b8d777 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 23 Dec 2016 18:41:00 +0000 Subject: Fix [3df559ef7c] - Negative bbox width on OS X. Tested OK on Windows with TK_LAYOUT_WITH_BASE_CHUNKS being defined. --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 2171cd0..1be26c4 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7819,7 +7819,7 @@ CharChunkMeasureChars( MeasureChars(tkfont, chars, charsLen, 0, bstart, 0, -1, 0, &widthUntilStart); - xDisplacement = startX - widthUntilStart - chunkPtr->x; + xDisplacement = startX - widthUntilStart - ciPtr->baseChunkPtr->x; } fit = MeasureChars(tkfont, chars, charsLen, 0, bend, -- cgit v0.12 From f816c46ea5a7eefb2cd880dedfa9e3b344a988f3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 23 Dec 2016 22:05:42 +0000 Subject: On Windows with TK_LAYOUT_WITH_BASE_CHUNKS and TK_DRAW_IN_CONTEXT being both defined for testing purposes, four tests (textDisp-18.6, 20.2, 20.3 and 20.4) were failing. Fix this. --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1be26c4..4b7b0db 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -8793,7 +8793,7 @@ FinalizeBaseChunk( #if TK_DRAW_IN_CONTEXT newwidth = 0; CharChunkMeasureChars(chunkPtr, NULL, 0, 0, -1, 0, -1, 0, &newwidth); - if (newwidth != chunkPtr->width) { + if (newwidth < chunkPtr->width) { widthAdjust += newwidth - chunkPtr->width; chunkPtr->width = newwidth; } -- cgit v0.12 From 0316d840d0dd2798e1e345dd5a565c3c83ccbae3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 23 Dec 2016 22:16:42 +0000 Subject: On Windows with TK_LAYOUT_WITH_BASE_CHUNKS and TK_DRAW_IN_CONTEXT being both defined for testing purposes, rendering of the text was incorrect because some chunks were superimposed (this was only a display issue, x and width of all chunks were already correct). Fix this. --- generic/tkTextDisp.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4b7b0db..f07650f 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7933,7 +7933,6 @@ CharDisplayProc( #if TK_DRAW_IN_CONTEXT int start = ciPtr->baseOffset + offsetBytes; int len = ciPtr->numBytes - offsetBytes; - int xDisplacement = x - chunkPtr->x; if ((len > 0) && (string[start + len - 1] == '\t')) { len--; @@ -7943,14 +7942,12 @@ CharDisplayProc( } TkpDrawCharsInContext(display, dst, stylePtr->fgGC, sValuePtr->tkfont, - string, numBytes, start, len, - ciPtr->baseChunkPtr->x + xDisplacement, + string, numBytes, start, len, offsetX, y + baseline - sValuePtr->offset); if (sValuePtr->underline) { TkUnderlineCharsInContext(display, dst, stylePtr->ulGC, - sValuePtr->tkfont, string, numBytes, - ciPtr->baseChunkPtr->x + xDisplacement, + sValuePtr->tkfont, string, numBytes, offsetX, y + baseline - sValuePtr->offset, start, start+len); } @@ -7959,8 +7956,7 @@ CharDisplayProc( Tk_GetFontMetrics(sValuePtr->tkfont, &fm); TkUnderlineCharsInContext(display, dst, stylePtr->ovGC, - sValuePtr->tkfont, string, numBytes, - ciPtr->baseChunkPtr->x + xDisplacement, + sValuePtr->tkfont, string, numBytes, offsetX, y + baseline - sValuePtr->offset - fm.descent - (fm.ascent * 3) / 10, start, start+len); -- cgit v0.12 From 531e91677e137dc0d6109374daef5cc802bf7c7d Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 30 Dec 2016 21:11:50 +0000 Subject: Restore correct rendering on OSX that was broken by the previous (platform-independent) commit --- macosx/tkMacOSXFont.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index d3e0e41..78e245a 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -1032,8 +1032,12 @@ TkpDrawCharsInContext( * whole (not just the range) string when * drawing. */ { + int widthUntilStart; + + TkpMeasureCharsInContext(tkfont, source, numBytes, 0, rangeStart, + -1, 0, &widthUntilStart); DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, - rangeStart, rangeLength, x, y, 0.0); + rangeStart, rangeLength, x-widthUntilStart, y, 0.0); } static void -- cgit v0.12 From aec9ede5b3da6947ff19211dab99b56bb5379305 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 30 Dec 2016 22:20:00 +0000 Subject: Do everything the other way round. Leave things how they were on OS X (revert [a076cf64] and [42e0339e]), and fix TkpDrawCharsInContext() on Win and Linux in case these platforms at some point of time decide to define TK_LAYOUT_WITH_BASE_CHUNKS and TK_DRAW_IN_CONTEXT to true --- generic/tkTextDisp.c | 10 +++++++--- macosx/tkMacOSXFont.c | 6 +----- unix/tkUnixFont.c | 5 ++++- win/tkWinFont.c | 6 +++++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f07650f..4b7b0db 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7933,6 +7933,7 @@ CharDisplayProc( #if TK_DRAW_IN_CONTEXT int start = ciPtr->baseOffset + offsetBytes; int len = ciPtr->numBytes - offsetBytes; + int xDisplacement = x - chunkPtr->x; if ((len > 0) && (string[start + len - 1] == '\t')) { len--; @@ -7942,12 +7943,14 @@ CharDisplayProc( } TkpDrawCharsInContext(display, dst, stylePtr->fgGC, sValuePtr->tkfont, - string, numBytes, start, len, offsetX, + string, numBytes, start, len, + ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset); if (sValuePtr->underline) { TkUnderlineCharsInContext(display, dst, stylePtr->ulGC, - sValuePtr->tkfont, string, numBytes, offsetX, + sValuePtr->tkfont, string, numBytes, + ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset, start, start+len); } @@ -7956,7 +7959,8 @@ CharDisplayProc( Tk_GetFontMetrics(sValuePtr->tkfont, &fm); TkUnderlineCharsInContext(display, dst, stylePtr->ovGC, - sValuePtr->tkfont, string, numBytes, offsetX, + sValuePtr->tkfont, string, numBytes, + ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset - fm.descent - (fm.ascent * 3) / 10, start, start+len); diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 78e245a..d3e0e41 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -1032,12 +1032,8 @@ TkpDrawCharsInContext( * whole (not just the range) string when * drawing. */ { - int widthUntilStart; - - TkpMeasureCharsInContext(tkfont, source, numBytes, 0, rangeStart, - -1, 0, &widthUntilStart); DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, - rangeStart, rangeLength, x-widthUntilStart, y, 0.0); + rangeStart, rangeLength, x, y, 0.0); } static void diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 4a466f1..0c663a3 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -1414,10 +1414,13 @@ TkpDrawCharsInContext( * whole (not just the range) string when * drawing. */ { + int widthUntilStart; + (void) numBytes; /*unused*/ + Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart, - rangeLength, x, y); + rangeLength, x+widthUntilStart, y); } /* diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 47c4c3c..860451b 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -1407,9 +1407,13 @@ TkpDrawCharsInContext( * whole (not just the range) string when * drawing. */ { + int widthUntilStart; + (void) numBytes; /*unused*/ + + Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart, - rangeLength, x, y); + rangeLength, x+widthUntilStart, y); } /* -- cgit v0.12 From f85e7916a82767bfc0f9fdffbc13edb698456c06 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 1 Jan 2017 20:56:48 +0000 Subject: Fix [28a4535fa2]: Off-by-1 error on text widget index on OS X --- macosx/tkMacOSXFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index d3e0e41..db36731 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -870,7 +870,7 @@ TkpMeasureCharsInContext( if (index <= start && !(flags & TK_WHOLE_WORDS)) { index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth); } - cs = (index < len || (flags & TK_WHOLE_WORDS)) ? + cs = (index < len && (flags & TK_WHOLE_WORDS)) ? whitespaceCharacterSet : lineendingCharacterSet; while (index > start && [cs characterIsMember:[string characterAtIndex:(index - 1)]]) { -- cgit v0.12 From daf2eae38a06d6471872c5ff1987af418eddbfaf Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 2 Jan 2017 13:19:02 +0000 Subject: 'Fixed' font-24.11 and unixfont-5.12 to fail again identically as they fail in core-8-6-branch. --- macosx/tkMacOSXFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index db36731..b5ae1a3 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -870,7 +870,7 @@ TkpMeasureCharsInContext( if (index <= start && !(flags & TK_WHOLE_WORDS)) { index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth); } - cs = (index < len && (flags & TK_WHOLE_WORDS)) ? + cs = (index <= len && (flags & TK_WHOLE_WORDS)) ? whitespaceCharacterSet : lineendingCharacterSet; while (index > start && [cs characterIsMember:[string characterAtIndex:(index - 1)]]) { -- cgit v0.12 From d72792591c268e1d4022885dcc8b0afeef200670 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 3 Jan 2017 13:05:16 +0000 Subject: Fix [f325020623898d6afe8bb73276459a922003c077|f325020623]: Tk crashes when drawing many dashed objects --- generic/tkCanvUtil.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index b4d0c3b..08aeab7 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -1134,7 +1134,9 @@ Tk_ConfigOutlineGC( if (mask && (dash->number != 0)) { gcValues->line_style = LineOnOffDash; gcValues->dash_offset = outline->offset; - if (dash->number > 0) { + if ((unsigned int)ABS(dash->number) > sizeof(char *)) { + gcValues->dashes = dash->pattern.pt[0]; + } else if (dash->number != 0) { gcValues->dashes = dash->pattern.array[0]; } else { gcValues->dashes = (char) (4 * width + 0.5); @@ -1338,7 +1340,9 @@ Tk_ResetOutlineGC( if ((dash->number > 2) || (dash->number < -1) || (dash->number==2 && (dash->pattern.array[0] != dash->pattern.array[1])) || ((dash->number == -1) && (dash->pattern.array[0] != ','))) { - if (dash->number > 0) { + if ((unsigned int)ABS(dash->number) > sizeof(char *)) { + dashList = dash->pattern.pt[0]; + } else if (dash->number != 0) { dashList = dash->pattern.array[0]; } else { dashList = (char) (4 * width + 0.5); -- cgit v0.12 From 99eada08acd17c833f14efa355e5f6383941f889 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 4 Jan 2017 16:27:45 +0000 Subject: Added more glob patterns in order to ignore Windows-specific compilation products when running fossil extra --- .fossil-settings/ignore-glob | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index e404f52..e8f5bbb 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -6,6 +6,7 @@ *.lib *.o *.obj +*.pdb *.res *.sl *.so @@ -18,4 +19,6 @@ */tktest* */versions.vc doc/man.macros +win/Debug_VC* +win/Release_VC* unix/tk.pc -- cgit v0.12 From 81fe5464621b13b397c1a16a7d9fbe260a669e2e Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 5 Jan 2017 07:47:26 +0000 Subject: Fix [dac92f194c]: OS X - text-2.8 and text-2.9 are both run and fail --- tests/text.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/text.test b/tests/text.test index 3e5b4b6..8ba177f 100644 --- a/tests/text.test +++ b/tests/text.test @@ -922,9 +922,9 @@ test text-2.8 {Tk_TextCmd procedure} -constraints { .t tag cget sel -relief } -cleanup { destroy .t -} -result {solid} +} -result {flat} test text-2.9 {Tk_TextCmd procedure} -constraints { - unix + unix notAqua } -body { catch {destroy .t} text .t -- cgit v0.12 From 3ae3e292d3d381885989cdaa6d121a7ae8d658a9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 5 Jan 2017 23:19:41 +0000 Subject: Fix [c12af74765]: OS X - text-21.1 fails --- tests/text.test | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/text.test b/tests/text.test index 8ba177f..9d9b836 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3925,7 +3925,7 @@ test text-20.5 {TextFetchSelection procedure, long selections} -setup { } -result {1} -test text-21.1 {TkTextLostSelection procedure} -constraints unix -setup { +test text-21.1 {TkTextLostSelection procedure} -constraints {unix notAqua} -setup { text .t .t insert 1.0 "Line 1" entry .t.e @@ -3940,6 +3940,21 @@ test text-21.1 {TkTextLostSelection procedure} -constraints unix -setup { } -cleanup { destroy .t .t2 } -result {} +test text-21.1a {TkTextLostSelection procedure} -constraints {unix aqua} -setup { + text .t + .t insert 1.0 "Line 1" + entry .t.e + .t.e insert end "abcdefg" + text .t2 + .t2 insert 1.0 "abc\ndef\nghijk\n1234" +} -body { + .t2 tag add sel 1.2 3.3 + .t.e select from 0 + .t.e select to 1 + .t2 tag ranges sel +} -cleanup { + destroy .t .t2 +} -result {1.2 3.3} test text-21.2 {TkTextLostSelection procedure} -constraints win -setup { text .t .t insert 1.0 "Line 1" -- cgit v0.12 From c20a3010587a7f5b2488d01ec10021f70eb92a8b Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 6 Jan 2017 14:14:21 +0000 Subject: Better fix for [c12af74765]: OS X - text-21.1 fails --- tests/constraints.tcl | 4 ++++ tests/text.test | 19 ++----------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/tests/constraints.tcl b/tests/constraints.tcl index e0486ff..a87499d 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -180,7 +180,11 @@ namespace import -force tk::test::* namespace import -force tcltest::testConstraint testConstraint notAqua [expr {[tk windowingsystem] ne "aqua"}] testConstraint aqua [expr {[tk windowingsystem] eq "aqua"}] +testConstraint x11 [expr {[tk windowingsystem] eq "x11"}] testConstraint nonwin [expr {[tk windowingsystem] ne "win32"}] +testConstraint aquaOrWin32 [expr { + ([tk windowingsystem] eq "win32") || [testConstraint aqua] +}] testConstraint userInteraction 0 testConstraint nonUnixUserInteraction [expr { [testConstraint userInteraction] || diff --git a/tests/text.test b/tests/text.test index 9d9b836..6812855 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3925,7 +3925,7 @@ test text-20.5 {TextFetchSelection procedure, long selections} -setup { } -result {1} -test text-21.1 {TkTextLostSelection procedure} -constraints {unix notAqua} -setup { +test text-21.1 {TkTextLostSelection procedure} -constraints {x11} -setup { text .t .t insert 1.0 "Line 1" entry .t.e @@ -3940,22 +3940,7 @@ test text-21.1 {TkTextLostSelection procedure} -constraints {unix notAqua} -setu } -cleanup { destroy .t .t2 } -result {} -test text-21.1a {TkTextLostSelection procedure} -constraints {unix aqua} -setup { - text .t - .t insert 1.0 "Line 1" - entry .t.e - .t.e insert end "abcdefg" - text .t2 - .t2 insert 1.0 "abc\ndef\nghijk\n1234" -} -body { - .t2 tag add sel 1.2 3.3 - .t.e select from 0 - .t.e select to 1 - .t2 tag ranges sel -} -cleanup { - destroy .t .t2 -} -result {1.2 3.3} -test text-21.2 {TkTextLostSelection procedure} -constraints win -setup { +test text-21.2 {TkTextLostSelection procedure} -constraints aquaOrWin32 -setup { text .t .t insert 1.0 "Line 1" entry .t.e -- cgit v0.12 From ee8455b769a597dc5d87f89478032b49cf49cdba Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 7 Jan 2017 14:45:40 +0000 Subject: Reverted [7ed6460f] since it fixes an issue unrelated to the bug presented in [3df559ef7c] - Negative bbox width on OS X. --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4b7b0db..1be26c4 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -8793,7 +8793,7 @@ FinalizeBaseChunk( #if TK_DRAW_IN_CONTEXT newwidth = 0; CharChunkMeasureChars(chunkPtr, NULL, 0, 0, -1, 0, -1, 0, &newwidth); - if (newwidth < chunkPtr->width) { + if (newwidth != chunkPtr->width) { widthAdjust += newwidth - chunkPtr->width; chunkPtr->width = newwidth; } -- cgit v0.12 From 07c65ee9c99b263ed8b6aefb42c7c5f6e47a441e Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 7 Jan 2017 14:51:58 +0000 Subject: Fix [ae32eb7e10]: Win + specific text widget configuration : textDisp-18.6, -20.2 -20.3 -20.4 fail --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 2171cd0..c060687 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -8793,7 +8793,7 @@ FinalizeBaseChunk( #if TK_DRAW_IN_CONTEXT newwidth = 0; CharChunkMeasureChars(chunkPtr, NULL, 0, 0, -1, 0, -1, 0, &newwidth); - if (newwidth != chunkPtr->width) { + if (newwidth < chunkPtr->width) { widthAdjust += newwidth - chunkPtr->width; chunkPtr->width = newwidth; } -- cgit v0.12 From 8313aaf2d2c39dd94d04766a10a0207c682790e2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 7 Jan 2017 15:49:04 +0000 Subject: Patch from chw for [7a838c38a1]: X11 bind event ring buffer and GraphicsExpose/NoExpose --- generic/tkBind.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/generic/tkBind.c b/generic/tkBind.c index d3fdc96..525e13e 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -1260,6 +1260,16 @@ Tk_BindEvent( } } + /* + * Ignore event types which are not in flagArray. Most notably, + * NoExpose events can fill the ring buffer and disturb (thus + * masking out) event sequences of interest. + */ + + if ((eventPtr->type >= TK_LASTEVENT) || !flagArray[eventPtr->type]) { + return; + } + dispPtr = ((TkWindow *) tkwin)->dispPtr; bindInfoPtr = winPtr->mainPtr->bindInfo; -- cgit v0.12 From 16a463a4eb33a7d69b47b2b4ae6203876db04b09 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 9 Jan 2017 13:42:46 +0000 Subject: Better comment explaining why some events are ignored. --- generic/tkBind.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 525e13e..567c51f 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -1261,9 +1261,9 @@ Tk_BindEvent( } /* - * Ignore event types which are not in flagArray. Most notably, - * NoExpose events can fill the ring buffer and disturb (thus - * masking out) event sequences of interest. + * Ignore event types which are not in flagArray and all zeroes there. + * Most notably, NoExpose events can fill the ring buffer and disturb + * (thus masking out) event sequences of interest. */ if ((eventPtr->type >= TK_LASTEVENT) || !flagArray[eventPtr->type]) { -- cgit v0.12 From 5947e3261525f012e16d814aca14fa42a498a5ce Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 10 Jan 2017 16:02:10 +0000 Subject: More internal use of size_t. Add test-case imgPhoto-4.74, which shows error-handling when there are two values on the command line not connected to options. --- generic/tkImgPhoto.c | 44 ++++++++++++++++++++++++++------------------ tests/imgPhoto.test | 7 +++++++ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 3e03f3d..4ee9f69 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -409,7 +409,8 @@ ImgPhotoCmd( Tk_PhotoImageBlock block; Tk_Window tkwin; Tk_PhotoImageFormat *imageFormat; - int imageWidth, imageHeight, matched, length, oldformat = 0; + size_t length; + int imageWidth, imageHeight, matched, oldformat = 0; Tcl_Channel chan; Tk_PhotoHandle srcHandle; ThreadSpecificData *tsdPtr = @@ -446,12 +447,13 @@ ImgPhotoCmd( Tcl_WrongNumArgs(interp, 2, objv, "option"); return TCL_ERROR; } - arg = Tcl_GetStringFromObj(objv[2], &length); - if (strncmp(arg,"-data", (unsigned) length) == 0) { + arg = Tcl_GetString(objv[2]); + length = objv[2]->length; + if (strncmp(arg,"-data", length) == 0) { if (masterPtr->dataString) { Tcl_SetObjResult(interp, masterPtr->dataString); } - } else if (strncmp(arg,"-format", (unsigned) length) == 0) { + } else if (strncmp(arg,"-format", length) == 0) { if (masterPtr->format) { Tcl_SetObjResult(interp, masterPtr->format); } @@ -495,9 +497,10 @@ ImgPhotoCmd( return TCL_OK; } else if (objc == 3) { - const char *arg = Tcl_GetStringFromObj(objv[2], &length); + const char *arg = Tcl_GetString(objv[2]); - if (length > 1 && !strncmp(arg, "-data", (unsigned) length)) { + length = objv[2]->length; + if (length > 1 && !strncmp(arg, "-data", length)) { Tcl_AppendResult(interp, "-data {} {} {}", NULL); if (masterPtr->dataString) { /* @@ -511,7 +514,7 @@ ImgPhotoCmd( } return TCL_OK; } else if (length > 1 && - !strncmp(arg, "-format", (unsigned) length)) { + !strncmp(arg, "-format", length)) { Tcl_AppendResult(interp, "-format {} {} {}", NULL); if (masterPtr->format) { /* @@ -1489,7 +1492,8 @@ ParseSubcommandOptions( * TK_PHOTO_COMPOSITE_* constants. */ NULL }; - int index, c, bit, currentBit, length; + size_t length; + int index, c, bit, currentBit; int values[4], numValues, maxValues, argIndex; const char *option, *expandedOption, *needed; const char *const *listPtr; @@ -1501,7 +1505,8 @@ ParseSubcommandOptions( * optPtr->name. */ - expandedOption = option = Tcl_GetStringFromObj(objv[index], &length); + expandedOption = option = Tcl_GetString(objv[index]); + length = objv[index]->length; if (option[0] != '-') { if (optPtr->name == NULL) { optPtr->name = objv[index]; @@ -1519,7 +1524,7 @@ ParseSubcommandOptions( currentBit = 1; for (listPtr = optionNames; *listPtr != NULL; ++listPtr) { if ((c == *listPtr[0]) - && (strncmp(option, *listPtr, (size_t) length) == 0)) { + && (strncmp(option, *listPtr, length) == 0)) { expandedOption = *listPtr; if (bit != 0) { goto unknownOrAmbiguousOption; @@ -1765,7 +1770,8 @@ ImgPhotoConfigureMaster( const char *oldFileString, *oldPaletteString; Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL; Tcl_Obj *tempdata, *tempformat; - int length, i, j, result, imageWidth, imageHeight, oldformat; + size_t length; + int i, j, result, imageWidth, imageHeight, oldformat; double oldGamma; Tcl_Channel chan; Tk_PhotoImageFormat *imageFormat; @@ -1773,10 +1779,11 @@ ImgPhotoConfigureMaster( args = ckalloc((objc + 1) * sizeof(char *)); for (i = 0, j = 0; i < objc; i++,j++) { - args[j] = Tcl_GetStringFromObj(objv[i], &length); + args[j] = Tcl_GetString(objv[i]); + length = objv[i]->length; if ((length > 1) && (args[j][0] == '-')) { if ((args[j][1] == 'd') && - !strncmp(args[j], "-data", (size_t) length)) { + !strncmp(args[j], "-data", length)) { if (++i < objc) { data = objv[i]; j--; @@ -1789,7 +1796,7 @@ ImgPhotoConfigureMaster( return TCL_ERROR; } } else if ((args[j][1] == 'f') && - !strncmp(args[j], "-format", (size_t) length)) { + !strncmp(args[j], "-format", length)) { if (++i < objc) { format = objv[i]; j--; @@ -1852,9 +1859,10 @@ ImgPhotoConfigureMaster( * Force into ByteArray format, which most (all) image handlers will * use anyway. Empty length means ignore the -data option. */ + int bytesize; - (void) Tcl_GetByteArrayFromObj(data, &length); - if (length) { + (void) Tcl_GetByteArrayFromObj(data, &bytesize); + if (bytesize) { Tcl_IncrRefCount(data); } else { data = NULL; @@ -1870,8 +1878,8 @@ ImgPhotoConfigureMaster( * object. */ - (void) Tcl_GetStringFromObj(format, &length); - if (length) { + (void) Tcl_GetString(format); + if (format->length) { Tcl_IncrRefCount(format); } else { format = NULL; diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index e85f512..db23fea 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -797,6 +797,13 @@ test imgPhoto-4.73 {ImgPhotoCmd procedure: copy with -compositingrule} -setup { } -cleanup { image delete photo1 photo2 } -result {0,2 1,1 2,0} +test imgPhoto-4.74 {ImgPhotoCmd procedure: put option error handling} -setup { + image create photo photo1 +} -body { + photo1 put {{white}} -to 10 10 20 20 {{white}} +} -cleanup { + image delete photo1 +} -returnCodes 1 -result {wrong # args: should be "photo1 put data ?-option value ...?"} test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} -constraints { hasTeapotPhoto -- cgit v0.12 From 225f01858954fb5bc8b0f1304167d52e7249d22d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 11 Jan 2017 10:51:15 +0000 Subject: Alternative proposed solution for [d4fb4e80d220e46e588f310291fd7a4205e8cd67|d4fb4e80d2], with test-case. --- generic/tkImgPhoto.c | 6 +++++- tests/imgPhoto.test | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 4ee9f69..1bd0142 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -1540,7 +1540,11 @@ ParseSubcommandOptions( */ if (!(allowedOptions & bit)) { - goto unknownOrAmbiguousOption; + if (optPtr->name != NULL) { + goto unknownOrAmbiguousOption; + } + optPtr->name = objv[index]; + continue; } /* diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index db23fea..e93dab4 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -804,6 +804,16 @@ test imgPhoto-4.74 {ImgPhotoCmd procedure: put option error handling} -setup { } -cleanup { image delete photo1 } -returnCodes 1 -result {wrong # args: should be "photo1 put data ?-option value ...?"} +test imgPhoto-4.75 { read command: filename starting with '-'} -constraints { + hasTeapotPhoto +} -body { + file copy -force $teapotPhotoFile -teapotPhotoFile + image create photo photo1 + photo1 read -teapotPhotoFile +} -cleanup { + image delete photo1 + file delete ./-teapotPhotoFile +} -result {} test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} -constraints { hasTeapotPhoto -- cgit v0.12 From 6a0d791579f271fd69868f377393a2e02ab5e82d Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 14 Jan 2017 14:32:30 +0000 Subject: Partially fix [fab5fed65e]: OS X - lots of textDisp failures (spurious 'borders' and indices in tk_textRedraw). This commit fixes the spurious indices part of the bug report. --- macosx/tkMacOSXDraw.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 474ed41..09a6b4e 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1527,12 +1527,6 @@ TkScrollWindow( srcRect = CGRectMake(x, y, width, height); dstRect = CGRectOffset(srcRect, dx, dy); - /* Expand the rectangles slightly to avoid degeneracies. */ - srcRect.origin.y -= 1; - srcRect.size.height += 2; - dstRect.origin.y += 1; - dstRect.size.height -= 2; - /* Compute the damage. */ dmgRgn = HIShapeCreateMutableWithRect(&srcRect); extraRgn = HIShapeCreateWithRect(&dstRect); -- cgit v0.12 From 32a7d700a16f886e7d863c0189979b4c89837001 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 15 Jan 2017 22:01:02 +0000 Subject: Partially fix [fab5fed65e]: OS X - lots of textDisp failures (spurious 'borders' and indices in tk_textRedraw). This commit fixes the 'borders' part of the bug report. --- macosx/tkMacOSXWindowEvent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index a669a8a..4672586 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -357,8 +357,8 @@ GenerateUpdates( event.xany.window = Tk_WindowId(winPtr); event.xany.display = Tk_Display(winPtr); event.type = Expose; - event.xexpose.x = damageBounds.origin.x - bounds.origin.x; - event.xexpose.y = damageBounds.origin.y - bounds.origin.y; + event.xexpose.x = damageBounds.origin.x; + event.xexpose.y = damageBounds.origin.y; event.xexpose.width = damageBounds.size.width; event.xexpose.height = damageBounds.size.height; event.xexpose.count = 0; -- cgit v0.12 From 886747e926ca6149ad730cbd07c59aa716f46435 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 15 Jan 2017 22:29:53 +0000 Subject: Remove obsolete comments. The line they comment was kicked out of the code in [946e946700]. Also, add a small optimization to avoid double invalidation of the damaged region. Indeed the detailed analysis of ticket [fab5fed65e] showed that on OS X the damaged region is invalidated twice: - once through the processing of the Expose event (on OS X the Appkit is not used to draw the widget, Tk is used instead, see comments in tkMacOSXWindowEvent.c around line 770) - a second time because DisplayText() calls TextInvalidateRegion() after TkScrollWindow() --- generic/tkTextDisp.c | 3 ++- macosx/tkMacOSXDraw.c | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1be26c4..c271b4b 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4299,8 +4299,9 @@ DisplayText( if (TkScrollWindow(textPtr->tkwin, dInfoPtr->scrollGC, dInfoPtr->x, oldY, dInfoPtr->maxX-dInfoPtr->x, height, 0, y-oldY, damageRgn)) { +#ifndef MAC_OSX_TK TextInvalidateRegion(textPtr, damageRgn); - +#endif } numCopies++; TkDestroyRegion(damageRgn); diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 09a6b4e..5ca8bfe 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1565,9 +1565,6 @@ TkScrollWindow( int oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); [view generateExposeEvents:dmgRgn childrenOnly:1]; Tcl_SetServiceMode(oldMode); - - /* Belt and suspenders: make the AppKit request a redraw - when it gets control again. */ } } else { dmgRgn = HIShapeCreateEmpty(); -- cgit v0.12 From 2e7b097afc15bc6b6fad5e18b7bd69d961e9b349 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 17 Jan 2017 12:39:57 +0000 Subject: tag Tk_FreeXId() as deprecated. Remove the function from the build if TK_NO_DEPRECATED is defined. --- generic/tk.decls | 2 +- generic/tk.h | 4 +- generic/tkDecls.h | 8 +- generic/tkStubInit.c | 5 + generic/ttk/ttkGenStubs.tcl | 963 -------------------------------------------- unix/Makefile.in | 2 +- win/Makefile.in | 2 +- 7 files changed, 18 insertions(+), 968 deletions(-) delete mode 100644 generic/ttk/ttkGenStubs.tcl diff --git a/generic/tk.decls b/generic/tk.decls index 9ceb3af..eaaa063 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -326,7 +326,7 @@ declare 75 { declare 76 { void Tk_FreeTextLayout(Tk_TextLayout textLayout) } -declare 77 { +declare 77 deprecated { void Tk_FreeXId(Display *display, XID xid) } declare 78 { diff --git a/generic/tk.h b/generic/tk.h index 9403f31..658b11e 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -414,7 +414,9 @@ typedef enum { #define TK_CONFIG_COLOR_ONLY (1 << 1) #define TK_CONFIG_MONO_ONLY (1 << 2) #define TK_CONFIG_DONT_SET_DEFAULT (1 << 3) -#define TK_CONFIG_OPTION_SPECIFIED (1 << 4) +#if !defined(TK_NO_DEPRECATED) || defined(BUILD_tk) +# define TK_CONFIG_OPTION_SPECIFIED (1 << 4) +#endif #define TK_CONFIG_USER_BIT 0x100 #endif /* __NO_OLD_CONFIG */ diff --git a/generic/tkDecls.h b/generic/tkDecls.h index eaaaf6c..3b72706 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -17,6 +17,12 @@ #define TCL_STORAGE_CLASS DLLEXPORT #endif +#if defined(TK_NO_DEPRECATED) && defined(BUILD_tk) +# define TK_DEPRECATED MODULE_SCOPE +#else +# define TK_DEPRECATED EXTERN +#endif + /* * WARNING: This file is automatically generated by the tools/genStubs.tcl * script. Any modifications to the function declarations below should be made @@ -281,7 +287,7 @@ EXTERN void Tk_FreePixmap(Display *display, Pixmap pixmap); /* 76 */ EXTERN void Tk_FreeTextLayout(Tk_TextLayout textLayout); /* 77 */ -EXTERN void Tk_FreeXId(Display *display, XID xid); +TK_DEPRECATED void Tk_FreeXId(Display *display, XID xid); /* 78 */ EXTERN GC Tk_GCForColor(XColor *colorPtr, Drawable drawable); /* 79 */ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index ffe7b75..7f5b3be 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -40,6 +40,10 @@ MODULE_SCOPE const TkStubs tkStubs; #undef Tk_MainEx #undef Tk_FreeXId + +#ifdef TK_NO_DEPRECATED +#define Tk_FreeXId 0 +#else static void doNothing(void) { @@ -47,6 +51,7 @@ doNothing(void) } #define Tk_FreeXId ((void (*)(Display *, XID)) doNothing) +#endif #ifdef _WIN32 diff --git a/generic/ttk/ttkGenStubs.tcl b/generic/ttk/ttkGenStubs.tcl deleted file mode 100644 index 8047e3f..0000000 --- a/generic/ttk/ttkGenStubs.tcl +++ /dev/null @@ -1,963 +0,0 @@ -# ttkGenStubs.tcl -- -# -# This script generates a set of stub files for a given -# interface. -# -# -# Copyright (c) 1998-1999 by Scriptics Corporation. -# Copyright (c) 2007 Daniel A. Steffen -# -# See the file "license.terms" for information on usage and redistribution -# of this file, and for a DISCLAIMER OF ALL WARRANTIES. -# -# SOURCE: tcl/tools/genStubs.tcl, revision 1.44 -# -# CHANGES: -# + Second argument to "declare" is used as a status guard -# instead of a platform guard. -# + Allow trailing semicolon in function declarations -# - -namespace eval genStubs { - # libraryName -- - # - # The name of the entire library. This value is used to compute - # the USE_*_STUBS macro and the name of the init file. - - variable libraryName "UNKNOWN" - - # interfaces -- - # - # An array indexed by interface name that is used to maintain - # the set of valid interfaces. The value is empty. - - array set interfaces {} - - # curName -- - # - # The name of the interface currently being defined. - - variable curName "UNKNOWN" - - # scspec -- - # - # Storage class specifier for external function declarations. - # Normally "EXTERN", may be set to something like XYZAPI - # - variable scspec "EXTERN" - - # epoch, revision -- - # - # The epoch and revision numbers of the interface currently being defined. - # (@@@TODO: should be an array mapping interface names -> numbers) - # - - variable epoch {} - variable revision 0 - - # hooks -- - # - # An array indexed by interface name that contains the set of - # subinterfaces that should be defined for a given interface. - - array set hooks {} - - # stubs -- - # - # This three dimensional array is indexed first by interface name, - # second by field name, and third by a numeric offset or the - # constant "lastNum". The lastNum entry contains the largest - # numeric offset used for a given interface. - # - # Field "decl,$i" contains the C function specification that - # should be used for the given entry in the stub table. The spec - # consists of a list in the form returned by parseDecl. - # Other fields TBD later. - - array set stubs {} - - # outDir -- - # - # The directory where the generated files should be placed. - - variable outDir . -} - -# genStubs::library -- -# -# This function is used in the declarations file to set the name -# of the library that the interfaces are associated with (e.g. "tcl"). -# This value will be used to define the inline conditional macro. -# -# Arguments: -# name The library name. -# -# Results: -# None. - -proc genStubs::library {name} { - variable libraryName $name -} - -# genStubs::interface -- -# -# This function is used in the declarations file to set the name -# of the interface currently being defined. -# -# Arguments: -# name The name of the interface. -# -# Results: -# None. - -proc genStubs::interface {name} { - variable curName $name - variable interfaces - variable stubs - - set interfaces($name) {} - set stubs($name,lastNum) 0 - return -} - -# genStubs::scspec -- -# -# Define the storage class macro used for external function declarations. -# Typically, this will be a macro like XYZAPI or EXTERN that -# expands to either DLLIMPORT or DLLEXPORT, depending on whether -# -DBUILD_XYZ has been set. -# -proc genStubs::scspec {value} { - variable scspec $value -} - -# genStubs::epoch -- -# -# Define the epoch number for this library. The epoch -# should be incrememented when a release is made that -# contains incompatible changes to the public API. -# -proc genStubs::epoch {value} { - variable epoch $value -} - -# genStubs::hooks -- -# -# This function defines the subinterface hooks for the current -# interface. -# -# Arguments: -# names The ordered list of interfaces that are reachable through the -# hook vector. -# -# Results: -# None. - -proc genStubs::hooks {names} { - variable curName - variable hooks - - set hooks($curName) $names - return -} - -# genStubs::declare -- -# -# This function is used in the declarations file to declare a new -# interface entry. -# -# Arguments: -# index The index number of the interface. -# status Status of the interface: one of "current", -# "deprecated", or "obsolete". -# decl The C function declaration, or {} for an undefined -# entry. -# -# Results: -# None. - -proc genStubs::declare {args} { - variable stubs - variable curName - variable revision - - incr revision - if {[llength $args] == 2} { - lassign $args index decl - set status current - } elseif {[llength $args] == 3} { - lassign $args index status decl - } else { - puts stderr "wrong # args: declare $args" - return - } - - # Check for duplicate declarations, then add the declaration and - # bump the lastNum counter if necessary. - - if {[info exists stubs($curName,decl,$index)]} { - puts stderr "Duplicate entry: $index" - } - regsub -all "\[ \t\n\]+" [string trim $decl] " " decl - set decl [parseDecl $decl] - - set stubs($curName,status,$index) $status - set stubs($curName,decl,$index) $decl - - if {$index > $stubs($curName,lastNum)} { - set stubs($curName,lastNum) $index - } - return -} - -# genStubs::export -- -# -# This function is used in the declarations file to declare a symbol -# that is exported from the library but is not in the stubs table. -# -# Arguments: -# decl The C function declaration, or {} for an undefined -# entry. -# -# Results: -# None. - -proc genStubs::export {args} { - if {[llength $args] != 1} { - puts stderr "wrong # args: export $args" - } - return -} - -# genStubs::rewriteFile -- -# -# This function replaces the machine generated portion of the -# specified file with new contents. It looks for the !BEGIN! and -# !END! comments to determine where to place the new text. -# -# Arguments: -# file The name of the file to modify. -# text The new text to place in the file. -# -# Results: -# None. - -proc genStubs::rewriteFile {file text} { - if {![file exists $file]} { - puts stderr "Cannot find file: $file" - return - } - set in [open ${file} r] - set out [open ${file}.new w] - fconfigure $out -translation lf - - while {![eof $in]} { - set line [gets $in] - if {[string match "*!BEGIN!*" $line]} { - break - } - puts $out $line - } - puts $out "/* !BEGIN!: Do not edit below this line. */" - puts $out $text - while {![eof $in]} { - set line [gets $in] - if {[string match "*!END!*" $line]} { - break - } - } - puts $out "/* !END!: Do not edit above this line. */" - puts -nonewline $out [read $in] - close $in - close $out - file rename -force ${file}.new ${file} - return -} - -# genStubs::addPlatformGuard -- -# -# Wrap a string inside a platform #ifdef. -# -# Arguments: -# plat Platform to test. -# -# Results: -# Returns the original text inside an appropriate #ifdef. - -proc genStubs::addPlatformGuard {plat iftxt {eltxt {}}} { - set text "" - switch $plat { - win { - append text "#ifdef _WIN32 /* WIN */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* WIN */\n${eltxt}" - } - append text "#endif /* WIN */\n" - } - unix { - append text "#if !defined(_WIN32) && !defined(MAC_OSX_TCL)\ - /* UNIX */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* UNIX */\n${eltxt}" - } - append text "#endif /* UNIX */\n" - } - macosx { - append text "#ifdef MAC_OSX_TCL /* MACOSX */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* MACOSX */\n${eltxt}" - } - append text "#endif /* MACOSX */\n" - } - aqua { - append text "#ifdef MAC_OSX_TK /* AQUA */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* AQUA */\n${eltxt}" - } - append text "#endif /* AQUA */\n" - } - x11 { - append text "#if !(defined(_WIN32) || defined(MAC_OSX_TK))\ - /* X11 */\n${iftxt}" - if {$eltxt ne ""} { - append text "#else /* X11 */\n${eltxt}" - } - append text "#endif /* X11 */\n" - } - default { - append text "${iftxt}${eltxt}" - } - } - return $text -} - -# genStubs::emitSlots -- -# -# Generate the stub table slots for the given interface. If there -# are no generic slots, then one table is generated for each -# platform, otherwise one table is generated for all platforms. -# -# Arguments: -# name The name of the interface being emitted. -# textVar The variable to use for output. -# -# Results: -# None. - -proc genStubs::emitSlots {name textVar} { - upvar $textVar text - - forAllStubs $name makeSlot noGuard text {" void (*reserved$i)(void);\n"} - return -} - -# genStubs::parseDecl -- -# -# Parse a C function declaration into its component parts. -# -# Arguments: -# decl The function declaration. -# -# Results: -# Returns a list of the form {returnType name args}. The args -# element consists of a list of type/name pairs, or a single -# element "void". If the function declaration is malformed -# then an error is displayed and the return value is {}. - -proc genStubs::parseDecl {decl} { - if {![regexp {^(.*)\((.*)\);?$} $decl all prefix args]} { - set prefix $decl - set args {} - } - set prefix [string trim $prefix] - if {![regexp {^(.+[ ][*]*)([^ *]+)$} $prefix all rtype fname]} { - puts stderr "Bad return type: $decl" - return - } - set rtype [string trim $rtype] - if {$args eq ""} { - return [list $rtype $fname {}] - } - foreach arg [split $args ,] { - lappend argList [string trim $arg] - } - if {![string compare [lindex $argList end] "..."]} { - set args TCL_VARARGS - foreach arg [lrange $argList 0 end-1] { - set argInfo [parseArg $arg] - if {[llength $argInfo] == 2 || [llength $argInfo] == 3} { - lappend args $argInfo - } else { - puts stderr "Bad argument: '$arg' in '$decl'" - return - } - } - } else { - set args {} - foreach arg $argList { - set argInfo [parseArg $arg] - if {![string compare $argInfo "void"]} { - lappend args "void" - break - } elseif {[llength $argInfo] == 2 || [llength $argInfo] == 3} { - lappend args $argInfo - } else { - puts stderr "Bad argument: '$arg' in '$decl'" - return - } - } - } - return [list $rtype $fname $args] -} - -# genStubs::parseArg -- -# -# This function parses a function argument into a type and name. -# -# Arguments: -# arg The argument to parse. -# -# Results: -# Returns a list of type and name with an optional third array -# indicator. If the argument is malformed, returns "". - -proc genStubs::parseArg {arg} { - if {![regexp {^(.+[ ][*]*)([^][ *]+)(\[\])?$} $arg all type name array]} { - if {$arg eq "void"} { - return $arg - } else { - return - } - } - set result [list [string trim $type] $name] - if {$array ne ""} { - lappend result $array - } - return $result -} - -# genStubs::makeDecl -- -# -# Generate the prototype for a function. -# -# Arguments: -# name The interface name. -# decl The function declaration. -# index The slot index for this function. -# -# Results: -# Returns the formatted declaration string. - -proc genStubs::makeDecl {name decl index} { - variable scspec - lassign $decl rtype fname args - - append text "/* $index */\n" - set line "$scspec $rtype" - set count [expr {2 - ([string length $line] / 8)}] - append line [string range "\t\t\t" 0 $count] - set pad [expr {24 - [string length $line]}] - if {$pad <= 0} { - append line " " - set pad 0 - } - if {$args eq ""} { - append line $fname - append text $line - append text ";\n" - return $text - } - append line $fname - - set arg1 [lindex $args 0] - switch -exact $arg1 { - void { - append line "(void)" - } - TCL_VARARGS { - set sep "(" - foreach arg [lrange $args 1 end] { - append line $sep - set next {} - append next [lindex $arg 0] - if {[string index $next end] ne "*"} { - append next " " - } - append next [lindex $arg 1] [lindex $arg 2] - if {[string length $line] + [string length $next] \ - + $pad > 76} { - append text [string trimright $line] \n - set line "\t\t\t\t" - set pad 28 - } - append line $next - set sep ", " - } - append line ", ...)" - } - default { - set sep "(" - foreach arg $args { - append line $sep - set next {} - append next [lindex $arg 0] - if {[string index $next end] ne "*"} { - append next " " - } - append next [lindex $arg 1] [lindex $arg 2] - if {[string length $line] + [string length $next] \ - + $pad > 76} { - append text [string trimright $line] \n - set line "\t\t\t\t" - set pad 28 - } - append line $next - set sep ", " - } - append line ")" - } - } - return "$text$line;\n" -} - -# genStubs::makeMacro -- -# -# Generate the inline macro for a function. -# -# Arguments: -# name The interface name. -# decl The function declaration. -# index The slot index for this function. -# -# Results: -# Returns the formatted macro definition. - -proc genStubs::makeMacro {name decl index} { - lassign $decl rtype fname args - - set lfname [string tolower [string index $fname 0]] - append lfname [string range $fname 1 end] - - set text "#define $fname \\\n\t(" - if {$args eq ""} { - append text "*" - } - append text "${name}StubsPtr->$lfname)" - append text " /* $index */\n" - return $text -} - -# genStubs::makeSlot -- -# -# Generate the stub table entry for a function. -# -# Arguments: -# name The interface name. -# decl The function declaration. -# index The slot index for this function. -# -# Results: -# Returns the formatted table entry. - -proc genStubs::makeSlot {name decl index} { - lassign $decl rtype fname args - - set lfname [string tolower [string index $fname 0]] - append lfname [string range $fname 1 end] - - set text " " - if {$args eq ""} { - append text $rtype " *" $lfname "; /* $index */\n" - return $text - } - if {[string range $rtype end-8 end] eq "__stdcall"} { - append text [string trim [string range $rtype 0 end-9]] " (__stdcall *" $lfname ") " - } else { - append text $rtype " (*" $lfname ") " - } - set arg1 [lindex $args 0] - switch -exact $arg1 { - void { - append text "(void)" - } - TCL_VARARGS { - set sep "(" - foreach arg [lrange $args 1 end] { - append text $sep [lindex $arg 0] - if {[string index $text end] ne "*"} { - append text " " - } - append text [lindex $arg 1] [lindex $arg 2] - set sep ", " - } - append text ", ...)" - } - default { - set sep "(" - foreach arg $args { - append text $sep [lindex $arg 0] - if {[string index $text end] ne "*"} { - append text " " - } - append text [lindex $arg 1] [lindex $arg 2] - set sep ", " - } - append text ")" - } - } - - append text "; /* $index */\n" - return $text -} - -# genStubs::makeInit -- -# -# Generate the prototype for a function. -# -# Arguments: -# name The interface name. -# decl The function declaration. -# index The slot index for this function. -# -# Results: -# Returns the formatted declaration string. - -proc genStubs::makeInit {name decl index} { - if {[lindex $decl 2] eq ""} { - append text " &" [lindex $decl 1] ", /* " $index " */\n" - } else { - append text " " [lindex $decl 1] ", /* " $index " */\n" - } - return $text -} - -# genStubs::forAllStubs -- -# -# This function iterates over all of the slots and invokes -# a callback for each slot. The result of the callback is then -# placed inside appropriate guards. -# -# Arguments: -# name The interface name. -# slotProc The proc to invoke to handle the slot. It will -# have the interface name, the declaration, and -# the index appended. -# guardProc The proc to invoke to add guards. It will have -# the slot status and text appended. -# textVar The variable to use for output. -# skipString The string to emit if a slot is skipped. This -# string will be subst'ed in the loop so "$i" can -# be used to substitute the index value. -# -# Results: -# None. - -proc genStubs::forAllStubs {name slotProc guardProc textVar - {skipString {"/* Slot $i is reserved */\n"}}} { - variable stubs - upvar $textVar text - - set lastNum $stubs($name,lastNum) - - for {set i 0} {$i <= $lastNum} {incr i} { - if {[info exists stubs($name,decl,$i)]} { - append text [$guardProc $stubs($name,status,$i) \ - [$slotProc $name $stubs($name,decl,$i) $i]] - } else { - eval {append text} $skipString - } - } -} - -proc genStubs::noGuard {status text} { return $text } - -proc genStubs::addGuard {status text} { - variable libraryName - set upName [string toupper $libraryName] - - switch -- $status { - current { - # No change - } - deprecated { - set text [ifdeffed "${upName}_DEPRECATED" $text] - } - obsolete { - set text "" - } - default { - puts stderr "Unrecognized status code $status" - } - } - return $text -} - -proc genStubs::ifdeffed {macro text} { - join [list "#ifdef $macro" $text "#endif" ""] \n -} - -# genStubs::emitDeclarations -- -# -# This function emits the function declarations for this interface. -# -# Arguments: -# name The interface name. -# textVar The variable to use for output. -# -# Results: -# None. - -proc genStubs::emitDeclarations {name textVar} { - upvar $textVar text - - append text "\n/*\n * Exported function declarations:\n */\n\n" - forAllStubs $name makeDecl noGuard text - return -} - -# genStubs::emitMacros -- -# -# This function emits the inline macros for an interface. -# -# Arguments: -# name The name of the interface being emitted. -# textVar The variable to use for output. -# -# Results: -# None. - -proc genStubs::emitMacros {name textVar} { - variable libraryName - upvar $textVar text - - set upName [string toupper $libraryName] - append text "\n#if defined(USE_${upName}_STUBS)\n" - append text "\n/*\n * Inline function declarations:\n */\n\n" - - forAllStubs $name makeMacro addGuard text - - append text "\n#endif /* defined(USE_${upName}_STUBS) */\n" - return -} - -# genStubs::emitHeader -- -# -# This function emits the body of the Decls.h file for -# the specified interface. -# -# Arguments: -# name The name of the interface being emitted. -# -# Results: -# None. - -proc genStubs::emitHeader {name} { - variable outDir - variable hooks - variable epoch - variable revision - - set capName [string toupper [string index $name 0]] - append capName [string range $name 1 end] - - if {$epoch ne ""} { - set CAPName [string toupper $name] - append text "\n" - append text "#define ${CAPName}_STUBS_EPOCH $epoch\n" - append text "#define ${CAPName}_STUBS_REVISION $revision\n" - } - - append text "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n" - - emitDeclarations $name text - - if {[info exists hooks($name)]} { - append text "\ntypedef struct {\n" - foreach hook $hooks($name) { - set capHook [string toupper [string index $hook 0]] - append capHook [string range $hook 1 end] - append text " const struct ${capHook}Stubs *${hook}Stubs;\n" - } - append text "} ${capName}StubHooks;\n" - } - append text "\ntypedef struct ${capName}Stubs {\n" - append text " int magic;\n" - if {$epoch ne ""} { - append text " int epoch;\n" - append text " int revision;\n" - } - if {[info exists hooks($name)]} { - append text " const ${capName}StubHooks *hooks;\n\n" - } else { - append text " void *hooks;\n\n" - } - - emitSlots $name text - - append text "} ${capName}Stubs;\n\n" - - append text "extern const ${capName}Stubs *${name}StubsPtr;\n\n" - append text "#ifdef __cplusplus\n}\n#endif\n" - - emitMacros $name text - - rewriteFile [file join $outDir ${name}Decls.h] $text - return -} - -# genStubs::emitInit -- -# -# Generate the table initializers for an interface. -# -# Arguments: -# name The name of the interface to initialize. -# textVar The variable to use for output. -# -# Results: -# Returns the formatted output. - -proc genStubs::emitInit {name textVar} { - variable hooks - variable interfaces - variable epoch - upvar $textVar text - set root 1 - - set capName [string toupper [string index $name 0]] - append capName [string range $name 1 end] - - if {[info exists hooks($name)]} { - append text "\nstatic const ${capName}StubHooks ${name}StubHooks = \{\n" - set sep " " - foreach sub $hooks($name) { - append text $sep "&${sub}Stubs" - set sep ",\n " - } - append text "\n\};\n" - } - foreach intf [array names interfaces] { - if {[info exists hooks($intf)]} { - if {[lsearch -exact $hooks($intf) $name] >= 0} { - set root 0 - break - } - } - } - - append text "\n" - if {!$root} { - append text "static " - } - append text "const ${capName}Stubs ${name}Stubs = \{\n TCL_STUB_MAGIC,\n" - if {$epoch ne ""} { - set CAPName [string toupper $name] - append text " ${CAPName}_STUBS_EPOCH,\n" - append text " ${CAPName}_STUBS_REVISION,\n" - } - if {[info exists hooks($name)]} { - append text " &${name}StubHooks,\n" - } else { - append text " 0,\n" - } - - forAllStubs $name makeInit noGuard text {" 0, /* $i */\n"} - - append text "\};\n" - return -} - -# genStubs::emitInits -- -# -# This function emits the body of the StubInit.c file for -# the specified interface. -# -# Arguments: -# name The name of the interface being emitted. -# -# Results: -# None. - -proc genStubs::emitInits {} { - variable hooks - variable outDir - variable libraryName - variable interfaces - - # Assuming that dependencies only go one level deep, we need to emit - # all of the leaves first to avoid needing forward declarations. - - set leaves {} - set roots {} - foreach name [lsort [array names interfaces]] { - if {[info exists hooks($name)]} { - lappend roots $name - } else { - lappend leaves $name - } - } - foreach name $leaves { - emitInit $name text - } - foreach name $roots { - emitInit $name text - } - - rewriteFile [file join $outDir ${libraryName}StubInit.c] $text -} - -# genStubs::init -- -# -# This is the main entry point. -# -# Arguments: -# None. -# -# Results: -# None. - -proc genStubs::init {} { - global argv argv0 - variable outDir - variable interfaces - - if {[llength $argv] < 2} { - puts stderr "usage: $argv0 outDir declFile ?declFile...?" - exit 1 - } - - set outDir [lindex $argv 0] - - foreach file [lrange $argv 1 end] { - source $file - } - - foreach name [lsort [array names interfaces]] { - puts "Emitting $name" - emitHeader $name - } - - emitInits -} - -# lassign -- -# -# This function emulates the TclX lassign command. -# -# Arguments: -# valueList A list containing the values to be assigned. -# args The list of variables to be assigned. -# -# Results: -# Returns any values that were not assigned to variables. - -if {[string length [namespace which lassign]] == 0} { - proc lassign {valueList args} { - if {[llength $args] == 0} { - error "wrong # args: should be \"lassign list varName ?varName ...?\"" - } - uplevel [list foreach $args $valueList {break}] - return [lrange $valueList [llength $args] end] - } -} - -genStubs::init diff --git a/unix/Makefile.in b/unix/Makefile.in index a4bc2d4..8e6433a 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -1465,7 +1465,7 @@ $(TTK_DIR)/ttkStubInit.c: $(TTK_DIR)/ttk.decls genstubs: $(TCL_EXE) $(TOOL_DIR)/genStubs.tcl $(GENERIC_DIR) \ $(GENERIC_DIR)/tk.decls $(GENERIC_DIR)/tkInt.decls - $(TCL_EXE) $(TTK_DIR)/ttkGenStubs.tcl $(TTK_DIR) $(TTK_DIR)/ttk.decls + $(TCL_EXE) $(TOOL_DIR)/genStubs.tcl $(TTK_DIR) $(TTK_DIR)/ttk.decls # # Target to check that all exported functions have an entry in the stubs diff --git a/win/Makefile.in b/win/Makefile.in index 7e48213..0b1acd7 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -730,7 +730,7 @@ genstubs: "$(GENERIC_DIR_NATIVE)" \ "$(GENERIC_DIR_NATIVE)/tk.decls" \ "$(GENERIC_DIR_NATIVE)/tkInt.decls" - $(TCL_EXE) "$(TTK_DIR)/ttkGenStubs.tcl" \ + $(TCL_EXE) "$(TCL_TOOL_DIR)/genStubs.tcl" \ "$(TTK_DIR)" \ "$(TTK_DIR)/ttk.decls" -- cgit v0.12 From c558898981a43637a64c17a40fd816ae41991961 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 18 Jan 2017 12:44:22 +0000 Subject: Change more refCount checks to the form "(...refCount-- <= 1)", so no separate decrement and compare is necessary. This allows (in the future) the same code to work when refCount becomes unsigned (which at least doubles the range). No functional change. --- generic/tkImgPhInstance.c | 3 +-- generic/tkText.c | 12 ++++-------- generic/tkTextDisp.c | 9 ++++----- generic/tkTextIndex.c | 2 +- generic/tkTextTag.c | 5 ++--- generic/tkWindow.c | 3 +-- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index bd152f2..98aaeab 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -721,8 +721,7 @@ TkImgPhotoFree( PhotoInstance *instancePtr = clientData; ColorTable *colorPtr; - instancePtr->refCount -= 1; - if (instancePtr->refCount > 0) { + if (instancePtr->refCount-- > 1) { return; } diff --git a/generic/tkText.c b/generic/tkText.c index 412a7f2..6ff1db9 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -1570,8 +1570,7 @@ TextWidgetObjCmd( } done: - textPtr->refCount--; - if (textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } return result; @@ -1964,9 +1963,7 @@ DestroyText( * portion of the text widget. */ - sharedTextPtr->refCount--; - - if (sharedTextPtr->refCount > 0) { + if (sharedTextPtr->refCount-- > 1) { TkBTreeRemoveClient(sharedTextPtr->tree, textPtr); /* @@ -2042,13 +2039,12 @@ DestroyText( } textPtr->tkwin = NULL; - textPtr->refCount--; Tcl_DeleteCommandFromToken(textPtr->interp, textPtr->widgetCmd); if (textPtr->afterSyncCmd){ Tcl_DecrRefCount(textPtr->afterSyncCmd); textPtr->afterSyncCmd = NULL; } - if (textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } } @@ -5526,7 +5522,7 @@ RunAfterSyncCmd( * The widget has been deleted. Don't do anything. */ - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree((char *) textPtr); } return; diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1be26c4..704d47d 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3005,7 +3005,7 @@ AsyncUpdateLineMetrics( * The widget has been deleted, or is not mapped. Don't do anything. */ - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } return; @@ -3080,8 +3080,7 @@ AsyncUpdateLineMetrics( GenerateWidgetViewSyncEvent(textPtr, 1); - textPtr->refCount--; - if (textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } return; @@ -4163,7 +4162,7 @@ DisplayText( textPtr->refCount++; dInfoPtr->flags &= ~REPICK_NEEDED; TkTextPickCurrent(textPtr, &textPtr->pickEvent); - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); goto end; } @@ -6752,7 +6751,7 @@ AsyncUpdateYScrollbar( GetYView(textPtr->interp, textPtr, 1); } - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } } diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index d227bd8..faa1afd 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -87,7 +87,7 @@ FreeTextIndexInternalRep( TkTextIndex *indexPtr = GET_TEXTINDEX(indexObjPtr); if (indexPtr->textPtr != NULL) { - if (--indexPtr->textPtr->refCount == 0) { + if (indexPtr->textPtr->refCount-- <= 1) { /* * The text widget has been deleted and we need to free it now. */ diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index dd3127d..d9329f5 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -1258,8 +1258,7 @@ TkTextFreeTag( if (textPtr != tagPtr->textPtr) { Tcl_Panic("Tag being deleted from wrong widget"); } - textPtr->refCount--; - if (textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } tagPtr->textPtr = NULL; @@ -1522,7 +1521,7 @@ TkTextBindProc( } done: - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } } diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 5855b7c..20b4f20 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -1479,8 +1479,7 @@ Tk_DestroyWindow( winPtr->mainPtr->deletionEpoch++; } - winPtr->mainPtr->refCount--; - if (winPtr->mainPtr->refCount == 0) { + if (winPtr->mainPtr->refCount-- <= 1) { register const TkCmd *cmdPtr; /* -- cgit v0.12 From 5442c2a77a9c025b2245d42dbae20829f03be9bc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 18 Jan 2017 12:45:33 +0000 Subject: Use the win32 Wide API in some more places. And some simplifications, since we no longer support win95/98/ME --- win/tkWinClipboard.c | 11 +---------- win/tkWinFont.c | 41 ++++++++++++++++------------------------- win/tkWinMenu.c | 46 ++++++++++++++++++++++------------------------ 3 files changed, 39 insertions(+), 59 deletions(-) diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 200883f..929070b 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -414,16 +414,7 @@ UpdateClipboard( OpenClipboard(hwnd); EmptyClipboard(); - /* - * CF_UNICODETEXT is only supported on NT, but it it is prefered when - * possible. - */ - - if (TkWinGetPlatformId() != VER_PLATFORM_WIN32_WINDOWS) { - SetClipboardData(CF_UNICODETEXT, NULL); - } else { - SetClipboardData(CF_TEXT, NULL); - } + SetClipboardData(CF_UNICODETEXT, NULL); CloseClipboard(); TkWinUpdatingClipboard(FALSE); } diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 860451b..ea8a7a2 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -262,16 +262,7 @@ void TkpFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { - if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) { - /* - * If running NT, then we will be calling some Unicode functions - * explictly. So, even if the Tcl system encoding isn't Unicode, make - * sure we convert to/from the Unicode char set. - */ - - systemEncoding = TkWinGetUnicodeEncoding(); - } - + systemEncoding = TkWinGetUnicodeEncoding(); TkWinSetupSystemFonts(mainPtr); } @@ -760,14 +751,14 @@ TkpGetFontAttrsForChar( * character */ FontFamily *familyPtr = thisSubFontPtr->familyPtr; HFONT oldfont; /* Saved font from the device context */ - TEXTMETRICA tm; /* Font metrics of the selected subfont */ + TEXTMETRIC tm; /* Font metrics of the selected subfont */ /* * Get the font attributes. */ oldfont = SelectObject(hdc, thisSubFontPtr->hFont0); - GetTextMetricsA(hdc, &tm); + GetTextMetrics(hdc, &tm); SelectObject(hdc, oldfont); ReleaseDC(fontPtr->hwnd, hdc); faPtr->family = familyPtr->faceName; @@ -1118,7 +1109,7 @@ Tk_DrawChars( HBRUSH oldBrush, stipple; HBITMAP oldBitmap, bitmap; HDC dcMem; - TEXTMETRICA tm; + TEXTMETRIC tm; SIZE size; if (twdPtr->type != TWD_BITMAP) { @@ -1145,7 +1136,7 @@ Tk_DrawChars( */ GetTextExtentPointA(dcMem, source, numBytes, &size); - GetTextMetricsA(dcMem, &tm); + GetTextMetrics(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); oldBitmap = SelectObject(dcMem, bitmap); @@ -1184,7 +1175,7 @@ Tk_DrawChars( } else { HBITMAP oldBitmap, bitmap; HDC dcMem; - TEXTMETRICA tm; + TEXTMETRIC tm; SIZE size; dcMem = CreateCompatibleDC(dc); @@ -1199,7 +1190,7 @@ Tk_DrawChars( */ GetTextExtentPointA(dcMem, source, numBytes, &size); - GetTextMetricsA(dcMem, &tm); + GetTextMetrics(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); oldBitmap = SelectObject(dcMem, bitmap); @@ -1266,7 +1257,7 @@ TkDrawAngledChars( HBRUSH oldBrush, stipple; HBITMAP oldBitmap, bitmap; HDC dcMem; - TEXTMETRICA tm; + TEXTMETRIC tm; SIZE size; if (twdPtr->type != TWD_BITMAP) { @@ -1293,7 +1284,7 @@ TkDrawAngledChars( */ GetTextExtentPointA(dcMem, source, numBytes, &size); - GetTextMetricsA(dcMem, &tm); + GetTextMetrics(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); oldBitmap = SelectObject(dcMem, bitmap); @@ -1332,7 +1323,7 @@ TkDrawAngledChars( } else { HBITMAP oldBitmap, bitmap; HDC dcMem; - TEXTMETRICA tm; + TEXTMETRIC tm; SIZE size; dcMem = CreateCompatibleDC(dc); @@ -1347,7 +1338,7 @@ TkDrawAngledChars( */ GetTextExtentPointA(dcMem, source, numBytes, &size); - GetTextMetricsA(dcMem, &tm); + GetTextMetrics(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); oldBitmap = SelectObject(dcMem, bitmap); @@ -1454,11 +1445,11 @@ MultiFontTextOut( Tcl_DString runString; const char *p, *end, *next; SubFont *lastSubFontPtr, *thisSubFontPtr; - TEXTMETRICA tm; + TEXTMETRIC tm; lastSubFontPtr = &fontPtr->subFontArray[0]; oldFont = SelectFont(hdc, fontPtr, lastSubFontPtr, angle); - GetTextMetricsA(hdc, &tm); + GetTextMetrics(hdc, &tm); end = source + numBytes; for (p = source; p < end; ) { @@ -1482,7 +1473,7 @@ MultiFontTextOut( lastSubFontPtr = thisSubFontPtr; source = p; SelectFont(hdc, fontPtr, lastSubFontPtr, angle); - GetTextMetricsA(hdc, &tm); + GetTextMetrics(hdc, &tm); } p = next; } @@ -1560,7 +1551,7 @@ InitFont( HDC hdc; HWND hwnd; HFONT oldFont; - TEXTMETRICA tm; + TEXTMETRIC tm; Window window; TkFontMetrics *fmPtr; Tcl_Encoding encoding; @@ -1573,7 +1564,7 @@ InitFont( hdc = GetDC(hwnd); oldFont = SelectObject(hdc, hFont); - GetTextMetricsA(hdc, &tm); + GetTextMetrics(hdc, &tm); /* * On any version NT, there may fonts with international names. Use the diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 8e14669..3cf7c10 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -900,7 +900,7 @@ TkWinMenuProc( LRESULT lResult; if (!TkWinHandleMenuEvent(&hwnd, &message, &wParam, &lParam, &lResult)) { - lResult = DefWindowProcA(hwnd, message, wParam, lParam); + lResult = DefWindowProc(hwnd, message, wParam, lParam); } return lResult; } @@ -999,7 +999,7 @@ TkWinEmbeddedMenuProc( } default: - lResult = DefWindowProcA(hwnd, message, wParam, lParam); + lResult = DefWindowProc(hwnd, message, wParam, lParam); break; } return lResult; @@ -2036,33 +2036,33 @@ TkWinMenuKeyObjCmd( if (eventPtr->type == KeyPress) { switch (keySym) { case XK_Alt_L: - scanCode = MapVirtualKeyA(VK_LMENU, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_LMENU, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYDOWN, VK_MENU, (int) (scanCode << 16) | (1 << 29)); break; case XK_Alt_R: - scanCode = MapVirtualKeyA(VK_RMENU, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_RMENU, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYDOWN, VK_MENU, (int) (scanCode << 16) | (1 << 29) | (1 << 24)); break; case XK_F10: - scanCode = MapVirtualKeyA(VK_F10, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_F10, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYDOWN, VK_F10, (int) (scanCode << 16)); break; default: virtualKey = XKeysymToKeycode(winPtr->display, keySym); - scanCode = MapVirtualKeyA(virtualKey, 0); + scanCode = MapVirtualKey(virtualKey, 0); if (0 != scanCode) { XKeyEvent xkey = eventPtr->xkey; - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYDOWN, virtualKey, (int) ((scanCode << 16) | (1 << 29))); if (xkey.nbytes > 0) { for (i = 0; i < xkey.nbytes; i++) { - CallWindowProcA(DefWindowProcA, + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSCHAR, xkey.trans_chars[i], (int) ((scanCode << 16) | (1 << 29))); @@ -2073,28 +2073,28 @@ TkWinMenuKeyObjCmd( } else if (eventPtr->type == KeyRelease) { switch (keySym) { case XK_Alt_L: - scanCode = MapVirtualKeyA(VK_LMENU, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_LMENU, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYUP, VK_MENU, (int) (scanCode << 16) | (1 << 29) | (1 << 30) | (1 << 31)); break; case XK_Alt_R: - scanCode = MapVirtualKeyA(VK_RMENU, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_RMENU, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYUP, VK_MENU, (int) (scanCode << 16) | (1 << 24) | (0x111 << 29) | (1 << 30) | (1 << 31)); break; case XK_F10: - scanCode = MapVirtualKeyA(VK_F10, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_F10, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYUP, VK_F10, (int) (scanCode << 16) | (1 << 30) | (1 << 31)); break; default: virtualKey = XKeysymToKeycode(winPtr->display, keySym); - scanCode = MapVirtualKeyA(virtualKey, 0); + scanCode = MapVirtualKey(virtualKey, 0); if (0 != scanCode) { - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYUP, virtualKey, (int) ((scanCode << 16) | (1 << 29) | (1 << 30) | (1 << 31))); } @@ -3199,7 +3199,7 @@ SetDefaults( HDC scratchDC; int bold = 0; int italic = 0; - TEXTMETRICA tm; + TEXTMETRIC tm; int pointSize; HFONT menuFont; /* See: [Bug #3239768] tk8.4.19 (and later) WIN32 menu font support */ @@ -3239,7 +3239,7 @@ SetDefaults( &nc.metrics, 0); menuFont = CreateFontIndirect(&nc.metrics.lfMenuFont); SelectObject(scratchDC, menuFont); - GetTextMetricsA(scratchDC, &tm); + GetTextMetrics(scratchDC, &tm); GetTextFaceA(scratchDC, LF_FACESIZE, faceName); pointSize = MulDiv(tm.tmHeight - tm.tmInternalLeading, 72, GetDeviceCaps(scratchDC, LOGPIXELSY)); @@ -3295,9 +3295,7 @@ SetDefaults( */ showMenuAccelerators = TRUE; - if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) { - SystemParametersInfoA(SPI_GETKEYBOARDCUES, 0, &showMenuAccelerators, 0); - } + SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &showMenuAccelerators, 0); } /* -- cgit v0.12 From b8a68d0c335e5b303b12e9fd8194e27be780a219 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 20 Jan 2017 14:37:27 +0000 Subject: Smarter initialization of doubleTypePtr/intTypePtr without hash-table lookup or creating complete Tcl_Obj's. In Windows tests, allow up to 64 bits for HWND. Check stubs for "8.6-" in stead of "8.6", for better interoperability with "novem". --- generic/tkConsole.c | 2 +- generic/tkIntXlibDecls.h | 4 ++++ generic/tkMain.c | 2 +- generic/tkObj.c | 15 +++++++++++++-- generic/tkTest.c | 2 +- generic/tkWindow.c | 2 +- win/tkWinTest.c | 18 +++++++++--------- 7 files changed, 30 insertions(+), 15 deletions(-) diff --git a/generic/tkConsole.c b/generic/tkConsole.c index fc60d5f..57e8364 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -223,7 +223,7 @@ Tk_InitConsoleChannels( * Ensure that we are getting a compatible version of Tcl. */ - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { return; } diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index de44068..ce9752f 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -23,6 +23,10 @@ # include #endif +#ifndef EXTERN +# define EXTERN extern TCL_STORAGE_CLASS +#endif + /* Some (older) versions of X11/Xutil.h have a wrong signature of those two functions, so move them out of the way temporarly. */ #define XOffsetRegion _XOffsetRegion diff --git a/generic/tkMain.c b/generic/tkMain.c index 1b21223..87a3cf7 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -196,7 +196,7 @@ Tk_MainEx( * Ensure that we are getting a compatible version of Tcl. */ - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { if (Tcl_InitStubs(interp, "8.1", 0) == NULL) { abort(); } else { diff --git a/generic/tkObj.c b/generic/tkObj.c index 7c09656..90fedbc 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -153,8 +153,19 @@ GetTypeCache(void) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->doubleTypePtr == NULL) { - tsdPtr->doubleTypePtr = Tcl_GetObjType("double"); - tsdPtr->intTypePtr = Tcl_GetObjType("int"); + /* Smart initialization of doubleTypePtr/intTypePtr without + * hash-table lookup or creating complete Tcl_Obj's */ + Tcl_Obj obj; + obj.length = 3; + obj.bytes = (char *)"0.0"; + obj.typePtr = NULL; + Tcl_GetDoubleFromObj(NULL, &obj, &obj.internalRep.doubleValue); + tsdPtr->doubleTypePtr = obj.typePtr; + obj.bytes += 2; + obj.length = 1; + obj.typePtr = NULL; + Tcl_GetLongFromObj(NULL, &obj, &obj.internalRep.longValue); + tsdPtr->intTypePtr = obj.typePtr; } return tsdPtr; } diff --git a/generic/tkTest.c b/generic/tkTest.c index faba89d..e23be36 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -227,7 +227,7 @@ Tktest_Init( { static int initialized = 0; - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { return TCL_ERROR; } if (Tk_InitStubs(interp, TK_VERSION, 0) == NULL) { diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 20b4f20..f02db35 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -3040,7 +3040,7 @@ Initialize( * Ensure that we are getting a compatible version of Tcl. */ - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { return TCL_ERROR; } diff --git a/win/tkWinTest.c b/win/tkWinTest.c index d824ee4..095358d 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -483,7 +483,7 @@ TestfindwindowObjCmd( AppendSystemError(interp, GetLastError()); r = TCL_ERROR; } else { - Tcl_SetObjResult(interp, Tcl_NewLongObj(PTR2INT(hwnd))); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj((size_t)hwnd)); } Tcl_DStringFree(&titleString); @@ -499,7 +499,7 @@ EnumChildrenProc( { Tcl_Obj *listObj = (Tcl_Obj *) lParam; - Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewLongObj(PTR2INT(hwnd))); + Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewWideIntObj((size_t)hwnd)); return TRUE; } @@ -510,7 +510,7 @@ TestgetwindowinfoObjCmd( int objc, Tcl_Obj *const objv[]) { - long hwnd; + Tcl_WideInt hwnd; Tcl_Obj *dictObj = NULL, *classObj = NULL, *textObj = NULL; Tcl_Obj *childrenObj = NULL; TCHAR buf[512]; @@ -521,10 +521,10 @@ TestgetwindowinfoObjCmd( return TCL_ERROR; } - if (Tcl_GetLongFromObj(interp, objv[1], &hwnd) != TCL_OK) + if (Tcl_GetWideIntFromObj(interp, objv[1], &hwnd) != TCL_OK) return TCL_ERROR; - cch = GetClassName(INT2PTR(hwnd), buf, cchBuf); + cch = GetClassName((HWND)(size_t)hwnd, buf, cchBuf); if (cch == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to get class name: ", -1)); AppendSystemError(interp, GetLastError()); @@ -539,17 +539,17 @@ TestgetwindowinfoObjCmd( dictObj = Tcl_NewDictObj(); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("class", 5), classObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2), - Tcl_NewLongObj(GetWindowLongA(INT2PTR(hwnd), GWL_ID))); + Tcl_NewWideIntObj(GetWindowLongPtr((HWND)(size_t)hwnd, GWL_ID))); - cch = GetWindowText(INT2PTR(hwnd), (LPTSTR)buf, cchBuf); + cch = GetWindowText((HWND)(size_t)hwnd, (LPTSTR)buf, cchBuf); textObj = Tcl_NewUnicodeObj((LPCWSTR)buf, cch); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6), - Tcl_NewLongObj(PTR2INT(GetParent((INT2PTR(hwnd)))))); + Tcl_NewWideIntObj((size_t)(GetParent((HWND)(size_t)hwnd)))); childrenObj = Tcl_NewListObj(0, NULL); - EnumChildWindows(INT2PTR(hwnd), EnumChildrenProc, (LPARAM)childrenObj); + EnumChildWindows((HWND)(size_t)hwnd, EnumChildrenProc, (LPARAM)childrenObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("children", -1), childrenObj); Tcl_SetObjResult(interp, dictObj); -- cgit v0.12 From e926662190cc08e5f057d0d90cdf9da4a1aab15f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 20 Jan 2017 14:39:30 +0000 Subject: Compile with -Wwrite-strings, as does Tcl. In pkgIndex files, allow "8.6-" to match, for better interoperability with "novem" --- unix/Makefile.in | 2 +- unix/configure | 2 +- unix/tcl.m4 | 2 +- win/Makefile.in | 2 +- win/configure | 2 +- win/makefile.vc | 2 +- win/tcl.m4 | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/unix/Makefile.in b/unix/Makefile.in index 8e6433a..1b8677e 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -723,7 +723,7 @@ install-binaries: $(TK_STUB_LIB_FILE) $(TK_LIB_FILE) ${WISH_EXE} echo "Creating package index $(PKG_INDEX)"; \ rm -f "$(PKG_INDEX)"; \ (\ - echo "if {[catch {package present Tcl 8.6.0}]} return";\ + echo "if {[catch {package present Tcl 8.6-}]} return";\ relative=`echo | awk '{ORS=" "; split("$(TK_PKG_DIR)",a,"/"); for (f in a) {print ".."}}'`;\ if test "x$(DLL_INSTALL_DIR)" != "x$(BIN_INSTALL_DIR)"; then \ echo "package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}$(TK_LIB_FILE)]] Tk]";\ diff --git a/unix/configure b/unix/configure index 1ed0275..f76ae3b 100755 --- a/unix/configure +++ b/unix/configure @@ -4595,7 +4595,7 @@ fi if test "$GCC" = yes; then : CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" else diff --git a/unix/tcl.m4 b/unix/tcl.m4 index a1d4021..2ab432c 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1096,7 +1096,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_DEBUG=-g AS_IF([test "$GCC" = yes], [ CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" ], [ CFLAGS_OPTIMIZE=-O CFLAGS_WARNING="" diff --git a/win/Makefile.in b/win/Makefile.in index 0b1acd7..80d616b 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -487,7 +487,7 @@ install-binaries: binaries @echo "Creating package index $(PKG_INDEX)"; @$(RM) $(PKG_INDEX); @(\ - echo "if {[catch {package present Tcl 8.6.0}]} return";\ + echo "if {[catch {package present Tcl 8.6-}]} return";\ echo "if {(\$$::tcl_platform(platform) eq \"unix\") && ([info exists ::env(DISPLAY)]";\ echo " || ([info exists ::argv] && (\"-display\" in \$$::argv)))} {";\ echo " package ifneeded Tk $(VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir .. .. bin libtk$(VERSION).dll]] Tk]";\ diff --git a/win/configure b/win/configure index 0b80f22..0149709 100755 --- a/win/configure +++ b/win/configure @@ -4335,7 +4335,7 @@ $as_echo "using shared flags" >&6; } CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" - CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" LDFLAGS_DEBUG= LDFLAGS_OPTIMIZE= diff --git a/win/makefile.vc b/win/makefile.vc index 6f61327..c8c42a2 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -961,7 +961,7 @@ install-binaries: !if !$(STATIC_BUILD) @echo creating package index @type << > $(OUT_DIR)\pkgIndex.tcl -if {[catch {package present Tcl 8.6.0}]} { return } +if {[catch {package present Tcl 8.6-}]} { return } if {($$::tcl_platform(platform) eq "unix") && ([info exists ::env(DISPLAY)] || ([info exists ::argv] && ("-display" in $$::argv)))} { package ifneeded Tk $(TK_PATCH_LEVEL) [list load [file join $$dir .. .. bin libtk$(TK_DOTVERSION).dll] Tk] diff --git a/win/tcl.m4 b/win/tcl.m4 index d1fb11c..4d28744 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -727,7 +727,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" - CFLAGS_WARNING="-Wall -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" LDFLAGS_DEBUG= LDFLAGS_OPTIMIZE= -- cgit v0.12 From 0742c300b49248cdf4e360ac99c629081a106f79 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 20 Jan 2017 15:51:20 +0000 Subject: Typo in Dutch translation. Use copyright sign directly in *.msg files (and widget demo). --- library/demos/en.msg | 2 +- library/demos/nl.msg | 4 ++-- library/demos/widget | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/demos/en.msg b/library/demos/en.msg index d4783fe..05d4a64 100644 --- a/library/demos/en.msg +++ b/library/demos/en.msg @@ -18,7 +18,7 @@ ::msgcat::mcset en "Demo code: %s" ::msgcat::mcset en "About Widget Demo" ::msgcat::mcset en "Tk widget demonstration application" -::msgcat::mcset en "Copyright (c) %s" "Copyright \u00a9 %s" +::msgcat::mcset en "Copyright © %s" ::msgcat::mcset en " @@title Tk Widget Demonstrations diff --git a/library/demos/nl.msg b/library/demos/nl.msg index b17ceaa..cd52630 100644 --- a/library/demos/nl.msg +++ b/library/demos/nl.msg @@ -18,9 +18,9 @@ ::msgcat::mcset nl "Demo code: %s" "Code van Demo %s" ::msgcat::mcset nl "About Widget Demo" "Over deze demonstratie" ::msgcat::mcset nl "Tk widget demonstration" "Demonstratie van Tk widgets" -::msgcat::mcset nl "Copyright (c) %s" "Copyright (c) %s" +::msgcat::mcset nl "Copyright © %s" -::msgcat::mcset nl "Tk Widget Demonstrations" "Demostratie van Tk widgets" +::msgcat::mcset nl "Tk Widget Demonstrations" "Demonstratie van Tk widgets" ::msgcat::mcset nl "This application provides a front end for several short scripts" \ "Dit programma is een schil rond enkele korte scripts waarmee" ::msgcat::mcset nl "that demonstrate what you can do with Tk widgets. Each of the" \ diff --git a/library/demos/widget b/library/demos/widget index 162497e..052c160 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -723,10 +723,10 @@ proc PrintTextWin32 {filename} { proc tkAboutDialog {} { tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \ -message [mc "Tk widget demonstration application"] -detail \ -"[mc {Copyright (c) %s} {1996-1997 Sun Microsystems, Inc.}] -[mc {Copyright (c) %s} {1997-2000 Ajuba Solutions, Inc.}] -[mc {Copyright (c) %s} {2001-2007 Donal K. Fellows}] -[mc {Copyright (c) %s} {2002-2007 Daniel A. Steffen}]" +"[mc \"Copyright\ \u00a9\ %s\" {1996-1997 Sun Microsystems, Inc.}] +[mc \"Copyright\ \u00a9\ %s\" {1997-2000 Ajuba Solutions, Inc.}] +[mc \"Copyright\ \u00a9\ %s\" {2001-2007 Donal K. Fellows}] +[mc \"Copyright\ \u00a9\ %s\" {2002-2007 Daniel A. Steffen}]" } # Local Variables: -- cgit v0.12 From 3fb089ed701dcab661c4b34a2ea70bef7d5d9516 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 21 Jan 2017 13:06:08 +0000 Subject: Fix [ed22529c92]: Spinbox validation is turned off when validate function returns false --- doc/spinbox.n | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/spinbox.n b/doc/spinbox.n index 330bb17..acf06d6 100644 --- a/doc/spinbox.n +++ b/doc/spinbox.n @@ -217,15 +217,19 @@ were editing the spinbox widget from). It is also recommended to not set an associated \fB\-textvariable\fR during validation, as that can cause the spinbox widget to become out of sync with the \fB\-textvariable\fR. .PP -Also, the \fBvalidate\fR option will set itself to \fBnone\fR when the -spinbox value gets changed because of adjustment of \fBfrom\fR or \fBto\fR -and the \fBvalidateCommand\fR returns false. For instance +Also, the \fB-validate\fR option will set itself to \fBnone\fR when the +spinbox value gets changed because of adjustment of \fB-from\fR or \fB-to\fR +and the \fB-validatecommand\fR returns false. For instance .CS \fIspinbox pathName \-from 1 \-to 10 \-validate all \-vcmd {return 0}\fR .CE -will in fact set the \fBvalidate\fR option to \fBnone\fR because the default -value for the spinbox gets changed (due to the \fBfrom\fR and \fBto\fR +will in fact set the \fB-validate\fR option to \fBnone\fR because the default +value for the spinbox gets changed (due to the \fB-from\fR and \fB-to\fR options) to a value not accepted by the validation script. +.PP +Moreover, forced validation is performed when invoking any spinbutton of +the spinbox. If the validation script returns false in this situation, +then the \fB-validate\fR option will be automatically set to \fBnone\fR. .SH "WIDGET COMMAND" .PP The \fBspinbox\fR command creates a new Tcl command whose -- cgit v0.12 From dabee7102b4e83ddd4784375631348c6b1ed0e11 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 22 Jan 2017 09:05:57 +0000 Subject: Fix [89a638af38]: OS X - textDisp-15.8 fails --- tests/textDisp.test | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index d3de2d8..8342c46 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1952,13 +1952,15 @@ test textDisp-15.8 {Scrolling near end of window} { .tf.f.t insert end "\nLine $i" } update ; after 1000 ; update + set refind [.tf.f.t index @0,[winfo height .tf.f.t]] # Should scroll and should not crash! .tf.f.t yview scroll 1 unit # Check that it has scrolled - set res [.tf.f.t index @0,[expr [winfo height .tf.f.t] - 15]] + set newind [.tf.f.t index @0,[winfo height .tf.f.t]] + set res [.tf.f.t compare $newind > $refind] destroy .tf set res -} {12.0} +} {1} .t configure -wrap char .t delete 1.0 end -- cgit v0.12 From ebb2c5a3dbf48abcc99a56379e0924f43c594285 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 23 Jan 2017 09:45:18 +0000 Subject: Remove superfloeus double-quite in widget's "about" dialog. --- library/demos/widget | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/demos/widget b/library/demos/widget index 052c160..88d55c6 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -723,10 +723,10 @@ proc PrintTextWin32 {filename} { proc tkAboutDialog {} { tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \ -message [mc "Tk widget demonstration application"] -detail \ -"[mc \"Copyright\ \u00a9\ %s\" {1996-1997 Sun Microsystems, Inc.}] -[mc \"Copyright\ \u00a9\ %s\" {1997-2000 Ajuba Solutions, Inc.}] -[mc \"Copyright\ \u00a9\ %s\" {2001-2007 Donal K. Fellows}] -[mc \"Copyright\ \u00a9\ %s\" {2002-2007 Daniel A. Steffen}]" +"[mc "Copyright \u00a9 %s" {1996-1997 Sun Microsystems, Inc.}] +[mc "Copyright \u00a9 %s" {1997-2000 Ajuba Solutions, Inc.}] +[mc "Copyright \u00a9 %s" {2001-2007 Donal K. Fellows}] +[mc "Copyright \u00a9 %s" {2002-2007 Daniel A. Steffen}]" } # Local Variables: -- cgit v0.12 From e0911ec4c26de1730f2f00b8d32a5e1980211dea Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 23 Jan 2017 14:46:22 +0000 Subject: If Tk is compiled with -DTK_NO_DEPRECATED=1, remove some deprecated code (pack subcommands) and other stuff which is not used any more. And fix a few typos. Remove rmd.bat and rmd.bat, which are also not used any more. --- .fossil-settings/crlf-glob | 2 -- .fossil-settings/crnl-glob | 2 -- .fossil-settings/encoding-glob | 2 -- changes | 2 +- generic/tk.h | 3 ++- generic/tkIntXlibDecls.h | 8 ++++++-- generic/tkPack.c | 15 ++++++++++++++- generic/tkPanedWindow.c | 22 +++++++++++----------- macosx/Tk.xcode/project.pbxproj | 3 --- macosx/Tk.xcodeproj/project.pbxproj | 4 ---- win/mkd.bat | 12 ------------ win/rmd.bat | 20 -------------------- win/rules.vc | 20 ++++++-------------- 13 files changed, 40 insertions(+), 75 deletions(-) delete mode 100644 win/mkd.bat delete mode 100644 win/rmd.bat diff --git a/.fossil-settings/crlf-glob b/.fossil-settings/crlf-glob index 7175730..ad7795f 100644 --- a/.fossil-settings/crlf-glob +++ b/.fossil-settings/crlf-glob @@ -1,6 +1,4 @@ win/buildall.vc.bat win/makefile.bc win/makefile.vc -win/mkd.bat -win/rmd.bat win/rules.vc diff --git a/.fossil-settings/crnl-glob b/.fossil-settings/crnl-glob index 7175730..ad7795f 100644 --- a/.fossil-settings/crnl-glob +++ b/.fossil-settings/crnl-glob @@ -1,6 +1,4 @@ win/buildall.vc.bat win/makefile.bc win/makefile.vc -win/mkd.bat -win/rmd.bat win/rules.vc diff --git a/.fossil-settings/encoding-glob b/.fossil-settings/encoding-glob index 7175730..ad7795f 100644 --- a/.fossil-settings/encoding-glob +++ b/.fossil-settings/encoding-glob @@ -1,6 +1,4 @@ win/buildall.vc.bat win/makefile.bc win/makefile.vc -win/mkd.bat -win/rmd.bat win/rules.vc diff --git a/changes b/changes index bf3e62e..3f1b43d 100644 --- a/changes +++ b/changes @@ -1315,7 +1315,7 @@ ISO Latin-1 character set. result across the execution of binding scripts. Otherwise if an event triggers in the middle of some other script (e.g. a destroy event during window creation, because there was an error in the creation command), -the intepreter's result gets lost. +the interpreter's result gets lost. 2/19/94 (bug fix) Fixed bug in dealing with results of sent command that could cause them to get lost in some situations. diff --git a/generic/tk.h b/generic/tk.h index 658b11e..a0fbba9 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -748,9 +748,10 @@ typedef XActivateDeactivateEvent XDeactivateEvent; (((Tk_FakeWin *) (tkwin))->flags & TK_WM_MANAGEABLE) #define Tk_ReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->reqWidth) #define Tk_ReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->reqHeight) -/* Tk_InternalBorderWidth is deprecated */ +#ifndef TK_NO_DEPRECATED #define Tk_InternalBorderWidth(tkwin) \ (((Tk_FakeWin *) (tkwin))->internalBorderLeft) +#endif /* !TK_NO_DEPRECATED */ #define Tk_InternalBorderLeft(tkwin) \ (((Tk_FakeWin *) (tkwin))->internalBorderLeft) #define Tk_InternalBorderRight(tkwin) \ diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index ce9752f..67b7c39 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -36,8 +36,12 @@ #undef XUnionRegion #ifdef BUILD_tk -#undef TCL_STORAGE_CLASS -#define TCL_STORAGE_CLASS DLLEXPORT +# undef TCL_STORAGE_CLASS +# define TCL_STORAGE_CLASS DLLEXPORT +#else +# ifndef TCL_STORAGE_CLASS +# define TCL_STORAGE_CLASS DLLIMPORT +# endif #endif typedef int (*XAfterFunction) ( /* WARNING, this type not in Xlib spec */ diff --git a/generic/tkPack.c b/generic/tkPack.c index 88a4b2d..8257b43 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -122,8 +122,10 @@ static int ConfigureSlaves(Tcl_Interp *interp, Tk_Window tkwin, int objc, Tcl_Obj *const objv[]); static void DestroyPacker(void *memPtr); static Packer * GetPacker(Tk_Window tkwin); +#ifndef TK_NO_DEPRECATED static int PackAfter(Tcl_Interp *interp, Packer *prevPtr, Packer *masterPtr, int objc,Tcl_Obj *const objv[]); +#endif /* !TK_NO_DEPRECATED */ static void PackStructureProc(ClientData clientData, XEvent *eventPtr); static void Unlink(Packer *packPtr); @@ -197,11 +199,14 @@ Tk_PackObjCmd( Tk_Window tkwin = clientData; const char *argv2; static const char *const optionStrings[] = { - /* after, append, before and unpack are deprecated */ +#ifndef TK_NO_DEPRECATED "after", "append", "before", "unpack", +#endif /* !TK_NO_DEPRECATED */ "configure", "forget", "info", "propagate", "slaves", NULL }; enum options { +#ifndef TK_NO_DEPRECATED PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK, +#endif /* !TK_NO_DEPRECATED */ PACK_CONFIGURE, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES }; int index; @@ -219,6 +224,7 @@ Tk_PackObjCmd( if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, sizeof(char *), "option", 0, &index) != TCL_OK) { +#ifndef TK_NO_DEPRECATED /* * Call it again without the deprecated ones to get a proper error * message. This works well since there can't be any ambiguity between @@ -228,11 +234,13 @@ Tk_PackObjCmd( Tcl_ResetResult(interp); Tcl_GetIndexFromObjStruct(interp, objv[1], &optionStrings[4], sizeof(char *), "option", 0, &index); +#endif /* TK_NO_DEPRECATED */ return TCL_ERROR; } argv2 = Tcl_GetString(objv[2]); switch ((enum options) index) { +#ifndef TK_NO_DEPRECATED case PACK_AFTER: { Packer *prevPtr; Tk_Window tkwin2; @@ -297,6 +305,7 @@ Tk_PackObjCmd( } return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3); } +#endif /* !TK_NO_DEPRECATED */ case PACK_CONFIGURE: if (argv2[0] != '.') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -458,6 +467,7 @@ Tk_PackObjCmd( Tcl_SetObjResult(interp, resultObj); break; } +#ifndef TK_NO_DEPRECATED case PACK_UNPACK: { Tk_Window tkwin2; Packer *packPtr; @@ -481,6 +491,7 @@ Tk_PackObjCmd( } break; } +#endif /* !TK_NO_DEPRECATED */ } return TCL_OK; @@ -1087,6 +1098,7 @@ GetPacker( *------------------------------------------------------------------------ */ +#ifndef TK_NO_DEPRECATED static int PackAfter( Tcl_Interp *interp, /* Interpreter for error reporting. */ @@ -1307,6 +1319,7 @@ PackAfter( } return TCL_OK; } +#endif /* !TK_NO_DEPRECATED */ /* *---------------------------------------------------------------------- diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index f350d0a..4bfc695 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -1484,10 +1484,10 @@ DisplayPanedWindow( */ if (horizontal) { - sashHeight = Tk_Height(tkwin) - (2 * Tk_InternalBorderWidth(tkwin)); + sashHeight = Tk_Height(tkwin) - (2 * Tk_InternalBorderLeft(tkwin)); sashWidth = pwPtr->sashWidth; } else { - sashWidth = Tk_Width(tkwin) - (2 * Tk_InternalBorderWidth(tkwin)); + sashWidth = Tk_Width(tkwin) - (2 * Tk_InternalBorderLeft(tkwin)); sashHeight = pwPtr->sashWidth; } @@ -1754,7 +1754,7 @@ ArrangePanes( */ paneDynSize = paneDynMinSize = 0; - internalBW = Tk_InternalBorderWidth(pwPtr->tkwin); + internalBW = Tk_InternalBorderLeft(pwPtr->tkwin); pwHeight = Tk_Height(pwPtr->tkwin) - (2 * internalBW); pwWidth = Tk_Width(pwPtr->tkwin) - (2 * internalBW); x = y = internalBW; @@ -2184,7 +2184,7 @@ ComputeGeometry( pwPtr->flags |= REQUESTED_RELAYOUT; - x = y = internalBw = Tk_InternalBorderWidth(pwPtr->tkwin); + x = y = internalBw = Tk_InternalBorderLeft(pwPtr->tkwin); reqWidth = reqHeight = 0; /* @@ -2890,7 +2890,7 @@ PanedWindowProxyCommand( return TCL_ERROR; } - internalBW = Tk_InternalBorderWidth(pwPtr->tkwin); + internalBW = Tk_InternalBorderLeft(pwPtr->tkwin); if (pwPtr->orient == ORIENT_HORIZONTAL) { if (x < 0) { x = 0; @@ -2899,10 +2899,10 @@ PanedWindowProxyCommand( if (x > pwWidth) { x = pwWidth; } - y = Tk_InternalBorderWidth(pwPtr->tkwin); + y = Tk_InternalBorderLeft(pwPtr->tkwin); sashWidth = pwPtr->sashWidth; sashHeight = Tk_Height(pwPtr->tkwin) - - (2 * Tk_InternalBorderWidth(pwPtr->tkwin)); + (2 * Tk_InternalBorderLeft(pwPtr->tkwin)); } else { if (y < 0) { y = 0; @@ -2911,10 +2911,10 @@ PanedWindowProxyCommand( if (y > pwHeight) { y = pwHeight; } - x = Tk_InternalBorderWidth(pwPtr->tkwin); + x = Tk_InternalBorderLeft(pwPtr->tkwin); sashHeight = pwPtr->sashWidth; sashWidth = Tk_Width(pwPtr->tkwin) - - (2 * Tk_InternalBorderWidth(pwPtr->tkwin)); + (2 * Tk_InternalBorderLeft(pwPtr->tkwin)); } if (sashWidth < 1) { @@ -3053,7 +3053,7 @@ PanedWindowIdentifyCoords( } else { sashHeight = Tk_ReqHeight(pwPtr->tkwin); } - sashHeight -= 2 * Tk_InternalBorderWidth(pwPtr->tkwin); + sashHeight -= 2 * Tk_InternalBorderLeft(pwPtr->tkwin); if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { sashWidth = pwPtr->handleSize; lpad = (pwPtr->handleSize - pwPtr->sashWidth) / 2; @@ -3081,7 +3081,7 @@ PanedWindowIdentifyCoords( } else { sashWidth = Tk_ReqWidth(pwPtr->tkwin); } - sashWidth -= 2 * Tk_InternalBorderWidth(pwPtr->tkwin); + sashWidth -= 2 * Tk_InternalBorderLeft(pwPtr->tkwin); lpad = rpad = 0; } diff --git a/macosx/Tk.xcode/project.pbxproj b/macosx/Tk.xcode/project.pbxproj index eee37a2..f919a71 100644 --- a/macosx/Tk.xcode/project.pbxproj +++ b/macosx/Tk.xcode/project.pbxproj @@ -1215,13 +1215,11 @@ F966BC9808F27A3E005CB29B /* makefile.bc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.bc; sourceTree = ""; }; F966BC9908F27A3E005CB29B /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = ""; }; F966BC9A08F27A3E005CB29B /* makefile.vc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.vc; sourceTree = ""; }; - F966BC9B08F27A3E005CB29B /* mkd.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mkd.bat; sourceTree = ""; }; F966BC9C08F27A3E005CB29B /* nmakehlp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nmakehlp.c; sourceTree = ""; }; F966BCEE08F27A3E005CB29B /* tk.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk.rc; sourceTree = ""; }; F966BCEF08F27A3E005CB29B /* tk_base.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk_base.rc; sourceTree = ""; }; F966BCF208F27A3E005CB29B /* wish.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = wish.rc; sourceTree = ""; }; F966BCF308F27A3E005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; - F966BCF408F27A3E005CB29B /* rmd.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rmd.bat; sourceTree = ""; }; F966BCF508F27A3F005CB29B /* rules.vc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rules.vc; sourceTree = ""; }; F966BCF608F27A3F005CB29B /* stubs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stubs.c; sourceTree = ""; }; F966BCF708F27A3F005CB29B /* tcl.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tcl.m4; sourceTree = ""; }; @@ -2794,7 +2792,6 @@ F966BC9808F27A3E005CB29B /* makefile.bc */, F966BC9908F27A3E005CB29B /* Makefile.in */, F966BC9A08F27A3E005CB29B /* makefile.vc */, - F966BC9B08F27A3E005CB29B /* mkd.bat */, F966BC9C08F27A3E005CB29B /* nmakehlp.c */, F966BC9D08F27A3E005CB29B /* rc */, F966BCF308F27A3E005CB29B /* README */, diff --git a/macosx/Tk.xcodeproj/project.pbxproj b/macosx/Tk.xcodeproj/project.pbxproj index 2f7edba..a873432 100644 --- a/macosx/Tk.xcodeproj/project.pbxproj +++ b/macosx/Tk.xcodeproj/project.pbxproj @@ -1215,13 +1215,11 @@ F966BC9808F27A3E005CB29B /* makefile.bc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.bc; sourceTree = ""; }; F966BC9908F27A3E005CB29B /* Makefile.in */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = Makefile.in; sourceTree = ""; }; F966BC9A08F27A3E005CB29B /* makefile.vc */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; path = makefile.vc; sourceTree = ""; }; - F966BC9B08F27A3E005CB29B /* mkd.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mkd.bat; sourceTree = ""; }; F966BC9C08F27A3E005CB29B /* nmakehlp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nmakehlp.c; sourceTree = ""; }; F966BCEE08F27A3E005CB29B /* tk.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk.rc; sourceTree = ""; }; F966BCEF08F27A3E005CB29B /* tk_base.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tk_base.rc; sourceTree = ""; }; F966BCF208F27A3E005CB29B /* wish.rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = wish.rc; sourceTree = ""; }; F966BCF308F27A3E005CB29B /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; - F966BCF408F27A3E005CB29B /* rmd.bat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rmd.bat; sourceTree = ""; }; F966BCF508F27A3F005CB29B /* rules.vc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rules.vc; sourceTree = ""; }; F966BCF608F27A3F005CB29B /* stubs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stubs.c; sourceTree = ""; }; F966BCF708F27A3F005CB29B /* tcl.m4 */ = {isa = PBXFileReference; explicitFileType = text.script.sh; fileEncoding = 4; path = tcl.m4; sourceTree = ""; }; @@ -2794,11 +2792,9 @@ F966BC9808F27A3E005CB29B /* makefile.bc */, F966BC9908F27A3E005CB29B /* Makefile.in */, F966BC9A08F27A3E005CB29B /* makefile.vc */, - F966BC9B08F27A3E005CB29B /* mkd.bat */, F966BC9C08F27A3E005CB29B /* nmakehlp.c */, F966BC9D08F27A3E005CB29B /* rc */, F966BCF308F27A3E005CB29B /* README */, - F966BCF408F27A3E005CB29B /* rmd.bat */, F966BCF508F27A3F005CB29B /* rules.vc */, F966BCF608F27A3F005CB29B /* stubs.c */, F966BCF708F27A3F005CB29B /* tcl.m4 */, diff --git a/win/mkd.bat b/win/mkd.bat deleted file mode 100644 index 1bd5ccb..0000000 --- a/win/mkd.bat +++ /dev/null @@ -1,12 +0,0 @@ -@echo off - -if exist %1\nul goto end - -md %1 -if errorlevel 1 goto end - -echo Created directory %1 - -:end - - diff --git a/win/rmd.bat b/win/rmd.bat deleted file mode 100644 index 820b76f..0000000 --- a/win/rmd.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -if not exist %1\nul goto end - -echo Removing directory %1 - -if "%OS%" == "Windows_NT" goto winnt - -deltree /y %1 -if errorlevel 1 goto end -goto success - -:winnt -rmdir /s /q %1 -if errorlevel 1 goto end - -:success -echo Deleted directory %1 - -:end diff --git a/win/rules.vc b/win/rules.vc index 2cd711b..fbbe705 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -33,7 +33,6 @@ _INSTALLDIR = $(INSTALLDIR:/=\) # "delete all" method. #---------------------------------------------------------- -!if "$(OS)" == "Windows_NT" RMDIR = rmdir /S /Q ERRNULL = 2>NUL !if ![ver | find "4.0" > nul] @@ -43,13 +42,6 @@ COPY = copy >NUL CPY = xcopy /i /y >NUL COPY = copy /y >NUL !endif -!else # "$(OS)" != "Windows_NT" -CPY = xcopy /i >_JUNK.OUT # On Win98 NUL does not work here. -COPY = copy >_JUNK.OUT # On Win98 NUL does not work here. -RMDIR = deltree /Y -NULL = \NUL # Used in testing directory existence -ERRNULL = >NUL # Win9x shell cannot redirect stderr -!endif MKDIR = mkdir #------------------------------------------------------------------------------ @@ -405,14 +397,14 @@ TCL_COMPILE_DEBUG = 0 #---------------------------------------------------------- !if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"] -TCL_NO_DEPRECATED = 0 +TK_NO_DEPRECATED = 0 WARNINGS = -W3 !else !if [nmakehlp -f $(CHECKS) "nodep"] !message *** Doing nodep check -TCL_NO_DEPRECATED = 1 +TK_NO_DEPRECATED = 1 !else -TCL_NO_DEPRECATED = 0 +TK_NO_DEPRECATED = 0 !endif !if [nmakehlp -f $(CHECKS) "fullwarn"] !message *** Doing full warnings check @@ -451,7 +443,7 @@ This compiler does not support profile guided optimization. # Set our defines now armed with our options. #---------------------------------------------------------- -OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS +OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS -DTCL_NO_DEPRECATED !if $(TCL_MEM_DEBUG) OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG @@ -468,8 +460,8 @@ OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1 !if $(STATIC_BUILD) OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD !endif -!if $(TCL_NO_DEPRECATED) -OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED +!if $(TK_NO_DEPRECATED) +OPTDEFINES = $(OPTDEFINES) -DTK_NO_DEPRECATED !endif !if !$(DEBUG) -- cgit v0.12 From 565d1642f3eabd3b4e7a17c4aec1743facb416ba Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 23 Jan 2017 14:52:54 +0000 Subject: more typos --- generic/tkTest.c | 2 +- generic/tkWindow.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index e23be36..1f801be 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -452,7 +452,7 @@ TestcursorObjCmd( * A standard Tcl result. * * Side effects: - * All the intepreters created by previous calls to "testnewapp" get + * All the interpreters created by previous calls to "testnewapp" get * deleted. * *---------------------------------------------------------------------- diff --git a/generic/tkWindow.c b/generic/tkWindow.c index f02db35..3b3b025 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -943,7 +943,7 @@ TkCreateMainWindow( } /* - * Set variables for the intepreter. + * Set variables for the interpreter. */ Tcl_SetVar2(interp, "tk_patchLevel", NULL, TK_PATCH_LEVEL, TCL_GLOBAL_ONLY); -- cgit v0.12 From 66e41a71e3b7254f83641c7a1d512bfa94c45d40 Mon Sep 17 00:00:00 2001 From: pspjuth Date: Wed, 25 Jan 2017 22:05:51 +0000 Subject: Fix [140ea8ab38]: Long text lines are not drawn on Windows. --- win/tkWinFont.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/win/tkWinFont.c b/win/tkWinFont.c index f209716..1292772 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -1307,7 +1307,15 @@ MultiFontTextOut( for (p = source; p < end; ) { next = p + Tcl_UtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); - if (thisSubFontPtr != lastSubFontPtr) { + + /* + * The drawing API has a limit of 32767 pixels in one go. + * To avoid spending time on a rare case we do not measure each char, + * instead we limit to drawing chunks of 200 bytes since that works + * well in practice. + */ + + if ((thisSubFontPtr != lastSubFontPtr) || (p-source > 200)) { if (p > source) { familyPtr = lastSubFontPtr->familyPtr; Tcl_UtfToExternalDString(familyPtr->encoding, source, -- cgit v0.12 From d033d601736ea26760f95cc30695c80d4d19bafe Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 28 Jan 2017 17:37:29 +0000 Subject: Fixed [c0dbdd3ff3]: Tk Compatibility Fonts block access to system fonts --- win/tkWinFont.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 9a32227..c01dc3f 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -2528,22 +2528,6 @@ FamilyExists( int result; Tcl_DString faceString; - /* - * Just immediately rule out the following fonts, because they look so - * ugly on windows. The caller's fallback mechanism will cause the - * corresponding appropriate TrueType fonts to be selected. - */ - - if (strcasecmp(faceName, "Courier") == 0) { - return 0; - } - if (strcasecmp(faceName, "Times") == 0) { - return 0; - } - if (strcasecmp(faceName, "Helvetica") == 0) { - return 0; - } - Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &faceString); /* -- cgit v0.12 From ac3c1f125c104ab506961d6653f0de098a056686 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 28 Jan 2017 17:38:11 +0000 Subject: Make tests pass again after fixing [c0dbdd3ff3]: Tk Compatibility Fonts block access to system fonts --- tests/entry.test | 18 ++++++++++++++---- tests/font.test | 6 +++--- tests/spinbox.test | 23 +++++++++++++++++++---- tests/textDisp.test | 2 +- tests/textWind.test | 4 ++-- tests/winFont.test | 6 +++--- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/tests/entry.test b/tests/entry.test index eeebe5d..785dd0b 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -2305,10 +2305,20 @@ test entry-8.18 {DeleteChars procedure} -setup { .e insert 0 "xyzzy" update .e delete 2 4 - winfo reqwidth .e -} -cleanup { - destroy .e -} -result {31} + # To check that deletion actually happened we measure the new width + # of the widget, based on the measuring width of the remaining text ("xyy") + # in the widget. For that purpose we have to mirror the code in tkEntry.c + # for computation of the reqwidth + # note: XPAD corresponds to the hardcoded #define XPAD 1 + set XPAD 1 + set expected [expr { [font measure [.e cget -font] "xyy"] \ + + 2 * ( [.e cget -borderwidth] + \ + [.e cget -highlightthickness] + $XPAD ) } ] + expr {[winfo reqwidth .e] == $expected} +} -cleanup { + destroy .e + unset XPAD expected +} -result {1} test entry-9.1 {EntryValueChanged procedure} -setup { unset -nocomplain x diff --git a/tests/font.test b/tests/font.test index 7e37698..b8c0144 100644 --- a/tests/font.test +++ b/tests/font.test @@ -141,7 +141,7 @@ test font-4.9 {font command: actual} -constraints {unix noExceed} -body { test font-4.10 {font command: actual} -constraints win -body { # (objc > 3) so objPtr = objv[3 + skip] font actual {-family times} -family -} -result {Times New Roman} +} -result {times} test font-4.11 {font command: bad option} -body { font actual xyz -style } -returnCodes error -result {bad option "-style": must be -family, -size, -weight, -slant, -underline, or -overstrike} @@ -153,7 +153,7 @@ test font-4.13 {font command: actual} -body { } -match glob -result {*} test font-4.14 {font command: actual} -constraints win -body { font actual {-family times} -family -- \ud800\udc00 -} -result {Times New Roman} +} -result {times} test font-4.15 {font command: actual} -body { font actual {-family times} -- \udc00\ud800 } -returnCodes 1 -match glob -result {expected a single character but got "*"} @@ -2345,7 +2345,7 @@ test font-45.1 {TkFontGetAliasList: no match} -body { } -result [font actual {-size 10} -family] test font-45.2 {TkFontGetAliasList: match} -constraints win -body { font actual {times 10} -family -} -result {Times New Roman} +} -result {times} test font-45.3 {TkFontGetAliasList: match} -constraints {unix noExceed} -body { # can fail on Unix systems that have a real "times new roman" font font actual {{times new roman} 10} -family diff --git a/tests/spinbox.test b/tests/spinbox.test index 206a61d..1f2bdac 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -2607,10 +2607,25 @@ test spinbox-8.18 {DeleteChars procedure} -setup { .e insert 0 "xyzzy" update .e delete 2 4 - winfo reqwidth .e -} -cleanup { - destroy .e -} -result {42} + # To check that deletion actually happened we measure the new width + # of the widget, based on the measuring width of the remaining text ("xyy") + # in the widget. For that purpose we have to mirror the code in tkEntry.c + # for computation of the reqwidth + # note: XPAD corresponds to the hardcoded #define XPAD 1 + set XPAD 1 + set buttonWidth [expr { [font measure [.e cget -font] "0"] + 2 * (1 + $XPAD) }] + if {$buttonWidth < 11} { + set buttonWidth 11 + } + set expected [expr { [font measure [.e cget -font] "xyy"] \ + + 2 * ( [.e cget -borderwidth] + \ + [.e cget -highlightthickness] + $XPAD ) \ + + $buttonWidth } ] + expr {[winfo reqwidth .e] == $expected} +} -cleanup { + destroy .e + unset XPAD buttonWidth expected +} -result {1} test spinbox-9.1 {SpinboxValueChanged procedure} -setup { unset -nocomplain x diff --git a/tests/textDisp.test b/tests/textDisp.test index 5393533..c413b40 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -41,7 +41,7 @@ catch {destroy .f .t} frame .f -width 100 -height 20 pack append . .f left -set fixedFont {Courier -12} +set fixedFont {"Courier New" -12} # 15 on XP, 13 on Solaris 8 set fixedHeight [font metrics $fixedFont -linespace] # 7 on all platforms diff --git a/tests/textWind.test b/tests/textWind.test index b0359f9..f5a5152 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -16,7 +16,7 @@ tcltest::loadTestedCommands option add *Text.borderWidth 2 option add *Text.highlightThickness 2 -option add *Text.font {Courier -12} +option add *Text.font {"Courier New" -12} deleteWindows @@ -27,7 +27,7 @@ update .t debug on # 15 on XP, 13 on Solaris 8 -set fixedHeight [font metrics {Courier -12} -linespace] +set fixedHeight [font metrics {"Courier New" -12} -linespace] set fixedDiff [expr {$fixedHeight - 13}] ;# 2 on XP set color [expr {[winfo depth .t] > 1 ? "green" : "black"}] diff --git a/tests/winFont.test b/tests/winFont.test index 08a53ff..93aeca9 100644 --- a/tests/winFont.test +++ b/tests/winFont.test @@ -71,7 +71,7 @@ test winfont-2.7 {TkpGetFontFromAttributes procedure: Times fonts} -constraints lappend x [font actual {-family "Times"} -family] lappend x [font actual {-family "New York"} -family] lappend x [font actual {-family "Times New Roman"} -family] -} -result {{Times New Roman} {Times New Roman} {Times New Roman}} +} -result {Times Times {Times New Roman}} test winfont-2.8 {TkpGetFontFromAttributes procedure: Courier fonts} -constraints { win } -setup { @@ -80,7 +80,7 @@ test winfont-2.8 {TkpGetFontFromAttributes procedure: Courier fonts} -constraint lappend x [font actual {-family "Courier"} -family] lappend x [font actual {-family "Monaco"} -family] lappend x [font actual {-family "Courier New"} -family] -} -result {{Courier New} {Courier New} {Courier New}} +} -result {Courier Courier {Courier New}} test winfont-2.9 {TkpGetFontFromAttributes procedure: Helvetica fonts} -constraints { win } -setup { @@ -89,7 +89,7 @@ test winfont-2.9 {TkpGetFontFromAttributes procedure: Helvetica fonts} -constrai lappend x [font actual {-family "Helvetica"} -family] lappend x [font actual {-family "Geneva"} -family] lappend x [font actual {-family "Arial"} -family] -} -result {Arial Arial Arial} +} -result {Helvetica Helvetica Arial} test winfont-2.10 {TkpGetFontFromAttributes procedure: fallback} -constraints { win } -body { -- cgit v0.12 From 161ab94f1c1e0e903cd217f89ff6981d9cd74923 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 29 Jan 2017 16:48:38 +0000 Subject: Remove superfluous 'textfonts' constraint in textDisp-20.1,2,3,4,5 --- tests/textDisp.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index 8342c46..44e3edc 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2873,28 +2873,28 @@ for {set i 2} {$i <= 200} {incr i} { .t configure -wrap word .t delete 50.0 51.0 .t insert 50.0 "This is a long line, one that will wrap around twice.\n" -test textDisp-20.1 {FindDLine} {textfonts} { +test textDisp-20.1 {FindDLine} { .t yview 48.0 list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \ [.t dlineinfo 58.0] } [list {} {} [list 3 [expr {$fixedDiff + 16}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] -test textDisp-20.2 {FindDLine} {textfonts} { +test textDisp-20.2 {FindDLine} { .t yview 100.0 .t yview -pickplace 53.0 list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.21] } [list [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {-1 - $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {12 + $fixedDiff/2}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]] -test textDisp-20.3 {FindDLine} {textfonts} { +test textDisp-20.3 {FindDLine} { .t yview 100.0 .t yview 49.0 list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 57.0] } [list [list 3 [expr {$fixedDiff + 16}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {2*$fixedDiff + 29}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] -test textDisp-20.4 {FindDLine} {textfonts} { +test textDisp-20.4 {FindDLine} { .t yview 100.0 .t yview 42.0 list [.t dlineinfo 50.0] [.t dlineinfo 50.24] [.t dlineinfo 50.40] } [list [list 3 [expr {8*$fixedDiff + 107}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 133 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] .t config -wrap none -test textDisp-20.5 {FindDLine} {textfonts} { +test textDisp-20.5 {FindDLine} { .t yview 100.0 .t yview 48.0 list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40] -- cgit v0.12 From 0691533b9281b179d99856732c3eb28f6a4256cf Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 1 Feb 2017 21:09:34 +0000 Subject: Remove old pack syntax from the scripts of the Tk test suite --- tests/focusTcl.test | 8 ++++---- tests/pack.test | 4 ++-- tests/text.test | 30 +++++++++++++++--------------- tests/textDisp.test | 6 +++--- tests/textIndex.test | 6 +++--- tests/textMark.test | 2 +- tests/textTag.test | 2 +- tests/textWind.test | 2 +- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/focusTcl.test b/tests/focusTcl.test index ef848bb..0e457a6 100644 --- a/tests/focusTcl.test +++ b/tests/focusTcl.test @@ -402,7 +402,7 @@ test focusTcl-5.4 {tkFocusOK procedure, -takefocus ""} -body { test focusTcl-5.5 {tkFocusOK procedure, -takefocus "", not mapped} -body { setup1 . .b.x configure -takefocus "" - pack unpack .b.x + pack forget .b.x update tk_focusNext .b } -cleanup { @@ -413,7 +413,7 @@ test focusTcl-5.6 {tkFocusOK procedure, -takefocus "", not mapped} -body { foreach w {.b.x .b.y .b.z} { $w configure -takefocus "" } - pack unpack .b + pack forget .b update tk_focusNext .b } -cleanup { @@ -422,7 +422,7 @@ test focusTcl-5.6 {tkFocusOK procedure, -takefocus "", not mapped} -body { test focusTcl-5.7 {tkFocusOK procedure, -takefocus "", not mapped} -body { setup1 . .b.y configure -takefocus 1 - pack unpack .b.y + pack forget .b.y update tk_focusNext .b.x } -cleanup { @@ -432,7 +432,7 @@ test focusTcl-5.8 {tkFocusOK procedure, -takefocus "", not mapped} -body { proc always args {return 1} setup1 . .b.y configure -takefocus always - pack unpack .b.y + pack forget .b.y update tk_focusNext .b.x } -cleanup { diff --git a/tests/pack.test b/tests/pack.test index eac1562..efb262b 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1403,7 +1403,7 @@ test pack-15.1 {managing geometry with -in option} -setup { pack .pack.b -in .pack.f.f2 update set result [winfo geom .pack.b] - pack unpack .pack.a + pack forget .pack.a update lappend result [winfo geom .pack.b] } -cleanup { @@ -1441,7 +1441,7 @@ test pack-15.3 {managing geometry with -in option} -setup { pack .pack.b -in .pack.f.f2 update set result [winfo ismapped .pack.b] - pack unpack .pack.f + pack forget .pack.f update lappend result [winfo ismapped .pack.b] } -cleanup { diff --git a/tests/text.test b/tests/text.test index 6812855..edd2a6e 100644 --- a/tests/text.test +++ b/tests/text.test @@ -2631,7 +2631,7 @@ test text-10.37 {TextWidgetCmd procedure, "count" option} -setup { } -result {3} test text-10.38 {TextWidgetCmd procedure, "count" option} -setup { text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both } -body { .t configure -width 20 -height 10 update @@ -2727,7 +2727,7 @@ test text-9.2.47 {TextWidgetCmd procedure, "count" option} -setup { test text-11.1 {counting with tag priority eliding} -setup { text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both } -body { .t insert end "hello" .t configure -wrap none @@ -2744,7 +2744,7 @@ test text-11.1 {counting with tag priority eliding} -setup { } -result {0 1 2 3 4 5 5 6} test text-11.2 {counting with tag priority eliding} -setup { text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both } -body { .t insert end "hello" .t tag configure elide1 -elide 0 @@ -2856,7 +2856,7 @@ test text-11.7 {counting with tag priority eliding} -setup { } -result {5 5} test text-11.8 {counting with tag priority eliding} -setup { text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both set res {} } -body { .t insert end "hello" @@ -2882,7 +2882,7 @@ test text-11.8 {counting with tag priority eliding} -setup { } -result {0 0 0 0 3 2 1 1} test text-11.9 {counting with tag priority eliding} -setup { text .t -font {Courier -12} -borderwidth 2 -highlightthickness 2 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both set res {} } -body { .t tag configure WELCOME -elide 1 @@ -3432,7 +3432,7 @@ test text-14.18 {ConfigureText procedure} -constraints fonts -setup { text .top.t -font {Courier -12} -borderwidth 2 -highlightthickness 2 } -body { .top.t configure -width 20 -height 10 - pack append .top .top.t top + pack .top.t update set geom [wm geometry .top] set x [string range $geom 0 [string first + $geom]] @@ -3449,7 +3449,7 @@ test text-14.19 {ConfigureText procedure} -setup { } -body { .top.t configure -width 20 -height 10 -setgrid 1 wm overrideredirect .top 1 - pack append .top .top.t top + pack .top.t wm geometry .top +0+0 update wm geometry .top @@ -3466,7 +3466,7 @@ test text-14.20 {ConfigureText procedure} -setup { } -body { .top.t configure -width 20 -height 10 -setgrid 1 wm overrideredirect .top 1 - pack append .top .top.t top + pack .top.t wm geometry .top +0+0 update set result [wm geometry .top] @@ -3756,7 +3756,7 @@ Line 4 test text-19.11 {DeleteChars procedure} -body { toplevel .top text .top.t -width 20 -height 5 - pack append .top .top.t top + pack .top.t wm geometry .top +0+0 .top.t insert 1.0 "abc\n123\nx\ny\nz\nq\nr\ns" update @@ -3768,7 +3768,7 @@ test text-19.11 {DeleteChars procedure} -body { test text-19.12 {DeleteChars procedure} -body { toplevel .top text .top.t -width 20 -height 5 - pack append .top .top.t top + pack .top.t wm geometry .top +0+0 .top.t insert 1.0 "abc\n123\nx\ny\nz\nq\nr\ns" .top.t yview 3.0 @@ -3841,7 +3841,7 @@ test text-19.16 {DeleteChars procedure, updates affecting topIndex} -setup { test text-20.1 {TextFetchSelection procedure} -setup { text .t -width 20 -height 10 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both update } -body { foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} { @@ -3856,7 +3856,7 @@ b.0b.1b.2b.3b.4 c.0c} test text-20.2 {TextFetchSelection procedure} -setup { text .t -width 20 -height 10 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both update } -body { foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} { @@ -3876,7 +3876,7 @@ b.0b.1b.2b.3b.4 c.0c} test text-20.3 {TextFetchSelection procedure} -setup { text .t -width 20 -height 10 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both update } -body { foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} { @@ -3890,7 +3890,7 @@ test text-20.3 {TextFetchSelection procedure} -setup { } -result {m} test text-20.4 {TextFetchSelection procedure} -setup { text .t -width 20 -height 10 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both update } -body { foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} { @@ -3910,7 +3910,7 @@ test text-20.4 {TextFetchSelection procedure} -setup { cj.0j.1j.2j.3j.4m} test text-20.5 {TextFetchSelection procedure, long selections} -setup { text .t -width 20 -height 10 - pack append . .t {top expand fill} + pack .t -expand 1 -fill both update set x "" } -body { diff --git a/tests/textDisp.test b/tests/textDisp.test index 8342c46..a3a4553 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -39,7 +39,7 @@ option add *Text.highlightThickness $twht catch {destroy .f .t} frame .f -width 100 -height 20 -pack append . .f left +pack .f -side left set fixedFont {Courier -12} # 15 on XP, 13 on Solaris 8 @@ -65,7 +65,7 @@ set bigAscent [font metrics $bigFont -ascent] set ascentDiff [expr {$bigAscent - $fixedAscent}] text .t -font $fixedFont -width 20 -height 10 -yscrollcommand scroll -pack append . .t {top expand fill} +pack .t -expand 1 -fill both .t tag configure big -font $bigFont .t debug on wm geometry . {} @@ -599,7 +599,7 @@ test textDisp-4.6 {UpdateDisplayInfo, tiny window} { wm overrideredirect . 1 } frame .f2 -width 20 -height 100 - pack before .f .f2 top + pack .f2 -before .f wm geom . 103x103 update .t configure -wrap none -borderwidth 2 diff --git a/tests/textIndex.test b/tests/textIndex.test index 83a249e..7d44516 100644 --- a/tests/textIndex.test +++ b/tests/textIndex.test @@ -13,7 +13,7 @@ namespace import -force tcltest::test catch {destroy .t} text .t -font {Courier -12} -width 20 -height 10 -pack append . .t {top expand fill} +pack .t -expand 1 -fill both update .t debug on wm geometry . {} @@ -714,7 +714,7 @@ test textIndex-18.1 {Object indices don't cache mark names} { } {3.4 3.0 1.0} frame .f -width 100 -height 20 -pack append . .f left +pack .f -side left set fixedFont {Courier -12} set fixedHeight [font metrics $fixedFont -linespace] @@ -724,7 +724,7 @@ set varFont {Times -14} set bigFont {Helvetica -24} destroy .t text .t -font $fixedFont -width 20 -height 10 -wrap char -pack append . .t {top expand fill} +pack .t -expand 1 -fill both .t tag configure big -font $bigFont .t debug on wm geometry . {} diff --git a/tests/textMark.test b/tests/textMark.test index edd0e92..bbf226e 100644 --- a/tests/textMark.test +++ b/tests/textMark.test @@ -13,7 +13,7 @@ tcltest::loadTestedCommands destroy .t text .t -width 20 -height 10 -pack append . .t {top expand fill} +pack .t -expand 1 -fill both update .t debug on wm geometry . {} diff --git a/tests/textTag.test b/tests/textTag.test index 88081d0..ddbaa3b 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -17,7 +17,7 @@ testConstraint haveCourier12 [expr {[catch { .t configure -font {Courier 12} }] == 0}] -pack append . .t {top expand fill} +pack .t -expand 1 -fill both update .t debug on diff --git a/tests/textWind.test b/tests/textWind.test index 27b7309..fd29e19 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -22,7 +22,7 @@ option add *Text.font {Courier -12} deleteWindows # Widget used in tests 1.* - 16.* text .t -width 30 -height 6 -bd 2 -highlightthickness 2 -pack append . .t {top expand fill} +pack .t -expand 1 -fill both update .t debug on -- cgit v0.12 From 57fc44c584797fe0a1f04d80fa255ad5e3339b86 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 8 Feb 2017 18:22:34 +0000 Subject: Fix [c492c96aa2]: Combobox arrow not grayed (alt, clam and default ttk themes) --- library/ttk/altTheme.tcl | 1 + library/ttk/clamTheme.tcl | 1 + library/ttk/defaults.tcl | 1 + 3 files changed, 3 insertions(+) diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl index e792539..9aa6061 100644 --- a/library/ttk/altTheme.tcl +++ b/library/ttk/altTheme.tcl @@ -64,6 +64,7 @@ namespace eval ttk::theme::alt { ttk::style configure TCombobox -padding 1 ttk::style map TCombobox -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] + ttk::style map TCombobox -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure ComboboxPopdownFrame \ -relief solid -borderwidth 1 diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index f4ad43b..b278e3f 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -111,6 +111,7 @@ namespace eval ttk::theme::clam { readonly $colors(-frame)] \ -foreground [list {readonly focus} $colors(-selectfg)] \ ; + ttk::style map TCombobox -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure ComboboxPopdownFrame \ -relief solid -borderwidth 1 diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl index 853ed20..f38a4a2 100644 --- a/library/ttk/defaults.tcl +++ b/library/ttk/defaults.tcl @@ -74,6 +74,7 @@ namespace eval ttk::theme::default { -relief sunken -fieldbackground white -padding 1 ttk::style map TEntry -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] + ttk::style map TCombobox -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure TCombobox -arrowsize 12 -padding 1 ttk::style map TCombobox -fieldbackground \ -- cgit v0.12 From cb619ed5ddc6047ebf6fff8c2c64a42c37e95926 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 9 Feb 2017 19:28:56 +0000 Subject: Group multiple [style map TCombobox] statements into a single instruction --- library/ttk/altTheme.tcl | 4 ++-- library/ttk/clamTheme.tcl | 3 +-- library/ttk/defaults.tcl | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl index 9aa6061..5630e6c 100644 --- a/library/ttk/altTheme.tcl +++ b/library/ttk/altTheme.tcl @@ -63,8 +63,8 @@ namespace eval ttk::theme::alt { [list readonly $colors(-frame) disabled $colors(-frame)] ttk::style configure TCombobox -padding 1 ttk::style map TCombobox -fieldbackground \ - [list readonly $colors(-frame) disabled $colors(-frame)] - ttk::style map TCombobox -arrowcolor [list disabled $colors(-disabledfg)] + [list readonly $colors(-frame) disabled $colors(-frame)] \ + -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure ComboboxPopdownFrame \ -relief solid -borderwidth 1 diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index b278e3f..808c365 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -110,8 +110,7 @@ namespace eval ttk::theme::clam { -fieldbackground [list {readonly focus} $colors(-selectbg) \ readonly $colors(-frame)] \ -foreground [list {readonly focus} $colors(-selectfg)] \ - ; - ttk::style map TCombobox -arrowcolor [list disabled $colors(-disabledfg)] + -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure ComboboxPopdownFrame \ -relief solid -borderwidth 1 diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl index f38a4a2..56e2176 100644 --- a/library/ttk/defaults.tcl +++ b/library/ttk/defaults.tcl @@ -74,11 +74,11 @@ namespace eval ttk::theme::default { -relief sunken -fieldbackground white -padding 1 ttk::style map TEntry -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] - ttk::style map TCombobox -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure TCombobox -arrowsize 12 -padding 1 ttk::style map TCombobox -fieldbackground \ - [list readonly $colors(-frame) disabled $colors(-frame)] + [list readonly $colors(-frame) disabled $colors(-frame)] \ + -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure TSpinbox -arrowsize 10 -padding {2 0 10 0} ttk::style map TSpinbox -fieldbackground \ -- cgit v0.12 From 1a74e9de135efaea49d48f7974960bc6e8426949 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 10 Feb 2017 11:38:55 +0000 Subject: Fix [7d967c68a09e07e355358af40f36dd5dd84c7022|7d967c68a0] follow-up: Tk applications segmentation fault when ibus-daemon IME is restarted. Patch by Brad Lanam. --- generic/tkWindow.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/generic/tkWindow.c b/generic/tkWindow.c index e4d696b..690a841 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -475,9 +475,6 @@ GetScreen( dispPtr->cursorFont = None; dispPtr->warpWindow = NULL; dispPtr->multipleAtom = None; -#ifdef TK_USE_INPUT_METHODS - dispPtr->ximGeneration = 0; -#endif /*TK_USE_INPUT_METHODS*/ /* * By default we do want to collapse motion events in @@ -656,6 +653,7 @@ TkAllocWindow( winPtr->flags = 0; winPtr->handlerList = NULL; #ifdef TK_USE_INPUT_METHODS + winPtr->ximGeneration = 0; winPtr->inputContext = NULL; #endif /* TK_USE_INPUT_METHODS */ winPtr->tagPtr = NULL; -- cgit v0.12 From 4a1828d3e7f328cce5d6b770ffbb6ea5a5373d0c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 13 Feb 2017 09:57:07 +0000 Subject: Make tk.h work unchanged with Tcl 9.0 (novem), account for possible missing TCL_STORAGE_CLASS definition. More internal use of size_t in stead of int. --- generic/tk.h | 4 ++++ generic/tkCmds.c | 7 +++---- generic/tkGC.c | 5 ++--- generic/tkImgBmap.c | 5 ++--- generic/tkVisual.c | 13 ++++++------- unix/tkUnixWm.c | 28 ++++++++++++---------------- 6 files changed, 29 insertions(+), 33 deletions(-) diff --git a/generic/tk.h b/generic/tk.h index 1d070d3..1cb10e2 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -105,6 +105,10 @@ extern "C" { #ifdef BUILD_tk #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT +#else +# ifndef TCL_STORAGE_CLASS +# define TCL_STORAGE_CLASS DLLIMPORT +# endif #endif /* diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 6196b17..93c1fb0 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -2068,14 +2068,13 @@ TkGetDisplayOf( * present. */ { const char *string; - int length; if (objc < 1) { return 0; } - string = Tcl_GetStringFromObj(objv[0], &length); - if ((length >= 2) && - (strncmp(string, "-displayof", (unsigned) length) == 0)) { + string = Tcl_GetString(objv[0]); + if ((objv[0]->length >= 2) && + (strncmp(string, "-displayof", objv[0]->length) == 0)) { if (objc < 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-displayof\" missing", -1)); diff --git a/generic/tkGC.c b/generic/tkGC.c index c424e30..55e5774 100644 --- a/generic/tkGC.c +++ b/generic/tkGC.c @@ -23,7 +23,7 @@ typedef struct { GC gc; /* Graphics context. */ Display *display; /* Display to which gc belongs. */ - int refCount; /* Number of active uses of gc. */ + size_t refCount; /* Number of active uses of gc. */ Tcl_HashEntry *valueHashPtr;/* Entry in valueTable (needed when deleting * this structure). */ } TkGC; @@ -312,8 +312,7 @@ Tk_FreeGC( Tcl_Panic("Tk_FreeGC received unknown gc argument"); } gcPtr = Tcl_GetHashValue(idHashPtr); - gcPtr->refCount--; - if (gcPtr->refCount == 0) { + if (gcPtr->refCount-- <= 1) { XFreeGC(gcPtr->display, gcPtr->gc); Tcl_DeleteHashEntry(gcPtr->valueHashPtr); Tcl_DeleteHashEntry(idHashPtr); diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index 0906673..1a9a86e 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -49,7 +49,7 @@ typedef struct BitmapMaster { */ typedef struct BitmapInstance { - int refCount; /* Number of instances that share this data + size_t refCount; /* Number of instances that share this data * structure. */ BitmapMaster *masterPtr; /* Pointer to master for image. */ Tk_Window tkwin; /* Window in which the instances will be @@ -951,8 +951,7 @@ ImgBmapFree( BitmapInstance *instancePtr = clientData; BitmapInstance *prevPtr; - instancePtr->refCount--; - if (instancePtr->refCount > 0) { + if (instancePtr->refCount-- > 1) { return; } diff --git a/generic/tkVisual.c b/generic/tkVisual.c index 8b0c155..6f6816d 100644 --- a/generic/tkVisual.c +++ b/generic/tkVisual.c @@ -46,7 +46,7 @@ static const VisualDictionary visualNames[] = { struct TkColormap { Colormap colormap; /* X's identifier for the colormap. */ Visual *visual; /* Visual for which colormap was allocated. */ - int refCount; /* How many uses of the colormap are still + size_t refCount; /* How many uses of the colormap are still * outstanding (calls to Tk_GetColormap minus * calls to Tk_FreeColormap). */ int shareable; /* 0 means this colormap was allocated by a @@ -137,7 +137,7 @@ Tk_GetVisual( for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == *colormapPtr) { - cmapPtr->refCount += 1; + cmapPtr->refCount++; break; } } @@ -324,7 +324,7 @@ Tk_GetVisual( cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->shareable && (cmapPtr->visual == visual)) { *colormapPtr = cmapPtr->colormap; - cmapPtr->refCount += 1; + cmapPtr->refCount++; goto done; } } @@ -427,7 +427,7 @@ Tk_GetColormap( for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == colormap) { - cmapPtr->refCount += 1; + cmapPtr->refCount++; } } return colormap; @@ -476,8 +476,7 @@ Tk_FreeColormap( for (prevPtr = NULL, cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; prevPtr = cmapPtr, cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == colormap) { - cmapPtr->refCount -= 1; - if (cmapPtr->refCount == 0) { + if (cmapPtr->refCount-- <= 1) { XFreeColormap(display, colormap); if (prevPtr == NULL) { dispPtr->cmapPtr = cmapPtr->nextPtr; @@ -534,7 +533,7 @@ Tk_PreserveColormap( for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == colormap) { - cmapPtr->refCount += 1; + cmapPtr->refCount++; return; } } diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 19ac86c..68ab6d6 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -1033,7 +1033,7 @@ Tk_WmObjCmd( WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT, WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM, WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT, WMOPT_WITHDRAW }; - int index, length; + int index; const char *argv1; TkWindow *winPtr; Tk_Window targetWin; @@ -1045,9 +1045,9 @@ Tk_WmObjCmd( return TCL_ERROR; } - argv1 = Tcl_GetStringFromObj(objv[1], &length); - if ((argv1[0] == 't') && (strncmp(argv1, "tracing", (size_t) length) == 0) - && (length >= 3)) { + argv1 = Tcl_GetString(objv[1]); + if ((argv1[0] == 't') && (strncmp(argv1, "tracing", objv[1]->length) == 0) + && (objv[1]->length >= 3)) { int wmTracing; if ((objc != 2) && (objc != 3)) { @@ -1457,7 +1457,6 @@ WmClientCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; - int length; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); @@ -1470,7 +1469,7 @@ WmClientCmd( } return TCL_OK; } - argv3 = Tcl_GetStringFromObj(objv[3], &length); + argv3 = Tcl_GetString(objv[3]); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); @@ -1486,7 +1485,7 @@ WmClientCmd( if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } - wmPtr->clientMachine = ckalloc(length + 1); + wmPtr->clientMachine = ckalloc(objv[3]->length + 1); strcpy(wmPtr->clientMachine, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XTextProperty textProp; @@ -2072,7 +2071,6 @@ WmGroupCmd( Tk_Window tkwin2; WmInfo *wmPtr2; const char *argv3; - int length; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); @@ -2084,7 +2082,7 @@ WmGroupCmd( } return TCL_OK; } - argv3 = Tcl_GetStringFromObj(objv[3], &length); + argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { wmPtr->hints.flags &= ~WindowGroupHint; if (wmPtr->leaderName != NULL) { @@ -2112,7 +2110,7 @@ WmGroupCmd( } wmPtr->hints.window_group = Tk_WindowId(wmPtr2->wrapperPtr); wmPtr->hints.flags |= WindowGroupHint; - wmPtr->leaderName = ckalloc(length + 1); + wmPtr->leaderName = ckalloc(objv[3]->length + 1); strcpy(wmPtr->leaderName, argv3); } UpdateHints(winPtr); @@ -2334,7 +2332,6 @@ WmIconnameCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; - int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); @@ -2349,8 +2346,8 @@ WmIconnameCmd( if (wmPtr->iconName != NULL) { ckfree(wmPtr->iconName); } - argv3 = Tcl_GetStringFromObj(objv[3], &length); - wmPtr->iconName = ckalloc(length + 1); + argv3 = Tcl_GetString(objv[3]); + wmPtr->iconName = ckalloc(objv[3]->length + 1); strcpy(wmPtr->iconName, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { UpdateTitle(winPtr); @@ -3471,7 +3468,6 @@ WmTitleCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; - int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); @@ -3487,8 +3483,8 @@ WmTitleCmd( if (wmPtr->title != NULL) { ckfree(wmPtr->title); } - argv3 = Tcl_GetStringFromObj(objv[3], &length); - wmPtr->title = ckalloc(length + 1); + argv3 = Tcl_GetString(objv[3]); + wmPtr->title = ckalloc(objv[3]->length + 1); strcpy(wmPtr->title, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { -- cgit v0.12 From 1e9b0fc3c284b29e0adaf439f2438d0246eb7838 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Feb 2017 13:56:17 +0000 Subject: Change some internal refCount's from int to size_t. --- generic/tkImgPhoto.h | 2 +- generic/tkInt.h | 4 ++-- tests/textDisp.test | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tkImgPhoto.h b/generic/tkImgPhoto.h index 36bc6cb..45fac88 100644 --- a/generic/tkImgPhoto.h +++ b/generic/tkImgPhoto.h @@ -201,7 +201,7 @@ struct PhotoInstance { * this particular colormap. */ PhotoInstance *nextPtr; /* Pointer to the next instance in the list of * instances associated with this master. */ - int refCount; /* Number of instances using this structure. */ + size_t refCount; /* Number of instances using this structure. */ Tk_Uid palette; /* Palette for these particular instances. */ double gamma; /* Gamma value for these instances. */ Tk_Uid defaultPalette; /* Default palette to use if a palette is not diff --git a/generic/tkInt.h b/generic/tkInt.h index f00d833..3138ffc 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -478,7 +478,7 @@ typedef struct TkDisplay { #endif /* TK_USE_INPUT_METHODS */ Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ - int refCount; /* Reference count of how many Tk applications + size_t refCount; /* Reference count of how many Tk applications * are using this display. Used to clean up * the display when we no longer have any Tk * applications using it. */ @@ -582,7 +582,7 @@ typedef struct TkEventHandler { */ typedef struct TkMainInfo { - int refCount; /* Number of windows whose "mainPtr" fields + size_t refCount; /* Number of windows whose "mainPtr" fields * point here. When this becomes zero, can * free up the structure (the reference count * is zero because windows can get deleted in diff --git a/tests/textDisp.test b/tests/textDisp.test index 9a71d96..f2eb47d 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2878,7 +2878,7 @@ test textDisp-20.1 {FindDLine} { list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \ [.t dlineinfo 58.0] } [list {} {} [list 3 [expr {$fixedDiff + 16}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}] -test textDisp-20.2 {FindDLine} { +test textDisp-20.2 {FindDLine} { .t yview 100.0 .t yview -pickplace 53.0 list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.21] -- cgit v0.12 From 6214efc0cc2054edbeaf5d08ac8c9a1864797d4a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 16 Feb 2017 11:05:09 +0000 Subject: If compiled with TK_NO_DEPRECATED, remove support for old "set" and "get" syntax on scrollbar. --- generic/tkScrollbar.c | 13 +++++++++---- generic/tkScrollbar.h | 6 ++++++ tests/scrollbar.test | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index 5017d30..9c1ceb8 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -179,10 +179,12 @@ Tk_ScrollbarObjCmd( scrollPtr->sliderLast = 0; scrollPtr->activeField = 0; scrollPtr->activeRelief = TK_RELIEF_RAISED; +#ifndef TK_NO_DEPRECATED scrollPtr->totalUnits = 0; scrollPtr->windowUnits = 0; scrollPtr->firstUnit = 0; scrollPtr->lastUnit = 0; +#endif /* TK_NO_DEPRECATED */ scrollPtr->firstFraction = 0.0; scrollPtr->lastFraction = 0.0; scrollPtr->cursor = None; @@ -377,10 +379,13 @@ ScrollbarWidgetObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "get"); goto error; } +#ifndef TK_NO_DEPRECATED if (scrollPtr->flags & NEW_STYLE_COMMANDS) { +#endif /* TK_NO_DEPRECATED */ resObjs[0] = Tcl_NewDoubleObj(scrollPtr->firstFraction); resObjs[1] = Tcl_NewDoubleObj(scrollPtr->lastFraction); Tcl_SetObjResult(interp, Tcl_NewListObj(2, resObjs)); +#ifndef TK_NO_DEPRECATED } else { resObjs[0] = Tcl_NewIntObj(scrollPtr->totalUnits); resObjs[1] = Tcl_NewIntObj(scrollPtr->windowUnits); @@ -388,6 +393,7 @@ ScrollbarWidgetObjCmd( resObjs[3] = Tcl_NewIntObj(scrollPtr->lastUnit); Tcl_SetObjResult(interp, Tcl_NewListObj(4, resObjs)); } +#endif /* TK_NO_DEPRECATED */ break; } case COMMAND_IDENTIFY: { @@ -413,8 +419,6 @@ ScrollbarWidgetObjCmd( break; } case COMMAND_SET: { - int totalUnits, windowUnits, firstUnit, lastUnit; - if (objc == 4) { double first, last; @@ -438,8 +442,10 @@ ScrollbarWidgetObjCmd( } else { scrollPtr->lastFraction = last; } +#ifndef TK_NO_DEPRECATED scrollPtr->flags |= NEW_STYLE_COMMANDS; } else if (objc == 6) { + int totalUnits, windowUnits, firstUnit, lastUnit; if (Tcl_GetIntFromObj(interp, objv[2], &totalUnits) != TCL_OK) { goto error; } @@ -477,10 +483,9 @@ ScrollbarWidgetObjCmd( scrollPtr->lastFraction = ((double) (lastUnit+1))/totalUnits; } scrollPtr->flags &= ~NEW_STYLE_COMMANDS; +#endif /* !TK_NO_DEPRECATED */ } else { Tcl_WrongNumArgs(interp, 1, objv, "set firstFraction lastFraction"); - Tcl_AppendResult(interp, " or \"", Tcl_GetString(objv[0]), - " set totalUnits windowUnits firstUnit lastUnit\"", NULL); goto error; } TkpComputeScrollbarGeometry(scrollPtr); diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h index b0cd085..66b12b8 100644 --- a/generic/tkScrollbar.h +++ b/generic/tkScrollbar.h @@ -96,6 +96,7 @@ typedef struct TkScrollbar { * the NEW_STYLE_COMMANDS flag is 0. */ +#ifndef TK_NO_DEPRECATED int totalUnits; /* Total dimension of application, in units. * Valid only if the NEW_STYLE_COMMANDS flag * isn't set. */ @@ -108,6 +109,9 @@ typedef struct TkScrollbar { int lastUnit; /* Index of last unit visible in window. * Valid only if the NEW_STYLE_COMMANDS flag * isn't set. */ +#else + int dummy1,dummy2,dummy3,dummy4; /* sizeof(TkScrollbar) should not depend on TK_NO_DEPRECATED */ +#endif /* TK_NO_DEPRECATED */ double firstFraction; /* Position of first visible thing in window, * specified as a fraction between 0 and * 1.0. */ @@ -153,7 +157,9 @@ typedef struct TkScrollbar { */ #define REDRAW_PENDING 1 +#ifndef TK_NO_DEPRECATED #define NEW_STYLE_COMMANDS 2 +#endif /* TK_NO_DEPRECATED */ #define GOT_FOCUS 4 /* diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 6d811dc..b7cdbc0 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -396,10 +396,10 @@ test scrollbar-3.70 {ScrollbarWidgetCmd procedure, "set" option} { } {100 50 30 30} test scrollbar-3.71 {ScrollbarWidgetCmd procedure, "set" option} { list [catch {.s set 1 2 3} msg] $msg -} {1 {wrong # args: should be ".s set firstFraction lastFraction" or ".s set totalUnits windowUnits firstUnit lastUnit"}} +} {1 {wrong # args: should be ".s set firstFraction lastFraction"}} test scrollbar-3.72 {ScrollbarWidgetCmd procedure, "set" option} { list [catch {.s set 1 2 3 4 5} msg] $msg -} {1 {wrong # args: should be ".s set firstFraction lastFraction" or ".s set totalUnits windowUnits firstUnit lastUnit"}} +} {1 {wrong # args: should be ".s set firstFraction lastFraction"}} test scrollbar-3.73 {ScrollbarWidgetCmd procedure} { list [catch {.s bogus} msg] $msg } {1 {bad option "bogus": must be activate, cget, configure, delta, fraction, get, identify, or set}} -- cgit v0.12 From 9439bbc72e66a54de76674374faf70c629eda920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ignacio=20Mar=C3=ADn?= Date: Fri, 3 Mar 2017 18:26:11 +0000 Subject: Patch on behalf of TheLemonMan that addresses bug [6b3644a4858f018cd08615d3d516b07d271fe2a]. --- generic/tkImgPNG.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index c6e3029..6e64afa 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -2245,10 +2245,10 @@ ApplyAlpha( p += offset; if (16 == pngPtr->bitDepth) { - register int channel; + register unsigned int channel; while (p < endPtr) { - channel = (unsigned char) + channel = (unsigned int) (((p[0] << 8) | p[1]) * pngPtr->alpha); *p++ = (unsigned char) (channel >> 8); -- cgit v0.12 -- cgit v0.12