static char *sccsid
= "@(#)cmd2.c 3.17 84/01/11";
char *help_shortcmd
[] = {
"{1-9} Select window {1-9} and return to conversation mode.",
"%{1-9} Select window {1-9} but stay in command mode.",
"escape Return to conversation mode",
" and don't change the current window.",
"^^ Return to conversation mode",
" and change to previously selected window.",
"c{1-9} Close window {1-9}.",
"S Show all windows in sequence.",
"L List all windows with their labels.",
"m{1-9} Move window {1-9}.",
"M{1-9} Move window {1-9} to previous position.",
"{^Y^E} Scroll {up, down} one line",
"{^U^D} Scroll {up, down} half a window.",
"{^B^F} Scroll {up, down} a full window.",
"{hjkl} Move cursor {left, down, up, right}.",
":%{1-9} Select window {1-9}.",
":buffer lines Set the default window buffer size.",
":close {1-9} Close window.",
":cursor modes Set the cursor modes.",
":escape C Set escape character to C.",
":label {1-9} string Label window {1-9}.",
":source filename Execute commands in ``filename''.",
":terse [off] Turn on (or off) terse mode.",
":window row col nrow ncol [nline label]",
" Open a window at ``row'', ``col''",
" of size ``nrow'', ``ncol'',",
" with ``nline'', and ``label''.",
":write {1-9} string Write ``string'' to window {1-9}.",
if ((w
= openiwin(wwnrow
- 3, "Help")) == 0) {
error("Can't open help window: %s.", wwerror());
(void) wwprintf(w
, "The escape character is %s, which gets you into command mode.\n\n",
help_print(w
, "Short commands", help_shortcmd
);
help_print(w
, "Long commands", help_longcmd
);
help_print(w
, name
, list
)
(void) wwprintf(w
, "%s:%s\n\n",
name
, firsttime
? "" : " (continued)");
while (*p
&& w
->ww_cur
.r
< w
->ww_w
.b
- 2) {
(void) wwputs("\033E", w
); /* clear and home cursor */
struct timezone timezone
;
if ((w
= openiwin(6, "Timing and Resource Usage")) == 0) {
error("Can't open time window: %s.", wwerror());
(void) gettimeofday(&timeval
, &timezone
);
timeval
.tv_sec
-= starttime
.tv_sec
;
if ((timeval
.tv_usec
-= starttime
.tv_usec
) < 0) {
timeval
.tv_usec
+= 1000000;
(void) getrusage(flag
, &rusage
);
(void) wwprintf(w
, "time\t\tutime\t\tstime\t\tmaxrss\tixrss\tidrss\tisrss\n");
(void) wwprintf(w
, "%-16s", strtime(&timeval
));
(void) wwprintf(w
, "%-16s", strtime(&rusage
.ru_utime
));
(void) wwprintf(w
, "%-16s", strtime(&rusage
.ru_stime
));
(void) wwprintf(w
, "%D\t%D\t%D\t%D\n",
rusage
.ru_maxrss
, rusage
.ru_ixrss
,
rusage
.ru_idrss
, rusage
.ru_isrss
);
(void) wwprintf(w
, "minflt\tmajflt\tnswap\tinblk\toublk\tmsgsnd\tmsgrcv\tnsigs\tnvcsw\tnivcsw\n");
(void) wwprintf(w
, "%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\n",
rusage
.ru_minflt
, rusage
.ru_majflt
, rusage
.ru_nswap
,
rusage
.ru_inblock
, rusage
.ru_oublock
,
rusage
.ru_msgsnd
, rusage
.ru_msgrcv
, rusage
.ru_nsignals
,
rusage
.ru_nvcsw
, rusage
.ru_nivcsw
);
register struct timeval
*t
;
(void) sprintf(p
, "%D:", t
->tv_sec
/ (60*60));
(void) sprintf(p
, fill
? "%02D:" : "%D:", t
->tv_sec
/ 60);
(void) sprintf(p
, fill
? "%02D.%02d" : "%D.%02D",
t
->tv_sec
, t
->tv_usec
/ 10000);
if ((w
= openiwin(6, "IO Statics")) == 0) {
error("Can't open statistics window: %s.", wwerror());
(void) wwprintf(w
, "nread\tnreadz\tnreade\tnreadc\tnwrite\tnwritec\n");
(void) wwprintf(w
, "%d\t%d\t%d\t%d\t%d\t%d\n",
nread
, nreadz
, nreade
, nreadc
, wwnwrite
, wwnwritec
);
(void) wwprintf(w
, "nupdate\tnupdlin\tnupdmis\tnmajlin\tnmajmis\n");
(void) wwprintf(w
, "%d\t%d\t%d\t%d\t%d\n",
wwnupdate
, wwnupdline
, wwnupdmiss
, wwnmajline
, wwnmajmiss
);
register struct ww
*w
, *wp
;
for (n
= 0, i
= 0; i
< NWINDOW
; i
++)
if ((w
= openiwin(n
+ 2, "Windows")) == 0) {
error("Can't open listing window: %s.", wwerror());
for (i
= 0; i
< NWINDOW
; i
++) {
if ((wp
= window
[i
]) == 0)
(void) wwprintf(w
, "%c %c %-13s %-.*s\n",
wp
== selwin
? '*' : ' ',
wp
->ww_state
== WWS_HASPROC
? wp
->ww_label
: "(No label)");
(void) wwputs("Really quit [yn]? ", cmdwin
);
(void) wwputs("Yes", cmdwin
);
(void) wwputs("\r\n", cmdwin
);
* Open an information window.
if ((w
= wwopen(0, nrow
, wwncol
, 2, 0, 0)) == 0)
(void) setlabel(w
, label
);
(void) wwprintf(w
, "\033Y%c%c[Type any key to continue] ",
w
->ww_w
.nr
- 1 + ' ', ' '); /* print on last line */
more(w
, fmt
, a
, b
, c
, d
, e
)
if (w
->ww_cur
.r
> w
->ww_w
.b
- 3) {
(void) wwputs("\033E", w
);
(void) wwprintf(w
, fmt
, a
, b
, c
, d
, e
);