From b953acd1adcee2fe7ed421057e3777dfc262d8a3 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 6b9f74b94131d093483c64f7ceabf120c0d7cafc 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 d71ad7c875011c2a2316b2ddea67184dbc874e2b 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 805fcdaf248860dc18393f6057e20658717c2456 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 5f7fc554638bca715178872239e12d3af70873e7 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 6c9bfa9fd65f656771dfae771ae084c936bffcc7 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 e9eb040566b7acbcd65658273c897ca92f28e961 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 e07cc72f16cbe99171e74b22132575f9827d298e 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 cfda4cad423c9d190e8ef313abb2fde96fac95ec 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 301474e0cb79bc9057a9bce0d96a595194eb3256 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 199597ae00067ebb743923a3958f7543e64507fe 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 4b575b58dce1e0d4b71eea75120c6d1a7ccc71b2 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 4b0858ce51227f71e7d9835ea25060c0bcc03d3d 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 83aa3068c39588ffa2bd61df5338a0f1936ef997 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 e852090eebf396bdcb0664be5722171dd88afefc 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 fefc3f4a1f2283804ec0b894bc2829910e28c181 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 ba1f867ffc2d20e016e251f7ec8e36cb0cacb570 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 976013e1d050d7ace1bf0af0fe1f59d43ab7e327 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 d7d3c32de08fbf3b6f30c619475a0623f2d9c919 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 f43794e951d2b2331a240723a593e47ba6b7e31b 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 5cafc16d94f20c0dcdd7e54203ae353b6d077171 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 72cebab7ec06894d54c3923a7b9dfcf1fda3539f 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 bfc0e68c24746362ccf16c7907dfa9da6b6cb7a7 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 c8dabf74db56545232a68b807db99bcc9fe8623c 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 f2c83432d562ac26c807364d38ee02de96e145a2 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 a2f7d5ff11fca87060c1bb7bda5034e7ef6ce529 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 519495544a6cd4d25dbc6e67bec287f2bf4c8d3b 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 066e1ea2f98b7472f540eb63571a56557244d3f4 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 ef72d15557c5d17d8810a8c16a52edf7af887680 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 e00cb4a0748e0dba9ab54cfca500b67da37eb880 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 b202e08b8181a7fa344925469b6f61db1095e610 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 67c2fd8a68c9de080c59b696883599f5ef4afcb4 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 1a644790652ad4a2ac88f72002c07da5bdc50330 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 8f511c765e83351d579cd979acca4716c8d12a9d 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 9a0550fd1ec02f31a286fd2bb3ae52de8f766e51 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 31fb09c715cebd3a070ef5d80d47bace123acd8b 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 65b38b266578bb228a5ee208e85882ab7c3ccaba 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 ae89da7f55a5eb900a5d5fbcad002ce5b1ba5456 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 754a4bf8c1a1249177f99eb567c7744cd57415de 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 55332a033ec9aaf19d4b328ba3c2ea03ada2b368 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 -- cgit v0.12 From c3cd22c6fba7fe228267b501d84ccb2976bf2f1b 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 d12d5b41f2b6cd0cf1ba2c23de29e1594d7c5bdc 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 437b969154ff6901480fd045efb10d62a95264a0 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 374b27a9b3859f485714da057074137ed4cbc90a 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 938a781fc060670163d405d5a24f516587b37161 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 5d5d4600fd16c6a67cac090fc11728c0a68c8c9f 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 4188122ab8f39802c6b1f7446aa4fe34c73ca22b 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 f065a5d5abea56c47d49c6646ca7b0f0e110259e 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 005349642a0dd00d953ca5c1bb64c2a026ee6402 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 1b8e0125b84845a3b0ba6b69d6c4894aa15627f2 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