diff options
author | hobbs <hobbs> | 2006-09-06 22:01:24 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2006-09-06 22:01:24 (GMT) |
commit | c1e05e3afb76356ef8e2d5af2a2ce3660c6bee48 (patch) | |
tree | 983074bdc91b005de21970a3ec98bae0c6d5af63 /generic | |
parent | 87caa3a60c4200a5a79707791643a555407a1271 (diff) | |
download | tk-c1e05e3afb76356ef8e2d5af2a2ce3660c6bee48.zip tk-c1e05e3afb76356ef8e2d5af2a2ce3660c6bee48.tar.gz tk-c1e05e3afb76356ef8e2d5af2a2ce3660c6bee48.tar.bz2 |
* generic/tkEntry.c: move hard-coded ALWAYS_SHOW_SELECTION
* generic/tkInt.h: control of entry/text selection display
* generic/tkText.c: based on focus to the Tcl level,
* generic/tkTextBTree.c: controlled by ::tk::AlwaysShowSelection
* generic/tkTextDisp.c: (boolean, private). [Bug 1553691]
* generic/tkWindow.c:
* library/tk.tcl
* unix/tkUnixPort.h:
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkEntry.c | 20 | ||||
-rw-r--r-- | generic/tkInt.h | 5 | ||||
-rw-r--r-- | generic/tkText.c | 39 | ||||
-rw-r--r-- | generic/tkTextBTree.c | 7 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 12 | ||||
-rw-r--r-- | generic/tkWindow.c | 40 |
6 files changed, 82 insertions, 41 deletions
diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 2894686..f98f446 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkEntry.c,v 1.35.2.1 2005/03/25 04:34:16 wolfsuit Exp $ + * RCS: @(#) $Id: tkEntry.c,v 1.35.2.2 2006/09/06 22:01:25 hobbs Exp $ */ #include "tkInt.h" @@ -1658,11 +1658,11 @@ DisplayEntry(clientData) * don't have the focus. */ -#ifdef ALWAYS_SHOW_SELECTION - showSelection = 1; -#else - showSelection = (entryPtr->flags & GOT_FOCUS); -#endif + if (TkpAlwaysShowSelection(entryPtr->tkwin)) { + showSelection = 1; + } else { + showSelection = (entryPtr->flags & GOT_FOCUS); + } /* * Draw the background in three layers. From bottom to top the @@ -2838,16 +2838,16 @@ EntryLostSelection(clientData) /* * On Windows and Mac systems, we want to remember the selection * for the next time the focus enters the window. On Unix, we need - * to clear the selection since it is always visible. + * to clear the selection since it is always visible. This is + * controlled by ::tk::AlwaysShowSelection. */ -#ifdef ALWAYS_SHOW_SELECTION - if ((entryPtr->selectFirst >= 0) && entryPtr->exportSelection) { + if (TkpAlwaysShowSelection(entryPtr->tkwin) + && (entryPtr->selectFirst >= 0) && entryPtr->exportSelection) { entryPtr->selectFirst = -1; entryPtr->selectLast = -1; EventuallyRedraw(entryPtr); } -#endif } /* diff --git a/generic/tkInt.h b/generic/tkInt.h index 848a8e9..1bfc008 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: $Id: tkInt.h,v 1.56.2.8 2006/06/05 18:06:47 dgp Exp $ + * RCS: $Id: tkInt.h,v 1.56.2.9 2006/09/06 22:01:25 hobbs Exp $ */ #ifndef _TKINT @@ -676,6 +676,8 @@ typedef struct TkMainInfo { * structures. Managed by tkImage.c. */ int strictMotif; /* This is linked to the tk_strictMotif * global variable. */ + int alwaysShowSelection; /* This is linked to the + * ::tk::AlwaysShowSelection variable. */ struct TkMainInfo *nextPtr; /* Next in list of all main windows managed by * this process. */ } TkMainInfo; @@ -1212,6 +1214,7 @@ EXTERN void TkPrintPadAmount _ANSI_ARGS_((Tcl_Interp *interp, EXTERN int TkParsePadAmount _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, int *pad1Ptr, int *pad2Ptr)); +EXTERN int TkpAlwaysShowSelection _ANSI_ARGS_((Tk_Window tkwin)); /* * Unsupported commands. diff --git a/generic/tkText.c b/generic/tkText.c index a06b90f..33edca7 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.33.2.2 2006/09/06 19:53:22 hobbs Exp $ + * RCS: @(#) $Id: tkText.c,v 1.33.2.3 2006/09/06 22:01:25 hobbs Exp $ */ #include "default.h" @@ -1281,9 +1281,9 @@ TextEventProc(clientData, eventPtr) textPtr->flags &= ~(GOT_FOCUS | INSERT_ON); textPtr->insertBlinkHandler = (Tcl_TimerToken) NULL; } -#ifndef ALWAYS_SHOW_SELECTION - TkTextRedrawTag(textPtr, NULL, NULL, textPtr->selTagPtr, 1); -#endif + if (!TkpAlwaysShowSelection(textPtr->tkwin)) { + TkTextRedrawTag(textPtr, NULL, NULL, textPtr->selTagPtr, 1); + } TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index); TkTextIndexForwChars(&index, 1, &index2); TkTextChanged(textPtr, &index, &index2); @@ -1896,24 +1896,25 @@ TkTextLostSelection(clientData) { register TkText *textPtr = (TkText *) clientData; XEvent event; -#ifdef ALWAYS_SHOW_SELECTION - TkTextIndex start, end; - if (!textPtr->exportSelection) { - return; - } + if (TkpAlwaysShowSelection(textPtr->tkwin)) { + TkTextIndex start, end; - /* - * On Windows and Mac systems, we want to remember the selection - * for the next time the focus enters the window. On Unix, - * just remove the "sel" tag from everything in the widget. - */ + if (!textPtr->exportSelection) { + return; + } - TkTextMakeByteIndex(textPtr->tree, 0, 0, &start); - TkTextMakeByteIndex(textPtr->tree, TkBTreeNumLines(textPtr->tree), 0, &end); - TkTextRedrawTag(textPtr, &start, &end, textPtr->selTagPtr, 1); - TkBTreeTag(&start, &end, textPtr->selTagPtr, 0); -#endif + /* + * On Windows and Mac systems, we want to remember the selection + * for the next time the focus enters the window. On Unix, + * just remove the "sel" tag from everything in the widget. + */ + + TkTextMakeByteIndex(textPtr->tree, 0, 0, &start); + TkTextMakeByteIndex(textPtr->tree, TkBTreeNumLines(textPtr->tree), 0, &end); + TkTextRedrawTag(textPtr, &start, &end, textPtr->selTagPtr, 1); + TkBTreeTag(&start, &end, textPtr->selTagPtr, 0); + } /* * Send an event that the selection changed. This is equivalent to diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 5c5fb86..5c4069e 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextBTree.c,v 1.6.2.1 2005/11/27 02:44:25 das Exp $ + * RCS: @(#) $Id: tkTextBTree.c,v 1.6.2.2 2006/09/06 22:01:25 hobbs Exp $ */ #include "tkInt.h" @@ -2550,13 +2550,12 @@ TkTextIsElided(textPtr, indexPtr) for (i = numTags-1; i >=0; i--) { if (tagCnts[i] & 1) { -#ifndef ALWAYS_SHOW_SELECTION /* who would make the selection elided? */ - if ((tagPtr == textPtr->selTagPtr) + if (!TkpAlwaysShowSelection(textPtr->tkwin) + && (tagPtr == textPtr->selTagPtr) && !(textPtr->flags & GOT_FOCUS)) { continue; } -#endif elide = tagPtrs[i]->elide; break; } diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 22a5a2e..e13766e 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextDisp.c,v 1.14.2.2 2006/04/05 19:48:07 hobbs Exp $ + * RCS: @(#) $Id: tkTextDisp.c,v 1.14.2.3 2006/09/06 22:01:26 hobbs Exp $ */ #include "tkPort.h" @@ -546,15 +546,15 @@ GetStyle(textPtr, indexPtr) tagPtr = tagPtrs[i]; /* - * On Windows and Mac, we need to skip the selection tag if - * we don't have focus. + * Skip the selection tag if we don't have focus, + * unless we always want to show the selection. */ -#ifndef ALWAYS_SHOW_SELECTION - if ((tagPtr == textPtr->selTagPtr) && !(textPtr->flags & GOT_FOCUS)) { + if (!TkpAlwaysShowSelection(textPtr->tkwin) + && (tagPtr == textPtr->selTagPtr) + && !(textPtr->flags & GOT_FOCUS)) { continue; } -#endif if ((tagPtr->border != NULL) && (tagPtr->priority > borderPrio)) { styleValues.border = tagPtr->border; diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 266ebeb..bf6676b 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWindow.c,v 1.56.2.10 2006/07/14 18:24:09 andreas_kupries Exp $ + * RCS: @(#) $Id: tkWindow.c,v 1.56.2.11 2006/09/06 22:01:26 hobbs Exp $ */ #include "tkPort.h" @@ -902,10 +902,19 @@ TkCreateMainWindow(interp, screenName, baseName) mainPtr->optionRootPtr = NULL; Tcl_InitHashTable(&mainPtr->imageTable, TCL_STRING_KEYS); mainPtr->strictMotif = 0; + mainPtr->alwaysShowSelection = 0; if (Tcl_LinkVar(interp, "tk_strictMotif", (char *) &mainPtr->strictMotif, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } + if (Tcl_CreateNamespace(interp, "::tk", NULL, NULL) == NULL) { + Tcl_ResetResult(interp); + } + if (Tcl_LinkVar(interp, "::tk::AlwaysShowSelection", + (char *) &mainPtr->alwaysShowSelection, + TCL_LINK_BOOLEAN) != TCL_OK) { + Tcl_ResetResult(interp); + } mainPtr->nextPtr = tsdPtr->mainWindowList; tsdPtr->mainWindowList = mainPtr; winPtr->mainPtr = mainPtr; @@ -1529,6 +1538,7 @@ Tk_DestroyWindow(tkwin) TkDeadAppCmd, (ClientData) NULL, (void (*) _ANSI_ARGS_((ClientData))) NULL); Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif"); + Tcl_UnlinkVar(winPtr->mainPtr->interp, "::tk::AlwaysShowSelection"); } Tcl_DeleteHashTable(&winPtr->mainPtr->nameTable); @@ -2690,6 +2700,34 @@ Tk_GetNumMainWindows() /* *---------------------------------------------------------------------- * + * TkpAlwaysShowSelection -- + * + * Indicates whether text/entry widgets should always display + * their selection, regardless of window focus. + * + * Results: + * The return value is 1 if always showing the selection has been + * requested for tkwin's application by setting the + * ::tk::AlwaysShowSelection variable in its interpreter to a true value. + * 0 is returned if it has a false value. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkpAlwaysShowSelection(tkwin) + Tk_Window tkwin; /* Window whose application is + * to be checked. */ +{ + return ((TkWindow *) tkwin)->mainPtr->alwaysShowSelection; +} + +/* + *---------------------------------------------------------------------- + * * DeleteWindowsExitProc -- * * This procedure is invoked as an exit handler. It deletes all |