Tcl Source Code

Changes On Branch updateextended
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch updateextended Excluding Merge-Ins

This is equivalent to a diff from ac14beae58 to f2ca25064c

2016-08-26
13:49
Merge dup-removal into search loop so we avoid pre-processing efforts on data that are never used. C... check-in: 6b4fc5cf0f user: dgp tags: trunk
2016-08-19
08:48
merge trunk check-in: fad3c1f68f user: jan.nijtmans tags: tip-439, semver
2016-08-10
04:27
* added some docco for [update] changes. Leaf check-in: f2ca25064c user: colin tags: updateextended
04:12
* [update] - added flags for all possible Tcl_DoOneEvent() modes - obviates [vwait] and provides a ... check-in: 26b64e7254 user: colin tags: updateextended
2016-07-28
21:43
Create new branch named "pyk-trunk" check-in: edeed2a4f8 user: pooryorick tags: pyk-trunk
2016-07-27
18:56
merge mark check-in: ac14beae58 user: dgp tags: trunk
18:55
merge release check-in: cea1f5457e user: dgp tags: core-8-6-branch
2016-07-26
10:09
[db0a5f6417] Make a few tests resilient to differences in semantics of pipes between OSs. check-in: c853c914b6 user: dkf tags: trunk

Changes to doc/update.n.

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
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







-
+






-
+







+
+
+
+
+
+
+
+
+
+







.TH update n 7.5 Tcl "Tcl Built-In Commands"
.so man.macros
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
update \- Process pending events and idle callbacks
.SH SYNOPSIS
\fBupdate\fR ?\fBidletasks\fR?
\fBupdate\fR ?\fIoption ...\fR?
.BE
.SH DESCRIPTION
.PP
This command is used to bring the application
.QW "up to date"
by entering the event loop repeatedly until all pending events
(including idle callbacks) have been processed.
(including idle callbacks, if specified) have been processed.
.PP
If the \fBidletasks\fR keyword is specified as an argument to the
command, then no new events or errors are processed;  only idle
callbacks are invoked.
This causes operations that are normally deferred, such as display
updates and window layout calculations, to be performed immediately.
.PP
Options accepted are
	\fBidletasks\fR - process any pending window events or idle events, do not wait
	\fBwindow\fR - process window events
	\fBfile\fR - process file events
	\fBtimer\fR - process timer events
	\fBonlyidle\fR - process only idle events
	\fBall\fR - process all events
	\fBwait\fR - wait until at least one event has been processed
	\fBnowait\fR - return immediately if no events are pending.
.PP
The \fBupdate idletasks\fR command is useful in scripts where
changes have been made to the application's state and you want those
changes to appear on the display immediately, rather than waiting
for the script to complete.  Most display updates are performed as
idle callbacks, so \fBupdate idletasks\fR will cause them to run.
However, there are some kinds of updates that only happen in
response to events, such as those triggered by window size changes;
56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72

73
74
75







-
+


    # Test to see if our time-limit has been hit.  This would
    # also give a chance for serving network sockets and, if
    # the Tk package is loaded, updating a user interface.
    \fBupdate\fR
}
.CE
.SH "SEE ALSO"
after(n), interp(n)
after(n), interp(n), Tcl_DoOneEvent(3)
.SH KEYWORDS
asynchronous I/O, event, flush, handler, idle, update

Changes to generic/tclEvent.c.

1493
1494
1495
1496
1497
1498
1499

1500
1501


1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516




































1517
1518
1519

1520
1521
1522
1523
1524
1525
1526
1493
1494
1495
1496
1497
1498
1499
1500


1501
1502
1503
1504
1505












1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541



1542
1543
1544
1545
1546
1547
1548
1549







+
-
-
+
+



-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+







    ClientData clientData,	/* Not used. */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* Argument objects. */
{
    int optionIndex;
    int flags = 0;		/* Initialized to avoid compiler warning. */
    int index;
    static const char *const updateOptions[] = {"idletasks", NULL};
    enum updateOptions {OPT_IDLETASKS};
    static const char *const updateOptions[] = {"idletasks", "window", "file", "timer", "onlyidle", "all", "wait", "nowait", NULL};
    enum updateOptions {OPT_IDLETASKS, OPT_WINDOW, OPT_FILE, OPT_TIMER, OPT_ONLYIDLE, OPT_ALL, OPT_WAIT, OPT_NOWAIT};

    if (objc == 1) {
	flags = TCL_ALL_EVENTS|TCL_DONT_WAIT;
    } else if (objc == 2) {
	if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions,
		"option", 0, &optionIndex) != TCL_OK) {
	    return TCL_ERROR;
	}
	switch ((enum updateOptions) optionIndex) {
	case OPT_IDLETASKS:
	    flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
	    break;
	default:
	    Tcl_Panic("Tcl_UpdateObjCmd: bad option index to UpdateOptions");
	}
    } else {
	flags = 0;
	for (index = 1; index < objc; index++) {
	    if (Tcl_GetIndexFromObj(interp, objv[index], updateOptions,
				    "option", 0, &optionIndex) != TCL_OK) {
		return TCL_ERROR;
	    }

	    switch ((enum updateOptions) optionIndex) {
	    case OPT_IDLETASKS:
		flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
		break;
	    case OPT_WINDOW:
		flags |= TCL_WINDOW_EVENTS;	// Process window system events.
		break;
	    case OPT_FILE:
		flags |= TCL_FILE_EVENTS; 	// Process file events.
		break;
	    case OPT_TIMER:
		flags |= TCL_TIMER_EVENTS;	// Process timer events.
		break;
	    case OPT_ONLYIDLE:
		flags |= TCL_IDLE_EVENTS;	// Process idle callbacks.
		break;
	    case OPT_ALL:
		flags |= TCL_ALL_EVENTS;	// Process all kinds of events
		break;
	    case OPT_WAIT:
		flags &= ~TCL_DONT_WAIT;	// Sleep until an event occurs
		break;
	    case OPT_NOWAIT:
		flags |= TCL_DONT_WAIT;	// Do not sleep:  process only events that are ready at the time of the call.
		break;
	    default:
		Tcl_Panic("Tcl_UpdateObjCmd: bad option index to UpdateOptions");
	    }
    } else {
	Tcl_WrongNumArgs(interp, 1, objv, "?idletasks?");
	return TCL_ERROR;
	}
    }

    while (Tcl_DoOneEvent(flags) != 0) {
	if (Tcl_Canceled(interp, TCL_LEAVE_ERR_MSG) == TCL_ERROR) {
	    return TCL_ERROR;
	}
	if (Tcl_LimitExceeded(interp)) {

Changes to tests/event.test.

610
611
612
613
614
615
616
617

618
619
620

621
622
623
624
625
626
627
610
611
612
613
614
615
616

617
618
619

620
621
622
623
624
625
626
627







-
+


-
+







    [A new] start
} -cleanup {
    A destroy
} -result {}

test event-12.1 {Tcl_UpdateCmd procedure} -returnCodes error -body {
    update a b
} -result {wrong # args: should be "update ?idletasks?"}
} -result {bad option "b": must be idletasks, window, file, timer, onlyidle, all, wait, or nowait}
test event-12.2 {Tcl_UpdateCmd procedure} -returnCodes error -body {
    update bogus
} -result {bad option "bogus": must be idletasks}
} -result {bad option "bogus": must be idletasks, window, file, timer, onlyidle, all, wait, or nowait}
test event-12.3 {Tcl_UpdateCmd procedure} -setup {
    foreach i [after info] {
	after cancel $i
    }
} -body {
    after 500 {set x after}
    after idle {set y after}