/*
* tkCmds.c --
*
* This file contains a collection of Tk-related Tcl commands
* that didn't fit in any particular file of the toolkit.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tkCmds.c 1.110 96/04/03 15:54:47
*/
#include "tkInt.h"
#include <errno.h>
/*
* Forward declarations for procedures defined later in this file:
*/
int flags));
/*
*----------------------------------------------------------------------
*
* Tk_BellCmd --
*
* This procedure is invoked to process the "bell" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
" ?-displayof window?\"", (char *) NULL);
return TCL_ERROR;
}
if (argc == 3) {
"\": must be -displayof", (char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tk_BindCmd --
*
* This procedure is invoked to process the "bind" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
" window ?pattern? ?command?\"", (char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
} else {
}
if (argc == 4) {
int append = 0;
unsigned long mask;
if (argv[3][0] == 0) {
}
argv[3]++;
append = 1;
}
if (mask == 0) {
return TCL_ERROR;
}
} else if (argc == 3) {
char *command;
return TCL_OK;
}
} else {
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TkBindEventProc --
*
* This procedure is invoked by Tk_HandleEvent for each event; it
* causes any appropriate bindings for that event to be invoked.
*
* Results:
* None.
*
* Side effects:
* Depends on what bindings have been established with the "bind"
* command.
*
*----------------------------------------------------------------------
*/
void
{
int i, count;
char *p;
return;
}
/*
* Make a copy of the tags for the window, replacing window names
* with pointers to the pathName from the appropriate window.
*/
}
if (*p == '.') {
} else {
p = NULL;
}
}
objPtr[i] = (ClientData) p;
}
} else {
/* Empty loop body. */
}
count = 4;
} else {
count = 3;
}
}
}
}
}
/*
*----------------------------------------------------------------------
*
* Tk_BindtagsCmd --
*
* This procedure is invoked to process the "bindtags" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
int i, tagArgc;
char *p, **tagArgv;
" window ?tags?\"", (char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
if (argc == 2) {
/* Empty loop body. */
}
}
} else {
}
}
return TCL_OK;
}
}
if (argv[2][0] == 0) {
return TCL_OK;
}
return TCL_ERROR;
}
(tagArgc * sizeof(ClientData)));
for (i = 0; i < tagArgc; i++) {
p = tagArgv[i];
if (p[0] == '.') {
char *copy;
/*
* Handle names starting with "." specially: store a malloc'ed
* string, rather than a Uid; at event time we'll look up the
* name in the window table and use the corresponding window,
* if there is one.
*/
} else {
}
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TkFreeBindingTags --
*
* This procedure is called to free all of the binding tags
* associated with a window; typically it is only invoked where
* there are window-specific tags.
*
* Results:
* None.
*
* Side effects:
* Any binding tags for winPtr are freed.
*
*----------------------------------------------------------------------
*/
void
{
int i;
char *p;
if (*p == '.') {
/*
* Names starting with "." are malloced rather than Uids, so
* they have to be freed.
*/
ckfree(p);
}
}
}
/*
*----------------------------------------------------------------------
*
* Tk_DestroyCmd --
*
* This procedure is invoked to process the "destroy" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
int
* interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
int i;
for (i = 1; i < argc; i++) {
return TCL_ERROR;
}
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tk_LowerCmd --
*
* This procedure is invoked to process the "lower" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
int
* interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
return TCL_ERROR;
}
return TCL_ERROR;
}
if (argc == 2) {
} else {
return TCL_ERROR;
}
}
return TCL_ERROR;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tk_RaiseCmd --
*
* This procedure is invoked to process the "raise" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
int
* interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
return TCL_ERROR;
}
return TCL_ERROR;
}
if (argc == 2) {
} else {
return TCL_ERROR;
}
}
return TCL_ERROR;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tk_TkCmd --
*
* This procedure is invoked to process the "tk" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
int
* interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
char c;
if (argc < 2) {
return TCL_ERROR;
}
c = argv[1][0];
if (argc > 3) {
" appname ?newName?\"", (char *) NULL);
return TCL_ERROR;
}
if (argc == 3) {
}
} else {
"\": must be appname", (char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tk_TkwaitCmd --
*
* This procedure is invoked to process the "tkwait" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
int
* interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
int c, done;
if (argc != 3) {
return TCL_ERROR;
}
c = argv[1][0];
&& (length >= 2)) {
return TCL_ERROR;
}
done = 0;
while (!done) {
Tcl_DoOneEvent(0);
}
&& (length >= 2)) {
return TCL_ERROR;
}
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.
*/
"\" was deleted before its visibility changed",
(char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
done = 0;
while (!done) {
Tcl_DoOneEvent(0);
}
/*
* Note: there's no need to delete the event handler. It was
* deleted automatically when the window was destroyed.
*/
} else {
"\": must be variable, visibility, or window", (char *) NULL);
return TCL_ERROR;
}
/*
* Clear out the interpreter's result, since it may have been set
* by event handlers.
*/
return TCL_OK;
}
/* ARGSUSED */
static char *
char *name1; /* Name of variable. */
char *name2; /* Second part of variable name. */
int flags; /* Information about what happened. */
{
*donePtr = 1;
return (char *) NULL;
}
/*ARGSUSED*/
static void
{
*donePtr = 1;
}
*donePtr = 2;
}
}
static void
{
*donePtr = 1;
}
}
/*
*----------------------------------------------------------------------
*
* Tk_UpdateCmd --
*
* This procedure is invoked to process the "update" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
int
* interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
int flags;
if (argc == 1) {
} else if (argc == 2) {
"\": must be idletasks", (char *) NULL);
return TCL_ERROR;
}
} else {
return TCL_ERROR;
}
/*
* Handle all pending events, sync the display, and repeat over
* and over again until all pending events have been handled.
* Special note: it's possible that the entire application could
* be destroyed by an event handler that occurs during the update.
* Thus, don't use any information from tkwin after calling
* Tcl_DoOneEvent.
*/
while (1) {
while (Tcl_DoOneEvent(flags) != 0) {
/* Empty loop body */
}
if (Tcl_DoOneEvent(flags) == 0) {
break;
}
}
/*
* Must clear the interpreter's result because event handlers could
* have executed commands.
*/
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tk_WinfoCmd --
*
* This procedure is invoked to process the "winfo" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
int
* interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
char c, *argName;
if (argc != 3) {\
goto wrongArgs; \
} \
return TCL_ERROR; \
}
if (argc < 2) {
return TCL_ERROR;
}
c = argv[1][0];
char *atomName;
if (argc == 3) {
} else if (argc == 5) {
return TCL_ERROR;
}
} else {
argv[0], " atom ?-displayof window? name\"",
(char *) NULL);
return TCL_ERROR;
}
&& (length >= 5)) {
if (argc == 3) {
} else if (argc == 5) {
return TCL_ERROR;
}
} else {
argv[0], " atomname ?-displayof window? id\"",
(char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
&& (length >= 2)) {
SETUP("cells");
&& (length >= 2)) {
SETUP("children");
}
&& (length >= 2)) {
SETUP("class");
&& (length >= 3)) {
SETUP("colormapfull");
? "1" : "0";
&& (length >= 3)) {
if (argc == 4) {
index = 2;
} else if (argc == 6) {
index = 4;
return TCL_ERROR;
}
} else {
argv[0], " containing ?-displayof window? rootX rootY\"",
(char *) NULL);
return TCL_ERROR;
}
!= TCL_OK)) {
return TCL_ERROR;
}
}
SETUP("depth");
if (argc != 3) {
argName = "exists";
goto wrongArgs;
}
} else {
}
&& (length >= 2)) {
if (argc != 4) {
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
SETUP("geometry");
SETUP("height");
SETUP("id");
&& (length >= 2)) {
if (argc == 4) {
return TCL_ERROR;
}
} else if (argc != 2) {
argv[0], " interps ?-displayof window?\"",
(char *) NULL);
return TCL_ERROR;
}
&& (length >= 2)) {
SETUP("ismapped");
SETUP("manager");
}
SETUP("name");
SETUP("parent");
}
&& (length >= 2)) {
if (argc == 3) {
index = 2;
} else if (argc == 5) {
index = 4;
return TCL_ERROR;
}
} else {
argv[0], " pathname ?-displayof window? id\"",
(char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
"\" doesn't exist in this application", (char *) NULL);
return TCL_ERROR;
}
&& (length >= 2)) {
int pixels;
if (argc != 4) {
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
int x, y;
SETUP("pointerx");
x = -1;
} else {
}
int x, y;
SETUP("pointerxy");
x = -1;
} else {
}
int x, y;
SETUP("pointery");
y = -1;
} else {
}
&& (length >= 4)) {
SETUP("reqheight");
&& (length >= 4)) {
SETUP("reqwidth");
&& (length >= 2)) {
if (argc != 4) {
return TCL_ERROR;
}
return TCL_ERROR;
}
return TCL_ERROR;
}
int x, y;
SETUP("rootx");
Tk_GetRootCoords(window, &x, &y);
int x, y;
SETUP("rooty");
Tk_GetRootCoords(window, &x, &y);
SETUP("screen");
(char *) NULL);
&& (length >= 7)) {
SETUP("screencells");
&& (length >= 7)) {
SETUP("screendepth");
&& (length >= 7)) {
SETUP("screenheight");
&& (length >= 9)) {
SETUP("screenmmheight");
&& (length >= 9)) {
SETUP("screenmmwidth");
&& (length >= 7)) {
SETUP("screenvisual");
}
&& (length >= 7)) {
SETUP("screenwidth");
&& (length >= 2)) {
SETUP("server");
SETUP("toplevel");
}
&& (length >= 3)) {
SETUP("viewable");
break;
}
break;
}
}
SETUP("visual");
}
&& (length >= 7)) {
SETUP("visualid");
&& (length >= 7)) {
int count, i;
int includeVisualId;
if (argc == 3) {
includeVisualId = 0;
} else if ((argc == 4)
includeVisualId = 1;
} else {
argv[0], " visualsavailable window ?includeids?\"",
(char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
if (visInfoPtr == NULL) {
return TCL_ERROR;
}
for (i = 0; i < count; i++) {
switch (visInfoPtr[i].class) {
default: fmt = "unknown"; break;
}
if (includeVisualId) {
(unsigned int) visInfoPtr[i].visualid);
}
}
XFree((char *) visInfoPtr);
&& (length >= 6)) {
int x, y;
SETUP("vrootheight");
&& (length >= 6)) {
int x, y;
SETUP("vrootwidth");
int x, y;
SETUP("vrootx");
int x, y;
SETUP("vrooty");
SETUP("width");
SETUP("x");
SETUP("y");
} else {
"\": must be atom, atomname, cells, children, ",
"class, colormapfull, containing, depth, exists, fpixels, ",
"geometry, height, ",
"id, interps, ismapped, manager, name, parent, pathname, ",
"pixels, pointerx, pointerxy, pointery, reqheight, ",
"reqwidth, rgb, ",
"rootx, rooty, ",
"screen, screencells, screendepth, screenheight, ",
"screenmmheight, screenmmwidth, screenvisual, ",
"screenwidth, server, ",
"toplevel, viewable, visual, visualid, visualsavailable, ",
"vrootheight, vrootwidth, vrootx, vrooty, ",
"width, x, or y", (char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* GetDisplayOf --
*
* Parses a "-displayof" option for the "winfo" command.
*
* Results:
* The return value is a token for the window specified in
* argv[1]. If argv[0] and argv[1] couldn't be parsed, NULL
* is returned and an error is left in interp->result.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static Tk_Window
* given in argv[1]. */
char **argv; /* Array of two strings. First must be
* "-displayof" or an abbreviation, second
* must be window name. */
{
"\": must be -displayof", (char *) NULL);
}
}
/*
*----------------------------------------------------------------------
*
* TkDeadAppCmd --
*
* If an application has been deleted then all Tk commands will be
* re-bound to this procedure.
*
* Results:
* A standard Tcl error is reported to let the user know that
* the application is dead.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
"\" command: application has been destroyed", (char *) NULL);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* GetToplevel --
*
* Retrieves the toplevel window which is the nearest ancestor of
* of the specified window.
*
* Results:
* Returns the toplevel window or NULL if the window has no
* ancestor which is a toplevel.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static TkWindow *
* deterined. */
{
return NULL;
}
}
return winPtr;
}