From 7eb4c1166891ec63b165278baa86e5f4bd23aca8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 11 Feb 2014 14:56:03 +0000 Subject: [3f456a5bb9]: Patches for listbox right justify --- generic/tkListbox.c | 108 +++++++++++++++++++++++++++++++++++++++++++++-- library/demos/states.tcl | 9 ++++ macosx/tkMacOSXDefault.h | 1 + unix/tkUnixDefault.h | 1 + win/tkWinDefault.h | 1 + 5 files changed, 116 insertions(+), 4 deletions(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 437973a..22bb354 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -165,6 +165,8 @@ typedef struct { Pixmap gray; /* Pixmap for displaying disabled text. */ int flags; /* Various flag bits: see below for * definitions. */ + Tk_Justify justify; /* Justification */ + int oldMaxOffset; /* Used in scrolling for right/center justification */ } Listbox; /* @@ -308,6 +310,8 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_STRING, "-listvariable", "listVariable", "Variable", DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0} }; @@ -435,6 +439,7 @@ static char * ListboxListVarProc(ClientData clientData, const char *name2, int flags); static void MigrateHashEntries(Tcl_HashTable *table, int first, int last, int offset); +static int GetMaxOffset(Listbox *listPtr); /* * The structure below defines button class behavior by means of procedures @@ -545,6 +550,8 @@ Tk_ListboxObjCmd( listPtr->cursor = None; listPtr->state = STATE_NORMAL; listPtr->gray = None; + listPtr->justify = TK_JUSTIFY_LEFT; + listPtr->oldMaxOffset = 0; /* * Keep a hold of the associated tkwin until we destroy the listbox, @@ -571,6 +578,13 @@ Tk_ListboxObjCmd( return TCL_ERROR; } + if (listPtr->justify == TK_JUSTIFY_RIGHT) { + listPtr->xOffset = GetMaxOffset(listPtr); + } else if (listPtr->justify == TK_JUSTIFY_CENTER) { + listPtr->xOffset = GetMaxOffset(listPtr) / 2; + listPtr->xOffset -= listPtr->xOffset % listPtr->xScrollUnit; + } + Tcl_SetObjResult(interp, TkNewWindowObj(listPtr->tkwin)); return TCL_OK; } @@ -1110,7 +1124,7 @@ ListboxBboxSubCmd( Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); - x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; + x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; y = ((index - listPtr->topIndex)*listPtr->lineHeight) + listPtr->inset + listPtr->selBorderWidth; results[0] = Tcl_NewIntObj(x); @@ -1837,6 +1851,7 @@ DisplayListbox( * or right edge of the listbox is * off-screen. */ Pixmap pixmap; + int totalLength, height; listPtr->flags &= ~REDRAW_PENDING; if (listPtr->flags & LISTBOX_DELETED) { @@ -2055,12 +2070,22 @@ DisplayListbox( /* * Draw the actual text of this item. */ + Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); + stringRep = Tcl_GetStringFromObj(curElement, &stringLen); + Tk_ComputeTextLayout(listPtr->tkfont, + stringRep, stringLen, 0, + listPtr->justify, TK_IGNORE_NEWLINES, &totalLength, &height); Tk_GetFontMetrics(listPtr->tkfont, &fm); y += fm.ascent + listPtr->selBorderWidth; - x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; - Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); - stringRep = Tcl_GetStringFromObj(curElement, &stringLen); + + if (listPtr->justify == TK_JUSTIFY_LEFT) { + x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; + } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { + x = width - totalLength - listPtr->inset - listPtr->selBorderWidth - listPtr->xOffset + GetMaxOffset(listPtr) - 1; + } else { + x = (width + GetMaxOffset(listPtr))/2 - totalLength/2 - listPtr->xOffset; + } Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont, stringRep, stringLen, x, y); @@ -2581,6 +2606,7 @@ ListboxEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { + int tmpOffset, tmpOffset2, maxOffset; Listbox *listPtr = clientData; if (eventPtr->type == Expose) { @@ -2612,6 +2638,53 @@ ListboxEventProc( } listPtr->flags |= UPDATE_V_SCROLLBAR|UPDATE_H_SCROLLBAR; ChangeListboxView(listPtr, listPtr->topIndex); + if (listPtr->justify == TK_JUSTIFY_RIGHT) { + maxOffset = GetMaxOffset(listPtr); + if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { // window has shrunk + if (maxOffset > listPtr->oldMaxOffset) { + tmpOffset = maxOffset - listPtr->oldMaxOffset; + } else { + tmpOffset = listPtr->oldMaxOffset - maxOffset; + } + tmpOffset -= tmpOffset % listPtr->xScrollUnit; + if ((tmpOffset + listPtr->xOffset) > maxOffset) { + tmpOffset = maxOffset - listPtr->xOffset; + } + if (tmpOffset < 0) { + tmpOffset = 0; + } + listPtr->xOffset += tmpOffset; + } else { + listPtr->xOffset = maxOffset; + } + listPtr->oldMaxOffset = maxOffset; + } else if (listPtr->justify == TK_JUSTIFY_CENTER) { + maxOffset = GetMaxOffset(listPtr); + if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { // window has shrunk + tmpOffset2 = maxOffset / 2; + if (maxOffset > listPtr->oldMaxOffset) { + tmpOffset = maxOffset/2 - listPtr->oldMaxOffset/2; + } else { + tmpOffset = listPtr->oldMaxOffset/2 - maxOffset/2; + } + tmpOffset -= tmpOffset % listPtr->xScrollUnit; + if ((tmpOffset + listPtr->xOffset) > maxOffset) { + tmpOffset = maxOffset - listPtr->xOffset; + } + if (tmpOffset < 0) { + tmpOffset = 0; + } + if (listPtr->xOffset < tmpOffset2) { + listPtr->xOffset += tmpOffset; + } else { + listPtr->xOffset -= tmpOffset; + } + } else { + listPtr->xOffset = maxOffset/2; + listPtr->xOffset -= listPtr->xOffset % listPtr->xScrollUnit; + } + listPtr->oldMaxOffset = maxOffset; + } ChangeListboxOffset(listPtr, listPtr->xOffset); /* @@ -3549,6 +3622,33 @@ MigrateHashEntries( } /* + *---------------------------------------------------------------------- + * + * GetMaxOffset -- + * + * Passing in a listbox pointer, returns the maximum offset for the box + * + * Results: + * Listbox's maxOffset + * + * Side effects: + * None + * + *---------------------------------------------------------------------- +*/ +static int GetMaxOffset(register Listbox *listPtr) +{ + int maxOffset; + + maxOffset = listPtr->maxWidth - (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1; + if (maxOffset < 0) { + maxOffset = 0; + } + maxOffset -= maxOffset % listPtr->xScrollUnit; + + return maxOffset; +} +/* * Local Variables: * mode: c * c-basic-offset: 4 diff --git a/library/demos/states.tcl b/library/demos/states.tcl index e76540d..09d2718 100644 --- a/library/demos/states.tcl +++ b/library/demos/states.tcl @@ -19,6 +19,15 @@ positionWindow $w label $w.msg -font $font -wraplength 4i -justify left -text "A listbox containing the 50 states is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by scanning. To scan, press button 2 in the widget and drag up or down." pack $w.msg -side top +foreach c {Left Center Right} { + set lower [string tolower $c] + radiobutton $w.$lower -text $c -variable just \ + -relief flat -value $lower -anchor w \ + -command "$w.frame.list configure -justify \$just" \ + -tristatevalue "multi" + pack $w.$lower -side left -pady 2 -fill x +} + ## See Code / Dismiss buttons set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index 8565cdb..903f5f9 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -262,6 +262,7 @@ #define DEF_LISTBOX_RELIEF "solid" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" +#define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index b922278..8768a2e 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -224,6 +224,7 @@ #define DEF_LISTBOX_RELIEF "sunken" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" +#define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index 11c3e6d..6d1a0c9 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -227,6 +227,7 @@ #define DEF_LISTBOX_RELIEF "sunken" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" +#define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" -- cgit v0.12 From 5c01788dc22a4a2f8e6d9e943dc61a5b73b28291 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 11 Feb 2014 19:05:15 +0000 Subject: Adapt documentation and test-case --- doc/listbox.n | 7 ++++--- tests/listbox.test | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/listbox.n b/doc/listbox.n index 4264823..1da40fd 100644 --- a/doc/listbox.n +++ b/doc/listbox.n @@ -17,9 +17,10 @@ listbox \- Create and manipulate 'listbox' item list widgets \-background \-borderwidth \-cursor \-disabledforeground \-exportselection \-font \-foreground \-highlightbackground \-highlightcolor -\-highlightthickness \-relief \-selectbackground -\-selectborderwidth \-selectforeground \-setgrid -\-takefocus \-xscrollcommand \-yscrollcommand +\-highlightthickness \-justify \-relief +\-selectbackground \-selectborderwidth \-selectforeground +\-setgrid \-takefocus \-xscrollcommand +\-yscrollcommand .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-activestyle activeStyle ActiveStyle diff --git a/tests/listbox.test b/tests/listbox.test index e05d574..72b1cdf 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -455,7 +455,7 @@ test listbox-3.22 {ListboxWidgetCmd procedure, "cget" option} -body { } -result {0} test listbox-3.23 {ListboxWidgetCmd procedure, "configure" option} -body { llength [.l configure] -} -result {27} +} -result {28} test listbox-3.24 {ListboxWidgetCmd procedure, "configure" option} -body { .l configure -gorp } -returnCodes error -result {unknown option "-gorp"} -- cgit v0.12 From da6ca47d6d53db41a974859bf961ddc2d8f9d1d3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 29 Jun 2015 21:57:04 +0000 Subject: Fixed bug [2886436fff] - [.txt delete] deletes before start index - This is option 2: don't change the behavior of the text widget, but document it better. --- doc/text.n | 7 +++++-- generic/tkText.c | 14 +++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/doc/text.n b/doc/text.n index b11363d..1ccadbb 100644 --- a/doc/text.n +++ b/doc/text.n @@ -1216,8 +1216,11 @@ If \fIindex2\fR does not specify a position later in the text than \fIindex1\fR then no characters are deleted. If \fIindex2\fR is not specified then the single character at \fIindex1\fR is deleted. -It is not allowable to delete characters in a way that would leave -the text without a newline as the last character. +Attempts to delete characters in a way that would leave +the text without a newline as the last character will be tweaked by the +text widget to avoid this. In particular, attempts to delete complete +lines of text up to the end of the text will result in +deletion of the newline character just preceding \fIindex1\fR. The command returns an empty string. If more indices are given, multiple ranges of text will be deleted. All indices are first checked for validity before any deletions are made. diff --git a/generic/tkText.c b/generic/tkText.c index 139e71d..5042582 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -3001,11 +3001,15 @@ DeleteIndexRange( * file (just before the dummy line) is being deleted, then back up index * to just before the newline. If there is a newline just before the first * character being deleted, then back up the first index too, so that an - * even number of lines gets deleted. Furthermore, remove any tags that - * are present on the newline that isn't going to be deleted after all - * (this simulates deleting the newline and then adding a "clean" one back - * again). Note that index1 and index2 might now be equal again which - * means that no text will be deleted but tags might be removed. + * even number of lines gets deleted. The idea is that a deletion + * involving a range starting at a line start and including the final \n + * (i.e. index2 is "end") is an attempt to delete complete lines, so the + * \n before the deleted block shall become the new final \n. Furthermore, + * remove any tags that are present on the newline that isn't going to be + * deleted after all (this simulates deleting the newline and then adding + * a "clean" one back again). Note that index1 and index2 might now be + * equal again which means that no text will be deleted but tags might be + * removed. */ line1 = TkBTreeLinesTo(textPtr, index1.linePtr); -- cgit v0.12 From b3db9087841c153570ebfc1edd7ac33f3dd8bbcf Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 14 Jul 2015 19:18:58 +0000 Subject: Tried to be even clearer. --- doc/text.n | 7 ++++--- generic/tkText.c | 19 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/text.n b/doc/text.n index 1ccadbb..5b7804a 100644 --- a/doc/text.n +++ b/doc/text.n @@ -1218,9 +1218,10 @@ If \fIindex2\fR is not specified then the single character at \fIindex1\fR is deleted. Attempts to delete characters in a way that would leave the text without a newline as the last character will be tweaked by the -text widget to avoid this. In particular, attempts to delete complete -lines of text up to the end of the text will result in -deletion of the newline character just preceding \fIindex1\fR. +text widget to avoid this. In particular, deletion of complete lines of +text up to the end of the text will also delete the newline character just +before the deleted block so that it is replaced by the new final newline +of the text widget. The command returns an empty string. If more indices are given, multiple ranges of text will be deleted. All indices are first checked for validity before any deletions are made. diff --git a/generic/tkText.c b/generic/tkText.c index 5042582..eb2d77a 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -3000,16 +3000,15 @@ DeleteIndexRange( * dummy empty line at the end of the text. If the final newline of the * file (just before the dummy line) is being deleted, then back up index * to just before the newline. If there is a newline just before the first - * character being deleted, then back up the first index too, so that an - * even number of lines gets deleted. The idea is that a deletion - * involving a range starting at a line start and including the final \n - * (i.e. index2 is "end") is an attempt to delete complete lines, so the - * \n before the deleted block shall become the new final \n. Furthermore, - * remove any tags that are present on the newline that isn't going to be - * deleted after all (this simulates deleting the newline and then adding - * a "clean" one back again). Note that index1 and index2 might now be - * equal again which means that no text will be deleted but tags might be - * removed. + * character being deleted, then back up the first index too. The idea is + * that a deletion involving a range starting at a line start and + * including the final \n (i.e. index2 is "end") is an attempt to delete + * complete lines, so the \n before the deleted block shall become the new + * final \n. Furthermore, remove any tags that are present on the newline + * that isn't going to be deleted after all (this simulates deleting the + * newline and then adding a "clean" one back again). Note that index1 and + * index2 might now be equal again which means that no text will be + * deleted but tags might be removed. */ line1 = TkBTreeLinesTo(textPtr, index1.linePtr); -- cgit v0.12 From 02dd303fbbf431e473d72f9a91e00ee432f10705 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 23 Oct 2015 15:35:13 +0000 Subject: Bump to release number 8.5.19 --- README | 2 +- generic/tk.h | 4 ++-- library/tk.tcl | 2 +- unix/configure | 2 +- unix/configure.in | 2 +- unix/tk.spec | 2 +- win/configure | 2 +- win/configure.in | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README b/README index 6fad4bb..4d1dc24 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ README: Tk - This is the Tk 8.5.18 source distribution. + This is the Tk 8.5.19 source distribution. http://sourceforge.net/projects/tcl/files/Tcl/ You can get any source release of Tk from the URL above. diff --git a/generic/tk.h b/generic/tk.h index e356ce5..bf43b41 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -59,10 +59,10 @@ extern "C" { #define TK_MAJOR_VERSION 8 #define TK_MINOR_VERSION 5 #define TK_RELEASE_LEVEL TCL_FINAL_RELEASE -#define TK_RELEASE_SERIAL 18 +#define TK_RELEASE_SERIAL 19 #define TK_VERSION "8.5" -#define TK_PATCH_LEVEL "8.5.18" +#define TK_PATCH_LEVEL "8.5.19" /* * A special definition used to allow this header file to be included from diff --git a/library/tk.tcl b/library/tk.tcl index a9db8cb..64fb6f6 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -15,7 +15,7 @@ package require Tcl 8.5 ;# Guard against [source] in an 8.4- interp before # Insist on running with compatible version of Tcl package require Tcl 8.5.0 # Verify that we have Tk binary and script components from the same release -package require -exact Tk 8.5.18 +package require -exact Tk 8.5.19 # Create a ::tk namespace namespace eval ::tk { diff --git a/unix/configure b/unix/configure index 10e2b48..41380f8 100755 --- a/unix/configure +++ b/unix/configure @@ -1338,7 +1338,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu TK_VERSION=8.5 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=5 -TK_PATCH_LEVEL=".18" +TK_PATCH_LEVEL=".19" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" diff --git a/unix/configure.in b/unix/configure.in index bab5d8a..d4a8c28 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [ TK_VERSION=8.5 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=5 -TK_PATCH_LEVEL=".18" +TK_PATCH_LEVEL=".19" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" diff --git a/unix/tk.spec b/unix/tk.spec index fd51c52..02bb625 100644 --- a/unix/tk.spec +++ b/unix/tk.spec @@ -4,7 +4,7 @@ Name: tk Summary: Tk graphical toolkit for the Tcl scripting language. -Version: 8.5.18 +Version: 8.5.19 Release: 2 License: BSD Group: Development/Languages diff --git a/win/configure b/win/configure index bd48382..5c16b5b 100755 --- a/win/configure +++ b/win/configure @@ -1312,7 +1312,7 @@ SHELL=/bin/sh TK_VERSION=8.5 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=5 -TK_PATCH_LEVEL=".18" +TK_PATCH_LEVEL=".19" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ diff --git a/win/configure.in b/win/configure.in index 4634bb6..9dd7fb8 100644 --- a/win/configure.in +++ b/win/configure.in @@ -14,7 +14,7 @@ SHELL=/bin/sh TK_VERSION=8.5 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=5 -TK_PATCH_LEVEL=".18" +TK_PATCH_LEVEL=".19" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ -- cgit v0.12 From cd9cafa8325db1e113f2f38de9285a06eab4f432 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 23 Oct 2015 18:49:37 +0000 Subject: update changes --- changes | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/changes b/changes index d9d34a3..df3ab72 100644 --- a/changes +++ b/changes @@ -6987,3 +6987,48 @@ Tk Cocoa 2.0: App Store enabled (walzer,culler,desmera,owen,nyberg,reincke) *** POTENTIAL INCOMPATIBILITY *** --- Released 8.5.18, March 6, 2015 --- http://core.tcl.tk/tk/ for details + +2015-03-10 (bug) Cocoa: premature image free crash (walzer) + +2015-03-15 (bug) Cocoa: wish launches in front. [focus -force] works (culler) + +2015-04-09 (bug)[e4ed00] [$text index "1.0 display wordstart"] crash (vogel) + +2015-04-09 (bug)[562118] Unicode support of "wordstart" modifier (vogel) + +2015-05-05 (bug)[06c3fc] PNG alpha error corrupted output file (gauthier,porter) + +2015-05-24 (bug)[53f8fc] panedwindow geometry management (vogel) + +2015-05-26 (bug)[1641721] tk_getOpenFile symlink display doubled (nijtmans) + +2015-06-01 (bug)[d7bad5][2368195][3592454][1714535][1292219][3592454] + panedwindow fixes (vogel) + +2015-06-25 (bug)[805cff] Tk_ConfigureWidget() segfault (aspect,nijtmans) + +2015-07-13 (bug)[3f179a] Text widget crash with elided text (vogel) + +2015-07-16 (bug)[2886436] Stop [$text delete] acting before start index (vogel) + +2015-07-28 (bug)[1236306] TraverseToMenu error bound to toplevel destroy (vogel) + +2015-08-20 (bug)[00189c] MSVC 14: semi-static UCRT support (dower,nijtmans) + +2015-09-29 (bug)[1501749] Crash embedded window delete bound to (vogel) + +2015-10-08 (new feature)[TIP 437] New panedwindow options (vogel) + +2015-10-09 (bug)[1669632] [text] autoseparator placement (nash,vogel) + +2015-10-09 (bug)[2262711] [text] RE search Unicode+elided (kaitzschu,vogel) + +2015-10-09 (bug)[1815161] [$text count -ypixels] needs management (vogel) + +2015-10-22 (bug)[1520118] Document spinbox validate expectations (vogel) + +2015-10-22 (bug)[1414025] $entry insertion cursor visibility (vogel) + +Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) + +--- Released 8.5.19, December 1, 2015 --- http://core.tcl.tk/tk/ for details -- cgit v0.12 From e07b10f1a79f05875a092a57edd405f0e23f7345 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sat, 9 Jan 2016 03:03:29 +0000 Subject: Additional fixes for memory leaks, window flickering on OS X 10.11; thanks to Marc Culler for patch --- macosx/tkMacOSXInit.c | 9 ++++++--- macosx/tkMacOSXWindowEvent.c | 10 ++++++---- macosx/tkMacOSXWm.c | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index cb97f47..26eb3f5 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -72,11 +72,13 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt _mainPool = [NSAutoreleasePool new]; } } + #ifdef TK_MAC_DEBUG_NOTIFICATIONS - (void)_postedNotification:(NSNotification *)notification { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); } #endif + - (void)_setupApplicationNotifications { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; #define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil] @@ -91,18 +93,19 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &keyboardChanged, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorCoalesce); #endif } + - (void)_setupEventLoop { NSAutoreleasePool *pool = [NSAutoreleasePool new]; [self finishLaunching]; [self setWindowsNeedUpdate:YES]; [pool drain]; } + - (void)_setup:(Tcl_Interp *)interp { _eventInterp = interp; - _mainPool = nil; + _mainPool = [NSAutoreleasePool new]; [NSApp setPoolProtected:NO]; _defaultMainMenu = nil; - NSAutoreleasePool *pool = [NSAutoreleasePool new]; [self _setupMenus]; [self setDelegate:self]; #ifdef TK_MAC_DEBUG_NOTIFICATIONS @@ -111,8 +114,8 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt #endif [self _setupWindowNotifications]; [self _setupApplicationNotifications]; - [pool drain]; } + - (NSString *)tkFrameworkImagePath:(NSString*)image { NSString *path = nil; NSAutoreleasePool *pool = [NSAutoreleasePool new]; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 91cc348..fce3801 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -165,6 +165,10 @@ extern BOOL opaqueTag; if (winPtr) { TkGenWMDestroyEvent((Tk_Window) winPtr); + if (_windowWithMouse == w) { + _windowWithMouse = nil; + [w release]; + } } /* @@ -862,12 +866,9 @@ ConfigureRestrictProc( /* * Try to prevent flickers and flashes. - * - * This stops the flickers, but on OSX 10.11 flashes still occur when - * the width of the window is 16, 32, 48, 64, 80, 96, 112, 256, 512, - * 768, ... */ [w disableFlushWindow]; + NSDisableScreenUpdates(); /* Disable Tk drawing until the window has been completely configured.*/ TkMacOSXSetDrawingEnabled(winPtr, 0); @@ -891,6 +892,7 @@ ConfigureRestrictProc( while (Tk_DoOneEvent(TK_ALL_EVENTS|TK_DONT_WAIT)) {} [w enableFlushWindow]; [w flushWindowIfNeeded]; + NSEnableScreenUpdates(); [NSApp setPoolProtected:NO]; } } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 50cac20..5df72f0 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -907,6 +907,8 @@ TkWmDeadWindow( [front makeKeyAndOrderFront:NSApp]; } } + [NSApp _resetAutoreleasePool]; + #if DEBUG_ZOMBIES > 0 fprintf(stderr, "================= Pool dump ===================\n"); [NSAutoreleasePool showPools]; -- cgit v0.12 From 1495c801841af36629d7d985074d43ddc31f62fe Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 9 Jan 2016 22:30:01 +0000 Subject: (cherry-pick) Fix [1927212]: MouseWheel unbound for non-aqua scrollbars. Thanks to Francois Vogel for the actual work --- library/scrlbar.tcl | 7 +++++++ tests/scrollbar.test | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index 4b25325..43ce4ae 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -141,6 +141,13 @@ if {[tk windowingsystem] eq "aqua"} { bind Scrollbar { tk::ScrollByUnits %W h [expr {-10 * (%D)}] } +} else { + bind Scrollbar { + tk::ScrollByUnits %W v [expr {- (%D /120 ) * 4}] + } + bind Scrollbar { + tk::ScrollByUnits %W h [expr {- (%D /120 ) * 4}] + } } # tk::ScrollButtonDown -- # This procedure is invoked when a button is pressed in a scrollbar. diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 5d4334f..35f48bd 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -632,6 +632,36 @@ test scrollbar-9.1 {scrollbar widget vs hidden commands} { list [winfo children .] [interp hidden] } [list {} $l] +test scrollbar-10.1 { event on scrollbar} -constraints {win|unix} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} + +test scrollbar-10.2 { event on scrollbar} -constraints {win|unix} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} + catch {destroy .s} catch {destroy .t} -- cgit v0.12 From 651d6089bd63522c1a689dabead4ed1c6c4a5f17 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 11 Jan 2016 00:28:14 +0000 Subject: Fix for 63c3542c06, messageboxes in Tk-Cocoa; thanks to Marc Culler for patch --- macosx/tkMacOSXDialog.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index eebff3c..4ceb010 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1013,7 +1013,8 @@ Tk_MessageBoxObjCmd( NSArray *buttons; NSAlert *alert = [NSAlert new]; NSInteger modalReturnCode = 1; - + BOOL parentIsKey = NO; + iconIndex = ICON_INFO; typeIndex = TYPE_OK; for (i = 1; i < objc; i += 2) { @@ -1139,6 +1140,7 @@ Tk_MessageBoxObjCmd( callbackInfo->typeIndex = typeIndex; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { + parentIsKey = [parent isKeyWindow]; #if MAC_OS_X_VERSION_MIN_REQUIRED > 1090 [alert beginSheetModalForWindow:parent completionHandler:^(NSModalResponse returnCode) @@ -1161,6 +1163,9 @@ Tk_MessageBoxObjCmd( result = (modalReturnCode >= NSAlertFirstButtonReturn) ? TCL_OK : TCL_ERROR; end: [alert release]; + if (parentIsKey) { + [parent makeKeyWindow]; + } return result; } -- cgit v0.12 From 44cda04c842ee384d0e830bbb247787ee0819fee Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 11 Jan 2016 00:45:56 +0000 Subject: Additional tweaks for dialog --- macosx/tkMacOSXDialog.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 4ceb010..6af6b33 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -398,6 +398,7 @@ Tk_GetOpenFileObjCmd( TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { + BOOL parentIsKey = NO; if (Tcl_GetIndexFromObjStruct(interp, objv[i], openOptionStrings, sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { goto end; @@ -513,6 +514,7 @@ Tk_GetOpenFileObjCmd( #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 [panel beginSheetForDirectory:directory file:filename + parentIsKey = [parent isKeyWindow]; types:fileTypes modalForWindow:parent modalDelegate:NSApp @@ -544,6 +546,9 @@ Tk_GetOpenFileObjCmd( if (typeVariablePtr && result == TCL_OK) { /* * The -typevariable option is not really supported. + if (parentIsKey) { + [parent makeKeyWindow]; + } */ Tcl_SetVar2(interp, Tcl_GetString(typeVariablePtr), NULL, @@ -596,6 +601,7 @@ Tk_GetSaveFileObjCmd( TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { + BOOL parentIsKey = NO; if (Tcl_GetIndexFromObjStruct(interp, objv[i], saveOptionStrings, sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { goto end; @@ -712,6 +718,7 @@ Tk_GetSaveFileObjCmd( #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 [panel beginSheetForDirectory:directory file:filename + parentIsKey = [parent isKeyWindow]; modalForWindow:parent modalDelegate:NSApp didEndSelector: @@ -737,7 +744,9 @@ Tk_GetSaveFileObjCmd( contextInfo:callbackInfo]; } result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; - + if (parentIsKey) { + [parent makeKeyWindow]; + } end: TkFreeFileFilters(&fl); return result; @@ -780,6 +789,7 @@ Tk_ChooseDirectoryObjCmd( NSWindow *parent; NSOpenPanel *panel = [NSOpenPanel openPanel]; NSInteger modalReturnCode = modalError; + BOOL parentIsKey = NO; for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObjStruct(interp, objv[i], chooseOptionStrings, @@ -847,6 +857,7 @@ Tk_ChooseDirectoryObjCmd( callbackInfo->multiple = 0; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { + parentIsKey = [parent isKeyWindow]; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 [panel beginSheetForDirectory:directory file:filename @@ -874,7 +885,9 @@ Tk_ChooseDirectoryObjCmd( contextInfo:callbackInfo]; } result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; - + if (parentIsKey) { + [parent makeKeyWindow]; + } end: return result; } -- cgit v0.12 From 5147bd27c61d07d5acfdd82046fccfdbb1aa38df Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 11 Jan 2016 14:32:00 +0000 Subject: Improved patch formatting. No functional change --- generic/tkListbox.c | 70 ++++++++++++++++++++++++++++++------------------ macosx/tkMacOSXDefault.h | 2 +- unix/tkUnixDefault.h | 2 +- win/tkWinDefault.h | 2 +- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index f16218b..2929882 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -165,8 +165,9 @@ typedef struct { Pixmap gray; /* Pixmap for displaying disabled text. */ int flags; /* Various flag bits: see below for * definitions. */ - Tk_Justify justify; /* Justification */ - int oldMaxOffset; /* Used in scrolling for right/center justification */ + Tk_Justify justify; /* Justification. */ + int oldMaxOffset; /* Used in scrolling for right/center + * justification. */ } Listbox; /* @@ -277,6 +278,8 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, -1, Tk_Offset(Listbox, highlightWidth), 0, 0, 0}, + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LISTBOX_RELIEF, -1, Tk_Offset(Listbox, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", @@ -310,8 +313,6 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_STRING, "-listvariable", "listVariable", "Variable", DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", - DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0} }; @@ -440,7 +441,7 @@ static char * ListboxListVarProc(ClientData clientData, const char *name2, int flags); static void MigrateHashEntries(Tcl_HashTable *table, int first, int last, int offset); -static int GetMaxOffset(Listbox *listPtr); +static int GetMaxOffset(Listbox *listPtr); /* * The structure below defines button class behavior by means of procedures @@ -1125,7 +1126,7 @@ ListboxBboxSubCmd( Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); - x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; + x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; y = ((index - listPtr->topIndex)*listPtr->lineHeight) + listPtr->inset + listPtr->selBorderWidth; results[0] = Tcl_NewIntObj(x); @@ -2071,23 +2072,27 @@ DisplayListbox( /* * Draw the actual text of this item. */ - Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); - stringRep = Tcl_GetStringFromObj(curElement, &stringLen); - Tk_ComputeTextLayout(listPtr->tkfont, - stringRep, stringLen, 0, - listPtr->justify, TK_IGNORE_NEWLINES, &totalLength, &height); + + Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); + stringRep = Tcl_GetStringFromObj(curElement, &stringLen); + Tk_ComputeTextLayout(listPtr->tkfont, stringRep, stringLen, 0, + listPtr->justify, TK_IGNORE_NEWLINES, &totalLength, &height); Tk_GetFontMetrics(listPtr->tkfont, &fm); y += fm.ascent + listPtr->selBorderWidth; - if (listPtr->justify == TK_JUSTIFY_LEFT) { - x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; - } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { - x = width - totalLength - listPtr->inset - listPtr->selBorderWidth - listPtr->xOffset + GetMaxOffset(listPtr) - 1; - } else { - x = (width + GetMaxOffset(listPtr))/2 - totalLength/2 - listPtr->xOffset; - } - Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont, + if (listPtr->justify == TK_JUSTIFY_LEFT) { + x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; + } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { + x = width - totalLength - listPtr->inset - + listPtr->selBorderWidth - listPtr->xOffset + + GetMaxOffset(listPtr) - 1; + } else { + x = (width + GetMaxOffset(listPtr))/2 - totalLength/2 - + listPtr->xOffset; + } + + Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont, stringRep, stringLen, x, y); /* @@ -2641,7 +2646,12 @@ ListboxEventProc( ChangeListboxView(listPtr, listPtr->topIndex); if (listPtr->justify == TK_JUSTIFY_RIGHT) { maxOffset = GetMaxOffset(listPtr); - if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { // window has shrunk + if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { + + /* + * Window has shrunk. + */ + if (maxOffset > listPtr->oldMaxOffset) { tmpOffset = maxOffset - listPtr->oldMaxOffset; } else { @@ -2661,7 +2671,12 @@ ListboxEventProc( listPtr->oldMaxOffset = maxOffset; } else if (listPtr->justify == TK_JUSTIFY_CENTER) { maxOffset = GetMaxOffset(listPtr); - if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { // window has shrunk + if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { + + /* + * Window has shrunk. + */ + tmpOffset2 = maxOffset / 2; if (maxOffset > listPtr->oldMaxOffset) { tmpOffset = maxOffset/2 - listPtr->oldMaxOffset/2; @@ -3661,21 +3676,24 @@ MigrateHashEntries( * * GetMaxOffset -- * - * Passing in a listbox pointer, returns the maximum offset for the box + * Passing in a listbox pointer, returns the maximum offset for the box. * * Results: - * Listbox's maxOffset + * Listbox's maxOffset. * * Side effects: - * None + * None. * *---------------------------------------------------------------------- */ -static int GetMaxOffset(register Listbox *listPtr) +static int GetMaxOffset( + register Listbox *listPtr) { int maxOffset; - maxOffset = listPtr->maxWidth - (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1; + maxOffset = listPtr->maxWidth - + (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - + 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1; if (maxOffset < 0) { maxOffset = 0; } diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index dc73188..65762b7 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -259,10 +259,10 @@ #define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG #define DEF_LISTBOX_HIGHLIGHT BLACK #define DEF_LISTBOX_HIGHLIGHT_WIDTH "0" +#define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_RELIEF "solid" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" -#define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index ac7bc4d..2c3854d 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -221,10 +221,10 @@ #define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG #define DEF_LISTBOX_HIGHLIGHT BLACK #define DEF_LISTBOX_HIGHLIGHT_WIDTH "1" +#define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_RELIEF "sunken" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" -#define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index 29fe4ee..f389075 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -224,10 +224,10 @@ #define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG #define DEF_LISTBOX_HIGHLIGHT HIGHLIGHT #define DEF_LISTBOX_HIGHLIGHT_WIDTH "1" +#define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_RELIEF "sunken" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" -#define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" -- cgit v0.12 From 5de259d30a538e9ede43cea981bdf0002bb0601d Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 11 Jan 2016 16:23:55 +0000 Subject: Polished listbox justification demo --- library/demos/states.tcl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/demos/states.tcl b/library/demos/states.tcl index 41ce0bf..aeb3d5b 100644 --- a/library/demos/states.tcl +++ b/library/demos/states.tcl @@ -19,14 +19,16 @@ positionWindow $w label $w.msg -font $font -wraplength 4i -justify left -text "A listbox containing the 50 states is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by scanning. To scan, press button 2 in the widget and drag up or down." pack $w.msg -side top +labelframe $w.justif -text Justification foreach c {Left Center Right} { set lower [string tolower $c] - radiobutton $w.$lower -text $c -variable just \ - -relief flat -value $lower -anchor w \ - -command "$w.frame.list configure -justify \$just" \ - -tristatevalue "multi" - pack $w.$lower -side left -pady 2 -fill x + radiobutton $w.justif.$lower -text $c -variable just \ + -relief flat -value $lower -anchor w \ + -command "$w.frame.list configure -justify \$just" \ + -tristatevalue "multi" + pack $w.justif.$lower -side left -pady 2 -fill x } +pack $w.justif ## See Code / Dismiss buttons set btns [addSeeDismiss $w.buttons $w] -- cgit v0.12 From 2ab896442a6992390a79803686b3aa3abe266cc6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 11 Jan 2016 18:00:11 +0000 Subject: Added some tests --- tests/listbox.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/listbox.test b/tests/listbox.test index 0519e93..effaad8 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -203,6 +203,21 @@ test listbox-1.31 {configuration options} -body { } -cleanup { .l configure -highlightthickness [lindex [.l configure -highlightthickness] 3] } -result {0 0} +test listbox-1.32.1 {configuration options} -setup { + set res {} +} -body { + .l configure -justify left + set res [list [lindex [.l configure -justify] 4] [.l cget -justify]] + .l configure -justify center + lappend res [lindex [.l configure -justify] 4] [.l cget -justify] + .l configure -justify right + lappend res [lindex [.l configure -justify] 4] [.l cget -justify] +} -cleanup { + .l configure -justify [lindex [.l configure -justify] 3] +} -result {left left center center right right} +test listbox-1.32.2 {configuration options} -body { + .l configure -justify bogus +} -returnCodes error -result {bad justification "bogus": must be left, right, or center} test listbox-1.33 {configuration options} -body { .l configure -relief groove list [lindex [.l configure -relief] 4] [.l cget -relief] -- cgit v0.12 From bbcec99c56690c05359f41e55c6dd7f3461c9aee Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 12 Jan 2016 09:55:10 +0000 Subject: (cherry-pick) Fix [2049429]: Some options aren't picked up from the options database. --- doc/SetOptions.3 | 50 +++++++++++++++++++++++++++++-------------------- generic/tkEntry.c | 25 ++++++++++++------------- generic/tkListbox.c | 11 +++++------ generic/tkText.c | 8 ++++---- generic/tkTextTag.c | 8 ++++---- generic/ttk/ttkButton.c | 4 ++-- macosx/README | 2 +- macosx/tkMacOSXDialog.c | 2 +- 8 files changed, 59 insertions(+), 51 deletions(-) diff --git a/doc/SetOptions.3 b/doc/SetOptions.3 index 028467a..f12a00f 100644 --- a/doc/SetOptions.3 +++ b/doc/SetOptions.3 @@ -129,19 +129,21 @@ option table is no longer needed \fBTk_DeleteOptionTable\fR should be called to free all of its resources. All of the option tables for a Tcl interpreter are freed automatically if the interpreter is deleted. .PP -\fBTk_InitOptions\fR is invoked when a new widget is created to set -the default values for all of the widget's configuration options. -\fBTk_InitOptions\fR is passed a token for an option table (\fIoptionTable\fR) -and a pointer to a widget record (\fIrecordPtr\fR), which is the C -structure that holds information about this widget. \fBTk_InitOptions\fR -uses the information in the option table to -choose an appropriate default for each option, then it stores the default -value directly into the widget record, overwriting any information that -was already present in the widget record. \fBTk_InitOptions\fR normally -returns \fBTCL_OK\fR. If an error occurred while setting the default values -(e.g., because a default value was erroneous) then \fBTCL_ERROR\fR is returned -and an error message is left in \fIinterp\fR's result if \fIinterp\fR -is not NULL. +\fBTk_InitOptions\fR is invoked when a new widget is created to set the +default values for all of the widget's configuration options that do not +have \fBTK_OPTION_DONT_SET_DEFAULT\fR set in their \fIflags\fR field. +\fBTk_InitOptions\fR is passed a token for an option table +(\fIoptionTable\fR) and a pointer to a widget record (\fIrecordPtr\fR), +which is the C structure that holds information about this widget. +\fBTk_InitOptions\fR uses the information in the option table to choose an +appropriate default for each option, except those having +\fBTK_OPTION_DONT_SET_DEFAULT\fR set, then it stores the default value +directly into the widget record, overwriting any information that was +already present in the widget record. \fBTk_InitOptions\fR normally +returns \fBTCL_OK\fR. If an error occurred while setting the default +values (e.g., because a default value was erroneous) then \fBTCL_ERROR\fR +is returned and an error message is left in \fIinterp\fR's result if +\fIinterp\fR is not NULL. .PP \fBTk_SetOptions\fR is invoked to modify configuration options based on information specified in a Tcl command. The command might be one that @@ -306,19 +308,27 @@ given by \fIinternalOffset\fR. For example, if the option's type is value is not stored in that form. At least one of the offsets must be greater than or equal to zero. .PP -The \fIflags\fR field consists of one or more bits ORed together. At -present only a single flag is supported: \fBTK_OPTION_NULL_OK\fR. If -this bit is set for an option then an empty string will be accepted as -the value for the option and the resulting internal form will be a -NULL pointer, a zero value, or \fBNone\fR, depending on the type of -the option. If the flag is not set then empty strings will result -in errors. +The \fIflags\fR field consists of one or more bits ORed together. The +following flags are supported: +.TP +\fBTK_OPTION_NULL_OK\fR +If this bit is set for an option then an empty string will be accepted as +the value for the option and the resulting internal form will be a NULL +pointer, a zero value, or \fBNone\fR, depending on the type of the option. +If the flag is not set then empty strings will result in errors. \fBTK_OPTION_NULL_OK\fR is typically used to allow a feature to be turned off entirely, e.g. set a cursor value to \fBNone\fR so that a window simply inherits its parent's cursor. Not all option types support the \fBTK_OPTION_NULL_OK\fR flag; for those that do, there is an explicit indication of that fact in the descriptions below. +.TP +\fBTK_OPTION_DONT_SET_DEFAULT\fR +If this bit is set for an option then no default value will be set in +\fBTk_InitOptions\fR for this option. Neither the option database, nor any +system default value, nor \fIoptionTable\fR are used to give a default +value to this option. Instead it is assumed that the caller has already +supplied a default value in the widget code. .PP The \fItype\fR field of each Tk_OptionSpec structure determines how to parse the value of that configuration option. The diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 338652b..9f43f90 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -133,7 +133,7 @@ static const Tk_OptionSpec entryOptSpec[] = { 0, (ClientData) DEF_ENTRY_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr), - TK_CONFIG_NULL_OK, (ClientData) DEF_ENTRY_SELECT_FG_MONO, 0}, + TK_OPTION_NULL_OK, (ClientData) DEF_ENTRY_SELECT_FG_MONO, 0}, {TK_OPTION_STRING, "-show", "show", "Show", DEF_ENTRY_SHOW, -1, Tk_Offset(Entry, showChar), TK_OPTION_NULL_OK, 0, 0}, @@ -279,23 +279,23 @@ static const Tk_OptionSpec sbOptSpec[] = { 0, (ClientData) DEF_ENTRY_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr), - TK_CONFIG_NULL_OK, (ClientData) DEF_ENTRY_SELECT_FG_MONO, 0}, + TK_OPTION_NULL_OK, (ClientData) DEF_ENTRY_SELECT_FG_MONO, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_ENTRY_STATE, -1, Tk_Offset(Entry, state), 0, (ClientData) stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_ENTRY_TAKE_FOCUS, -1, Tk_Offset(Entry, takeFocus), - TK_CONFIG_NULL_OK, 0, 0}, + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_ENTRY_TEXT_VARIABLE, -1, Tk_Offset(Entry, textVarName), - TK_CONFIG_NULL_OK, 0, 0}, + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_DOUBLE, "-to", "to", "To", DEF_SPINBOX_TO, -1, Tk_Offset(Spinbox, toValue), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate", DEF_ENTRY_VALIDATE, -1, Tk_Offset(Entry, validate), 0, (ClientData) validateStrings, 0}, {TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand", - NULL, -1, Tk_Offset(Entry, validateCmd), TK_CONFIG_NULL_OK, 0, 0}, + NULL, -1, Tk_Offset(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-values", "values", "Values", DEF_SPINBOX_VALUES, -1, Tk_Offset(Spinbox, valueStr), TK_OPTION_NULL_OK, 0, 0}, @@ -307,7 +307,7 @@ static const Tk_OptionSpec sbOptSpec[] = { DEF_SPINBOX_WRAP, -1, Tk_Offset(Spinbox, wrap), 0, 0, 0}, {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", DEF_ENTRY_SCROLL_COMMAND, -1, Tk_Offset(Entry, scrollCmd), - TK_CONFIG_NULL_OK, 0, 0}, + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0} }; @@ -390,7 +390,7 @@ static const char *selElementNames[] = { */ static int ConfigureEntry(Tcl_Interp *interp, Entry *entryPtr, - int objc, Tcl_Obj *const objv[], int flags); + int objc, Tcl_Obj *const objv[]); static int DeleteChars(Entry *entryPtr, int index, int count); static void DestroyEntry(char *memPtr); static void DisplayEntry(ClientData clientData); @@ -553,7 +553,7 @@ Tk_EntryObjCmd( if ((Tk_InitOptions(interp, (char *) entryPtr, optionTable, tkwin) != TCL_OK) || - (ConfigureEntry(interp, entryPtr, objc-2, objv+2, 0) != TCL_OK)) { + (ConfigureEntry(interp, entryPtr, objc-2, objv+2) != TCL_OK)) { Tk_DestroyWindow(entryPtr->tkwin); return TCL_ERROR; } @@ -658,7 +658,7 @@ EntryWidgetObjCmd( Tcl_SetObjResult(interp, objPtr); } } else { - result = ConfigureEntry(interp, entryPtr, objc-2, objv+2, 0); + result = ConfigureEntry(interp, entryPtr, objc-2, objv+2); } break; @@ -1086,8 +1086,7 @@ ConfigureEntry( Entry *entryPtr, /* Information about widget; may or may not * already have values for some fields. */ int objc, /* Number of valid entries in argv. */ - Tcl_Obj *const objv[], /* Argument objects. */ - int flags) /* Flags to pass to Tk_ConfigureWidget. */ + Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_SavedOptions savedOptions; Tk_3DBorder border; @@ -3637,7 +3636,7 @@ Tk_SpinboxObjCmd( Tk_DestroyWindow(entryPtr->tkwin); return TCL_ERROR; } - if (ConfigureEntry(interp, entryPtr, objc-2, objv+2, 0) != TCL_OK) { + if (ConfigureEntry(interp, entryPtr, objc-2, objv+2) != TCL_OK) { goto error; } @@ -3747,7 +3746,7 @@ SpinboxWidgetObjCmd( Tcl_SetObjResult(interp, objPtr); } } else { - result = ConfigureEntry(interp, entryPtr, objc-2, objv+2, 0); + result = ConfigureEntry(interp, entryPtr, objc-2, objv+2); } break; diff --git a/generic/tkListbox.c b/generic/tkListbox.c index ff72596..86fb671 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -278,7 +278,7 @@ static const Tk_OptionSpec optionSpecs[] = { Tk_Offset(Listbox, selBorderWidth), 0, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_LISTBOX_SELECT_FG_COLOR, -1, Tk_Offset(Listbox, selFgColorPtr), - TK_CONFIG_NULL_OK, (ClientData) DEF_LISTBOX_SELECT_FG_MONO, 0}, + TK_OPTION_NULL_OK, (ClientData) DEF_LISTBOX_SELECT_FG_MONO, 0}, {TK_OPTION_STRING, "-selectmode", "selectMode", "SelectMode", DEF_LISTBOX_SELECT_MODE, -1, Tk_Offset(Listbox, selectMode), TK_OPTION_NULL_OK, 0, 0}, @@ -379,7 +379,7 @@ enum indices { static void ChangeListboxOffset(Listbox *listPtr, int offset); static void ChangeListboxView(Listbox *listPtr, int index); static int ConfigureListbox(Tcl_Interp *interp, Listbox *listPtr, - int objc, Tcl_Obj *const objv[], int flags); + int objc, Tcl_Obj *const objv[]); static int ConfigureListboxItem(Tcl_Interp *interp, Listbox *listPtr, ItemAttr *attrs, int objc, Tcl_Obj *const objv[], int index); @@ -564,7 +564,7 @@ Tk_ListboxObjCmd( return TCL_ERROR; } - if (ConfigureListbox(interp, listPtr, objc-2, objv+2, 0) != TCL_OK) { + if (ConfigureListbox(interp, listPtr, objc-2, objv+2) != TCL_OK) { Tk_DestroyWindow(listPtr->tkwin); return TCL_ERROR; } @@ -700,7 +700,7 @@ ListboxWidgetObjCmd( result = TCL_OK; } } else { - result = ConfigureListbox(interp, listPtr, objc-2, objv+2, 0); + result = ConfigureListbox(interp, listPtr, objc-2, objv+2); } break; } @@ -1544,8 +1544,7 @@ ConfigureListbox( register Listbox *listPtr, /* Information about widget; may or may not * already have values for some fields. */ int objc, /* Number of valid entries in argv. */ - Tcl_Obj *const objv[], /* Arguments. */ - int flags) /* Flags to pass to Tk_ConfigureWidget. */ + Tcl_Obj *const objv[]) /* Arguments. */ { Tk_SavedOptions savedOptions; Tcl_Obj *oldListObj = NULL; diff --git a/generic/tkText.c b/generic/tkText.c index 6e982b0..341ec0f 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -197,18 +197,18 @@ static const Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, (ClientData) DEF_TEXT_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_TEXT_SELECT_FG_COLOR, -1, Tk_Offset(TkText, selFgColorPtr), - TK_CONFIG_NULL_OK, (ClientData) DEF_TEXT_SELECT_FG_MONO, 0}, + TK_OPTION_NULL_OK, (ClientData) DEF_TEXT_SELECT_FG_MONO, 0}, {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_TEXT_SET_GRID, -1, Tk_Offset(TkText, setGrid), 0, 0, 0}, {TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing", DEF_TEXT_SPACING1, -1, Tk_Offset(TkText, spacing1), - TK_OPTION_DONT_SET_DEFAULT, 0 , TK_TEXT_LINE_GEOMETRY }, + 0, 0 , TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing2", "spacing2", "Spacing", DEF_TEXT_SPACING2, -1, Tk_Offset(TkText, spacing2), - TK_OPTION_DONT_SET_DEFAULT, 0 , TK_TEXT_LINE_GEOMETRY }, + 0, 0 , TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing", DEF_TEXT_SPACING3, -1, Tk_Offset(TkText, spacing3), - TK_OPTION_DONT_SET_DEFAULT, 0 , TK_TEXT_LINE_GEOMETRY }, + 0, 0 , TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_CUSTOM, "-startline", NULL, NULL, NULL, -1, Tk_Offset(TkText, start), TK_OPTION_NULL_OK, (ClientData) &lineOption, TK_TEXT_LINE_RANGE}, diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index dad03bf..a310dd7 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -44,11 +44,11 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_BITMAP, "-bgstipple", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", NULL, NULL, - "0", Tk_Offset(TkTextTag, borderWidthPtr), Tk_Offset(TkTextTag, borderWidth), - TK_OPTION_DONT_SET_DEFAULT|TK_OPTION_NULL_OK, 0, 0}, + NULL, Tk_Offset(TkTextTag, borderWidthPtr), Tk_Offset(TkTextTag, borderWidth), + TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_STRING, "-elide", NULL, NULL, - "0", -1, Tk_Offset(TkTextTag, elideString), - TK_OPTION_DONT_SET_DEFAULT|TK_OPTION_NULL_OK, 0, 0}, + NULL, -1, Tk_Offset(TkTextTag, elideString), + TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_BITMAP, "-fgstipple", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_FONT, "-font", NULL, NULL, diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index 2954184..bc44f25 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -413,8 +413,8 @@ typedef struct static Tk_OptionSpec CheckbuttonOptionSpecs[] = { {TK_OPTION_STRING, "-variable", "variable", "Variable", - "", Tk_Offset(Checkbutton, checkbutton.variableObj), -1, - TK_OPTION_DONT_SET_DEFAULT,0,0}, + NULL, Tk_Offset(Checkbutton, checkbutton.variableObj), -1, + TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-onvalue", "onValue", "OnValue", "1", Tk_Offset(Checkbutton, checkbutton.onValueObj), -1, 0,0,0}, diff --git a/macosx/README b/macosx/README index 7b17fb8..8940ee6 100644 --- a/macosx/README +++ b/macosx/README @@ -399,7 +399,7 @@ The main program in a typical OSX application looks like this (see *) } The run method implements the event loop for the application. There -are three key steps in the run method. First it calls +are three key steps in the run method. First it calls [NSApp finishLaunching], which creates the bouncing application icon and does other mysterious things. Second it creates an NSAutoreleasePool. Third, it starts an event loop which drains the diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 6af6b33..67f17be 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1027,7 +1027,7 @@ Tk_MessageBoxObjCmd( NSAlert *alert = [NSAlert new]; NSInteger modalReturnCode = 1; BOOL parentIsKey = NO; - + iconIndex = ICON_INFO; typeIndex = TYPE_OK; for (i = 1; i < objc; i += 2) { -- cgit v0.12 From 9b0a5374a4e77d86b7a0e94ff46dceb6a413d246 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 12 Jan 2016 15:08:41 +0000 Subject: Added more tests --- tests/listbox.test | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/tests/listbox.test b/tests/listbox.test index effaad8..57cd974 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -456,6 +456,80 @@ test listbox-3.18 {ListboxWidgetCmd procedure, "bbox" option, partial last line} mkPartial list [.partial.l bbox 3] [.partial.l bbox 4] } -result {{5 56 24 14} {5 73 23 14}} +test listbox-3.18a {ListboxWidgetCmd procedure, "bbox" option, justified} -constraints { + fonts +} -setup { + destroy .top.l .top + unset -nocomplain res +} -body { + toplevel .top + listbox .top.l -justify left + .top.l insert end Item1 LongerItem2 MuchLongerItem3 + pack .top.l + update + lappend res [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] + .top.l configure -justify center + lappend res [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] + .top.l configure -justify right + lappend res [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] +} -cleanup { + destroy .top.l .top + unset -nocomplain res +} -result { + # + # Results to be defined when I get my hands on a platform featuring tcltest::testConstraints fonts == 1 + {TBD} {TBD} {TBD} {TBD} {TBD} {TBD} +} +test listbox-3.18b {ListboxWidgetCmd procedure, "bbox" option, justified, non-default borderwidth} -setup { + destroy .top.l .top + unset -nocomplain lres res +} -body { + toplevel .top + listbox .top.l -justify left -borderwidth 17 -highlightthickness 19 -selectborderwidth 22 + .top.l insert end Item1 LongerItem2 MuchLongerItem3 + .top.l selection set 1 + pack .top.l + update + lappend lres [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] + .top.l configure -justify center + lappend lres [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] + .top.l configure -justify right + lappend lres [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] + set res 1 + for {set i 0} {$i < [llength $lres]} {incr i 4} { + set res [expr {$res * [expr {[lindex $lres $i] >= 0}] }] + } + set res +} -cleanup { + destroy .top.l .top + unset -nocomplain lres res +} -result {1} +test listbox-3.18c {ListboxWidgetCmd procedure, "bbox" option, justified, selecting does not change offset} -setup { + destroy .top.l .top + unset -nocomplain bb1 bb2 +} -body { + toplevel .top + listbox .top.l -justify center + .top.l insert end Item1 Item2 Item3 + pack .top.l + update + set bb1 [.top.l bbox 1] + .top.l selection set 1 + update + set bb2 [.top.l bbox 1] + expr { + [lindex $bb1 0] == [lindex $bb2 0] && + [lindex $bb1 1] == [lindex $bb2 1] && + [lindex $bb1 2] == [lindex $bb2 2] && + [lindex $bb1 3] == [lindex $bb2 3] + } + # Note: the result of this test is relevant only if test listbox-3.18a + # succeeds first, otherwise the fact the present test listbox-3.18c + # passes does not mean it is OK +} -cleanup { + destroy .top.l .top + unset -nocomplain bb1 bb2 +} -result {1} test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget } -returnCodes error -result {wrong # args: should be ".l cget option"} -- cgit v0.12 From 9976bb4ea9febe4dbdb963f7b5d81e4c71a21ba0 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 13 Jan 2016 07:16:53 +0000 Subject: Typo fixed --- generic/tkListbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 2929882..7295677 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -90,7 +90,7 @@ typedef struct { * display. */ int topIndex; /* Index of top-most element visible in * window. */ - int fullLines; /* Number of lines that fit are completely + int fullLines; /* Number of lines that are completely * visible in window. There may be one * additional line at the bottom that is * partially visible. */ -- cgit v0.12 From cbe1741d686fd3de6be07ad51e091360d967b1ef Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 13 Jan 2016 07:49:55 +0000 Subject: More typos fixed --- generic/tkListbox.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 7295677..50f1717 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -97,7 +97,7 @@ typedef struct { int partialLine; /* 0 means that the window holds exactly * fullLines lines. 1 means that there is one * additional line that is partially - * visble. */ + * visible. */ int setGrid; /* Non-zero means pass gridding information to * window manager. */ @@ -131,7 +131,7 @@ typedef struct { int active; /* Index of "active" element (the one that has * been selected by keyboard traversal). -1 * means none. */ - int activeStyle; /* style in which to draw the active element. + int activeStyle; /* Style in which to draw the active element. * One of: underline, none, dotbox */ /* @@ -200,7 +200,7 @@ typedef struct { * be updated. * GOT_FOCUS: Non-zero means this widget currently has the * input focus. - * MAXWIDTH_IS_STALE: Stored maxWidth may be out-of-date + * MAXWIDTH_IS_STALE: Stored maxWidth may be out-of-date. * LISTBOX_DELETED: This listbox has been effectively destroyed. */ @@ -318,7 +318,7 @@ static const Tk_OptionSpec optionSpecs[] = { /* * The itemAttrOptionSpecs table defines the valid configuration options for - * listbox items + * listbox items. */ static const Tk_OptionSpec itemAttrOptionSpecs[] = { @@ -345,7 +345,7 @@ static const Tk_OptionSpec itemAttrOptionSpecs[] = { }; /* - * The following tables define the listbox widget commands (and sub- commands) + * The following tables define the listbox widget commands (and sub-commands) * and map the indexes into the string tables into enumerated types used to * dispatch the listbox widget command. */ @@ -628,7 +628,7 @@ ListboxWidgetObjCmd( /* * Parse the command by looking up the second argument in the list of - * valid subcommand names + * valid subcommand names. */ result = Tcl_GetIndexFromObj(interp, objv[1], commandNames, @@ -2033,7 +2033,7 @@ DisplayListbox( } else { /* * If there is an item attributes record for this item, draw - * the background box and set the foreground color accordingly + * the background box and set the foreground color accordingly. */ if (entry != NULL) { @@ -2489,7 +2489,7 @@ ListboxDeleteSubCmd( /* * Check width of the element. We only have to check if widthChanged * has not already been set to 1, because we only need one maxWidth - * element to disappear for us to have to recompute the width + * element to disappear for us to have to recompute the width. */ if (widthChanged == 0) { @@ -2824,7 +2824,11 @@ GetListboxIndex( stringRep = Tcl_GetString(indexObj); if (stringRep[0] == '@') { - /* @x,y index */ + + /* + * @x,y index + */ + int y; const char *start; char *end; @@ -3554,7 +3558,7 @@ ListboxListVarProc( /* * If the list length has decreased, then we should clean up selection and - * attributes information for elements past the end of the new list + * attributes information for elements past the end of the new list. */ oldLength = listPtr->nElements; -- cgit v0.12 From 48ae923fc9c18de0e45d927b819cc756b6833aba Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 16 Jan 2016 14:00:15 +0000 Subject: Addressed question 1 (see artifact [9d48a9c212] of ticket [3f456a5bb9]) --- generic/tkListbox.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 490f795..bea98ee 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -114,7 +114,8 @@ typedef struct { int xOffset; /* The left edge of each string in the listbox * is offset to the left by this many pixels * (0 means no offset, positive means there is - * an offset). */ + * an offset). This is x scrolling information + * is not linked to justification. */ /* * Information about what's selected or active, if any. -- cgit v0.12 From cc44a614a3a33b8007a980a64270832c67c629f2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 16 Jan 2016 14:03:32 +0000 Subject: Addressed question 2 (see artifact [9d48a9c212] of ticket [3f456a5bb9]). This code arranges for the correct xview when creating the listbox with non-default justification. It is correctly placed in Tk_ListboxObjCmd. When changing justification later, i.e. in ConfigureListbox, there is no reason to change the xview, it would not be desired that the listbox xview jumps when configuring -justify. --- generic/tkListbox.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index bea98ee..56e2c2f 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -581,6 +581,10 @@ Tk_ListboxObjCmd( return TCL_ERROR; } + /* + * Adjust startup x view according to the justify option. + */ + if (listPtr->justify == TK_JUSTIFY_RIGHT) { listPtr->xOffset = GetMaxOffset(listPtr); } else if (listPtr->justify == TK_JUSTIFY_CENTER) { -- cgit v0.12 From d48a10cb3142cfbefd0314439d877da5eb03b926 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 16 Jan 2016 14:16:00 +0000 Subject: Addressed issue A and question 6 (see artifact [9d48a9c212] of ticket [3f456a5bb9]). Issue A is fixed. Test case: package req Tk listbox .l .l insert end M M M M M M M M M pack .l .l conf -just center ; # or right .l conf -highlightthickness 40 .l selection set 4 Regarding question 6, Tk_TextWidth is a bit lower level function in the API, which must be slightly beneficial regarding performance. Tk_TextWidth is therefore preferred. --- generic/tkListbox.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 56e2c2f..a57650b 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -1857,7 +1857,7 @@ DisplayListbox( * or right edge of the listbox is * off-screen. */ Pixmap pixmap; - int totalLength, height; + int textWidth; listPtr->flags &= ~REDRAW_PENDING; if (listPtr->flags & LISTBOX_DELETED) { @@ -2079,21 +2079,19 @@ DisplayListbox( Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); stringRep = Tcl_GetStringFromObj(curElement, &stringLen); - Tk_ComputeTextLayout(listPtr->tkfont, stringRep, stringLen, 0, - listPtr->justify, TK_IGNORE_NEWLINES, &totalLength, &height); + textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); y += fm.ascent + listPtr->selBorderWidth; if (listPtr->justify == TK_JUSTIFY_LEFT) { - x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; + x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { - x = width - totalLength - listPtr->inset - - listPtr->selBorderWidth - listPtr->xOffset + - GetMaxOffset(listPtr) - 1; + x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth) + - textWidth - listPtr->xOffset + GetMaxOffset(listPtr); } else { - x = (width + GetMaxOffset(listPtr))/2 - totalLength/2 - - listPtr->xOffset; + x = (Tk_Width(tkwin) - textWidth)/2 + - listPtr->xOffset + GetMaxOffset(listPtr)/2; } Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont, -- cgit v0.12 From dfecb499abf1df3c0605d0058f454d8230221dd8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 16 Jan 2016 14:20:40 +0000 Subject: Addressed issue B (see artifact [9d48a9c212] of ticket [3f456a5bb9]) --- generic/tkListbox.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index a57650b..4f20d44 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -1096,6 +1096,7 @@ ListboxBboxSubCmd( Listbox *listPtr, /* Information about the listbox */ int index) /* Index of the element to get bbox info on */ { + register Tk_Window tkwin = listPtr->tkwin; int lastVisibleIndex; /* @@ -1131,7 +1132,15 @@ ListboxBboxSubCmd( Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); - x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; + if (listPtr->justify == TK_JUSTIFY_LEFT) { + x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; + } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { + x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth) + - pixelWidth - listPtr->xOffset + GetMaxOffset(listPtr); + } else { + x = (Tk_Width(tkwin) - pixelWidth)/2 + - listPtr->xOffset + GetMaxOffset(listPtr)/2; + } y = ((index - listPtr->topIndex)*listPtr->lineHeight) + listPtr->inset + listPtr->selBorderWidth; results[0] = Tcl_NewIntObj(x); -- cgit v0.12 From c1d11ea280efc1d70e599d7237cf84235c715064 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 16 Jan 2016 15:21:29 +0000 Subject: Fixed bug [639558ac83] - Lots of listbox tests fail on Linux --- tests/listbox.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/listbox.test b/tests/listbox.test index f50267e..9ca0411 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -57,6 +57,7 @@ proc mkPartial {{w .partial}} { # like border width have predictable values. option add *Listbox.borderWidth 2 +option add *Listbox.selectBorderWidth 1 option add *Listbox.highlightThickness 2 option add *Listbox.font {Helvetica -12 bold} -- cgit v0.12 From e43c3c8be1a8b46419c5b4b8308a1dff03a803fc Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 16 Jan 2016 15:43:00 +0000 Subject: Decided about test results for listbox-3.18a --- tests/listbox.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/listbox.test b/tests/listbox.test index fdad4c0..b62946d 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -476,11 +476,11 @@ test listbox-3.18a {ListboxWidgetCmd procedure, "bbox" option, justified} -const } -cleanup { destroy .top.l .top unset -nocomplain res -} -result { - # - # Results to be defined when I get my hands on a platform featuring tcltest::testConstraints fonts == 1 - {TBD} {TBD} {TBD} {TBD} {TBD} {TBD} -} +} -result [list \ + {5 5 34 14} {5 22 74 14} {5 39 106 14} \ + {58 5 34 14} {38 22 74 14} {22 39 106 14} \ + {111 5 34 14} {71 22 74 14} {39 39 106 14} \ +] test listbox-3.18b {ListboxWidgetCmd procedure, "bbox" option, justified, non-default borderwidth} -setup { destroy .top.l .top unset -nocomplain lres res -- cgit v0.12 From 24a1905f5c41cebbad36b04ef8c1f9327fe5a109 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 16 Jan 2016 15:45:54 +0000 Subject: Removed test listbox-3.18c since it is irrelevant (the rendering of the selected items is made in a code that depends on existence of a selection but this is untestable by bboxing since bbox is independent from the presence of a selection in the listbox) --- tests/listbox.test | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/tests/listbox.test b/tests/listbox.test index b62946d..812d1c2 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -505,32 +505,6 @@ test listbox-3.18b {ListboxWidgetCmd procedure, "bbox" option, justified, non-de destroy .top.l .top unset -nocomplain lres res } -result {1} -test listbox-3.18c {ListboxWidgetCmd procedure, "bbox" option, justified, selecting does not change offset} -setup { - destroy .top.l .top - unset -nocomplain bb1 bb2 -} -body { - toplevel .top - listbox .top.l -justify center - .top.l insert end Item1 Item2 Item3 - pack .top.l - update - set bb1 [.top.l bbox 1] - .top.l selection set 1 - update - set bb2 [.top.l bbox 1] - expr { - [lindex $bb1 0] == [lindex $bb2 0] && - [lindex $bb1 1] == [lindex $bb2 1] && - [lindex $bb1 2] == [lindex $bb2 2] && - [lindex $bb1 3] == [lindex $bb2 3] - } - # Note: the result of this test is relevant only if test listbox-3.18a - # succeeds first, otherwise the fact the present test listbox-3.18c - # passes does not mean it is OK -} -cleanup { - destroy .top.l .top - unset -nocomplain bb1 bb2 -} -result {1} test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget } -returnCodes error -result {wrong # args: should be ".l cget option"} -- cgit v0.12 From 61a97384456cdf43006536d3436fa51ee3e9acff Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 17 Jan 2016 20:40:01 +0000 Subject: Addressed questions 3 and 5 (see artifact [9d48a9c212] of ticket [3f456a5bb9]). It is not desirable to make the listbox xview jump on resizing. --- generic/tkListbox.c | 61 ----------------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 4f20d44..9ff9d23 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -167,8 +167,6 @@ typedef struct { int flags; /* Various flag bits: see below for * definitions. */ Tk_Justify justify; /* Justification. */ - int oldMaxOffset; /* Used in scrolling for right/center - * justification. */ } Listbox; /* @@ -554,7 +552,6 @@ Tk_ListboxObjCmd( listPtr->state = STATE_NORMAL; listPtr->gray = None; listPtr->justify = TK_JUSTIFY_LEFT; - listPtr->oldMaxOffset = 0; /* * Keep a hold of the associated tkwin until we destroy the listbox, @@ -2623,7 +2620,6 @@ ListboxEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { - int tmpOffset, tmpOffset2, maxOffset; Listbox *listPtr = clientData; if (eventPtr->type == Expose) { @@ -2655,63 +2651,6 @@ ListboxEventProc( } listPtr->flags |= UPDATE_V_SCROLLBAR|UPDATE_H_SCROLLBAR; ChangeListboxView(listPtr, listPtr->topIndex); - if (listPtr->justify == TK_JUSTIFY_RIGHT) { - maxOffset = GetMaxOffset(listPtr); - if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { - - /* - * Window has shrunk. - */ - - if (maxOffset > listPtr->oldMaxOffset) { - tmpOffset = maxOffset - listPtr->oldMaxOffset; - } else { - tmpOffset = listPtr->oldMaxOffset - maxOffset; - } - tmpOffset -= tmpOffset % listPtr->xScrollUnit; - if ((tmpOffset + listPtr->xOffset) > maxOffset) { - tmpOffset = maxOffset - listPtr->xOffset; - } - if (tmpOffset < 0) { - tmpOffset = 0; - } - listPtr->xOffset += tmpOffset; - } else { - listPtr->xOffset = maxOffset; - } - listPtr->oldMaxOffset = maxOffset; - } else if (listPtr->justify == TK_JUSTIFY_CENTER) { - maxOffset = GetMaxOffset(listPtr); - if (maxOffset != listPtr->oldMaxOffset && listPtr->oldMaxOffset > 0) { - - /* - * Window has shrunk. - */ - - tmpOffset2 = maxOffset / 2; - if (maxOffset > listPtr->oldMaxOffset) { - tmpOffset = maxOffset/2 - listPtr->oldMaxOffset/2; - } else { - tmpOffset = listPtr->oldMaxOffset/2 - maxOffset/2; - } - tmpOffset -= tmpOffset % listPtr->xScrollUnit; - if ((tmpOffset + listPtr->xOffset) > maxOffset) { - tmpOffset = maxOffset - listPtr->xOffset; - } - if (tmpOffset < 0) { - tmpOffset = 0; - } - if (listPtr->xOffset < tmpOffset2) { - listPtr->xOffset += tmpOffset; - } else { - listPtr->xOffset -= tmpOffset; - } - } else { - listPtr->xOffset = maxOffset/2; - listPtr->xOffset -= listPtr->xOffset % listPtr->xScrollUnit; - } - listPtr->oldMaxOffset = maxOffset; - } ChangeListboxOffset(listPtr, listPtr->xOffset); /* -- cgit v0.12 From f753eecfed15ad634f2a6b98c56a6cd1f0194beb Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 17 Jan 2016 21:09:52 +0000 Subject: Addressed question 4 (see artifact [9d48a9c212] of ticket [3f456a5bb9]). --- generic/tkListbox.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 9ff9d23..e29c637 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -3630,7 +3630,8 @@ MigrateHashEntries( * * GetMaxOffset -- * - * Passing in a listbox pointer, returns the maximum offset for the box. + * Passing in a listbox pointer, returns the maximum offset for the box, + * i.e. the maximum possible horizontal scrolling value (in pixels). * * Results: * Listbox's maxOffset. @@ -3649,6 +3650,11 @@ static int GetMaxOffset( (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1; if (maxOffset < 0) { + + /* + * Listbox is larger in width than its largest width item. + */ + maxOffset = 0; } maxOffset -= maxOffset % listPtr->xScrollUnit; -- cgit v0.12 From 53047ac807d37682c72abeb9a92fff3e41779108 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 18 Jan 2016 09:47:10 +0000 Subject: Fixed bug with the listbox justify patch: with large borders, when moving the horizontal scrollbar fully to the right the edge of the border could not be seen, one needed to push once on the right arrow of the scrollbar to see it. Test case: package require Tk destroy .top toplevel .top listbox .top.l -justify right -borderwidth 17 -highlightthickness 19 -selectborderwidth 22 scrollbar .top.hs -command ".top.l xview" -orient horizontal .top.l configure -xscrollcommand ".top.hs set" set huge [concat "START -" [string repeat "Huge Item... " 20] "- END"] .top.l insert end $huge pack .top.l -expand 1 -fill both pack .top.hs -expand 1 -fill x --- generic/tkListbox.c | 1 - 1 file changed, 1 deletion(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index e29c637..ee6941e 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -3657,7 +3657,6 @@ static int GetMaxOffset( maxOffset = 0; } - maxOffset -= maxOffset % listPtr->xScrollUnit; return maxOffset; } -- cgit v0.12 From 85c13e1d28d4bac711f3b92737b501207e261280 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 18 Jan 2016 10:08:58 +0000 Subject: Use GetMaxOffset when possible to reduce code duplication. The change in ListboxScanTo is not exactly equivalent but I believe the previous version was a bug. --- generic/tkListbox.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index ee6941e..795ec0f 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -2887,9 +2887,7 @@ ChangeListboxOffset( */ offset += listPtr->xScrollUnit / 2; - maxOffset = listPtr->maxWidth - (Tk_Width(listPtr->tkwin) - - 2*listPtr->inset - 2*listPtr->selBorderWidth) - + listPtr->xScrollUnit - 1; + maxOffset = GetMaxOffset(listPtr); if (offset > maxOffset) { offset = maxOffset; } @@ -2930,9 +2928,7 @@ ListboxScanTo( int newTopIndex, newOffset, maxIndex, maxOffset; maxIndex = listPtr->nElements - listPtr->fullLines; - maxOffset = listPtr->maxWidth + (listPtr->xScrollUnit - 1) - - (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - - 2*listPtr->selBorderWidth - listPtr->xScrollUnit); + maxOffset = GetMaxOffset(listPtr); /* * Compute new top line for screen by amplifying the difference between -- cgit v0.12 From 94fd95f35c60eceaa87f6e666785e6a6d3fb5630 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 18 Jan 2016 10:19:24 +0000 Subject: Documented what listbox-3.18b intends to test. --- tests/listbox.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/listbox.test b/tests/listbox.test index 812d1c2..76a4349 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -485,6 +485,10 @@ test listbox-3.18b {ListboxWidgetCmd procedure, "bbox" option, justified, non-de destroy .top.l .top unset -nocomplain lres res } -body { + # This test checks whether all "x" values from bbox for different size + # items with different justification settings are all positive or zero + # This checks a bit the calculation of this x value with non-default + # borders widths of the listbox toplevel .top listbox .top.l -justify left -borderwidth 17 -highlightthickness 19 -selectborderwidth 22 .top.l insert end Item1 LongerItem2 MuchLongerItem3 -- cgit v0.12 From 60426c4ec3415ab57206d57f49f672f407b94a86 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 18 Jan 2016 18:17:30 +0000 Subject: Removed attempt of adjustment of the startup xview according to the -justify option. Anyway this does not work. --- generic/tkListbox.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 795ec0f..04dab6f 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -578,17 +578,6 @@ Tk_ListboxObjCmd( return TCL_ERROR; } - /* - * Adjust startup x view according to the justify option. - */ - - if (listPtr->justify == TK_JUSTIFY_RIGHT) { - listPtr->xOffset = GetMaxOffset(listPtr); - } else if (listPtr->justify == TK_JUSTIFY_CENTER) { - listPtr->xOffset = GetMaxOffset(listPtr) / 2; - listPtr->xOffset -= listPtr->xOffset % listPtr->xScrollUnit; - } - Tcl_SetObjResult(interp, TkNewWindowObj(listPtr->tkwin)); return TCL_OK; } -- cgit v0.12 From 65f1c08a6b543a6c25ad704beb200541fc7f6a94 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 18 Jan 2016 18:43:27 +0000 Subject: Reverted [5f396dacdc]. --- generic/tkListbox.c | 1 + tests/listbox.test | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 04dab6f..c7effdd 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -3642,6 +3642,7 @@ static int GetMaxOffset( maxOffset = 0; } + maxOffset -= maxOffset % listPtr->xScrollUnit; return maxOffset; } diff --git a/tests/listbox.test b/tests/listbox.test index 76a4349..40041de 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -509,6 +509,28 @@ test listbox-3.18b {ListboxWidgetCmd procedure, "bbox" option, justified, non-de destroy .top.l .top unset -nocomplain lres res } -result {1} +test listbox-3.18c {ListboxWidgetCmd procedure, "bbox" option, justified, with x scrolling} -setup { + destroy .top.l .top.hs .top + +} -body { +package req Tk +destroy .top.l .top.hs .top + toplevel .top + listbox .top.l -justify right -borderwidth 7 -highlightthickness 10 -selectborderwidth 20 + scrollbar .top.hs -command ".top.l xview" -orient horizontal + .top.l configure -xscrollcommand ".top.hs set" + set huge [concat "START -" [string repeat "Huge Item... " 20] "- END"] + .top.l insert end VeryVeryLongItem1 AnEvenMuchVeryVeryLongerItem2 $huge ShortItem3 + pack .top.l -expand 1 -fill both + pack .top.hs -expand 1 -fill x + update + + finish write this test case + +} -cleanup { + destroy .top.l .top.hs .top + +} -result {} test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget } -returnCodes error -result {wrong # args: should be ".l cget option"} -- cgit v0.12 From eed41e54aa350fab52153895c9052ed38517e9fa Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 18 Jan 2016 18:45:27 +0000 Subject: Removed unfinished test case committed by error in the previous commit. --- tests/listbox.test | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/tests/listbox.test b/tests/listbox.test index 40041de..76a4349 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -509,28 +509,6 @@ test listbox-3.18b {ListboxWidgetCmd procedure, "bbox" option, justified, non-de destroy .top.l .top unset -nocomplain lres res } -result {1} -test listbox-3.18c {ListboxWidgetCmd procedure, "bbox" option, justified, with x scrolling} -setup { - destroy .top.l .top.hs .top - -} -body { -package req Tk -destroy .top.l .top.hs .top - toplevel .top - listbox .top.l -justify right -borderwidth 7 -highlightthickness 10 -selectborderwidth 20 - scrollbar .top.hs -command ".top.l xview" -orient horizontal - .top.l configure -xscrollcommand ".top.hs set" - set huge [concat "START -" [string repeat "Huge Item... " 20] "- END"] - .top.l insert end VeryVeryLongItem1 AnEvenMuchVeryVeryLongerItem2 $huge ShortItem3 - pack .top.l -expand 1 -fill both - pack .top.hs -expand 1 -fill x - update - - finish write this test case - -} -cleanup { - destroy .top.l .top.hs .top - -} -result {} test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget } -returnCodes error -result {wrong # args: should be ".l cget option"} -- cgit v0.12 From 05fb4fb354a81a939be50ee1eea487e58cd6e5b6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 20 Jan 2016 22:03:33 +0000 Subject: Fixed bug [9e606527af] - && instead of & used in generic/tkOption.c --- generic/tkOption.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkOption.c b/generic/tkOption.c index d758b6f..680c9db 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -560,7 +560,7 @@ Tk_GetOption( count -= levelPtr[-1].bases[currentStack]; } - if (currentStack && CLASS) { + if (currentStack & CLASS) { nodeId = winClassId; } else { nodeId = winNameId; -- cgit v0.12 From 10be4df79f97808bfedd7ac58d6e44e04a221e65 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 21 Jan 2016 20:04:18 +0000 Subject: Update changes file. --- changes | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/changes b/changes index 37cf0bd..6a5d4d7 100644 --- a/changes +++ b/changes @@ -7055,6 +7055,20 @@ Tk Cocoa 2.0: App Store enabled (walzer,culler,desmera,owen,nyberg,reincke) 2015-12-19 (bug)[793909] -textvariable handle undefined namespace (vogel) +2015-12-26 (bug)[2f78c7] crash with [text] and [tablelist] (vogel) + +2016-01-06 (bug)[1288433,3102228] <> misfires (vogel) + +2016-01-08 (bug)[1510538] initial scrollbar width (vogel,nijtmans) + +2016-01-08 (bug)[1305128] event not received by scrollbar (vogel,nijtmans) + +2016-01-09 (bug)[1927212] Mousewheel/scrollbar bindings (vogel) + +2016-01-11 (bug)[63c354] Cocoa message boxes (culler) + +2016-01-12 (bug)[2049429] get more $text options from database (vogel) + Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) --- Released 8.5.19, January 31, 2016 --- http://core.tcl.tk/tk/ for details -- cgit v0.12 From 567e654b82f4cd34d86fa80a81c35250bc1392d9 Mon Sep 17 00:00:00 2001 From: dgp Date: Sat, 23 Jan 2016 18:55:15 +0000 Subject: Repair failure to compile on OSX/Cocoa. --- macosx/tkMacOSXDialog.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 67f17be..0f7ef3a 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -395,10 +395,12 @@ Tk_GetOpenFileObjCmd( NSMutableArray *fileTypes = nil; NSOpenPanel *panel = [NSOpenPanel openPanel]; NSInteger modalReturnCode = modalError; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + BOOL parentIsKey = NO; +#endif TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { - BOOL parentIsKey = NO; if (Tcl_GetIndexFromObjStruct(interp, objv[i], openOptionStrings, sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { goto end; @@ -598,10 +600,11 @@ Tk_GetSaveFileObjCmd( NSMutableArray *fileTypes = nil; NSSavePanel *panel = [NSSavePanel savePanel]; NSInteger modalReturnCode = modalError; + BOOL parentIsKey = NO; TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { - BOOL parentIsKey = NO; + parentIsKey = NO; if (Tcl_GetIndexFromObjStruct(interp, objv[i], saveOptionStrings, sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { goto end; -- cgit v0.12 From aafc31a89b188a589cc256a1f62bb80b2f053a2b Mon Sep 17 00:00:00 2001 From: dgp Date: Sat, 23 Jan 2016 19:00:19 +0000 Subject: Remove cross-test disruption. --- tests/font.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/font.test b/tests/font.test index 9ed24dc..2defb29 100644 --- a/tests/font.test +++ b/tests/font.test @@ -1162,6 +1162,7 @@ test font-33.1 {Tk_TextWidth procedure} { test font-34.1 {ConfigAttributesObj procedure: arguments} { # (Tcl_GetIndexFromObj() != TCL_OK) + set x {} setup list [catch {font create xyz -xyz} msg] $msg } {1 {bad option "-xyz": must be -family, -size, -weight, -slant, -underline, or -overstrike}} -- cgit v0.12 From 61276a830613eb1ed26aa90b4572e80b0caa64f3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 23 Jan 2016 19:41:53 +0000 Subject: Better repair of parentIsKey (backported from Tk 8.6). Problem was introduced in (apparently ill-merged) commit [3f634e02ece26dff] --- macosx/tkMacOSXDialog.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 0f7ef3a..84fef94 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -190,6 +190,7 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) { Tcl_Obj **objv, **tmpv; int objc, result = Tcl_ListObjGetElements(callbackInfo->interp, callbackInfo->cmdObj, &objc, &objv); + if (result == TCL_OK && objc) { tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); @@ -212,18 +213,22 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) { ckfree((char *)callbackInfo); } } -- (void)tkAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode - contextInfo:(void *)contextInfo { + +- (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode + contextInfo: (void *) contextInfo +{ AlertCallbackInfo *callbackInfo = contextInfo; if (returnCode >= NSAlertFirstButtonReturn) { Tcl_Obj *resultObj = Tcl_NewStringObj(alertButtonStrings[ alertNativeButtonIndexAndTypeToButtonIndex[callbackInfo-> typeIndex][returnCode - NSAlertFirstButtonReturn]], -1); + if (callbackInfo->cmdObj) { Tcl_Obj **objv, **tmpv; int objc, result = Tcl_ListObjGetElements(callbackInfo->interp, callbackInfo->cmdObj, &objc, &objv); + if (result == TCL_OK && objc) { tmpv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); @@ -395,9 +400,7 @@ Tk_GetOpenFileObjCmd( NSMutableArray *fileTypes = nil; NSOpenPanel *panel = [NSOpenPanel openPanel]; NSInteger modalReturnCode = modalError; -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 BOOL parentIsKey = NO; -#endif TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { @@ -513,10 +516,10 @@ Tk_GetOpenFileObjCmd( callbackInfo->multiple = multiple; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { + parentIsKey = [parent isKeyWindow]; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 [panel beginSheetForDirectory:directory file:filename - parentIsKey = [parent isKeyWindow]; types:fileTypes modalForWindow:parent modalDelegate:NSApp @@ -545,12 +548,12 @@ Tk_GetOpenFileObjCmd( contextInfo:callbackInfo]; } result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; - if (typeVariablePtr && result == TCL_OK) { - /* - * The -typevariable option is not really supported. if (parentIsKey) { [parent makeKeyWindow]; } + if (typeVariablePtr && result == TCL_OK) { + /* + * The -typevariable option is not really supported. */ Tcl_SetVar2(interp, Tcl_GetString(typeVariablePtr), NULL, @@ -604,7 +607,6 @@ Tk_GetSaveFileObjCmd( TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { - parentIsKey = NO; if (Tcl_GetIndexFromObjStruct(interp, objv[i], saveOptionStrings, sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { goto end; @@ -718,10 +720,10 @@ Tk_GetSaveFileObjCmd( callbackInfo->multiple = 0; parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { + parentIsKey = [parent isKeyWindow]; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 [panel beginSheetForDirectory:directory file:filename - parentIsKey = [parent isKeyWindow]; modalForWindow:parent modalDelegate:NSApp didEndSelector: @@ -1177,7 +1179,7 @@ Tk_MessageBoxObjCmd( contextInfo:callbackInfo]; } result = (modalReturnCode >= NSAlertFirstButtonReturn) ? TCL_OK : TCL_ERROR; - end: + end: [alert release]; if (parentIsKey) { [parent makeKeyWindow]; -- cgit v0.12 From 3000865931e61dd77e966d0af27b4c86dcdbfaad Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 23 Jan 2016 19:46:08 +0000 Subject: (cherry-pick): Fixed bug [9e606527af] - && instead of & used in generic/tkOption.c --- generic/tkOption.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkOption.c b/generic/tkOption.c index bff799b..17989f8 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -559,7 +559,7 @@ Tk_GetOption( count -= levelPtr[-1].bases[currentStack]; } - if (currentStack && CLASS) { + if (currentStack & CLASS) { nodeId = winClassId; } else { nodeId = winNameId; -- cgit v0.12 From 7385219f157994efd45b0d32fd66f3ead06ea469 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 24 Jan 2016 19:19:51 +0000 Subject: Crash in Mac test suite no longer triggered after patch from Marc Culler --- macosx/tkMacOSXNotify.c | 1 - macosx/tkMacOSXWm.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 0737d74..fa359f0 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -274,7 +274,6 @@ TkMacOSXEventsCheckProc( inMode:GetRunLoopMode(modalSession) dequeue:YES]; if (currentEvent) { - [NSApp _resetAutoreleasePool]; /* Generate Xevents. */ int oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); NSEvent *processedEvent = [NSApp tkProcessEvent:currentEvent]; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 5df72f0..114980f 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -24,8 +24,6 @@ #define DEBUG_ZOMBIES 0 -#define DEBUG_ZOMBIES 0 - /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_WINDOWS -- cgit v0.12 From ac9442c6d07c589501a97b710d1608b1bb68a7dc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 24 Jan 2016 20:12:55 +0000 Subject: Fix (minor) memory leak (backported from Tk 8.6). Some efficientcy improvements (backported from 8.6 too). No change of functionality --- macosx/tkMacOSXWm.c | 80 +++++++++++++++++++++-------------------------------- 1 file changed, 32 insertions(+), 48 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 114980f..be7bf47 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -911,9 +911,9 @@ TkWmDeadWindow( fprintf(stderr, "================= Pool dump ===================\n"); [NSAutoreleasePool showPools]; #endif + } ckfree((char *)wmPtr); winPtr->wmInfoPtr = NULL; - } } /* @@ -5112,7 +5112,7 @@ TkUnsupported1ObjCmd( }; Tk_Window tkwin = clientData; TkWindow *winPtr; - int index; + int index, i; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?"); @@ -5121,56 +5121,40 @@ TkUnsupported1ObjCmd( /* Iterate through objc/objv to set correct background color and toggle opacity of window. */ - int i; for (i= 0; i < objc; i++) { - - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*black*") == 1) { - colorName = [NSColor blackColor]; // use #000000 in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*dark*") == 1) { + if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*black*")) { + colorName = [NSColor blackColor]; // use #000000 in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*dark*")) { colorName = [NSColor darkGrayColor]; //use #545454 in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*light*") == 1) { + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*light*")) { colorName = [NSColor lightGrayColor]; //use #ababab in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*white*")) { + colorName = [NSColor whiteColor]; //use #ffffff in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "gray*")) { + colorName = [NSColor grayColor]; //use #7f7f7f in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*red*")) { + colorName = [NSColor redColor]; //use #ff0000 in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*green*")) { + colorName = [NSColor greenColor]; //use #00ff00 in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*blue*")) { + colorName = [NSColor blueColor]; //use #0000ff in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*cyan*")) { + colorName = [NSColor cyanColor]; //use #00ffff in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*yellow*")) { + colorName = [NSColor yellowColor]; //use #ffff00 in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*magenta*")) { + colorName = [NSColor magentaColor]; //use #ff00ff in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*orange*")) { + colorName = [NSColor orangeColor]; //use #ff8000 in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*purple*")) { + colorName = [NSColor purpleColor]; //use #800080 in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*brown*")){ + colorName = [NSColor brownColor]; //use #996633 in Tk scripts to match + } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*clear*")) { + colorName = [NSColor clearColor]; //use systemTransparent in Tk scripts to match } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*white*") == 1) { - colorName = [NSColor whiteColor]; //use #ffffff in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "gray*") == 1) { - colorName = [NSColor grayColor]; //use #7f7f7f in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*red*") == 1) { - colorName = [NSColor redColor]; //use #ff0000 in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*green*") == 1) { - colorName = [NSColor greenColor]; //use #00ff00 in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*blue*") == 1) { - colorName = [NSColor blueColor]; //use #0000ff in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*cyan*") == 1) { - colorName = [NSColor cyanColor]; //use #00ffff in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*yellow*") == 1) { - colorName = [NSColor yellowColor]; //use #ffff00 in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*magenta*") == 1) { - colorName = [NSColor magentaColor]; //use #ff00ff in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*orange*") == 1) { - colorName = [NSColor orangeColor]; //use #ff8000 in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*purple*") == 1) { - colorName = [NSColor purpleColor]; //use #800080 in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*brown*") == 1){ - colorName = [NSColor brownColor]; //use #996633 in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*clear*") == 1) { - colorName = [NSColor clearColor]; //use systemTransparent in Tk scripts to match - } - if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*opacity*") == 1) { - opaqueTag=YES; + if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*opacity*")) { + opaqueTag = YES; } } -- cgit v0.12 From 48ef3bc66f0806a4b54f4abb9888a5fc53e78d33 Mon Sep 17 00:00:00 2001 From: jenglish Date: Mon, 25 Jan 2016 20:39:31 +0000 Subject: NotebookAddCommand: fix off-by-one error counting objc/objv when readding an already-managed window with arguments. Bug reported on tcl-core by Sam Bromley (22 Jan 2016) --- generic/ttk/ttkNotebook.c | 2 +- tests/ttk/notebook.test | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 551f4a6..dd757cb 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -902,7 +902,7 @@ static int NotebookAddCommand( if (tab->state == TAB_STATE_HIDDEN) { tab->state = TAB_STATE_NORMAL; } - if (ConfigureTab(interp, nb, tab, slaveWindow, objc-4,objv+4) != TCL_OK) { + if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) { return TCL_ERROR; } diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test index cdce020..3a2a6ff 100644 --- a/tests/ttk/notebook.test +++ b/tests/ttk/notebook.test @@ -468,6 +468,27 @@ test notebook-1817596-3 "insert/configure" -body { } -result [list [list .nb.l2 .nb.l0 .nb.l1] L2 L0 L1] -cleanup { destroy .nb } +test notebook-readd-1 "add same widget twice" -body { + pack [ttk::notebook .nb] + .nb add [ttk::button .nb.b1] -text "Button" + .nb add .nb.b1 + .nb tabs +} -result [list .nb.b1] -cleanup { destroy .nb } + +test notebook-readd-2 "add same widget twice, with options" -body { + pack [ttk::notebook .nb] + .nb add [ttk::button .nb.b1] -text "Tab label" + .nb add .nb.b1 -text "Changed tab label" + .nb tabs +} -result [list .nb.b1] -cleanup { destroy .nb } + +test notebook-readd-3 "insert same widget twice, with options" -body { + pack [ttk::notebook .nb] + .nb insert end [ttk::button .nb.b1] -text "Tab label" + .nb insert end .nb.b1 -text "Changed tab label" + .nb tabs +} -result [list .nb.b1] -cleanup { destroy .nb } + # See #1343984 test notebook-1343984-1 "don't autoselect on destroy - setup" -body { -- cgit v0.12 From b93bf38ccbdc6c1ad92004de062574738c6a3569 Mon Sep 17 00:00:00 2001 From: jenglish Date: Mon, 25 Jan 2016 20:48:08 +0000 Subject: NotebookAddCommand: fix off-by-one error counting objc/objv when readding an already-managed window with arguments. Bug reported on tcl-core by Sam Bromley (22 Jan 2016) --- generic/ttk/ttkNotebook.c | 2 +- tests/ttk/notebook.test | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 16a8bfe..81a8b64 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -901,7 +901,7 @@ static int NotebookAddCommand( if (tab->state == TAB_STATE_HIDDEN) { tab->state = TAB_STATE_NORMAL; } - if (ConfigureTab(interp, nb, tab, slaveWindow, objc-4,objv+4) != TCL_OK) { + if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) { return TCL_ERROR; } diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test index cdce020..3a2a6ff 100644 --- a/tests/ttk/notebook.test +++ b/tests/ttk/notebook.test @@ -468,6 +468,27 @@ test notebook-1817596-3 "insert/configure" -body { } -result [list [list .nb.l2 .nb.l0 .nb.l1] L2 L0 L1] -cleanup { destroy .nb } +test notebook-readd-1 "add same widget twice" -body { + pack [ttk::notebook .nb] + .nb add [ttk::button .nb.b1] -text "Button" + .nb add .nb.b1 + .nb tabs +} -result [list .nb.b1] -cleanup { destroy .nb } + +test notebook-readd-2 "add same widget twice, with options" -body { + pack [ttk::notebook .nb] + .nb add [ttk::button .nb.b1] -text "Tab label" + .nb add .nb.b1 -text "Changed tab label" + .nb tabs +} -result [list .nb.b1] -cleanup { destroy .nb } + +test notebook-readd-3 "insert same widget twice, with options" -body { + pack [ttk::notebook .nb] + .nb insert end [ttk::button .nb.b1] -text "Tab label" + .nb insert end .nb.b1 -text "Changed tab label" + .nb tabs +} -result [list .nb.b1] -cleanup { destroy .nb } + # See #1343984 test notebook-1343984-1 "don't autoselect on destroy - setup" -body { -- cgit v0.12 From b2bb8f7366e971a698d64610c5d30fa31f414ca1 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 28 Jan 2016 17:40:10 +0000 Subject: Bump to 8.6.5 --- README | 2 +- generic/tk.h | 4 ++-- library/tk.tcl | 2 +- unix/configure | 14 +++++++------- unix/configure.in | 2 +- win/configure | 2 +- win/configure.in | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README b/README index 1470c04..aa5d0f6 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ README: Tk - This is the Tk 8.6.4 source distribution. + This is the Tk 8.6.5 source distribution. http://sourceforge.net/projects/tcl/files/Tcl/ You can get any source release of Tk from the URL above. diff --git a/generic/tk.h b/generic/tk.h index 4a655a4..75d82ba 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -75,10 +75,10 @@ extern "C" { #define TK_MAJOR_VERSION 8 #define TK_MINOR_VERSION 6 #define TK_RELEASE_LEVEL TCL_FINAL_RELEASE -#define TK_RELEASE_SERIAL 4 +#define TK_RELEASE_SERIAL 5 #define TK_VERSION "8.6" -#define TK_PATCH_LEVEL "8.6.4" +#define TK_PATCH_LEVEL "8.6.5" /* * A special definition used to allow this header file to be included from diff --git a/library/tk.tcl b/library/tk.tcl index 946ab7e..38162d1 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -13,7 +13,7 @@ # Insist on running with compatible version of Tcl package require Tcl 8.6 # Verify that we have Tk binary and script components from the same release -package require -exact Tk 8.6.4 +package require -exact Tk 8.6.5 # Create a ::tk namespace namespace eval ::tk { diff --git a/unix/configure b/unix/configure index 8f9a4ac..3958a6b 100755 --- a/unix/configure +++ b/unix/configure @@ -1338,7 +1338,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".4" +TK_PATCH_LEVEL=".5" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" @@ -9598,7 +9598,7 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Xlib.h. + # Guess where to find include files, by looking for Intrinsic.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -9606,7 +9606,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -9633,7 +9633,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Xlib.h"; then + if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi @@ -9647,18 +9647,18 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lX11 $LIBS" + LIBS="-lXt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XrmInitialize () +XtMalloc (0) ; return 0; } diff --git a/unix/configure.in b/unix/configure.in index 5a18d46..cb412af 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [ TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".4" +TK_PATCH_LEVEL=".5" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" diff --git a/win/configure b/win/configure index 18efa23..cbac248 100755 --- a/win/configure +++ b/win/configure @@ -1312,7 +1312,7 @@ SHELL=/bin/sh TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".4" +TK_PATCH_LEVEL=".5" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ diff --git a/win/configure.in b/win/configure.in index 709b97f..0ff9304 100644 --- a/win/configure.in +++ b/win/configure.in @@ -14,7 +14,7 @@ SHELL=/bin/sh TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".4" +TK_PATCH_LEVEL=".5" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ -- cgit v0.12 From c3777ebd3a31648fc5427b9536d2e304e9cbcf77 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 29 Jan 2016 07:11:54 +0000 Subject: Fixed test entry-6.12: merge from 8.5 didn't see that $fixed does not exist in trunk version of entry.test. Thanks to emiliano for the report. --- tests/entry.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/entry.test b/tests/entry.test index 9c30b00..4f09450 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -1074,7 +1074,7 @@ test entry-3.42 {EntryWidgetCmd procedure, "scan" widget command} -setup { } -body { .e scan a } -cleanup { - destroy .e + destroy .efixed } -returnCodes error -result {wrong # args: should be ".e scan mark|dragto x"} test entry-3.43 {EntryWidgetCmd procedure, "scan" widget command} -setup { entry .e @@ -1896,12 +1896,12 @@ test entry-6.12 {EntryComputeGeometry procedure} -constraints { fonts } -setup { catch {destroy .e} - entry .e -font $fixed -bd 2 -relief raised -width 20 + entry .e -font {Courier -12} -bd 2 -relief raised -width 20 pack .e } -body { .e insert end "012\t456\t" update - list [.e index @81] [.e index @82] [.e index @116] [.e index @117] + list [.e index @80] [.e index @81] [.e index @115] [.e index @116] } -cleanup { destroy .e } -result {6 7 7 8} -- cgit v0.12 From b5e22a7b7e4fd964d34f9d16aa7802fe7322636c Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 31 Jan 2016 00:53:25 +0000 Subject: Fix build errors on i386 for Cocoa; thanks to Marc Culler for patch --- macosx/tkMacOSXButton.c | 4 ++-- macosx/tkMacOSXInit.c | 2 -- macosx/tkMacOSXPrivate.h | 4 ++++ macosx/ttkMacOSXTheme.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 59d394e..ebbcf09 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -289,10 +289,10 @@ TkpComputeButtonGeometry( if ( butPtr->indicatorOn ) { switch (butPtr->type) { case TYPE_RADIO_BUTTON: - GetThemeMetric(kThemeMetricRadioButtonWidth, &butPtr->indicatorDiameter); + GetThemeMetric(kThemeMetricRadioButtonWidth, (SInt32 *)&butPtr->indicatorDiameter); break; case TYPE_CHECK_BUTTON: - GetThemeMetric(kThemeMetricCheckBoxWidth, &butPtr->indicatorDiameter); + GetThemeMetric(kThemeMetricCheckBoxWidth, (SInt32 *)&butPtr->indicatorDiameter); break; default: break; diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index b965a38..33a60f2 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -57,9 +57,7 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt @end @implementation TKApplication -#ifndef __clang__ @synthesize poolProtected = _poolProtected; -#endif @end @implementation TKApplication(TKInit) diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 2a411f6..65d60ce 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -276,6 +276,10 @@ VISIBILITY_HIDDEN NSArray *_defaultHelpMenuItems; NSWindow *_windowWithMouse; NSAutoreleasePool *_mainPool; +#ifdef __i386__ + /* The Objective C runtime used on i386 requires this. */ + BOOL _poolProtected; +#endif } @property BOOL poolProtected; @end diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 4753a40..f9611c5 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -298,7 +298,7 @@ static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - *heightPtr = GetThemeMetric(kThemeMetricLargeTabHeight, heightPtr); + GetThemeMetric(kThemeMetricLargeTabHeight, (SInt32 *)heightPtr); *paddingPtr = Ttk_MakePadding(0, 0, 0, 2); } -- cgit v0.12 From 312ef46823e21b861e68eeb0073936e15177c0f7 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 31 Jan 2016 00:54:18 +0000 Subject: Fix build errors on i386 for Cocoa; thanks to Marc Culler for patch --- macosx/tkMacOSXButton.c | 4 ++-- macosx/tkMacOSXInit.c | 2 -- macosx/tkMacOSXPrivate.h | 3 +++ macosx/ttkMacOSXTheme.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index adb78c6..35f4ab5 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -289,10 +289,10 @@ TkpComputeButtonGeometry( if ( butPtr->indicatorOn ) { switch (butPtr->type) { case TYPE_RADIO_BUTTON: - GetThemeMetric(kThemeMetricRadioButtonWidth, &butPtr->indicatorDiameter); + GetThemeMetric(kThemeMetricRadioButtonWidth, (SInt32 *)&butPtr->indicatorDiameter); break; case TYPE_CHECK_BUTTON: - GetThemeMetric(kThemeMetricCheckBoxWidth, &butPtr->indicatorDiameter); + GetThemeMetric(kThemeMetricCheckBoxWidth, (SInt32 *)&butPtr->indicatorDiameter); break; default: break; diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 26eb3f5..8e353b4 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -59,9 +59,7 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt @end @implementation TKApplication -#ifndef __clang__ @synthesize poolProtected = _poolProtected; -#endif @end @implementation TKApplication(TKInit) diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index e635020..d892f4e 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -274,6 +274,9 @@ VISIBILITY_HIDDEN NSArray *_defaultHelpMenuItems; NSWindow *_windowWithMouse; NSAutoreleasePool *_mainPool; +#ifdef __i386__ + BOOL _poolProtected; +#endif } @property BOOL poolProtected; @end diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 87ec4c2..1997370 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -299,7 +299,7 @@ static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - *heightPtr = GetThemeMetric(kThemeMetricLargeTabHeight, heightPtr); + GetThemeMetric(kThemeMetricLargeTabHeight, (SInt32 *)heightPtr); *paddingPtr = Ttk_MakePadding(0, 0, 0, 2); } -- cgit v0.12 From a5b54a7f07e68d3223a0b945b7e7e0da345633ed Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 2 Feb 2016 22:16:08 +0000 Subject: Re-implement tkoption readfile using Tcl_ReadChars --- generic/tkOption.c | 40 ++++++++-------------------------------- tests/option.file3 | 2 +- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/generic/tkOption.c b/generic/tkOption.c index 680c9db..24e7fb3 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -1080,10 +1080,10 @@ ReadOptionFile( * TK_MAX_PRIO. */ { const char *realName; - char *buffer; + Tcl_Obj *buffer; int result, bufferSize; Tcl_Channel chan; - Tcl_DString newName, optString; + Tcl_DString newName; /* * Prevent file system access in a safe interpreter. @@ -1108,24 +1108,10 @@ ReadOptionFile( return TCL_ERROR; } - /* - * Compute size of file by seeking to the end of the file. This will - * overallocate if we are performing CRLF translation. - */ - - bufferSize = (int) Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_END); - Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_SET); - - if (bufferSize < 0) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "error seeking to end of file \"%s\": %s", - fileName, Tcl_PosixError(interp))); - Tcl_Close(NULL, chan); - return TCL_ERROR; - } - - buffer = ckalloc(bufferSize + 1); - bufferSize = Tcl_Read(chan, buffer, bufferSize); + buffer = Tcl_NewObj(); + Tcl_IncrRefCount(buffer); + Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8"); + bufferSize = Tcl_ReadChars(chan, buffer, -1, 0); if (bufferSize < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading file \"%s\": %s", @@ -1134,18 +1120,8 @@ ReadOptionFile( return TCL_ERROR; } Tcl_Close(NULL, chan); - buffer[bufferSize] = 0; - if ((bufferSize>2) && !memcmp(buffer, "\357\273\277", 3)) { - /* File starts with UTF-8 BOM */ - result = AddFromString(interp, tkwin, buffer+3, priority); - } else { - Tcl_DStringInit(&optString); - Tcl_ExternalToUtfDString(NULL, buffer, bufferSize, &optString); - result = AddFromString(interp, tkwin, Tcl_DStringValue(&optString), - priority); - Tcl_DStringFree(&optString); - } - ckfree(buffer); + result = AddFromString(interp, tkwin, Tcl_GetString(buffer), priority); + Tcl_DecrRefCount(buffer); return result; } diff --git a/tests/option.file3 b/tests/option.file3 index 87f41ae..146cfd9 100755 --- a/tests/option.file3 +++ b/tests/option.file3 @@ -1,4 +1,4 @@ -! This file is a sample option (resource) database used to test +! This file is a sample option (resource) database used to test ! Tk's option-handling capabilities. ! Comment line \ -- cgit v0.12 From 098b03f8f4259f1767486350c21f5b7e11a6e06b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 3 Feb 2016 08:45:48 +0000 Subject: Backout [477949] for Tk 8.5, after discussion in TclCore mailing list: option readfile cannot use multibytes. Ticket [0a3d799a] To clarify a bit, what we discovered was that [[option readfile]] as found in all Tk releases up to and including 8.5.18 is already able to read in the whole BMP, so long as the file is stored in the encoding utf-8. The classic ASCII subset is fine. utf-8 is fine. Other encodings are at best non-portable. What [477949] did was to add support for files stored in [[encoding system]] but at the expense of breaking the support for the files stored in utf-8. Not the right outcome for a patch release. --- generic/tkOption.c | 13 ++----------- tests/option.file3 | 18 ------------------ tests/option.test | 11 ++++------- 3 files changed, 6 insertions(+), 36 deletions(-) delete mode 100755 tests/option.file3 diff --git a/generic/tkOption.c b/generic/tkOption.c index 17989f8..95b140d 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -1086,7 +1086,7 @@ ReadOptionFile( char *buffer; int result, bufferSize; Tcl_Channel chan; - Tcl_DString newName, optString; + Tcl_DString newName; /* * Prevent file system access in a safe interpreter. @@ -1136,16 +1136,7 @@ ReadOptionFile( } Tcl_Close(NULL, chan); buffer[bufferSize] = 0; - if ((bufferSize>2) && !memcmp(buffer, "\357\273\277", 3)) { - /* File starts with UTF-8 BOM */ - result = AddFromString(interp, tkwin, buffer+3, priority); - } else { - Tcl_DStringInit(&optString); - Tcl_ExternalToUtfDString(NULL, buffer, bufferSize, &optString); - result = AddFromString(interp, tkwin, Tcl_DStringValue(&optString), - priority); - Tcl_DStringFree(&optString); - } + result = AddFromString(interp, tkwin, buffer, priority); ckfree(buffer); return result; } diff --git a/tests/option.file3 b/tests/option.file3 deleted file mode 100755 index 87f41ae..0000000 --- a/tests/option.file3 +++ /dev/null @@ -1,18 +0,0 @@ -! This file is a sample option (resource) database used to test -! Tk's option-handling capabilities. - -! Comment line \ - with a backslash-newline sequence embedded in it. - -*x1: blue - tktest.x2 : green -*\ -x3 \ - : pur\ -ple -*x 4: brówn -# More comments, this time delimited by hash-marks. - # Comment-line with space. -*x6: -*x9: \ \ \\\101\n -# comment line as last line of file. diff --git a/tests/option.test b/tests/option.test index 4668771..1bfcb7c 100644 --- a/tests/option.test +++ b/tests/option.test @@ -187,7 +187,6 @@ test option-14.12 {error conditions} { set option1 [file join [testsDirectory] option.file1] set option2 [file join [testsDirectory] option.file2] -set option3 [file join [testsDirectory] option.file3] test option-15.1 {database files} { list [catch {option read non-existent} msg] $msg @@ -208,18 +207,16 @@ test option-15.9 {database files} {option get . x3 color} burgundy test option-15.10 {database files} { list [catch {option read $option2} msg] $msg } {1 {missing colon on line 2}} -option read $option3 -test option-15.11 {database files} {option get . {x 4} color} br\xf3wn test option-16.1 {ReadOptionFile} { - set option4 [makeFile {} option.file3] - set file [open $option4 w] + set option3 [makeFile {} option.file3] + set file [open $option3 w] fconfigure $file -translation crlf puts $file "*x7: true\n*x8: false" close $file - option read $option4 userDefault + option read $option3 userDefault set result [list [option get . x7 color] [option get . x8 color]] - removeFile $option4 + removeFile $option3 set result } {true false} -- cgit v0.12 From e1d015ea1d6d8301149fa627ec1abf6b487d99c3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 3 Feb 2016 09:14:37 +0000 Subject: Added documentation, please review! --- doc/option.n | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/option.n b/doc/option.n index 8699c0d..8f29d3a 100644 --- a/doc/option.n +++ b/doc/option.n @@ -59,6 +59,11 @@ options specified in that file to the option database. If \fIpriority\fR is specified, it indicates the priority level at which to enter the options; \fIpriority\fR defaults to \fBinteractive\fR. .PP +The file is read through a channel which is in "utf-8" encoding, +invalid byte sequences are automatically converted to valid +ones. This means that encodings like ISO 8859-1 or cp1282 with +high probablility will work as well, but this is not guaranteed. +.PP The \fIpriority\fR arguments to the \fBoption\fR command are normally specified symbolically using one of the following values: .TP -- cgit v0.12 From 3b67157554ddf66b9d0fafeda1944869ed881b13 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 3 Feb 2016 09:20:12 +0000 Subject: Document that [encoding system] has no effect on option readfile --- doc/option.n | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/option.n b/doc/option.n index 8f29d3a..2763d64 100644 --- a/doc/option.n +++ b/doc/option.n @@ -60,9 +60,10 @@ is specified, it indicates the priority level at which to enter the options; \fIpriority\fR defaults to \fBinteractive\fR. .PP The file is read through a channel which is in "utf-8" encoding, -invalid byte sequences are automatically converted to valid -ones. This means that encodings like ISO 8859-1 or cp1282 with -high probablility will work as well, but this is not guaranteed. +invalid byte sequences are automatically converted to valid ones. +This means that encodings like ISO 8859-1 or cp1252 with high +probability will work as well, but this cannot be guaranteed. +This cannot be changed, setting the [encoding system] has no effect. .PP The \fIpriority\fR arguments to the \fBoption\fR command are normally specified symbolically using one of the following values: -- cgit v0.12 From 6dddb4fc012c00ae1c5465fcf5225fa618a6994c Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 4 Feb 2016 17:49:39 +0000 Subject: [06c1433906] Possible fix for text widget crashes. --- generic/tkTextDisp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 133a7d7..10f6414 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4699,6 +4699,11 @@ TextChanged( } } + while ((lastPtr != NULL) + && (lastPtr->index.linePtr == index2Ptr->linePtr)) { + lastPtr = lastPtr->nextPtr; + } + /* * Delete all the DLines from firstPtr up to but not including lastPtr. */ -- cgit v0.12 From 4b766d1f24378289437bc45e7405f68a48053915 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 5 Feb 2016 19:30:32 +0000 Subject: Fix crashing test case, textDisp-8.13 --- generic/tkTextDisp.c | 5 +++++ tests/textDisp.test | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 18b373f..f2e760b 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4765,6 +4765,11 @@ TextChanged( } } + while ((lastPtr != NULL) + && (lastPtr->index.linePtr == index2Ptr->linePtr)) { + lastPtr = lastPtr->nextPtr; + } + /* * Delete all the DLines from firstPtr up to but not including lastPtr. */ diff --git a/tests/textDisp.test b/tests/textDisp.test index caba769..f5fbd3d 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1192,6 +1192,15 @@ test textDisp-8.12 {TkTextChanged, moving the insert cursor redraws only past an # cursor is in since this display line was just unlinked in (a). } {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {2.0 3.0}} +test textDisp-8.13 {TkTextChanged, [06c1433906]} { + .t delete 1.0 end + .t insert 1.0 \nLine1\nLine2\n + update + .t insert 3.0 "" + .t delete 1.0 2.0 + update idletasks +} {} + test textDisp-9.1 {TkTextRedrawTag} { .t configure -wrap char .t delete 1.0 end -- cgit v0.12 From e5ea273dc4f32113d02d0ede8742e214ad6ea37b Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 7 Feb 2016 13:29:51 +0000 Subject: Hopefully a better fix for [06c1433906] - Text widget crash --- generic/tkTextDisp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 10f6414..fe69f28 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4683,6 +4683,9 @@ TextChanged( */ lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); + if ((lastPtr != NULL) && (TkTextIndexCmp(&lastPtr->index, &rounded) < 0)) { + lastPtr = lastPtr->nextPtr; + } /* * At least one display line is supposed to change. This makes the @@ -4699,11 +4702,6 @@ TextChanged( } } - while ((lastPtr != NULL) - && (lastPtr->index.linePtr == index2Ptr->linePtr)) { - lastPtr = lastPtr->nextPtr; - } - /* * Delete all the DLines from firstPtr up to but not including lastPtr. */ -- cgit v0.12 From 0253e18f4273fb5354b29beca73e4835ec02058f Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 7 Feb 2016 13:34:02 +0000 Subject: Cherrypicked the new test textDisp-8.13 from core-8-5-branch. This test (and all the other tests) pass. --- tests/textDisp.test | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/textDisp.test b/tests/textDisp.test index ac3aee0..532caf4 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1191,6 +1191,14 @@ test textDisp-8.12 {TkTextChanged, moving the insert cursor redraws only past an # because during (b) findDLine cannot return the display line the # cursor is in since this display line was just unlinked in (a). } {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {2.0 3.0}} +test textDisp-8.13 {TkTextChanged, used to crash, see [06c1433906]} { + .t delete 1.0 end + .t insert 1.0 \nLine1\nLine2\n + update + .t insert 3.0 "" + .t delete 1.0 2.0 + update idletasks +} {} test textDisp-9.1 {TkTextRedrawTag} { .t configure -wrap char -- cgit v0.12 From ecb4e238565152c913a65d2eb5d8ad782793b474 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 7 Feb 2016 19:21:04 +0000 Subject: while is better than if because it deals with wrapped lines then. --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index fe69f28..91642f9 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4683,7 +4683,7 @@ TextChanged( */ lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); - if ((lastPtr != NULL) && (TkTextIndexCmp(&lastPtr->index, &rounded) < 0)) { + while ((lastPtr != NULL) && (TkTextIndexCmp(&lastPtr->index, &rounded) < 0)) { lastPtr = lastPtr->nextPtr; } -- cgit v0.12 From 173f7cf4cfa6289eab436d64654e37090f2616f3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 8 Feb 2016 15:52:53 +0000 Subject: =?UTF-8?q?(cherry-pick):=20Fix=20[06c14339060ba9ae]:=20Text=20wid?= =?UTF-8?q?get=20crash=20during=20delete.=20Thanks=20to=20Fran=C3=A7ois=20?= =?UTF-8?q?Vogel=20for=20the=20implementation=20and=20Brian=20Griffin=20fo?= =?UTF-8?q?r=20all=20his=20help=20getting=20this=20figured=20out.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generic/tkTextDisp.c | 8 +++----- tests/textDisp.test | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 10f6414..91642f9 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4683,6 +4683,9 @@ TextChanged( */ lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); + while ((lastPtr != NULL) && (TkTextIndexCmp(&lastPtr->index, &rounded) < 0)) { + lastPtr = lastPtr->nextPtr; + } /* * At least one display line is supposed to change. This makes the @@ -4699,11 +4702,6 @@ TextChanged( } } - while ((lastPtr != NULL) - && (lastPtr->index.linePtr == index2Ptr->linePtr)) { - lastPtr = lastPtr->nextPtr; - } - /* * Delete all the DLines from firstPtr up to but not including lastPtr. */ diff --git a/tests/textDisp.test b/tests/textDisp.test index 6f26457..532caf4 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1191,8 +1191,7 @@ test textDisp-8.12 {TkTextChanged, moving the insert cursor redraws only past an # because during (b) findDLine cannot return the display line the # cursor is in since this display line was just unlinked in (a). } {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {2.0 3.0}} - -test textDisp-8.13 {TkTextChanged, [06c1433906]} { +test textDisp-8.13 {TkTextChanged, used to crash, see [06c1433906]} { .t delete 1.0 end .t insert 1.0 \nLine1\nLine2\n update -- cgit v0.12 From 6fcac7ae49122cfb95054e673f24cd82835d4116 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 8 Feb 2016 19:42:54 +0000 Subject: Reverted [311ef109] and [1847c858] because they are no longer needed to fix bug [2f78c7c5ea]. The corresponding test textDisp-9.14 still passes. --- generic/tkTextDisp.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 91642f9..c5ad36b 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4806,16 +4806,9 @@ TextRedrawTag( /* * Round up the starting position if it's before the first line visible on - * the screen (we only care about what's on the screen). Beware that the - * display info structure might need update, for instance if we arrived - * here from an 'after idle' script removing tags in a range whose - * display lines (and dInfo) were partially invalidated by a previous - * delete operation in the text widget. + * the screen (we only care about what's on the screen). */ - if (dInfoPtr->flags & DINFO_OUT_OF_DATE) { - UpdateDisplayInfo(textPtr); - } dlPtr = dInfoPtr->dLinePtr; if (dlPtr == NULL) { return; -- cgit v0.12 From 47fa51915781b8ceb0ad65f72b06b6d4814dbde7 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 8 Feb 2016 20:13:20 +0000 Subject: More comments in FindDLine, with slightly optimized code to achieve the same functionality. --- generic/tkTextDisp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c5ad36b..d45ac73 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6618,17 +6618,25 @@ FindDLine( /* * We're past the last display line, either because the desired * index lies past the visible text, or because the desired index - * is on the last display line showing the last logical line. + * is on the last display line. */ indexPtr2 = dlPtrPrev->index; TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount, &indexPtr2); if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) { + /* + * The desired index is on the last display line. + * --> return this display line. + */ dlPtr = dlPtrPrev; - break; } else { - return NULL; + /* + * The desired index is past the visible text. There is no + * display line displaying something at the desired index + * --> return NULL. + */ } + break; } if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) { dlPtr = dlPtrPrev; -- cgit v0.12 From afd2fa759f72c2936c5fcec0449acbaaaa93f989 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 8 Feb 2016 20:15:40 +0000 Subject: Renumbered lines to avoid wrong interpretation of the test. --- tests/textDisp.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index 532caf4..6aa3721 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1193,7 +1193,7 @@ test textDisp-8.12 {TkTextChanged, moving the insert cursor redraws only past an } {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {2.0 3.0}} test textDisp-8.13 {TkTextChanged, used to crash, see [06c1433906]} { .t delete 1.0 end - .t insert 1.0 \nLine1\nLine2\n + .t insert 1.0 \nLine2\nLine3\n update .t insert 3.0 "" .t delete 1.0 2.0 -- cgit v0.12 From 83b0263aba8b8dbf0fd2fa41cb65bd43322c9c3b Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 8 Feb 2016 20:44:22 +0000 Subject: update release date --- changes | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/changes b/changes index 45d9411..a752d10 100644 --- a/changes +++ b/changes @@ -7029,8 +7029,6 @@ Tk Cocoa 2.0: App Store enabled (walzer,culler,desmera,owen,nyberg,reincke) 2015-10-22 (bug)[1414025] $entry insertion cursor visibility (vogel) -2015-10-25 (bug)[477949] Unicode-enable [option readfile] (androwish,nijtmans) - 2015-10-26 (bug) PNG rendering on El Capitan (meier,walzer) 2015-11-08 (bug)[2160206] menubutton panic (vogel) @@ -7073,4 +7071,4 @@ Tk Cocoa 2.0: App Store enabled (walzer,culler,desmera,owen,nyberg,reincke) Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) ---- Released 8.5.19, January 31, 2016 --- http://core.tcl.tk/tk/ for details +--- Released 8.5.19, February 12, 2016 --- http://core.tcl.tk/tk/ for details -- cgit v0.12 From d00d37bf4da1bd2c0ac1548af910aea41a4e1289 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 8 Feb 2016 21:13:57 +0000 Subject: Made FindDLine fully match its header description. --- generic/tkTextDisp.c | 33 ++++++++++++++++++++++++++++++--- tests/textDisp.test | 11 +---------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index d45ac73..4d41134 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6590,6 +6590,7 @@ FindDLine( CONST TkTextIndex *indexPtr)/* Index of desired character. */ { DLine *dlPtrPrev; + TkTextIndex indexPtr2; if (dlPtr == NULL) { return NULL; @@ -6614,7 +6615,6 @@ FindDLine( dlPtrPrev = dlPtr; dlPtr = dlPtr->nextPtr; if (dlPtr == NULL) { - TkTextIndex indexPtr2; /* * We're past the last display line, either because the desired * index lies past the visible text, or because the desired index @@ -6632,14 +6632,41 @@ FindDLine( } else { /* * The desired index is past the visible text. There is no - * display line displaying something at the desired index + * display line displaying something at the desired index. * --> return NULL. */ } break; } if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) { - dlPtr = dlPtrPrev; + /* + * If we're here then we would normally expect that: + * dlPtrPrev->index <= indexPtr < dlPtr->index + * i.e. we have found the searched display line being dlPtr. + * However it is possible that some DLines were unlinked + * previously, leading to a situation where going through + * the list of display lines skips display lines that did + * exist just a moment ago. + */ + indexPtr2 = dlPtrPrev->index; + TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount, + &indexPtr2); + if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) { + /* + * Confirmed: + * dlPtrPrev->index <= indexPtr < dlPtr->index + * --> return dlPtrPrev. + */ + dlPtr = dlPtrPrev; + } else { + /* + * The last (rightmost) index shown by dlPtrPrev is still + * before the desired index. This may be because there was + * previously a display line between dlPtrPrev and dlPtr + * and this display line has been unlinked. + * --> return dlPtr. + */ + } break; } } diff --git a/tests/textDisp.test b/tests/textDisp.test index 6aa3721..885c940 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1181,16 +1181,7 @@ test textDisp-8.12 {TkTextChanged, moving the insert cursor redraws only past an .t mark set insert 3.8 ; # within the same line update lappend res $tk_textRedraw - # This last one is tricky: correct result really is {2.0 3.0} when - # calling .t mark set insert, two calls to TkTextChanged are done: - # (a) to redraw the line of the past position of the cursor - # (b) to redraw the line of the new position of the cursor - # During (a) the display line showing the cursor gets unlinked, - # which leads TkTextChanged in (b) to schedule a redraw starting - # one line _before_ the line containing the insert cursor. This is - # because during (b) findDLine cannot return the display line the - # cursor is in since this display line was just unlinked in (a). -} {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {2.0 3.0}} +} {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {3.0 4.0}} test textDisp-8.13 {TkTextChanged, used to crash, see [06c1433906]} { .t delete 1.0 end .t insert 1.0 \nLine2\nLine3\n -- cgit v0.12 From 961c4a400fecbd654b8b744a5de3f006ceb22d58 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 8 Feb 2016 21:39:52 +0000 Subject: With the real fix in FindDLine ([717e12ee]) there is no need anymore of the emergency patch [c3c09f82]. --- generic/tkTextDisp.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4d41134..44d451a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4683,9 +4683,6 @@ TextChanged( */ lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); - while ((lastPtr != NULL) && (TkTextIndexCmp(&lastPtr->index, &rounded) < 0)) { - lastPtr = lastPtr->nextPtr; - } /* * At least one display line is supposed to change. This makes the -- cgit v0.12 From 4cf679d27cf1beb50d5806e6173a8071821aff95 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 8 Feb 2016 21:45:03 +0000 Subject: Corrected indentation + added an explanatory comment. --- generic/tkTextDisp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 07623c4..960f11a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5243,7 +5243,10 @@ TkTextSetYView( dInfoPtr->newTopPixelOffset = 0; goto scheduleUpdate; - } + } + /* + * The line is already on screen, with no need to scroll. + */ return; } } -- cgit v0.12 From bc001728827804d86aac9bd890ef3776ceee373c Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 8 Feb 2016 21:47:37 +0000 Subject: Corrected indentation + added an explanatory comment (cherrypicked [1121252f]) --- generic/tkTextDisp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 91642f9..559fbf7 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5176,7 +5176,10 @@ TkTextSetYView( dInfoPtr->newTopPixelOffset = 0; goto scheduleUpdate; - } + } + /* + * The line is already on screen, with no need to scroll. + */ return; } } -- cgit v0.12 From c278933f3e8bc3f001b31f47b2ed6be701ff3c51 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 8 Feb 2016 22:06:39 +0000 Subject: Fixed (with a real fix this time) bug [06c1433906] - Text widget crash during delete (cherrypicked [48cf3656d9]) --- generic/tkTextDisp.c | 57 +++++++++++++++++++++++++++++++++++++--------------- tests/textDisp.test | 13 ++---------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 559fbf7..68c09fc 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4683,9 +4683,6 @@ TextChanged( */ lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); - while ((lastPtr != NULL) && (TkTextIndexCmp(&lastPtr->index, &rounded) < 0)) { - lastPtr = lastPtr->nextPtr; - } /* * At least one display line is supposed to change. This makes the @@ -4806,16 +4803,9 @@ TextRedrawTag( /* * Round up the starting position if it's before the first line visible on - * the screen (we only care about what's on the screen). Beware that the - * display info structure might need update, for instance if we arrived - * here from an 'after idle' script removing tags in a range whose - * display lines (and dInfo) were partially invalidated by a previous - * delete operation in the text widget. + * the screen (we only care about what's on the screen). */ - if (dInfoPtr->flags & DINFO_OUT_OF_DATE) { - UpdateDisplayInfo(textPtr); - } dlPtr = dInfoPtr->dLinePtr; if (dlPtr == NULL) { return; @@ -6600,6 +6590,7 @@ FindDLine( CONST TkTextIndex *indexPtr)/* Index of desired character. */ { DLine *dlPtrPrev; + TkTextIndex indexPtr2; if (dlPtr == NULL) { return NULL; @@ -6624,24 +6615,58 @@ FindDLine( dlPtrPrev = dlPtr; dlPtr = dlPtr->nextPtr; if (dlPtr == NULL) { - TkTextIndex indexPtr2; /* * We're past the last display line, either because the desired * index lies past the visible text, or because the desired index - * is on the last display line showing the last logical line. + * is on the last display line. */ indexPtr2 = dlPtrPrev->index; TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount, &indexPtr2); if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) { + /* + * The desired index is on the last display line. + * --> return this display line. + */ dlPtr = dlPtrPrev; - break; } else { - return NULL; + /* + * The desired index is past the visible text. There is no + * display line displaying something at the desired index. + * --> return NULL. + */ } + break; } if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) { - dlPtr = dlPtrPrev; + /* + * If we're here then we would normally expect that: + * dlPtrPrev->index <= indexPtr < dlPtr->index + * i.e. we have found the searched display line being dlPtr. + * However it is possible that some DLines were unlinked + * previously, leading to a situation where going through + * the list of display lines skips display lines that did + * exist just a moment ago. + */ + indexPtr2 = dlPtrPrev->index; + TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount, + &indexPtr2); + if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) { + /* + * Confirmed: + * dlPtrPrev->index <= indexPtr < dlPtr->index + * --> return dlPtrPrev. + */ + dlPtr = dlPtrPrev; + } else { + /* + * The last (rightmost) index shown by dlPtrPrev is still + * before the desired index. This may be because there was + * previously a display line between dlPtrPrev and dlPtr + * and this display line has been unlinked. + * --> return dlPtr. + */ + } break; } } diff --git a/tests/textDisp.test b/tests/textDisp.test index 532caf4..885c940 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1181,19 +1181,10 @@ test textDisp-8.12 {TkTextChanged, moving the insert cursor redraws only past an .t mark set insert 3.8 ; # within the same line update lappend res $tk_textRedraw - # This last one is tricky: correct result really is {2.0 3.0} when - # calling .t mark set insert, two calls to TkTextChanged are done: - # (a) to redraw the line of the past position of the cursor - # (b) to redraw the line of the new position of the cursor - # During (a) the display line showing the cursor gets unlinked, - # which leads TkTextChanged in (b) to schedule a redraw starting - # one line _before_ the line containing the insert cursor. This is - # because during (b) findDLine cannot return the display line the - # cursor is in since this display line was just unlinked in (a). -} {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {2.0 3.0}} +} {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {3.0 4.0}} test textDisp-8.13 {TkTextChanged, used to crash, see [06c1433906]} { .t delete 1.0 end - .t insert 1.0 \nLine1\nLine2\n + .t insert 1.0 \nLine2\nLine3\n update .t insert 3.0 "" .t delete 1.0 2.0 -- cgit v0.12 From 199e45b764bee51a9aacbced3e5ac9828b731d3f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 9 Feb 2016 09:23:17 +0000 Subject: Fix [62a5ba7474]: tk 'make install' fails on Mac OS 10.11 --- macosx/GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile index 02240ed..24e1f77 100644 --- a/macosx/GNUmakefile +++ b/macosx/GNUmakefile @@ -116,7 +116,7 @@ TCL_FRAMEWORK_DIR := ${TCL_BUILD_DIR}/.. MAKE_VARS := else TCL_DIR := ${TCL_FRAMEWORK_DIR}/Tcl.framework -TCL_EXE := ${TCLSH_DIR}/tclsh${TCL_VERSION} +TCL_EXE := ${TCLSH_DIR}/bin/tclsh${TCL_VERSION} MAKE_VARS := TCL_EXE export DYLD_FRAMEWORK_PATH := ${TCL_FRAMEWORK_DIR} endif -- cgit v0.12 From cee89de4d610dbf0fa12d1626fb704c73a098fc1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 9 Feb 2016 09:24:31 +0000 Subject: (cherry-pick): Fix [62a5ba7474]: tk 'make install' fails on Mac OS 10.11 --- macosx/GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile index f3299e2..a69e9d9 100644 --- a/macosx/GNUmakefile +++ b/macosx/GNUmakefile @@ -116,7 +116,7 @@ TCL_FRAMEWORK_DIR := ${TCL_BUILD_DIR}/.. MAKE_VARS := else TCL_DIR := ${TCL_FRAMEWORK_DIR}/Tcl.framework -TCL_EXE := ${TCLSH_DIR}/tclsh${TCL_VERSION} +TCL_EXE := ${TCLSH_DIR}/bin/tclsh${TCL_VERSION} MAKE_VARS := TCL_EXE export DYLD_FRAMEWORK_PATH := ${TCL_FRAMEWORK_DIR} endif -- cgit v0.12 From 8f151700b10bf8811876305e284738707d4ad237 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 9 Feb 2016 09:48:23 +0000 Subject: Slightly more logical fix for [62a5ba7474]: tk 'make install' fails on Mac OS 10.11, which doesn't change the meaning of TCLSH_DIR --- macosx/GNUmakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile index 24e1f77..d0bab1a 100644 --- a/macosx/GNUmakefile +++ b/macosx/GNUmakefile @@ -35,7 +35,7 @@ MANDIR ?= ${PREFIX}/man TCL_BUILD_DIR ?= ${BUILD_DIR}/tcl/${BUILD_STYLE} # location of installed tcl, only used if tcl in TCL_BUILD_DIR can't be found TCL_FRAMEWORK_DIR ?= /Library/Frameworks -TCLSH_DIR ?= ${PREFIX} +TCLSH_DIR ?= ${PREFIX}/bin # set to non-empty value to install manpages in addition to html help: INSTALL_MANPAGES ?= @@ -116,7 +116,7 @@ TCL_FRAMEWORK_DIR := ${TCL_BUILD_DIR}/.. MAKE_VARS := else TCL_DIR := ${TCL_FRAMEWORK_DIR}/Tcl.framework -TCL_EXE := ${TCLSH_DIR}/bin/tclsh${TCL_VERSION} +TCL_EXE := ${TCLSH_DIR}/tclsh${TCL_VERSION} MAKE_VARS := TCL_EXE export DYLD_FRAMEWORK_PATH := ${TCL_FRAMEWORK_DIR} endif -- cgit v0.12 From 815d4d45ee5bc0d0f1bc242e303f39491f356cb6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 9 Feb 2016 09:49:21 +0000 Subject: (cherry-pick): Slightly more logical fix for [62a5ba7474]: tk 'make install' fails on Mac OS 10.11, which doesn't change the meaning of TCLSH_DIR --- macosx/GNUmakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile index a69e9d9..46f76d5 100644 --- a/macosx/GNUmakefile +++ b/macosx/GNUmakefile @@ -35,7 +35,7 @@ MANDIR ?= ${PREFIX}/man TCL_BUILD_DIR ?= ${BUILD_DIR}/tcl/${BUILD_STYLE} # location of installed tcl, only used if tcl in TCL_BUILD_DIR can't be found TCL_FRAMEWORK_DIR ?= /Library/Frameworks -TCLSH_DIR ?= ${PREFIX} +TCLSH_DIR ?= ${PREFIX}/bin # set to non-empty value to install manpages in addition to html help: INSTALL_MANPAGES ?= @@ -116,7 +116,7 @@ TCL_FRAMEWORK_DIR := ${TCL_BUILD_DIR}/.. MAKE_VARS := else TCL_DIR := ${TCL_FRAMEWORK_DIR}/Tcl.framework -TCL_EXE := ${TCLSH_DIR}/bin/tclsh${TCL_VERSION} +TCL_EXE := ${TCLSH_DIR}/tclsh${TCL_VERSION} MAKE_VARS := TCL_EXE export DYLD_FRAMEWORK_PATH := ${TCL_FRAMEWORK_DIR} endif -- cgit v0.12 From 9e0da9a8a02dceebf16ed424cdef34ebcb6f3b5c Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 9 Feb 2016 18:44:42 +0000 Subject: Repair broken test. --- tests/entry.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/entry.test b/tests/entry.test index 4f09450..d27ffb5 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -1074,7 +1074,7 @@ test entry-3.42 {EntryWidgetCmd procedure, "scan" widget command} -setup { } -body { .e scan a } -cleanup { - destroy .efixed + destroy .e } -returnCodes error -result {wrong # args: should be ".e scan mark|dragto x"} test entry-3.43 {EntryWidgetCmd procedure, "scan" widget command} -setup { entry .e -- cgit v0.12 From b258e6b408ef99ed31fdde484f21548851eca156 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:23:23 +0000 Subject: -selectbackground tag configuration option: implementation --- generic/tkText.c | 7 ++++++- generic/tkText.h | 2 ++ generic/tkTextDisp.c | 13 +++++++++++++ generic/tkTextTag.c | 10 +++++++++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 3079417..1b420d6 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2253,7 +2253,11 @@ ConfigureText( * replaced in the widget record. */ - textPtr->selTagPtr->border = textPtr->selBorder; + if (textPtr->selTagPtr->selBorder == NULL) { + textPtr->selTagPtr->border = textPtr->selBorder; + } else { + textPtr->selTagPtr->selBorder = textPtr->selBorder; + } if (textPtr->selTagPtr->borderWidthPtr != textPtr->selBorderWidthPtr) { textPtr->selTagPtr->borderWidthPtr = textPtr->selBorderWidthPtr; textPtr->selTagPtr->borderWidth = textPtr->selBorderWidth; @@ -2277,6 +2281,7 @@ ConfigureText( textPtr->selTagPtr->affectsDisplayGeometry = 1; } if ((textPtr->selTagPtr->border != NULL) + || (textPtr->selTagPtr->selBorder != NULL) || (textPtr->selTagPtr->reliefString != NULL) || (textPtr->selTagPtr->bgStipple != None) || (textPtr->selTagPtr->fgColor != NULL) diff --git a/generic/tkText.h b/generic/tkText.h index fc92644..5cd009f 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -362,6 +362,8 @@ typedef struct TkTextTag { * means option not specified. */ int rMargin; /* Right margin for text, in pixels. Only * valid if rMarginString is non-NULL. */ + Tk_3DBorder selBorder; /* Used for drawing background for selected text. + * NULL means no value specified here. */ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL * means option not specified. */ int spacing1; /* Extra spacing above first display line for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 7969091..1bd5905 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -748,6 +748,7 @@ GetStyle( TextStyle *stylePtr; Tcl_HashEntry *hPtr; int numTags, isNew, i; + int isSelected; XGCValues gcValues; unsigned long mask; /* @@ -786,6 +787,14 @@ GetStyle( styleValues.tabStyle = textPtr->tabStyle; styleValues.wrapMode = textPtr->wrapMode; styleValues.elide = 0; + isSelected = 0; + + for (i = 0 ; i < numTags; i++) { + if (textPtr->selTagPtr == tagPtrs[i]) { + isSelected = 1; + break; + } + } for (i = 0 ; i < numTags; i++) { Tk_3DBorder border; @@ -811,6 +820,10 @@ GetStyle( border = textPtr->inactiveSelBorder; } + if ((tagPtr->selBorder != NULL) && (isSelected)) { + border = tagPtr->selBorder; + } + if ((border != NULL) && (tagPtr->priority > borderPrio)) { styleValues.border = border; borderPrio = tagPtr->priority; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 3363d25..a857cf9 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -70,6 +70,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-rmargin", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, + {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, spacing1String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-spacing2", NULL, NULL, @@ -484,7 +486,11 @@ TkTextTagCmd( */ if (tagPtr == textPtr->selTagPtr) { - textPtr->selBorder = tagPtr->border; + if (tagPtr->selBorder == NULL) { + textPtr->selBorder = tagPtr->border; + } else { + textPtr->selBorder = tagPtr->selBorder; + } textPtr->selBorderWidth = tagPtr->borderWidth; textPtr->selBorderWidthPtr = tagPtr->borderWidthPtr; textPtr->selFgColorPtr = tagPtr->fgColor; @@ -509,6 +515,7 @@ TkTextTagCmd( tagPtr->affectsDisplayGeometry = 1; } if ((tagPtr->border != NULL) + || (tagPtr->selBorder != NULL) || (tagPtr->reliefString != NULL) || (tagPtr->bgStipple != None) || (tagPtr->fgColor != NULL) @@ -1017,6 +1024,7 @@ TkTextCreateTag( tagPtr->overstrike = 0; tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; + tagPtr->selBorder = NULL; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; tagPtr->spacing2String = NULL; -- cgit v0.12 From b3b68ebfe18ad11c210bc80ec440c49d7b6dad8d Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:24:38 +0000 Subject: -selectbackground tag configuration option: documentation --- doc/text.n | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/text.n b/doc/text.n index ac7803c..41d6a6f 100644 --- a/doc/text.n +++ b/doc/text.n @@ -517,6 +517,13 @@ option is only used when wrapping is enabled. If a text line wraps, the right margin for each line on the display is determined by the first non-elided character of that display line. .TP +\fB\-selectbackground \fIcolor\fR +\fIcolor\fR specifies the background color to use when displaying selected +items. It may have any of the forms accepted by \fBTk_GetColor\fR. If +\fIcolor\fR has not been specified, or if it is specified as an empty +string, then the color specified by the fB\-background\fR tag option is +used. +.TP \fB\-spacing1 \fIpixels\fR . \fIPixels\fR specifies how much additional space should be left above each -- cgit v0.12 From f47ea89bb9b84548e135f0a72a033b20f0fe9f2a Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:27:11 +0000 Subject: -selectbackground tag configuration option: tests --- tests/textTag.test | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/textTag.test b/tests/textTag.test index fed073a..a7935da 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -228,6 +228,17 @@ test textTag-1.25 {configuration options} -constraints { } -cleanup { .t tag configure x -rmargin [lindex [.t tag configure x -rmargin] 3] } -returnCodes error -result {bad screen distance "bad"} +test textTag-1.25a {tag configuration options} -body { + .t tag configure x -selectbackground #012345 + .t tag cget x -selectbackground +} -cleanup { + .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] +} -result {#012345} +test textTag-1.25b {configuration options} -body { + .t tag configure x -selectbackground non-existent +} -cleanup { + .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] +} -returnCodes error -result {unknown color name "non-existent"} test textTag-1.26 {tag configuration options} -constraints { haveCourier12 } -body { @@ -713,7 +724,29 @@ test textTag-5.22 {TkTextTagCmd - "configure" option} -constraints { .t tag configure sel -borderwidth {} .t cget -selectborderwidth } -result {} - +test textTag-5.23 {TkTextTagCmd - "configure" option} -body { + set x {} + # when [.t tag cget sel -selectbackground] == "", mirroring happens between + # the text widget option -selectbackground + # and the tag option -background + .t tag configure sel -selectbackground {} + .t configure -selectbackground black + .t tag configure sel -background yellow + lappend x [.t cget -selectbackground] + .t tag configure sel -background orange + .t configure -selectbackground blue + lappend x [.t tag cget sel -background] + # when [.t tag cget sel -selectbackground] != "", mirroring happens between + # the text widget option -selectbackground + # and the tag option -selectbackground + .t tag configure sel -selectbackground green + .t configure -selectbackground red + lappend x [.t tag cget sel -selectbackground] + .t configure -selectbackground black + .t tag configure sel -selectbackground white + lappend x [.t cget -selectbackground] + return $x +} -result {yellow blue red white} test textTag-6.1 {TkTextTagCmd - "delete" option} -constraints { haveCourier12 -- cgit v0.12 From 0e661eb452692fff53250ae95abde079888f3a27 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:29:22 +0000 Subject: -selectforeground tag configuration option: implementation --- generic/tkText.c | 7 ++++++- generic/tkText.h | 2 ++ generic/tkTextDisp.c | 10 ++++++++-- generic/tkTextTag.c | 10 +++++++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 1b420d6..464d4d9 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2262,7 +2262,11 @@ ConfigureText( textPtr->selTagPtr->borderWidthPtr = textPtr->selBorderWidthPtr; textPtr->selTagPtr->borderWidth = textPtr->selBorderWidth; } - textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; + if (textPtr->selTagPtr->selFgColor == NULL) { + textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; + } else { + textPtr->selTagPtr->selFgColor = textPtr->selFgColorPtr; + } textPtr->selTagPtr->affectsDisplay = 0; textPtr->selTagPtr->affectsDisplayGeometry = 0; if ((textPtr->selTagPtr->elideString != NULL) @@ -2285,6 +2289,7 @@ ConfigureText( || (textPtr->selTagPtr->reliefString != NULL) || (textPtr->selTagPtr->bgStipple != None) || (textPtr->selTagPtr->fgColor != NULL) + || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) || (textPtr->selTagPtr->underlineString != NULL)) { diff --git a/generic/tkText.h b/generic/tkText.h index 5cd009f..3056ab8 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -364,6 +364,8 @@ typedef struct TkTextTag { * valid if rMarginString is non-NULL. */ Tk_3DBorder selBorder; /* Used for drawing background for selected text. * NULL means no value specified here. */ + XColor *selFgColor; /* Foreground color for selected text. NULL means + * no value specified here. */ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL * means option not specified. */ int spacing1; /* Extra spacing above first display line for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1bd5905..e8f8d79 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -798,9 +798,11 @@ GetStyle( for (i = 0 ; i < numTags; i++) { Tk_3DBorder border; + XColor *fgColor; tagPtr = tagPtrs[i]; border = tagPtr->border; + fgColor = tagPtr->fgColor; /* * If this is the selection tag, and inactiveSelBorder is NULL (the @@ -824,6 +826,10 @@ GetStyle( border = tagPtr->selBorder; } + if ((tagPtr->selFgColor != None) && (isSelected)) { + fgColor = tagPtr->selFgColor; + } + if ((border != NULL) && (tagPtr->priority > borderPrio)) { styleValues.border = border; borderPrio = tagPtr->priority; @@ -847,8 +853,8 @@ GetStyle( styleValues.bgStipple = tagPtr->bgStipple; bgStipplePrio = tagPtr->priority; } - if ((tagPtr->fgColor != None) && (tagPtr->priority > fgPrio)) { - styleValues.fgColor = tagPtr->fgColor; + if ((fgColor != None) && (tagPtr->priority > fgPrio)) { + styleValues.fgColor = fgColor; fgPrio = tagPtr->priority; } if ((tagPtr->tkfont != None) && (tagPtr->priority > fontPrio)) { diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index a857cf9..97356ed 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -72,6 +72,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, spacing1String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-spacing2", NULL, NULL, @@ -493,7 +495,11 @@ TkTextTagCmd( } textPtr->selBorderWidth = tagPtr->borderWidth; textPtr->selBorderWidthPtr = tagPtr->borderWidthPtr; - textPtr->selFgColorPtr = tagPtr->fgColor; + if (tagPtr->selFgColor == NULL) { + textPtr->selFgColorPtr = tagPtr->fgColor; + } else { + textPtr->selFgColorPtr = tagPtr->selFgColor; + } } tagPtr->affectsDisplay = 0; @@ -519,6 +525,7 @@ TkTextTagCmd( || (tagPtr->reliefString != NULL) || (tagPtr->bgStipple != None) || (tagPtr->fgColor != NULL) + || (tagPtr->selFgColor != NULL) || (tagPtr->fgStipple != None) || (tagPtr->overstrikeString != NULL) || (tagPtr->underlineString != NULL)) { @@ -1025,6 +1032,7 @@ TkTextCreateTag( tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; tagPtr->selBorder = NULL; + tagPtr->selFgColor = NULL; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; tagPtr->spacing2String = NULL; -- cgit v0.12 From 8ffa9516ef4ea4b1d2bded2bc05999322889a15a Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:29:50 +0000 Subject: -selectforeground tag configuration option: documentation --- doc/text.n | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/text.n b/doc/text.n index 41d6a6f..61808ce 100644 --- a/doc/text.n +++ b/doc/text.n @@ -524,6 +524,13 @@ items. It may have any of the forms accepted by \fBTk_GetColor\fR. If string, then the color specified by the fB\-background\fR tag option is used. .TP +\fB\-selectforeground \fIcolor\fR +\fIcolor\fR specifies the foreground color to use when displaying selected +items. It may have any of the forms accepted by \fBTk_GetColor\fR. If +\fIcolor\fR has not been specified, or if it is specified as an empty +string, then the color specified by the fB\-foreground\fR tag option is +used. +.TP \fB\-spacing1 \fIpixels\fR . \fIPixels\fR specifies how much additional space should be left above each -- cgit v0.12 From 91073e4b5a77eb86aadddb05d9666a89f9b81907 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:30:11 +0000 Subject: -selectforeground tag configuration option: tests --- tests/textTag.test | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/textTag.test b/tests/textTag.test index a7935da..8b5ac74 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -239,6 +239,17 @@ test textTag-1.25b {configuration options} -body { } -cleanup { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -returnCodes error -result {unknown color name "non-existent"} +test textTag-1.25c {tag configuration options} -body { + .t tag configure x -selectforeground #012345 + .t tag cget x -selectforeground +} -cleanup { + .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] +} -result {#012345} +test textTag-1.25d {configuration options} -body { + .t tag configure x -selectforeground non-existent +} -cleanup { + .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] +} -returnCodes error -result {unknown color name "non-existent"} test textTag-1.26 {tag configuration options} -constraints { haveCourier12 } -body { @@ -747,6 +758,29 @@ test textTag-5.23 {TkTextTagCmd - "configure" option} -body { lappend x [.t cget -selectbackground] return $x } -result {yellow blue red white} +test textTag-5.24 {TkTextTagCmd - "configure" option} -body { + set x {} + # when [.t tag cget sel -selectforeground] == "", mirroring happens between + # the text widget option -selectforeground + # and the tag option -foreground + .t tag configure sel -selectforeground {} + .t configure -selectforeground black + .t tag configure sel -foreground yellow + lappend x [.t cget -selectforeground] + .t tag configure sel -foreground orange + .t configure -selectforeground blue + lappend x [.t tag cget sel -foreground] + # when [.t tag cget sel -selectforeground] != "", mirroring happens between + # the text widget option -selectforeground + # and the tag option -selectforeground + .t tag configure sel -selectforeground green + .t configure -selectforeground red + lappend x [.t tag cget sel -selectforeground] + .t configure -selectforeground black + .t tag configure sel -selectforeground white + lappend x [.t cget -selectforeground] + return $x +} -result {yellow blue red white} test textTag-6.1 {TkTextTagCmd - "delete" option} -constraints { haveCourier12 -- cgit v0.12 From 5d588d31457d24ca04b54f6f1c92647e6a3d2b50 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:32:10 +0000 Subject: -selectbgstipple tag configuration option: implementation --- generic/tkText.c | 1 + generic/tkText.h | 2 ++ generic/tkTextDisp.c | 10 ++++++++-- generic/tkTextTag.c | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 464d4d9..7a2a6d5 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2288,6 +2288,7 @@ ConfigureText( || (textPtr->selTagPtr->selBorder != NULL) || (textPtr->selTagPtr->reliefString != NULL) || (textPtr->selTagPtr->bgStipple != None) + || (textPtr->selTagPtr->selBgStipple != None) || (textPtr->selTagPtr->fgColor != NULL) || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) diff --git a/generic/tkText.h b/generic/tkText.h index 3056ab8..c8a71b3 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -364,6 +364,8 @@ typedef struct TkTextTag { * valid if rMarginString is non-NULL. */ Tk_3DBorder selBorder; /* Used for drawing background for selected text. * NULL means no value specified here. */ + Pixmap selBgStipple; /* Stipple bitmap for background of selected text. + * None means no value specified here. */ XColor *selFgColor; /* Foreground color for selected text. NULL means * no value specified here. */ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index e8f8d79..0ccd3c2 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -798,10 +798,12 @@ GetStyle( for (i = 0 ; i < numTags; i++) { Tk_3DBorder border; + Pixmap bgStipple; XColor *fgColor; tagPtr = tagPtrs[i]; border = tagPtr->border; + bgStipple = tagPtr->bgStipple; fgColor = tagPtr->fgColor; /* @@ -826,6 +828,10 @@ GetStyle( border = tagPtr->selBorder; } + if ((tagPtr->selBgStipple != None) && (isSelected)) { + bgStipple = tagPtr->selBgStipple; + } + if ((tagPtr->selFgColor != None) && (isSelected)) { fgColor = tagPtr->selFgColor; } @@ -848,9 +854,9 @@ GetStyle( styleValues.relief = tagPtr->relief; reliefPrio = tagPtr->priority; } - if ((tagPtr->bgStipple != None) + if ((bgStipple != None) && (tagPtr->priority > bgStipplePrio)) { - styleValues.bgStipple = tagPtr->bgStipple; + styleValues.bgStipple = bgStipple; bgStipplePrio = tagPtr->priority; } if ((fgColor != None) && (tagPtr->priority > fgPrio)) { diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 97356ed..86a6e77 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -72,6 +72,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_BITMAP, "-selectbgstipple", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, selBgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, @@ -524,6 +526,7 @@ TkTextTagCmd( || (tagPtr->selBorder != NULL) || (tagPtr->reliefString != NULL) || (tagPtr->bgStipple != None) + || (tagPtr->selBgStipple != None) || (tagPtr->fgColor != NULL) || (tagPtr->selFgColor != NULL) || (tagPtr->fgStipple != None) @@ -1032,6 +1035,7 @@ TkTextCreateTag( tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; tagPtr->selBorder = NULL; + tagPtr->selBgStipple = None; tagPtr->selFgColor = NULL; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; -- cgit v0.12 From 28fda9f36ca5e2e5cb00e56da38cd13e8391f44d Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:32:41 +0000 Subject: -selectbgstipple tag configuration option: documentation --- doc/text.n | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/text.n b/doc/text.n index 61808ce..a8f25c9 100644 --- a/doc/text.n +++ b/doc/text.n @@ -524,6 +524,14 @@ items. It may have any of the forms accepted by \fBTk_GetColor\fR. If string, then the color specified by the fB\-background\fR tag option is used. .TP +\fB\-selectbgstipple \fIbitmap\fR +. +\fIBitmap\fR specifies a bitmap that is used as a stipple pattern for the +selected background. It may have any of the forms accepted by +\fBTk_GetBitmap\fR. If \fIbitmap\fR has not been specified, or if it is +specified as an empty string, then the \fIbitmap\fR specified by +'''-bgstipple''' will be used for the background. +.TP \fB\-selectforeground \fIcolor\fR \fIcolor\fR specifies the foreground color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If -- cgit v0.12 From fe236b4cfe544d14e84df23e27d07f7efba752d5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:33:07 +0000 Subject: -selectbgstipple tag configuration option: tests --- tests/textTag.test | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/textTag.test b/tests/textTag.test index 8b5ac74..63081f3 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -240,12 +240,23 @@ test textTag-1.25b {configuration options} -body { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -returnCodes error -result {unknown color name "non-existent"} test textTag-1.25c {tag configuration options} -body { + .t tag configure x -selectbgstipple gray50 + .t tag cget x -selectbgstipple +} -cleanup { + .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] +} -result {gray50} +test textTag-1.25d {configuration options} -body { + .t tag configure x -selectbgstipple badStipple +} -cleanup { + .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] +} -returnCodes error -result {bitmap "badStipple" not defined} +test textTag-1.25e {tag configuration options} -body { .t tag configure x -selectforeground #012345 .t tag cget x -selectforeground } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] } -result {#012345} -test textTag-1.25d {configuration options} -body { +test textTag-1.25f {configuration options} -body { .t tag configure x -selectforeground non-existent } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] -- cgit v0.12 From da061a037670e4bc29f960a349403aac50cd915c Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:36:19 +0000 Subject: -selectfgstipple tag configuration option: implementation --- generic/tkText.c | 1 + generic/tkText.h | 3 +++ generic/tkTextDisp.c | 10 ++++++++-- generic/tkTextTag.c | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 7a2a6d5..ccc9691 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2292,6 +2292,7 @@ ConfigureText( || (textPtr->selTagPtr->fgColor != NULL) || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) + || (textPtr->selTagPtr->selFgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) || (textPtr->selTagPtr->underlineString != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; diff --git a/generic/tkText.h b/generic/tkText.h index c8a71b3..1a7d986 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -368,6 +368,9 @@ typedef struct TkTextTag { * None means no value specified here. */ XColor *selFgColor; /* Foreground color for selected text. NULL means * no value specified here. */ + Pixmap selFgStipple; /* Stipple bitmap for text and other + * foreground stuff when selected. None means + * no value specified here.*/ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL * means option not specified. */ int spacing1; /* Extra spacing above first display line for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 0ccd3c2..d0c1483 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -800,11 +800,13 @@ GetStyle( Tk_3DBorder border; Pixmap bgStipple; XColor *fgColor; + Pixmap fgStipple; tagPtr = tagPtrs[i]; border = tagPtr->border; bgStipple = tagPtr->bgStipple; fgColor = tagPtr->fgColor; + fgStipple = tagPtr->fgStipple; /* * If this is the selection tag, and inactiveSelBorder is NULL (the @@ -836,6 +838,10 @@ GetStyle( fgColor = tagPtr->selFgColor; } + if ((tagPtr->selFgStipple != None) && (isSelected)) { + bgStipple = tagPtr->selFgStipple; + } + if ((border != NULL) && (tagPtr->priority > borderPrio)) { styleValues.border = border; borderPrio = tagPtr->priority; @@ -867,9 +873,9 @@ GetStyle( styleValues.tkfont = tagPtr->tkfont; fontPrio = tagPtr->priority; } - if ((tagPtr->fgStipple != None) + if ((fgStipple != None) && (tagPtr->priority > fgStipplePrio)) { - styleValues.fgStipple = tagPtr->fgStipple; + styleValues.fgStipple = fgStipple; fgStipplePrio = tagPtr->priority; } if ((tagPtr->justifyString != NULL) diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 86a6e77..bb512e4 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -74,6 +74,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BITMAP, "-selectbgstipple", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBgStipple), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_BITMAP, "-selectfgstipple", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, selFgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, @@ -530,6 +532,7 @@ TkTextTagCmd( || (tagPtr->fgColor != NULL) || (tagPtr->selFgColor != NULL) || (tagPtr->fgStipple != None) + || (tagPtr->selFgStipple != None) || (tagPtr->overstrikeString != NULL) || (tagPtr->underlineString != NULL)) { tagPtr->affectsDisplay = 1; @@ -1037,6 +1040,7 @@ TkTextCreateTag( tagPtr->selBorder = NULL; tagPtr->selBgStipple = None; tagPtr->selFgColor = NULL; + tagPtr->selFgStipple = None; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; tagPtr->spacing2String = NULL; -- cgit v0.12 From 196fc0f4ea980dfeed790a1c2f5e4cae7077c0b4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:36:41 +0000 Subject: -selectfgstipple tag configuration option: documentation (+ polished doc of the previously developed new tag options) --- doc/text.n | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/text.n b/doc/text.n index a8f25c9..0216e5c 100644 --- a/doc/text.n +++ b/doc/text.n @@ -518,10 +518,10 @@ margin for each line on the display is determined by the first non-elided character of that display line. .TP \fB\-selectbackground \fIcolor\fR -\fIcolor\fR specifies the background color to use when displaying selected +\fIColor\fR specifies the background color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not been specified, or if it is specified as an empty -string, then the color specified by the fB\-background\fR tag option is +string, then the color specified by the \fB\-background\fR tag option is used. .TP \fB\-selectbgstipple \fIbitmap\fR @@ -529,14 +529,22 @@ used. \fIBitmap\fR specifies a bitmap that is used as a stipple pattern for the selected background. It may have any of the forms accepted by \fBTk_GetBitmap\fR. If \fIbitmap\fR has not been specified, or if it is -specified as an empty string, then the \fIbitmap\fR specified by -'''-bgstipple''' will be used for the background. +specified as an empty string, then the bitmap specified by +\fB\-bgstipple\fR will be used for the background. +.TP +\fB\-selectfgstipple \fIbitmap\fR +. +\fIBitmap\fR specifies a bitmap that is used as a stipple pattern when drawing +selected text and other foreground information such as underlines. It may have any of +the forms accepted by \fBTk_GetBitmap\fR. If \fIbitmap\fR has not been +specified, or if it is specified as an empty string, then the bitmap specified by +\fB\-fgstipple\fR will be used. .TP \fB\-selectforeground \fIcolor\fR -\fIcolor\fR specifies the foreground color to use when displaying selected +\fIColor\fR specifies the foreground color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not been specified, or if it is specified as an empty -string, then the color specified by the fB\-foreground\fR tag option is +string, then the color specified by the \fB\-foreground\fR tag option is used. .TP \fB\-spacing1 \fIpixels\fR -- cgit v0.12 From e108f0116e3154bacd641f8f85529512a2b9046f Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:37:33 +0000 Subject: -selectfgstipple tag configuration option: tests --- tests/textTag.test | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/textTag.test b/tests/textTag.test index 63081f3..ede86fd 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -251,12 +251,23 @@ test textTag-1.25d {configuration options} -body { .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] } -returnCodes error -result {bitmap "badStipple" not defined} test textTag-1.25e {tag configuration options} -body { + .t tag configure x -selectfgstipple gray50 + .t tag cget x -selectfgstipple +} -cleanup { + .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] +} -result {gray50} +test textTag-1.25f {configuration options} -body { + .t tag configure x -selectfgstipple badStipple +} -cleanup { + .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] +} -returnCodes error -result {bitmap "badStipple" not defined} +test textTag-1.25g {tag configuration options} -body { .t tag configure x -selectforeground #012345 .t tag cget x -selectforeground } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] } -result {#012345} -test textTag-1.25f {configuration options} -body { +test textTag-1.25h {configuration options} -body { .t tag configure x -selectforeground non-existent } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] -- cgit v0.12 From 62609c21da13af24e1df10132bdb5effc1d3ea7a Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:40:51 +0000 Subject: -underlinefg tag configuration option: implementation --- generic/tkText.c | 3 ++- generic/tkText.h | 4 +++- generic/tkTextDisp.c | 19 +++++++++++++++++-- generic/tkTextTag.c | 6 +++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index ccc9691..7010601 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2294,7 +2294,8 @@ ConfigureText( || (textPtr->selTagPtr->fgStipple != None) || (textPtr->selTagPtr->selFgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) - || (textPtr->selTagPtr->underlineString != NULL)) { + || (textPtr->selTagPtr->underlineString != NULL) + || (textPtr->selTagPtr->underlineColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); diff --git a/generic/tkText.h b/generic/tkText.h index 1a7d986..815841c 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -398,7 +398,9 @@ typedef struct TkTextTag { int underline; /* Non-zero means draw underline underneath * text. Only valid if underlineString is * non-NULL. */ - TkWrapMode wrapMode; /* How to handle wrap-around for this tag. + XColor *underlineColor; /* Color for the underline. NULL means same + * color as foreground. */ + TkWrapMode wrapMode; /* How to hsandle wrap-around for this tag. * Must be TEXT_WRAPMODE_CHAR, * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or * TEXT_WRAPMODE_NULL to use wrapmode for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index d0c1483..f246818 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -149,6 +149,8 @@ typedef struct StyleValues { int tabStyle; /* One of TABULAR or WORDPROCESSOR. */ int underline; /* Non-zero means draw underline underneath * text. */ + XColor *underlineColor; /* Foreground color for underline underneath + * text. */ int elide; /* Zero means draw text, otherwise not. */ TkWrapMode wrapMode; /* How to handle wrap-around for this tag. * One of TEXT_WRAPMODE_CHAR, @@ -166,6 +168,7 @@ typedef struct TextStyle { * referenced in Chunks. */ GC bgGC; /* Graphics context for background. None means * use widget background. */ + GC ulGC; /* Graphics context for underline. */ GC fgGC; /* Graphics context for foreground. */ StyleValues *sValuePtr; /* Raw information from which GCs were * derived. */ @@ -778,6 +781,7 @@ GetStyle( memset(&styleValues, 0, sizeof(StyleValues)); styleValues.relief = TK_RELIEF_FLAT; styleValues.fgColor = textPtr->fgColor; + styleValues.underlineColor = textPtr->fgColor; styleValues.tkfont = textPtr->tkfont; styleValues.justify = TK_JUSTIFY_LEFT; styleValues.spacing1 = textPtr->spacing1; @@ -937,6 +941,11 @@ GetStyle( && (tagPtr->priority > underlinePrio)) { styleValues.underline = tagPtr->underline; underlinePrio = tagPtr->priority; + if (tagPtr->underlineColor != None) { + styleValues.underlineColor = tagPtr->underlineColor; + } else if (fgColor != None) { + styleValues.underlineColor = fgColor; + } } if ((tagPtr->elideString != NULL) && (tagPtr->priority > elidePrio)) { @@ -993,6 +1002,9 @@ GetStyle( mask |= GCStipple|GCFillStyle; } stylePtr->fgGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); + mask = GCForeground; + gcValues.foreground = styleValues.underlineColor->pixel; + stylePtr->ulGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); stylePtr->sValuePtr = (StyleValues *) Tcl_GetHashKey(&textPtr->dInfoPtr->styleTable, hPtr); stylePtr->hPtr = hPtr; @@ -1033,6 +1045,9 @@ FreeStyle( if (stylePtr->fgGC != None) { Tk_FreeGC(textPtr->display, stylePtr->fgGC); } + if (stylePtr->ulGC != None) { + Tk_FreeGC(textPtr->display, stylePtr->ulGC); + } Tcl_DeleteHashEntry(stylePtr->hPtr); ckfree(stylePtr); } @@ -7876,7 +7891,7 @@ CharDisplayProc( y + baseline - sValuePtr->offset); if (sValuePtr->underline) { - TkUnderlineCharsInContext(display, dst, stylePtr->fgGC, + TkUnderlineCharsInContext(display, dst, stylePtr->ulGC, sValuePtr->tkfont, string, numBytes, ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset, @@ -7903,7 +7918,7 @@ CharDisplayProc( Tk_DrawChars(display, dst, stylePtr->fgGC, sValuePtr->tkfont, string, numBytes, offsetX, y + baseline - sValuePtr->offset); if (sValuePtr->underline) { - Tk_UnderlineChars(display, dst, stylePtr->fgGC, sValuePtr->tkfont, + Tk_UnderlineChars(display, dst, stylePtr->ulGC, sValuePtr->tkfont, string, offsetX, y + baseline - sValuePtr->offset, 0, numBytes); diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index bb512e4..ed0ef98 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -92,6 +92,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_STRING, "-underline", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, underlineString), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_COLOR, "-underlinefg", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, underlineColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, wrapMode), TK_OPTION_NULL_OK, wrapStrings, 0}, @@ -534,7 +536,8 @@ TkTextTagCmd( || (tagPtr->fgStipple != None) || (tagPtr->selFgStipple != None) || (tagPtr->overstrikeString != NULL) - || (tagPtr->underlineString != NULL)) { + || (tagPtr->underlineString != NULL) + || (tagPtr->underlineColor != NULL)) { tagPtr->affectsDisplay = 1; } if (!newTag) { @@ -1052,6 +1055,7 @@ TkTextCreateTag( tagPtr->tabStyle = TK_TEXT_TABSTYLE_NONE; tagPtr->underlineString = NULL; tagPtr->underline = 0; + tagPtr->underlineColor = NULL; tagPtr->elideString = NULL; tagPtr->elide = 0; tagPtr->wrapMode = TEXT_WRAPMODE_NULL; -- cgit v0.12 From ecdc7dbb08227389f593c55a3b769a4e1ec9c8aa Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:41:37 +0000 Subject: -underlinefg tag configuration option: documentation --- doc/text.n | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/text.n b/doc/text.n index 0216e5c..e88728c 100644 --- a/doc/text.n +++ b/doc/text.n @@ -589,6 +589,14 @@ unspecified for the tag (the default). \fIBoolean\fR specifies whether or not to draw an underline underneath characters. It may have any of the forms accepted by \fBTcl_GetBoolean\fR. .TP +.TP +\fB\-underlinefg \fIcolor\fR +. +\fIColor\fR specifies the color to use when displaying the underline. It may +have any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not +been specified, or if it is specified as an empty string, then the color +specified by the \fB\-foreground\fR tag option is used. +.TP \fB\-wrap \fImode\fR . \fIMode\fR specifies how to handle lines that are wider than the text's -- cgit v0.12 From 797f245ca2d4aafd6a0f7ad853cccd32a7942171 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:42:17 +0000 Subject: -underlinefg tag configuration option: tests --- tests/textTag.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/textTag.test b/tests/textTag.test index ede86fd..ae71a48 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -347,6 +347,17 @@ test textTag-1.35 {configuration options} -constraints { } -cleanup { .t tag configure x -underline [lindex [.t tag configure x -underline] 3] } -returnCodes error -result {expected boolean value but got "stupid"} +test textTag-1.36 {tag configuration options} -body { + .t tag configure x -underlinefg red + .t tag cget x -underlinefg +} -cleanup { + .t tag configure x -underlinefg [lindex [.t tag configure x -underlinefg] 3] +} -result {red} +test textTag-1.37 {configuration options} -body { + .t tag configure x -underlinefg stupid +} -cleanup { + .t tag configure x -underlinefg [lindex [.t tag configure x -underlinefg] 3] +} -returnCodes error -result {unknown color name "stupid"} test textTag-2.1 {TkTextTagCmd - "add" option} -constraints { @@ -603,6 +614,13 @@ test textTag-5.4 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -result {-underline {} {} {} yes} +test textTag-5.4a {TkTextTagCmd - "configure" option} -body { + .t tag delete x + .t tag configure x -underlinefg lightgreen + .t tag configure x -underlinefg +} -cleanup { + .t tag delete x +} -result {-underlinefg {} {} {} lightgreen} test textTag-5.5 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { -- cgit v0.12 From 7c5f4b62829c4efa7ee754d566c45a0be0ace440 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:44:23 +0000 Subject: -overstrikefg tag configuration option: implementation --- generic/tkText.c | 1 + generic/tkText.h | 2 ++ generic/tkTextDisp.c | 20 +++++++++++++++++--- generic/tkTextTag.c | 8 +++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 7010601..19dce65 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2294,6 +2294,7 @@ ConfigureText( || (textPtr->selTagPtr->fgStipple != None) || (textPtr->selTagPtr->selFgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) + || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) || (textPtr->selTagPtr->underlineColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; diff --git a/generic/tkText.h b/generic/tkText.h index 815841c..242785a 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -358,6 +358,8 @@ typedef struct TkTextTag { int overstrike; /* Non-zero means draw horizontal line through * middle of text. Only valid if * overstrikeString is non-NULL. */ + XColor *overstrikeColor; /* Color for the overstrike. NULL means same + * color as foreground. */ char *rMarginString; /* -rmargin option string (malloc-ed). NULL * means option not specified. */ int rMargin; /* Right margin for text, in pixels. Only diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f246818..b74c6db 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -140,6 +140,8 @@ typedef struct StyleValues { * baseline of line. */ int overstrike; /* Non-zero means draw overstrike through * text. */ + XColor *overstrikeColor; /* Foreground color for overstrike through + * text. */ int rMargin; /* Right margin, in pixels. */ int spacing1; /* Spacing above first dline in text line. */ int spacing2; /* Spacing between lines of dline. */ @@ -168,8 +170,9 @@ typedef struct TextStyle { * referenced in Chunks. */ GC bgGC; /* Graphics context for background. None means * use widget background. */ - GC ulGC; /* Graphics context for underline. */ GC fgGC; /* Graphics context for foreground. */ + GC ulGC; /* Graphics context for underline. */ + GC ovGC; /* Graphics context for overstrike. */ StyleValues *sValuePtr; /* Raw information from which GCs were * derived. */ Tcl_HashEntry *hPtr; /* Pointer to entry in styleTable. Used to @@ -782,6 +785,7 @@ GetStyle( styleValues.relief = TK_RELIEF_FLAT; styleValues.fgColor = textPtr->fgColor; styleValues.underlineColor = textPtr->fgColor; + styleValues.overstrikeColor = textPtr->fgColor; styleValues.tkfont = textPtr->tkfont; styleValues.justify = TK_JUSTIFY_LEFT; styleValues.spacing1 = textPtr->spacing1; @@ -906,6 +910,11 @@ GetStyle( && (tagPtr->priority > overstrikePrio)) { styleValues.overstrike = tagPtr->overstrike; overstrikePrio = tagPtr->priority; + if (tagPtr->overstrikeColor != None) { + styleValues.overstrikeColor = tagPtr->overstrikeColor; + } else if (fgColor != None) { + styleValues.overstrikeColor = fgColor; + } } if ((tagPtr->rMarginString != NULL) && (tagPtr->priority > rMarginPrio)) { @@ -1005,6 +1014,8 @@ GetStyle( mask = GCForeground; gcValues.foreground = styleValues.underlineColor->pixel; stylePtr->ulGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); + gcValues.foreground = styleValues.overstrikeColor->pixel; + stylePtr->ovGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); stylePtr->sValuePtr = (StyleValues *) Tcl_GetHashKey(&textPtr->dInfoPtr->styleTable, hPtr); stylePtr->hPtr = hPtr; @@ -1048,6 +1059,9 @@ FreeStyle( if (stylePtr->ulGC != None) { Tk_FreeGC(textPtr->display, stylePtr->ulGC); } + if (stylePtr->ovGC != None) { + Tk_FreeGC(textPtr->display, stylePtr->ovGC); + } Tcl_DeleteHashEntry(stylePtr->hPtr); ckfree(stylePtr); } @@ -7901,7 +7915,7 @@ CharDisplayProc( Tk_FontMetrics fm; Tk_GetFontMetrics(sValuePtr->tkfont, &fm); - TkUnderlineCharsInContext(display, dst, stylePtr->fgGC, + TkUnderlineCharsInContext(display, dst, stylePtr->ovGC, sValuePtr->tkfont, string, numBytes, ciPtr->baseChunkPtr->x + xDisplacement, y + baseline - sValuePtr->offset @@ -7928,7 +7942,7 @@ CharDisplayProc( Tk_FontMetrics fm; Tk_GetFontMetrics(sValuePtr->tkfont, &fm); - Tk_UnderlineChars(display, dst, stylePtr->fgGC, sValuePtr->tkfont, + Tk_UnderlineChars(display, dst, stylePtr->ovGC, sValuePtr->tkfont, string, offsetX, y + baseline - sValuePtr->offset - fm.descent - (fm.ascent * 3) / 10, diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index ed0ef98..e268352 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -66,6 +66,9 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_STRING, "-overstrike", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, overstrikeString), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_COLOR, "-overstrikefg", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, overstrikeColor), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-relief", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-rmargin", NULL, NULL, @@ -93,7 +96,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, underlineString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-underlinefg", NULL, NULL, - NULL, -1, Tk_Offset(TkTextTag, underlineColor), TK_OPTION_NULL_OK, 0, 0}, + NULL, -1, Tk_Offset(TkTextTag, underlineColor), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, wrapMode), TK_OPTION_NULL_OK, wrapStrings, 0}, @@ -536,6 +540,7 @@ TkTextTagCmd( || (tagPtr->fgStipple != None) || (tagPtr->selFgStipple != None) || (tagPtr->overstrikeString != NULL) + || (tagPtr->overstrikeColor != NULL) || (tagPtr->underlineString != NULL) || (tagPtr->underlineColor != NULL)) { tagPtr->affectsDisplay = 1; @@ -1038,6 +1043,7 @@ TkTextCreateTag( tagPtr->offset = 0; tagPtr->overstrikeString = NULL; tagPtr->overstrike = 0; + tagPtr->overstrikeColor = NULL; tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; tagPtr->selBorder = NULL; -- cgit v0.12 From 935d5f2814f55a18088b4ce4a3cfc6cb76fa86df Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:44:48 +0000 Subject: -overstrikefg tag configuration option: documentation --- doc/text.n | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/text.n b/doc/text.n index e88728c..fd18a59 100644 --- a/doc/text.n +++ b/doc/text.n @@ -500,6 +500,13 @@ Specifies whether or not to draw a horizontal rule through the middle of characters. \fIBoolean\fR may have any of the forms accepted by \fBTcl_GetBoolean\fR. .TP +\fB\-overstrikefg \fIcolor\fR +. +\fIColor\fR specifies the color to use when displaying the overstrike. It may +have any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not +been specified, or if it is specified as an empty string, then the color +specified by the \fB\-foreground\fR tag option is used. +.TP \fB\-relief \fIrelief\fR . \fIRelief\fR specifies the relief style to use for drawing the border, in any @@ -589,7 +596,6 @@ unspecified for the tag (the default). \fIBoolean\fR specifies whether or not to draw an underline underneath characters. It may have any of the forms accepted by \fBTcl_GetBoolean\fR. .TP -.TP \fB\-underlinefg \fIcolor\fR . \fIColor\fR specifies the color to use when displaying the underline. It may -- cgit v0.12 From 74d865bb3e520e131dc6655986fe79141120c2e9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 9 Feb 2016 21:45:19 +0000 Subject: -overstrikefg tag configuration option: tests --- tests/textTag.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/textTag.test b/tests/textTag.test index ae71a48..c2feaa7 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -198,6 +198,17 @@ test textTag-1.21 {configuration options} -constraints { } -cleanup { .t tag configure x -overstrike [lindex [.t tag configure x -overstrike] 3] } -returnCodes error -result {expected boolean value but got "stupid"} +test textTag-1.21a {tag configuration options} -body { + .t tag configure x -overstrikefg red + .t tag cget x -overstrikefg +} -cleanup { + .t tag configure x -overstrikefg [lindex [.t tag configure x -overstrikefg] 3] +} -result {red} +test textTag-1.21b {configuration options} -body { + .t tag configure x -overstrikefg stupid +} -cleanup { + .t tag configure x -overstrikefg [lindex [.t tag configure x -overstrikefg] 3] +} -returnCodes error -result {unknown color name "stupid"} test textTag-1.22 {tag configuration options} -constraints { haveCourier12 } -body { @@ -630,6 +641,13 @@ test textTag-5.5 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -result {on} +test textTag-5.5a {TkTextTagCmd - "configure" option} -body { + .t tag delete x + .t tag configure x -overstrikefg lightgreen + .t tag configure x -overstrikefg +} -cleanup { + .t tag delete x +} -result {-overstrikefg {} {} {} lightgreen} test textTag-5.6 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { -- cgit v0.12 From 30a85a7ace1cf7ea9de7828dfb84fde2af23148b Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:51:45 +0000 Subject: -lmargincolor tag configuration option: implementation --- generic/tkText.c | 3 ++- generic/tkText.h | 3 +++ generic/tkTextDisp.c | 26 ++++++++++++++++++++++++++ generic/tkTextTag.c | 6 +++++- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 19dce65..415e0bc 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2296,7 +2296,8 @@ ConfigureText( || (textPtr->selTagPtr->overstrikeString != NULL) || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) - || (textPtr->selTagPtr->underlineColor != NULL)) { + || (textPtr->selTagPtr->underlineColor != NULL) + || (textPtr->selTagPtr->lMarginColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); diff --git a/generic/tkText.h b/generic/tkText.h index 242785a..22df370 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -347,6 +347,9 @@ typedef struct TkTextTag { int lMargin2; /* Left margin for second and later display * lines of each text line, in pixels. Only * valid if lMargin2String is non-NULL. */ + Tk_3DBorder lMarginColor; /* Used for drawing background in left margins. + * This is used for both lmargin1 and lmargin2. + * NULL means no value specified here. */ char *offsetString; /* -offset option string (malloc-ed). NULL * means option not specified. */ int offset; /* Vertical offset of text's baseline from diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index b74c6db..c0d6384 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -136,6 +136,7 @@ typedef struct StyleValues { * line of each text line. */ int lMargin2; /* Left margin, in pixels, for second and * later display lines of each text line. */ + Tk_3DBorder lMarginColor; /* Color of left margins (1 and 2). */ int offset; /* Offset in pixels of baseline, relative to * baseline of line. */ int overstrike; /* Non-zero means draw overstrike through @@ -240,6 +241,10 @@ typedef struct DLine { int spaceBelow; /* How much extra space was added to the * bottom of the line because of spacing * options. This is included in height. */ + Tk_3DBorder lMarginColor; /* Background color of the area corresponding + * to the left margin of the display line. */ + int lMarginWidth; /* Pixel width of the area corresponding to + * the left margin. */ int length; /* Total length of line, in pixels. */ TkTextDispChunk *chunkPtr; /* Pointer to first chunk in list of all of * those that are displayed on this line of @@ -765,6 +770,7 @@ GetStyle( int fgPrio, fontPrio, fgStipplePrio; int underlinePrio, elidePrio, justifyPrio, offsetPrio; int lMargin1Prio, lMargin2Prio, rMarginPrio; + int lMarginColorPrio; int spacing1Prio, spacing2Prio, spacing3Prio; int overstrikePrio, tabPrio, tabStylePrio, wrapPrio; @@ -779,6 +785,7 @@ GetStyle( fgPrio = fontPrio = fgStipplePrio = -1; underlinePrio = elidePrio = justifyPrio = offsetPrio = -1; lMargin1Prio = lMargin2Prio = rMarginPrio = -1; + lMarginColorPrio = -1; spacing1Prio = spacing2Prio = spacing3Prio = -1; overstrikePrio = tabPrio = tabStylePrio = wrapPrio = -1; memset(&styleValues, 0, sizeof(StyleValues)); @@ -901,6 +908,11 @@ GetStyle( styleValues.lMargin2 = tagPtr->lMargin2; lMargin2Prio = tagPtr->priority; } + if ((tagPtr->lMarginColor != NULL) + && (tagPtr->priority > lMarginColorPrio)) { + styleValues.lMarginColor = tagPtr->lMarginColor; + lMarginColorPrio = tagPtr->priority; + } if ((tagPtr->offsetString != NULL) && (tagPtr->priority > offsetPrio)) { styleValues.offset = tagPtr->offset; @@ -1173,6 +1185,8 @@ LayoutDLine( dlPtr->nextPtr = NULL; dlPtr->flags = NEW_LAYOUT | OLD_Y_INVALID; dlPtr->logicalLinesMerged = 0; + dlPtr->lMarginColor = NULL; + dlPtr->lMarginWidth = 0; /* * This is not necessarily totally correct, where we have merged logical @@ -1447,6 +1461,7 @@ LayoutDLine( x = chunkPtr->stylePtr->sValuePtr->lMargin2; } + dlPtr->lMarginWidth = x; if (wrapMode == TEXT_WRAPMODE_NONE) { maxX = -1; } else { @@ -1758,6 +1773,7 @@ LayoutDLine( } dlPtr->height += dlPtr->spaceAbove + dlPtr->spaceBelow; dlPtr->baseline += dlPtr->spaceAbove; + dlPtr->lMarginColor = sValuePtr->lMarginColor; /* * Recompute line length: may have changed because of justification. @@ -2444,6 +2460,16 @@ DisplayDLine( Tk_Width(textPtr->tkwin), dlPtr->height, 0, TK_RELIEF_FLAT); /* + * Second, draw the background color of the left margin. + */ + if (dlPtr->lMarginColor != NULL) { + int x = dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset; + + Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->lMarginColor, 0, y, + (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + } + + /* * Next, draw background information for the whole line. */ diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index e268352..a3e55fc 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -61,6 +61,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, lMargin1String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-lmargin2", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,0,0}, + {TK_OPTION_BORDER, "-lmargincolor", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-offset", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-overstrike", NULL, NULL, @@ -542,7 +544,8 @@ TkTextTagCmd( || (tagPtr->overstrikeString != NULL) || (tagPtr->overstrikeColor != NULL) || (tagPtr->underlineString != NULL) - || (tagPtr->underlineColor != NULL)) { + || (tagPtr->underlineColor != NULL) + || (tagPtr->lMarginColor != NULL)) { tagPtr->affectsDisplay = 1; } if (!newTag) { @@ -1039,6 +1042,7 @@ TkTextCreateTag( tagPtr->lMargin1 = 0; tagPtr->lMargin2String = NULL; tagPtr->lMargin2 = 0; + tagPtr->lMarginColor = NULL; tagPtr->offsetString = NULL; tagPtr->offset = 0; tagPtr->overstrikeString = NULL; -- cgit v0.12 From 3c2928472dcfca0f3053ad349df8b64e98a6923c Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:52:15 +0000 Subject: -lmargincolor tag configuration option: documentation --- doc/text.n | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/text.n b/doc/text.n index fd18a59..1e6dbc2 100644 --- a/doc/text.n +++ b/doc/text.n @@ -486,6 +486,15 @@ much the line should be indented from the left edge of the window. option is only used when wrapping is enabled, and it only applies to the second and later display lines for a text line. .TP +\fB\-lmargincolor \fIcolor\fR +. +\fIColor\fR specifies the background color to use in regions that do not +contain characters because they are indented by \fB\-lmargin1\fR or +\fB\-lmargin2\fR. It may have any of the forms accepted by +\fBTk_GetColor\fR.If \fIcolor\fR has not been specified, or if it is +specified as an empty string, then the color specified by the +\fB-background\fR widget option is used. +.TP \fB\-offset \fIpixels\fR . \fIPixels\fR specifies an amount by which the text's baseline should be offset -- cgit v0.12 From 47cbb49b5a939e1af93b945c53daa3177d9aeef0 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:52:33 +0000 Subject: -lmargincolor tag configuration option: tests --- tests/textTag.test | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/textTag.test b/tests/textTag.test index c2feaa7..9e0cf38 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -168,6 +168,17 @@ test textTag-1.17 {configuration options} -constraints { } -cleanup { .t tag configure x -lmargin2 [lindex [.t tag configure x -lmargin2] 3] } -returnCodes error -result {bad screen distance "bad"} +test textTag-1.17a {tag configuration options} -body { + .t tag configure x -lmargincolor lightgreen + .t tag cget x -lmargincolor +} -cleanup { + .t tag configure x -lmargincolor [lindex [.t tag configure x -lmargincolor] 3] +} -result {lightgreen} +test textTag-1.17b {configuration options} -body { + .t tag configure x -lmargincolor non-existent +} -cleanup { + .t tag configure x -lmargincolor [lindex [.t tag configure x -lmargincolor] 3] +} -returnCodes error -result {unknown color name "non-existent"} test textTag-1.18 {tag configuration options} -constraints { haveCourier12 } -body { @@ -705,16 +716,15 @@ test textTag-5.12 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -returnCodes error -result {bad screen distance "1.0q"} -test textTag-5.13 {TkTextTagCmd - "configure" option} -constraints { - haveCourier12 -} -body { +test textTag-5.13 {TkTextTagCmd - "configure" option} -body { .t tag delete x - .t tag configure x -lmargin1 2 -lmargin2 4 -rmargin 5 + .t tag configure x -lmargin1 2 -lmargin2 4 -rmargin 5 \ + -lmargincolor darkblue list [.t tag configure x -lmargin1] [.t tag configure x -lmargin2] \ - [.t tag configure x -rmargin] + [.t tag configure x -rmargin] [.t tag configure x -lmargincolor] } -cleanup { .t tag delete x -} -result {{-lmargin1 {} {} {} 2} {-lmargin2 {} {} {} 4} {-rmargin {} {} {} 5}} +} -result {{-lmargin1 {} {} {} 2} {-lmargin2 {} {} {} 4} {-rmargin {} {} {} 5} {-lmargincolor {} {} {} darkblue}} test textTag-5.14 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { @@ -731,6 +741,12 @@ test textTag-5.15 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -returnCodes error -result {bad screen distance "gorp"} +test textTag-5.15a {TkTextTagCmd - "configure" option} -body { + .t tag delete x + .t tag configure x -lmargincolor rainbow +} -cleanup { + .t tag delete x +} -returnCodes error -result {unknown color name "rainbow"} test textTag-5.16 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { -- cgit v0.12 From 3cea177e222e8c8b59cfcd693faa3581340d2c3d Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:53:30 +0000 Subject: -rmargincolor tag configuration option: implementation --- generic/tkText.c | 3 ++- generic/tkText.h | 2 ++ generic/tkTextDisp.c | 29 +++++++++++++++++++++++++---- generic/tkTextTag.c | 6 +++++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 415e0bc..0de648a 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2297,7 +2297,8 @@ ConfigureText( || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) || (textPtr->selTagPtr->underlineColor != NULL) - || (textPtr->selTagPtr->lMarginColor != NULL)) { + || (textPtr->selTagPtr->lMarginColor != NULL) + || (textPtr->selTagPtr->rMarginColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); diff --git a/generic/tkText.h b/generic/tkText.h index 22df370..8fab200 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -367,6 +367,8 @@ typedef struct TkTextTag { * means option not specified. */ int rMargin; /* Right margin for text, in pixels. Only * valid if rMarginString is non-NULL. */ + Tk_3DBorder rMarginColor; /* Used for drawing background in right margin. + * NULL means no value specified here. */ Tk_3DBorder selBorder; /* Used for drawing background for selected text. * NULL means no value specified here. */ Pixmap selBgStipple; /* Stipple bitmap for background of selected text. diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c0d6384..c0dc017 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -144,6 +144,7 @@ typedef struct StyleValues { XColor *overstrikeColor; /* Foreground color for overstrike through * text. */ int rMargin; /* Right margin, in pixels. */ + Tk_3DBorder rMarginColor; /* Color of right margin. */ int spacing1; /* Spacing above first dline in text line. */ int spacing2; /* Spacing between lines of dline. */ int spacing3; /* Spacing below last dline in text line. */ @@ -245,6 +246,10 @@ typedef struct DLine { * to the left margin of the display line. */ int lMarginWidth; /* Pixel width of the area corresponding to * the left margin. */ + Tk_3DBorder rMarginColor; /* Background color of the area corresponding + * to the right margin of the display line. */ + int rMarginWidth; /* Pixel width of the area corresponding to + * the right margin. */ int length; /* Total length of line, in pixels. */ TkTextDispChunk *chunkPtr; /* Pointer to first chunk in list of all of * those that are displayed on this line of @@ -770,7 +775,7 @@ GetStyle( int fgPrio, fontPrio, fgStipplePrio; int underlinePrio, elidePrio, justifyPrio, offsetPrio; int lMargin1Prio, lMargin2Prio, rMarginPrio; - int lMarginColorPrio; + int lMarginColorPrio, rMarginColorPrio; int spacing1Prio, spacing2Prio, spacing3Prio; int overstrikePrio, tabPrio, tabStylePrio, wrapPrio; @@ -785,7 +790,7 @@ GetStyle( fgPrio = fontPrio = fgStipplePrio = -1; underlinePrio = elidePrio = justifyPrio = offsetPrio = -1; lMargin1Prio = lMargin2Prio = rMarginPrio = -1; - lMarginColorPrio = -1; + lMarginColorPrio = rMarginColorPrio = -1; spacing1Prio = spacing2Prio = spacing3Prio = -1; overstrikePrio = tabPrio = tabStylePrio = wrapPrio = -1; memset(&styleValues, 0, sizeof(StyleValues)); @@ -933,6 +938,11 @@ GetStyle( styleValues.rMargin = tagPtr->rMargin; rMarginPrio = tagPtr->priority; } + if ((tagPtr->rMarginColor != NULL) + && (tagPtr->priority > rMarginColorPrio)) { + styleValues.rMarginColor = tagPtr->rMarginColor; + rMarginColorPrio = tagPtr->priority; + } if ((tagPtr->spacing1String != NULL) && (tagPtr->priority > spacing1Prio)) { styleValues.spacing1 = tagPtr->spacing1; @@ -1187,6 +1197,8 @@ LayoutDLine( dlPtr->logicalLinesMerged = 0; dlPtr->lMarginColor = NULL; dlPtr->lMarginWidth = 0; + dlPtr->rMarginColor = NULL; + dlPtr->rMarginWidth = 0; /* * This is not necessarily totally correct, where we have merged logical @@ -1774,6 +1786,10 @@ LayoutDLine( dlPtr->height += dlPtr->spaceAbove + dlPtr->spaceBelow; dlPtr->baseline += dlPtr->spaceAbove; dlPtr->lMarginColor = sValuePtr->lMarginColor; + dlPtr->rMarginColor = sValuePtr->rMarginColor; + if (wrapMode != TEXT_WRAPMODE_NONE) { + dlPtr->rMarginWidth = rMargin; + } /* * Recompute line length: may have changed because of justification. @@ -2460,13 +2476,18 @@ DisplayDLine( Tk_Width(textPtr->tkwin), dlPtr->height, 0, TK_RELIEF_FLAT); /* - * Second, draw the background color of the left margin. + * Second, draw the background color of the left and right margins. */ if (dlPtr->lMarginColor != NULL) { int x = dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset; Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->lMarginColor, 0, y, - (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + } + if (dlPtr->rMarginColor != NULL) { + Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->rMarginColor, + dInfoPtr->maxX - dlPtr->rMarginWidth + dInfoPtr->curXPixelOffset, + y, dlPtr->rMarginWidth, dlPtr->height, 0, TK_RELIEF_FLAT); } /* diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index a3e55fc..49d6a50 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -75,6 +75,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-rmargin", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, + {TK_OPTION_BORDER, "-rmargincolor", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BITMAP, "-selectbgstipple", NULL, NULL, @@ -545,7 +547,8 @@ TkTextTagCmd( || (tagPtr->overstrikeColor != NULL) || (tagPtr->underlineString != NULL) || (tagPtr->underlineColor != NULL) - || (tagPtr->lMarginColor != NULL)) { + || (tagPtr->lMarginColor != NULL) + || (tagPtr->rMarginColor != NULL)) { tagPtr->affectsDisplay = 1; } if (!newTag) { @@ -1050,6 +1053,7 @@ TkTextCreateTag( tagPtr->overstrikeColor = NULL; tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; + tagPtr->rMarginColor = NULL; tagPtr->selBorder = NULL; tagPtr->selBgStipple = None; tagPtr->selFgColor = NULL; -- cgit v0.12 From c841d963af542a097122211248620383ff6098c0 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:53:51 +0000 Subject: -rmargincolor tag configuration option: documentation --- doc/text.n | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/text.n b/doc/text.n index 1e6dbc2..84ad710 100644 --- a/doc/text.n +++ b/doc/text.n @@ -533,6 +533,14 @@ option is only used when wrapping is enabled. If a text line wraps, the right margin for each line on the display is determined by the first non-elided character of that display line. .TP +\fB\-rmargincolor \fIcolor\fR +. +\fIColor\fR specifies the background color to use in regions that do not +contain characters because they are indented by \fB\-rmargin1\fR. It may +have any of the forms accepted by \fBTk_GetColor\fR.If \fIcolor\fR has not +been specified, or if it is specified as an empty string, then the color +specified by the \fB-background\fR widget option is used. +.TP \fB\-selectbackground \fIcolor\fR \fIColor\fR specifies the background color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If -- cgit v0.12 From 6acf033f061f09ca43c0203318847b950110eb87 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 10 Feb 2016 22:54:09 +0000 Subject: -rmargincolor tag configuration option: tests --- tests/textTag.test | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/tests/textTag.test b/tests/textTag.test index 9e0cf38..f8d7033 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -251,45 +251,56 @@ test textTag-1.25 {configuration options} -constraints { .t tag configure x -rmargin [lindex [.t tag configure x -rmargin] 3] } -returnCodes error -result {bad screen distance "bad"} test textTag-1.25a {tag configuration options} -body { + .t tag configure x -rmargincolor darkblue + .t tag cget x -rmargincolor +} -cleanup { + .t tag configure x -rmargincolor [lindex [.t tag configure x -rmargincolor] 3] +} -result {darkblue} +test textTag-1.25b {configuration options} -body { + .t tag configure x -rmargincolor non-existent +} -cleanup { + .t tag configure x -rmargincolor [lindex [.t tag configure x -rmargincolor] 3] +} -returnCodes error -result {unknown color name "non-existent"} +test textTag-1.25c {tag configuration options} -body { .t tag configure x -selectbackground #012345 .t tag cget x -selectbackground } -cleanup { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -result {#012345} -test textTag-1.25b {configuration options} -body { +test textTag-1.25d {configuration options} -body { .t tag configure x -selectbackground non-existent } -cleanup { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -returnCodes error -result {unknown color name "non-existent"} -test textTag-1.25c {tag configuration options} -body { +test textTag-1.25e {tag configuration options} -body { .t tag configure x -selectbgstipple gray50 .t tag cget x -selectbgstipple } -cleanup { .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] } -result {gray50} -test textTag-1.25d {configuration options} -body { +test textTag-1.25f {configuration options} -body { .t tag configure x -selectbgstipple badStipple } -cleanup { .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] } -returnCodes error -result {bitmap "badStipple" not defined} -test textTag-1.25e {tag configuration options} -body { +test textTag-1.25g {tag configuration options} -body { .t tag configure x -selectfgstipple gray50 .t tag cget x -selectfgstipple } -cleanup { .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] } -result {gray50} -test textTag-1.25f {configuration options} -body { +test textTag-1.25h {configuration options} -body { .t tag configure x -selectfgstipple badStipple } -cleanup { .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] } -returnCodes error -result {bitmap "badStipple" not defined} -test textTag-1.25g {tag configuration options} -body { +test textTag-1.25i {tag configuration options} -body { .t tag configure x -selectforeground #012345 .t tag cget x -selectforeground } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] } -result {#012345} -test textTag-1.25h {configuration options} -body { +test textTag-1.25j {configuration options} -body { .t tag configure x -selectforeground non-existent } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] @@ -719,12 +730,16 @@ test textTag-5.12 {TkTextTagCmd - "configure" option} -constraints { test textTag-5.13 {TkTextTagCmd - "configure" option} -body { .t tag delete x .t tag configure x -lmargin1 2 -lmargin2 4 -rmargin 5 \ - -lmargincolor darkblue + -lmargincolor darkblue -rmargincolor lightgreen list [.t tag configure x -lmargin1] [.t tag configure x -lmargin2] \ - [.t tag configure x -rmargin] [.t tag configure x -lmargincolor] + [.t tag configure x -rmargin] [.t tag configure x -lmargincolor] \ + [.t tag configure x -rmargincolor] } -cleanup { .t tag delete x -} -result {{-lmargin1 {} {} {} 2} {-lmargin2 {} {} {} 4} {-rmargin {} {} {} 5} {-lmargincolor {} {} {} darkblue}} +} -result [list {-lmargin1 {} {} {} 2} {-lmargin2 {} {} {} 4} \ + {-rmargin {} {} {} 5} \ + {-lmargincolor {} {} {} darkblue} {-rmargincolor {} {} {} lightgreen} \ + ] test textTag-5.14 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 } -body { @@ -755,6 +770,12 @@ test textTag-5.16 {TkTextTagCmd - "configure" option} -constraints { } -cleanup { .t tag delete x } -returnCodes error -result {bad screen distance "140.1.1"} +test textTag-5.16a {TkTextTagCmd - "configure" option} -body { + .t tag delete x + .t tag configure x -rmargincolor rainbow +} -cleanup { + .t tag delete x +} -returnCodes error -result {unknown color name "rainbow"} .t tag delete x test textTag-5.17 {TkTextTagCmd - "configure" option} -constraints { haveCourier12 -- cgit v0.12 From 0fe18b82571d24300bc235e6c37013742ee3b778 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Feb 2016 10:41:03 +0000 Subject: Fixed typo in comment (introduced by error in [6a21622c7e]) --- generic/tkText.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkText.h b/generic/tkText.h index 8fab200..f37e01a 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -407,7 +407,7 @@ typedef struct TkTextTag { * non-NULL. */ XColor *underlineColor; /* Color for the underline. NULL means same * color as foreground. */ - TkWrapMode wrapMode; /* How to hsandle wrap-around for this tag. + TkWrapMode wrapMode; /* How to handle wrap-around for this tag. * Must be TEXT_WRAPMODE_CHAR, * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or * TEXT_WRAPMODE_NULL to use wrapmode for -- cgit v0.12 From 4dd26486a8997a2706c8c9369c4a17706c33e114 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 11 Feb 2016 13:09:34 +0000 Subject: Fix crash in TkFinalize() if Tk_Init() is never called. Suggested by Brian Griffin. --- generic/tkEvent.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generic/tkEvent.c b/generic/tkEvent.c index bcc6d98..95aeda1 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -2039,6 +2039,12 @@ TkFinalize( { ExitHandler *exitPtr; +#if defined(_WIN32) && !defined(STATIC_BUILD) + if (!tclStubsPtr) { + return; + } +#endif + Tcl_DeleteExitHandler(TkFinalize, NULL); Tcl_MutexLock(&exitMutex); -- cgit v0.12 From 03e15875540e77c1ee40fbeb63955bb50eade596 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 11 Feb 2016 13:11:28 +0000 Subject: (cherry-pick): Fix crash in TkFinalize() if Tk_Init() is never called. Suggested by Brian Griffin. --- generic/tkEvent.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 03e7283..747555e 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -2047,6 +2047,12 @@ TkFinalize( { ExitHandler *exitPtr; +#if defined(_WIN32) && !defined(STATIC_BUILD) + if (!tclStubsPtr) { + return; + } +#endif + Tcl_DeleteExitHandler(TkFinalize, NULL); Tcl_MutexLock(&exitMutex); -- cgit v0.12 From 2d1dee7c0fdf51a57ac71ed493aa92e278a7720e Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Feb 2016 13:17:51 +0000 Subject: -lmargincolor tag configuration option: implementation slightly optimized since Tk_Fill3DRectangle is robust with respect to negative widths --- generic/tkTextDisp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c0dc017..f871fc1 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -2479,10 +2479,9 @@ DisplayDLine( * Second, draw the background color of the left and right margins. */ if (dlPtr->lMarginColor != NULL) { - int x = dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset; - Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->lMarginColor, 0, y, - (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset, + dlPtr->height, 0, TK_RELIEF_FLAT); } if (dlPtr->rMarginColor != NULL) { Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->rMarginColor, -- cgit v0.12 From 2c864a03e860d3d1b46385e52f6fb648b9f7edb2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Feb 2016 13:58:42 +0000 Subject: Repair visual test for bevels, inadvertently broken in [6a93101279] --- tests/bevel.tcl | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/bevel.tcl b/tests/bevel.tcl index 531def0..4af60f3 100644 --- a/tests/bevel.tcl +++ b/tests/bevel.tcl @@ -147,14 +147,12 @@ set ind [.t.t index end] xxxx} {} SSSSS sol100 {xxxx x} {} SSSSSSSSSSSSSSSSSS sol100 {x xxx} {} SSSSSSSSS sol100 xxxx {} -} .t.t insert end "\n\nA thinner border is continuous" .t.t insert end { xxxx} {} SSSSS sol12 {xxxx x} {} SSSSSSSSSSSSSSSSSS sol12 {x xxx} {} SSSSSSSSS sol12 xxxx {} -} .t.t tag add big $ind end -- cgit v0.12 From c62581912456c387fe35dfbb2a72dfca95dab139 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Feb 2016 13:59:46 +0000 Subject: Repair visual test for bevels, inadvertently broken in [9046f1cb83] (cherrypicked [7ac2438944]) --- tests/bevel.tcl | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/bevel.tcl b/tests/bevel.tcl index 531def0..4af60f3 100644 --- a/tests/bevel.tcl +++ b/tests/bevel.tcl @@ -147,14 +147,12 @@ set ind [.t.t index end] xxxx} {} SSSSS sol100 {xxxx x} {} SSSSSSSSSSSSSSSSSS sol100 {x xxx} {} SSSSSSSSS sol100 xxxx {} -} .t.t insert end "\n\nA thinner border is continuous" .t.t insert end { xxxx} {} SSSSS sol12 {xxxx x} {} SSSSSSSSSSSSSSSSSS sol12 {x xxx} {} SSSSSSSSS sol12 xxxx {} -} .t.t tag add big $ind end -- cgit v0.12 From 365dd709b8625b7b08f347f0c0122612c454b618 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Feb 2016 20:06:29 +0000 Subject: Fixed error in comment --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 7969091..1eea37d 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -1640,7 +1640,7 @@ LayoutDLine( * Make one more pass over the line to recompute various things like its * height, length, and total number of bytes. Also modify the x-locations * of chunks to reflect justification. If we're not wrapping, I'm not sure - * what is the best way to handle left and center justification: should + * what is the best way to handle right and center justification: should * the total length, for purposes of justification, be (a) the window * width, (b) the length of the longest line in the window, or (c) the * length of the longest line in the text? (c) isn't available, (b) seems -- cgit v0.12 From b41c4d29075b0456ea437df35adc6cd251aa892b Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Feb 2016 20:11:59 +0000 Subject: Fixed error in comment (cherrypicked [a3d4e5de17] --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 68c09fc..1f39112 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -1638,7 +1638,7 @@ LayoutDLine( * Make one more pass over the line to recompute various things like its * height, length, and total number of bytes. Also modify the x-locations * of chunks to reflect justification. If we're not wrapping, I'm not sure - * what is the best way to handle left and center justification: should + * what is the best way to handle right and center justification: should * the total length, for purposes of justification, be (a) the window * width, (b) the length of the longest line in the window, or (c) the * length of the longest line in the text? (c) isn't available, (b) seems -- cgit v0.12 From 2944e4c7eb5d6ddae6aaf1eac0262f396d2a4a95 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 19 Feb 2016 17:39:34 +0000 Subject: update changes --- changes | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/changes b/changes index 81be9f1..bf3e62e 100644 --- a/changes +++ b/changes @@ -7167,3 +7167,102 @@ Tk Cocoa 2.0: App Store enabled (walzer,culler,desmera,owen,nyberg,reincke) *** POTENTIAL INCOMPATIBILITY *** --- Released 8.6.4, March 12, 2015 --- http://core.tcl.tk/tk/ for details + +2015-03-10 (bug) Cocoa: premature image free crash (walzer) + +2015-03-15 (bug) Cocoa: wish launches in front. [focus -force] works (culler) + +2015-04-09 (bug)[e4ed00] [$text index "1.0 display wordstart"] crash (vogel) + +2015-04-09 (bug)[562118] Unicode support of "wordstart" modifier (vogel) + +2015-05-05 (bug)[06c3fc] PNG alpha error corrupted output file (gauthier,porter) + +2015-05-20 (bug)[dece63] various mem corruptions in images (mic42,porter) + +2015-05-24 (bug)[53f8fc] panedwindow geometry management (vogel) + +2015-05-26 (bug)[1641721] tk_getOpenFile symlink display doubled (nijtmans) + +2015-06-01 (bug)[d7bad5][2368195][3592454][1714535][1292219][3592454] + panedwindow fixes (vogel) + +2015-06-25 (bug)[805cff] Tk_ConfigureWidget() segfault (aspect,nijtmans) + +2015-07-13 (bug)[3f179a] Text widget crash with elided text (vogel) + +2015-07-16 (bug)[2886436] Stop [$text delete] acting before start index (vogel) + +2015-07-28 (bug)[1236306] TraverseToMenu error bound to toplevel destroy (vogel) + +2015-08-20 (bug)[00189c] MSVC 14: semi-static UCRT support (dower,nijtmans) + +2015-09-13 (bug)[cc0ba3] PNG read buffer overflow (maxjarek,porter) + +2015-09-29 (bug)[1501749] Crash embedded window delete bound to (vogel) + +2015-10-04 (license) Replace icons that lacked clear free license (cowals) + +2015-10-06 (bug)[46c83f] Win: tk_getOpenFile -initialdir (koend,nadkarni) + +2015-10-08 (new feature)[TIP 437] New panedwindow options (vogel) + +2015-10-09 (bug)[1669632] [text] autoseparator placement (nash,vogel) + +2015-10-09 (bug)[2262711] [text] RE search Unicode+elided (kaitzschu,vogel) + +2015-10-09 (bug)[1815161] [$text count -ypixels] needs management (vogel) + +2015-10-22 (bug)[1520118] Document spinbox validate expectations (vogel) + +2015-10-22 (bug)[1414025] $entry insertion cursor visibility (vogel) + +2015-10-26 (bug) PNG rendering on El Capitan (meier,walzer) + +2015-11-08 (bug)[2160206] menubutton panic (vogel) + +2015-11-08 (bug)[220854] Display trailing TAB in entry (vogel) + +2015-11-08 (bug)[542199] double click on lone char in entry (vogel) + +2015-11-08 (bug)[297442d] strict motif binding on (vogel) + +2015-11-08 (bug)[3601604] $listbox -takefocus (vogel) + +2015-11-09 (bug)[5ee8af] X, Win: 64-bit enable embedded windows (vogel) + +2015-11-29 (bug)[1997299] [text] tag borderwidth leak (vogel) + +2015-12-12 (bug)[1739605] [text see] misbehavior (danckaert) + +2015-12-13 (bug)[ff8a1e] Never-mapped [text] performance (danckaert) + +2015-12-19 (bug)[1700065] Report errors from -textvariable write trace (vogel) + +2015-12-19 (bug)[793909] -textvariable handle undefined namespace (vogel) + +2015-12-26 (bug)[2f78c7] crash with [text] and [tablelist] (vogel) + +2016-01-06 (bug)[1288433,3102228] <> misfires (vogel) + +2016-01-08 (bug)[1510538] initial scrollbar width (vogel,nijtmans) + +2016-01-08 (bug)[1305128] event not received by scrollbar (vogel,nijtmans) + +2016-01-09 (bug)[1927212] Mousewheel/scrollbar bindings (vogel) + +2016-01-11 (bug)[63c354] Cocoa message boxes (culler) + +2016-01-12 (bug)[2049429] get more $text options from database (vogel) + +2016-01-22 (TIP 441) New option [listbox ... -justify] (vogel) + +2016-01-25 (bug) OBOE in ttk::notebook options parsing (bromley,english) + +2016-02-08 (enhance) [option readile] expects utf-8 file (oehlmann,nijtmans) + +2016-02-08 (bug) crash in [$text delete] (griffin,vogel) + +Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) + +--- Released 8.6.5, February 29, 2016 --- http://core.tcl.tk/tk/ for details -- cgit v0.12 From 4e1b2a38af5d33026af79d7bcb6320680bab198b Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 21 Feb 2016 20:53:44 +0000 Subject: Fixed typo in canvas man page --- doc/canvas.n | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/canvas.n b/doc/canvas.n index bc29cc3..38697cd 100644 --- a/doc/canvas.n +++ b/doc/canvas.n @@ -263,7 +263,7 @@ automatically decremented by one. A number less than 0 is treated as if it were zero, and a number greater than the length of the text item is treated as if it were equal to the length of the text item. For -polygons, numbers less than 0 or greater then the length +polygons, numbers less than 0 or greater than the length of the coordinate list will be adjusted by adding or subtracting the length until the result is between zero and the length, inclusive. @@ -405,7 +405,7 @@ behaves as if the \fIstart\fR argument had not been specified. . Selects all the items completely enclosed within the rectangular region given by \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR. -\fIX1\fR must be no greater then \fIx2\fR and \fIy1\fR must be +\fIX1\fR must be no greater than \fIx2\fR and \fIy1\fR must be no greater than \fIy2\fR. .TP \fBoverlapping\fR \fIx1\fR \fIy1\fR \fIx2\fR \fIy2\fR @@ -413,7 +413,7 @@ no greater than \fIy2\fR. Selects all the items that overlap or are enclosed within the rectangular region given by \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR. -\fIX1\fR must be no greater then \fIx2\fR and \fIy1\fR must be +\fIX1\fR must be no greater than \fIx2\fR and \fIy1\fR must be no greater than \fIy2\fR. .TP \fBwithtag \fItagOrId\fR -- cgit v0.12 From 3dfd0dd611bcd8d85edae8c326be10eb2ee5518a Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 22 Feb 2016 17:45:21 +0000 Subject: Added missing comments describing input parameters of some procs --- library/spinbox.tcl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/spinbox.tcl b/library/spinbox.tcl index 6a5f829..02584f4 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -336,6 +336,7 @@ proc ::tk::spinbox::ClosestGap {w x} { # Arguments: # w - The spinbox window in which the button was pressed. # x - The x-coordinate of the button press. +# y - The y-coordinate of the button press. proc ::tk::spinbox::ButtonDown {w x y} { variable ::tk::Priv @@ -388,6 +389,7 @@ proc ::tk::spinbox::ButtonDown {w x y} { # Arguments: # w - The spinbox window in which the button was pressed. # x - The x-coordinate of the button press. +# y - The y-coordinate of the button press. proc ::tk::spinbox::ButtonUp {w x y} { variable ::tk::Priv @@ -491,6 +493,8 @@ proc ::tk::spinbox::Paste {w x} { # # Arguments: # w - The spinbox window. +# x - The x-coordinate of the mouse. +# y - The y-coordinate of the mouse. proc ::tk::spinbox::Motion {w x y} { variable ::tk::Priv -- cgit v0.12 From a3ee774779349213a90779a5b69d5ac5d8357099 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 24 Feb 2016 20:10:25 +0000 Subject: Fixed bug [e9112ef96e] - [wm forget] doesn't completely --- macosx/tkMacOSXWm.c | 5 +++++ unix/tkUnixWm.c | 5 +++++ win/tkWinWm.c | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 3ea2f51..39990e6 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1788,6 +1788,11 @@ WmForgetCmd( TkWmDeadWindow(winPtr); RemapWindows(winPtr, (MacDrawable *) winPtr->parentPtr->window); + /* + * Make sure wm no longer manages this window + */ + Tk_ManageGeometry(frameWin, NULL, NULL); + winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); /* diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 612270c..19ac86c 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -1826,6 +1826,11 @@ WmForgetCmd( ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); RemapWindows(winPtr, winPtr->parentPtr); + /* + * Make sure wm no longer manages this window + */ + Tk_ManageGeometry(frameWin, NULL, NULL); + /* * Flags (above) must be cleared before calling TkMapTopFrame (below). */ diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 768ee69..4e7618d 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -3673,6 +3673,12 @@ WmForgetCmd( winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); Tk_MakeWindowExist((Tk_Window)winPtr->parentPtr); RemapWindows(winPtr, Tk_GetHWND(winPtr->parentPtr->window)); + + /* + * Make sure wm no longer manages this window + */ + Tk_ManageGeometry(frameWin, NULL, NULL); + TkWmDeadWindow(winPtr); /* flags (above) must be cleared before calling */ /* TkMapTopFrame (below) */ -- cgit v0.12 From 612675a4f57c40b222eccf363977705fbdd848aa Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 25 Feb 2016 08:09:32 +0000 Subject: Fixed typo in spinbox documentation page --- doc/spinbox.n | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/spinbox.n b/doc/spinbox.n index 7227cf1..330bb17 100644 --- a/doc/spinbox.n +++ b/doc/spinbox.n @@ -55,7 +55,7 @@ A floating-point value corresponding to the lowest value for a spinbox, to be used in conjunction with \fB\-to\fR and \fB\-increment\fR. When all are specified correctly, the spinbox will use these values to control its contents. This value must be less than the \fB\-to\fR option. -If \fB\-values\fR is specified, it supercedes this option. +If \fB\-values\fR is specified, it supersedes this option. .OP "\-invalidcommand or \-invcmd" invalidCommand InvalidCommand Specifies a script to eval when \fB\-validatecommand\fR returns 0. Setting it to an empty string disables this feature (the default). The best use of @@ -84,7 +84,7 @@ A floating-point value corresponding to the highest value for the spinbox, to be used in conjunction with \fB\-from\fR and \fB\-increment\fR. When all are specified correctly, the spinbox will use these values to control its contents. This value must be greater than the \fB\-from\fR option. -If \fB\-values\fR is specified, it supercedes this option. +If \fB\-values\fR is specified, it supersedes this option. .OP \-validate validate Validate Specifies the mode in which validation should operate: \fBnone\fR, \fBfocus\fR, \fBfocusin\fR, \fBfocusout\fR, \fBkey\fR, or \fBall\fR. -- cgit v0.12 From da0931455c52ed9f10b7fe25ab15ab0f4f08ca64 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 2 Mar 2016 14:22:21 +0000 Subject: Eliminate exess spacings in many doc pages --- doc/ConfigWidg.3 | 4 ++-- doc/CrtSelHdlr.3 | 4 ++-- doc/CrtWindow.3 | 4 ++-- doc/FontId.3 | 12 +++++----- doc/GetColor.3 | 4 ++-- doc/GetCursor.3 | 4 ++-- doc/GetFont.3 | 14 +++++------ doc/MapWindow.3 | 8 +++---- doc/MeasureChar.3 | 18 +++++++------- doc/TextLayout.3 | 24 +++++++++---------- doc/Tk_Main.3 | 4 ++-- doc/WindowId.3 | 4 ++-- doc/button.n | 6 ++--- doc/checkbutton.n | 4 ++-- doc/chooseDirectory.n | 4 ++-- doc/clipboard.n | 6 ++--- doc/event.n | 16 ++++++------- doc/font.n | 6 ++--- doc/getOpenFile.n | 8 +++---- doc/listbox.n | 6 ++--- doc/loadTk.n | 4 ++-- doc/menu.n | 8 +++---- doc/options.n | 6 ++--- doc/panedwindow.n | 8 +++---- doc/radiobutton.n | 6 ++--- doc/scale.n | 4 ++-- doc/selection.n | 6 ++--- doc/tkerror.n | 8 +++---- doc/ttk_Geometry.3 | 30 +++++++++++------------ doc/ttk_button.n | 12 +++++----- doc/ttk_checkbutton.n | 20 ++++++++-------- doc/ttk_combobox.n | 12 +++++----- doc/ttk_entry.n | 46 +++++++++++++++++------------------ doc/ttk_frame.n | 6 ++--- doc/ttk_image.n | 10 ++++---- doc/ttk_intro.n | 22 ++++++++--------- doc/ttk_label.n | 14 +++++------ doc/ttk_labelframe.n | 12 +++++----- doc/ttk_menubutton.n | 12 +++++----- doc/ttk_notebook.n | 30 +++++++++++------------ doc/ttk_progressbar.n | 14 +++++------ doc/ttk_radiobutton.n | 18 +++++++------- doc/ttk_scrollbar.n | 10 ++++---- doc/ttk_separator.n | 6 ++--- doc/ttk_spinbox.n | 6 ++--- doc/ttk_style.n | 28 +++++++++++----------- doc/ttk_treeview.n | 66 +++++++++++++++++++++++++-------------------------- doc/ttk_vsapi.n | 4 ++-- doc/wm.n | 4 ++-- 49 files changed, 296 insertions(+), 296 deletions(-) diff --git a/doc/ConfigWidg.3 b/doc/ConfigWidg.3 index ddc1030..92be073 100644 --- a/doc/ConfigWidg.3 +++ b/doc/ConfigWidg.3 @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_ConfigureWidget 3 4.1 Tk "Tk Library Procedures" .so man.macros .BS @@ -174,7 +174,7 @@ legal values for \fItype\fR, and the corresponding actions, are: \fBTK_CONFIG_ACTIVE_CURSOR\fR The value must be an ASCII string identifying a cursor in a form -suitable for passing to \fBTk_GetCursor\fR. +suitable for passing to \fBTk_GetCursor\fR. The value is converted to a \fBTk_Cursor\fR by calling \fBTk_GetCursor\fR and the result is stored in the target. In addition, the resulting cursor is made the active cursor diff --git a/doc/CrtSelHdlr.3 b/doc/CrtSelHdlr.3 index 2aeffa9..2292ccc 100644 --- a/doc/CrtSelHdlr.3 +++ b/doc/CrtSelHdlr.3 @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_CreateSelHandler 3 4.0 Tk "Tk Library Procedures" .so man.macros .BS @@ -44,7 +44,7 @@ requestor. \fBTk_CreateSelHandler\fR arranges for a particular procedure (\fIproc\fR) to be called whenever \fIselection\fR is owned by \fItkwin\fR and the selection contents are requested in the -form given by \fItarget\fR. +form given by \fItarget\fR. \fITarget\fR should be one of the entries defined in the left column of Table 2 of the X Inter-Client Communication Conventions Manual (ICCCM) or diff --git a/doc/CrtWindow.3 b/doc/CrtWindow.3 index 8f44545..b254460 100644 --- a/doc/CrtWindow.3 +++ b/doc/CrtWindow.3 @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_CreateWindow 3 4.2 Tk "Tk Library Procedures" .so man.macros .BS @@ -52,7 +52,7 @@ Name of new window, specified as path name within application .BE .SH DESCRIPTION .PP -The procedures \fBTk_CreateWindow\fR, +The procedures \fBTk_CreateWindow\fR, \fBTk_CreateAnonymousWindow\fR, and \fBTk_CreateWindowFromPath\fR are used to create new windows for use in Tk-based applications. Each of the procedures returns a token diff --git a/doc/FontId.3 b/doc/FontId.3 index c79b89f..9d35ae6 100644 --- a/doc/FontId.3 +++ b/doc/FontId.3 @@ -3,12 +3,12 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_FontId 3 8.0 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME -Tk_FontId, Tk_GetFontMetrics, Tk_PostscriptFontName \- accessor functions for +Tk_FontId, Tk_GetFontMetrics, Tk_PostscriptFontName \- accessor functions for fonts .SH SYNOPSIS .nf @@ -37,7 +37,7 @@ Postscript font that corresponds to \fItkfont\fR will be appended. .PP Given a \fItkfont\fR, \fBTk_FontId\fR returns the token that should be selected into an XGCValues structure in order to construct a graphics -context that can be used to draw text in the specified font. +context that can be used to draw text in the specified font. .PP \fBTk_GetFontMetrics\fR computes the ascent, descent, and linespace of the \fItkfont\fR in pixels and stores those values in the structure pointer to by @@ -45,7 +45,7 @@ context that can be used to draw text in the specified font. multiple lines of text, to align the baselines of text in different fonts, and to vertically align text in a given region. See the documentation for the \fBfont\fR command for definitions of the terms -ascent, descent, and linespace, used in font metrics. +ascent, descent, and linespace, used in font metrics. .PP \fBTk_PostscriptFontName\fR maps a \fItkfont\fR to the corresponding Postscript font name that should be used when printing. The return value @@ -56,10 +56,10 @@ appended to \fIdsPtr\fR. \fIDsPtr\fR must refer to an initialized Postscript printer, the following screen font families should print correctly: .IP -\fBAvant Garde\fR, \fBArial\fR, \fBBookman\fR, \fBCourier\fR, +\fBAvant Garde\fR, \fBArial\fR, \fBBookman\fR, \fBCourier\fR, \fBCourier New\fR, \fBGeneva\fR, \fBHelvetica\fR, \fBMonaco\fR, \fBNew Century Schoolbook\fR, \fBNew York\fR, \fBPalatino\fR, \fBSymbol\fR, -\fBTimes\fR, \fBTimes New Roman\fR, \fBZapf Chancery\fR, and +\fBTimes\fR, \fBTimes New Roman\fR, \fBZapf Chancery\fR, and \fBZapf Dingbats\fR. .PP Any other font families may not print correctly because the computed diff --git a/doc/GetColor.3 b/doc/GetColor.3 index 9d07d95..15254aa 100644 --- a/doc/GetColor.3 +++ b/doc/GetColor.3 @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_AllocColorFromObj 3 8.1 Tk "Tk Library Procedures" .so man.macros .BS @@ -127,7 +127,7 @@ This package maintains a database of all the colors currently in use. If the same color is requested multiple times from \fBTk_GetColor\fR or \fBTk_AllocColorFromObj\fR (e.g. by different -windows), or if the +windows), or if the same intensities are requested multiple times from \fBTk_GetColorByValue\fR, then existing pixel values will be re-used. Re-using an existing pixel avoids any interaction diff --git a/doc/GetCursor.3 b/doc/GetCursor.3 index 8526a47..403c05e 100644 --- a/doc/GetCursor.3 +++ b/doc/GetCursor.3 @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_AllocCursorFromObj 3 8.1 Tk "Tk Library Procedures" .so man.macros .BS @@ -118,7 +118,7 @@ in preference to black and white cursors. In this form, \fIsourceName\fR and \fImaskName\fR are the names of files describing cursors for the cursor's source bits and mask. Each file must be in standard X11 cursor format. -\fIFgColor\fR and \fIbgColor\fR +\fIFgColor\fR and \fIbgColor\fR indicate the colors to use for the cursor, in any of the forms acceptable to \fBTk_GetColor\fR. This form of the command will not work on Macintosh or Windows computers. diff --git a/doc/GetFont.3 b/doc/GetFont.3 index cf02f00..0504916 100644 --- a/doc/GetFont.3 +++ b/doc/GetFont.3 @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_AllocFontFromObj 3 8.1 Tk "Tk Library Procedures" .so man.macros .BS @@ -14,19 +14,19 @@ Tk_AllocFontFromObj, Tk_GetFont, Tk_GetFontFromObj, Tk_NameOfFont, Tk_FreeFontFr .nf \fB#include \fR .sp -Tk_Font +Tk_Font \fBTk_AllocFontFromObj(\fIinterp, tkwin, objPtr\fB)\fR .sp -Tk_Font -\fBTk_GetFont(\fIinterp, tkwin, string\fB)\fR +Tk_Font +\fBTk_GetFont(\fIinterp, tkwin, string\fB)\fR .sp -Tk_Font +Tk_Font \fBTk_GetFontFromObj(\fItkwin, objPtr\fB)\fR .sp const char * \fBTk_NameOfFont(\fItkfont\fB)\fR .sp -Tk_Font +Tk_Font \fBTk_FreeFontFromObj(\fItkwin, objPtr\fB)\fR .sp void @@ -55,7 +55,7 @@ returns a token that represents the font. The return value can be used in subsequent calls to procedures such as \fBTk_GetFontMetrics\fR, \fBTk_MeasureChars\fR, and \fBTk_FreeFont\fR. The Tk_Font token will remain valid until -\fBTk_FreeFontFromObj\fR or \fBTk_FreeFont\fR is called to release it. +\fBTk_FreeFontFromObj\fR or \fBTk_FreeFont\fR is called to release it. \fIObjPtr\fR can contain either a symbolic name or a font description; see the documentation for the \fBfont\fR command for a description of the valid formats. If \fBTk_AllocFontFromObj\fR is unsuccessful (because, diff --git a/doc/MapWindow.3 b/doc/MapWindow.3 index 8abce64..a3c6296 100644 --- a/doc/MapWindow.3 +++ b/doc/MapWindow.3 @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_MapWindow 3 "" Tk "Tk Library Procedures" .so man.macros .BS @@ -35,9 +35,9 @@ deferred window creation. from the screen. .PP If \fItkwin\fR is a child window (i.e. \fBTk_CreateWindow\fR was -used to create a child window), then event handlers interested in map -and unmap events are invoked immediately. If \fItkwin\fR is not an -internal window, then the event handlers will be invoked later, after +used to create a child window), then event handlers interested in map +and unmap events are invoked immediately. If \fItkwin\fR is not an +internal window, then the event handlers will be invoked later, after X has seen the request and returned an event for it. .PP These procedures should be used in place of the X procedures diff --git a/doc/MeasureChar.3 b/doc/MeasureChar.3 index 7433451..3959978 100644 --- a/doc/MeasureChar.3 +++ b/doc/MeasureChar.3 @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_MeasureChars 3 8.1 Tk "Tk Library Procedures" .so man.macros .BS @@ -32,7 +32,7 @@ returned by a previous call to \fBTk_GetFont\fR. Text to be measured or displayed. Need not be null terminated. Any non-printing meta-characters in the string (such as tabs, newlines, and other control characters) will be measured or displayed in a -platform-dependent manner. +platform-dependent manner. .AP int numBytes in The maximum number of bytes to consider when measuring or drawing \fIstring\fR. Must be greater than or equal to 0. @@ -60,11 +60,11 @@ Display on which to draw. .AP Drawable drawable in Window or pixmap in which to draw. .AP GC gc in -Graphics context for drawing characters. The font selected into this GC +Graphics context for drawing characters. The font selected into this GC must be the same as the \fItkfont\fR. .AP int "x, y" in Coordinates at which to place the left edge of the baseline when displaying -\fIstring\fR. +\fIstring\fR. .AP int firstByte in The index of the first byte of the first character to underline in the \fIstring\fR. Underlining begins at the left edge of this character. @@ -80,7 +80,7 @@ single-line strings. To measure and display single-font, multi-line, justified text, refer to the documentation for \fBTk_ComputeTextLayout\fR. There is no programming interface in the core of Tk that supports multi-font, multi-line text; support for that behavior must be built on -top of simpler layers. +top of simpler layers. Note that the interfaces described here are byte-oriented not character-oriented, so index values coming from Tcl scripts need to be converted to byte offsets using the @@ -95,7 +95,7 @@ escape sequences, while under Windows and Macintosh hollow or solid boxes may be substituted. Refer to the documentation for \fBTk_ComputeTextLayout\fR for a programming interface that supports the platform-independent expansion of tab characters into columns and -newlines/returns into multi-line text. +newlines/returns into multi-line text. .PP \fBTk_MeasureChars\fR is used both to compute the length of a given string and to compute how many characters from a string fit in a given @@ -106,12 +106,12 @@ value will be \fInumBytes\fR. \fI*lengthPtr\fR is filled with the computed width, in pixels, of the portion of the string that was measured. For example, if the return value is 5, then \fI*lengthPtr\fR is filled with the distance between the left edge of \fIstring\fR[0] and the right edge of -\fIstring\fR[4]. +\fIstring\fR[4]. .PP \fBTk_TextWidth\fR is a wrapper function that provides a simpler interface to the \fBTk_MeasureChars\fR function. The return value is how much space in pixels the given \fIstring\fR needs. -.PP +.PP \fBTk_DrawChars\fR draws the \fIstring\fR at the given location in the given \fIdrawable\fR. .PP @@ -120,7 +120,7 @@ given \fIstring\fR. It does not draw the characters (which are assumed to have been displayed previously by \fBTk_DrawChars\fR); it just draws the underline. This procedure is used to underline a few characters without having to construct an underlined font. To produce natively underlined -text, the appropriate underlined font should be constructed and used. +text, the appropriate underlined font should be constructed and used. .SH "SEE ALSO" font(n), FontId(3) .SH KEYWORDS diff --git a/doc/TextLayout.3 b/doc/TextLayout.3 index 3863ee7..5729a44 100644 --- a/doc/TextLayout.3 +++ b/doc/TextLayout.3 @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_ComputeTextLayout 3 8.1 Tk "Tk Library Procedures" .so man.macros .BS @@ -48,7 +48,7 @@ have been returned by a previous call to \fBTk_GetFont\fR. .AP "const char" *string in Potentially multi-line string whose dimensions are to be computed and stored in the text layout. The \fIstring\fR must remain valid for the -lifetime of the text layout. +lifetime of the text layout. .AP int numChars in The number of characters to consider from \fIstring\fR. If \fInumChars\fR is less than 0, then assumes \fIstring\fR is null @@ -77,7 +77,7 @@ measured and displayed in a platform-dependent manner as described in \fBTk_MeasureChars\fR, and will not have any special behaviors. .AP int *widthPtr out If non-NULL, filled with either the width, in pixels, of the widest -line in the text layout, or the width, in pixels, of the bounding box for the +line in the text layout, or the width, in pixels, of the bounding box for the character specified by \fIindex\fR. .AP int *heightPtr out If non-NULL, filled with either the total height, in pixels, of all @@ -101,7 +101,7 @@ text layout when it is being drawn, or the coordinates of a point (with respect to the upper-left hand corner of the text layout) to check against the text layout. .AP int firstChar in -The index of the first character to draw from the given text layout. +The index of the first character to draw from the given text layout. The number 0 means to draw from the beginning. .AP int lastChar in The index of the last character up to which to draw. The character @@ -119,7 +119,7 @@ for the character specified by \fIindex\fR. Either or both \fIxPtr\fR and \fIyPtr\fR may be NULL, in which case the corresponding value is not calculated. .AP int "width, height" in -Specifies the width and height, in pixels, of the rectangular area to +Specifies the width and height, in pixels, of the rectangular area to compare for intersection against the text layout. .AP Tcl_Interp *interp out Postscript code that will print the text layout is appended to @@ -132,7 +132,7 @@ justified text. To measure and display simple single-font, single-line strings, refer to the documentation for \fBTk_MeasureChars\fR. There is no programming interface in the core of Tk that supports multi-font, multi-line text; support for that behavior must be built on top of -simpler layers. +simpler layers. Note that unlike the lower level text display routines, the functions described here all operate on character-oriented lengths and indices rather than byte-oriented values. See the description of @@ -150,11 +150,11 @@ returns a Tk_TextLayout token that holds this information. This token is used in subsequent calls to procedures such as \fBTk_DrawTextLayout\fR, \fBTk_DistanceToTextLayout\fR, and \fBTk_FreeTextLayout\fR. The \fIstring\fR and \fItkfont\fR used when computing the layout must remain -valid for the lifetime of this token. +valid for the lifetime of this token. .PP \fBTk_FreeTextLayout\fR is called to release the storage associated with \fIlayout\fR when it is no longer needed. A \fIlayout\fR should not be used -in any other text layout procedures once it has been released. +in any other text layout procedures once it has been released. .PP \fBTk_DrawTextLayout\fR uses the information in \fIlayout\fR to display a single-font, multi-line, justified string of text at the specified location. @@ -191,7 +191,7 @@ placeholder character. \fBTk_CharBbox\fR uses the information in \fIlayout\fR to return the bounding box for the character specified by \fIindex\fR. The width of the bounding box is the advance width of the character, and does not include any -left or right bearing. Any character that extends partially outside of +left or right bearing. Any character that extends partially outside of \fIlayout\fR is considered to be truncated at the edge. Any character that would be located completely outside of \fIlayout\fR is considered to be zero-width and pegged against the edge. The height of the bounding @@ -264,13 +264,13 @@ much as fits placed on the line and the rest on subsequent line(s). If \fIwrapLength\fR is so small that not even one character can fit on a given line, the \fIwrapLength\fR is ignored for that line and one character will be placed on the line anyhow. When wrapping is turned -off, only newline/return characters may cause a line break. +off, only newline/return characters may cause a line break. .PP When a text layout has been created using an underlined \fItkfont\fR, then any space characters that occur at the end of individual lines, -newlines/returns, and tabs will not be displayed underlined when +newlines/returns, and tabs will not be displayed underlined when \fBTk_DrawTextLayout\fR is called, because those characters are never actually drawn \- they are merely placeholders maintained in the -\fIlayout\fR. +\fIlayout\fR. .SH KEYWORDS font diff --git a/doc/Tk_Main.3 b/doc/Tk_Main.3 index a1bb149..ea5f771 100644 --- a/doc/Tk_Main.3 +++ b/doc/Tk_Main.3 @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_Main 3 4.0 Tk "Tk Library Procedures" .so man.macros .BS @@ -29,7 +29,7 @@ The value for this argument is usually \fBTcl_AppInit\fR. .SH DESCRIPTION .PP \fBTk_Main\fR acts as the main program for most Tk-based applications. -Starting with Tk 4.0 it is not called \fBmain\fR anymore because it +Starting with Tk 4.0 it is not called \fBmain\fR anymore because it is part of the Tk library and having a function \fBmain\fR in a library (particularly a shared library) causes problems on many systems. diff --git a/doc/WindowId.3 b/doc/WindowId.3 index 6d55dc0..f937963 100644 --- a/doc/WindowId.3 +++ b/doc/WindowId.3 @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH Tk_WindowId 3 "8.4" Tk "Tk Library Procedures" .so man.macros .BS @@ -168,7 +168,7 @@ the window's minimum requested size. These values correspond to the last call to \fBTk_SetMinimumRequestSize\fR for \fItkwin\fR. .PP \fBTk_InternalBorderLeft\fR, \fBTk_InternalBorderRight\fR, -\fBTk_InternalBorderTop\fR and \fBTk_InternalBorderBottom\fR +\fBTk_InternalBorderTop\fR and \fBTk_InternalBorderBottom\fR return the width of one side of the internal border that has been requested for \fItkwin\fR, or 0 if no internal border was requested. The return value is simply the last value passed to diff --git a/doc/button.n b/doc/button.n index e9a45a3..233feb6 100644 --- a/doc/button.n +++ b/doc/button.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH button n 4.4 Tk "Tk Built-In Commands" .so man.macros .BS @@ -69,7 +69,7 @@ In this state the \fB\-disabledforeground\fR and Specifies a desired width for the button. If an image or bitmap is being displayed in the button then the value is in screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR). -For a text button (no image or with \fB\-compound none\fR) then the width +For a text button (no image or with \fB\-compound none\fR) then the width specifies how much space in characters to allocate for the text label. If the width is negative then this specifies a minimum width. If this option is not specified, the button's desired width is computed @@ -96,7 +96,7 @@ one of the characters may optionally be underlined using the \fB\-underline\fR option. It can display itself in either of three different ways, according to -the \fB\-state\fR option; +the \fB\-state\fR option; it can be made to appear raised, sunken, or flat; and it can be made to flash. When a user invokes the button (by pressing mouse button 1 with the cursor over the diff --git a/doc/checkbutton.n b/doc/checkbutton.n index 2e6f840..bfefca4 100644 --- a/doc/checkbutton.n +++ b/doc/checkbutton.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH checkbutton n 4.4 Tk "Tk Built-In Commands" .so man.macros .BS @@ -52,7 +52,7 @@ and setting \fB\-indicatoron\fR to false and \fB\-overrelief\fR to the effect is achieved of having a flat button that raises on mouse-over and which is depressed when activated. This is the behavior typically exhibited by -the Bold, Italic, and Underline checkbuttons on the toolbar of a +the Bold, Italic, and Underline checkbuttons on the toolbar of a word-processor, for example. .OP \-offvalue offValue Value Specifies value to store in the button's associated variable whenever diff --git a/doc/chooseDirectory.n b/doc/chooseDirectory.n index 86c593d..8528ddb 100644 --- a/doc/chooseDirectory.n +++ b/doc/chooseDirectory.n @@ -1,7 +1,7 @@ '\" '\" Copyright (c) 1998-2000 by Scriptics Corporation. '\" All rights reserved. -'\" +'\" .TH tk_chooseDirectory n 8.3 Tk "Tk Built-In Commands" .so man.macros .BS @@ -20,7 +20,7 @@ possible as command line arguments: \fB\-initialdir\fR \fIdirname\fR Specifies that the directories in \fIdirectory\fR should be displayed when the dialog pops up. If this parameter is not specified, -the initial directory defaults to the current working directory +the initial directory defaults to the current working directory on non-Windows systems and on Windows systems prior to Vista. On Vista and later systems, the initial directory defaults to the last user-selected directory for the application. If the diff --git a/doc/clipboard.n b/doc/clipboard.n index 374cbd1..6f047dd 100644 --- a/doc/clipboard.n +++ b/doc/clipboard.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH clipboard n 8.4 Tk "Tk Built-In Commands" .so man.macros .BS @@ -17,7 +17,7 @@ clipboard \- Manipulate Tk clipboard .SH DESCRIPTION .PP This command provides a Tcl interface to the Tk clipboard, -which stores data for later retrieval using the selection mechanism +which stores data for later retrieval using the selection mechanism (via the \fB\-selection CLIPBOARD\fR option). In order to copy data into the clipboard, \fBclipboard clear\fR must be called, followed by a sequence of one or more calls to \fBclipboard @@ -52,7 +52,7 @@ Table 2 of the ICCCM), and defaults to \fBSTRING\fR. If \fIformat\fR is divided into fields separated by white space; each field is converted to its atom value, and the 32-bit atom value is transmitted instead of the atom name. For any other \fIformat\fR, \fIdata\fR is divided -into fields separated by white space and each +into fields separated by white space and each field is converted to a 32-bit integer; an array of integers is transmitted to the selection requester. Note that strings passed to \fBclipboard append\fR are concatenated before conversion, so the diff --git a/doc/event.n b/doc/event.n index 7a3cfca..12433cb 100644 --- a/doc/event.n +++ b/doc/event.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH event n 8.3 Tk "Tk Built-In Commands" .so man.macros .BS @@ -172,7 +172,7 @@ one of \fBNotifyNormal\fR, \fBNotifyGrab\fR, \fBNotifyUngrab\fR, or \fBNotifyWhileGrabbed\fR. Valid for \fBEnter\fR, \fBLeave\fR, \fBFocusIn\fR, and \fBFocusOut\fR events. -Corresponds to the \fB%m\fR substitution for binding scripts. +Corresponds to the \fB%m\fR substitution for binding scripts. .TP \fB\-override\fI boolean\fR \fIBoolean\fR must be a boolean value; it specifies the @@ -224,7 +224,7 @@ Corresponds to the \fB%#\fR substitution for binding scripts. For \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events it must be an integer value. -For \fBVisibility\fR events it must be one of \fBVisibilityUnobscured\fR, +For \fBVisibility\fR events it must be one of \fBVisibilityUnobscured\fR, \fBVisibilityPartiallyObscured\fR, or \fBVisibilityFullyObscured\fR. This option overrides any modifiers such as \fBMeta\fR or \fBControl\fR specified in the base \fIevent\fR. @@ -302,9 +302,9 @@ If \fIWindow\fR is empty the coordinate is relative to the screen, and this option corresponds to the \fB%Y\fR substitution for binding scripts. .PP -Any options that are not specified when generating an event are filled -with the value 0, except for \fIserial\fR, which is filled with the -next X event serial number. +Any options that are not specified when generating an event are filled +with the value 0, except for \fIserial\fR, which is filled with the +next X event serial number. .SH "PREDEFINED VIRTUAL EVENTS" .PP Tk defines the following virtual events for the purposes of @@ -540,7 +540,7 @@ will be invoked, because a physical event is considered more specific than a virtual event, all other things being equal. However, when the user types Meta-Control-y the \fB<>\fR binding will be invoked, because the -\fBMeta\fR modifier in the physical pattern associated with the +\fBMeta\fR modifier in the physical pattern associated with the virtual binding is more specific than the \fB sequence for the physical event. .PP @@ -560,7 +560,7 @@ bind Entry {} .PP the behavior will change such in two ways. First, the shadowed \fB<>\fR binding will emerge. -Typing Control-y will no longer invoke the \fB\fR binding, +Typing Control-y will no longer invoke the \fB\fR binding, but instead invoke the virtual event \fB<>\fR. Second, pressing the F6 key will now also invoke the \fB<>\fR binding. .SS "MOVING THE MOUSE POINTER" diff --git a/doc/font.n b/doc/font.n index 49d8aad..72f9270 100644 --- a/doc/font.n +++ b/doc/font.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH font n 8.0 Tk "Tk Built-In Commands" .so man.macros .BS @@ -38,7 +38,7 @@ that character, which will be different from the base font if the base font does not contain the given character. If \fIchar\fR may be a hyphen, it should be preceded by \fB\-\|\-\fR to distinguish it from a misspelled \fIoption\fR. -.TP +.TP \fBfont configure \fIfontname\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? . Query or modify the desired attributes for the named font called @@ -88,7 +88,7 @@ omitted, it defaults to the main window. Measures the amount of space the string \fItext\fR would use in the given \fIfont\fR when displayed in \fIwindow\fR. \fIfont\fR is a font description; see \fBFONT DESCRIPTIONS\fR below. If the \fIwindow\fR argument is -omitted, it +omitted, it defaults to the main window. The return value is the total width in pixels of \fItext\fR, not including the extra pixels used by highly exaggerated characters such as cursive diff --git a/doc/getOpenFile.n b/doc/getOpenFile.n index f5e92ff..39bce41 100644 --- a/doc/getOpenFile.n +++ b/doc/getOpenFile.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH tk_getOpenFile n 4.2 Tk "Tk Built-In Commands" .so man.macros .BS @@ -65,8 +65,8 @@ discussion on the contents of \fIfilePatternList\fR. \fB\-initialdir\fR \fIdirectory\fR . Specifies that the files in \fIdirectory\fR should be displayed -when the dialog pops up. If this parameter is not specified, -the initial directory defaults to the current working directory +when the dialog pops up. If this parameter is not specified, +the initial directory defaults to the current working directory on non-Windows systems and on Windows systems prior to Vista. On Vista and later systems, the initial directory defaults to the last user-selected directory for the application. If the @@ -95,7 +95,7 @@ turns the file dialog into a sheet attached to the parent window. \fB\-title\fR \fItitleString\fR . Specifies a string to display as the title of the dialog box. If this -option is not specified, then a default title is displayed. +option is not specified, then a default title is displayed. .TP \fB\-typevariable\fR \fIvariableName\fR . diff --git a/doc/listbox.n b/doc/listbox.n index 0f263b4..66b75b9 100644 --- a/doc/listbox.n +++ b/doc/listbox.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH listbox n 8.4 Tk "Tk Built-In Commands" .so man.macros .BS @@ -229,7 +229,7 @@ list. Returns an empty string. \fIpathName \fBitemcget \fIindex option\fR . Returns the current value of the item configuration option given -by \fIoption\fR. \fIOption\fR may have any of the values accepted +by \fIoption\fR. \fIOption\fR may have any of the values accepted by the \fBitemconfigure\fR command. .TP \fIpathName \fBitemconfigure \fIindex\fR ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption value ...\fR? @@ -249,7 +249,7 @@ are currently supported for items: .TP \fB\-background \fIcolor\fR . -\fIColor\fR specifies the background color to use when displaying the +\fIColor\fR specifies the background color to use when displaying the item. It may have any of the forms accepted by \fBTk_GetColor\fR. .TP \fB\-foreground \fIcolor\fR diff --git a/doc/loadTk.n b/doc/loadTk.n index d4ec51e..3673e98 100644 --- a/doc/loadTk.n +++ b/doc/loadTk.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH "Safe Tk" n 8.0 Tk "Tk Built-In Commands" .so man.macros .BS @@ -11,7 +11,7 @@ .SH NAME safe::loadTk \- Load Tk into a safe interpreter. .SH SYNOPSIS -\fBsafe::loadTk \fIslave\fR ?\fB\-use\fR \fIwindowId\fR? ?\fB\-display\fR \fIdisplayName\fR? +\fBsafe::loadTk \fIslave\fR ?\fB\-use\fR \fIwindowId\fR? ?\fB\-display\fR \fIdisplayName\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/menu.n b/doc/menu.n index 1067f38..ed1bb33 100644 --- a/doc/menu.n +++ b/doc/menu.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH menu n 4.1 Tk "Tk Built-In Commands" .so man.macros .BS @@ -269,8 +269,8 @@ are appended to the standard Help menu of the user's menubar whenever the window's menubar is in front. The first items in the menu are provided by Mac OS X. .PP -When Tk sees a System menu on Windows, its items are appended to the -system menu that the menubar is attached to. This menu is tied to the +When Tk sees a System menu on Windows, its items are appended to the +system menu that the menubar is attached to. This menu is tied to the application icon and can be invoked with the mouse or by typing Alt+Spacebar. Due to limitations in the Windows API, any font changes, colors, images, bitmaps, or tearoff images will not appear in the @@ -676,7 +676,7 @@ option for the menu along with the \fB\-activebackground\fR option from the entry. Disabled state means that the entry should be insensitive: the default bindings will refuse to activate or invoke the entry. -In this state the entry is displayed according to the +In this state the entry is displayed according to the \fB\-disabledforeground\fR option for the menu and the \fB\-background\fR option from the entry. This option is not available for separator entries. diff --git a/doc/options.n b/doc/options.n index 36937b1..738a1c6 100644 --- a/doc/options.n +++ b/doc/options.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH options n 4.4 Tk "Tk Built-In Commands" .so man.macros .BS @@ -268,7 +268,7 @@ traversal (e.g., Tab and Shift-Tab). Before setting the focus to a window, the traversal scripts consult the value of the \fB\-takefocus\fR option. A value of \fB0\fR means that the window should be skipped entirely -during keyboard traversal. +during keyboard traversal. \fB1\fR means that the window should receive the input focus as long as it is viewable (it and all of its ancestors are mapped). An empty value for the option means that the traversal scripts make @@ -278,7 +278,7 @@ disabled, if it has no key bindings, or if it is not viewable. If the value has any other form, then the traversal scripts take the value, append the name of the window to it (with a separator space), and evaluate the resulting string as a Tcl script. -The script must return \fB0\fR, \fB1\fR, or an empty string: a +The script must return \fB0\fR, \fB1\fR, or an empty string: a \fB0\fR or \fB1\fR value specifies whether the window will receive the input focus, and an empty string results in the default decision described above. diff --git a/doc/panedwindow.n b/doc/panedwindow.n index e2c954a..fcfebf4 100644 --- a/doc/panedwindow.n +++ b/doc/panedwindow.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH panedwindow n 8.4 Tk "Tk Built-In Commands" .so man.macros .BS @@ -151,7 +151,7 @@ Remove the proxy from the display. .TP \fIpathName \fBproxy place \fIx y\fR . -Place the proxy at the given \fIx\fR and \fIy\fR coordinates. +Place the proxy at the given \fIx\fR and \fIy\fR coordinates. .RE .TP \fIpathName \fBsash \fR?\fIargs\fR? @@ -239,13 +239,13 @@ dimension for vertical panedwindows. May be any value accepted by \fB\-padx \fIn\fR . Specifies a non-negative value indicating how much extra space to -leave on each side of the window in the X-direction. The value may +leave on each side of the window in the X-direction. The value may have any of the forms accepted by \fBTk_GetPixels\fR. .TP \fB\-pady \fIn\fR . Specifies a non-negative value indicating how much extra space to -leave on each side of the window in the Y-direction. The value may +leave on each side of the window in the Y-direction. The value may have any of the forms accepted by \fBTk_GetPixels\fR. .TP \fB\-sticky \fIstyle\fR diff --git a/doc/radiobutton.n b/doc/radiobutton.n index 557b42c..c79aa23 100644 --- a/doc/radiobutton.n +++ b/doc/radiobutton.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH radiobutton n 4.4 Tk "Tk Built-In Commands" .so man.macros .BS @@ -59,10 +59,10 @@ By setting this option to .QW flat and setting \fB\-indicatoron\fR to false and \fB\-overrelief\fR to .QW raised , -the effect is achieved +the effect is achieved of having a flat button that raises on mouse-over and which is depressed when activated. This is the behavior typically exhibited by -the Align-Left, Align-Right, and Center radiobuttons on the toolbar of a +the Align-Left, Align-Right, and Center radiobuttons on the toolbar of a word-processor, for example. .OP \-overrelief overRelief OverRelief Specifies an alternative relief for the radiobutton, to be used when the diff --git a/doc/scale.n b/doc/scale.n index 7bc5c59..0504b4b 100644 --- a/doc/scale.n +++ b/doc/scale.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH scale n 4.1 Tk "Tk Built-In Commands" .so man.macros .BS @@ -209,7 +209,7 @@ the horizontal behavior is described in parentheses. .IP [1] If button 1 is pressed in the trough, the scale's value will be incremented or decremented by the value of the \fB\-resolution\fR -option so that the slider moves in the direction of the cursor. +option so that the slider moves in the direction of the cursor. If the button is held down, the action auto-repeats. .IP [2] If button 1 is pressed over the slider, the slider can be dragged diff --git a/doc/selection.n b/doc/selection.n index e06a716..f5bb660 100644 --- a/doc/selection.n +++ b/doc/selection.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH selection n 8.1 Tk "Tk Built-In Commands" .so man.macros .BS @@ -36,7 +36,7 @@ atom name such as \fBPRIMARY\fR or \fBCLIPBOARD\fR; see the Inter-Client Communication Conventions Manual for complete details. \fISelection\fR defaults to \fBPRIMARY\fR and \fIwindow\fR defaults to .QW . . -Returns an empty string. +Returns an empty string. .TP \fBselection get\fR ?\fB\-displayof\fR \fIwindow\fR? ?\fB\-selection\fR \fIselection\fR? ?\fB\-type\fR \fItype\fR? . @@ -79,7 +79,7 @@ automatically handled as type \fBUTF8_STRING\fR as well. When \fIselection\fR is requested, \fIwindow\fR is the selection owner, and \fItype\fR is the requested type, \fIcommand\fR will be executed as a Tcl command with two additional numbers appended to it -(with space separators). +(with space separators). The two additional numbers are \fIoffset\fR and \fImaxChars\fR: \fIoffset\fR specifies a starting character position in the selection and \fImaxChars\fR gives the maximum diff --git a/doc/tkerror.n b/doc/tkerror.n index 0780901..53cb0d1 100644 --- a/doc/tkerror.n +++ b/doc/tkerror.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH tkerror n 4.1 Tk "Tk Built-In Commands" .so man.macros .BS @@ -20,11 +20,11 @@ Note: as of Tk 4.1 the \fBtkerror\fR command has been renamed to \fBbgerror\fR because the event loop (which is what usually invokes it) is now part of Tcl. For backward compatibility the \fBbgerror\fR provided by the current Tk version still -tries to call \fBtkerror\fR if there is one (or an auto loadable one), +tries to call \fBtkerror\fR if there is one (or an auto loadable one), so old script defining that error handler should still work, but you -should anyhow modify your scripts to use \fBbgerror\fR instead +should anyhow modify your scripts to use \fBbgerror\fR instead of \fBtkerror\fR because that support for the old name might vanish -in the near future. If that call fails, \fBbgerror\fR +in the near future. If that call fails, \fBbgerror\fR posts a dialog showing the error and offering to see the stack trace to the user. If you want your own error management you should directly override \fBbgerror\fR instead of \fBtkerror\fR. diff --git a/doc/ttk_Geometry.3 b/doc/ttk_Geometry.3 index 8dfae37..61015c5 100644 --- a/doc/ttk_Geometry.3 +++ b/doc/ttk_Geometry.3 @@ -75,7 +75,7 @@ Used to store error messages. .AP int left in Extra padding (in pixels) to add to the left side of a region. .AP "Tcl_Obj *" objPtr in -String value contains a symbolic name +String value contains a symbolic name to be converted to an enumerated value or bitmask. Internal rep may be be modified to cache corresponding value. .AP Ttk_Padding padding in @@ -84,18 +84,18 @@ Extra padding to add on the inside of a region. .AP Ttk_Box parcel in A rectangular region, allocated from a cavity. .AP int relief in -One of the standard Tk relief options -(TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, etc.). +One of the standard Tk relief options +(TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, etc.). See \fBTk_GetReliefFromObj\fR. .AP short right in Extra padding (in pixels) to add to the right side of a region. .AP Ttk_Side side in -One of \fBTTK_SIDE_LEFT\fR, \fBTTK_SIDE_TOP\fR, +One of \fBTTK_SIDE_LEFT\fR, \fBTTK_SIDE_TOP\fR, \fBTTK_SIDE_RIGHT\fR, or \fBTTK_SIDE_BOTTOM\fR. .AP unsigned sticky in A bitmask containing one or more of the bits -\fBTTK_STICK_W\fR (west, or left), -\fBTTK_STICK_E\fR (east, or right, +\fBTTK_STICK_W\fR (west, or left), +\fBTTK_STICK_E\fR (east, or right, \fBTTK_STICK_N\fR (north, or top), and \fBTTK_STICK_S\fR (south, or bottom). \fBTTK_FILL_X\fR is defined as a synonym for (TTK_STICK_W|TTK_STICK_E), @@ -104,7 +104,7 @@ and \fBTTK_FILL_BOTH\fR and \fBTTK_STICK_ALL\fR are synonyms for (TTK_FILL_X|TTK_FILL_Y). See also: \fIgrid(n)\fR. .AP Tk_Window tkwin in -Window whose screen geometry determines +Window whose screen geometry determines the conversion between absolute units and pixels. .AP short top in Extra padding at the top of a region. @@ -184,14 +184,14 @@ with all components equal to the specified \fIborder\fR. and returns a combined padding containing the sum of the individual padding components. .PP -\fBTtk_RelievePadding\fR +\fBTtk_RelievePadding\fR adds an extra 2 pixels of padding to \fIpadding\fR according to the specified \fIrelief\fR. -If \fIrelief\fR is \fBTK_RELIEF_SUNKEN\fR, +If \fIrelief\fR is \fBTK_RELIEF_SUNKEN\fR, adds two pixels at the top and left so the inner region is shifted down and to the left. If it is \fBTK_RELIEF_RAISED\fR, adds two pixels -at the bottom and right so +at the bottom and right so the inner region is shifted up and to the right. Otherwise, adds 1 pixel on all sides. This is typically used in element geometry procedures to simulate a @@ -201,17 +201,17 @@ look for pushbuttons. .PP \fBTtk_GetPaddingFromObj\fR converts the string in \fIobjPtr\fR to a \fBTtk_Padding\fR structure. -The string representation is a list of -up to four length specifications +The string representation is a list of +up to four length specifications .QW "\fIleft top right bottom\fR" . -If fewer than four elements are specified, +If fewer than four elements are specified, \fIbottom\fR defaults to \fItop\fR, -\fIright\fR defaults to \fIleft\fR, and +\fIright\fR defaults to \fIleft\fR, and \fItop\fR defaults to \fIleft\fR. See \fBTk_GetPixelsFromObj(3)\fR for the syntax of length specifications. .PP \fBTtk_GetBorderFromObj\fR is the same as \fBTtk_GetPaddingFromObj\fR -except that the lengths are specified as integers +except that the lengths are specified as integers (i.e., resolution-dependant values like \fI3m\fR are not allowed). .PP \fBTtk_GetStickyFromObj\fR converts the string in \fIobjPtr\fR diff --git a/doc/ttk_button.n b/doc/ttk_button.n index 2f3c845..62ebe47 100644 --- a/doc/ttk_button.n +++ b/doc/ttk_button.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::button n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -36,12 +36,12 @@ button (meaning, roughly, The default is \fBnormal\fR. .RS .PP -Depending on the theme, the default button may be displayed +Depending on the theme, the default button may be displayed with an extra highlight ring, or with a different border color. .RE .OP \-width width Width -If greater than zero, specifies how much space, in character widths, -to allocate for the text label. +If greater than zero, specifies how much space, in character widths, +to allocate for the text label. If less than zero, specifies a minimum width. If zero or unspecified, the natural width of the text label is used. Note that some themes may specify a non-zero \fB\-width\fR @@ -55,8 +55,8 @@ in the style. .\" .OP \-relief relief Relief .SH "WIDGET COMMAND" .PP -In addition to the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR commands, buttons support the following additional widget commands: .TP \fIpathName \fBinvoke\fR diff --git a/doc/ttk_checkbutton.n b/doc/ttk_checkbutton.n index 6236503..ed79f5a 100644 --- a/doc/ttk_checkbutton.n +++ b/doc/ttk_checkbutton.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::checkbutton n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -14,7 +14,7 @@ ttk::checkbutton \- On/off widget .BE .SH DESCRIPTION A \fBttk::checkbutton\fR widget is used to show or change a setting. -It has two states, selected and deselected. +It has two states, selected and deselected. The state of the checkbutton may be linked to a Tcl variable. .SO ttk_widget \-class \-compound \-cursor @@ -26,18 +26,18 @@ The state of the checkbutton may be linked to a Tcl variable. .OP \-command command Command A Tcl script to execute whenever the widget is invoked. .OP \-offvalue offValue OffValue -The value to store in the associated \fB\-variable\fR +The value to store in the associated \fB\-variable\fR when the widget is deselected. Defaults to \fB0\fR. .OP \-onvalue onValue OnValue -The value to store in the associated \fB\-variable\fR +The value to store in the associated \fB\-variable\fR when the widget is selected. Defaults to \fB1\fR. .OP \-variable variable Variable The name of a global variable whose value is linked to the widget. Defaults to the widget pathname if not specified. .SH "WIDGET COMMAND" .PP -In addition to the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR commands, checkbuttons support the following additional widget commands: .TP @@ -48,17 +48,17 @@ If the widget is currently selected, sets the \fB\-variable\fR to the \fB\-offvalue\fR and deselects the widget; otherwise, sets the \fB\-variable\fR to the \fB\-onvalue\fR Returns the result of the \fB\-command\fR. -.\" Missing: select, deselect, toggle +.\" Missing: select, deselect, toggle .\" Are these useful? They don't invoke the -command .\" Missing: flash. This is definitely not useful. .SH "WIDGET STATES" .PP The widget does not respond to user input if the \fBdisabled\fR state is set. -The widget sets the \fBselected\fR state whenever +The widget sets the \fBselected\fR state whenever the linked \fB\-variable\fR is set to the widget's \fB\-onvalue\fR, and clears it otherwise. -The widget sets the \fBalternate\fR state whenever the -linked \fB\-variable\fR is unset. +The widget sets the \fBalternate\fR state whenever the +linked \fB\-variable\fR is unset. (The \fBalternate\fR state may be used to indicate a .QW tri-state or diff --git a/doc/ttk_combobox.n b/doc/ttk_combobox.n index dc1c7d1..5e5b3fc 100644 --- a/doc/ttk_combobox.n +++ b/doc/ttk_combobox.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::combobox n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -15,7 +15,7 @@ ttk::combobox \- text field with popdown selection list .SH DESCRIPTION .PP A \fBttk::combobox\fR combines a text field with a pop-down list of values; -the user may select the value of the text field from among the +the user may select the value of the text field from among the values in the list. .SO ttk_widget \-class \-cursor \-takefocus @@ -37,14 +37,14 @@ The \fB\-postcommand\fR script may specify the \fB\-values\fR to display. .OP \-state state State One of \fBnormal\fR, \fBreadonly\fR, or \fBdisabled\fR. In the \fBreadonly\fR state, -the value may not be edited directly, and +the value may not be edited directly, and the user can only select one of the \fB\-values\fR from the dropdown list. -In the \fBnormal\fR state, +In the \fBnormal\fR state, the text field is directly editable. In the \fBdisabled\fR state, no interaction is possible. .OP \-textvariable textVariable TextVariable -Specifies the name of a global variable whose value is linked +Specifies the name of a global variable whose value is linked to the widget value. Whenever the variable changes value the widget value is updated, and vice versa. @@ -66,7 +66,7 @@ The following subcommands are possible for combobox widgets: '\"See \fIttk::widget(n)\fR. .TP \fIpathName \fBcurrent\fR ?\fInewIndex\fR? -If \fInewIndex\fR is supplied, sets the combobox value +If \fInewIndex\fR is supplied, sets the combobox value to the element at position \fInewIndex\fR in the list of \fB\-values\fR. Otherwise, returns the index of the current value in the list of \fB\-values\fR or \fB\-1\fR if the current value does not appear in the list. diff --git a/doc/ttk_entry.n b/doc/ttk_entry.n index 34779a6..984e957 100644 --- a/doc/ttk_entry.n +++ b/doc/ttk_entry.n @@ -5,7 +5,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::entry n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -18,9 +18,9 @@ ttk::entry \- Editable text field widget .PP An \fBttk::entry\fR widget displays a one-line text string and allows that string to be edited by the user. -The value of the string may be linked to a Tcl variable +The value of the string may be linked to a Tcl variable with the \fB\-textvariable\fR option. -Entry widgets support horizontal scrolling with the +Entry widgets support horizontal scrolling with the standard \fB\-xscrollcommand\fR option and \fBxview\fR widget command. .SO ttk_widget \-class \-cursor \-style @@ -28,7 +28,7 @@ standard \fB\-xscrollcommand\fR option and \fBxview\fR widget command. .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-exportselection exportSelection ExportSelection -A boolean value specifying whether or not +A boolean value specifying whether or not a selection in the widget should be linked to the X selection. If the selection is exported, then selecting in the widget deselects the current X selection, selecting outside the widget deselects any @@ -65,7 +65,7 @@ Specifies one of three states for the entry, \fBnormal\fR, \fBdisabled\fR, or \fBreadonly\fR. See \fBWIDGET STATES\fR, below. .OP \-textvariable textVariable Variable -Specifies the name of a global variable whose value is linked +Specifies the name of a global variable whose value is linked to the entry widget's contents. Whenever the variable changes value, the widget's contents are updated, and vice versa. @@ -217,7 +217,7 @@ earlier one, then the entry's selection is cleared. '\"See \fIttk::widget(n)\fR. .TP \fIpathName \fBvalidate\fR -Force revalidation, independent of the conditions specified +Force revalidation, independent of the conditions specified by the \fB\-validate\fR option. Returns 0 if validation fails, 1 if it succeeds. Sets or clears the \fBinvalid\fR state accordingly. @@ -277,20 +277,20 @@ options are used to enable entry widget validation. .PP There are two main validation modes: \fIprevalidation\fR, in which the \fB\-validatecommand\fR is evaluated prior to each edit -and the return value is used to determine whether to accept +and the return value is used to determine whether to accept or reject the change; -and \fIrevalidation\fR, in which the \fB\-validatecommand\fR is +and \fIrevalidation\fR, in which the \fB\-validatecommand\fR is evaluated to determine whether the current value is valid. .PP The \fB\-validate\fR option determines when validation occurs; it may be set to any of the following values: .RS .IP \fBnone\fR -Default. This means validation will only occur when +Default. This means validation will only occur when specifically requested by the \fBvalidate\fR widget command. .IP \fBkey\fR The entry will be prevalidated prior to each edit -(specifically, whenever the \fBinsert\fR or \fBdelete\fR +(specifically, whenever the \fBinsert\fR or \fBdelete\fR widget commands are called). If prevalidation fails, the edit is rejected. .IP \fBfocus\fR @@ -311,20 +311,20 @@ may modify the entry widget's value via the widget \fBinsert\fR or \fBdelete\fR commands, or by setting the linked \fB\-textvariable\fR. If either does so during prevalidation, -then the edit is rejected +then the edit is rejected regardless of the value returned by the \fB\-validatecommand\fR. .PP -If \fB\-validatecommand\fR is empty (the default), +If \fB\-validatecommand\fR is empty (the default), validation always succeeds. .SS "VALIDATION SCRIPT SUBSTITUTIONS" .PP -It is possible to perform percent substitutions on the +It is possible to perform percent substitutions on the \fB\-validatecommand\fR and \fB\-invalidcommand\fR, just as in a \fBbind\fR script. The following substitutions are recognized: .RS .IP \fB%d\fR -Type of action: 1 for \fBinsert\fR prevalidation, +Type of action: 1 for \fBinsert\fR prevalidation, 0 for \fBdelete\fR prevalidation, or \-1 for revalidation. .IP \fB%i\fR @@ -348,19 +348,19 @@ The name of the entry widget. .PP The standard Tk entry widget automatically disables validation (by setting \fB\-validate\fR to \fBnone\fR) -if the \fB\-validatecommand\fR or \fB\-invalidcommand\fR modifies +if the \fB\-validatecommand\fR or \fB\-invalidcommand\fR modifies the entry's value. The Tk themed entry widget only disables validation if one of the validation scripts raises an error, or if \fB\-validatecommand\fR does not return a valid boolean value. -(Thus, it is not necessary to re-enable validation after +(Thus, it is not necessary to re-enable validation after modifying the entry value in a validation script). .PP In addition, the standard entry widget invokes validation whenever the linked \fB\-textvariable\fR is modified; the Tk themed entry widget does not. .SH "DEFAULT BINDINGS" .PP -The entry widget's default bindings enable the following behavior. +The entry widget's default bindings enable the following behavior. In the descriptions below, .QW word refers to a contiguous group of letters, digits, or @@ -442,22 +442,22 @@ Control-k deletes all the characters to the right of the insertion cursor. .SH "WIDGET STATES" .PP -In the \fBdisabled\fR state, +In the \fBdisabled\fR state, the entry cannot be edited and the text cannot be selected. In the \fBreadonly\fR state, -no insert cursor is displayed and -the entry cannot be edited +no insert cursor is displayed and +the entry cannot be edited (specifically: the \fBinsert\fR and \fBdelete\fR commands have no effect). -The \fBdisabled\fR state is the same as \fBreadonly\fR, +The \fBdisabled\fR state is the same as \fBreadonly\fR, and in addition text cannot be selected. .PP -Note that changes to the linked \fB\-textvariable\fR will +Note that changes to the linked \fB\-textvariable\fR will still be reflected in the entry, even if it is disabled or readonly. .PP Typically, the text is .QW grayed-out in the \fBdisabled\fR state, -and a different background is used in the \fBreadonly\fR state. +and a different background is used in the \fBreadonly\fR state. .PP The entry widget sets the \fBinvalid\fR state if revalidation fails, and clears it whenever validation succeeds. diff --git a/doc/ttk_frame.n b/doc/ttk_frame.n index 3b885e0..b54ce96 100644 --- a/doc/ttk_frame.n +++ b/doc/ttk_frame.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::frame n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -22,9 +22,9 @@ together. .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-borderwidth borderWidth BorderWidth -The desired width of the widget border. Defaults to 0. +The desired width of the widget border. Defaults to 0. .OP \-relief relief Relief -One of the standard Tk border styles: +One of the standard Tk border styles: \fBflat\fR, \fBgroove\fR, \fBraised\fR, \fBridge\fR, \fBsolid\fR, or \fBsunken\fR. Defaults to \fBflat\fR. diff --git a/doc/ttk_image.n b/doc/ttk_image.n index 99d38c6..4985c20 100644 --- a/doc/ttk_image.n +++ b/doc/ttk_image.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk_image n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -16,7 +16,7 @@ ttk_image \- Define an element based on an image .PP The \fIimage\fR element factory creates a new element in the current theme whose visual appearance is determined -by Tk images. +by Tk images. \fIimageSpec\fP is a list of one or more elements. The first element is the default image name. The rest of the list is a sequence of \fIstatespec / value\fR @@ -36,7 +36,7 @@ Specifies a minimum height for the element. If less than zero, the base image's height is used as a default. .TP \fB\-padding\fR \fIpadding\fR -Specifies the element's interior padding. Defaults to +Specifies the element's interior padding. Defaults to \fB\-border\fR if not specified. .TP \fB\-sticky\fR \fIspec\fR @@ -53,13 +53,13 @@ Specifies a minimum width for the element. If less than zero, the base image's width is used as a default. .SH "IMAGE STRETCHING" .PP -If the element's allocated parcel is larger than the image, +If the element's allocated parcel is larger than the image, the image will be placed in the parcel based on the \fB\-sticky\fR option. If the image needs to stretch horizontally (i.e., \fB\-sticky ew\fR) or vertically (\fB\-sticky ns\fR), subregions of the image are replicated to fill the parcel based on the \fB\-border\fR option. -The \fB\-border\fR divides the image into 9 regions: +The \fB\-border\fR divides the image into 9 regions: four fixed corners, top and left edges (which may be tiled horizontally), left and right edges (which may be tiled vertically), and the central area (which may be tiled in both directions). diff --git a/doc/ttk_intro.n b/doc/ttk_intro.n index baef34d..bc3cd69 100644 --- a/doc/ttk_intro.n +++ b/doc/ttk_intro.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::intro n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -24,7 +24,7 @@ all aspects of the widget's appearance are controlled by the style of the widget (i.e. the style of the elements of the widget). .SH "THEMES" .PP -A \fItheme\fR is a collection of elements and styles +A \fItheme\fR is a collection of elements and styles that determine the look and feel of the widget set. Themes can be used to: .IP \(bu @@ -47,7 +47,7 @@ For example, a vertical scrollbar widget contains \fBuparrow\fR, .PP Element names use a recursive dotted notation. For example, \fBuparrow\fR identifies a generic arrow element, -and \fBScrollbar.uparrow\fR and \fBCombobox.uparrow\fR identify +and \fBScrollbar.uparrow\fR and \fBCombobox.uparrow\fR identify widget-specific elements. When looking for an element, the style engine looks for the specific name first, and if an element of that name is @@ -56,9 +56,9 @@ successive leading components of the element name. .PP Like widgets, elements have \fIoptions\fR which specify what to display and how to display it. -For example, the \fBtext\fR element +For example, the \fBtext\fR element (which displays a text string) has -\fB\-text\fR, \fB\-font\fR, \fB\-foreground\fR, \fB\-background\fR, +\fB\-text\fR, \fB\-font\fR, \fB\-foreground\fR, \fB\-background\fR, \fB\-underline\fR, and \fB\-width\fR options. The value of an element option is taken from: .IP \(bu @@ -105,14 +105,14 @@ and the various flavors of buttons which have \fBactive\fR state. The themed Tk widgets generalizes this idea: every widget has a bitmap of independent state flags. Widget state flags include \fBactive\fR, \fBdisabled\fR, -\fBpressed\fR, \fBfocus\fR, etc., +\fBpressed\fR, \fBfocus\fR, etc., (see \fIttk::widget(n)\fR for the full list of state flags). .PP -Instead of a \fB\-state\fR option, every widget now has +Instead of a \fB\-state\fR option, every widget now has a \fBstate\fR widget command which is used to set or query the state. A \fIstate specification\fR is a list of symbolic state names -indicating which bits are set, each optionally prefixed with an +indicating which bits are set, each optionally prefixed with an exclamation point indicating that the bit is cleared instead. .PP For example, the class bindings for the \fBttk::button\fR @@ -132,7 +132,7 @@ This specifies that the widget becomes \fBactive\fR when the pointer enters the widget, and inactive when it leaves. Similarly it becomes \fBpressed\fR when the mouse button is pressed, and \fB!pressed\fR on the ButtonRelease event. -In addition, the button unpresses if +In addition, the button unpresses if pointer is dragged outside the widget while Button-1 is held down, and represses if it's dragged back in. Finally, when the mouse button is released, the widget's @@ -143,7 +143,7 @@ but not by much). '\" Note to self: rewrite that paragraph. It's horrible. .SH "STYLES" .PP -Each widget is associated with a \fIstyle\fR, +Each widget is associated with a \fIstyle\fR, which specifies values for element options. Style names use a recursive dotted notation like layouts and elements; by default, widgets use the class name to look up a style in the current theme. @@ -157,7 +157,7 @@ ttk::\fBstyle configure\fR TButton \e ; .CE .PP -Many elements are displayed differently depending on the widget state. +Many elements are displayed differently depending on the widget state. For example, buttons have a different background when they are active, a different foreground when disabled, and a different relief when pressed. The \fBstyle map\fR command specifies dynamic option settings diff --git a/doc/ttk_label.n b/doc/ttk_label.n index ff93adf..6781b47 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::label n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -15,7 +15,7 @@ ttk::label \- Display a text string and/or image .SH DESCRIPTION .PP A \fBttk::label\fR widget displays a textual label and/or image. -The label may be linked to a Tcl variable +The label may be linked to a Tcl variable to automatically change the displayed text. .SO ttk_widget \-class \-compound \-cursor @@ -31,7 +31,7 @@ relative to the inner margins. Legal values are \fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, and \fBcenter\fR. See also \fB\-justify\fR. .OP \-background frameColor FrameColor -The widget's background color. +The widget's background color. If unspecified, the theme default is used. .OP \-font font Font Font to use for label text. @@ -45,17 +45,17 @@ One of \fBleft\fR, \fBcenter\fR, or \fBright\fR. See also \fB\-anchor\fR. .OP \-padding padding Padding Specifies the amount of extra space to allocate for the widget. -The padding is a list of up to four length specifications +The padding is a list of up to four length specifications \fIleft top right bottom\fR. -If fewer than four elements are specified, +If fewer than four elements are specified, \fIbottom\fR defaults to \fItop\fR, -\fIright\fR defaults to \fIleft\fR, and +\fIright\fR defaults to \fIleft\fR, and \fItop\fR defaults to \fIleft\fR. .OP \-relief relief Relief .\" Rewrite this: Specifies the 3-D effect desired for the widget border. Valid values are -\fBflat\fR, \fBgroove\fR, \fBraised\fR, \fBridge\fR, \fBsolid\fR, +\fBflat\fR, \fBgroove\fR, \fBraised\fR, \fBridge\fR, \fBsolid\fR, and \fBsunken\fR. .OP \-text text Text Specifies a text string to be displayed inside the widget diff --git a/doc/ttk_labelframe.n b/doc/ttk_labelframe.n index 2dae91f..64edf6a 100644 --- a/doc/ttk_labelframe.n +++ b/doc/ttk_labelframe.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::labelframe n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -22,7 +22,7 @@ another widget. \-style .SE .SH "WIDGET-SPECIFIC OPTIONS" -.\" XXX: Currently included, but may go away: +.\" XXX: Currently included, but may go away: .\" XXX: .OP -borderwidth borderWidth BorderWidth .\" XXX: The desired width of the widget border. Default is theme-dependent. .\" XXX: .OP -relief relief Relief @@ -31,7 +31,7 @@ another widget. .\" XXX: \fBsolid\fR, or \fBsunken\fR. .\" XXX: Default is theme-dependent. .OP \-labelanchor labelAnchor LabelAnchor -Specifies where to place the label. +Specifies where to place the label. Allowed values are (clockwise from the top upper left corner): \fBnw\fR, \fBn\fR, \fBne\fR, \fBen\fR, \fBe\fR, \fBes\fR, \fBse\fR, \fBs\fR,\fBsw\fR, \fBws\fR, \fBw\fR and \fBwn\fR. @@ -43,10 +43,10 @@ The default value is theme-dependent. .OP \-text text Text Specifies the text of the label. .OP \-underline underline Underline -If set, specifies the integer index (0-based) of a character to +If set, specifies the integer index (0-based) of a character to underline in the text string. -The underlined character is used for mnemonic activation. -Mnemonic activation for a \fBttk::labelframe\fR +The underlined character is used for mnemonic activation. +Mnemonic activation for a \fBttk::labelframe\fR sets the keyboard focus to the first child of the \fBttk::labelframe\fR widget. .OP \-padding padding Padding Additional padding to include inside the border. diff --git a/doc/ttk_menubutton.n b/doc/ttk_menubutton.n index 33189e8..698bd0c 100644 --- a/doc/ttk_menubutton.n +++ b/doc/ttk_menubutton.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::menubutton n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -24,10 +24,10 @@ and displays a menu when pressed. .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-direction direction Direction -Specifies where the menu is to be popped up relative -to the menubutton. +Specifies where the menu is to be popped up relative +to the menubutton. One of: \fBabove\fR, \fBbelow\fR, \fBleft\fR, \fBright\fR, -or \fBflush\fR. The default is \fBbelow\fR. +or \fBflush\fR. The default is \fBbelow\fR. \fBflush\fR pops the menu up directly over the menubutton. .OP \-menu menu Menu Specifies the path name of the menu associated with the menubutton. @@ -38,8 +38,8 @@ menubutton. .\" .OP \-padding padding Pad .SH "WIDGET COMMAND" .PP -Menubutton widgets support the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR +Menubutton widgets support the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR methods. No other widget methods are used. .SH "STANDARD STYLES" .PP diff --git a/doc/ttk_notebook.n b/doc/ttk_notebook.n index cecae48..4d1b789 100644 --- a/doc/ttk_notebook.n +++ b/doc/ttk_notebook.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::notebook n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -18,7 +18,7 @@ ttk::notebook \- Multi-paned container widget .fi .BE .SH DESCRIPTION -A \fBttk::notebook\fR widget manages a collection of windows +A \fBttk::notebook\fR widget manages a collection of windows and displays a single one at a time. Each slave window is associated with a \fItab\fR, which the user may select to change the currently-displayed window. @@ -28,35 +28,35 @@ which the user may select to change the currently-displayed window. .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-height height Height -If present and greater than zero, +If present and greater than zero, specifies the desired height of the pane area (not including internal padding or tabs). Otherwise, the maximum height of all panes is used. .OP \-padding padding Padding Specifies the amount of extra space to add around the outside of the notebook. -The padding is a list of up to four length specifications +The padding is a list of up to four length specifications \fIleft top right bottom\fR. -If fewer than four elements are specified, +If fewer than four elements are specified, \fIbottom\fR defaults to \fItop\fR, -\fIright\fR defaults to \fIleft\fR, and +\fIright\fR defaults to \fIleft\fR, and \fItop\fR defaults to \fIleft\fR. .OP \-width width Width -If present and greater than zero, +If present and greater than zero, specifies the desired width of the pane area (not including internal padding). Otherwise, the maximum width of all panes is used. .SH "TAB OPTIONS" The following options may be specified for individual notebook panes: .OP \-state state State -Either \fBnormal\fR, \fBdisabled\fR or \fBhidden\fR. +Either \fBnormal\fR, \fBdisabled\fR or \fBhidden\fR. If \fBdisabled\fR, then the tab is not selectable. If \fBhidden\fR, then the tab is not shown. .OP \-sticky sticky Sticky Specifies how the slave window is positioned within the pane area. Value is a string containing zero or more of the characters \fBn, s, e,\fR or \fBw\fR. -Each letter refers to a side (north, south, east, or west) +Each letter refers to a side (north, south, east, or west) that the slave window will .QW stick to, as per the \fBgrid\fR geometry manager. @@ -73,7 +73,7 @@ Specifies how to display the image relative to the text, in the case both \fB\-text\fR and \fB\-image\fR are present. See \fIlabel(n)\fR for legal values. .OP \-underline underline Underline -Specifies the integer index (0-based) of a character to underline +Specifies the integer index (0-based) of a character to underline in the text string. The underlined character is used for mnemonic activation if \fBttk::notebook::enableTraversal\fR is called. @@ -87,7 +87,7 @@ The name of a slave window; .IP \(bu A positional specification of the form .QW @\fIx\fR,\fIy\fR , -which identifies the tab +which identifies the tab .IP \(bu The literal string .QW \fBcurrent\fR , @@ -95,7 +95,7 @@ which identifies the currently-selected tab; or: .IP \(bu The literal string .QW \fBend\fR , -which returns the number of tabs +which returns the number of tabs (only valid for .QW "\fIpathname \fBindex\fR" ). .SH "WIDGET COMMAND" @@ -142,9 +142,9 @@ or the total number of tabs if \fItabid\fR is the string .TP \fIpathname \fBinsert \fIpos subwindow options...\fR Inserts a pane at the specified position. -\fIpos\fR is either the string \fBend\fR, an integer index, +\fIpos\fR is either the string \fBend\fR, an integer index, or the name of a managed subwindow. -If \fIsubwindow\fR is already managed by the notebook, +If \fIsubwindow\fR is already managed by the notebook, moves it to the specified position. See \fBTAB OPTIONS\fR for the list of available options. .TP @@ -190,7 +190,7 @@ containing the notebook as follows: of any tab, will select that tab. .PP Multiple notebooks in a single toplevel may be enabled for traversal, -including nested notebooks. +including nested notebooks. However, notebook traversal only works properly if all panes are direct children of the notebook. .SH "VIRTUAL EVENTS" diff --git a/doc/ttk_progressbar.n b/doc/ttk_progressbar.n index 6306450..1945f70 100644 --- a/doc/ttk_progressbar.n +++ b/doc/ttk_progressbar.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::progressbar n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -44,15 +44,15 @@ that is, the progress bar completes one when the \fB\-value\fR increases by \fB\-maximum\fR. .OP \-variable variable Variable The name of a global Tcl variable which is linked to the \fB\-value\fR. -If specified, the \fB\-value\fR of the progress bar is -automatically set to the value of the variable whenever +If specified, the \fB\-value\fR of the progress bar is +automatically set to the value of the variable whenever the latter is modified. .OP \-phase phase Phase Read-only option. -The widget periodically increments the value of this option +The widget periodically increments the value of this option whenever the \fB\-value\fR is greater than 0 and, in \fIdeterminate\fR mode, less than \fB\-maximum\fR. -This option may be used by the current theme +This option may be used by the current theme to provide additional animation effects. .SH "WIDGET COMMAND" .PP @@ -72,7 +72,7 @@ Test the widget state; see \fIttk::widget(n)\fR. .TP \fIpathName \fBstart\fR ?\fIinterval\fR? Begin autoincrement mode: -schedules a recurring timer event that calls \fBstep\fR +schedules a recurring timer event that calls \fBstep\fR every \fIinterval\fR milliseconds. If omitted, \fIinterval\fR defaults to 50 milliseconds (20 steps/second). .TP @@ -80,7 +80,7 @@ If omitted, \fIinterval\fR defaults to 50 milliseconds (20 steps/second). Modify or query the widget state; see \fIttk::widget(n)\fR. .TP \fIpathName \fBstep\fR ?\fIamount\fR? -Increments the \fB\-value\fR by \fIamount\fR. +Increments the \fB\-value\fR by \fIamount\fR. \fIamount\fR defaults to 1.0 if omitted. .TP \fIpathName \fBstop\fR diff --git a/doc/ttk_radiobutton.n b/doc/ttk_radiobutton.n index c16f2cd..5b4dcce 100644 --- a/doc/ttk_radiobutton.n +++ b/doc/ttk_radiobutton.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::radiobutton n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -29,21 +29,21 @@ it sets the variable to its associated value. .OP \-command command Command A Tcl script to evaluate whenever the widget is invoked. .OP \-value Value Value -The value to store in the associated \fB\-variable\fR -when the widget is selected. +The value to store in the associated \fB\-variable\fR +when the widget is selected. .OP \-variable variable Variable The name of a global variable whose value is linked to the widget. Default value is \fB::selectedButton\fR. .SH "WIDGET COMMAND" .PP -In addition to the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR +In addition to the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR commands, radiobuttons support the following additional widget commands: .TP \fIpathname\fB invoke\fR Sets the \fB\-variable\fR to the \fB\-value\fR, selects the widget, -and evaluates the associated \fB\-command\fR. +and evaluates the associated \fB\-command\fR. Returns the result of the \fB\-command\fR, or the empty string if no \fB\-command\fR is specified. .\" Missing: select, deselect. Useful? @@ -51,11 +51,11 @@ string if no \fB\-command\fR is specified. .SH "WIDGET STATES" .PP The widget does not respond to user input if the \fBdisabled\fR state is set. -The widget sets the \fBselected\fR state whenever +The widget sets the \fBselected\fR state whenever the linked \fB\-variable\fR is set to the widget's \fB\-value\fR, and clears it otherwise. -The widget sets the \fBalternate\fR state whenever the -linked \fB\-variable\fR is unset. +The widget sets the \fBalternate\fR state whenever the +linked \fB\-variable\fR is unset. (The \fBalternate\fR state may be used to indicate a .QW tri-state or diff --git a/doc/ttk_scrollbar.n b/doc/ttk_scrollbar.n index 56df214..03d09f2 100644 --- a/doc/ttk_scrollbar.n +++ b/doc/ttk_scrollbar.n @@ -4,12 +4,12 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::scrollbar n 8.5 Tk "Tk Themed Widget" .so man.macros .BS .SH NAME -ttk::scrollbar \- Control the viewport of a scrollable widget +ttk::scrollbar \- Control the viewport of a scrollable widget .SH SYNOPSIS \fBttk::scrollbar\fR \fIpathName \fR?\fIoptions...\fR? .BE @@ -30,7 +30,7 @@ these are used to scroll the visible region in discrete units. .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-command command Command -A Tcl script prefix to evaluate +A Tcl script prefix to evaluate to change the view in the widget associated with the scrollbar. Additional arguments are appended to the value of this option, as described in \fBSCROLLING COMMANDS\fR below, @@ -66,7 +66,7 @@ See \fIttk::widget(n)\fR. Test the widget state; see \fIttk::widget(n)\fR. .TP \fIpathName \fBset \fIfirst last\fR -This command is normally invoked by the scrollbar's associated widget +This command is normally invoked by the scrollbar's associated widget from an \fB\-xscrollcommand\fR or \fB\-yscrollcommand\fR callback. Specifies the visible range to be displayed. \fIfirst\fR and \fIlast\fR are real fractions between 0 and 1. @@ -147,7 +147,7 @@ of individual elements, based on the position and state of the mouse pointer. set f [frame .f] ttk::scrollbar $f.hsb \-orient horizontal \-command [list $f.t xview] ttk::scrollbar $f.vsb \-orient vertical \-command [list $f.t yview] -text $f.t \-xscrollcommand [list $f.hsb set] \-yscrollcommand [list $f.vsb set] +text $f.t \-xscrollcommand [list $f.hsb set] \-yscrollcommand [list $f.vsb set] grid $f.t \-row 0 \-column 0 \-sticky nsew grid $f.vsb \-row 0 \-column 1 \-sticky nsew grid $f.hsb \-row 1 \-column 0 \-sticky nsew diff --git a/doc/ttk_separator.n b/doc/ttk_separator.n index d955fc4..fea2701 100644 --- a/doc/ttk_separator.n +++ b/doc/ttk_separator.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::separator n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -26,8 +26,8 @@ One of \fBhorizontal\fR or \fBvertical\fR. Specifies the orientation of the separator. .SH "WIDGET COMMAND" .PP -Separator widgets support the standard -\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR +Separator widgets support the standard +\fBcget\fR, \fBconfigure\fR, \fBidentify\fR, \fBinstate\fR, and \fBstate\fR methods. No other widget methods are used. .SH "SEE ALSO" ttk::widget(n) diff --git a/doc/ttk_spinbox.n b/doc/ttk_spinbox.n index f10af3d..7ae586f 100644 --- a/doc/ttk_spinbox.n +++ b/doc/ttk_spinbox.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::spinbox n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -42,7 +42,7 @@ time one of the widget spin buttons is pressed. The up button applies a positive increment, the down button applies a negative increment. .OP \-values values Values This must be a Tcl list of values. If this option is set then this will -override any range set using the \fB\-from\fR, \fB\-to\fR and +override any range set using the \fB\-from\fR, \fB\-to\fR and \fB\-increment\fR options. The widget will instead use the values specified beginning with the first value. .OP \-wrap wrap Wrap @@ -60,7 +60,7 @@ Specifies a Tcl command to be invoked whenever a spinbutton is invoked. See the \fBttk::entry\fR manual for information about indexing characters. .SH "VALIDATION" .PP -See the \fBttk::entry\fR manual for information about using the +See the \fBttk::entry\fR manual for information about using the \fB\-validate\fR and \fB\-validatecommand\fR options. .SH "WIDGET COMMAND" .PP diff --git a/doc/ttk_style.n b/doc/ttk_style.n index dc3bade..985e3cd 100644 --- a/doc/ttk_style.n +++ b/doc/ttk_style.n @@ -1,9 +1,9 @@ '\" '\" Copyright (c) 2004 Joe English -'\" +'\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::style n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -23,9 +23,9 @@ which specifies the set of elements making up the widget and how they are arranged, along with dynamic and default settings for element options. By default, the style name is the same as the widget's class; -this may be overridden by the \fB\-style\fR option. +this may be overridden by the \fB\-style\fR option. .PP -A \fItheme\fR is a collection of elements and styles +A \fItheme\fR is a collection of elements and styles which controls the overall look and feel of an application. .SH DESCRIPTION .PP @@ -43,31 +43,31 @@ is used. \fBttk::style lookup \fIstyle\fR \fI\-option \fR?\fIstate \fR?\fIdefault\fR?? Returns the value specified for \fI\-option\fR in style \fIstyle\fR in state \fIstate\fR, using the standard lookup rules for element options. -\fIstate\fR is a list of state names; if omitted, +\fIstate\fR is a list of state names; if omitted, it defaults to all bits off (the .QW normal state). If the \fIdefault\fR argument is present, it is used as a fallback value in case no specification for \fI\-option\fR is found. -.\" Otherwise -- signal error? return empty string? Leave unspecified for now. +.\" Otherwise -- signal error? return empty string? Leave unspecified for now. .TP \fBttk::style layout \fIstyle\fR ?\fIlayoutSpec\fR? -Define the widget layout for style \fIstyle\fR. +Define the widget layout for style \fIstyle\fR. See \fBLAYOUTS\fR below for the format of \fIlayoutSpec\fR. If \fIlayoutSpec\fR is omitted, return the layout specification for style \fIstyle\fR. -.TP +.TP \fBttk::style element create\fR \fIelementName\fR \fItype\fR ?\fIargs...\fR? Creates a new element in the current theme of type \fItype\fR. -The only cross-platform built-in element type is \fIimage\fR -(see \fBttk_image\fR(n)) but themes may define other element types +The only cross-platform built-in element type is \fIimage\fR +(see \fBttk_image\fR(n)) but themes may define other element types (see \fBTtk_RegisterElementFactory\fR). On suitable versions of Windows an element factory is registered to create Windows theme elements (see \fBttk_vsapi\fR(n)). -.TP +.TP \fBttk::style element names\fR Returns the list of elements defined in the current theme. -.TP +.TP \fBttk::style element options \fIelement\fR Returns the list of \fIelement\fR's options. .TP @@ -79,7 +79,7 @@ If \fB\-settings\fR is present, \fIscript\fR is evaluated in the context of the new theme as per \fBttk::style theme settings\fR. .TP \fBttk::style theme settings \fIthemeName\fR \fIscript\fR -Temporarily sets the current theme to \fIthemeName\fR, +Temporarily sets the current theme to \fIthemeName\fR, evaluate \fIscript\fR, then restore the previous theme. Typically \fIscript\fR simply defines styles and elements, though arbitrary Tcl code may appear. @@ -99,7 +99,7 @@ The layout mechanism uses a simplified version of the \fBpack\fR geometry manager: given an initial cavity, each element is allocated a parcel. Valid options are: -.TP +.TP \fB\-side \fIside\fR Specifies which side of the cavity to place the element; one of \fBleft\fR, \fBright\fR, \fBtop\fR, or \fBbottom\fR. diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n index dd83c20..660b076 100644 --- a/doc/ttk_treeview.n +++ b/doc/ttk_treeview.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk::treeview n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -15,15 +15,15 @@ ttk::treeview \- hierarchical multicolumn data display widget .SH DESCRIPTION .PP The \fBttk::treeview\fR widget displays a hierarchical collection of items. -Each item has a textual label, an optional image, +Each item has a textual label, an optional image, and an optional list of data values. The data values are displayed in successive columns after the tree label. .PP The order in which data values are displayed may be controlled -by setting the \fB\-displaycolumns\fR widget option. +by setting the \fB\-displaycolumns\fR widget option. The tree widget can also display column headings. -Columns may be accessed by number or by symbolic names +Columns may be accessed by number or by symbolic names listed in the \fB\-columns\fR widget option; see \fBCOLUMN IDENTIFIERS\fR. .PP @@ -40,7 +40,7 @@ and control the appearance of the item. .\" @@@HERE: describe selection, focus item .PP Treeview widgets support horizontal and vertical scrolling with the -standard \fB\-\fR[\fBxy\fR]\fBscrollcommand\fR options +standard \fB\-\fR[\fBxy\fR]\fBscrollcommand\fR options and [\fBxy\fR]\fBview\fR widget commands. .SO ttk_widget \-class \-cursor \-takefocus @@ -48,14 +48,14 @@ and [\fBxy\fR]\fBview\fR widget commands. .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-columns columns Columns -A list of column identifiers, +A list of column identifiers, specifying the number of columns and their names. .\"X: This is a read-only option; it may only be set when the widget is created. .OP \-displaycolumns displayColumns DisplayColumns -A list of column identifiers +A list of column identifiers (either symbolic names or integer indices) -specifying which data columns are displayed -and the order in which they appear, +specifying which data columns are displayed +and the order in which they appear, or the string \fB#all\fP. If set to \fB#all\fP (the default), all columns are shown in the order given. @@ -76,7 +76,7 @@ If set to \fBextended\fR (the default), multiple items may be selected. If \fBbrowse\fR, only a single item will be selected at a time. If \fBnone\fR, the selection will not be changed. .PP -Note that application code and tag bindings can set the selection +Note that application code and tag bindings can set the selection however they wish, regardless of the value of \fB\-selectmode\fR. .RE .OP \-show show Show @@ -84,7 +84,7 @@ A list containing zero or more of the following values, specifying which elements of the tree to display. .RS .IP \fBtree\fR -Display tree labels in column #0. +Display tree labels in column #0. .IP \fBheadings\fR Display the heading row. .PP @@ -114,7 +114,7 @@ returns the list of children belonging to \fIitem\fR. .RS .PP If \fInewchildren\fR is specified, replaces \fIitem\fR's child list -with \fInewchildren\fR. +with \fInewchildren\fR. Items in the old child list not present in the new child list are detached from the tree. None of the items in \fInewchildren\fR may be an ancestor @@ -125,7 +125,7 @@ of \fIitem\fR. Query or modify the options for the specified \fIcolumn\fR. If no \fI\-option\fR is specified, returns a dictionary of option/value pairs. -If a single \fI\-option\fR is specified, +If a single \fI\-option\fR is specified, returns the value of that option. Otherwise, the options are updated with the specified values. The following options may be set on each column: @@ -134,7 +134,7 @@ The following options may be set on each column: \fB\-id \fIname\fR The column name. This is a read-only option. For example, [\fI$pathname \fBcolumn #\fIn \fB\-id\fR] -returns the data column associated with display column #\fIn\fR. +returns the data column associated with display column #\fIn\fR. .TP \fB\-anchor\fR Specifies how the text in this column should be aligned @@ -145,7 +145,7 @@ with respect to the cell. One of \fB\-minwidth\fR The minimum width of the column in pixels. The treeview widget will not make the column any smaller than -\fB\-minwidth\fR when the widget is resized or the user drags a +\fB\-minwidth\fR when the widget is resized or the user drags a column separator. .TP \fB\-stretch\fR @@ -184,7 +184,7 @@ Returns 1 if the specified \fIitem\fR is present in the tree, If \fIitem\fR is specified, sets the focus item to \fIitem\fR. Otherwise, returns the current focus item, or \fB{}\fR if there is none. .\" Need: way to clear the focus item. {} works for this... -.TP +.TP \fIpathname \fBheading \fIcolumn\fR ?\fI\-option \fR?\fIvalue \-option value...\fR? Query or modify the heading options for the specified \fIcolumn\fR. Valid options are: @@ -251,13 +251,13 @@ and data columns. Returns the integer index of \fIitem\fR within its parent's list of children. .TP \fIpathname \fBinsert \fIparent index\fR ?\fB\-id \fIid\fR? \fIoptions...\fR -Creates a new item. +Creates a new item. \fIparent\fR is the item ID of the parent item, or the empty string \fB{}\fR to create a new top-level item. \fIindex\fR is an integer, or the value \fBend\fR, specifying where in the list of \fIparent\fR's children to insert the new item. -If \fIindex\fR is less than or equal to zero, +If \fIindex\fR is less than or equal to zero, the new node is inserted at the beginning; if \fIindex\fR is greater than or equal to the current number of children, it is inserted at the end. @@ -276,9 +276,9 @@ Test the widget state; see \fIttk::widget(n)\fR. .TP \fIpathname \fBitem \fIitem\fR ?\fI\-option \fR?\fIvalue \-option value...\fR? Query or modify the options for the specified \fIitem\fR. -If no \fI\-option\fR is specified, +If no \fI\-option\fR is specified, returns a dictionary of option/value pairs. -If a single \fI\-option\fR is specified, +If a single \fI\-option\fR is specified, returns the value of that option. Otherwise, the item's options are updated with the specified values. See \fBITEM OPTIONS\fR for the list of available options. @@ -292,7 +292,7 @@ If \fIindex\fR is less than or equal to zero, \fIitem\fR is moved to the beginning; if greater than or equal to the number of children, it is moved to the end. .RE -.TP +.TP \fIpathname \fBnext \fIitem\fR Returns the identifier of \fIitem\fR's next sibling, or \fB{}\fR if \fIitem\fR is the last child of its parent. @@ -300,7 +300,7 @@ or \fB{}\fR if \fIitem\fR is the last child of its parent. \fIpathname \fBparent \fIitem\fR Returns the ID of the parent of \fIitem\fR, or \fB{}\fR if \fIitem\fR is at the top level of the hierarchy. -.TP +.TP \fIpathname \fBprev \fIitem\fR Returns the identifier of \fIitem\fR's previous sibling, or \fB{}\fR if \fIitem\fR is the first child of its parent. @@ -308,7 +308,7 @@ or \fB{}\fR if \fIitem\fR is the first child of its parent. \fIpathname \fBsee \fIitem\fR Ensure that \fIitem\fR is visible: sets all of \fIitem\fR's ancestors to \fB\-open true\fR, -and scrolls the widget if necessary so that \fIitem\fR is +and scrolls the widget if necessary so that \fIitem\fR is within the visible portion of the tree. .TP \fIpathname \fBselection\fR ?\fIselop itemList\fR? @@ -344,7 +344,7 @@ Modify or query the widget state; see \fIttk::widget(n)\fR. .RS .TP \fIpathName \fBtag bind \fItagName \fR?\fIsequence\fR? ?\fIscript\fR? -Add a Tk binding script for the event sequence \fIsequence\fR +Add a Tk binding script for the event sequence \fIsequence\fR to the tag \fItagName\fR. When an X event is delivered to an item, binding scripts for each of the item's \fB\-tags\fR are evaluated in order as per \fIbindtags(n)\fR. @@ -353,10 +353,10 @@ in order as per \fIbindtags(n)\fR. \fB\fR, \fB\fR, and virtual events are sent to the focus item. \fB\fR, \fB\fR, and \fB\fR events -are sent to the item under the mouse pointer. +are sent to the item under the mouse pointer. No other event types are supported. .PP -The binding \fIscript\fR undergoes \fB%\fR-substitutions before +The binding \fIscript\fR undergoes \fB%\fR-substitutions before evaluation; see \fBbind(n)\fR for details. .RE .TP @@ -364,10 +364,10 @@ evaluation; see \fBbind(n)\fR for details. Query or modify the options for the specified \fItagName\fR. If one or more \fIoption/value\fR pairs are specified, sets the value of those options for the specified tag. -If a single \fIoption\fR is specified, -returns the value of that option +If a single \fIoption\fR is specified, +returns the value of that option (or the empty string if the option has not been specified for \fItagName\fR). -With no additional arguments, +With no additional arguments, returns a dictionary of the option settings for \fItagName\fR. See \fBTAG OPTIONS\fR for the list of available options. .TP @@ -420,7 +420,7 @@ the extra values are ignored. A boolean value indicating whether the item's children should be displayed (\fB\-open true\fR) or hidden (\fB\-open false\fR). .OP \-tags tags Tags -A list of tags associated with this item. +A list of tags associated with this item. .SH "TAG OPTIONS" .PP The following options may be specified on tags: @@ -448,8 +448,8 @@ An integer \fIn\fR, specifying the \fIn\fRth data column. A string of the form \fB#\fIn\fR, where \fIn\fR is an integer, specifying the \fIn\fRth display column. .PP -\fBNOTE:\fR -Item \fB\-values\fR may be displayed in a different order than +\fBNOTE:\fR +Item \fB\-values\fR may be displayed in a different order than the order in which they are stored. .PP \fBNOTE:\fR Column #0 always refers to the tree column, @@ -457,7 +457,7 @@ even if \fB\-show tree\fR is not specified. .PP A \fIdata column number\fR is an index into an item's \fB\-values\fR list; a \fIdisplay column number\fR is the column number in the tree -where the values are displayed. +where the values are displayed. Tree labels are displayed in column #0. If \fB\-displaycolumns\fR is not set, then data column \fIn\fR is displayed in display column \fB#\fIn+1\fR. diff --git a/doc/ttk_vsapi.n b/doc/ttk_vsapi.n index 34145fb..334836c 100644 --- a/doc/ttk_vsapi.n +++ b/doc/ttk_vsapi.n @@ -3,7 +3,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH ttk_vsapi n 8.5 Tk "Tk Themed Widget" .so man.macros .BS @@ -72,7 +72,7 @@ If no \fIstateMap\fR parameter is given there is an implicit default map of {{} 1} .SH "EXAMPLE" .PP -Create a correctly themed close button by changing the layout of +Create a correctly themed close button by changing the layout of a \fBttk::button\fR(n). This uses the WINDOW part WP_SMALLCLOSEBUTTON and as documented the states CBS_DISABLED, CBS_HOT, CBS_NORMAL and CBS_PUSHED are mapped from ttk states. diff --git a/doc/wm.n b/doc/wm.n index c44ab9b..b1a9fea 100644 --- a/doc/wm.n +++ b/doc/wm.n @@ -4,7 +4,7 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" +'\" .TH wm n 8.5 Tk "Tk Built-In Commands" .so man.macros .BS @@ -796,7 +796,7 @@ Gridded geometry management is typically invoked by turning on the \fBsetGrid\fR option for a widget; it can also be invoked with the \fBwm grid\fR command or by calling \fBTk_SetGrid\fR. In each of these approaches the particular widget (or sometimes -code in the application as a whole) specifies the relationship between +code in the application as a whole) specifies the relationship between integral grid sizes for the window and pixel sizes. To return to non-gridded geometry management, invoke \fBwm grid\fR with empty argument strings. -- cgit v0.12 From 8281e14d143f2a712e48508878be90681109d5ea Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 2 Mar 2016 15:25:48 +0000 Subject: Revert part of [032c1ee138449c93dfa885fab07796783945e174|032c1ee138]: Only the patchlevel should have been changed, nothing else. --- unix/configure | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/unix/configure b/unix/configure index 3958a6b..5ffc3fa 100755 --- a/unix/configure +++ b/unix/configure @@ -9598,7 +9598,7 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Intrinsic.h. + # Guess where to find include files, by looking for Xlib.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -9606,7 +9606,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -9633,7 +9633,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Intrinsic.h"; then + if test -r "$ac_dir/X11/Xlib.h"; then ac_x_includes=$ac_dir break fi @@ -9647,18 +9647,18 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lXt $LIBS" + LIBS="-lX11 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XtMalloc (0) +XrmInitialize () ; return 0; } -- cgit v0.12 From 9d05857f2e1878b20cc6aa7cd5c87ed5c55aeea5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 2 Mar 2016 15:52:05 +0000 Subject: Update version in tk.spec --- unix/tk.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tk.spec b/unix/tk.spec index af982f7..e43e28e 100644 --- a/unix/tk.spec +++ b/unix/tk.spec @@ -4,7 +4,7 @@ Name: tk Summary: Tk graphical toolkit for the Tcl scripting language. -Version: 8.6.4 +Version: 8.6.5 Release: 2 License: BSD Group: Development/Languages -- cgit v0.12 -- cgit v0.12 From 3c8ec9fb51362438b77878fdd3bf159444907b6b Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 7 Mar 2016 07:25:34 +0000 Subject: Fixed bug [3137232] - spinbox error after destroying toplevel from widget (cherrypicked [e6d91ca077] --- library/spinbox.tcl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/spinbox.tcl b/library/spinbox.tcl index 02584f4..fecf7d6 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -299,6 +299,10 @@ bind Spinbox { proc ::tk::spinbox::Invoke {w elem} { variable ::tk::Priv + if {![winfo exists $w]} { + return + } + if {![info exists Priv(outsideElement)]} { $w invoke $elem incr Priv(repeated) -- cgit v0.12 From c7d53262ae761b4bffa6be4626431ec3e58bf394 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 7 Mar 2016 20:54:20 +0000 Subject: Fixed bug [2981253] - spinbox button frozen in case of repeated depressions (cherrypicked [5fe2f5839e]) --- library/spinbox.tcl | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/library/spinbox.tcl b/library/spinbox.tcl index fecf7d6..1965ed8 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -86,10 +86,12 @@ bind Spinbox { ::tk::spinbox::Motion %W %x %y } bind Spinbox { + ::tk::spinbox::ArrowPress %W %x %y set tk::Priv(selectMode) word ::tk::spinbox::MouseSelect %W %x sel.first } bind Spinbox { + ::tk::spinbox::ArrowPress %W %x %y set tk::Priv(selectMode) line ::tk::spinbox::MouseSelect %W %x 0 } @@ -332,6 +334,35 @@ proc ::tk::spinbox::ClosestGap {w x} { incr pos } +# ::tk::spinbox::ArrowPress -- +# This procedure is invoked to handle button-1 presses in buttonup +# or buttondown elements of spinbox widgets. +# +# Arguments: +# w - The spinbox window in which the button was pressed. +# x - The x-coordinate of the button press. +# y - The y-coordinate of the button press. + +proc ::tk::spinbox::ArrowPress {w x y} { + variable ::tk::Priv + + if {[$w cget -state] ne "disabled" && \ + [string match "button*" $Priv(element)]} { + $w selection element $Priv(element) + set Priv(repeated) 0 + set Priv(relief) [$w cget -$Priv(element)relief] + catch {after cancel $Priv(afterId)} + set delay [$w cget -repeatdelay] + if {$delay > 0} { + set Priv(afterId) [after $delay \ + [list ::tk::spinbox::Invoke $w $Priv(element)]] + } + if {[info exists Priv(outsideElement)]} { + unset Priv(outsideElement) + } + } +} + # ::tk::spinbox::ButtonDown -- # This procedure is invoked to handle button-1 presses in spinbox # widgets. It moves the insertion cursor, sets the selection anchor, @@ -355,20 +386,7 @@ proc ::tk::spinbox::ButtonDown {w x y} { switch -exact $Priv(element) { "buttonup" - "buttondown" { - if {"disabled" ne [$w cget -state]} { - $w selection element $Priv(element) - set Priv(repeated) 0 - set Priv(relief) [$w cget -$Priv(element)relief] - catch {after cancel $Priv(afterId)} - set delay [$w cget -repeatdelay] - if {$delay > 0} { - set Priv(afterId) [after $delay \ - [list ::tk::spinbox::Invoke $w $Priv(element)]] - } - if {[info exists Priv(outsideElement)]} { - unset Priv(outsideElement) - } - } + ::tk::spinbox::ArrowPress $w $x $y } "entry" { set Priv(selectMode) char -- cgit v0.12 From 1e12a7a6bfefbc1315f92dfb45a245d831328e4e Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 7 Mar 2016 21:01:49 +0000 Subject: Fixed bug [2262543] - Scale widget unexpectedly fires command callback (cherrypicked [3c1a8559dd]) --- generic/tkScale.c | 15 +++++++- tests/scale.test | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 1 deletion(-) diff --git a/generic/tkScale.c b/generic/tkScale.c index cc7c294..cbc5202 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -303,6 +303,12 @@ Tk_ScaleObjCmd( return TCL_ERROR; } + /* + * The widget was just created, no command callback must be invoked. + */ + + scalePtr->flags &= ~INVOKE_COMMAND; + Tcl_SetObjResult(interp, TkNewWindowObj(scalePtr->tkwin)); return TCL_OK; } @@ -1268,7 +1274,14 @@ TkScaleSetValue( return; } scalePtr->value = value; - if (invokeCommand) { + + /* + * Schedule command callback invocation only if there is such a command + * already registered, otherwise the callback would trigger later when + * configuring the widget -command option even if the value did not change. + */ + + if ((invokeCommand) && (scalePtr->command != NULL)) { scalePtr->flags |= INVOKE_COMMAND; } TkEventuallyRedrawScale(scalePtr, REDRAW_SLIDER); diff --git a/tests/scale.test b/tests/scale.test index a8d08a8..8c14ed4 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -1396,6 +1396,114 @@ test scale-19 {Bug [3529885fff] - Click in through goes in wrong direction} \ } \ -result {1.0 1.0 1.0 1.0} +test scale-20.1 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 1} -setup { + catch {destroy .s} + set res {} + set commandedVar -1 +} -body { + scale .s -from 1 -to 50 -command {set commandedVar} + pack .s + update ; # -command callback shall NOT fire + set res [list [.s get] $commandedVar] +} -cleanup { + destroy .s +} -result {1 -1} +test scale-20.2 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 2} -setup { + catch {destroy .s} + set res {} + set commandedVar -1 + set scaleVar 7 +} -body { + scale .s -from 1 -to 50 -variable scaleVar -command {set commandedVar} + pack .s + update ; # -command callback shall NOT fire + set res [list [.s get] $commandedVar] +} -cleanup { + destroy .s +} -result {7 -1} +test scale-20.3 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 3} -setup { + catch {destroy .s} + set res {} + set commandedVar -1 +} -body { + scale .s -from 1 -to 50 + .s set 10 + .s configure -command {set commandedVar} + pack .s + update ; # -command callback shall NOT fire + set res [list [.s get] $commandedVar] +} -cleanup { + destroy .s +} -result {10 -1} +test scale-20.4 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 4} -setup { + catch {destroy .s} + set res {} + set commandedVar -1 +} -body { + scale .s -from 1 -to 50 -command {set commandedVar} + .s set 10 + pack .s + update ; # -command callback shall fire + set res [list [.s get] $commandedVar] +} -cleanup { + destroy .s +} -result {10 10} +test scale-20.5 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 5} -setup { + catch {destroy .s} + set res {} + set commandedVar -1 +} -body { + scale .s -from 1 -to 50 + pack .s + .s set 10 + .s configure -command {set commandedVar} + update ; # -command callback shall NOT fire + set res [list [.s get] $commandedVar] +} -cleanup { + destroy .s +} -result {10 -1} +test scale-20.6 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 6} -setup { + catch {destroy .s} + set res {} + set commandedVar -1 +} -body { + scale .s -from 1 -to 50 + pack .s + .s configure -command {set commandedVar} + .s set 10 + update ; # -command callback shall fire + set res [list [.s get] $commandedVar] +} -cleanup { + destroy .s +} -result {10 10} +test scale-20.7 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 7} -setup { + catch {destroy .s} + set res {} + set commandedVar -1 +} -body { + scale .s -from 1 -to 50 -command {set commandedVar} + pack .s + .s set 10 + update ; # -command callback shall fire + set res [list [.s get] $commandedVar] +} -cleanup { + destroy .s +} -result {10 10} +test scale-20.8 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 8} -setup { + catch {destroy .s} + set res {} + set commandedVar -1 + set scaleVar 7 +} -body { + scale .s -from 1 -to 50 -variable scaleVar -command {set commandedVar} + pack .s + .s set 10 + update ; # -command callback shall fire + set res [list [.s get] $commandedVar] +} -cleanup { + destroy .s +} -result {10 10} + option clear # cleanup -- cgit v0.12 From 23afeb02af6706ac255b77e35f2cc644d2c4e524 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 7 Mar 2016 21:07:31 +0000 Subject: Added test case wm-forget-2 related to test the fix for bug [e9112ef96e] (cherrypicked [a6c6d3bd08]) --- tests/wm.test | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/wm.test b/tests/wm.test index 1aa0779..afcc2cd 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -2276,6 +2276,32 @@ test wm-forget-1.4 "pack into unmapped toplevel causes crash" -body { deleteWindows } -result {} +test wm-forget-2 {bug [e9112ef96e] - [wm forget] doesn't completely} -setup { + catch {destroy .l .f.b .f} + set res {} +} -body { + label .l -text "Top Dot" + frame .f + button .f.b -text Hello -command "puts Hello!" + pack .l -side top + pack .f.b + pack .f -side bottom + update + set res [winfo manager .f] + pack forget .f + update + lappend res [winfo manager .f] + wm manage .f + update + lappend res [winfo manager .f] + wm forget .f + update + lappend res [winfo manager .f] +} -cleanup { + destroy .l .f.b .f + unset res +} -result {pack {} wm {}} + # FIXME: # Test delivery of virtual events to the WM. We could check to see if the -- cgit v0.12 From d4e3294d3a4adb1370d84500401b26f7279119cc Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 8 Mar 2016 21:55:45 +0000 Subject: Backed out anything dealing with stippling, in accordance with discussion about TIP #443 --- doc/text.n | 16 ---------------- generic/tkText.c | 2 -- generic/tkText.h | 5 ----- generic/tkTextDisp.c | 20 ++++---------------- generic/tkTextTag.c | 8 -------- tests/textTag.test | 24 +----------------------- 6 files changed, 5 insertions(+), 70 deletions(-) diff --git a/doc/text.n b/doc/text.n index 84ad710..5d6ac19 100644 --- a/doc/text.n +++ b/doc/text.n @@ -548,22 +548,6 @@ items. It may have any of the forms accepted by \fBTk_GetColor\fR. If string, then the color specified by the \fB\-background\fR tag option is used. .TP -\fB\-selectbgstipple \fIbitmap\fR -. -\fIBitmap\fR specifies a bitmap that is used as a stipple pattern for the -selected background. It may have any of the forms accepted by -\fBTk_GetBitmap\fR. If \fIbitmap\fR has not been specified, or if it is -specified as an empty string, then the bitmap specified by -\fB\-bgstipple\fR will be used for the background. -.TP -\fB\-selectfgstipple \fIbitmap\fR -. -\fIBitmap\fR specifies a bitmap that is used as a stipple pattern when drawing -selected text and other foreground information such as underlines. It may have any of -the forms accepted by \fBTk_GetBitmap\fR. If \fIbitmap\fR has not been -specified, or if it is specified as an empty string, then the bitmap specified by -\fB\-fgstipple\fR will be used. -.TP \fB\-selectforeground \fIcolor\fR \fIColor\fR specifies the foreground color to use when displaying selected items. It may have any of the forms accepted by \fBTk_GetColor\fR. If diff --git a/generic/tkText.c b/generic/tkText.c index 0de648a..88fe19a 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2288,11 +2288,9 @@ ConfigureText( || (textPtr->selTagPtr->selBorder != NULL) || (textPtr->selTagPtr->reliefString != NULL) || (textPtr->selTagPtr->bgStipple != None) - || (textPtr->selTagPtr->selBgStipple != None) || (textPtr->selTagPtr->fgColor != NULL) || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) - || (textPtr->selTagPtr->selFgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) diff --git a/generic/tkText.h b/generic/tkText.h index f37e01a..5d88784 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -371,13 +371,8 @@ typedef struct TkTextTag { * NULL means no value specified here. */ Tk_3DBorder selBorder; /* Used for drawing background for selected text. * NULL means no value specified here. */ - Pixmap selBgStipple; /* Stipple bitmap for background of selected text. - * None means no value specified here. */ XColor *selFgColor; /* Foreground color for selected text. NULL means * no value specified here. */ - Pixmap selFgStipple; /* Stipple bitmap for text and other - * foreground stuff when selected. None means - * no value specified here.*/ char *spacing1String; /* -spacing1 option string (malloc-ed). NULL * means option not specified. */ int spacing1; /* Extra spacing above first display line for diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index d22bcb3..0849307 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -818,15 +818,11 @@ GetStyle( for (i = 0 ; i < numTags; i++) { Tk_3DBorder border; - Pixmap bgStipple; XColor *fgColor; - Pixmap fgStipple; tagPtr = tagPtrs[i]; border = tagPtr->border; - bgStipple = tagPtr->bgStipple; fgColor = tagPtr->fgColor; - fgStipple = tagPtr->fgStipple; /* * If this is the selection tag, and inactiveSelBorder is NULL (the @@ -850,18 +846,10 @@ GetStyle( border = tagPtr->selBorder; } - if ((tagPtr->selBgStipple != None) && (isSelected)) { - bgStipple = tagPtr->selBgStipple; - } - if ((tagPtr->selFgColor != None) && (isSelected)) { fgColor = tagPtr->selFgColor; } - if ((tagPtr->selFgStipple != None) && (isSelected)) { - bgStipple = tagPtr->selFgStipple; - } - if ((border != NULL) && (tagPtr->priority > borderPrio)) { styleValues.border = border; borderPrio = tagPtr->priority; @@ -880,9 +868,9 @@ GetStyle( styleValues.relief = tagPtr->relief; reliefPrio = tagPtr->priority; } - if ((bgStipple != None) + if ((tagPtr->bgStipple != None) && (tagPtr->priority > bgStipplePrio)) { - styleValues.bgStipple = bgStipple; + styleValues.bgStipple = tagPtr->bgStipple; bgStipplePrio = tagPtr->priority; } if ((fgColor != None) && (tagPtr->priority > fgPrio)) { @@ -893,9 +881,9 @@ GetStyle( styleValues.tkfont = tagPtr->tkfont; fontPrio = tagPtr->priority; } - if ((fgStipple != None) + if ((tagPtr->fgStipple != None) && (tagPtr->priority > fgStipplePrio)) { - styleValues.fgStipple = fgStipple; + styleValues.fgStipple = tagPtr->fgStipple; fgStipplePrio = tagPtr->priority; } if ((tagPtr->justifyString != NULL) diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 49d6a50..a212615 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -79,10 +79,6 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_BITMAP, "-selectbgstipple", NULL, NULL, - NULL, -1, Tk_Offset(TkTextTag, selBgStipple), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_BITMAP, "-selectfgstipple", NULL, NULL, - NULL, -1, Tk_Offset(TkTextTag, selFgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, @@ -538,11 +534,9 @@ TkTextTagCmd( || (tagPtr->selBorder != NULL) || (tagPtr->reliefString != NULL) || (tagPtr->bgStipple != None) - || (tagPtr->selBgStipple != None) || (tagPtr->fgColor != NULL) || (tagPtr->selFgColor != NULL) || (tagPtr->fgStipple != None) - || (tagPtr->selFgStipple != None) || (tagPtr->overstrikeString != NULL) || (tagPtr->overstrikeColor != NULL) || (tagPtr->underlineString != NULL) @@ -1055,9 +1049,7 @@ TkTextCreateTag( tagPtr->rMargin = 0; tagPtr->rMarginColor = NULL; tagPtr->selBorder = NULL; - tagPtr->selBgStipple = None; tagPtr->selFgColor = NULL; - tagPtr->selFgStipple = None; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; tagPtr->spacing2String = NULL; diff --git a/tests/textTag.test b/tests/textTag.test index f8d7033..88081d0 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -273,34 +273,12 @@ test textTag-1.25d {configuration options} -body { .t tag configure x -selectbackground [lindex [.t tag configure x -selectbackground] 3] } -returnCodes error -result {unknown color name "non-existent"} test textTag-1.25e {tag configuration options} -body { - .t tag configure x -selectbgstipple gray50 - .t tag cget x -selectbgstipple -} -cleanup { - .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] -} -result {gray50} -test textTag-1.25f {configuration options} -body { - .t tag configure x -selectbgstipple badStipple -} -cleanup { - .t tag configure x -selectbgstipple [lindex [.t tag configure x -selectbgstipple] 3] -} -returnCodes error -result {bitmap "badStipple" not defined} -test textTag-1.25g {tag configuration options} -body { - .t tag configure x -selectfgstipple gray50 - .t tag cget x -selectfgstipple -} -cleanup { - .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] -} -result {gray50} -test textTag-1.25h {configuration options} -body { - .t tag configure x -selectfgstipple badStipple -} -cleanup { - .t tag configure x -selectfgstipple [lindex [.t tag configure x -selectfgstipple] 3] -} -returnCodes error -result {bitmap "badStipple" not defined} -test textTag-1.25i {tag configuration options} -body { .t tag configure x -selectforeground #012345 .t tag cget x -selectforeground } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] } -result {#012345} -test textTag-1.25j {configuration options} -body { +test textTag-1.25f {configuration options} -body { .t tag configure x -selectforeground non-existent } -cleanup { .t tag configure x -selectforeground [lindex [.t tag configure x -selectforeground] 3] -- cgit v0.12 From cabdab6542ae2c49f932009ed1643db724857401 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 9 Mar 2016 14:29:30 +0000 Subject: (cherry-pick) Explicit require Tcl 8.6.0, no matter if Tk is compiled against a later Tcl patchlevel. --- win/makefile.vc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/makefile.vc b/win/makefile.vc index ae43eb6..6f61327 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 $(TCL_PATCH_LEVEL)}]} { return } +if {[catch {package present Tcl 8.6.0}]} { 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] -- cgit v0.12 From d30f4bda39ecf441026e68b7f58eb642c659230f Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 11 Mar 2016 08:24:23 +0000 Subject: Fixed bug [d95e5d8f16] - Hidden panes in panedwindow incorrectly trigger events (cherrypicked [42c8d8441c]) --- generic/tkPanedWindow.c | 8 ++++++-- tests/panedwindow.test | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index 2451647..f350d0a 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -1370,11 +1370,15 @@ PanedWindowEventProc( DestroyPanedWindow(pwPtr); } else if (eventPtr->type == UnmapNotify) { for (i = 0; i < pwPtr->numSlaves; i++) { - Tk_UnmapWindow(pwPtr->slaves[i]->tkwin); + if (!pwPtr->slaves[i]->hide) { + Tk_UnmapWindow(pwPtr->slaves[i]->tkwin); + } } } else if (eventPtr->type == MapNotify) { for (i = 0; i < pwPtr->numSlaves; i++) { - Tk_MapWindow(pwPtr->slaves[i]->tkwin); + if (!pwPtr->slaves[i]->hide) { + Tk_MapWindow(pwPtr->slaves[i]->tkwin); + } } } } diff --git a/tests/panedwindow.test b/tests/panedwindow.test index 666ed9c..ee184ce 100644 --- a/tests/panedwindow.test +++ b/tests/panedwindow.test @@ -4955,6 +4955,38 @@ test panedwindow-23.30 {ConfigurePanes, -hide works} -setup { } -cleanup { deleteWindows } -result {1 1 1 0 39 40 40 1 130 1 0 1 1 40 40 40 42 130} +test panedwindow-23.30a {ConfigurePanes, hidden panes are unmapped} -setup { + deleteWindows +} -body { + panedwindow .p1 -sashrelief raised + panedwindow .p2 -sashrelief raised + label .l1 -text Label1 + label .l2 -text Label2 + label .l3 -text Label3 + .p2 add .l2 -sticky nsew + .p2 add .l3 -sticky nsew + .p1 add .p2 -sticky nsew + .p1 add .l1 -sticky nsew + pack .p1 -side top -expand 1 -fill both + update + set result [list] + lappend result [list [winfo ismapped .p1] [winfo ismapped .p2] \ + [winfo ismapped .l1] [winfo ismapped .l2] [winfo ismapped .l3]] + .p2 paneconfigure .l1 -hide 1 + update + lappend result [list [winfo ismapped .p1] [winfo ismapped .p2] \ + [winfo ismapped .l1] [winfo ismapped .l2] [winfo ismapped .l3]] + .p1 paneconfigure .p2 -hide 1 + update + lappend result [list [winfo ismapped .p1] [winfo ismapped .p2] \ + [winfo ismapped .l1] [winfo ismapped .l2] [winfo ismapped .l3]] + .p1 paneconfigure .p2 -hide 0 + update + lappend result [list [winfo ismapped .p1] [winfo ismapped .p2] \ + [winfo ismapped .l1] [winfo ismapped .l2] [winfo ismapped .l3]] +} -cleanup { + deleteWindows +} -result {{1 1 1 1 1} {1 1 0 1 1} {1 0 0 0 0} {1 1 0 1 1}} test panedwindow-23.31 {ConfigurePanes, -hide works, last pane stretches} -setup { deleteWindows } -body { -- cgit v0.12 From 80c74be24faeeddbe71c2078229afbde8d89e3dc Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 20 Mar 2016 09:56:09 +0000 Subject: Fixed bug [487861ffff] - cascade with -accelerator looks wrong (cherrypicked [282635ad52]) --- win/tkWinMenu.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 4593928..8eede75 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -155,7 +155,7 @@ static void DrawWindowsSystemBitmap(Display *display, Drawable drawable, GC gc, const RECT *rectPtr, int bitmapID, int alignFlags); static void FreeID(WORD commandID); -static char * GetEntryText(TkMenuEntry *mePtr); +static char * GetEntryText(TkMenu *menuPtr, TkMenuEntry *mePtr); static void GetMenuAccelGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *widthPtr, @@ -486,6 +486,7 @@ TkpDestroyMenuEntry( static char * GetEntryText( + TkMenu *menuPtr, /* The menu considered. */ TkMenuEntry *mePtr) /* A pointer to the menu entry. */ { char *itemText; @@ -506,7 +507,7 @@ GetEntryText( int i; const char *label = (mePtr->labelPtr == NULL) ? "" : Tcl_GetString(mePtr->labelPtr); - const char *accel = (mePtr->accelPtr == NULL) ? "" + const char *accel = ((menuPtr->menuType == MENUBAR) || (mePtr->accelPtr == NULL)) ? "" : Tcl_GetString(mePtr->accelPtr); const char *p, *next; Tcl_DString itemString; @@ -605,7 +606,7 @@ ReconfigureWindowsMenu( continue; } - itemText = GetEntryText(mePtr); + itemText = GetEntryText(menuPtr, mePtr); if ((menuPtr->menuType == MENUBAR) || (menuPtr->menuFlags & MENU_SYSTEM_MENU)) { Tcl_WinUtfToTChar(itemText, -1, &translatedText); @@ -1502,12 +1503,12 @@ GetMenuAccelGeometry( *heightPtr = fmPtr->linespace; if (mePtr->type == CASCADE_ENTRY) { *widthPtr = 0; - } else if (mePtr->accelPtr == NULL) { - *widthPtr = 0; - } else { + } else if ((menuPtr->menuType != MENUBAR) && (mePtr->accelPtr != NULL)) { const char *accel = Tcl_GetString(mePtr->accelPtr); *widthPtr = Tk_TextWidth(tkfont, accel, mePtr->accelLength); + } else { + *widthPtr = 0; } } @@ -1763,6 +1764,10 @@ DrawMenuEntryAccelerator( int leftEdge = x + mePtr->indicatorSpace + mePtr->labelWidth; const char *accel; + if (menuPtr->menuType == MENUBAR) { + return; + } + if (mePtr->accelPtr != NULL) { accel = Tcl_GetString(mePtr->accelPtr); } else { -- cgit v0.12 From b8683c2dcc13728de8db64f269aaa5c68abe514f Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Mar 2016 09:59:45 +0000 Subject: Fixed bug [1192095] - Toplevel menus return incorrect active index (cherrypicked [6efe4d5396]) --- win/tkWinMenu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 8eede75..8e14669 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -1288,7 +1288,17 @@ TkWinHandleMenuEvent( if (menuPtr != NULL) { long entryIndex = LOWORD(*pwParam); - mePtr = NULL; + if ((menuPtr->menuType == MENUBAR) && menuPtr->tearoff) { + /* + * Windows passes the entry index starting at 0 for + * the first menu entry. However this entry #0 is the + * tearoff entry for Tk (the menu has -tearoff 1), + * which is ignored for MENUBAR menues on Windows. + */ + + entryIndex++; + } + mePtr = NULL; if (flags != 0xFFFF) { if ((flags&MF_POPUP) && (entryIndexnumEntries)) { mePtr = menuPtr->entries[entryIndex]; -- cgit v0.12 From 04ed959780456503f83b4aa4e4d67c344ad9ded4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Mar 2016 15:00:58 +0000 Subject: Beginning of fix for [18c08df753] - Reverted [296bd4c3], and adjusted textDisp-4.9 accordingly by adding one fixedHeight on the two necessary places in the test result --- generic/tkText.c | 12 +++++++++--- tests/text.test | 3 +-- tests/textDisp.test | 8 ++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 341ec0f..4942913 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -3003,9 +3003,11 @@ DeleteIndexRange( * The code below is ugly, but it's needed to make sure there is always a * dummy empty line at the end of the text. If the final newline of the * file (just before the dummy line) is being deleted, then back up index - * to just before the newline. Furthermore, remove any tags that are - * present on the newline that isn't going to be deleted after all (this - * simulates deleting the newline and then adding a "clean" one back + * to just before the newline. If there is a newline just before the first + * character being deleted, then back up the first index too, so that an + * even number of lines gets deleted. Furthermore, remove any tags that + * are present on the newline that isn't going to be deleted after all + * (this simulates deleting the newline and then adding a "clean" one back * again). Note that index1 and index2 might now be equal again which * means that no text will be deleted but tags might be removed. */ @@ -3020,6 +3022,10 @@ DeleteIndexRange( oldIndex2 = index2; TkTextIndexBackChars(NULL, &oldIndex2, 1, &index2, COUNT_INDICES); line2--; + if ((index1.byteIndex == 0) && (line1 != 0)) { + TkTextIndexBackChars(NULL, &index1, 1, &index1, COUNT_INDICES); + line1--; + } arrayPtr = TkBTreeGetTags(&index2, NULL, &arraySize); if (arrayPtr != NULL) { for (i = 0; i < arraySize; i++) { diff --git a/tests/text.test b/tests/text.test index 7c1731d..2ca5d54 100644 --- a/tests/text.test +++ b/tests/text.test @@ -1272,10 +1272,9 @@ test text-17.8 {DeleteChars procedure} { .t tag add sel 1.0 end .t delete 4.0 end list [.t tag ranges sel] [.t get 1.0 end] -} {{1.0 4.0} {Line 1 +} {{1.0 3.5} {Line 1 abcde 12345 - }} test text-17.9 {DeleteChars procedure} { setup diff --git a/tests/textDisp.test b/tests/textDisp.test index 885c940..bb009ad 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -657,7 +657,7 @@ test textDisp-4.9 {UpdateDisplayInfo, filling in extra vertical space} {textfont update .t delete 15.0 end list [.t bbox 7.0] [.t bbox 12.0] -} [list [list [expr {$hlth + $px + $bw}] [expr {$hlth + $py + $bw + $fixedHeight}] $fixedWidth $fixedHeight] [list [expr {$hlth + $px + $bw}] [expr {$hlth + $py + $bw + 6 * $fixedHeight}] $fixedWidth $fixedHeight]] +} [list [list [expr {$hlth + $px + $bw}] [expr {$hlth + $py + $bw + 2 * $fixedHeight}] $fixedWidth $fixedHeight] [list [expr {$hlth + $px + $bw}] [expr {$hlth + $py + $bw + 7 * $fixedHeight}] $fixedWidth $fixedHeight]] test textDisp-4.10 {UpdateDisplayInfo, filling in extra vertical space} { .t delete 1.0 end .t insert end "1\n2\n3\n4\n5\nLine 6 is such a long line that it wraps around.\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17" @@ -666,7 +666,7 @@ test textDisp-4.10 {UpdateDisplayInfo, filling in extra vertical space} { .t delete 13.0 end update list [.t index @0,0] $tk_textRelayout $tk_textRedraw -} {6.0 {13.0 7.0 6.40 6.20 6.0} {6.0 6.20 6.40 7.0 13.0}} +} {5.0 {12.0 7.0 6.40 6.20 6.0 5.0} {5.0 6.0 6.20 6.40 7.0 12.0}} test textDisp-4.11 {UpdateDisplayInfo, filling in extra vertical space} { .t delete 1.0 end .t insert end "1\n2\n3\n4\n5\nLine 6 is such a long line that it wraps around, not once but really quite a few times.\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17" @@ -675,7 +675,7 @@ test textDisp-4.11 {UpdateDisplayInfo, filling in extra vertical space} { .t delete 14.0 end update list [.t index @0,0] $tk_textRelayout $tk_textRedraw -} {6.60 {14.0 7.0 6.80 6.60} {6.60 6.80 7.0 14.0}} +} {6.40 {13.0 7.0 6.80 6.60 6.40} {6.40 6.60 6.80 7.0 13.0}} test textDisp-4.12 {UpdateDisplayInfo, filling in extra vertical space} { .t delete 1.0 end .t insert end "1\n2\n3\n4\n5\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16" @@ -3697,7 +3697,7 @@ test textDisp-28.1 {"yview" option with bizarre scroll command} { set result [.t2.t index @0,0] update lappend result [.t2.t index @0,0] -} {6.0 2.0} +} {6.0 1.0} test textDisp-29.1 {miscellaneous: lines wrap but are still too long} {textfonts} { catch {destroy .t2} -- cgit v0.12 From 0970af5f4951894b38cb6e9dcc6b64cdb7e4a41a Mon Sep 17 00:00:00 2001 From: dkf Date: Mon, 4 Apr 2016 09:12:17 +0000 Subject: Minor: fix code indentation --- generic/tkImgPNG.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index 2ee515b..c6e3029 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -335,7 +335,7 @@ InitPNGImage( if (Tcl_ZlibStreamInit(NULL, dir, TCL_ZLIB_FORMAT_ZLIB, TCL_ZLIB_COMPRESS_DEFAULT, NULL, &pngPtr->stream) != TCL_OK) { - if (interp) { + if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "zlib initialization failed", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "ZLIB_INIT", NULL); -- cgit v0.12 From 1e91aa73ce7aa59b5950e2a91443fdcdcba6ccaf Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 5 Apr 2016 16:08:33 +0000 Subject: Fixed [fd3a4dc111] - <> event is not always sent to peers --- generic/tkText.c | 5 ++++- tests/text.test | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/generic/tkText.c b/generic/tkText.c index 506075d..e6cb96d 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5215,7 +5215,10 @@ TextEditCmd( */ if ((!oldModified) != (!setModified)) { - GenerateModifiedEvent(textPtr); + for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL; + textPtr = textPtr->next) { + GenerateModifiedEvent(textPtr); + } } break; case EDIT_REDO: diff --git a/tests/text.test b/tests/text.test index ff933a8..03b5ae3 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6321,6 +6321,21 @@ test text-27.14 {<> virtual event - delete before Modified} -body { } -cleanup { destroy .t } -result {thing special} +test text-27.14a {<> virtual event - propagation to peers} -body { +# Bug [fd3a4dc111], <> event is not always sent to peers + set ::retval 0 + text .t -undo 1 + .t peer create .tt + pack .t .tt + bind .t <> {incr ::retval} + bind .tt <> {incr ::retval} + .t insert end "This increments ::retval once for each peer, i.e. twice." + .t edit modified 0 ; # shall increment twice as well, not just once + update idletasks + set ::retval +} -cleanup { + destroy .t .tt +} -result {4} test text-27.15 {<> virtual event} -body { set ::retval no_selection pack [text .t -undo 1] -- cgit v0.12 From ab3f233c1f2acb66be6fd409a52e396acbdf6964 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 5 Apr 2016 20:28:54 +0000 Subject: Implementation of TIP #446 - Introspect Undo/Redo Stack Depths --- generic/tkText.c | 30 ++++++++++++++++++++++--- generic/tkUndo.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- generic/tkUndo.h | 3 ++- 3 files changed, 93 insertions(+), 7 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 506075d..c293557 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2093,7 +2093,7 @@ ConfigureText( textPtr->sharedTextPtr->maxUndo = textPtr->maxUndo; textPtr->sharedTextPtr->autoSeparators = textPtr->autoSeparators; - TkUndoSetDepth(textPtr->sharedTextPtr->undoStack, + TkUndoSetMaxDepth(textPtr->sharedTextPtr->undoStack, textPtr->sharedTextPtr->maxUndo); /* @@ -5165,10 +5165,12 @@ TextEditCmd( { int index, setModified, oldModified; static const char *const editOptionStrings[] = { - "modified", "redo", "reset", "separator", "undo", NULL + "modified", "redo", "redodepth", "reset", "separator", "undo", + "undodepth", NULL }; enum editOptions { - EDIT_MODIFIED, EDIT_REDO, EDIT_RESET, EDIT_SEPARATOR, EDIT_UNDO + EDIT_MODIFIED, EDIT_REDO, EDIT_REDODEPTH, EDIT_RESET, + EDIT_SEPARATOR, EDIT_UNDO, EDIT_UNDODEPTH }; if (objc < 3) { @@ -5229,6 +5231,17 @@ TextEditCmd( return TCL_ERROR; } break; + case EDIT_REDODEPTH: { + int depth; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + depth = TkUndoGetDepth(textPtr->sharedTextPtr->undoStack, 1); + Tcl_SetObjResult(interp, Tcl_NewIntObj(depth)); + break; + } case EDIT_RESET: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); @@ -5254,6 +5267,17 @@ TextEditCmd( return TCL_ERROR; } break; + case EDIT_UNDODEPTH: { + int depth; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + depth = TkUndoGetDepth(textPtr->sharedTextPtr->undoStack, 0); + Tcl_SetObjResult(interp, Tcl_NewIntObj(depth)); + break; + } } return TCL_OK; } diff --git a/generic/tkUndo.c b/generic/tkUndo.c index 8359e0a..3aa3ee2 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -353,7 +353,7 @@ TkUndoInitStack( /* *---------------------------------------------------------------------- * - * TkUndoSetDepth -- + * TkUndoSetMaxDepth -- * * Set the maximum depth of stack. * @@ -368,7 +368,7 @@ TkUndoInitStack( */ void -TkUndoSetDepth( +TkUndoSetMaxDepth( TkUndoRedoStack *stack, /* An Undo/Redo stack */ int maxdepth) /* The maximum stack depth */ { @@ -428,6 +428,67 @@ TkUndoSetDepth( /* *---------------------------------------------------------------------- * + * TkUndoGetDepth + * + * Return the depth of the undo (or redo) stack. + * + * Results: + * An integer representing the number of undoable (or redoable) actions. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkUndoGetDepth( + TkUndoRedoStack *stack, /* An Undo/Redo stack */ + int whichStack) /* 0 means the undo stack, + * otherwise the redo stack */ +{ + int depth = 0; + TkUndoAtom *elem = NULL; + + if (stack != NULL) { + if (whichStack) { + elem = stack->redoStack; + } else { + elem = stack->undoStack; + } + + if (elem != NULL) { + /* + * Skip the first (top) separator if there is one. + */ + + if (elem->type == TK_UNDO_SEPARATOR) { + elem = elem->next; + } + + /* + * The number of compound actions in the stack is then + * the number of separators plus one, except if there is + * a separator at the bottom of the stack. This latter + * case cannot however happen (TkUndoInsertSeparator + * prevents from inserting a separator there). + */ + + while (elem != NULL) { + if (elem->type == TK_UNDO_SEPARATOR) { + depth++; + } + elem = elem->next; + } + depth++; + } + } + return depth; +} + +/* + *---------------------------------------------------------------------- + * * TkUndoClearStacks -- * * Clear both the undo and redo stack. @@ -498,7 +559,7 @@ TkUndoInsertUndoSeparator( { if (TkUndoInsertSeparator(&stack->undoStack)) { stack->depth++; - TkUndoSetDepth(stack, stack->maxdepth); + TkUndoSetMaxDepth(stack, stack->maxdepth); } } diff --git a/generic/tkUndo.h b/generic/tkUndo.h index e63aac4..883f6ee 100644 --- a/generic/tkUndo.h +++ b/generic/tkUndo.h @@ -96,7 +96,8 @@ MODULE_SCOPE void TkUndoClearStack(TkUndoAtom **stack); */ MODULE_SCOPE TkUndoRedoStack *TkUndoInitStack(Tcl_Interp *interp, int maxdepth); -MODULE_SCOPE void TkUndoSetDepth(TkUndoRedoStack *stack, int maxdepth); +MODULE_SCOPE void TkUndoSetMaxDepth(TkUndoRedoStack *stack, int maxdepth); +MODULE_SCOPE int TkUndoGetDepth(TkUndoRedoStack *stack, int whichStack); MODULE_SCOPE void TkUndoClearStacks(TkUndoRedoStack *stack); MODULE_SCOPE void TkUndoFreeStack(TkUndoRedoStack *stack); MODULE_SCOPE void TkUndoInsertUndoSeparator(TkUndoRedoStack *stack); -- cgit v0.12 From f617c83058bb40a68dae5c9834acdda18b534de8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 7 Apr 2016 19:32:29 +0000 Subject: [.t edit undodepth/redodepth] return 0 when -undo false --- generic/tkText.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index c293557..3114835 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5232,13 +5232,15 @@ TextEditCmd( } break; case EDIT_REDODEPTH: { - int depth; + int depth = 0; if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } - depth = TkUndoGetDepth(textPtr->sharedTextPtr->undoStack, 1); + if (textPtr->sharedTextPtr->undo) { + depth = TkUndoGetDepth(textPtr->sharedTextPtr->undoStack, 1); + } Tcl_SetObjResult(interp, Tcl_NewIntObj(depth)); break; } @@ -5268,13 +5270,15 @@ TextEditCmd( } break; case EDIT_UNDODEPTH: { - int depth; + int depth = 0; if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } - depth = TkUndoGetDepth(textPtr->sharedTextPtr->undoStack, 0); + if (textPtr->sharedTextPtr->undo) { + depth = TkUndoGetDepth(textPtr->sharedTextPtr->undoStack, 0); + } Tcl_SetObjResult(interp, Tcl_NewIntObj(depth)); break; } -- cgit v0.12 From b8b29378dcd5a89e371ac9bd1ae4737d08379a46 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 7 Apr 2016 19:50:31 +0000 Subject: Documentation for [.t edit undodepth/redodepth] --- doc/text.n | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/text.n b/doc/text.n index cf516f4..e38b4f1 100644 --- a/doc/text.n +++ b/doc/text.n @@ -1295,6 +1295,12 @@ 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. .TP +\fIpathName \fBedit redodepth\fR +. +Returns the depth of the redo stack (number of redoable actions). When this is +zero there is nothing to redo. When the \fB\-undo\fR option is false zero is +returned. +.TP \fIpathName \fBedit reset\fR . Clears the undo and redo stacks. @@ -1310,6 +1316,12 @@ 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 stack is empty. Does nothing when the \fB\-undo\fR option is false. +.TP +\fIpathName \fBedit undodepth\fR +. +Returns the depth of the undo stack (number of undoable actions). When this is +zero there is nothing to undo. When the \fB\-undo\fR option is false zero is +returned. .RE .TP \fIpathName \fBget\fR ?\fB\-displaychars\fR? ?\fB\-\-\fR? \fIindex1\fR ?\fIindex2 ...\fR? -- cgit v0.12 From 42e24abdab002f3f1a1b9b06419c377461adf612 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 7 Apr 2016 19:54:47 +0000 Subject: Fixed tests numbering --- tests/text.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/text.test b/tests/text.test index ff933a8..a778b79 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6367,7 +6367,7 @@ test text-27.18 {patch 1469210 - inserting after undo} -setup { } -cleanup { destroy .t } -result 1 -test text-25.19 {patch 1669632 (i) - undo after } -setup { +test text-27.19 {patch 1669632 (i) - undo after } -setup { destroy .t } -body { text .t -undo 1 @@ -6381,7 +6381,7 @@ test text-25.19 {patch 1669632 (i) - undo after } -setup { } -cleanup { destroy .t } -result WORLD -test text-25.20 {patch 1669632 (iv) - undo after <>} -setup { +test text-27.20 {patch 1669632 (iv) - undo after <>} -setup { destroy .top .top.t } -body { toplevel .top @@ -6400,7 +6400,7 @@ test text-25.20 {patch 1669632 (iv) - undo after <>} -setup { } -cleanup { destroy .top.t .top } -result HELLO -test text-25.21 {patch 1669632 (vii) - <> shall not remove separators} -setup { +test text-27.21 {patch 1669632 (vii) - <> shall not remove separators} -setup { destroy .t } -body { text .t -undo 1 @@ -6416,7 +6416,7 @@ test text-25.21 {patch 1669632 (vii) - <> shall not remove separators} -se } -cleanup { destroy .t } -result "This WORLD is an example text" -test text-25.22 {patch 1669632 (v) - <> is atomic} -setup { +test text-27.22 {patch 1669632 (v) - <> is atomic} -setup { destroy .t } -body { toplevel .top @@ -6436,7 +6436,7 @@ test text-25.22 {patch 1669632 (v) - <> is atomic} -setup { } -cleanup { destroy .top.t .top } -result "This A an example text" - test text-25.23 {patch 1669632 (v) - <> is atomic} -setup { + test text-27.23 {patch 1669632 (v) - <> is atomic} -setup { destroy .t } -body { toplevel .top -- cgit v0.12 From a49d18f50fd597f7b77eae71f3df70469136f839 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 7 Apr 2016 20:18:24 +0000 Subject: Tests for [.t edit undodepth/redodepth] --- tests/text.test | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/text.test b/tests/text.test index a778b79..da246f9 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6188,7 +6188,7 @@ test text-27.2 {TextEditCmd procedure, argument parsing} -body { .t edit gorp } -cleanup { destroy .t -} -returnCodes {error} -result {bad edit option "gorp": must be modified, redo, reset, separator, or undo} +} -returnCodes {error} -result {bad edit option "gorp": must be modified, redo, redodepth, reset, separator, undo, or undodepth} test text-27.3 {TextEditUndo procedure, undoing changes} -body { text .t -undo 1 pack .t @@ -6456,6 +6456,32 @@ test text-27.22 {patch 1669632 (v) - <> is atomic} -setup { } -cleanup { destroy .top.t .top } -result "This A an example text" +test text-27.24 {TextEditCmd procedure, undo and redo stack depths} -setup { + destroy .t + set res {} +} -body { + text .t -undo false -autoseparators false + lappend res [.t edit undodepth] [.t edit redodepth] + .t configure -undo true + lappend res [.t edit undodepth] [.t edit redodepth] + .t insert end "DO\n" + .t edit separator + .t insert end "IT\n" + .t insert end "YOURSELF\n" + .t edit separator + lappend res [.t edit undodepth] [.t edit redodepth] + .t edit undo + lappend res [.t edit undodepth] [.t edit redodepth] + .t configure -undo false + lappend res [.t edit undodepth] [.t edit redodepth] + .t configure -undo true + lappend res [.t edit undodepth] [.t edit redodepth] + .t edit redo + lappend res [.t edit undodepth] [.t edit redodepth] +} -cleanup { + destroy .t +} -result {0 0 0 0 2 0 1 1 0 0 1 1 2 0} + test text-28.1 {bug fix - 624372, ControlUtfProc long lines} -body { pack [text .t -wrap none] -- cgit v0.12 From 5077869365e6523dddbd6aadb38e58dd32206cad Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 8 Apr 2016 19:01:46 +0000 Subject: Documented the <> virtual event in the event man page --- doc/event.n | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/event.n b/doc/event.n index 12433cb..045339e 100644 --- a/doc/event.n +++ b/doc/event.n @@ -351,6 +351,12 @@ This is sent to a widget when the focus leaves the widget because of a user-driven .QW "tab to widget" action. +.TP +\fB<>\fR +This is sent to a text widget when its internal data become obsolete, +and again when these internal data are back in sync with the widget +view. The detail field (%d substitution) is either true (when the +widget is in sync) or false (when it is not). .PP Tk defines the following virtual events for the purposes of unifying bindings across multiple platforms. Users expect them to behave in the -- cgit v0.12 From fa289415c7aaacc173ab97665af201a54eae611a Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 8 Apr 2016 19:04:09 +0000 Subject: Fixed typo in [text] man page --- doc/text.n | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/text.n b/doc/text.n index cf516f4..9ec8f74 100644 --- a/doc/text.n +++ b/doc/text.n @@ -980,7 +980,7 @@ geometry manager), one can resort to \fIpathName \fBsync\fR and \fIpathName \fBpendingsync\fR to control the synchronization of the view of text widgets. .PP The \fB<>\fR virtual event fires when the line heights of the -text widget becomes obsolete (due to some editing command or configuration +text widget become obsolete (due to some editing command or configuration change), and again when the internal data of the text widget are back in sync with the widget view. The detail field (%d substitution) is either true (when the widget is in sync) or false (when it is not). -- cgit v0.12 From 00604f72c60af9ed0748c955048a446f7e5f7b9c Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 21 Apr 2016 22:03:01 +0000 Subject: Fixed [b362182e45] - Generation of virtual events through Tk_HandleEvent is unsafe --- generic/tkInt.h | 2 +- generic/tkListbox.c | 11 +---------- generic/tkText.c | 26 ++------------------------ generic/tkTextDisp.c | 17 ++++------------- generic/tkUtil.c | 9 +++++++-- macosx/tkMacOSXDialog.c | 8 ++++---- tests/listbox.test | 1 + tests/text.test | 6 +++++- win/tkWinDialog.c | 8 ++++---- 9 files changed, 29 insertions(+), 59 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index b644c5b..029f0f1 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1208,7 +1208,7 @@ MODULE_SCOPE void TkpCreateBusy(Tk_FakeWin *winPtr, Tk_Window tkRef, MODULE_SCOPE int TkBackgroundEvalObjv(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv, int flags); MODULE_SCOPE void TkSendVirtualEvent(Tk_Window tgtWin, - const char *eventName); + const char *eventName, Tcl_Obj *detail); MODULE_SCOPE Tcl_Command TkMakeEnsemble(Tcl_Interp *interp, const char *nsname, const char *name, ClientData clientData, const TkEnsemble *map); diff --git a/generic/tkListbox.c b/generic/tkListbox.c index c7effdd..b059727 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -3223,16 +3223,7 @@ static void GenerateListboxSelectEvent( Listbox *listPtr) /* Information about widget. */ { - union {XEvent general; XVirtualEvent virtual;} event; - - memset(&event, 0, sizeof(event)); - event.general.xany.type = VirtualEvent; - event.general.xany.serial = NextRequest(Tk_Display(listPtr->tkwin)); - event.general.xany.send_event = False; - event.general.xany.window = Tk_WindowId(listPtr->tkwin); - event.general.xany.display = Tk_Display(listPtr->tkwin); - event.virtual.name = Tk_GetUid("ListboxSelect"); - Tk_HandleEvent(&event.general); + TkSendVirtualEvent(listPtr->tkwin, "ListboxSelect", NULL); } /* diff --git a/generic/tkText.c b/generic/tkText.c index 506075d..b17a425 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -3554,16 +3554,7 @@ TkTextSelectionEvent( * event generate $textWidget <> */ - union {XEvent general; XVirtualEvent virtual;} event; - - memset(&event, 0, sizeof(event)); - event.general.xany.type = VirtualEvent; - event.general.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); - event.general.xany.send_event = False; - event.general.xany.window = Tk_WindowId(textPtr->tkwin); - event.general.xany.display = Tk_Display(textPtr->tkwin); - event.virtual.name = Tk_GetUid("Selection"); - Tk_HandleEvent(&event.general); + TkSendVirtualEvent(textPtr->tkwin, "Selection", NULL); } /* @@ -5361,21 +5352,8 @@ static void GenerateModifiedEvent( TkText *textPtr) /* Information about text widget. */ { - union { - XEvent general; - XVirtualEvent virtual; - } event; - Tk_MakeWindowExist(textPtr->tkwin); - - memset(&event, 0, sizeof(event)); - event.general.xany.type = VirtualEvent; - event.general.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); - event.general.xany.send_event = False; - event.general.xany.window = Tk_WindowId(textPtr->tkwin); - event.general.xany.display = Tk_Display(textPtr->tkwin); - event.virtual.name = Tk_GetUid("Modified"); - Tk_HandleEvent(&event.general); + TkSendVirtualEvent(textPtr->tkwin, "Modified", NULL); } /* diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 0849307..81bce94 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3104,7 +3104,7 @@ AsyncUpdateLineMetrics( * Send the <> event related to the text widget * line metrics asynchronous update. * This is equivalent to: - * event generate $textWidget <> -detail $s + * event generate $textWidget <> -data $s * where $s is the sync status: true (when the widget view is in * sync with its internal data) or false (when it is not). * @@ -3120,19 +3120,10 @@ AsyncUpdateLineMetrics( static void GenerateWidgetViewSyncEvent( TkText *textPtr, /* Information about text widget. */ - Bool InSync) /* True if in sync, false otherwise */ + Bool InSync) /* true if in sync, false otherwise */ { - union {XEvent general; XVirtualEvent virtual;} event; - - memset(&event, 0, sizeof(event)); - event.general.xany.type = VirtualEvent; - event.general.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); - event.general.xany.send_event = False; - event.general.xany.window = Tk_WindowId(textPtr->tkwin); - event.general.xany.display = Tk_Display(textPtr->tkwin); - event.virtual.name = Tk_GetUid("WidgetViewSync"); - event.virtual.user_data = Tcl_NewBooleanObj(InSync); - Tk_HandleEvent(&event.general); + TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", + Tcl_NewBooleanObj(InSync)); } /* diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 7ff9ecb..6563165 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -1162,7 +1162,8 @@ TkMakeEnsemble( * TkSendVirtualEvent -- * * Send a virtual event notification to the specified target window. - * Equivalent to "event generate $target <<$eventName>>" + * Equivalent to: + * "event generate $target <<$eventName>> -data $detail" * * Note that we use Tk_QueueWindowEvent, not Tk_HandleEvent, so this * routine does not reenter the interpreter. @@ -1173,7 +1174,8 @@ TkMakeEnsemble( void TkSendVirtualEvent( Tk_Window target, - const char *eventName) + const char *eventName, + Tcl_Obj *detail) { union {XEvent general; XVirtualEvent virtual;} event; @@ -1184,6 +1186,9 @@ TkSendVirtualEvent( event.general.xany.window = Tk_WindowId(target); event.general.xany.display = Tk_Display(target); event.virtual.name = Tk_GetUid(eventName); + if (detail != NULL) { + event.virtual.user_data = detail; + } Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); } diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index f6edb6d..80a7a11 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1320,7 +1320,7 @@ FontchooserEvent( switch (kind) { case FontchooserClosed: if (fcdPtr->parent != None) { - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility"); + TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); fontchooserInterp = NULL; } break; @@ -1343,7 +1343,7 @@ FontchooserEvent( ckfree(tmpv); } } - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged"); + TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); } break; } @@ -1553,7 +1553,7 @@ FontchooserConfigureCmd( [fm setSelectedAttributes:fontPanelFontAttributes isMultiple:NO]; if ([fp isVisible]) { - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged"); + TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); } break; case FontchooserCmd: @@ -1616,7 +1616,7 @@ FontchooserShowCmd( } if (![fp isVisible]) { [fm orderFrontFontPanel:NSApp]; - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility"); + TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); } fontchooserInterp = interp; diff --git a/tests/listbox.test b/tests/listbox.test index 76a4349..407420c 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -3170,6 +3170,7 @@ test listbox-31.2 {<> event on lost selection} -setup { focus -force .l event generate .l <1> -x 5 -y 5 ; # <> fires selection clear ; # <> fires again + update set res } -cleanup { destroy .l diff --git a/tests/text.test b/tests/text.test index a778b79..a500daf 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6280,7 +6280,7 @@ test text-27.11 {TextEditCmd procedure, set modified flag repeat} -setup { # Shouldn't require [update idle] to trigger event [Bug 1809538] lappend ::retval [.t edit modified] .t edit modified 1 - update idletasks + update lappend ::retval [.t edit modified] .t edit modified 1 ; # binding should only fire once [Bug 1799782] update idletasks @@ -6295,6 +6295,7 @@ test text-27.12 {<> virtual event} -body { bind .t <> "set ::retval modified" update idletasks .t insert end "nothing special\n" + update return $::retval } -cleanup { destroy .t @@ -6305,6 +6306,7 @@ test text-27.13 {<> virtual event - insert before Modified} -body { bind .t <> { set ::retval [.t get 1.0 end-1c] } update idletasks .t insert end "nothing special" + update return $::retval } -cleanup { destroy .t @@ -6317,6 +6319,7 @@ test text-27.14 {<> virtual event - delete before Modified} -body { .t insert end "nothing special" .t edit modified 0 .t delete 1.0 1.2 + update set ::retval } -cleanup { destroy .t @@ -6328,6 +6331,7 @@ test text-27.15 {<> virtual event} -body { update idletasks .t insert end "nothing special\n" .t tag add sel 1.0 1.1 + update set ::retval } -cleanup { destroy .t diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index d7f63fb..d58bd52 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -3145,13 +3145,13 @@ HookProc( if (IsWindow(hwndCtrl)) { EnableWindow(hwndCtrl, FALSE); } - TkSendVirtualEvent(phd->parent, "TkFontchooserVisibility"); + TkSendVirtualEvent(phd->parent, "TkFontchooserVisibility", NULL); return 1; /* we handled the message */ } if (WM_DESTROY == msg) { phd->hwnd = NULL; - TkSendVirtualEvent(phd->parent, "TkFontchooserVisibility"); + TkSendVirtualEvent(phd->parent, "TkFontchooserVisibility", NULL); return 0; } @@ -3169,7 +3169,7 @@ HookProc( ApplyLogfont(phd->interp, phd->cmdObj, hdc, &lf); } if (phd && phd->parent) { - TkSendVirtualEvent(phd->parent, "TkFontchooserFontChanged"); + TkSendVirtualEvent(phd->parent, "TkFontchooserFontChanged", NULL); } return 1; } @@ -3481,7 +3481,7 @@ FontchooserShowCmd( ApplyLogfont(hdPtr->interp, hdPtr->cmdObj, hdc, &lf); } if (hdPtr->parent) { - TkSendVirtualEvent(hdPtr->parent, "TkFontchooserFontChanged"); + TkSendVirtualEvent(hdPtr->parent, "TkFontchooserFontChanged", NULL); } } Tcl_SetServiceMode(oldMode); -- cgit v0.12 From d9629dd3f036632bf29ca7792d85a0fd346e8cb9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 22 Apr 2016 20:15:13 +0000 Subject: Added test text-11a.51 to check the fix of [b362182e45] --- tests/text.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/text.test b/tests/text.test index a500daf..4b27c76 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3053,6 +3053,25 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { destroy .top.yt .top } -result {Sync:0 Pending:1 Sync:1 Pending:0} +test text-11a.51 {<> calls TkSendVirtualEvent(), + NOT Tk_HandleEvent(). + Bug [b362182e45704dd7bbd6aed91e48122035ea3d16]} -setup { + destroy .top.t .top +} -body { + set res {} + toplevel .top + pack [text .top.t] + for {set i 1} {$i < 10000} {incr i} { + .top.t insert end "Hello world!\n" + } + bind .top.t <> {destroy .top.t} + .top.t tag add mytag 1.5 8000.8 ; # shall not crash + update + set res "Still doing fine!" +} -cleanup { + destroy .top.t .top +} -result {Still doing fine!} + test text-12.1 {TextWidgetCmd procedure, "index" option} -setup { text .t } -body { -- cgit v0.12 From fe445933c38a59e269197da7ad01187157358ab4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 29 Apr 2016 19:07:53 +0000 Subject: Fixed [011706ec42] - tk::ButtonInvoke safety bug --- library/button.tcl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/button.tcl b/library/button.tcl index b2bafb2..061069a 100644 --- a/library/button.tcl +++ b/library/button.tcl @@ -597,14 +597,16 @@ proc ::tk::ButtonUp w { # w - The name of the widget. proc ::tk::ButtonInvoke w { - if {[$w cget -state] ne "disabled"} { + if {[winfo exists $w] && [$w cget -state] ne "disabled"} { set oldRelief [$w cget -relief] set oldState [$w cget -state] $w configure -state active -relief sunken update idletasks after 100 - $w configure -state $oldState -relief $oldRelief - uplevel #0 [list $w invoke] + if {[winfo exists $w]} { + $w configure -state $oldState -relief $oldRelief + uplevel #0 [list $w invoke] + } } } -- cgit v0.12 From dd7c680bf0627dc809b4b205ad1258100deaa466 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 29 Apr 2016 19:23:56 +0000 Subject: Fixed indentation --- library/button.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/button.tcl b/library/button.tcl index 061069a..16624e7 100644 --- a/library/button.tcl +++ b/library/button.tcl @@ -604,8 +604,8 @@ proc ::tk::ButtonInvoke w { update idletasks after 100 if {[winfo exists $w]} { - $w configure -state $oldState -relief $oldRelief - uplevel #0 [list $w invoke] + $w configure -state $oldState -relief $oldRelief + uplevel #0 [list $w invoke] } } } -- cgit v0.12 From acdaf387562f63cecd2e448c4790aa5e02bd89a9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 30 Apr 2016 15:50:35 +0000 Subject: Experiment: can it be done without a busy wait as well? Not tested on all platforms yet, feedback appreciated! --- library/button.tcl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/library/button.tcl b/library/button.tcl index 16624e7..469a9a8 100644 --- a/library/button.tcl +++ b/library/button.tcl @@ -589,6 +589,20 @@ proc ::tk::ButtonUp w { # Shared routines ################## +# ::tk::ButtonInvokeEnd -- +# The procedure below is called after a button is invoked through +# the keyboard. It simulate a release of the button via the mouse. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonInvokeEnd {w oldState oldRelief} { + if {[winfo exists $w]} { + $w configure -state $oldState -relief $oldRelief + uplevel #0 [list $w invoke] + } +} + # ::tk::ButtonInvoke -- # The procedure below is called when a button is invoked through # the keyboard. It simulate a press of the button via the mouse. @@ -601,12 +615,7 @@ proc ::tk::ButtonInvoke w { set oldRelief [$w cget -relief] set oldState [$w cget -state] $w configure -state active -relief sunken - update idletasks - after 100 - if {[winfo exists $w]} { - $w configure -state $oldState -relief $oldRelief - uplevel #0 [list $w invoke] - } + after 100 [list ::tk::ButtonInvokeEnd $w $oldState $oldRelief] } } -- cgit v0.12 From b1abab58282cc8ff89e73762114369e7a11ce07f Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 2 May 2016 20:16:20 +0000 Subject: Fixed Americano-British English (American English selected) --- tests/button.test | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/button.test b/tests/button.test index 984fd43..6d924f6 100644 --- a/tests/button.test +++ b/tests/button.test @@ -3750,7 +3750,7 @@ test button-12.1 {button widget vs hidden commands} -body { destroy .b } -result {1} -test button-13.1 {size behaviouor: label} -setup { +test button-13.1 {size behavior: label} -setup { label .a -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} label .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} label .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} @@ -3769,7 +3769,7 @@ test button-13.1 {size behaviouor: label} -setup { } -cleanup { destroy .a .b .c } -result {1 1 1} -test button-13.2 {size behaviouor: label} -setup { +test button-13.2 {size behavior: label} -setup { label .a -borderwidth 2 -highlightthickness 2 -font {Arial 20} label .b -borderwidth 2 -highlightthickness 2 -font {Arial 20} label .c -borderwidth 2 -highlightthickness 2 -font {Arial 20} @@ -3789,7 +3789,7 @@ test button-13.2 {size behaviouor: label} -setup { destroy .a .b .c } -result {1 1 1} -test button-13.3 {size behaviouor: button} -setup { +test button-13.3 {size behavior: button} -setup { button .a -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} button .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} @@ -3808,7 +3808,7 @@ test button-13.3 {size behaviouor: button} -setup { } -cleanup { destroy .a .b .c } -result {1 1 1} -test button-13.4 {size behaviouor: button} -setup { +test button-13.4 {size behavior: button} -setup { button .a -borderwidth 2 -highlightthickness 2 -font {Arial 20} button .b -borderwidth 2 -highlightthickness 2 -font {Arial 20} button .c -borderwidth 2 -highlightthickness 2 -font {Arial 20} @@ -3828,7 +3828,7 @@ test button-13.4 {size behaviouor: button} -setup { destroy .a .b .c } -result {1 1 1} -test button-13.5 {size behaviouor: radiobutton} -setup { +test button-13.5 {size behavior: radiobutton} -setup { radiobutton .a -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} radiobutton .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} radiobutton .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} @@ -3848,7 +3848,7 @@ test button-13.5 {size behaviouor: radiobutton} -setup { destroy .a .b .c } -result {1 1 1} -test button-13.6 {size behaviouor: radiobutton} -setup { +test button-13.6 {size behavior: radiobutton} -setup { radiobutton .a -borderwidth 2 -highlightthickness 2 -font {Arial 20} radiobutton .b -borderwidth 2 -highlightthickness 2 -font {Arial 20} radiobutton .c -borderwidth 2 -highlightthickness 2 -font {Arial 20} @@ -3868,7 +3868,7 @@ test button-13.6 {size behaviouor: radiobutton} -setup { destroy .a .b .c } -result {1 1 1} -test button-13.7 {size behaviouor: checkbutton} -setup { +test button-13.7 {size behavior: checkbutton} -setup { checkbutton .a -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} checkbutton .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} checkbutton .c -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} @@ -3888,7 +3888,7 @@ test button-13.7 {size behaviouor: checkbutton} -setup { destroy .a .b .c } -result {1 1 1} -test button-13.8 {size behaviouor: checkbutton} -setup { +test button-13.8 {size behavior: checkbutton} -setup { checkbutton .a -borderwidth 2 -highlightthickness 2 -font {Arial 20} checkbutton .b -borderwidth 2 -highlightthickness 2 -font {Arial 20} checkbutton .c -borderwidth 2 -highlightthickness 2 -font {Arial 20} -- cgit v0.12 From 9685eae702c2d72291bb0b47e5ec481b9afa3a80 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 2 May 2016 20:45:41 +0000 Subject: Added test button-14.1 to guard against regressions regarding [011706ec42] --- tests/button.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/button.test b/tests/button.test index 6d924f6..05f463c 100644 --- a/tests/button.test +++ b/tests/button.test @@ -3908,6 +3908,25 @@ test button-13.8 {size behavior: checkbutton} -setup { destroy .a .b .c } -result {1 1 1} +test button-14.1 {bug fix: [011706ec42] tk::ButtonInvoke unsafe wrt widget destruction} -body { + proc destroy_button {} { + if {[winfo exists .top.b]} { + destroy .top.b + puts destroyed + } + } + toplevel .top + button .top.b -text Foo -command destroy_button + bind .top.b destroy_button + pack .top.b + focus -force .top.b + update + event generate .top.b + update ; # shall not trigger error invalid command name ".top.b" +} -cleanup { + destroy .top.b .top +} -result {} + imageFinish cleanupTests return -- cgit v0.12 From 7c0c67cd90b2ba56e2758e4859676b35a7c56025 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 10 May 2016 19:09:58 +0000 Subject: Fixed [545f10fcf3] - Poor Xft coloured font performance on X11. Thanks to James Bonfield for the bug report, to Rob Davies for the patch, and to Brian Griffin for the testing --- unix/tkUnixRFont.c | 150 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 106 insertions(+), 44 deletions(-) diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index ab2ed4a..36e5462 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -14,6 +14,8 @@ #include #include +#define MAX_CACHED_COLORS 16 + typedef struct { XftFont *ftFont; XftFont *ft0Font; @@ -23,6 +25,11 @@ typedef struct { } UnixFtFace; typedef struct { + XftColor color; + int next; +} UnixFtColorList; + +typedef struct { TkFont font; /* Stuff used by generic font package. Must be * first in structure. */ UnixFtFace *faces; @@ -33,7 +40,9 @@ typedef struct { Display *display; int screen; XftDraw *ftDraw; - XftColor color; + int ncolors; + int firstColor; + UnixFtColorList colors[MAX_CACHED_COLORS]; } UnixFtFont; /* @@ -289,11 +298,8 @@ InitFont( fontPtr->display = Tk_Display(tkwin); fontPtr->screen = Tk_ScreenNumber(tkwin); fontPtr->ftDraw = 0; - fontPtr->color.color.red = 0; - fontPtr->color.color.green = 0; - fontPtr->color.color.blue = 0; - fontPtr->color.color.alpha = 0xffff; - fontPtr->color.pixel = 0xffffffff; + fontPtr->ncolors = 0; + fontPtr->firstColor = -1; /* * Fill in platform-specific fields of TkFont. @@ -737,6 +743,89 @@ TkpMeasureCharsInContext( maxLength, flags, lengthPtr); } +/* + *---------------------------------------------------------------------- + * + * LookUpColor -- + * + * Convert a pixel value to an XftColor. This can be slow due to the + * need to call XQueryColor, which involves a server round-trip. To + * avoid that, a least-recently-used cache of up to MAX_CACHED_COLORS + * is kept, in the form of a linked list. The returned color is moved + * to the front of the list, so repeatedly asking for the same one + * should be fast. + * + * Results: + * A pointer to the XftColor structure for the requested color is + * returned. + * + * Side effects: + * The converted color is stored in a cache in the UnixFtFont structure. The cache + * can hold at most MAX_CACHED_COLORS colors. If no more slots are available, the least + * recently used color is replaced with the new one. + *---------------------------------------------------------------------- + */ + +static XftColor * +LookUpColor(Display *display, /* Display to lookup colors on */ + UnixFtFont *fontPtr, /* Font to search for cached colors */ + unsigned long pixel) /* Pixel value to translate to XftColor */ +{ + int i, last = -1, last2 = -1; + XColor xcolor; + + for (i = fontPtr->firstColor; + i >= 0; last2 = last, last = i, i = fontPtr->colors[i].next) { + + if (pixel == fontPtr->colors[i].color.pixel) { + /* + * Color found in cache. Move it to the front of the list and return it. + */ + if (last >= 0) { + fontPtr->colors[last].next = fontPtr->colors[i].next; + fontPtr->colors[i].next = fontPtr->firstColor; + fontPtr->firstColor = i; + } + + return &fontPtr->colors[i].color; + } + } + + /* + * Color wasn't found, so it needs to be added to the cache. + * If a spare slot is available, it can be put there. If not, last + * will now point to the least recently used color, so replace that one. + */ + + if (fontPtr->ncolors < MAX_CACHED_COLORS) { + last2 = -1; + last = fontPtr->ncolors++; + } + + /* + * Translate the pixel value to a color. Needs a server round-trip. + */ + xcolor.pixel = pixel; + XQueryColor(display, DefaultColormap(display, fontPtr->screen), &xcolor); + + fontPtr->colors[last].color.color.red = xcolor.red; + fontPtr->colors[last].color.color.green = xcolor.green; + fontPtr->colors[last].color.color.blue = xcolor.blue; + fontPtr->colors[last].color.color.alpha = 0xffff; + fontPtr->colors[last].color.pixel = pixel; + + /* + * Put at the front of the list. + */ + if (last2 >= 0) { + fontPtr->colors[last2].next = fontPtr->colors[last].next; + } + fontPtr->colors[last].next = fontPtr->firstColor; + fontPtr->firstColor = last; + + return &fontPtr->colors[last].color; +} + #define NUM_SPEC 1024 void @@ -760,7 +849,7 @@ Tk_DrawChars( const int maxCoord = 0x7FFF;/* Xft coordinates are 16 bit values */ UnixFtFont *fontPtr = (UnixFtFont *) tkfont; XGCValues values; - XColor xcolor; + XftColor *xftcolor; int clen, nspec, xStart = x; XftGlyphFontSpec specs[NUM_SPEC]; XGlyphInfo metrics; @@ -782,16 +871,7 @@ Tk_DrawChars( Tk_DeleteErrorHandler(handler); } XGetGCValues(display, gc, GCForeground, &values); - if (values.foreground != fontPtr->color.pixel) { - xcolor.pixel = values.foreground; - XQueryColor(display, DefaultColormap(display, fontPtr->screen), - &xcolor); - fontPtr->color.color.red = xcolor.red; - fontPtr->color.color.green = xcolor.green; - fontPtr->color.color.blue = xcolor.blue; - fontPtr->color.color.alpha = 0xffff; - fontPtr->color.pixel = values.foreground; - } + xftcolor = LookUpColor(display, fontPtr, values.foreground); if (tsdPtr->clipRegion != None) { XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion); } @@ -823,14 +903,14 @@ Tk_DrawChars( y += metrics.yOff; nspec++; if (nspec == NUM_SPEC) { - XftDrawGlyphFontSpec(fontPtr->ftDraw, &fontPtr->color, + XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor, specs, nspec); nspec = 0; } } } if (nspec) { - XftDrawGlyphFontSpec(fontPtr->ftDraw, &fontPtr->color, specs, nspec); + XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor, specs, nspec); } doUnderlineStrikeout: @@ -892,7 +972,7 @@ TkDrawAngledChars( const int minCoord = -1000; /* Should be good enough... */ UnixFtFont *fontPtr = (UnixFtFont *) tkfont; XGCValues values; - XColor xcolor; + XftColor *xftcolor; int xStart = x, yStart = y; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -919,16 +999,7 @@ TkDrawAngledChars( } XGetGCValues(display, gc, GCForeground, &values); - if (values.foreground != fontPtr->color.pixel) { - xcolor.pixel = values.foreground; - XQueryColor(display, DefaultColormap(display, fontPtr->screen), - &xcolor); - fontPtr->color.color.red = xcolor.red; - fontPtr->color.color.green = xcolor.green; - fontPtr->color.color.blue = xcolor.blue; - fontPtr->color.color.alpha = 0xffff; - fontPtr->color.pixel = values.foreground; - } + xftcolor = LookUpColor(display, fontPtr, values.foreground); if (tsdPtr->clipRegion != None) { XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion); } @@ -967,7 +1038,7 @@ TkDrawAngledChars( * this information... but we'll be ready when it does! */ - XftDrawGlyphs(fontPtr->ftDraw, &fontPtr->color, currentFtFont, + XftDrawGlyphs(fontPtr->ftDraw, xftcolor, currentFtFont, originX, originY, glyphs, nglyph); } originX = ROUND16(x); @@ -984,7 +1055,7 @@ TkDrawAngledChars( glyphs[nglyph++] = XftCharIndex(fontPtr->display, ftFont, c); } if (nglyph) { - XftDrawGlyphs(fontPtr->ftDraw, &fontPtr->color, currentFtFont, + XftDrawGlyphs(fontPtr->ftDraw, xftcolor, currentFtFont, originX, originY, glyphs, nglyph); } #else /* !XFT_HAS_FIXED_ROTATED_PLACEMENT */ @@ -1008,16 +1079,7 @@ TkDrawAngledChars( Tk_DeleteErrorHandler(handler); } XGetGCValues(display, gc, GCForeground, &values); - if (values.foreground != fontPtr->color.pixel) { - xcolor.pixel = values.foreground; - XQueryColor(display, DefaultColormap(display, fontPtr->screen), - &xcolor); - fontPtr->color.color.red = xcolor.red; - fontPtr->color.color.green = xcolor.green; - fontPtr->color.color.blue = xcolor.blue; - fontPtr->color.color.alpha = 0xffff; - fontPtr->color.pixel = values.foreground; - } + xftcolor = LookUpColor(display, fontPtr, values.foreground); if (tsdPtr->clipRegion != None) { XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion); } @@ -1051,14 +1113,14 @@ TkDrawAngledChars( y += metrics.yOff*cosA - metrics.xOff*sinA; nspec++; if (nspec == NUM_SPEC) { - XftDrawGlyphFontSpec(fontPtr->ftDraw, &fontPtr->color, + XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor, specs, nspec); nspec = 0; } } } if (nspec) { - XftDrawGlyphFontSpec(fontPtr->ftDraw, &fontPtr->color, specs, nspec); + XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor, specs, nspec); } #endif /* XFT_HAS_FIXED_ROTATED_PLACEMENT */ -- cgit v0.12 From fbfb7ab3f964d449a7dd80957998c23fe8c49117 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 12 May 2016 09:46:57 +0000 Subject: (cherry-pick): Bug [64261b50]. Spurious mouse events sent to underlying window when file dialog is closed. --- win/tkWinDialog.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index d58bd52..a7d8c7d 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -674,19 +674,25 @@ static void LoadShellProcs() * processing functions are used to cope with keyboard navigation of * controls.) * - * Here is one solution. After returning, we poll the message queue for - * 1/4s looking for WM_LBUTTON up messages. If we see one it's consumed. - * If we get a WM_LBUTTONDOWN message, then we exit early, since the user - * must be doing something new. This fix only works for the current - * application, so the problem will still occur if the open dialog - * happens to be over another applications button. However this is a - * fairly rare occurrance. + * Here is one solution. After returning, we flush all mouse events + * for 1/4 second. In 8.6.5 and earlier, the code used to + * poll the message queue consuming WM_LBUTTONUP messages. + * On seeing a WM_LBUTTONDOWN message, it would exit early, since the user + * must be doing something new. However this early exit does not work + * on Vista and later because the Windows sends both BUTTONDOWN and + * BUTTONUP after the DBLCLICK instead of just BUTTONUP as on XP. + * Rather than try and figure out version specific sequences, we + * ignore all mouse events in that interval. + * + * This fix only works for the current application, so the problem will + * still occur if the open dialog happens to be over another applications + * button. However this is a fairly rare occurrance. * * Results: * None. * * Side effects: - * Consumes an unwanted BUTTON messages. + * Consumes unwanted mouse related messages. * *------------------------------------------------------------------------- */ @@ -698,10 +704,7 @@ EatSpuriousMessageBugFix(void) DWORD nTime = GetTickCount() + 250; while (GetTickCount() < nTime) { - if (PeekMessageA(&msg, 0, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_NOREMOVE)){ - break; - } - PeekMessageA(&msg, 0, WM_LBUTTONUP, WM_LBUTTONUP, PM_REMOVE); + PeekMessage(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE); } } @@ -1113,7 +1116,7 @@ ParseOFNOptions( if (strcmp(Tcl_GetString(objv[i]), "-xpstyle")) goto error_return; if (i + 1 == objc) { - Tcl_SetResult(interp, "value for \"-xpstyle\" missing", TCL_STATIC); + Tcl_SetObjResult(interp, Tcl_NewStringObj("value for \"-xpstyle\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); goto error_return; } @@ -1281,9 +1284,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, int oldMode; if (tsdPtr->newFileDialogsState != FDLG_STATE_USE_NEW) { - /* XXX - should be an assert but Tcl does not seem to have one? */ - Tcl_SetResult(interp, "Internal error: GetFileNameVista: IFileDialog API not available", TCL_STATIC); - return TCL_ERROR; + Tcl_Panic("Internal error: GetFileNameVista: IFileDialog API not available"); + return TCL_ERROR; } /* @@ -1425,6 +1427,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); hr = fdlgIf->lpVtbl->Show(fdlgIf, hWnd); Tcl_SetServiceMode(oldMode); + EatSpuriousMessageBugFix(); /* * Ensure that hWnd is enabled, because it can happen that we have updated -- cgit v0.12 From 603eb20ad00d84cd8494a90826c37edc71916e97 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 May 2016 20:26:20 +0000 Subject: Implementation of TIP #446 - Introspect Undo/Redo Stack --- generic/tkText.c | 34 +++++++++++++++++++++++--- generic/tkUndo.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- generic/tkUndo.h | 4 +++- 3 files changed, 103 insertions(+), 7 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 3e8d625..4a352b2 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2093,7 +2093,7 @@ ConfigureText( textPtr->sharedTextPtr->maxUndo = textPtr->maxUndo; textPtr->sharedTextPtr->autoSeparators = textPtr->autoSeparators; - TkUndoSetDepth(textPtr->sharedTextPtr->undoStack, + TkUndoSetMaxDepth(textPtr->sharedTextPtr->undoStack, textPtr->sharedTextPtr->maxUndo); /* @@ -5156,10 +5156,12 @@ TextEditCmd( { int index, setModified, oldModified; static const char *const editOptionStrings[] = { - "modified", "redo", "reset", "separator", "undo", NULL + "canundo", "canredo", "modified", "redo", "reset", "separator", + "undo", NULL }; enum editOptions { - EDIT_MODIFIED, EDIT_REDO, EDIT_RESET, EDIT_SEPARATOR, EDIT_UNDO + EDIT_CANUNDO, EDIT_CANREDO, EDIT_MODIFIED, EDIT_REDO, EDIT_RESET, + EDIT_SEPARATOR, EDIT_UNDO }; if (objc < 3) { @@ -5173,6 +5175,32 @@ TextEditCmd( } switch ((enum editOptions) index) { + case EDIT_CANREDO: { + int canRedo = 0; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + if (textPtr->sharedTextPtr->undo) { + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); + } + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canRedo)); + break; + } + case EDIT_CANUNDO: { + int canUndo = 0; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + if (textPtr->sharedTextPtr->undo) { + canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); + } + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canUndo)); + break; + } case EDIT_MODIFIED: if (objc == 3) { Tcl_SetObjResult(interp, diff --git a/generic/tkUndo.c b/generic/tkUndo.c index 8359e0a..5934154 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -353,7 +353,7 @@ TkUndoInitStack( /* *---------------------------------------------------------------------- * - * TkUndoSetDepth -- + * TkUndoSetMaxDepth -- * * Set the maximum depth of stack. * @@ -368,7 +368,7 @@ TkUndoInitStack( */ void -TkUndoSetDepth( +TkUndoSetMaxDepth( TkUndoRedoStack *stack, /* An Undo/Redo stack */ int maxdepth) /* The maximum stack depth */ { @@ -478,6 +478,72 @@ TkUndoFreeStack( /* *---------------------------------------------------------------------- * + * TkUndoCanRedo -- + * + * Returns true if redo is possible, i.e. if the redo stack is not empty. + * + * Results: + * A boolean. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkUndoCanRedo( + TkUndoRedoStack *stack) /* An Undo/Redo stack */ +{ + int canRedo = 0; + TkUndoAtom *elem = stack->redoStack; + + while (elem != NULL) { + if (elem->type != TK_UNDO_SEPARATOR) { + canRedo = 1; + break; + } + elem = elem->next; + } + return canRedo; +} + +/* + *---------------------------------------------------------------------- + * + * TkUndoCanUndo -- + * + * Returns true if undo is possible, i.e. if the undo stack is not empty. + * + * Results: + * A boolean. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkUndoCanUndo( + TkUndoRedoStack *stack) /* An Undo/Redo stack */ +{ + int canUndo = 0; + TkUndoAtom *elem = stack->undoStack; + + while (elem != NULL) { + if (elem->type != TK_UNDO_SEPARATOR) { + canUndo = 1; + break; + } + elem = elem->next; + } + return canUndo; +} + +/* + *---------------------------------------------------------------------- + * * TkUndoInsertUndoSeparator -- * * Insert a separator on the undo stack, indicating a border for an @@ -498,7 +564,7 @@ TkUndoInsertUndoSeparator( { if (TkUndoInsertSeparator(&stack->undoStack)) { stack->depth++; - TkUndoSetDepth(stack, stack->maxdepth); + TkUndoSetMaxDepth(stack, stack->maxdepth); } } diff --git a/generic/tkUndo.h b/generic/tkUndo.h index e63aac4..490ede9 100644 --- a/generic/tkUndo.h +++ b/generic/tkUndo.h @@ -96,9 +96,11 @@ MODULE_SCOPE void TkUndoClearStack(TkUndoAtom **stack); */ MODULE_SCOPE TkUndoRedoStack *TkUndoInitStack(Tcl_Interp *interp, int maxdepth); -MODULE_SCOPE void TkUndoSetDepth(TkUndoRedoStack *stack, int maxdepth); +MODULE_SCOPE void TkUndoSetMaxDepth(TkUndoRedoStack *stack, int maxdepth); MODULE_SCOPE void TkUndoClearStacks(TkUndoRedoStack *stack); MODULE_SCOPE void TkUndoFreeStack(TkUndoRedoStack *stack); +MODULE_SCOPE int TkUndoCanRedo(TkUndoRedoStack *stack); +MODULE_SCOPE int TkUndoCanUndo(TkUndoRedoStack *stack); MODULE_SCOPE void TkUndoInsertUndoSeparator(TkUndoRedoStack *stack); MODULE_SCOPE TkUndoSubAtom *TkUndoMakeCmdSubAtom(Tcl_Command command, Tcl_Obj *actionScript, TkUndoSubAtom *subAtomList); -- cgit v0.12 From a1fa144f468ecc214ff241aa6c61d2dbee1e3f82 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 May 2016 20:32:12 +0000 Subject: Documentation for [.t edit canundo/canredo] --- doc/text.n | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/text.n b/doc/text.n index 9ec8f74..c788fa5 100644 --- a/doc/text.n +++ b/doc/text.n @@ -1282,6 +1282,16 @@ behavior of the command depends on the \fIoption\fR argument that follows the supported: .RS .TP +\fIpathName \fBedit canredo\fR +. +Returns a boolean true if redo is possible, i.e. when the redo stack is not +empty. Otherwise returns false. +.TP +\fIpathName \fBedit canundo\fR +. +Returns a boolean true if undo is possible, i.e. when the undo stack is not +empty. Otherwise returns false. +.TP \fIpathName \fBedit modified \fR?\fIboolean\fR? . If \fIboolean\fR is not specified, returns the modified flag of the widget. -- cgit v0.12 From 561dec77f0234df7380ae28f6c22e386ba08d63b Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 May 2016 20:37:11 +0000 Subject: Tests for [.t edit canundo/canredo] --- tests/text.test | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/text.test b/tests/text.test index f217bcf..9be243d 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6207,7 +6207,7 @@ test text-27.2 {TextEditCmd procedure, argument parsing} -body { .t edit gorp } -cleanup { destroy .t -} -returnCodes {error} -result {bad edit option "gorp": must be modified, redo, reset, separator, or undo} +} -returnCodes {error} -result {bad edit option "gorp": must be canundo, canredo, modified, redo, reset, separator, or undo} test text-27.3 {TextEditUndo procedure, undoing changes} -body { text .t -undo 1 pack .t @@ -6494,6 +6494,32 @@ test text-27.22 {patch 1669632 (v) - <> is atomic} -setup { } -cleanup { destroy .top.t .top } -result "This A an example text" +test text-27.24 {TextEditCmd procedure, canundo and canredo} -setup { + destroy .t + set res {} +} -body { + text .t -undo false -autoseparators false + lappend res [.t edit canundo] [.t edit canredo] + .t configure -undo true + lappend res [.t edit canundo] [.t edit canredo] + .t insert end "DO\n" + .t edit separator + .t insert end "IT\n" + .t insert end "YOURSELF\n" + .t edit separator + lappend res [.t edit canundo] [.t edit canredo] + .t edit undo + lappend res [.t edit canundo] [.t edit canredo] + .t configure -undo false + lappend res [.t edit canundo] [.t edit canredo] + .t configure -undo true + lappend res [.t edit canundo] [.t edit canredo] + .t edit redo + lappend res [.t edit canundo] [.t edit canredo] +} -cleanup { + destroy .t +} -result {0 0 0 0 1 0 1 1 0 0 1 1 1 0} + test text-28.1 {bug fix - 624372, ControlUtfProc long lines} -body { pack [text .t -wrap none] -- cgit v0.12 From 4c0630f07e5f4720094070cdd78a0a58c5696aad Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 May 2016 21:12:30 +0000 Subject: Added <> event, triggering when either the undo stack or the redo stack becomes empty or unempty --- generic/tkText.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 4a352b2..5522154 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -401,6 +401,7 @@ static Tcl_Obj * TextGetText(const TkText *textPtr, const TkTextIndex *index1, const TkTextIndex *index2, int visibleOnly); static void GenerateModifiedEvent(TkText *textPtr); +static void GenerateUndoStackEvent(TkText *textPtr); static void UpdateDirtyFlag(TkSharedText *sharedPtr); static void RunAfterSyncCmd(ClientData clientData); static void TextPushUndoAction(TkText *textPtr, @@ -2769,6 +2770,7 @@ TextPushUndoAction( /* Index describing second location. */ { TkUndoSubAtom *iAtom, *dAtom; + TkUndoAtom *redoElem, *undoElem; /* * Create the helpers. @@ -2855,6 +2857,9 @@ TextPushUndoAction( Tcl_DecrRefCount(index1Obj); Tcl_DecrRefCount(index2Obj); + undoElem = textPtr->sharedTextPtr->undoStack->undoStack; + redoElem = textPtr->sharedTextPtr->undoStack->redoStack; + /* * Depending whether the action is to insert or delete, we provide the * appropriate second and third arguments to TkUndoPushAction. (The first @@ -2866,6 +2871,10 @@ TextPushUndoAction( } else { TkUndoPushAction(textPtr->sharedTextPtr->undoStack, dAtom, iAtom); } + + if (undoElem == NULL || redoElem != NULL) { + GenerateUndoStackEvent(textPtr); + } } /* @@ -5155,6 +5164,10 @@ TextEditCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { int index, setModified, oldModified; + int canRedo = 0; + int canUndo = 0; + TkUndoAtom *redoElem, *undoElem; + static const char *const editOptionStrings[] = { "canundo", "canredo", "modified", "redo", "reset", "separator", "undo", NULL @@ -5175,9 +5188,7 @@ TextEditCmd( } switch ((enum editOptions) index) { - case EDIT_CANREDO: { - int canRedo = 0; - + case EDIT_CANREDO: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; @@ -5187,10 +5198,7 @@ TextEditCmd( } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canRedo)); break; - } - case EDIT_CANUNDO: { - int canUndo = 0; - + case EDIT_CANUNDO: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; @@ -5200,7 +5208,6 @@ TextEditCmd( } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canUndo)); break; - } case EDIT_MODIFIED: if (objc == 3) { Tcl_SetObjResult(interp, @@ -5241,22 +5248,32 @@ TextEditCmd( } break; case EDIT_REDO: - if (objc != 3) { + if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } - if (TextEditRedo(textPtr)) { + undoElem = textPtr->sharedTextPtr->undoStack->undoStack; + if (TextEditRedo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to redo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", NULL); return TCL_ERROR; } + redoElem = textPtr->sharedTextPtr->undoStack->redoStack; + if (undoElem == NULL || redoElem == NULL) { + GenerateUndoStackEvent(textPtr); + } break; case EDIT_RESET: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } + undoElem = textPtr->sharedTextPtr->undoStack->undoStack; + redoElem = textPtr->sharedTextPtr->undoStack->redoStack; TkUndoClearStacks(textPtr->sharedTextPtr->undoStack); + if (undoElem != NULL || redoElem != NULL) { + GenerateUndoStackEvent(textPtr); + } break; case EDIT_SEPARATOR: if (objc != 3) { @@ -5266,15 +5283,20 @@ TextEditCmd( TkUndoInsertUndoSeparator(textPtr->sharedTextPtr->undoStack); break; case EDIT_UNDO: - if (objc != 3) { + if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } + redoElem = textPtr->sharedTextPtr->undoStack->redoStack; if (TextEditUndo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL); return TCL_ERROR; } + undoElem = textPtr->sharedTextPtr->undoStack->undoStack; + if (redoElem == NULL || undoElem == NULL) { + GenerateUndoStackEvent(textPtr); + } break; } return TCL_OK; @@ -5390,6 +5412,36 @@ GenerateModifiedEvent( /* *---------------------------------------------------------------------- * + * GenerateUndoStackEvent -- + * + * Send an event that the undo or redo stack became empty or unempty. + * This is equivalent to: + * event generate $textWidget <> + * for all peers of $textWidget. + * + * Results: + * None + * + * Side effects: + * May force the text window (and all peers) into existence. + * + *---------------------------------------------------------------------- + */ + +static void +GenerateUndoStackEvent( + TkText *textPtr) /* Information about text widget. */ +{ + for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL; + textPtr = textPtr->next) { + Tk_MakeWindowExist(textPtr->tkwin); + TkSendVirtualEvent(textPtr->tkwin, "UndoStack", NULL); + } +} + +/* + *---------------------------------------------------------------------- + * * UpdateDirtyFlag -- * * Updates the dirtyness of the text widget -- cgit v0.12 From b4f74086bc18e8d816af1d49606295c975420241 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 May 2016 21:22:57 +0000 Subject: Documented the <> event --- doc/event.n | 4 ++++ doc/text.n | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/doc/event.n b/doc/event.n index 045339e..54ad42e 100644 --- a/doc/event.n +++ b/doc/event.n @@ -352,6 +352,10 @@ user-driven .QW "tab to widget" action. .TP +\fB<>\fR +This is sent to a text widget when its undo stack or redo stack becomes +empty or unempty. +.TP \fB<>\fR This is sent to a text widget when its internal data become obsolete, and again when these internal data are back in sync with the widget diff --git a/doc/text.n b/doc/text.n index c788fa5..96e7ccc 100644 --- a/doc/text.n +++ b/doc/text.n @@ -897,6 +897,10 @@ separator is already present at the top of the undo stack no other will be inserted. That means that two separators on the undo stack are always separated by at least one insert or delete action. .PP +The \fB<>\fR virtual event is generated every time the undo stack +or the redo stack becomes empty or unempty. This event is generated once for +each peer widget. +.PP The undo mechanism is also linked to the modified flag. This means that undoing or redoing changes can take a modified text widget back to the unmodified state or vice versa. The modified flag will be set automatically to -- cgit v0.12 From 7a226093c601aa9aed761133e3a03a3b98d839a4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 May 2016 21:24:43 +0000 Subject: Removed useless precision regarding the <> event --- doc/text.n | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/text.n b/doc/text.n index 96e7ccc..e2bb01f 100644 --- a/doc/text.n +++ b/doc/text.n @@ -898,8 +898,7 @@ inserted. That means that two separators on the undo stack are always separated by at least one insert or delete action. .PP The \fB<>\fR virtual event is generated every time the undo stack -or the redo stack becomes empty or unempty. This event is generated once for -each peer widget. +or the redo stack becomes empty or unempty. .PP The undo mechanism is also linked to the modified flag. This means that undoing or redoing changes can take a modified text widget back to the -- cgit v0.12 From 496aa58fc7b28242708064b4bd4f75a055ded9e2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 May 2016 21:35:47 +0000 Subject: Added test for the <> event --- tests/text.test | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/text.test b/tests/text.test index 9be243d..0ec69d0 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6519,6 +6519,49 @@ test text-27.24 {TextEditCmd procedure, canundo and canredo} -setup { } -cleanup { destroy .t } -result {0 0 0 0 1 0 1 1 0 0 1 1 1 0} +test text-27.25 {<> virtual event} -setup { + destroy .t + set res {} + set nbUS 0 +} -body { + text .t -undo false -autoseparators false + bind .t <> {incr nbUS} + update ; lappend res $nbUS + .t configure -undo true + update ; lappend res $nbUS + .t insert end "DO\n" + .t edit separator + .t insert end "IT\n" + .t insert end "YOURSELF\n" + .t edit separator + .t insert end "MAN\n" + .t edit separator + update ; lappend res $nbUS + .t edit undo + update ; lappend res $nbUS + .t edit redo + update ; lappend res $nbUS + .t edit undo + update ; lappend res $nbUS + .t edit undo + update ; lappend res $nbUS + .t edit undo + update ; lappend res $nbUS + .t edit redo + update ; lappend res $nbUS + .t edit redo + update ; lappend res $nbUS + .t edit redo + update ; lappend res $nbUS + .t edit undo + update ; lappend res $nbUS + .t edit undo + update ; lappend res $nbUS + .t edit reset + update ; lappend res $nbUS +} -cleanup { + destroy .t +} -result {0 0 1 2 3 4 4 5 6 6 7 8 8 9} test text-28.1 {bug fix - 624372, ControlUtfProc long lines} -body { -- cgit v0.12 From 285b73d3427cf1e29de1ddc1a6ee2a3a138901a6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 May 2016 21:42:49 +0000 Subject: Aligned GenerateModifiedEvent() on GenerateUndoStackEvent() regarding generation of the event for each peer --- generic/tkText.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 5522154..a9b7527 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5241,10 +5241,7 @@ TextEditCmd( */ if ((!oldModified) != (!setModified)) { - for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL; - textPtr = textPtr->next) { - GenerateModifiedEvent(textPtr); - } + GenerateModifiedEvent(textPtr); } break; case EDIT_REDO: @@ -5391,7 +5388,8 @@ TextGetText( * * Send an event that the text was modified. This is equivalent to: * event generate $textWidget <> - * + * for all peers of $textWidget. +* * Results: * None * @@ -5405,8 +5403,11 @@ static void GenerateModifiedEvent( TkText *textPtr) /* Information about text widget. */ { - Tk_MakeWindowExist(textPtr->tkwin); - TkSendVirtualEvent(textPtr->tkwin, "Modified", NULL); + for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL; + textPtr = textPtr->next) { + Tk_MakeWindowExist(textPtr->tkwin); + TkSendVirtualEvent(textPtr->tkwin, "Modified", NULL); + } } /* @@ -5460,7 +5461,6 @@ UpdateDirtyFlag( TkSharedText *sharedTextPtr)/* Information about text widget. */ { int oldDirtyFlag; - TkText *textPtr; /* * If we've been forced to be dirty, we stay dirty (until explicitly @@ -5491,10 +5491,7 @@ UpdateDirtyFlag( } if (sharedTextPtr->isDirty == 0 || oldDirtyFlag == 0) { - for (textPtr = sharedTextPtr->peers; textPtr != NULL; - textPtr = textPtr->next) { - GenerateModifiedEvent(textPtr); - } + GenerateModifiedEvent(sharedTextPtr->peers); } } -- cgit v0.12 From d1ed9566df0379d64ce1bcbeb9cf4d6ce5054dc1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 17 May 2016 20:00:20 +0000 Subject: Took comments from Koen Danckaert into account (with my thanks) to simplify the implementation of TkUndoCanUndo() and TkUndoCanRedo() in tkUndo.c, and in tkText.c to remove direct calls to internals of the undo or redo stack --- generic/tkText.c | 27 +++++++++++++-------------- generic/tkUndo.c | 24 ++---------------------- 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index a9b7527..b610844 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2770,7 +2770,7 @@ TextPushUndoAction( /* Index describing second location. */ { TkUndoSubAtom *iAtom, *dAtom; - TkUndoAtom *redoElem, *undoElem; + int canUndo, canRedo; /* * Create the helpers. @@ -2857,8 +2857,8 @@ TextPushUndoAction( Tcl_DecrRefCount(index1Obj); Tcl_DecrRefCount(index2Obj); - undoElem = textPtr->sharedTextPtr->undoStack->undoStack; - redoElem = textPtr->sharedTextPtr->undoStack->redoStack; + canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); /* * Depending whether the action is to insert or delete, we provide the @@ -2872,7 +2872,7 @@ TextPushUndoAction( TkUndoPushAction(textPtr->sharedTextPtr->undoStack, dAtom, iAtom); } - if (undoElem == NULL || redoElem != NULL) { + if (!canUndo || canRedo) { GenerateUndoStackEvent(textPtr); } } @@ -5166,7 +5166,6 @@ TextEditCmd( int index, setModified, oldModified; int canRedo = 0; int canUndo = 0; - TkUndoAtom *redoElem, *undoElem; static const char *const editOptionStrings[] = { "canundo", "canredo", "modified", "redo", "reset", "separator", @@ -5249,14 +5248,14 @@ TextEditCmd( Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } - undoElem = textPtr->sharedTextPtr->undoStack->undoStack; + canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); if (TextEditRedo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to redo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", NULL); return TCL_ERROR; } - redoElem = textPtr->sharedTextPtr->undoStack->redoStack; - if (undoElem == NULL || redoElem == NULL) { + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); + if (!canUndo || !canRedo) { GenerateUndoStackEvent(textPtr); } break; @@ -5265,10 +5264,10 @@ TextEditCmd( Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } - undoElem = textPtr->sharedTextPtr->undoStack->undoStack; - redoElem = textPtr->sharedTextPtr->undoStack->redoStack; + canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); TkUndoClearStacks(textPtr->sharedTextPtr->undoStack); - if (undoElem != NULL || redoElem != NULL) { + if (canUndo || canRedo) { GenerateUndoStackEvent(textPtr); } break; @@ -5284,14 +5283,14 @@ TextEditCmd( Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } - redoElem = textPtr->sharedTextPtr->undoStack->redoStack; + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); if (TextEditUndo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL); return TCL_ERROR; } - undoElem = textPtr->sharedTextPtr->undoStack->undoStack; - if (redoElem == NULL || undoElem == NULL) { + canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); + if (!canRedo || !canUndo) { GenerateUndoStackEvent(textPtr); } break; diff --git a/generic/tkUndo.c b/generic/tkUndo.c index 5934154..c66905d 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -495,17 +495,7 @@ int TkUndoCanRedo( TkUndoRedoStack *stack) /* An Undo/Redo stack */ { - int canRedo = 0; - TkUndoAtom *elem = stack->redoStack; - - while (elem != NULL) { - if (elem->type != TK_UNDO_SEPARATOR) { - canRedo = 1; - break; - } - elem = elem->next; - } - return canRedo; + return stack->redoStack != NULL; } /* @@ -528,17 +518,7 @@ int TkUndoCanUndo( TkUndoRedoStack *stack) /* An Undo/Redo stack */ { - int canUndo = 0; - TkUndoAtom *elem = stack->undoStack; - - while (elem != NULL) { - if (elem->type != TK_UNDO_SEPARATOR) { - canUndo = 1; - break; - } - elem = elem->next; - } - return canUndo; + return stack->undoStack != NULL; } /* -- cgit v0.12 From ac52dfb290b2def674a44dcdd9d2a5744f435ba8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 17 May 2016 20:36:00 +0000 Subject: Added (currently failing) test case scrollbar-11.1 - Note that it will only fail on x11 and on aqua, not on Win because on Windows there is no binding of <2> for the Scrollbar class --- tests/scrollbar.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 3b16821..8f967ea 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -662,6 +662,24 @@ test scrollbar-10.2 { event on scrollbar} -constraints {win|unix} -s destroy .t .s } -result {1.4} +test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body { + proc destroy_scrollbar {} { + if {[winfo exists .top.s]} { + destroy .top.s + } + } + toplevel .top + scrollbar .top.s -command destroy_scrollbar + bind .top.s <2> destroy_scrollbar + pack .top.s + focus -force .top.s + update + event generate .top.s <2> + update ; # shall not trigger error invalid command name ".top.s" +} -cleanup { + destroy .top.s .top +} -result {} + catch {destroy .s} catch {destroy .t} -- cgit v0.12 From 51c67e374ef37b064bf13cda750744eb7b0d41fc Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 18 May 2016 02:26:41 +0000 Subject: Tweak to allow Tk to build on 10.5; thanks to Marc Culler for patch --- macosx/tkMacOSXNotify.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 1455688..f14e1b8 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -270,10 +270,15 @@ TkMacOSXEventsCheckProc( inMode:GetRunLoopMode(modalSession) dequeue:NO]; /* We must not steal any events during LiveResize. */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 if (testEvent && [[testEvent window] inLiveResize]) { break; } - +#else + if (testEvent && [[[testEvent window] contentView] inLiveResize]) { + break; + } +#endif currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(modalSession) -- cgit v0.12 From 1c0858ce27408d641e6b3bb8f66e9b59cf630014 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 18 May 2016 10:14:33 +0000 Subject: Fixed [011706ec42] for the scrollbar case. --- library/scrlbar.tcl | 11 ++++++++--- tests/scrollbar.test | 23 +++++++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index b7be014..6f1caa2 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -430,6 +430,9 @@ proc ::tk::ScrollTopBottom {w x y} { proc ::tk::ScrollButton2Down {w x y} { variable ::tk::Priv + if {![winfo exists $w]} { + return + } set element [$w identify $x $y] if {[string match {arrow[12]} $element]} { ScrollButtonDown $w $x $y @@ -443,7 +446,9 @@ proc ::tk::ScrollButton2Down {w x y} { # slider drag. update idletasks - $w configure -activerelief sunken - $w activate slider - ScrollStartDrag $w $x $y + if {[winfo exists $w]} { + $w configure -activerelief sunken + $w activate slider + ScrollStartDrag $w $x $y + } } diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 8f967ea..bd14067 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -669,8 +669,8 @@ test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destructi } } toplevel .top - scrollbar .top.s -command destroy_scrollbar - bind .top.s <2> destroy_scrollbar + scrollbar .top.s + bind .top.s <2> {destroy_scrollbar} pack .top.s focus -force .top.s update @@ -679,6 +679,25 @@ test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destructi } -cleanup { destroy .top.s .top } -result {} +test scrollbar-11.2 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body { + proc destroy_scrollbar {{y 0}} { + if {[winfo exists .top.s]} { + destroy .top.s + } + } + toplevel .top + wm minsize .top 50 400 + update + scrollbar .top.s + bind .top.s <2> {after idle destroy_scrollbar} + pack .top.s -expand true -fill y + focus -force .top.s + update + event generate .top.s <2> -x 2 -y [expr {[winfo height .top.s] / 2}] + update ; # shall not trigger error invalid command name ".top.s" +} -cleanup { + destroy .top.s .top +} -result {} catch {destroy .s} catch {destroy .t} -- cgit v0.12 From c130191cfa0f21c3ab4ac1092745bc5c06a42e7a Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 22 May 2016 19:56:27 +0000 Subject: Fixed [109865fa01] - ttk::menubutton has an unprotected winfo --- library/ttk/menubutton.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ttk/menubutton.tcl b/library/ttk/menubutton.tcl index 093bb02..2be064c 100644 --- a/library/ttk/menubutton.tcl +++ b/library/ttk/menubutton.tcl @@ -57,7 +57,7 @@ if {[tk windowingsystem] eq "x11"} { bind TMenubutton \ { %W state pressed ; ttk::menubutton::Popdown %W } bind TMenubutton \ - { %W state !pressed } + { if {[winfo exists %W]} { %W state !pressed } } } # PostPosition -- -- cgit v0.12 From a129a2159a084a7ead331d54273f5cf2a3a7a961 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 22 May 2016 20:55:05 +0000 Subject: Added test checkbutton-1.7 to guard against regressions regarding [109865fa01] --- tests/ttk/checkbutton.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/ttk/checkbutton.test b/tests/ttk/checkbutton.test index e18ff32..6b79287 100644 --- a/tests/ttk/checkbutton.test +++ b/tests/ttk/checkbutton.test @@ -45,4 +45,20 @@ test checkbutton-1.6 "Checkbutton default variable" -body { lappend result [info exists .cb] [set .cb] [.cb state] } -result [list .cb 0 alternate 1 on selected 1 off {}] +# Bug [109865fa01] +test checkbutton-1.7 "Button destroyed by click" -body { + proc destroy_button {} { + destroy .top + } + toplevel .top + ttk::menubutton .top.mb -text Button -style TLabel + bind .top.mb destroy_button + pack .top.mb + focus -force .top.mb + update + event generate .top.mb <1> + event generate .top.mb + update ; # shall not trigger error invalid command name ".top.b" +} -result {} + tcltest::cleanupTests -- cgit v0.12 From 936bae60225b39532ed5a37afd633737ac95613b Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 25 May 2016 21:19:33 +0000 Subject: Fixed [f2655bb0ec] - bind-15.23 fails if the mouse is inside the test window --- tests/bind.test | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/bind.test b/tests/bind.test index 474771d..ab3fa15 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -34,6 +34,14 @@ proc unsetBindings {} { bind .t {} } +# move the mouse pointer away of the testing area +# otherwise some spurious events may pollute the tests +toplevel .top +wm geometry .top 50x50-50-50 +update +event generate .top -warp 1 +update +destroy .top test bind-1.1 {bind command} -body { bind -- cgit v0.12 From bfc87e3ce9f57f6f966f6cf423d1064487cb887b Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 26 May 2016 18:21:34 +0000 Subject: Fixed [79549a9134] - Mouse pointer warping crashes --- generic/tkBind.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 9cd3b7b..81c768b 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3535,8 +3535,16 @@ DoWarp( { TkDisplay *dispPtr = clientData; - TkpWarpPointer(dispPtr); - XForceScreenSaver(dispPtr->display, ScreenSaverReset); + /* + * DoWarp was scheduled only if the window was mapped. It needs to be + * still mapped at the time the present idle callback is executed. In + * particular, this guards against window destruction in the meantime. + */ + + if (Tk_IsMapped(dispPtr->warpWindow)) { + TkpWarpPointer(dispPtr); + XForceScreenSaver(dispPtr->display, ScreenSaverReset); + } dispPtr->flags &= ~TK_DISPLAY_IN_WARP; } -- cgit v0.12 From ef21094dd7164fbf1d96d8c33570f4803b7e35e6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 26 May 2016 20:46:06 +0000 Subject: More complete fix for [79549a9134] - Mouse pointer warping crashes, with a non-regression test case. --- generic/tkBind.c | 7 ++++--- tests/bind.test | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 81c768b..4374494 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3537,11 +3537,12 @@ DoWarp( /* * DoWarp was scheduled only if the window was mapped. It needs to be - * still mapped at the time the present idle callback is executed. In - * particular, this guards against window destruction in the meantime. + * still mapped at the time the present idle callback is executed. Also + * one needs to guard against window destruction in the meantime. */ - if (Tk_IsMapped(dispPtr->warpWindow)) { + if (Tk_IsMapped(dispPtr->warpWindow) + && (Tk_WindowId(dispPtr->warpWindow) != None)) { TkpWarpPointer(dispPtr); XForceScreenSaver(dispPtr->display, ScreenSaverReset); } diff --git a/tests/bind.test b/tests/bind.test index 474771d..387b119 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -6093,6 +6093,18 @@ test bind-31.7 {virtual event user_data field - unshared, asynch} -setup { destroy .t.f } -result {{} {} {TestUserData >b<}} +test bind-32 {-warp, window was destroyed before the idle callback DoWarp} -setup { + frame .t.f + pack .t.f + focus -force .t.f + update +} -body { + event generate .t.f -warp 1 + destroy .t.f + update ; # shall simply not crash +} -cleanup { +} -result {} + # cleanup cleanupTests -- cgit v0.12 From 3c97457911a615a201c7105b290b206ac22e9d2f Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 30 May 2016 19:38:04 +0000 Subject: Fixed crash when calling event generate {} -warp 1 --- generic/tkBind.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 4374494..3b05066 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3539,10 +3539,13 @@ DoWarp( * DoWarp was scheduled only if the window was mapped. It needs to be * still mapped at the time the present idle callback is executed. Also * one needs to guard against window destruction in the meantime. + * Finally, the case warpWindow == NULL is special in that it means + * the whole screen. */ - if (Tk_IsMapped(dispPtr->warpWindow) - && (Tk_WindowId(dispPtr->warpWindow) != None)) { + if ((dispPtr->warpWindow == NULL) || + (Tk_IsMapped(dispPtr->warpWindow) + && (Tk_WindowId(dispPtr->warpWindow) != None))) { TkpWarpPointer(dispPtr); XForceScreenSaver(dispPtr->display, ScreenSaverReset); } -- cgit v0.12 From f77be3e4cd37f2986f8c5960d7b61d2f800ba6b4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 30 May 2016 20:16:28 +0000 Subject: A mouse button once pressed should be released. Doing otherwise messes up with assumptions in other (later) tests from the test suite, which reasonably think they start with all mouse buttons depressed. In the present case, canvas-13.1 failed because event generation of was missing in test bind-32 --- tests/bind.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bind.test b/tests/bind.test index 387b119..c26cfcd 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -6100,6 +6100,7 @@ test bind-32 {-warp, window was destroyed before the idle callback DoWarp} -setu update } -body { event generate .t.f -warp 1 + event generate .t.f destroy .t.f update ; # shall simply not crash } -cleanup { -- cgit v0.12 From f04872f8ab7961a917d3fe82641f8568f04397ab Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 1 Jun 2016 15:08:19 +0000 Subject: Fix [http://core.tcl.tk/tcl/info/3bd69eba99a395ee|3bd69eba99a395ee]: 'make dist' fails when tclsh9.0 is on $PATH --- generic/ttk/ttkGenStubs.tcl | 2 -- library/demos/ixset | 1 - library/demos/rmt | 1 - library/demos/timer | 1 - library/demos/widget | 1 - library/tk.tcl | 4 ---- tests/all.tcl | 3 +-- tests/constraints.tcl | 2 -- tests/ttk/all.tcl | 3 +-- 9 files changed, 2 insertions(+), 16 deletions(-) diff --git a/generic/ttk/ttkGenStubs.tcl b/generic/ttk/ttkGenStubs.tcl index 3c8eb19..5b374e6 100644 --- a/generic/ttk/ttkGenStubs.tcl +++ b/generic/ttk/ttkGenStubs.tcl @@ -24,8 +24,6 @@ # + stubs table is const-qualified # -package require Tcl 8 - namespace eval genStubs { # libraryName -- # diff --git a/library/demos/ixset b/library/demos/ixset index 06b644d..57985b1 100644 --- a/library/demos/ixset +++ b/library/demos/ixset @@ -9,7 +9,6 @@ exec wish "$0" ${1+"$@"} # 91/11/23 : pda@masi.ibp.fr, jt@ratp.fr : design # 92/08/01 : pda@masi.ibp.fr : cleaning -package require Tcl 8.4 package require Tk # diff --git a/library/demos/rmt b/library/demos/rmt index 51886de..00bdc9d 100644 --- a/library/demos/rmt +++ b/library/demos/rmt @@ -7,7 +7,6 @@ exec wish "$0" ${1+"$@"} # Tk applications. It allows you to select an application and # then type commands to that application. -package require Tcl 8.4 package require Tk wm title . "Tk Remote Controller" diff --git a/library/demos/timer b/library/demos/timer index e10b840..6b61ca4 100644 --- a/library/demos/timer +++ b/library/demos/timer @@ -5,7 +5,6 @@ exec wish "$0" ${1+"$@"} # timer -- # This script generates a counter with start and stop buttons. -package require Tcl 8.4 package require Tk label .counter -text 0.00 -relief raised -width 10 -padx 2m -pady 1m diff --git a/library/demos/widget b/library/demos/widget index d58f086..162497e 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -10,7 +10,6 @@ exec wish "$0" ${1+"$@"} # separate ".tcl" files is this directory, which are sourced by this script as # needed. -package require Tcl 8.5 package require Tk 8.5 package require msgcat package require Ttk diff --git a/library/tk.tcl b/library/tk.tcl index b971329..2dca7fd 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -10,10 +10,6 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require Tcl 8.5 ;# Guard against [source] in an 8.4- interp before - ;# using 8.5 [package] features. -# Insist on running with compatible version of Tcl -package require Tcl 8.5.0 # Verify that we have Tk binary and script components from the same release package require -exact Tk 8.5.19 diff --git a/tests/all.tcl b/tests/all.tcl index 7f57dc2..d15e5ca 100644 --- a/tests/all.tcl +++ b/tests/all.tcl @@ -9,9 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require Tcl 8.5 -package require tcltest 2.2 package require Tk ;# This is the Tk test suite; fail early if no Tk! +package require tcltest 2.2 tcltest::configure {*}$argv tcltest::configure -testdir [file normalize [file dirname [info script]]] tcltest::configure -loadfile \ diff --git a/tests/constraints.tcl b/tests/constraints.tcl index bc2c09b..01089aa 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -5,8 +5,6 @@ if {[namespace exists tk::test]} { return } -package require Tcl 8.4 - package require Tk 8.4 tk appname tktest wm title . tktest diff --git a/tests/ttk/all.tcl b/tests/ttk/all.tcl index da2e316..f03cd56 100644 --- a/tests/ttk/all.tcl +++ b/tests/ttk/all.tcl @@ -9,9 +9,8 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require Tcl 8.5 -package require tcltest 2.2 package require Tk ;# This is the Tk test suite; fail early if no Tk! +package require tcltest 2.2 tcltest::configure {*}$argv tcltest::configure -testdir [file normalize [file dirname [info script]]] tcltest::configure -loadfile \ -- cgit v0.12 From a703e6bbe026f5c46c230a40d0304ec787e88a31 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 8 Jun 2016 15:27:05 +0000 Subject: Fixed [6976e4b3b2] - -undo options not correct for peers --- generic/tkText.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index b610844..8be8881 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -122,7 +122,8 @@ static const Tk_ObjCustomOption lineOption = { static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BOOLEAN, "-autoseparators", "autoSeparators", "AutoSeparators", DEF_TEXT_AUTO_SEPARATORS, -1, - Tk_Offset(TkText, autoSeparators), 0, 0, 0}, + Tk_Offset(TkText, autoSeparators), + TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_TEXT_BG_COLOR, -1, Tk_Offset(TkText, border), 0, DEF_TEXT_BG_MONO, 0}, @@ -193,7 +194,8 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_INSERT_WIDTH, -1, Tk_Offset(TkText, insertWidth), 0, 0, 0}, {TK_OPTION_INT, "-maxundo", "maxUndo", "MaxUndo", - DEF_TEXT_MAX_UNDO, -1, Tk_Offset(TkText, maxUndo), 0, 0, 0}, + DEF_TEXT_MAX_UNDO, -1, Tk_Offset(TkText, maxUndo), + TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", DEF_TEXT_PADX, -1, Tk_Offset(TkText, padX), 0, 0, TK_TEXT_LINE_GEOMETRY}, @@ -239,7 +241,8 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_TAKE_FOCUS, -1, Tk_Offset(TkText, takeFocus), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-undo", "undo", "Undo", - DEF_TEXT_UNDO, -1, Tk_Offset(TkText, undo), 0, 0 , 0}, + DEF_TEXT_UNDO, -1, Tk_Offset(TkText, undo), + TK_OPTION_DONT_SET_DEFAULT, 0 , 0}, {TK_OPTION_INT, "-width", "width", "Width", DEF_TEXT_WIDTH, -1, Tk_Offset(TkText, width), 0, 0, TK_TEXT_LINE_GEOMETRY}, -- cgit v0.12 From 81b4ffc7a593b7ae4d2e91d29ad6e5564b7c9548 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 8 Jun 2016 15:33:39 +0000 Subject: Added test case text-27.16a to guard against regressions regarding [6976e4b3b2] --- tests/text.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/text.test b/tests/text.test index 0ec69d0..720afbe 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6383,6 +6383,21 @@ test text-27.16 {-maxundo configuration option} -body { } -cleanup { destroy .t } -result "line 1\n\n" +test text-27.16a {undo configuration options with peers} -body { + text .t -undo 1 -autoseparators 0 -maxundo 100 + .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 +} -result {1 1 0 0 100 100 1 1} 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 ce9dca75b1696d473e46b71fe75f0a2526971129 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 11 Jun 2016 20:11:18 +0000 Subject: Fixed [4cb3dab4eb] - Improvements to the documentation of Tk_FindPhoto et al. Patch provided by Simon Bachmann. --- doc/FindPhoto.3 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/FindPhoto.3 b/doc/FindPhoto.3 index d6ccb5b..dea7e05 100644 --- a/doc/FindPhoto.3 +++ b/doc/FindPhoto.3 @@ -99,6 +99,8 @@ being written to the photo image. particular photo image to the other procedures. The parameter is the name of the image, that is, the name specified to the \fBimage create photo\fR command, or assigned by that command if no name was specified. +If \fIimageName\fR does not exist or is not a photo image, +\fBTk_FindPhoto\fR returns NULL. .PP \fBTk_PhotoPutBlock\fR is used to supply blocks of image data to be displayed. The call affects an area of the image of size @@ -181,6 +183,18 @@ in the structure pointed to by the \fIblockPtr\fR parameter with values that describe the address and layout of the image data that the photo image has stored internally. The values are valid until the image is destroyed or its size is changed. +.PP +It is possible to modify an image by writing directly to the data +the \fIpixelPtr\fR field points to. The size of the image cannot be +changed this way, though. +Also, changes made by writing directly to \fIpixelPtr\fR will not be +immediately visible, but only after a call to +\fBTk_ImageChanged\fR or after an event that causes the interested +widgets to redraw themselves. +For these reasons usually it is preferrable to make changes to +a copy a of the image data and write it back with +\fBTk_PhotoPutBlock\fR or \fBTk_PhotoPutZoomedBlock\fR. +.PP \fBTk_PhotoGetImage\fR returns 1 for compatibility with the corresponding procedure in the old photo widget. .PP -- cgit v0.12 From f8da4262bfb61ab52c15ca76b3211eec99fd79f3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Jun 2016 10:01:41 +0000 Subject: Whitespace fixes --- generic/tkText.c | 294 +++++++++++++++++++++++++++---------------------------- 1 file changed, 147 insertions(+), 147 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 8be8881..5ad527a 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -123,7 +123,7 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BOOLEAN, "-autoseparators", "autoSeparators", "AutoSeparators", DEF_TEXT_AUTO_SEPARATORS, -1, Tk_Offset(TkText, autoSeparators), - TK_OPTION_DONT_SET_DEFAULT, 0, 0}, + TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_TEXT_BG_COLOR, -1, Tk_Offset(TkText, border), 0, DEF_TEXT_BG_MONO, 0}, @@ -195,7 +195,7 @@ static const Tk_OptionSpec optionSpecs[] = { 0, 0, 0}, {TK_OPTION_INT, "-maxundo", "maxUndo", "MaxUndo", DEF_TEXT_MAX_UNDO, -1, Tk_Offset(TkText, maxUndo), - TK_OPTION_DONT_SET_DEFAULT, 0, 0}, + TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", DEF_TEXT_PADX, -1, Tk_Offset(TkText, padX), 0, 0, TK_TEXT_LINE_GEOMETRY}, @@ -242,7 +242,7 @@ static const Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-undo", "undo", "Undo", DEF_TEXT_UNDO, -1, Tk_Offset(TkText, undo), - TK_OPTION_DONT_SET_DEFAULT, 0 , 0}, + TK_OPTION_DONT_SET_DEFAULT, 0 , 0}, {TK_OPTION_INT, "-width", "width", "Width", DEF_TEXT_WIDTH, -1, Tk_Offset(TkText, width), 0, 0, TK_TEXT_LINE_GEOMETRY}, @@ -923,43 +923,43 @@ TextWidgetObjCmd( * We're going to count up all display lines in the logical * line of 'indexFromPtr' up to, but not including the logical * line of 'indexToPtr' (except if this line is elided), and - * then subtract off what came in too much from elided lines, - * also subtract off what we didn't want from 'from' and add + * then subtract off what came in too much from elided lines, + * also subtract off what we didn't want from 'from' and add * on what we didn't count from 'to'. */ - while (TkTextIndexCmp(&index,indexToPtr) < 0) { + while (TkTextIndexCmp(&index,indexToPtr) < 0) { value += TkTextUpdateOneLine(textPtr, index.linePtr, - 0, &index, 0); + 0, &index, 0); } - index2 = index; - - /* - * Now we need to adjust the count to: - * - subtract off the number of display lines between - * indexToPtr and index2, since we might have skipped past - * indexToPtr, if we have several logical lines in a - * single display line - * - subtract off the number of display lines overcounted - * in the first logical line - * - add on the number of display lines in the last logical - * line - * This logic is still ok if both indexFromPtr and indexToPtr - * are in the same logical line. - */ - - index = *indexToPtr; - index.byteIndex = 0; - while (TkTextIndexCmp(&index,&index2) < 0) { - value -= TkTextUpdateOneLine(textPtr, index.linePtr, - 0, &index, 0); - } + index2 = index; + + /* + * Now we need to adjust the count to: + * - subtract off the number of display lines between + * indexToPtr and index2, since we might have skipped past + * indexToPtr, if we have several logical lines in a + * single display line + * - subtract off the number of display lines overcounted + * in the first logical line + * - add on the number of display lines in the last logical + * line + * This logic is still ok if both indexFromPtr and indexToPtr + * are in the same logical line. + */ + + index = *indexToPtr; + index.byteIndex = 0; + while (TkTextIndexCmp(&index,&index2) < 0) { + value -= TkTextUpdateOneLine(textPtr, index.linePtr, + 0, &index, 0); + } index.linePtr = indexFromPtr->linePtr; index.byteIndex = 0; while (1) { TkTextFindDisplayLineEnd(textPtr, &index, 1, NULL); - if (TkTextIndexCmp(&index,indexFromPtr) >= 0) { + if (TkTextIndexCmp(&index,indexFromPtr) >= 0) { break; } TkTextIndexForwBytes(textPtr, &index, 1, &index); @@ -971,7 +971,7 @@ TextWidgetObjCmd( index.byteIndex = 0; while (1) { TkTextFindDisplayLineEnd(textPtr, &index, 1, NULL); - if (TkTextIndexCmp(&index,indexToPtr) >= 0) { + if (TkTextIndexCmp(&index,indexToPtr) >= 0) { break; } TkTextIndexForwBytes(textPtr, &index, 1, &index); @@ -1399,14 +1399,14 @@ TextWidgetObjCmd( result = TextPeerCmd(textPtr, interp, objc, objv); break; case TEXT_PENDINGSYNC: { - if (objc != 2) { - Tcl_WrongNumArgs(interp, 2, objv, NULL); - result = TCL_ERROR; - goto done; - } - Tcl_SetObjResult(interp, - Tcl_NewBooleanObj(TkTextPendingsync(textPtr))); - break; + if (objc != 2) { + Tcl_WrongNumArgs(interp, 2, objv, NULL); + result = TCL_ERROR; + goto done; + } + Tcl_SetObjResult(interp, + Tcl_NewBooleanObj(TkTextPendingsync(textPtr))); + break; } case TEXT_REPLACE: { const TkTextIndex *indexFromPtr, *indexToPtr; @@ -1539,7 +1539,7 @@ TextWidgetObjCmd( textPtr->afterSyncCmd = cmd; } else { textPtr->afterSyncCmd = cmd; - Tcl_DoWhenIdle(RunAfterSyncCmd, (ClientData) textPtr); + Tcl_DoWhenIdle(RunAfterSyncCmd, (ClientData) textPtr); } break; } else if (objc != 2) { @@ -2195,10 +2195,10 @@ ConfigureText( * Also, clamp the insert and current (unshared) marks to the new * -startline/-endline range limits of the widget. All other (shared) * marks are unchanged. - * The return value of TkTextMarkNameToIndex does not need to be - * checked: "insert" and "current" marks always exist, and the - * purpose of the code below precisely is to move them inside the - * -startline/-endline range. + * The return value of TkTextMarkNameToIndex does not need to be + * checked: "insert" and "current" marks always exist, and the + * purpose of the code below precisely is to move them inside the + * -startline/-endline range. */ textPtr->sharedTextPtr->stateEpoch++; @@ -2258,18 +2258,18 @@ ConfigureText( */ if (textPtr->selTagPtr->selBorder == NULL) { - textPtr->selTagPtr->border = textPtr->selBorder; + textPtr->selTagPtr->border = textPtr->selBorder; } else { - textPtr->selTagPtr->selBorder = textPtr->selBorder; + textPtr->selTagPtr->selBorder = textPtr->selBorder; } if (textPtr->selTagPtr->borderWidthPtr != textPtr->selBorderWidthPtr) { textPtr->selTagPtr->borderWidthPtr = textPtr->selBorderWidthPtr; textPtr->selTagPtr->borderWidth = textPtr->selBorderWidth; } if (textPtr->selTagPtr->selFgColor == NULL) { - textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; + textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; } else { - textPtr->selTagPtr->selFgColor = textPtr->selFgColorPtr; + textPtr->selTagPtr->selFgColor = textPtr->selFgColorPtr; } textPtr->selTagPtr->affectsDisplay = 0; textPtr->selTagPtr->affectsDisplayGeometry = 0; @@ -2296,11 +2296,11 @@ ConfigureText( || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) || (textPtr->selTagPtr->overstrikeString != NULL) - || (textPtr->selTagPtr->overstrikeColor != NULL) + || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) || (textPtr->selTagPtr->underlineColor != NULL) - || (textPtr->selTagPtr->lMarginColor != NULL) - || (textPtr->selTagPtr->rMarginColor != NULL)) { + || (textPtr->selTagPtr->lMarginColor != NULL) + || (textPtr->selTagPtr->rMarginColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); @@ -2424,7 +2424,7 @@ TextWorldChanged( textPtr->charHeight = 1; } if (textPtr->charHeight != oldCharHeight) { - TkBTreeClientRangeChanged(textPtr, textPtr->charHeight); + TkBTreeClientRangeChanged(textPtr, textPtr->charHeight); } border = textPtr->borderWidth + textPtr->highlightWidth; Tk_GeometryRequest(textPtr->tkwin, @@ -2876,7 +2876,7 @@ TextPushUndoAction( } if (!canUndo || canRedo) { - GenerateUndoStackEvent(textPtr); + GenerateUndoStackEvent(textPtr); } } @@ -3214,11 +3214,11 @@ DeleteIndexRange( resetView = 1; line = line1; byteIndex = tPtr->topIndex.byteIndex; - } else { - /* - * Deletion range starts after the top line. This peers's view - * will not need to be reset. Nothing to do. - */ + } else { + /* + * Deletion range starts after the top line. This peers's view + * will not need to be reset. Nothing to do. + */ } } else if (index2.linePtr == tPtr->topIndex.linePtr) { /* @@ -3235,11 +3235,11 @@ DeleteIndexRange( } else { byteIndex -= (index2.byteIndex - index1.byteIndex); } - } else { - /* - * Deletion range ends before the top line. This peers's view - * will not need to be reset. Nothing to do. - */ + } else { + /* + * Deletion range ends before the top line. This peers's view + * will not need to be reset. Nothing to do. + */ } if (resetView) { lineAndByteIndex[resetViewCount] = line; @@ -3284,43 +3284,43 @@ DeleteIndexRange( TkTextIndex indexTmp; if (tPtr == textPtr) { - if (viewUpdate) { - /* - * line cannot be before -startline of textPtr because - * this line corresponds to an index which is necessarily - * between "1.0" and "end" relative to textPtr. - * Therefore no need to clamp line to the -start/-end - * range. - */ + if (viewUpdate) { + /* + * line cannot be before -startline of textPtr because + * this line corresponds to an index which is necessarily + * between "1.0" and "end" relative to textPtr. + * Therefore no need to clamp line to the -start/-end + * range. + */ TkTextMakeByteIndex(sharedTextPtr->tree, textPtr, line, byteIndex, &indexTmp); TkTextSetYView(tPtr, &indexTmp, 0); } } else { - TkTextMakeByteIndex(sharedTextPtr->tree, tPtr, line, + TkTextMakeByteIndex(sharedTextPtr->tree, tPtr, line, byteIndex, &indexTmp); - /* - * line may be before -startline of tPtr and must be - * clamped to -startline before providing it to - * TkTextSetYView otherwise lines before -startline - * would be displayed. - * There is no need to worry about -endline however, - * because the view will only be reset if the deletion - * involves the TOP line of the screen - */ - - if (tPtr->start != NULL) { - int start; - TkTextIndex indexStart; - - start = TkBTreeLinesTo(NULL, tPtr->start); - TkTextMakeByteIndex(sharedTextPtr->tree, NULL, start, + /* + * line may be before -startline of tPtr and must be + * clamped to -startline before providing it to + * TkTextSetYView otherwise lines before -startline + * would be displayed. + * There is no need to worry about -endline however, + * because the view will only be reset if the deletion + * involves the TOP line of the screen + */ + + if (tPtr->start != NULL) { + int start; + TkTextIndex indexStart; + + start = TkBTreeLinesTo(NULL, tPtr->start); + TkTextMakeByteIndex(sharedTextPtr->tree, NULL, start, 0, &indexStart); - if (TkTextIndexCmp(&indexTmp, &indexStart) < 0) { - indexTmp = indexStart; - } - } + if (TkTextIndexCmp(&indexTmp, &indexStart) < 0) { + indexTmp = indexStart; + } + } TkTextSetYView(tPtr, &indexTmp, 0); } } @@ -5172,7 +5172,7 @@ TextEditCmd( static const char *const editOptionStrings[] = { "canundo", "canredo", "modified", "redo", "reset", "separator", - "undo", NULL + "undo", NULL }; enum editOptions { EDIT_CANUNDO, EDIT_CANREDO, EDIT_MODIFIED, EDIT_REDO, EDIT_RESET, @@ -5191,25 +5191,25 @@ TextEditCmd( switch ((enum editOptions) index) { case EDIT_CANREDO: - if (objc != 3) { - Tcl_WrongNumArgs(interp, 3, objv, NULL); - return TCL_ERROR; - } - if (textPtr->sharedTextPtr->undo) { - canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); - } - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canRedo)); - break; + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + if (textPtr->sharedTextPtr->undo) { + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); + } + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canRedo)); + break; case EDIT_CANUNDO: - if (objc != 3) { - Tcl_WrongNumArgs(interp, 3, objv, NULL); - return TCL_ERROR; - } - if (textPtr->sharedTextPtr->undo) { - canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); - } - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canUndo)); - break; + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + if (textPtr->sharedTextPtr->undo) { + canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); + } + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(canUndo)); + break; case EDIT_MODIFIED: if (objc == 3) { Tcl_SetObjResult(interp, @@ -5243,36 +5243,36 @@ TextEditCmd( */ if ((!oldModified) != (!setModified)) { - GenerateModifiedEvent(textPtr); + GenerateModifiedEvent(textPtr); } break; case EDIT_REDO: - if (objc != 3) { + if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); 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; } - canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); - if (!canUndo || !canRedo) { - GenerateUndoStackEvent(textPtr); - } + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); + if (!canUndo || !canRedo) { + GenerateUndoStackEvent(textPtr); + } break; case EDIT_RESET: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } - canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); - canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); + canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); TkUndoClearStacks(textPtr->sharedTextPtr->undoStack); - if (canUndo || canRedo) { - GenerateUndoStackEvent(textPtr); - } + if (canUndo || canRedo) { + GenerateUndoStackEvent(textPtr); + } break; case EDIT_SEPARATOR: if (objc != 3) { @@ -5282,20 +5282,20 @@ TextEditCmd( TkUndoInsertUndoSeparator(textPtr->sharedTextPtr->undoStack); break; case EDIT_UNDO: - if (objc != 3) { + if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } - canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); + canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); if (TextEditUndo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL); return TCL_ERROR; } - canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); - if (!canRedo || !canUndo) { - GenerateUndoStackEvent(textPtr); - } + canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); + if (!canRedo || !canUndo) { + GenerateUndoStackEvent(textPtr); + } break; } return TCL_OK; @@ -5390,8 +5390,8 @@ TextGetText( * * Send an event that the text was modified. This is equivalent to: * event generate $textWidget <> - * for all peers of $textWidget. -* + * for all peers of $textWidget. + * * Results: * None * @@ -5406,9 +5406,9 @@ GenerateModifiedEvent( TkText *textPtr) /* Information about text widget. */ { for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL; - textPtr = textPtr->next) { - Tk_MakeWindowExist(textPtr->tkwin); - TkSendVirtualEvent(textPtr->tkwin, "Modified", NULL); + textPtr = textPtr->next) { + Tk_MakeWindowExist(textPtr->tkwin); + TkSendVirtualEvent(textPtr->tkwin, "Modified", NULL); } } @@ -5436,9 +5436,9 @@ GenerateUndoStackEvent( TkText *textPtr) /* Information about text widget. */ { for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL; - textPtr = textPtr->next) { - Tk_MakeWindowExist(textPtr->tkwin); - TkSendVirtualEvent(textPtr->tkwin, "UndoStack", NULL); + textPtr = textPtr->next) { + Tk_MakeWindowExist(textPtr->tkwin); + TkSendVirtualEvent(textPtr->tkwin, "UndoStack", NULL); } } @@ -5493,7 +5493,7 @@ UpdateDirtyFlag( } if (sharedTextPtr->isDirty == 0 || oldDirtyFlag == 0) { - GenerateModifiedEvent(sharedTextPtr->peers); + GenerateModifiedEvent(sharedTextPtr->peers); } } @@ -5522,21 +5522,21 @@ RunAfterSyncCmd( int code; if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { - /* - * The widget has been deleted. Don't do anything. - */ + /* + * The widget has been deleted. Don't do anything. + */ - if (--textPtr->refCount == 0) { - ckfree((char *) textPtr); - } - return; + if (--textPtr->refCount == 0) { + ckfree((char *) textPtr); + } + return; } Tcl_Preserve((ClientData) textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); if (code == TCL_ERROR) { - Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)"); - Tcl_BackgroundError(textPtr->interp); + Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)"); + Tcl_BackgroundError(textPtr->interp); } Tcl_Release((ClientData) textPtr->interp); Tcl_DecrRefCount(textPtr->afterSyncCmd); -- cgit v0.12 From a4f23e43240cacd74f2c10961ddd6ee145d92b53 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 21 Jun 2016 14:31:03 +0000 Subject: Start bringing Tk_Init up to date with facilities Tcl provides. --- generic/tkWindow.c | 41 ++++++++++++++--------------------------- tests/safe.test | 2 +- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/generic/tkWindow.c b/generic/tkWindow.c index b5cbbab..9405a05 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -3084,7 +3084,7 @@ Initialize( * master. */ - Tcl_DString ds; + Tcl_Obj *cmd; /* * Step 1 : find the master and construct the interp name (could be a @@ -3095,7 +3095,7 @@ Initialize( Tcl_Interp *master = interp; - while (1) { + while (Tcl_IsSafe(master)) { master = Tcl_GetMaster(master); if (master == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -3104,10 +3104,6 @@ Initialize( code = TCL_ERROR; goto done; } - if (!Tcl_IsSafe(master)) { - /* Found the trusted master. */ - break; - } } /* @@ -3116,39 +3112,30 @@ Initialize( code = Tcl_GetInterpPath(master, interp); if (code != TCL_OK) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "error in Tcl_GetInterpPath", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "FAILED", NULL); - goto done; + Tcl_Panic("Tcl_GetInterpPath broken!"); } /* - * Build the string to eval. + * Build the command to eval in trusted master. */ - Tcl_DStringInit(&ds); - Tcl_DStringAppendElement(&ds, "::safe::TkInit"); - Tcl_DStringAppendElement(&ds, Tcl_GetString(Tcl_GetObjResult(master))); - + cmd = Tcl_NewListObj(2, NULL); + Tcl_ListObjAppendElement(NULL, cmd, + Tcl_NewStringObj("::safe::TkInit", -1)); + Tcl_ListObjAppendElement(NULL, cmd, Tcl_GetObjResult(master)); + /* * Step 2 : Eval in the master. The argument is the *reversed* interp * path of the slave. */ - code = Tcl_EvalEx(master, Tcl_DStringValue(&ds), -1, 0); + Tcl_IncrRefCount(cmd); + code = Tcl_EvalObjEx(master, cmd, 0); + Tcl_DecrRefCount(cmd); + Tcl_TransferResult(master, code, interp); if (code != TCL_OK) { - /* - * We might want to transfer the error message or not. We don't. - * (No API to do it and maybe security reasons). - */ - - Tcl_DStringFree(&ds); - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "not allowed to start Tk by master's safe::TkInit", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "FAILED", NULL); goto done; } - Tcl_DStringFree(&ds); /* * Use the master's result as argv. Note: We don't use the Obj @@ -3156,7 +3143,7 @@ Initialize( * changing the code below. */ - argString = Tcl_GetString(Tcl_GetObjResult(master)); + argString = Tcl_GetString(Tcl_GetObjResult(interp)); } else { /* * If there is an "argv" variable, get its value, extract out relevant diff --git a/tests/safe.test b/tests/safe.test index e7ed6c7..69a67ba 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -187,7 +187,7 @@ test safe-5.1 {loading Tk in safe interps without master's clearance} -body { interp eval $i {load {} Tk} } -cleanup { safe::interpDelete $i -} -returnCodes error -result {not allowed to start Tk by master's safe::TkInit} +} -returnCodes error -result {not allowed} test safe-5.2 {multi-level Tk loading with clearance} -setup { set safeParent [safe::interpCreate] } -body { -- cgit v0.12 From c79aece8e069fedc176a325933523974a0460cb8 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 21 Jun 2016 20:31:52 +0000 Subject: work in progress --- generic/tkFrame.c | 24 +++++ generic/tkInt.h | 3 + generic/tkWindow.c | 272 +++++++++++++++++++++++++---------------------------- 3 files changed, 155 insertions(+), 144 deletions(-) diff --git a/generic/tkFrame.c b/generic/tkFrame.c index 057b4b8..f6edfb0 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -447,6 +447,30 @@ TkCreateFrame( return result; } +int +TkListCreateFrame( + ClientData clientData, /* Either NULL or pointer to option table. */ + Tcl_Interp *interp, /* Current interpreter. */ + Tcl_Obj *listObj, /* List of arguments. */ + int toplevel, /* Non-zero means create a toplevel window, + * zero means create a frame. */ + Tcl_Obj *nameObj) /* Should only be non-NULL if there is no main + * window associated with the interpreter. + * Gives the base name to use for the new + * application. */ + +{ + int objc; + Tcl_Obj **objv; + + if (TCL_OK != Tcl_ListObjGetElements(interp, listObj, &objc, &objv)) { + return TCL_ERROR; + } + return CreateFrame(clientData, interp, objc, objv, + toplevel ? TYPE_TOPLEVEL : TYPE_FRAME, + nameObj ? Tcl_GetString(nameObj) : NULL); +} + static int CreateFrame( ClientData clientData, /* NULL. */ diff --git a/generic/tkInt.h b/generic/tkInt.h index 029f0f1..dd5dcad 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1217,6 +1217,9 @@ MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp, MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp, ClientData clientData); MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr); +MODULE_SCOPE int TkListCreateFrame(ClientData clientData, + Tcl_Interp *interp, Tcl_Obj *listObj, + int toplevel, Tcl_Obj *nameObj); #ifdef _WIN32 #define TkParseColor XParseColor diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 9405a05..47b29bd 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -54,12 +54,6 @@ typedef struct ThreadSpecificData { static Tcl_ThreadDataKey dataKey; /* - * The Mutex below is used to lock access to the Tk_Uid structs above. - */ - -TCL_DECLARE_MUTEX(windowMutex) - -/* * Default values for "changes" and "atts" fields of TkWindows. Note that Tk * always requests all events for all windows, except StructureNotify events * on internal windows: these events are generated internally. @@ -206,40 +200,6 @@ static const TkCmd commands[] = { }; /* - * The variables and table below are used to parse arguments from the "argv" - * variable in Tk_Init. - */ - -static int synchronize = 0; -static char *name = NULL; -static char *display = NULL; -static char *geometry = NULL; -static char *colormap = NULL; -static char *use = NULL; -static char *visual = NULL; -static int rest = 0; - -static const Tk_ArgvInfo argTable[] = { - {"-colormap", TK_ARGV_STRING, NULL, (char *) &colormap, - "Colormap for main window"}, - {"-display", TK_ARGV_STRING, NULL, (char *) &display, - "Display to use"}, - {"-geometry", TK_ARGV_STRING, NULL, (char *) &geometry, - "Initial geometry for window"}, - {"-name", TK_ARGV_STRING, NULL, (char *) &name, - "Name to use for application"}, - {"-sync", TK_ARGV_CONSTANT, (char *) 1, (char *) &synchronize, - "Use synchronous mode for display server"}, - {"-visual", TK_ARGV_STRING, NULL, (char *) &visual, - "Visual for main window"}, - {"-use", TK_ARGV_STRING, NULL, (char *) &use, - "Id of window in which to embed application"}, - {"--", TK_ARGV_REST, (char *) 1, (char *) &rest, - "Pass all remaining arguments through to script"}, - {NULL, TK_ARGV_END, NULL, NULL, NULL} -}; - -/* * Forward declarations to functions defined later in this file: */ @@ -3028,16 +2988,51 @@ MODULE_SCOPE const TkStubs tkStubs; */ static int +CopyValue( + ClientData dummy, + Tcl_Obj *objPtr, + void *dstPtr) +{ + dstPtr = objPtr; + return 1; +} + +static int Initialize( Tcl_Interp *interp) /* Interpreter to initialize. */ { - char *p; - int argc, code; - const char **argv; - const char *args[20]; - const char *argString = NULL; - Tcl_DString class; + int code = TCL_OK; ThreadSpecificData *tsdPtr; + Tcl_Obj *value = NULL; + Tcl_Obj *cmd; + + Tcl_Obj *nameObj = NULL; + Tcl_Obj *classObj = NULL; + Tcl_Obj *displayObj = NULL; + Tcl_Obj *colorMapObj = NULL; + Tcl_Obj *useObj = NULL; + Tcl_Obj *visualObj = NULL; + Tcl_Obj *geometryObj = NULL; + + int sync = 0; + + const Tcl_ArgvInfo table[] = { + {TCL_ARGV_CONSTANT, "-sync", INT2PTR(1), &sync, + "Use synchronous mode for display server", NULL}, + {TCL_ARGV_FUNC, "-colormap", CopyValue, &colorMapObj, + "Colormap for main window", NULL}, + {TCL_ARGV_FUNC, "-display", CopyValue, &displayObj, + "Display to use", NULL}, + {TCL_ARGV_FUNC, "-geometry", CopyValue, &geometryObj, + "Initial geometry for window", NULL}, + {TCL_ARGV_FUNC, "-name", CopyValue, &nameObj, + "Name to use for application", NULL}, + {TCL_ARGV_FUNC, "-visual", CopyValue, &visualObj, + "Visual for main window", NULL}, + {TCL_ARGV_FUNC, "-use", CopyValue, &useObj, + "Id of window in which to embed application", NULL}, + TCL_ARGV_AUTO_REST, TCL_ARGV_AUTO_HELP, TCL_ARGV_TABLE_END + }; /* * Ensure that we are getting a compatible version of Tcl. @@ -3056,23 +3051,6 @@ Initialize( tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* - * Start by initializing all the static variables to default acceptable - * values so that no information is leaked from a previous run of this - * code. - */ - - Tcl_MutexLock(&windowMutex); - synchronize = 0; - name = NULL; - display = NULL; - geometry = NULL; - colormap = NULL; - use = NULL; - visual = NULL; - rest = 0; - argv = NULL; - - /* * We start by resetting the result because it might not be clean. */ @@ -3084,8 +3062,6 @@ Initialize( * master. */ - Tcl_Obj *cmd; - /* * Step 1 : find the master and construct the interp name (could be a * function if new APIs were ok). We could also construct the path @@ -3101,8 +3077,7 @@ Initialize( Tcl_SetObjResult(interp, Tcl_NewStringObj( "no controlling master interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_MASTER", NULL); - code = TCL_ERROR; - goto done; + return TCL_ERROR; } } @@ -3134,7 +3109,7 @@ Initialize( Tcl_DecrRefCount(cmd); Tcl_TransferResult(master, code, interp); if (code != TCL_OK) { - goto done; + return code; } /* @@ -3143,7 +3118,7 @@ Initialize( * changing the code below. */ - argString = Tcl_GetString(Tcl_GetObjResult(interp)); + value = Tcl_GetObjResult(interp); } else { /* * If there is an "argv" variable, get its value, extract out relevant @@ -3151,50 +3126,67 @@ Initialize( * that we used. */ - argString = Tcl_GetVar2(interp, "argv", NULL, TCL_GLOBAL_ONLY); + value = Tcl_GetVar2Ex(interp, "argv", NULL, TCL_GLOBAL_ONLY); } - if (argString != NULL) { - char buffer[TCL_INTEGER_SPACE]; - if (Tcl_SplitList(interp, argString, &argc, &argv) != TCL_OK) { - argError: + if (value) { + int objc; + Tcl_Obj **objv, **rest; + Tcl_Obj *parseList = Tcl_NewListObj(1, NULL); + + Tcl_ListObjAppendElement(NULL, parseList, Tcl_NewObj()); + + Tcl_IncrRefCount(value); + if (TCL_OK != Tcl_ListObjAppendList(interp, parseList, value) || + TCL_OK != Tcl_ListObjGetElements(NULL, parseList, &objc, &objv) || + TCL_OK != Tcl_ParseArgsObjv(interp, table, &objc, objv, &rest)) { Tcl_AddErrorInfo(interp, "\n (processing arguments in argv variable)"); code = TCL_ERROR; - goto done; } - if (Tk_ParseArgv(interp, (Tk_Window) NULL, &argc, argv, - argTable, TK_ARGV_DONT_SKIP_FIRST_ARG|TK_ARGV_NO_DEFAULTS) - != TCL_OK) { - goto argError; + if (code == TCL_OK) { + Tcl_SetVar2Ex(interp, "argv", NULL, + Tcl_NewListObj(objc-1, rest+1), TCL_GLOBAL_ONLY); + Tcl_SetVar2Ex(interp, "argc", NULL, + Tcl_NewIntObj(objc-1), TCL_GLOBAL_ONLY); + ckfree(rest); + } + Tcl_DecrRefCount(parseList); + if (code != TCL_OK) { + goto done; } - p = Tcl_Merge(argc, argv); - Tcl_SetVar2(interp, "argv", NULL, p, TCL_GLOBAL_ONLY); - sprintf(buffer, "%d", argc); - Tcl_SetVar2(interp, "argc", NULL, buffer, TCL_GLOBAL_ONLY); - ckfree(p); } /* * Figure out the application's name and class. */ - Tcl_DStringInit(&class); - if (name == NULL) { - int offset; + /* + * If we got no -name argument, fetch from TkpGetAppName(). + */ + + if (nameObj == NULL) { + Tcl_DString nameDS; - TkpGetAppName(interp, &class); - offset = Tcl_DStringLength(&class)+1; - Tcl_DStringSetLength(&class, offset); - Tcl_DStringAppend(&class, Tcl_DStringValue(&class), offset-1); - name = Tcl_DStringValue(&class) + offset; - } else { - Tcl_DStringAppend(&class, name, -1); + Tcl_DStringInit(&nameDS); + TkpGetAppName(interp, &nameDS); + nameObj = Tcl_NewStringObj(Tcl_DStringValue(&nameDS), + Tcl_DStringLength(&nameDS)); + Tcl_DStringFree(&nameDS); } - p = Tcl_DStringValue(&class); - if (*p) { - Tcl_UtfToTitle(p); + /* + * The -class argument is always the ToTitle of the -name + */ + + { + int numBytes; + const char *bytes = Tcl_GetStringFromObj(nameObj, &numBytes); + + classObj = Tcl_NewStringObj(bytes, numBytes); + + numBytes = Tcl_UtfToTitle(Tcl_GetString(classObj)); + Tcl_SetObjLength(classObj, numBytes); } /* @@ -3202,15 +3194,14 @@ Initialize( * information parsed from argv, if any. */ - args[0] = "toplevel"; - args[1] = "."; - args[2] = "-class"; - args[3] = Tcl_DStringValue(&class); - argc = 4; - if (display != NULL) { - args[argc] = "-screen"; - args[argc+1] = display; - argc += 2; + cmd = Tcl_NewStringObj("toplevel . -class", -1); + + Tcl_ListObjAppendElement(NULL, cmd, classObj); + classObj = NULL; + + if (displayObj) { + Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-screen", -1)); + Tcl_ListObjAppendElement(NULL, cmd, displayObj); /* * If this is the first application for this process, save the display @@ -3219,36 +3210,35 @@ Initialize( */ if (tsdPtr->numMainWindows == 0) { - Tcl_SetVar2(interp, "env", "DISPLAY", display, TCL_GLOBAL_ONLY); + Tcl_SetVar2Ex(interp, "env", "DISPLAY", displayObj, TCL_GLOBAL_ONLY); } + displayObj = NULL; } - if (colormap != NULL) { - args[argc] = "-colormap"; - args[argc+1] = colormap; - argc += 2; - colormap = NULL; + if (colorMapObj) { + Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-colormap", -1)); + Tcl_ListObjAppendElement(NULL, cmd, colorMapObj); + colorMapObj = NULL; } - if (use != NULL) { - args[argc] = "-use"; - args[argc+1] = use; - argc += 2; - use = NULL; + if (useObj) { + Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-use", -1)); + Tcl_ListObjAppendElement(NULL, cmd, useObj); + useObj = NULL; } - if (visual != NULL) { - args[argc] = "-visual"; - args[argc+1] = visual; - argc += 2; - visual = NULL; + if (visualObj) { + Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-visual", -1)); + Tcl_ListObjAppendElement(NULL, cmd, visualObj); + visualObj = NULL; } - args[argc] = NULL; - code = TkCreateFrame(NULL, interp, argc, args, 1, name); - Tcl_DStringFree(&class); + code = TkListCreateFrame(NULL, interp, cmd, 1, nameObj); + + Tcl_DecrRefCount(cmd); + if (code != TCL_OK) { goto done; } Tcl_ResetResult(interp); - if (synchronize) { + if (sync) { XSynchronize(Tk_Display(Tk_MainWindow(interp)), True); } @@ -3257,19 +3247,19 @@ Initialize( * geometry into the "geometry" variable. */ - if (geometry != NULL) { - Tcl_DString buf; + if (geometryObj) { - Tcl_SetVar2(interp, "geometry", NULL, geometry, TCL_GLOBAL_ONLY); - Tcl_DStringInit(&buf); - Tcl_DStringAppend(&buf, "wm geometry . ", -1); - Tcl_DStringAppend(&buf, geometry, -1); - code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0); - Tcl_DStringFree(&buf); + Tcl_SetVar2Ex(interp, "geometry", NULL, geometryObj, TCL_GLOBAL_ONLY); + + cmd = Tcl_NewStringObj("wm geometry .", -1); + Tcl_ListObjAppendElement(NULL, cmd, geometryObj); + Tcl_IncrRefCount(cmd); + code = Tcl_EvalObjEx(interp, cmd, 0); + Tcl_DecrRefCount(cmd); + geometryObj = NULL; if (code != TCL_OK) { goto done; } - geometry = NULL; } /* @@ -3306,10 +3296,6 @@ Initialize( * console window interpreter. */ - Tcl_MutexUnlock(&windowMutex); - if (argv != NULL) { - ckfree(argv); - } code = TkpInit(interp); if (code == TCL_OK) { @@ -3342,12 +3328,10 @@ tkInit", -1, 0); TkCreateThreadExitHandler(DeleteWindowsExitProc, tsdPtr); } - return code; - done: - Tcl_MutexUnlock(&windowMutex); - if (argv != NULL) { - ckfree(argv); + if (value) { + Tcl_DecrRefCount(value); + value = NULL; } return code; } -- cgit v0.12 From 43275fa6b210f53456fdd27679904f49a53ebbed Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 21 Jun 2016 21:19:31 +0000 Subject: Fixup the typecasting --- generic/tkWindow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 47b29bd..7afb031 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -2993,7 +2993,7 @@ CopyValue( Tcl_Obj *objPtr, void *dstPtr) { - dstPtr = objPtr; + *(Tcl_Obj **)dstPtr = objPtr; return 1; } -- cgit v0.12 From 4468bc4cb1e0e653f7602d9333640b5f6a9fbcf0 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 22 Jun 2016 17:48:38 +0000 Subject: [787adc5ed7] Workaround potential crash in Tcl_DStringAppend. --- generic/tkWindow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkWindow.c b/generic/tkWindow.c index f2e98e8..4ac2849 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -3175,7 +3175,7 @@ Initialize( TkpGetAppName(interp, &class); offset = Tcl_DStringLength(&class)+1; - Tcl_DStringSetLength(&class, offset); + Tcl_DStringSetLength(&class, 2*offset); Tcl_DStringAppend(&class, Tcl_DStringValue(&class), offset-1); name = Tcl_DStringValue(&class) + offset; } else { -- cgit v0.12 From 1c53ec442dddd830aecdcb7eaf90d19634177250 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 26 Jun 2016 20:18:50 +0000 Subject: Fixed typos --- doc/FindPhoto.3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/FindPhoto.3 b/doc/FindPhoto.3 index dea7e05..e4d83f0 100644 --- a/doc/FindPhoto.3 +++ b/doc/FindPhoto.3 @@ -191,8 +191,8 @@ Also, changes made by writing directly to \fIpixelPtr\fR will not be immediately visible, but only after a call to \fBTk_ImageChanged\fR or after an event that causes the interested widgets to redraw themselves. -For these reasons usually it is preferrable to make changes to -a copy a of the image data and write it back with +For these reasons usually it is preferable to make changes to +a copy of the image data and write it back with \fBTk_PhotoPutBlock\fR or \fBTk_PhotoPutZoomedBlock\fR. .PP \fBTk_PhotoGetImage\fR returns 1 for compatibility with the -- cgit v0.12 From 2336f2329bfb57ef247c9fb277bb06fabf27f85f Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 28 Jun 2016 21:25:51 +0000 Subject: [ce92c79bc6] Improve the 'configure' method of the internal megawidget framework. Thanks to Schelte Bron for pointing out the problems with it. --- library/megawidget.tcl | 169 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 160 insertions(+), 9 deletions(-) diff --git a/library/megawidget.tcl b/library/megawidget.tcl index 9b9be92..aeb1263 100644 --- a/library/megawidget.tcl +++ b/library/megawidget.tcl @@ -29,14 +29,13 @@ package require Tk 8.6 } ::oo::class create ::tk::MegawidgetClass { - variable w hull OptionSpecification options IdleCallbacks + variable w hull options IdleCallbacks constructor args { # Extract the "widget name" from the object name set w [namespace tail [self]] # Configure things - set OptionSpecification [my GetSpecs] - my configure {*}$args + tclParseConfigSpec [my varname options] [my GetSpecs] "" $args # Move the object out of the way of the hull widget rename [self] _tmp @@ -46,7 +45,7 @@ package require Tk 8.6 bind $hull [list [namespace which my] destroy] # Rename things into their final places - rename ::$w theFrame + rename ::$w theWidget rename [self] ::$w # Make the contents @@ -63,28 +62,165 @@ package require Tk 8.6 } } + #################################################################### + # + # MegawidgetClass::configure -- + # + # Implementation of 'configure' for megawidgets. Emulates the operation + # of the standard Tk configure method fairly closely, which makes things + # substantially more complex than they otherwise would be. + # + # This method assumes that the 'GetSpecs' method returns a description + # of all the specifications of the options (i.e., as Tk returns except + # with the actual values removed). It also assumes that the 'options' + # array in the class holds all options; it is up to subclasses to set + # traces on that array if they want to respond to configuration changes. + # + # TODO: allow unambiguous abbreviations. + # method configure args { - tclParseConfigSpec [my varname options] $OptionSpecification "" $args + # Configure behaves differently depending on the number of arguments + set argc [llength $args] + if {$argc == 0} { + return [lmap spec [my GetSpecs] { + lappend spec $options([lindex $spec 0]) + }] + } elseif {$argc == 1} { + set opt [lindex $args 0] + if {[info exists options($opt)]} { + set spec [lsearch -inline -index 0 -exact [my GetSpecs] $opt] + return [linsert $spec end $options($opt)] + } + } elseif {$argc == 2} { + # Special case for where we're setting a single option. This + # avoids some of the costly operations. We still do the [array + # get] as this gives a sufficiently-consistent trace. + set opt [lindex $args 0] + if {[dict exists [array get options] $opt]} { + # Actually set the new value of the option. Use a catch to + # allow a megawidget user to throw an error from a write trace + # on the options array to reject invalid values. + try { + array set options $args + } on error {ret info} { + # Rethrow the error to get a clean stack trace + return -code error -errorcode [dict get $info -errorcode] $ret + } + return + } + } elseif {$argc % 2 == 0} { + # Check that all specified options exist. Any unknown option will + # cause the merged dictionary to be bigger than the options array + set merge [dict merge [array get options] $args] + if {[dict size $merge] == [array size options]} { + # Actually set the new values of the options. Use a catch to + # allow a megawidget user to throw an error from a write trace + # on the options array to reject invalid values + try { + array set options $args + } on error {ret info} { + # Rethrow the error to get a clean stack trace + return -code error -errorcode [dict get $info -errorcode] $ret + } + return + } + # Due to the order of the merge, the unknown options will be at + # the end of the dict. This makes the first unknown option easy to + # find. + set opt [lindex [dict keys $merge] [array size options]] + } else { + set opt [lindex $args end] + return -code error -errorcode [list TK VALUE_MISSING] \ + "value for \"$opt\" missing" + } + return -code error -errorcode [list TK LOOKUP OPTION $opt] \ + "bad option \"$opt\": must be [tclListValidFlags options]" } + + #################################################################### + # + # MegawidgetClass::cget -- + # + # Implementation of 'cget' for megawidgets. Emulates the operation of + # the standard Tk cget method fairly closely. + # + # This method assumes that the 'options' array in the class holds all + # options; it is up to subclasses to set traces on that array if they + # want to respond to configuration reads. + # + # TODO: allow unambiguous abbreviations. + # method cget option { return $options($option) } + #################################################################### + # + # MegawidgetClass::TraceOption -- + # + # Sets up the tracing of an element of the options variable. + # + method TraceOption {option method args} { + set callback [list my $method {*}$args] + trace add variable options($option) write [namespace code $callback] + } + + #################################################################### + # + # MegawidgetClass::GetSpecs -- + # + # Return a list of descriptions of options supported by this + # megawidget. Each option is described by the 4-tuple list, consisting + # of the name of the option, the "option database" name, the "option + # database" class-name, and the default value of the option. These are + # the same values returned by calling the configure method of a widget, + # except without the current values of the options. + # method GetSpecs {} { return { {-takefocus takeFocus TakeFocus {}} } } + #################################################################### + # + # MegawidgetClass::CreateHull -- + # + # Creates the real main widget of the megawidget. This is often a frame + # or toplevel widget, but isn't always (lightweight megawidgets might + # use a content widget directly). + # + # The name of the hull widget is given by the 'w' instance variable. The + # name should be written into the 'hull' instance variable. The command + # created by this method will be renamed. + # method CreateHull {} { return -code error -errorcode {TCL OO ABSTRACT_METHOD} \ "method must be overridden" } + + #################################################################### + # + # MegawidgetClass::Create -- + # + # Creates the content of the megawidget. The name of the widget to + # create the content in will be in the 'hull' instance variable. + # method Create {} { return -code error -errorcode {TCL OO ABSTRACT_METHOD} \ "method must be overridden" } + #################################################################### + # + # MegawidgetClass::WhenIdle -- + # + # Arrange for a method to be called on the current instance when Tk is + # idle. Only one such method call per method will be queued; subsequent + # queuing actions before the callback fires will be silently ignored. + # The additional args will be passed to the callback, and the callbacks + # will be properly cancelled if the widget is destroyed. + # method WhenIdle {method args} { if {![info exists IdleCallbacks($method)]} { set IdleCallbacks($method) [after idle [list \ @@ -97,6 +233,15 @@ package require Tk 8.6 } } +#################################################################### +# +# tk::SimpleWidget -- +# +# Simple megawidget class that makes it easy create widgets that behave +# like a ttk widget. It creates the hull as a ttk::frame and maps the +# state manipulation methods of the overall megawidget to the equivalent +# operations on the ttk::frame. +# ::tk::Megawidget create ::tk::SimpleWidget {} { variable w hull options method GetSpecs {} { @@ -107,12 +252,12 @@ package require Tk 8.6 } method CreateHull {} { set hull [::ttk::frame $w -cursor $options(-cursor)] - trace add variable options(-cursor) write \ - [namespace code {my UpdateCursorOption}] + my TraceOption -cursor UpdateCursorOption } method UpdateCursorOption args { $hull configure -cursor $options(-cursor) } + # Not fixed names, so can't forward method state args { tailcall $hull state {*}$args } @@ -121,6 +266,13 @@ package require Tk 8.6 } } +#################################################################### +# +# tk::FocusableWidget -- +# +# Simple megawidget class that makes a ttk-like widget that has a focus +# ring. +# ::tk::Megawidget create ::tk::FocusableWidget ::tk::SimpleWidget { variable w hull options method GetSpecs {} { @@ -133,8 +285,7 @@ package require Tk 8.6 ttk::frame $w set hull [ttk::entry $w.cHull -takefocus 0 -cursor $options(-cursor)] pack $hull -expand yes -fill both -ipadx 2 -ipady 2 - trace add variable options(-cursor) write \ - [namespace code {my UpdateCursorOption}] + my TraceOption -cursor UpdateCursorOption } } -- cgit v0.12 From 3ff177d9afa1b11b8c17918825f3265fb4e5dbab Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 6 Jul 2016 03:00:40 +0000 Subject: Fix for excessive label padding in Tk/Mac; thanks to Brad Lanam for bug report --- macosx/tkMacOSXButton.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index ebbcf09..f4fbc48 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -318,7 +318,8 @@ TkpComputeButtonGeometry( Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength, butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); - txtWidth = butPtr->textWidth + DEF_INSET_LEFT + DEF_INSET_RIGHT; + /*Remove extraneous padding around label widgets.*/ + txtWidth = butPtr->textWidth; txtHeight = butPtr->textHeight + DEF_INSET_BOTTOM + DEF_INSET_TOP; charWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); Tk_GetFontMetrics(butPtr->tkfont, &fm); -- cgit v0.12 From c32ea9203392ec7c24b873842e0d0d84b66830cc Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Fri, 8 Jul 2016 01:21:02 +0000 Subject: Fix for bitmap distortion on Mac OS; thanks to Marc Culler for patch --- macosx/tkMacOSXDraw.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 6a0b409..d9b909b 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -314,29 +314,35 @@ XCopyPlane( TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask; unsigned long imageBackground = gc->background; if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP){ - CGImageRef mask = TkMacOSXCreateCGImageWithDrawable(clipPtr->value.pixmap); - CGRect rect = CGRectMake(dest_x, dest_y, width, height); - rect = CGRectOffset(rect, dstDraw->xOff, dstDraw->yOff); - CGContextSaveGState(context); - /* Move the origin of the destination to top left. */ - CGContextTranslateCTM(context, 0, rect.origin.y + CGRectGetMaxY(rect)); - CGContextScaleCTM(context, 1, -1); - /* Fill with the background color, clipping to the mask. */ - CGContextClipToMask(context, rect, mask); - TkMacOSXSetColorInContext(gc, gc->background, dc.context); - CGContextFillRect(dc.context, rect); - /* Fill with the foreground color, clipping to the intersection of img and mask. */ - CGContextClipToMask(context, rect, img); - TkMacOSXSetColorInContext(gc, gc->foreground, context); - CGContextFillRect(context, rect); - CGContextRestoreGState(context); - CGImageRelease(mask); - CGImageRelease(img); + CGRect srcRect = CGRectMake(src_x, src_y, width, height); + CGImageRef mask = TkMacOSXCreateCGImageWithDrawable(clipPtr->value.pixmap); + CGImageRef submask = CGImageCreateWithImageInRect(img, srcRect); + CGRect rect = CGRectMake(dest_x, dest_y, width, height); + rect = CGRectOffset(rect, dstDraw->xOff, dstDraw->yOff); + CGContextSaveGState(context); + /* Move the origin of the destination to top left. */ + CGContextTranslateCTM(context, 0, rect.origin.y + CGRectGetMaxY(rect)); + CGContextScaleCTM(context, 1, -1); + /* Fill with the background color, clipping to the mask. */ + CGContextClipToMask(context, rect, submask); + TkMacOSXSetColorInContext(gc, gc->background, dc.context); + CGContextFillRect(context, rect); + /* Fill with the foreground color, clipping to the + intersection of img and mask. */ + CGImageRef subimage = CGImageCreateWithImageInRect(img, srcRect); + CGContextClipToMask(context, rect, subimage); + TkMacOSXSetColorInContext(gc, gc->foreground, context); + CGContextFillRect(context, rect); + CGContextRestoreGState(context); + CGImageRelease(img); + CGImageRelease(mask); + CGImageRelease(submask); + CGImageRelease(subimage); } else { DrawCGImage(dst, gc, dc.context, img, gc->foreground, imageBackground, CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height), - CGRectMake(src_x, src_y, width, height), - CGRectMake(dest_x, dest_y, width, height)); + CGRectMake(src_x, src_y, width, height), + CGRectMake(dest_x, dest_y, width, height)); CGImageRelease(img); } } else { /* no image */ @@ -786,9 +792,6 @@ DrawCGImage( CGContextDrawImage(context, dstBounds, image); CGContextRestoreGState(context); #endif /* TK_MAC_DEBUG_IMAGE_DRAWING */ - /*if (CGImageIsMask(image)) { - CGContextRestoreGState(context); - }*/ if (subImage) { CFRelease(subImage); } -- cgit v0.12 From 2ae13e10ac2c3c86584cece38298da049533e803 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Fri, 15 Jul 2016 10:47:18 +0000 Subject: Fix for image/alpha rendering under hidpi/Retina displays on Mac OS; thanks to Marc Culler for assistance --- generic/tkImgPhInstance.c | 25 +++++++++++++++++++++++-- macosx/tkMacOSXDraw.c | 6 ++++-- macosx/tkMacOSXXStubs.c | 37 ++++++++++++++++++++++++++++++------- xlib/X11/Xlib.h | 3 +++ 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 666a9b0..bd152f2 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -404,6 +404,9 @@ TkImgPhotoGet( * * Note that Win32 pre-defines those operations that we really need. * + * Note that on MacOS, if the background comes from a Retina display + * then it will be twice as wide and twice as high as the photoimage. + * *---------------------------------------------------------------------- */ @@ -433,7 +436,16 @@ BlendComplexAlpha( unsigned long pixel; unsigned char r, g, b, alpha, unalpha, *masterPtr; unsigned char *alphaAr = iPtr->masterPtr->pix32; - +#if defined(MAC_OSX_TK) + /* Background "pixels" are actually 2^pp x 2^pp blocks of subpixels. Each + * block gets blended with the color of one image pixel. Since we iterate + * over the background subpixels, we reset the width and height to the + * subpixel dimensions of the background image we are using. + */ + int pp = bgImg->pixelpower; + width = width << pp; + height = height << pp; +#endif /* * This blending is an integer version of the Source-Over compositing rule * (see Porter&Duff, "Compositing Digital Images", proceedings of SIGGRAPH @@ -532,9 +544,16 @@ BlendComplexAlpha( #endif /* !_WIN32 && !MAC_OSX_TK */ for (y = 0; y < height; y++) { +# if !defined(MAC_OSX_TK) line = (y + yOffset) * iPtr->masterPtr->width; for (x = 0; x < width; x++) { masterPtr = alphaAr + ((line + x + xOffset) * 4); +#else + /* Repeat each image row and column 2^pp times. */ + line = ((y>>pp) + yOffset) * iPtr->masterPtr->width; + for (x = 0; x < width; x++) { + masterPtr = alphaAr + ((line + (x>>pp) + xOffset) * 4); +#endif alpha = masterPtr[3]; /* @@ -635,7 +654,9 @@ TkImgPhotoDisplay( (unsigned int)width, (unsigned int)height, AllPlanes, ZPixmap); if (bgImg == NULL) { Tk_DeleteErrorHandler(handler); - /* We failed to get the image so draw without blending alpha. It's the best we can do */ + /* We failed to get the image, so draw without blending alpha. + * It's the best we can do. + */ goto fallBack; } diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index d9b909b..f48538d 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -399,9 +399,11 @@ TkPutImage( CGImageRef img = CreateCGImageWithXImage(image); if (img) { + /* If the XImage has big pixels, rescale the source dimensions.*/ + int pp = image->pixelpower; DrawCGImage(d, gc, dc.context, img, gc->foreground, gc->background, - CGRectMake(0, 0, image->width, image->height), - CGRectMake(src_x, src_y, width, height), + CGRectMake(0, 0, image->width<height<format = format; ximage->data = data; ximage->obdata = NULL; + /* The default pixelpower is 0. This must be explicitly set to 1 in the + * case of an XImage extracted from a Retina display. + */ + ximage->pixelpower = 0; if (format == ZPixmap) { ximage->bits_per_pixel = 32; @@ -856,7 +860,8 @@ XCreateImage( * Results: * Returns a newly allocated XImage containing the data from the given * rectangle of the given drawable, or NULL if the XImage could not be - * constructed. + * constructed. NOTE: If we are copying from a window on a Retina + * display, the dimensions of the XImage will be 2*width x 2*height. * * Side effects: * None. @@ -885,7 +890,19 @@ XGetImage( int bitmap_pad = 0; int bytes_per_row = 4*width; int size; - TkMacOSXDbgMsg("XGetImage"); + MacDrawable *macDraw = (MacDrawable *) d; + NSWindow *win = TkMacOSXDrawableWindow(d); + /* This code assumes that backing scale factors are integers. Currently + * Retina displays use a scale factor of 2.0 and normal displays use 1.0. + * We do not support any other values here. + */ + int scalefactor = 1; + if (win && [win respondsToSelector:@selector(backingScaleFactor)]) { + scalefactor = ([win backingScaleFactor] == 2.0) ? 2 : 1; + } + int scaled_height = height * scalefactor; + int scaled_width = width * scalefactor; + if (format == ZPixmap) { if (width == 0 || height == 0) { /* This happens all the time. @@ -894,7 +911,7 @@ XGetImage( return NULL; } - bitmap_rep = BitmapRepFromDrawableRect(d, x, y,width, height); + bitmap_rep = BitmapRepFromDrawableRect(d, x, y, width, height); bitmap_fmt = [bitmap_rep bitmapFormat]; if ( bitmap_rep == Nil || @@ -913,7 +930,9 @@ XGetImage( if ( [bitmap_rep isPlanar ] == 0 && [bitmap_rep samplesPerPixel] == 4 ) { bytes_per_row = [bitmap_rep bytesPerRow]; - size = bytes_per_row*height; + assert(bytes_per_row == 4 * scaled_width); + assert([bitmap_rep bytesPerPlane] == bytes_per_row * scaled_height); + size = bytes_per_row*scaled_height; image_data = (char*)[bitmap_rep bitmapData]; if ( image_data ) { int row, n, m; @@ -924,7 +943,7 @@ XGetImage( */ if (bitmap_fmt == 0) { /* BGRA */ - for (row=0, n=0; rowpixelpower = 1; + } [ns_image removeRepresentation:bitmap_rep]; /*releases the rep*/ [ns_image release]; } diff --git a/xlib/X11/Xlib.h b/xlib/X11/Xlib.h index 667bdc7..8d8ec68 100644 --- a/xlib/X11/Xlib.h +++ b/xlib/X11/Xlib.h @@ -330,6 +330,9 @@ typedef struct _XImage { unsigned long green_mask; unsigned long blue_mask; XPointer obdata; /* hook for the object routines to hang on */ +#if defined(MAC_OSX_TK) + int pixelpower; /* n such that pixels are 2^n x 2^n blocks*/ +#endif struct funcs { /* image manipulation routines */ struct _XImage *(*create_image)(); #if NeedFunctionPrototypes -- cgit v0.12 From 238b8d68c514e0bca1a97dea4d50a4badedf2111 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 17 Jul 2016 03:19:10 +0000 Subject: Fix for Ticket c84f660833546b1b84e7fd3aef930c2f17207461 (Tk crashes when toplevel placed on second display, Mac); thanks to Marc Culler for patch --- macosx/tkMacOSXSubwindows.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index f026318..d9e1d63 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -153,8 +153,6 @@ XMapWindow( if ( [win canBecomeKeyWindow] ) { [win makeKeyAndOrderFront:NSApp]; } - /* Why do we need this? (It is used by Carbon)*/ - [win windowRef]; TkMacOSXApplyWindowAttributes(macWin->winPtr, win); } TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr); @@ -316,7 +314,6 @@ XResizeWindow( display->request++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { NSWindow *w = macWin->winPtr->wmInfoPtr->window; - if (w) { NSRect r = [w contentRectForFrameRect:[w frame]]; r.origin.y += r.size.height - height; @@ -360,10 +357,19 @@ XMoveResizeWindow( if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { NSWindow *w = macWin->winPtr->wmInfoPtr->window; if (w) { - NSRect r = NSMakeRect(x + macWin->winPtr->wmInfoPtr->xInParent, - tkMacOSXZeroScreenHeight - (y + - macWin->winPtr->wmInfoPtr->yInParent + height), - width, height); + /* We explicitly convert everything to doubles so we don't get + * surprised (again) by what happens when you do arithmetic with + * unsigned ints. + */ + CGFloat X = (CGFloat)x; + CGFloat Y = (CGFloat)y; + CGFloat Width = (CGFloat)width; + CGFloat Height = (CGFloat)height; + CGFloat XOff = (CGFloat)macWin->winPtr->wmInfoPtr->xInParent; + CGFloat YOff = (CGFloat)macWin->winPtr->wmInfoPtr->yInParent; + NSRect r = NSMakeRect(X + XOff, + tkMacOSXZeroScreenHeight - Y - YOff, + Width, Height); [w setFrame:[w frameRectForContentRect:r] display:YES]; } } else { -- cgit v0.12 From 2aa945d6a8109c74d9ff3331fb99a093635e0cd7 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Tue, 19 Jul 2016 23:48:19 +0000 Subject: Final tweak for OS X wm crash, thanks to Marc Culler --- macosx/tkMacOSXSubwindows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index d9e1d63..9851474 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -368,7 +368,7 @@ XMoveResizeWindow( CGFloat XOff = (CGFloat)macWin->winPtr->wmInfoPtr->xInParent; CGFloat YOff = (CGFloat)macWin->winPtr->wmInfoPtr->yInParent; NSRect r = NSMakeRect(X + XOff, - tkMacOSXZeroScreenHeight - Y - YOff, + tkMacOSXZeroScreenHeight - Y - YOff - Height, Width, Height); [w setFrame:[w frameRectForContentRect:r] display:YES]; } -- cgit v0.12