]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/window/window.1
BSD 4.4 Lite Usr.bin Sources
[FreeBSD/FreeBSD.git] / usr.bin / window / window.1
1 .\" Copyright (c) 1985, 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Edward Wang at The University of California, Berkeley.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\"    must display the following acknowledgement:
17 .\"     This product includes software developed by the University of
18 .\"     California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\"    may be used to endorse or promote products derived from this software
21 .\"    without specific prior written permission.
22 .\"
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" SUCH DAMAGE.
34 .\"
35 .\"     @(#)window.1    8.2 (Berkeley) 12/30/93
36 .\"
37 .Dd December 30, 1993
38 .Dt WINDOW 1
39 .Os BSD 4.3
40 .Sh NAME
41 .Nm window
42 .Nd window environment
43 .Sh SYNOPSIS
44 .Nm window
45 .Op Fl t
46 .Op Fl f
47 .Op Fl d
48 .Op Fl e Ar escape-char
49 .Op Fl c Ar command
50 .Sh DESCRIPTION
51 .Nm Window
52 implements a window environment on
53 .Tn ASCII
54 terminals.
55 .Pp
56 A window is a rectangular portion of the physical terminal
57 screen associated with a set of processes.  Its size and
58 position can be changed by the user at any time.  Processes
59 communicate with their window in the same way they normally
60 interact with a terminal\-through their standard input, output,
61 and diagnostic file descriptors.  The window program handles the
62 details of redirecting input and output to and from the
63 windows.  At any one time, only one window can receive
64 input from the keyboard, but all windows can simultaneously send output
65 to the display.
66 .Pp
67 When
68 .Nm window
69 starts up, the commands (see long commands below)
70 contained in the file
71 .Pa .windowrc
72 in the user's home directory are
73 executed.  If it does not exist, two equal sized windows spanning
74 the terminal screen are created by default.
75 .Pp
76 The command line options are
77 .Bl -tag -width Fl
78 .It Fl t
79 Turn on terse mode (see
80 .Ic terse
81 command below).
82 .It Fl f
83 Fast.  Don't perform any startup action.
84 .It Fl d
85 Ignore
86 .Pa .windowrc
87 and create the two default
88 windows instead.
89 .It Fl e Ar escape-char 
90 Set the escape character to
91 .Ar escape-char  .
92 .Ar Escape-char
93 can be a single character, or in the form
94 .Ic ^X
95 where
96 .Ar X
97 is any character, meaning
98 .No control\- Ns Ar X  . 
99 .It Fl c Ar command 
100 Execute the string
101 .Ar command
102 as a long command (see below)
103 before doing anything else.
104 .El
105 .Pp
106 Windows can overlap and are framed as necessary.  Each window
107 is named by one of the digits ``1'' to ``9''.  This one-character
108 identifier, as well as a user definable label string, are displayed
109 with the window on the top edge of its frame.  A window can be
110 designated to be in the
111 .Ar foreground  ,
112 in which case it will always be
113 on top of all normal, non-foreground windows, and can be covered
114 only by other foreground windows.  A window need not be completely
115 within the edges of the terminal screen.  Thus a large window
116 (possibly larger than the screen) may be positioned to show only
117 a portion of its full size.
118 .Pp
119 Each window has a cursor and a set of control functions.  Most intelligent
120 terminal operations such as line and
121 character deletion and insertion are supported.  Display modes
122 such as underlining and reverse video are available if they are
123 supported by the terminal.  In addition,
124 similar to terminals with multiple pages of memory,
125 each window has a text buffer which can have more lines than the window
126 itself.
127 .Ss Process Environment
128 With each newly created window, a shell program is spawned with its
129 process environment tailored to that window.  Its standard input,
130 output, and diagnostic file descriptors are bound to one end of either
131 a pseudo-terminal
132 .Xr (pty 4 )
133 or a
134 .Ux
135 domain socket
136 .Xr (socketpair 4 ) .
137 If a pseudo-terminal is used, then its special
138 characters and modes (see
139 .Xr stty 1 )
140 are copied from the physical
141 terminal.  A
142 .Xr termcap 5
143 entry tailored to this window is created
144 and passed as environment
145 .Xr (environ 5 )
146 variable
147 .Ev TERMCAP  .
148 The termcap entry contains the window's size and
149 characteristics as well as information from the physical terminal,
150 such as the existence of underline, reverse video, and other display
151 modes, and the codes produced by the terminal's function keys,
152 if any.  In addition, the window size attributes of the pseudo-terminal
153 are set to reflect the size of this window, and updated whenever
154 it is changed by the user.  In particular, the editor
155 .Xr vi 1
156 uses
157 this information to redraw its display.
158 .Ss Operation
159 During normal execution,
160 .Nm window
161 can be in one of two states:
162 conversation mode and command mode.  In conversation mode, the
163 terminal's real cursor is placed at the cursor position of a particular
164 window--called the current window--and input from the keyboard is sent
165 to the process in that window.  The current window is always
166 on top of all other windows, except those in foreground.  In addition,
167 it is set apart by highlighting its identifier and label in reverse video.
168 .Pp
169 Typing
170 .Nm window Ns 's 
171 escape character (normally
172 .Ic ^P )
173 in conversation
174 mode switches it into command mode.  In command mode, the top line of
175 the terminal screen becomes the command prompt window, and
176 .Nm window
177 interprets input from the keyboard as commands to manipulate windows.
178 .Pp
179 There are two types of commands: short commands are usually one or two
180 key strokes; long commands are strings either typed by the user in the
181 command window (see the
182 .Dq Ic \&:
183 command below), or read from a file (see
184 .Ic source
185 below).
186 .Ss Short Commands
187 Below,
188 .Ar \&#
189 represents one of the digits ``1'' to ``9''
190 corresponding to the windows 1 to 9.
191 .Ic ^X
192 means
193 .No control\- Ns Ar X  , 
194 where
195 .Ar X
196 is any character.  In particular,
197 .Ic ^^
198 is
199 .Li control\-^.
200 .Ar Escape
201 is the escape key, or
202 .Ic ^\&[ .
203 .Bl -tag -width Ds
204 .It Ar #
205 Select window
206 .Ar #
207 as the current window
208 and return to conversation mode.
209 .It Ic \&% Ns Ar # 
210 Select window
211 .Ar #
212 but stay in command mode.
213 .It Ic ^^
214 Select the previous window and return to conversation
215 mode.  This is useful for toggling between two windows.
216 .It Ic escape
217 Return to conversation mode.
218 .It Ic ^P
219 Return to conversation mode and write
220 .Ic ^P
221 to the
222 current window.  Thus, typing two
223 .Ic ^P Ns 's
224 in conversation
225 mode sends one to the current window.  If the
226 .Nm window
227 escape is changed to some other character, that
228 character takes the place of
229 .Ic ^P
230 here.
231 .It Ic ?
232 List a short summary of commands.
233 .It Ic ^L
234 Refresh the screen.
235 .It Ic q
236 Exit
237 .Nm window  .
238 Confirmation is requested.
239 .It Ic ^Z
240 Suspend
241 .Nm window  .
242 .It Ic w
243 Create a new window.  The user is prompted for the positions
244 of the upper left and lower right corners of the window.
245 The cursor is placed on the screen and the keys ``h'', ``j'',
246 ``k'', and ``l''
247 move the cursor left, down, up, and right, respectively.
248 The keys ``H'', ``J'', ``K'', and ``L'' move the cursor to the respective
249 limits of the screen.  Typing a number before the movement keys
250 repeats the movement that number of times.  Return enters the cursor position
251 as the upper left corner of the window.  The lower right corner
252 is entered in the same manner.  During this process,
253 the placement of the new window is indicated by a rectangular
254 box drawn on the screen, corresponding to where the new window
255 will be framed.  Typing escape at any point
256 cancels this command.
257 .Pp
258 This window becomes the current window,
259 and is given the first available ID.  The default buffer size
260 is used (see
261 .Ar default_nline
262 command below).
263 .Pp
264 Only fully visible windows can be created this way.
265 .It Ic c Ns Ar # 
266 Close window
267 .Ar # .
268 The process in the window is sent
269 the hangup signal (see
270 .Xr kill 1 ) .
271 .Xr Csh 1
272 should
273 handle this signal correctly and cause no problems.
274 .It Ic m Ns Ar # 
275 Move window
276 .Ar #
277 to another location.  A box in the shape
278 of the window is drawn on
279 the screen to indicate the new position of the window, and the same keys as
280 those for the
281 .Ic w
282 command are used to position the box.  The
283 window can be moved partially off-screen.
284 .It Ic M Ns Ar # 
285 Move window
286 .Ar #
287 to its previous position.
288 .It Ic s Ns Ar # 
289 Change the size of window
290 .Ar # .
291 The user is prompted
292 to enter the new lower right corner of the window.  A box
293 is drawn to indicate the new window size.  The same
294 keys used in
295 .Ic w
296 and
297 .Ic m
298 are used to enter the position.
299 .It Ic S Ns Ar # 
300 Change window
301 .Ar #
302 to its previous size.
303 .It Ic ^Y
304 Scroll the current window up by one line.
305 .It Ic ^E
306 Scroll the current window down by one line.
307 .It Ic ^U
308 Scroll the current window up by half the window size.
309 .It Ic ^D
310 Scroll the current window down by half the window size.
311 .It Ic ^B
312 Scroll the current window up by the full window size.
313 .It Ic ^F
314 Scroll the current window down by the full window size.
315 .It Ic h
316 Move the cursor of the current window left by one column.
317 .It Ic j
318 Move the cursor of the current window down by one line.
319 .It Ic k
320 Move the cursor of the current window up by one line.
321 .It Ic l
322 Move the cursor of the current window right by one column.
323 .It Ic y
324 Yank.  The user is prompted to enter two points within the current
325 window.  Then the content of the current window between those two points
326 is saved in the yank buffer.
327 .It Ic p
328 Put.  The content of the yank buffer is written to the current
329 window as input.
330 .It Ic ^S
331 Stop output in the current window.
332 .It Ic ^Q
333 Start output in the current window.
334 .It Ic :
335 Enter a line to be executed as long commands.
336 Normal line
337 editing characters (erase character, erase word, erase line)
338 are supported.
339 .El
340 .Ss Long Commands
341 Long commands are a sequence of statements
342 parsed much like a programming language, with a syntax
343 similar to that of C.  Numeric and string expressions and variables
344 are supported, as well as conditional statements.
345 .Pp
346 There are two data types: string and number.  A string is a sequence
347 of letters or digits beginning with a letter.  ``_'' and ``.'' are
348 considered letters.  Alternately, non-alphanumeric characters can
349 be included in strings by quoting them in ``"'' or escaping them
350 with ``\\''.  In addition, the ``\\'' sequences of C are supported,
351 both inside and outside quotes (e.g., ``\\n'' is a new line,
352 ``\\r'' a carriage return).  For example, these are legal strings:
353 abcde01234, "&#$^*&#", ab"$#"cd, ab\\$\\#cd, "/usr/ucb/window".
354 .Pp
355 A number is an integer value in one of three forms:
356 a decimal number, an octal number preceded by ``0'',
357 or a hexadecimal number preceded by ``0x'' or ``0X''.  The natural
358 machine integer size is used (i.e., the signed integer type
359 of the C compiler).  As in C, a non-zero number represents
360 a boolean true.
361 .Pp
362 The character ``#'' begins a comment which terminates at the
363 end of the line.
364 .Pp
365 A statement is either a conditional or an expression.  Expression
366 statements are terminated with a new line or ``;''.  To continue
367 an expression on the next line, terminate the first line with ``\\''.
368 .Ss Conditional Statement
369 .Nm Window
370 has a single control structure:
371 the fully bracketed if statement in the form
372 .Pp
373 .Bd -literal -offset indent -compact
374 if <expr> then
375 \t<statement>
376 \t...
377 elsif <expr> then
378 \t<statement>
379 \t...
380 else
381 \t<statement>
382 \t...
383 endif
384 .Ed
385 .Pp
386 The
387 .Ic else
388 and
389 .Ic elsif
390 parts are optional, and the latter can
391 be repeated any number of times.
392 <Expr>
393 must be numeric.
394 .Ss Expressions
395 Expressions in
396 .Nm window
397 are similar to those in the
398 C language, with most C operators supported on numeric
399 operands.  In addition, some are overloaded to operate on strings.
400 .Pp
401 When an expression is used as a statement, its value is discarded
402 after evaluation.  Therefore, only expressions with side
403 effects (assignments and function calls) are useful as statements.
404 .Pp
405 Single valued (no arrays) variables are supported, of both
406 numeric and string values.  Some variables are predefined.  They
407 are listed below.
408 .Pp
409 The operators in order of increasing precedence:
410 .Bl -tag -width Fl
411 .It Xo
412 .Aq Va expr1
413 .Ic =
414 .Aq Va expr2
415 .Xc
416 Assignment.  The variable of name
417 .Aq Va expr1 , 
418 which must be string valued,
419 is assigned the result of
420 .Aq Va expr2 . 
421 Returns the value of
422 .Aq Va expr2 . 
423 .It Xo
424 .Aq Va expr1
425 .Ic ?
426 .Aq Va expr2
427 .Ic :
428 .Aq Va expr3
429 .Xc
430 Returns the value of
431 .Aq Va expr2 
432 if
433 .Aq Va expr1 
434 evaluates true
435 (non-zero numeric value); returns the value of
436 .Aq Va expr3 
437 otherwise.  Only
438 one of
439 .Aq Va expr2 
440 and
441 .Aq Va expr3 
442 is evaluated.
443 .Aq Va Expr1 
444 must
445 be numeric.
446 .It Xo
447 .Aq Va expr1
448 .Ic \&|\&|
449 .Aq Va expr2
450 .Xc
451 Logical or.  Numeric values only.  Short circuit evaluation is supported
452 (i.e., if
453 .Aq Va expr1 
454 evaluates true, then
455 .Aq Va expr2 
456 is not evaluated).
457 .It Xo
458 .Aq Va expr1
459 .Ic \&&\&&
460 .Aq Va expr2
461 .Xc
462 Logical and with short circuit evaluation.  Numeric values only.
463 .It Xo
464 .Aq Va expr1
465 .Ic \&|
466 .Aq Va expr2
467 .Xc
468 Bitwise or.  Numeric values only.
469 .It Xo
470 .Aq Va expr1
471 .Ic ^
472 .Aq Va expr2
473 .Xc
474 Bitwise exclusive or.  Numeric values only.
475 .It Xo
476 .Aq Va expr1
477 .Ic \&&
478 .Aq Va expr2
479 .Xc
480 Bitwise and.  Numeric values only.
481 .It Xo
482 .Aq Va expr1
483 .Ic ==
484 .Aq Va expr2 ,
485 .Aq Va expr1
486 .Ic !=
487 .Aq expr2
488 .Xc
489 Comparison (equal and not equal, respectively).  The boolean
490 result (either 1 or 0) of the comparison is returned.  The
491 operands can be numeric or string valued.  One string operand
492 forces the other to be converted to a string in necessary.
493 .It Xo
494 .Aq Va expr1
495 .Ic <
496 .Aq Va expr2 ,
497 .Aq Va expr1
498 .Ic >
499 .Aq Va expr2 ,
500 .Aq Va expr1
501 .Ic <=
502 .Aq Va expr2 ,
503 .Xc
504 Less than, greater than, less than or equal to,
505 greater than or equal to.  Both numeric and string values, with
506 automatic conversion as above.
507 .It Xo
508 .Aq Va expr1
509 .Ic <<
510 .Aq Va expr2 ,
511 .Aq Va expr1
512 .Ic >>
513 .Aq Va expr2
514 .Xc
515 If both operands are numbers,
516 .Aq Va expr1
517 is bit
518 shifted left (or right) by
519 .Aq Va expr2
520 bits.  If
521 .Aq Va expr1
522 is
523 a string, then its first (or last)
524 .Aq Va expr2
525 characters are
526 returns (if
527 .Aq Va expr2
528 is also a string, then its length is used
529 in place of its value).
530 .It Xo
531 .Aq Va expr1
532 .Ic +
533 .Aq Va expr2 ,
534 .Aq Va expr1
535 .Ic -
536 .Aq Va expr2
537 .Xc
538 Addition and subtraction on numbers.  For ``+'', if one
539 argument is a string, then the other is converted to a string,
540 and the result is the concatenation of the two strings.
541 .It Xo
542 .Aq Va expr1
543 .Ic \&*
544 .Aq Va expr2 ,
545 .Aq Va expr1
546 .Ic \&/
547 .Aq Va expr2 ,
548 .Aq Va expr1
549 .Ic \&%
550 .Aq Va expr2
551 .Xc
552 Multiplication, division, modulo.  Numbers only.
553 .It Xo
554 .Ic \- Ns Aq Va expr ,
555 .Ic ~ Ns Aq Va expr ,
556 .Ic \&! Ns Aq Va expr ,
557 .Ic \&$ Ns Aq Va expr ,
558 .Ic \&$? Ns Aq Va expr
559 .Xc
560 The first three are unary minus, bitwise complement and logical complement
561 on numbers only.  The operator, ``$'', takes
562 .Aq Va expr
563 and returns
564 the value of the variable of that name.  If
565 .Aq Va expr
566 is numeric
567 with value
568 .Ar n
569 and it appears within an alias macro (see below),
570 then it refers to the nth argument of the alias invocation.  ``$?''
571 tests for the existence of the variable
572 .Aq Va expr ,
573 and returns 1
574 if it exists or 0 otherwise.
575 .It Xo
576 .Ao Va expr Ac Ns Pq Aq Ar arglist
577 .Xc
578 Function call.
579 .Aq Va Expr
580 must be a string that is the unique
581 prefix of the name of a builtin
582 .Nm window
583 function
584 or the full name of a user defined alias macro.  In the case of a builtin
585 function,
586 .Aq Ar arglist
587 can be in one of two forms:
588 .Bd -literal -offset indent
589 <expr1>, <expr2>, ...
590 argname1 = <expr1>, argname2 = <expr2>, ...
591 .Ed
592 .Pp
593 The two forms can in fact be intermixed, but the result is
594 unpredictable.  Most arguments can be omitted; default values will
595 be supplied for them.  The
596 .Ar argnames
597 can be unique prefixes
598 of the argument names.  The commas separating
599 arguments are used only to disambiguate, and can usually be omitted.
600 .Pp
601 Only the first argument form is valid for user defined aliases.  Aliases
602 are defined using the
603 .Ic alias
604 builtin function (see below).  Arguments
605 are accessed via a variant of the variable mechanism (see ``$'' operator
606 above).
607 .Pp
608 Most functions return value, but some are used for side effect
609 only and so must be used as statements.  When a function or an alias is used
610 as a statement, the parentheses surrounding
611 the argument list may be omitted.  Aliases return no value.
612 .El
613 .Ss  Builtin Functions
614 The arguments are listed by name in their natural
615 order.  Optional arguments are in square brackets
616 .Sq Op .
617 Arguments
618 that have no names are in angle brackets
619 .Sq <> .
620 An argument meant to be a boolean flag (often named
621 .Ar flag )
622 can be one of
623 .Ar on ,
624 .Ar off ,
625 .Ar yes ,
626 .Ar no ,
627 .Ar true ,
628 or
629 .Ar false ,
630 with
631 obvious meanings, or it can be a numeric expression,
632 in which case a non-zero value is true.
633 .Bl -tag -width Fl
634 .It Xo
635 .Ic alias Ns Po Bq Aq Ar string ,
636 .Bq Aq Ar string\-list Pc
637 .Xc
638 If no argument is given, all currently defined alias macros are
639 listed.  Otherwise,
640 .Aq Ar string
641 is defined as an alias,
642 with expansion
643 .Aq Ar string\-list > . 
644 The previous definition of
645 .Aq Ar string ,
646 if any, is returned.  Default for
647 .Aq Ar string\-list
648 is no change.
649 .It Ic close Ns Pq Aq Ar window\-list
650 Close the windows specified in
651 .Aq Ar window\-list .
652 If
653 .Aq Ar window\-list
654 is the word
655 .Ar all  ,
656 than all windows are closed.  No value is returned.
657 .It Ic cursormodes Ns Pq Bq Ar modes
658 Set the window cursor to
659 .Ar modes  .
660 .Ar Modes
661 is the bitwise
662 or of the mode bits defined as the variables
663 .Ar m_ul
664 (underline),
665 .Ar m_rev
666 (reverse video),
667 .Ar m_blk
668 (blinking),
669 and
670 .Ar m_grp
671 (graphics, terminal dependent).  Return
672 value is the previous modes.  Default is no change.
673 For example,
674 .Li cursor($m_rev$m_blk)
675 sets the window cursors to blinking
676 reverse video.
677 .It Ic default_nline Ns Pq Bq Ar nline
678 Set the default buffer size to
679 .Ar nline  .
680 Initially, it is
681 48 lines.  Returns the old default buffer size.  Default is
682 no change.  Using a very large buffer can slow the program down
683 considerably.
684 .It Ic default_shell Ns Pq Bq Aq Ar string\-list
685 Set the default window shell program to
686 .Aq Ar string\-list .
687 Returns
688 the first string in the old shell setting.  Default is no change.  Initially,
689 the default shell is taken from the environment variable
690 .Ev SHELL  .
691 .It Ic default_smooth Ns Pq Bq Ar flag
692 Set the default value of the
693 .Ar smooth
694 argument
695 to the command
696 .Nm window
697 (see below).  The argument
698 is a boolean flag (one of
699 .Ar on  ,
700 .Ar off  ,
701 .Ar yes  ,
702 .Ar no  ,
703 .Ar true  ,
704 .Ar false  ,
705 or a number,
706 as described above).  Default is no change.
707 The old value (as a number) is returned.
708 The initial value is 1 (true).
709 .It Xo
710 .Ic echo Ns ( Op Ar window ,
711 .Bq Aq Ar string\-list )
712 .Xc
713 Write the list of strings,
714 .Aq Ar string-list ,
715 to
716 .Nm window  ,
717 separated
718 by spaces and terminated with a new line.  The strings are only
719 displayed in the window, the processes in the window are not
720 involved (see
721 .Ic write
722 below).  No value is returned.  Default
723 is the current window.
724 .It Ic escape Ns Pq Bq Ar escapec
725 Set the escape character to
726 .Ar escape-char  .
727 Returns the old
728 escape character as a one-character string.  Default is no
729 change.
730 .Ar Escapec
731 can be a string of a single character, or
732 in the form
733 .Fl ^X ,
734 meaning
735 .No control\- Ns Ar X .
736 .It Xo
737 .Ic foreground Ns ( Bq Ar window ,
738 .Bq Ar flag ) 
739 .Xc
740 Move
741 .Nm window
742 in or out of foreground.
743 .Ar Flag
744 is a boolean value.  The old foreground flag
745 is returned.  Default for
746 .Nm window
747 is the current window,
748 default for
749 .Ar flag
750 is no change.
751 .It Xo
752 .Ic label Ns ( Bq Ar window ,
753 .Bq Ar label ) 
754 .Xc
755 Set the label of
756 .Nm window
757 to
758 .Ar label  .
759 Returns the old
760 label as a string.  Default for
761 .Nm window
762 is the current
763 window, default for
764 .Ar label
765 is no change.  To turn
766 off a label, set it to an empty string ("").
767 .It Ic list Ns Pq
768 No arguments.  List the identifiers and labels of all windows.  No
769 value is returned.
770 .It Ic select Ns Pq Bq Ar window
771 Make
772 .Nm window
773 the current window.  The previous current window
774 is returned.  Default is no change.
775 .It Ic source Ns Pq Ar filename
776 Read and execute the long commands in
777 .Ar filename  .
778 Returns \-1 if the file cannot be read, 0 otherwise.
779 .It Ic terse Ns Pq Bq flag
780 Set terse mode to
781 .Ar flag  .
782 In terse mode, the command window
783 stays hidden even in command mode, and errors are reported by
784 sounding the terminal's bell.
785 .Ar Flag
786 can take on the same
787 values as in
788 .Ar foreground
789 above.  Returns the old terse flag.
790 Default is no change.
791 .It Ic unalias Ns Pq Ar alias
792 Undefine
793 .Ar alias  .
794 Returns -1 if
795 .Ar alias
796 does not exist,
797 0 otherwise.
798 .It Ic unset Ns Pq Ar variable
799 Undefine
800 .Ar variable  .
801 Returns -1 if
802 .Ar variable
803 does not exist,
804 0 otherwise.
805 .It Ic variables Ns Pq
806 No arguments.  List all variables.  No value is returned.
807 .It Xo
808 .Ic window Ns ( Bq Ar row ,
809 .Bq Ar column ,
810 .Bq Ar nrow ,
811 .Bq Ar ncol ,
812 .Bq Ar nline ,
813 .Bq Ar label ,
814 .Bq Ar pty , 
815 .Bq Ar frame ,
816 .Bq Ar mapnl ,
817 .Bq Ar keepopen ,
818 .Bq Ar smooth ,
819 .Bq Ar shell ) . 
820 .Xc
821 Open a window with upper left corner at
822 .Ar row  ,
823 .Ar column
824 and size
825 .Ar nrow  ,
826 .Ar ncol  .
827 If
828 .Ar nline
829 is specified,
830 then that many lines are allocated for the text buffer.  Otherwise,
831 the default buffer size is used.  Default values for
832 .Ar row  ,
833 .Ar column  ,
834 .Ar nrow  ,
835 and
836 .Ar ncol
837 are, respectively,
838 the upper, left-most, lower, or right-most extremes of the
839 screen.
840 .Ar Label
841 is the label string.
842 .Ar Frame  ,
843 .Ar pty  ,
844 and
845 .Ar mapnl
846 are flag values
847 interpreted in the same way as the argument to
848 .Ar foreground
849 (see above);
850 they mean, respectively, put a frame around this window (default true),
851 allocate pseudo-terminal for this window rather than socketpair (default
852 true), and map new line characters in this window to carriage return
853 and line feed (default true if socketpair is used, false otherwise).
854 Normally, a window is automatically closed when its process
855 exits.  Setting
856 .Ar keepopen
857 to true (default false) prevents this
858 action.  When
859 .Ar smooth
860 is true, the screen is updated more frequently
861 (for this window) to produce a more terminal-like behavior.
862 The default value of
863 .Ar smooth
864 is set by the
865 .Ar default_smooth
866 command (see above).
867 .Ar Shell
868 is a list of strings that will be used as the shell
869 program to place in the window (default is the program specified
870 by
871 .Ar default_shell  ,
872 see above).  The created window's identifier
873 is returned as a number.
874 .It Xo
875 .Ic write Ns ( Bq Ar window ,
876 .Bq Aq Ar string\-list )
877 .Xc
878 Send the list of strings,
879 .Aq Ar string-list ,
880 to
881 .Nm window  ,
882 separated
883 by spaces but not terminated with a new line.  The strings are actually
884 given to the window as input.  No value is returned.  Default
885 is the current window.
886 .El
887 .Ss Predefined Variables
888 These variables are for information only.  Redefining them does
889 not affect the internal operation of
890 .Nm window  .
891 .Bl -tag -width modes
892 .It Ar baud
893 The baud rate as a number between 50 and 38400.
894 .It Ar modes
895 The display modes (reverse video, underline, blinking, graphics)
896 supported by the physical terminal.  The value of
897 .Ar modes
898 is the bitwise or of some of the one bit values,
899 .Ar m_blk ,
900 .Ar m_grp ,
901 .Ar m_rev ,
902 and
903 .Ar m_ul
904 (see below).
905 These values are useful
906 in setting the window cursors' modes (see
907 .Ar cursormodes
908 above).
909 .It Ar m_blk
910 The blinking mode bit.
911 .It Ar m_grp
912 The graphics mode bit (not very useful).
913 .It Ar m_rev
914 The reverse video mode bit.
915 .It Ar m_ul
916 The underline mode bit.
917 .It Ar ncol
918 The number of columns on the physical screen.
919 .It Ar nrow
920 The number of rows on the physical screen.
921 .It Ar term
922 The terminal type.  The standard name, found in the second name
923 field of the terminal's
924 .Ev TERMCAP
925 entry, is used.
926 .Sh ENVIRONMENT
927 .Nm Window
928 utilizes these environment variables:
929 .Ev HOME ,
930 .Ev SHELL ,
931 .Ev TERM ,
932 .Ev TERMCAP ,
933 .Ev WINDOW_ID .
934 .Sh FILES
935 .Bl -tag -width /dev/[pt]ty[pq]? -compact
936 .It Pa ~/.windowrc
937 startup command file.
938 .It Pa /dev/[pt]ty[pq]? 
939 pseudo-terminal devices.
940 .El
941 .Sh HISTORY
942 The
943 .Nm window
944 command appeared in
945 .Bx 4.3 .
946 .Sh DIAGNOSTICS
947 Should be self explanatory.