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