summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorericm <ericm>2000-08-02 23:08:19 (GMT)
committerericm <ericm>2000-08-02 23:08:19 (GMT)
commit7d67184a277c2923bc3f951b256ad643113c6a8e (patch)
tree59f48b5c69b01befbf1cab053c896977fd387000 /generic
parentd27ee63662ac46121aeb974aad912fa29bce12d5 (diff)
downloadtk-7d67184a277c2923bc3f951b256ad643113c6a8e.zip
tk-7d67184a277c2923bc3f951b256ad643113c6a8e.tar.gz
tk-7d67184a277c2923bc3f951b256ad643113c6a8e.tar.bz2
* generic/tkCmds.c (Tk_TkwaitObjCmd): Tcl_Obj'ified [tkwait] command.
* generic/tkWindow.c: Updated "tkwait" command entry to use Tcl_Obj'ified command. * generic/tkInt.h: Replace Tk_TkwaitCmd prototype with Tk_TkwaitObjCmd prototype.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkCmds.c148
-rw-r--r--generic/tkInt.h7
-rw-r--r--generic/tkWindow.c4
3 files changed, 85 insertions, 74 deletions
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
index 7c98aa6..2718d03 100644
--- a/generic/tkCmds.c
+++ b/generic/tkCmds.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: tkCmds.c,v 1.14 2000/05/17 22:44:09 hobbs Exp $
+ * RCS: @(#) $Id: tkCmds.c,v 1.15 2000/08/02 23:08:20 ericm Exp $
*/
#include "tkPort.h"
@@ -695,7 +695,7 @@ Tk_TkObjCmd(clientData, interp, objc, objv)
/*
*----------------------------------------------------------------------
*
- * Tk_TkwaitCmd --
+ * Tk_TkwaitObjCmd --
*
* This procedure is invoked to process the "tkwait" Tcl command.
* See the user documentation for details on what it does.
@@ -711,87 +711,97 @@ Tk_TkObjCmd(clientData, interp, objc, objv)
/* ARGSUSED */
int
-Tk_TkwaitCmd(clientData, interp, argc, argv)
+Tk_TkwaitObjCmd(clientData, interp, objc, objv)
ClientData clientData; /* Main window associated with
* interpreter. */
Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
+ int objc; /* Number of arguments. */
+ Tcl_Obj *CONST objv[]; /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window) clientData;
- int c, done;
- size_t length;
+ int done, index;
+ static char *optionStrings[] = { "variable", "visibility", "window",
+ (char *) NULL };
+ enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
+
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
+ return TCL_ERROR;
+ }
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " variable|visibility|window name\"", (char *) NULL);
+ if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
+ &index) != TCL_OK) {
return TCL_ERROR;
}
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'v') && (strncmp(argv[1], "variable", length) == 0)
- && (length >= 2)) {
- if (Tcl_TraceVar(interp, argv[2],
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- WaitVariableProc, (ClientData) &done) != TCL_OK) {
- return TCL_ERROR;
- }
- done = 0;
- while (!done) {
- Tcl_DoOneEvent(0);
- }
- Tcl_UntraceVar(interp, argv[2],
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- WaitVariableProc, (ClientData) &done);
- } else if ((c == 'v') && (strncmp(argv[1], "visibility", length) == 0)
- && (length >= 2)) {
- Tk_Window window;
- window = Tk_NameToWindow(interp, argv[2], tkwin);
- if (window == NULL) {
- return TCL_ERROR;
+ switch ((enum options) index) {
+ case TKWAIT_VARIABLE: {
+ if (Tcl_TraceVar(interp, Tcl_GetString(objv[2]),
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ done = 0;
+ while (!done) {
+ Tcl_DoOneEvent(0);
+ }
+ Tcl_UntraceVar(interp, Tcl_GetString(objv[2]),
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done);
+ break;
}
- Tk_CreateEventHandler(window, VisibilityChangeMask|StructureNotifyMask,
- WaitVisibilityProc, (ClientData) &done);
- done = 0;
- while (!done) {
- Tcl_DoOneEvent(0);
+
+ case TKWAIT_VISIBILITY: {
+ Tk_Window window;
+
+ window = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin);
+ if (window == NULL) {
+ return TCL_ERROR;
+ }
+ Tk_CreateEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ WaitVisibilityProc, (ClientData) &done);
+ done = 0;
+ while (!done) {
+ Tcl_DoOneEvent(0);
+ }
+ if (done != 1) {
+ /*
+ * Note that we do not delete the event handler because it
+ * was deleted automatically when the window was destroyed.
+ */
+
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "window \"", Tcl_GetString(objv[2]),
+ "\" was deleted before its visibility changed",
+ (char *) NULL);
+ return TCL_ERROR;
+ }
+ Tk_DeleteEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ WaitVisibilityProc, (ClientData) &done);
+ break;
}
- if (done != 1) {
+
+ case TKWAIT_WINDOW: {
+ Tk_Window window;
+
+ window = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin);
+ if (window == NULL) {
+ return TCL_ERROR;
+ }
+ Tk_CreateEventHandler(window, StructureNotifyMask,
+ WaitWindowProc, (ClientData) &done);
+ done = 0;
+ while (!done) {
+ Tcl_DoOneEvent(0);
+ }
/*
- * Note that we do not delete the event handler because it
- * was deleted automatically when the window was destroyed.
+ * Note: there's no need to delete the event handler. It was
+ * deleted automatically when the window was destroyed.
*/
-
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "window \"", argv[2],
- "\" was deleted before its visibility changed",
- (char *) NULL);
- return TCL_ERROR;
- }
- Tk_DeleteEventHandler(window, VisibilityChangeMask|StructureNotifyMask,
- WaitVisibilityProc, (ClientData) &done);
- } else if ((c == 'w') && (strncmp(argv[1], "window", length) == 0)) {
- Tk_Window window;
-
- window = Tk_NameToWindow(interp, argv[2], tkwin);
- if (window == NULL) {
- return TCL_ERROR;
- }
- Tk_CreateEventHandler(window, StructureNotifyMask,
- WaitWindowProc, (ClientData) &done);
- done = 0;
- while (!done) {
- Tcl_DoOneEvent(0);
+ break;
}
- /*
- * Note: there's no need to delete the event handler. It was
- * deleted automatically when the window was destroyed.
- */
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be variable, visibility, or window", (char *) NULL);
- return TCL_ERROR;
}
/*
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 81e4bd1..d2e7d95 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.26 2000/08/02 01:33:33 ericm Exp $
+ * RCS: $Id: tkInt.h,v 1.27 2000/08/02 23:08:20 ericm Exp $
*/
#ifndef _TKINT
@@ -1000,8 +1000,9 @@ EXTERN int Tk_TextCmd _ANSI_ARGS_((ClientData clientData,
EXTERN int Tk_TkObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
-EXTERN int Tk_TkwaitCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
+EXTERN int Tk_TkwaitObjCmd _ANSI_ARGS_((ClientData clientData,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *CONST objv[]));
EXTERN int Tk_ToplevelObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *CONST objv[]));
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index c2bc9fb..7578c0f 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.19 2000/08/02 01:33:33 ericm Exp $
+ * RCS: @(#) $Id: tkWindow.c,v 1.20 2000/08/02 23:08:20 ericm Exp $
*/
#include "tkPort.h"
@@ -115,7 +115,7 @@ static TkCmd commands[] = {
{"raise", NULL, Tk_RaiseObjCmd, 1, 1},
{"selection", Tk_SelectionCmd, NULL, 0, 1},
{"tk", NULL, Tk_TkObjCmd, 0, 1},
- {"tkwait", Tk_TkwaitCmd, NULL, 1, 1},
+ {"tkwait", NULL, Tk_TkwaitObjCmd, 1, 1},
#if defined(__WIN32__) || defined(MAC_TCL)
{"tk_chooseColor", NULL, Tk_ChooseColorObjCmd, 0, 1},
{"tk_chooseDirectory", NULL, Tk_ChooseDirectoryObjCmd, 0, 1},