1 .\" $NetBSD: window.1,v 1.18 2009/06/25 23:20:55 wiz Exp $
3 .\" Copyright (c) 1985, 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" Edward Wang at The University of California, Berkeley.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
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.
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
33 .\" @(#)window.1 8.2 (Berkeley) 12/30/93
40 .Nd window environment
46 .Op Fl e Ar escape-char
50 implements a window environment on
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.
58 communicate with their window in the same way they normally
59 interact with a terminal\-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
64 At any one time, only one window can receive
65 input from the keyboard, but all windows can simultaneously send output
70 starts up, the commands (see long commands below)
73 in the user's home directory are
75 If it does not exist, two equal sized windows spanning
76 the terminal screen are created by default.
78 The command line options are
81 Turn on terse mode (see
86 Don't perform any startup action.
90 and create the two default
92 .It Fl e Ar escape-char
93 Set the escape character to
96 can be a single character, or in the form
100 is any character, meaning
101 .No control\- Ns Ar X .
105 as a long command (see below)
106 before doing anything else.
109 Windows can overlap and are framed as necessary.
111 is named by one of the digits
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
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.
125 (possibly larger than the screen) may be positioned to show only
126 a portion of its full size.
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.
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
137 .Ss Process Environment
138 With each newly created window, a shell program is spawned with its
139 process environment tailored to that window.
141 output, and diagnostic file descriptors are bound to one end of either
142 a pseudo-terminal (see
148 If a pseudo-terminal is used, then its special
149 characters and modes (see
151 are copied from the physical
155 entry tailored to this window is created
156 and passed as environment (see
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,
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
171 this information to redraw its display.
173 During normal execution,
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.
184 it is set apart by highlighting its identifier and label in reverse video.
188 escape character (normally
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
195 interprets input from the keyboard as commands to manipulate windows.
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
201 command below), or read from a file (see
207 represents one of the digits
211 corresponding to the windows 1 to 9.
214 .No control\- Ns Ar X ,
223 is the escape key, or
229 as the current window
230 and return to conversation mode.
234 but stay in command mode.
236 Select the previous window and return to conversation mode.
237 This is useful for toggling between two windows.
239 Return to conversation mode.
241 Return to conversation mode and write
243 to the current window.
246 in conversation mode sends one to the current window.
249 escape is changed to some other character, that
250 character takes the place of
254 List a short summary of commands.
260 Confirmation is requested.
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
274 move the cursor left, down, up, and right, respectively.
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.
288 the placement of the new window is indicated by a rectangular
289 box drawn on the screen, corresponding to where the new window
291 Typing escape at any point cancels this command.
293 This window becomes the current window,
294 and is given the first available ID.
295 The default buffer size is used (see
299 Only fully visible windows can be created this way.
303 The process in the window is sent
304 the hangup signal (see
308 handle this signal correctly and cause no problems.
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
317 command are used to position the box.
318 The window can be moved partially off-screen.
322 to its previous position.
324 Change the size of window
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
333 are used to enter the position.
337 to its previous size.
339 Scroll the current window up by one line.
341 Scroll the current window down by one line.
343 Scroll the current window up by half the window size.
345 Scroll the current window down by half the window size.
347 Scroll the current window up by the full window size.
349 Scroll the current window down by the full window size.
351 Move the cursor of the current window left by one column.
353 Move the cursor of the current window down by one line.
355 Move the cursor of the current window up by one line.
357 Move the cursor of the current window right by one column.
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.
365 The content of the yank buffer is written to the current window as input.
367 Stop output in the current window.
369 Start output in the current window.
371 Enter a line to be executed as long commands.
373 editing characters (erase character, erase word, erase line)
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.
383 There are two data types: string and number.
384 A string is a sequence
385 of letters or digits beginning with a letter.
389 are considered letters.
390 Alternatively, non-alphanumeric characters can
391 be included in strings by quoting them in double
393 quotes or escaping them with backslash
397 sequences of C are supported,
398 both inside and outside quotes (e.g.,
403 For example, these are legal strings:
404 abcde01234, "\*[Am]#$^*\*[Am]#", ab"$#"cd, ab\\$\\#cd, "/usr/ucb/window".
406 A number is an integer value in one of three forms:
407 a decimal number, an octal number preceded by
409 or a hexadecimal number preceded by
413 The natural machine integer size is used (i.e., the signed integer type
415 As in C, a non-zero number represents a boolean true.
419 begins a comment which terminates at the
422 A statement is either a conditional or an expression.
423 Expression statements are terminated with a new line or
426 an expression on the next line, terminate the first line with
428 .Ss Conditional Statement
430 has a single control structure:
431 the fully bracketed if statement in the form
433 .Bd -literal -offset indent -compact
434 if \*[Lt]expr\*[Gt] then
435 \t\*[Lt]statement\*[Gt]
437 elsif \*[Lt]expr\*[Gt] then
438 \t\*[Lt]statement\*[Gt]
441 \t\*[Lt]statement\*[Gt]
450 parts are optional, and the latter can
451 be repeated any number of times.
457 are similar to those in the
458 C language, with most C operators supported on numeric
460 In addition, some are overloaded to operate on strings.
462 When an expression is used as a statement, its value is discarded
464 Therefore, only expressions with side
465 effects (assignments and function calls) are useful as statements.
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.
472 The operators in order of increasing precedence:
474 .It Ao Va expr1 Ac Ic = Ao Va expr2 Ac
478 which must be string valued,
479 is assigned the result of
483 .It Ao Va expr1 Ac Ic \&? Ao Va expr2 Ac Ic : Ao Va expr3 Ac
489 (non-zero numeric value); returns the value of
500 .It Ao Va expr1 Ac Ic \&|\&| Ao Va expr2 Ac
503 Short circuit evaluation is supported
509 .It Ao Va expr1 Ac Ic \&\*[Am]\&\*[Am] Ao Va expr2 Ac
510 Logical and with short circuit evaluation.
512 .It Ao Va expr1 Ac Ic \&| Ao Va expr2 Ac
515 .It Ao Va expr1 Ac Ic ^ Ao Va expr2 Ac
516 Bitwise exclusive or.
518 .It Ao Va expr1 Ac Ic \&\*[Am] Ao Va expr2 Ac
521 .It Ao Va expr1 Ac Ic == Ao Va expr2 Ac , Ao Va expr1 Ac Ic != Ao expr2 Ac
522 Comparison (equal and not equal, respectively).
523 The boolean result (either 1 or 0) of the comparison is returned.
524 The operands can be numeric or string valued.
526 forces the other to be converted to a string in necessary.
527 .It Ao Va expr1 Ac Ic \*[Lt] Ao Va expr2 Ac , \
528 Ao Va expr1 Ac Ic \*[Gt] Ao Va expr2 Ac , \
529 Ao Va expr1 Ac Ic \*[Le] Ao Va expr2 Ac ,
530 Less than, greater than, less than or equal to,
531 greater than or equal to.
532 Both numeric and string values, with
533 automatic conversion as above.
534 .It Ao Va expr1 Ac Ic \*[Lt]\*[Lt] Ao Va expr2 Ac , \
535 Ao Va expr1 Ac Ic \*[Gt]\*[Gt] Ao Va expr2 Ac
536 If both operands are numbers,
539 shifted left (or right) by
545 a string, then its first (or last)
550 is also a string, then its length is used
551 in place of its value).
552 .It Ao Va expr1 Ac Ic + Ao Va expr2 Ac , Ao Va expr1 Ac Ic - Ao Va expr2 Ac
553 Addition and subtraction on numbers.
557 argument is a string, then the other is converted to a string,
558 and the result is the concatenation of the two strings.
559 .It Ao Va expr1 Ac Ic \&* Ao Va expr2 Ac , \
560 Ao Va expr1 Ac Ic \&/ Ao Va expr2 Ac , Ao Va expr1 Ac Ic \&% Ao Va expr2 Ac
561 Multiplication, division, modulo.
563 .It Ic \- Ns Ao Va expr Ac , Ic ~ Ns Ao Va expr Ac , \
564 Ic \&! Ns Ao Va expr Ac , Ic \&$ Ns Ao Va expr Ac , Ic \&$? Ns Ao Va expr Ac
565 The first three are unary minus, bitwise complement and logical complement
572 the value of the variable of that name.
578 and it appears within an alias macro (see below),
579 then it refers to the nth argument of the alias invocation.
581 tests for the existence of the variable
584 if it exists or 0 otherwise.
585 .It Ao Va expr Ac Ns Pq Aq Ar arglist
588 must be a string that is the unique
589 prefix of the name of a builtin
592 or the full name of a user defined alias macro.
593 In the case of a builtin function,
595 can be in one of two forms:
596 .Bd -literal -offset indent
597 \*[Lt]expr1\*[Gt], \*[Lt]expr2\*[Gt], ...
598 argname1 = \*[Lt]expr1\*[Gt], argname2 = \*[Lt]expr2\*[Gt], ...
601 The two forms can in fact be intermixed, but the result is
603 Most arguments can be omitted; default values will
604 be supplied for them.
607 can be unique prefixes
608 of the argument names.
609 The commas separating
610 arguments are used only to disambiguate, and can usually be omitted.
612 Only the first argument form is valid for user defined aliases.
613 Aliases are defined using the
615 builtin function (see below).
617 are accessed via a variant of the variable mechanism (see
621 Most functions return value, but some are used for side effect
622 only and so must be used as statements.
623 When a function or an alias is used
624 as a statement, the parentheses surrounding
625 the argument list may be omitted.
626 Aliases return no value.
628 .Ss Builtin Functions
629 The arguments are listed by name in their natural order.
630 Optional arguments are in square brackets
633 that have no names are in angle brackets
635 An argument meant to be a boolean flag (often named
646 obvious meanings, or it can be a numeric expression,
647 in which case a non-zero value is true.
649 .It Ic alias Ns Po Bo Ao Ar string Ac Bc , Bo Ao Ar string\-list Ac Bc Pc
650 If no argument is given, all currently defined alias macros are
654 is defined as an alias,
656 .Aq Ar string\-list \*[Gt] .
657 The previous definition of
663 .It Ic close Ns Pq Aq Ar window\-list
664 Close the windows specified in
665 .Aq Ar window\-list .
670 than all windows are closed.
671 No value is returned.
672 .It Ic cursormodes Ns Pq Bq Ar modes
673 Set the window cursor to
677 or of the mode bits defined as the variables
686 (graphics, terminal dependent).
687 Return value is the previous modes.
688 Default is no change.
690 .Li cursor($m_rev$m_blk)
691 sets the window cursors to blinking
693 .It Ic default_nline Ns Pq Bq Ar nline
694 Set the default buffer size to
698 Returns the old default buffer size.
699 Default is no change.
700 Using a very large buffer can slow the program down considerably.
701 .It Ic default_shell Ns Pq Bq Aq Ar string\-list
702 Set the default window shell program to
703 .Aq Ar string\-list .
705 the first string in the old shell setting.
706 Default is no change.
707 Initially, the default shell is taken from the environment variable
709 .It Ic default_smooth Ns Pq Bq Ar flag
710 Set the default value of the
716 The argument is a boolean flag (one of
725 Default is no change.
726 The old value (as a number) is returned.
727 The initial value is 1 (true).
728 .It Ic echo Ns ( Oo Ar window Oc , Bq Aq Ar string\-list )
729 Write the list of strings,
734 by spaces and terminated with a new line.
736 displayed in the window, the processes in the window are not
740 No value is returned.
741 Default is the current window.
742 .It Ic escape Ns Pq Bq Ar escapec
743 Set the escape character to
746 escape character as a one-character string.
747 Default is no change.
749 can be a string of a single character, or
753 .No control\- Ns Ar X .
754 .It Ic foreground Ns ( Bo Ar window Bc , Bq Ar flag )
757 in or out of foreground.
760 The old foreground flag is returned.
763 is the current window,
767 .It Ic label Ns ( Bo Ar window Bc , Bq Ar label )
780 To turn off a label, set it to an empty string ("").
783 List the identifiers and labels of all windows.
784 No value is returned.
785 .It Ic select Ns Pq Bq Ar window
789 The previous current window is returned.
790 Default is no change.
791 .It Ic source Ns Pq Ar filename
792 Read and execute the long commands in
794 Returns \-1 if the file cannot be read, 0 otherwise.
795 .It Ic terse Ns Pq Bq flag
798 In terse mode, the command window
799 stays hidden even in command mode, and errors are reported by
800 sounding the terminal's bell.
806 Returns the old terse flag.
807 Default is no change.
808 .It Ic unalias Ns Pq Ar alias
815 .It Ic unset Ns Pq Ar variable
822 .It Ic variables Ns Pq
825 No value is returned.
826 .It Ic window Ns ( Bo Ar row Bc , Bo Ar column Bc , Bo Ar nrow Bc , \
827 Bo Ar ncol Bc , Bo Ar nline Bc , Bo Ar label Bc , Bo Ar pty Bc , \
828 Bo Ar frame Bc , Bo Ar mapnl Bc , Bo Ar keepopen Bc , Bo Ar smooth Bc , \
830 Open a window with upper left corner at
839 then that many lines are allocated for the text buffer.
840 Otherwise, the default buffer size is used.
848 the upper, left-most, lower, or right-most extremes of the
857 interpreted in the same way as the argument to
860 they mean, respectively, put a frame around this window (default true),
861 allocate pseudo-terminal for this window rather than socketpair (default
862 true), and map new line characters in this window to carriage return
863 and line feed (default true if socketpair is used, false otherwise).
864 Normally, a window is automatically closed when its process
868 to true (default false) prevents this action.
871 is true, the screen is updated more frequently
872 (for this window) to produce a more terminal-like behavior.
879 is a list of strings that will be used as the shell
880 program to place in the window (default is the program specified
884 The created window's identifier is returned as a number.
885 .It Ic write Ns ( Bo Ar window Bc , Bq Aq Ar string\-list )
886 Send the list of strings,
891 by spaces but not terminated with a new line.
892 The strings are actually given to the window as input.
893 No value is returned.
894 Default is the current window.
896 .Ss Predefined Variables
897 These variables are for information only.
898 Redefining them does not affect the internal operation of
900 .Bl -tag -width modes
902 The baud rate as a number between 50 and 38400.
904 The display modes (reverse video, underline, blinking, graphics)
905 supported by the physical terminal.
908 is the bitwise or of some of the one bit values,
915 These values are useful
916 in setting the window cursors' modes (see
920 The blinking mode bit.
922 The graphics mode bit (not very useful).
924 The reverse video mode bit.
926 The underline mode bit.
928 The number of columns on the physical screen.
930 The number of rows on the physical screen.
933 The standard name, found in the second name field of the terminal's
939 uses these environment variables:
946 .Bl -tag -width /dev/[pt]ty[pq]? -compact
948 startup command file.
949 .It Pa /dev/[pt]ty[pq]?
950 pseudo-terminal devices.
953 The following example
955 will open two windows.
956 The upper one will take one third of the screen
957 and run tcpdump, the lower one will take
958 the remaining two thirds of the screen and run
961 window r=1, nr=$nrow/3-1, l=tcpdump\\ pcn0, sh=tcpdump \\-ni pcn0
962 window r=$nrow/3, nr=2*$nrow/3+1
965 Should be self explanatory.