1 .\" $NetBSD: window.1,v 1.16 2009/03/10 21:18:35 joerg 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
45 .Op Fl e Ar escape-char
48 implements a window environment on
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.
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
62 At any one time, only one window can receive
63 input from the keyboard, but all windows can simultaneously send output
68 starts up, the commands (see long commands below)
71 in the user's home directory are
73 If it does not exist, two equal sized windows spanning
74 the terminal screen are created by default.
76 The command-line options are:
81 as a long command (see below)
82 before doing anything else.
86 and create the two default
88 .It Fl e Ar escape-char
89 Set the escape character to
92 can be a single character, or in the form
96 is any character, meaning
97 .No control- Ns Ar X .
100 Don't perform any startup action.
102 Turn on terse mode (see
107 Windows can overlap and are framed as necessary.
109 is named by one of the digits
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
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.
123 (possibly larger than the screen) may be positioned to show only
124 a portion of its full size.
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.
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
135 .Ss Process Environment
136 With each newly created window, a shell program is spawned with its
137 process environment tailored to that window.
139 output, and diagnostic file descriptors are bound to one end of either
140 a pseudo-terminal (see
146 If a pseudo-terminal is used, then its special
147 characters and modes (see
149 are copied from the physical
153 entry tailored to this window is created
154 and passed as environment (see
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,
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
169 this information to redraw its display.
171 During normal execution,
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.
182 it is set apart by highlighting its identifier and label in reverse video.
186 escape character (normally
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
193 interprets input from the keyboard as commands to manipulate windows.
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
199 command below), or read from a file (see
205 represents one of the digits
209 corresponding to the windows 1 to 9.
212 .No control- Ns Ar X ,
221 is the escape key, or
227 as the current window
228 and return to conversation mode.
232 but stay in command mode.
234 Select the previous window and return to conversation mode.
235 This is useful for toggling between two windows.
237 Return to conversation mode.
239 Return to conversation mode and write
241 to the current window.
244 in conversation mode sends one to the current window.
247 escape is changed to some other character, that
248 character takes the place of
252 List a short summary of commands.
258 Confirmation is requested.
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
272 move the cursor left, down, up, and right, respectively.
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.
286 the placement of the new window is indicated by a rectangular
287 box drawn on the screen, corresponding to where the new window
289 Typing escape at any point cancels this command.
291 This window becomes the current window,
292 and is given the first available ID.
293 The default buffer size is used (see
297 Only fully visible windows can be created this way.
301 The process in the window is sent
302 the hangup signal (see
306 handle this signal correctly and cause no problems.
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
315 command are used to position the box.
316 The window can be moved partially off-screen.
320 to its previous position.
322 Change the size of window
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
331 are used to enter the position.
335 to its previous size.
337 Scroll the current window up by one line.
339 Scroll the current window down by one line.
341 Scroll the current window up by half the window size.
343 Scroll the current window down by half the window size.
345 Scroll the current window up by the full window size.
347 Scroll the current window down by the full window size.
349 Move the cursor of the current window left by one column.
351 Move the cursor of the current window down by one line.
353 Move the cursor of the current window up by one line.
355 Move the cursor of the current window right by one column.
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.
363 The content of the yank buffer is written to the current window as input.
365 Stop output in the current window.
367 Start output in the current window.
369 Enter a line to be executed as long commands.
371 editing characters (erase character, erase word, erase line)
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.
381 There are two data types: string and number.
382 A string is a sequence
383 of letters or digits beginning with a letter.
387 are considered letters.
388 Alternatively, non-alphanumeric characters can
389 be included in strings by quoting them in double
391 quotes or escaping them with backslash
395 sequences of C are supported,
396 both inside and outside quotes (e.g.,
401 For example, these are legal strings:
402 abcde01234, "\*[Am]#$^*\*[Am]#", ab"$#"cd, ab\\$\\#cd, "/usr/ucb/window".
404 A number is an integer value in one of three forms:
405 a decimal number, an octal number preceded by
407 or a hexadecimal number preceded by
411 The natural machine integer size is used (i.e., the signed integer type
413 As in C, a non-zero number represents a boolean true.
417 begins a comment which terminates at the
420 A statement is either a conditional or an expression.
421 Expression statements are terminated with a new line or
424 an expression on the next line, terminate the first line with
426 .Ss Conditional Statement
428 has a single control structure:
429 the fully bracketed if statement in the form
431 .Bd -literal -offset indent -compact
432 if \*[Lt]expr\*[Gt] then
433 \t\*[Lt]statement\*[Gt]
435 elsif \*[Lt]expr\*[Gt] then
436 \t\*[Lt]statement\*[Gt]
439 \t\*[Lt]statement\*[Gt]
448 parts are optional, and the latter can
449 be repeated any number of times.
455 are similar to those in the
456 C language, with most C operators supported on numeric
458 In addition, some are overloaded to operate on strings.
460 When an expression is used as a statement, its value is discarded
462 Therefore, only expressions with side
463 effects (assignments and function calls) are useful as statements.
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.
470 The operators in order of increasing precedence:
480 which must be string valued,
481 is assigned the result of
497 (non-zero numeric value); returns the value of
515 Short circuit evaluation is supported
526 Logical and with short circuit evaluation.
540 Bitwise exclusive or.
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.
561 forces the other to be converted to a string in necessary.
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.
585 If both operands are numbers,
588 shifted left (or right) by
594 a string, then its first (or last)
599 is also a string, then its length is used
600 in place of its value).
609 Addition and subtraction on numbers.
613 argument is a string, then the other is converted to a string,
614 and the result is the concatenation of the two strings.
626 Multiplication, division, modulo.
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
635 The first three are unary minus, bitwise complement and logical complement
642 the value of the variable of that name.
648 and it appears within an alias macro (see below),
649 then it refers to the nth argument of the alias invocation.
651 tests for the existence of the variable
654 if it exists or 0 otherwise.
656 .Ao Va expr Ac Ns Pq Aq Ar arglist
660 must be a string that is the unique
661 prefix of the name of a builtin
664 or the full name of a user defined alias macro.
665 In the case of a builtin function,
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], ...
673 The two forms can in fact be intermixed, but the result is
675 Most arguments can be omitted; default values will
676 be supplied for them.
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.
684 Only the first argument form is valid for user defined aliases.
685 Aliases are defined using the
687 builtin function (see below).
689 are accessed via a variant of the variable mechanism (see
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.
700 .Ss Builtin Functions
701 The arguments are listed by name in their natural order.
702 Optional arguments are in square brackets
705 that have no names are in angle brackets
707 An argument meant to be a boolean flag (often named
718 obvious meanings, or it can be a numeric expression,
719 in which case a non-zero value is true.
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
726 is defined as an alias,
729 The previous definition of
735 .It Ic close Ns Pq Aq Ar window-list
736 Close the windows specified in
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
749 or of the mode bits defined as the variables
758 (graphics, terminal dependent).
759 Return value is the previous modes.
760 Default is no change.
762 .Li cursor($m_rev$m_blk)
763 sets the window cursors to blinking
765 .It Ic default_nline Ns Pq Bq Ar nline
766 Set the default buffer size to
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
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
781 .It Ic default_smooth Ns Pq Bq Ar flag
782 Set the default value of the
788 The argument is a boolean flag (one of
797 Default is no change.
798 The old value (as a number) is returned.
799 The initial value is 1 (true).
801 .Ic echo Ns ( Op Ar window ,
802 .Bq Aq Ar string-list )
804 Write the list of strings,
809 by spaces and terminated with a new line.
811 displayed in the window, the processes in the window are not
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
821 escape character as a one-character string.
822 Default is no change.
824 can be a string of a single character, or
828 .No control- Ns Ar X .
830 .Ic foreground Ns ( Bq Ar window ,
835 in or out of foreground.
838 The old foreground flag is returned.
841 is the current window,
846 .Ic label Ns ( Bq Ar window ,
861 To turn off a label, set it to an empty string ("").
864 List the identifiers and labels of all windows.
865 No value is returned.
866 .It Ic select Ns Pq Bq Ar 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
875 Returns \-1 if the file cannot be read, 0 otherwise.
876 .It Ic terse Ns Pq Bq 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.
887 Returns the old terse flag.
888 Default is no change.
889 .It Ic unalias Ns Pq Ar alias
896 .It Ic unset Ns Pq Ar variable
903 .It Ic variables Ns Pq
906 No value is returned.
908 .Ic window Ns ( Bq Ar row ,
921 Open a window with upper left corner at
930 then that many lines are allocated for the text buffer.
931 Otherwise, the default buffer size is used.
939 the upper, left-most, lower, or right-most extremes of the
948 interpreted in the same way as the argument to
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
959 to true (default false) prevents this action.
962 is true, the screen is updated more frequently
963 (for this window) to produce a more terminal-like behavior.
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
975 The created window's identifier is returned as a number.
977 .Ic write Ns ( Bq Ar window ,
978 .Bq Aq Ar string-list )
980 Send the list of strings,
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.
990 .Ss Predefined Variables
991 These variables are for information only.
992 Redefining them does not affect the internal operation of
994 .Bl -tag -width modes
996 The baud rate as a number between 50 and 38400.
998 The display modes (reverse video, underline, blinking, graphics)
999 supported by the physical terminal.
1002 is the bitwise or of some of the one bit values,
1009 These values are useful
1010 in setting the window cursors' modes (see
1014 The blinking mode bit.
1016 The graphics mode bit (not very useful).
1018 The reverse video mode bit.
1020 The underline mode bit.
1022 The number of columns on the physical screen.
1024 The number of rows on the physical screen.
1027 The standard name, found in the second name field of the terminal's
1033 uses these environment variables:
1040 .Bl -tag -width /dev/[pt]ty[pq]? -compact
1042 startup command file.
1043 .It Pa /dev/[pt]ty[pq]?
1044 pseudo-terminal devices.
1047 The following example
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
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
1059 Should be self explanatory.