01: /*
02: * UpdateCmd.java --
03: *
04: * Implements the "update" command.
05: *
06: * Copyright (c) 1997 Sun Microsystems, Inc.
07: *
08: * See the file "license.terms" for information on usage and
09: * redistribution of this file, and for a DISCLAIMER OF ALL
10: * WARRANTIES.
11: *
12: * RCS: @(#) $Id: UpdateCmd.java,v 1.1.1.1 1998/10/14 21:09:19 cvsadmin Exp $
13: *
14: */
15:
16: package tcl.lang;
17:
18: /*
19: * This class implements the built-in "update" command in Tcl.
20: */
21:
22: class UpdateCmd implements Command {
23:
24: /*
25: * Valid command options.
26: */
27:
28: static final private String validOpts[] = { "idletasks", };
29:
30: static final int OPT_IDLETASKS = 0;
31:
32: /*
33: *----------------------------------------------------------------------
34: *
35: * cmdProc --
36: *
37: * This procedure is invoked as part of the Command interface to
38: * process the "update" Tcl command. See the user documentation
39: * for details on what it does.
40: *
41: * Results:
42: * None.
43: *
44: * Side effects:
45: * See the user documentation.
46: *
47: *----------------------------------------------------------------------
48: */
49:
50: public void cmdProc(Interp interp, // Current interpreter.
51: TclObject argv[]) // Argument list.
52: throws TclException // A standard Tcl exception.
53: {
54: int flags;
55:
56: if (argv.length == 1) {
57: flags = TCL.ALL_EVENTS | TCL.DONT_WAIT;
58: } else if (argv.length == 2) {
59: TclIndex.get(interp, argv[1], validOpts, "option", 0);
60:
61: /*
62: * Since we just have one valid option, if the above call returns
63: * without an exception, we've got "idletasks" (or abreviations).
64: */
65:
66: flags = TCL.IDLE_EVENTS | TCL.DONT_WAIT;
67: } else {
68: throw new TclNumArgsException(interp, 1, argv,
69: "?idletasks?");
70: }
71:
72: while (interp.getNotifier().doOneEvent(flags) != 0) {
73: /* Empty loop body */
74: }
75:
76: /*
77: * Must clear the interpreter's result because event handlers could
78: * have executed commands.
79: */
80:
81: interp.resetResult();
82: }
83:
84: } // end UpdateCmd
|