summaryrefslogtreecommitdiffstats
path: root/generic/tkCmds.c
diff options
context:
space:
mode:
authorericm <ericm@noemail.net>2000-08-03 21:02:19 (GMT)
committerericm <ericm@noemail.net>2000-08-03 21:02:19 (GMT)
commitc5e11f8dc12919b9034d1e466fd731fa17ce95d0 (patch)
tree5af873be4a2bf0f9e0eef21003893de3571d64bf /generic/tkCmds.c
parent96de7fd1aa5ce7dcd4868b91ba15859e6a0cbbb1 (diff)
downloadtk-c5e11f8dc12919b9034d1e466fd731fa17ce95d0.zip
tk-c5e11f8dc12919b9034d1e466fd731fa17ce95d0.tar.gz
tk-c5e11f8dc12919b9034d1e466fd731fa17ce95d0.tar.bz2
* generic/tkInt.h: Replace Tk_BindCmd prototype with
Tk_BindObjCmd prototype. * generic/tkWindow.c: Updated "bind" command entry to use Tcl_Obj'ified command. * generic/tkCmds.c (Tk_BindObjCmd): Tcl_Obj'ified [bind] command. FossilOrigin-Name: 30698c56dc85982af1fda753f98c2a425a179124
Diffstat (limited to 'generic/tkCmds.c')
-rw-r--r--generic/tkCmds.c68
1 files changed, 48 insertions, 20 deletions
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
index d3ac006..726eea6 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.16 2000/08/03 20:36:15 ericm Exp $
+ * RCS: @(#) $Id: tkCmds.c,v 1.17 2000/08/03 21:02:19 ericm Exp $
*/
#include "tkPort.h"
@@ -106,7 +106,7 @@ Tk_BellObjCmd(clientData, interp, objc, objv)
/*
*----------------------------------------------------------------------
*
- * Tk_BindCmd --
+ * Tk_BindObjCmd --
*
* This procedure is invoked to process the "bind" Tcl command.
* See the user documentation for details on what it does.
@@ -121,54 +121,82 @@ Tk_BellObjCmd(clientData, interp, objc, objv)
*/
int
-Tk_BindCmd(clientData, interp, argc, argv)
+Tk_BindObjCmd(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;
TkWindow *winPtr;
ClientData object;
-
- if ((argc < 2) || (argc > 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " window ?pattern? ?command?\"", (char *) NULL);
+ char *string;
+
+ if ((objc < 2) || (objc > 4)) {
+ Tcl_WrongNumArgs(interp, 1, objv, "window ?pattern? ?command?");
return TCL_ERROR;
}
- if (argv[1][0] == '.') {
- winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[1], tkwin);
+ string = Tcl_GetString(objv[1]);
+
+ /*
+ * Bind tags either a window name or a tag name for the first argument.
+ * If the argument starts with ".", assume it is a window; otherwise, it
+ * is a tag.
+ */
+
+ if (string[0] == '.') {
+ winPtr = (TkWindow *) Tk_NameToWindow(interp, string, tkwin);
if (winPtr == NULL) {
return TCL_ERROR;
}
object = (ClientData) winPtr->pathName;
} else {
winPtr = (TkWindow *) clientData;
- object = (ClientData) Tk_GetUid(argv[1]);
+ object = (ClientData) Tk_GetUid(string);
}
- if (argc == 4) {
+ /*
+ * If there are four arguments, the command is modifying a binding. If
+ * there are three arguments, the command is querying a binding. If there
+ * are only two arguments, the command is querying all the bindings for
+ * the given tag/window.
+ */
+
+ if (objc == 4) {
int append = 0;
unsigned long mask;
+ char *sequence, *script;
+ sequence = Tcl_GetString(objv[2]);
+ script = Tcl_GetString(objv[3]);
+
+ /*
+ * If the script is null, just delete the binding.
+ */
- if (argv[3][0] == 0) {
+ if (script[0] == 0) {
return Tk_DeleteBinding(interp, winPtr->mainPtr->bindingTable,
- object, argv[2]);
+ object, sequence);
}
- if (argv[3][0] == '+') {
- argv[3]++;
+
+ /*
+ * If the script begins with "+", append this script to the existing
+ * binding.
+ */
+
+ if (script[0] == '+') {
+ script++;
append = 1;
}
mask = Tk_CreateBinding(interp, winPtr->mainPtr->bindingTable,
- object, argv[2], argv[3], append);
+ object, sequence, script, append);
if (mask == 0) {
return TCL_ERROR;
}
- } else if (argc == 3) {
+ } else if (objc == 3) {
char *command;
command = Tk_GetBinding(interp, winPtr->mainPtr->bindingTable,
- object, argv[2]);
+ object, Tcl_GetString(objv[2]));
if (command == NULL) {
Tcl_ResetResult(interp);
return TCL_OK;