-
Notifications
You must be signed in to change notification settings - Fork 1
/
ckFocus.c
80 lines (71 loc) · 1.94 KB
/
ckFocus.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* ckFocus.c --
*
* This file contains procedures that manage the input focus.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1995 Sun Microsystems, Inc.
* Copyright (c) 1995 Christian Werner
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "ckPort.h"
#include "ck.h"
/*
*--------------------------------------------------------------
*
* Ck_FocusCmd --
*
* This procedure is invoked to process the "focus" Tcl command.
* See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*--------------------------------------------------------------
*/
int
Ck_FocusCmd(clientData, interp, argc, argv)
ClientData clientData; /* Main window associated with
* interpreter. */
Tcl_Interp *interp; /* Current interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
CkWindow *winPtr = (CkWindow *) clientData;
CkWindow *newPtr, *focusWinPtr;
/*
* If invoked with no arguments, just return the current focus window.
*/
if (argc == 1) {
focusWinPtr = winPtr->mainPtr->focusPtr;
if (focusWinPtr != NULL) {
Tcl_SetResult(interp, focusWinPtr->pathName, TCL_VOLATILE);
}
return TCL_OK;
}
/*
* If invoked with a single argument beginning with "." then focus
* on that window.
*/
if (argc == 2) {
if (argv[1][0] == 0) {
return TCL_OK;
}
if (argv[1][0] == '.') {
newPtr = (CkWindow *) Ck_NameToWindow(interp, argv[1], winPtr);
if (newPtr == NULL)
return TCL_ERROR;
if (!(newPtr->flags & CK_ALREADY_DEAD))
Ck_SetFocus(newPtr);
return TCL_OK;
}
}
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" ?pathName?\"", (char *) NULL);
return TCL_ERROR;
}