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