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