summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--generic/tkEntry.c23
-rw-r--r--generic/tkInt.h5
-rw-r--r--generic/tkText.c43
-rw-r--r--generic/tkWindow.c41
-rw-r--r--library/tk.tcl9
-rw-r--r--macosx/tkMacOSXDefault.h3
-rw-r--r--unix/tkUnixDefault.h3
-rw-r--r--unix/tkUnixPort.h9
-rw-r--r--win/tkWinDefault.h3
10 files changed, 101 insertions, 50 deletions
diff --git a/ChangeLog b/ChangeLog
index e64775f..93144c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+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/tkWindow.c: controlled by ::tk::AlwaysShowSelection
+ * library/tk.tcl: (boolean, private). [Bug 1553691]
+ * macosx/tkMacOSXDefault.h:
+ * unix/tkUnixDefault.h:
+ * unix/tkUnixPort.h:
+ * win/tkWinDefault.h:
+
2006-08-30 Jeff Hobbs <jeffh@ActiveState.com>
* win/tkWinKey.c: Add WM_UNICHAR window message support (used by
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index 6f97c0c..1d9d084 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.39 2005/11/17 10:57:35 dkf Exp $
+ * RCS: @(#) $Id: tkEntry.c,v 1.40 2006/09/06 22:39:28 hobbs Exp $
*/
#include "tkInt.h"
@@ -1602,15 +1602,14 @@ DisplayEntry(
baseY = (Tk_Height(tkwin) + fm.ascent - fm.descent) / 2;
/*
- * On Windows and Mac, we need to hide the selection whenever we don't
- * have the focus.
+ * Hide the selection whenever we don't have the focus, unless we
+ * always want to show selection.
*/
-
-#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 layers are:
@@ -2790,15 +2789,15 @@ EntryLostSelection(
* 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.
+ * 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 40d1272..3ad218e 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.72 2006/08/18 10:24:41 dkf Exp $
+ * RCS: $Id: tkInt.h,v 1.73 2006/09/06 22:39:28 hobbs Exp $
*/
#ifndef _TKINT
@@ -651,6 +651,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;
@@ -1159,6 +1161,7 @@ MODULE_SCOPE void TkPrintPadAmount(Tcl_Interp *interp,
MODULE_SCOPE int TkParsePadAmount(Tcl_Interp *interp,
Tk_Window tkwin, Tcl_Obj *objPtr,
int *pad1Ptr, int *pad2Ptr);
+MODULE_SCOPE int TkpAlwaysShowSelection(Tk_Window tkwin);
MODULE_SCOPE void TkpDrawCharsInContext(Display * display,
Drawable drawable, GC gc, Tk_Font tkfont,
const char * source, int numBytes, int rangeStart,
diff --git a/generic/tkText.c b/generic/tkText.c
index aeb40bb..56e016f 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -13,7 +13,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.68 2006/04/05 17:16:29 vincentdarley Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.69 2006/09/06 22:39:28 hobbs Exp $
*/
#include "default.h"
@@ -160,11 +160,7 @@ static Tk_OptionSpec optionSpecs[] = {
Tk_Offset(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_BORDER, "-inactiveselectbackground", "inactiveSelectBackground",
"Foreground",
-#ifdef ALWAYS_SHOW_SELECTION
- DEF_TEXT_SELECT_COLOR,
-#else
- NULL,
-#endif
+ DEF_TEXT_INACTIVE_SELECT_COLOR,
-1, Tk_Offset(TkText, inactiveSelBorder),
TK_OPTION_NULL_OK, (ClientData) DEF_TEXT_SELECT_MONO, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
@@ -3316,25 +3312,28 @@ TkTextLostSelection(clientData)
ClientData clientData; /* Information about text widget. */
{
register TkText *textPtr = (TkText *) clientData;
-#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->sharedTextPtr->tree, textPtr, 0, 0, &start);
- TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr,
- TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), 0, &end);
- TkTextRedrawTag(NULL, 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->sharedTextPtr->tree, textPtr,
+ 0, 0, &start);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr,
+ TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr),
+ 0, &end);
+ TkTextRedrawTag(NULL, 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/tkWindow.c b/generic/tkWindow.c
index 324ed0c..e3c5295 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.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: tkWindow.c,v 1.75 2006/07/14 18:25:14 andreas_kupries Exp $
+ * RCS: @(#) $Id: tkWindow.c,v 1.76 2006/09/06 22:39:28 hobbs Exp $
*/
#include "tkPort.h"
@@ -888,10 +888,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;
@@ -1502,6 +1511,8 @@ 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);
@@ -2652,6 +2663,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 function is invoked as an exit handler. It deletes all of the
diff --git a/library/tk.tcl b/library/tk.tcl
index ce3d937..ad45cbb 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.56 2006/01/25 18:22:04 dgp Exp $
+# RCS: @(#) $Id: tk.tcl,v 1.57 2006/09/06 22:39:28 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.5
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.
@@ -340,7 +340,7 @@ if {![llength [info command tk_chooseDirectory]]} {
return [::tk::dialog::file::chooseDir:: {expand}$args]
}
}
-
+
#----------------------------------------------------------------------
# Define the set of common virtual events.
#----------------------------------------------------------------------
@@ -365,6 +365,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/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h
index 14eb937..dc8b07d 100644
--- a/macosx/tkMacOSXDefault.h
+++ b/macosx/tkMacOSXDefault.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: tkMacOSXDefault.h,v 1.9 2005/10/10 10:36:35 vincentdarley Exp $
+ * RCS: @(#) $Id: tkMacOSXDefault.h,v 1.10 2006/09/06 22:39:28 hobbs Exp $
*/
#ifndef _TKMACDEFAULT
@@ -511,6 +511,7 @@
#define DEF_TEXT_PADX "1"
#define DEF_TEXT_PADY "1"
#define DEF_TEXT_RELIEF "flat"
+#define DEF_TEXT_INACTIVE_SELECT_COLOR NULL
#define DEF_TEXT_SELECT_COLOR SELECT_BG
#define DEF_TEXT_SELECT_MONO BLACK
#define DEF_TEXT_SELECT_BD_COLOR "1"
diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h
index ec3777c..7ea67f5 100644
--- a/unix/tkUnixDefault.h
+++ b/unix/tkUnixDefault.h
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixDefault.h,v 1.23 2006/03/29 16:27:20 dgp Exp $
+ * RCS: @(#) $Id: tkUnixDefault.h,v 1.24 2006/09/06 22:39:28 hobbs Exp $
*/
#ifndef _TKUNIXDEFAULT
@@ -502,6 +502,7 @@
#define DEF_TEXT_PADX "1"
#define DEF_TEXT_PADY "1"
#define DEF_TEXT_RELIEF "sunken"
+#define DEF_TEXT_INACTIVE_SELECT_COLOR SELECT_BG
#define DEF_TEXT_SELECT_COLOR SELECT_BG
#define DEF_TEXT_SELECT_MONO BLACK
#define DEF_TEXT_SELECT_BD_COLOR "1"
diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h
index 7092840..e8d4c67 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.11 2006/03/13 18:19:19 dgp Exp $
+ * RCS: @(#) $Id: tkUnixPort.h,v 1.12 2006/09/06 22:39:28 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.
*
diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h
index 3f30f5f..e0946c6 100644
--- a/win/tkWinDefault.h
+++ b/win/tkWinDefault.h
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinDefault.h,v 1.20 2005/10/10 10:36:35 vincentdarley Exp $
+ * RCS: @(#) $Id: tkWinDefault.h,v 1.21 2006/09/06 22:39:28 hobbs Exp $
*/
#ifndef _TKWINDEFAULT
@@ -489,6 +489,7 @@
#define DEF_TEXT_PADX "1"
#define DEF_TEXT_PADY "1"
#define DEF_TEXT_RELIEF "sunken"
+#define DEF_TEXT_INACTIVE_SELECT_COLOR NULL
#define DEF_TEXT_SELECT_COLOR SELECT_BG
#define DEF_TEXT_SELECT_MONO BLACK
#define DEF_TEXT_SELECT_BD_COLOR "0"