summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--generic/tkEntry.c20
-rw-r--r--generic/tkInt.h5
-rw-r--r--generic/tkText.c39
-rw-r--r--generic/tkTextBTree.c7
-rw-r--r--generic/tkTextDisp.c12
-rw-r--r--generic/tkWindow.c40
-rw-r--r--library/tk.tcl9
-rw-r--r--unix/tkUnixPort.h9
9 files changed, 98 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index b88b3ee..0ae2375 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2006-09-06 Jeff Hobbs <jeffh@ActiveState.com>
+ * 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:
+
* generic/tkText.c (DeleteChars): backport of 8.5 text delete
speedup that removes tags from deleted area first. [Bug 1456342]
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
diff --git a/library/tk.tcl b/library/tk.tcl
index 60e807b..4ce180f 100644
--- a/library/tk.tcl
+++ b/library/tk.tcl
@@ -3,7 +3,7 @@
# Initialization script normally executed in the interpreter for each
# Tk-based application. Arranges class bindings for widgets.
#
-# RCS: @(#) $Id: tk.tcl,v 1.46.2.3 2006/01/25 18:21:41 dgp Exp $
+# RCS: @(#) $Id: tk.tcl,v 1.46.2.4 2006/09/06 22:01:26 hobbs Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
@@ -20,7 +20,7 @@ package require -exact Tcl 8.4
namespace eval ::tk {
# Set up the msgcat commands
namespace eval msgcat {
- namespace export mc mcmax
+ namespace export mc mcmax
if {[interp issafe] || [catch {package require msgcat}]} {
# The msgcat package is not available. Supply our own
# minimal replacement.
@@ -344,7 +344,7 @@ if {[info command tk_chooseDirectory] eq ""} {
return [eval ::tk::dialog::file::chooseDir:: $args]
}
}
-
+
#----------------------------------------------------------------------
# Define the set of common virtual events.
#----------------------------------------------------------------------
@@ -369,6 +369,9 @@ switch [tk windowingsystem] {
trace add variable ::tk_strictMotif write ::tk::EventMotifBindings
set ::tk_strictMotif $::tk_strictMotif
+ # On unix, we want to always display entry/text selection,
+ # regardless of which window has focus
+ set ::tk::AlwaysShowSelection 1
}
"win32" {
event add <<Cut>> <Control-Key-x> <Shift-Key-Delete>
diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h
index 223e160..9ca19e7 100644
--- a/unix/tkUnixPort.h
+++ b/unix/tkUnixPort.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: tkUnixPort.h,v 1.8.2.1 2006/03/13 18:19:01 dgp Exp $
+ * RCS: @(#) $Id: tkUnixPort.h,v 1.8.2.2 2006/09/06 22:01:26 hobbs Exp $
*/
#ifndef _UNIXPORT
@@ -202,13 +202,6 @@
sprintf((buf), "%#08lx", (unsigned long) (w))
/*
- * This macro indicates that entry and text widgets should display
- * the selection highlight regardless of which window has the focus.
- */
-
-#define ALWAYS_SHOW_SELECTION
-
-/*
* The following declaration is used to get access to a private Tcl interface
* that is needed for portability reasons.
*/