-
Notifications
You must be signed in to change notification settings - Fork 0
/
ckFocus.c
82 lines (73 loc) · 1.95 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
81
82
/*
* 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_FocusCmdObj --
*
* 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_FocusCmdObj(clientData, interp, objc, objv)
ClientData clientData; /* Main window associated with
* interpreter. */
Tcl_Interp *interp; /* Current interpreter. */
int objc; /* Number of arguments. */
Tcl_Obj * CONST objv[]; /* Tcl_Obj* array of arguments. */
{
CkWindow *winPtr = (CkWindow *) clientData;
CkWindow *newPtr, *focusWinPtr;
/*
* If invoked with no arguments, just return the current focus window.
*/
if (objc == 1) {
focusWinPtr = winPtr->mainPtr->focusPtr;
if (focusWinPtr != NULL) {
Tcl_SetObjResult( interp, Tcl_NewStringObj(focusWinPtr->pathName, -1));
}
return TCL_OK;
}
/*
* If invoked with a single argument beginning with "." then focus
* on that window.
*/
if (objc == 2) {
char *s = Tcl_GetString(objv[1]);
if (s[0] == 0) {
return TCL_OK;
}
if (s[0] == '.') {
newPtr = (CkWindow *) Ck_NameToWindow(interp, s, winPtr);
if (newPtr == NULL) {
return TCL_ERROR;
}
if (!(newPtr->flags & CK_ALREADY_DEAD)) {
Ck_SetFocus(newPtr);
}
return TCL_OK;
}
}
Tcl_WrongNumArgs (interp, 1, objv, "?pathname?");
return TCL_ERROR;
}