1 .\" Copyright (c) 1985, 1990, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Edward Wang at The University of California, Berkeley.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed by the University of
18 .\" California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\" may be used to endorse or promote products derived from this software
21 .\" without specific prior written permission.
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" @(#)window.1 8.2 (Berkeley) 12/30/93
43 .Nd window environment
49 .Op Fl e Ar escape-char
54 utility implements a window environment on
58 A window is a rectangular portion of the physical terminal
59 screen associated with a set of processes.
61 position can be changed by the user at any time.
63 communicate with their window in the same way they normally
64 interact with a terminal\-through their standard input, output,
65 and diagnostic file descriptors.
66 The window program handles the
67 details of redirecting input and output to and from the
69 At any one time, only one window can receive
70 input from the keyboard, but all windows can simultaneously send output
75 starts up, the commands (see long commands below)
78 in the user's home directory are
80 If it does not exist, two equal sized windows spanning
81 the terminal screen are created by default.
83 The command line options are
86 Turn on terse mode (see
91 Do not perform any startup action.
95 and create the two default
97 .It Fl e Ar escape-char
98 Set the escape character to
101 can be a single character, or in the form
105 is any character, meaning
106 .No control\- Ns Ar X .
110 as a long command (see below)
111 before doing anything else.
114 Windows can overlap and are framed as necessary.
116 is named by one of the digits ``1'' to ``9''.
118 identifier, as well as a user definable label string, are displayed
119 with the window on the top edge of its frame.
121 designated to be in the
123 in which case it will always be
124 on top of all normal, non-foreground windows, and can be covered
125 only by other foreground windows.
126 A window need not be completely
127 within the edges of the terminal screen.
129 (possibly larger than the screen) may be positioned to show only
130 a portion of its full size.
132 Each window has a cursor and a set of control functions.
134 terminal operations such as line and
135 character deletion and insertion are supported.
137 such as underlining and reverse video are available if they are
138 supported by the terminal.
140 similar to terminals with multiple pages of memory,
141 each window has a text buffer which can have more lines than the window
143 .Ss Process Environment
144 With each newly created window, a shell program is spawned with its
145 process environment tailored to that window.
147 output, and diagnostic file descriptors are bound to one end of either
148 a pseudo-terminal (see
154 If a pseudo-terminal is used, then its special
155 characters and modes (see
157 are copied from the physical
161 entry tailored to this window is created
162 and passed as environment (see
166 The termcap entry contains the window's size and
167 characteristics as well as information from the physical terminal,
168 such as the existence of underline, reverse video, and other display
169 modes, and the codes produced by the terminal's function keys,
171 In addition, the window size attributes of the pseudo-terminal
172 are set to reflect the size of this window, and updated whenever
173 it is changed by the user.
174 In particular, the editor
177 this information to redraw its display.
179 During normal execution,
181 can be in one of two states:
182 conversation mode and command mode.
183 In conversation mode, the
184 terminal's real cursor is placed at the cursor position of a particular
185 window--called the current window--and input from the keyboard is sent
186 to the process in that window.
187 The current window is always
188 on top of all other windows, except those in foreground.
190 it is set apart by highlighting its identifier and label in reverse video.
194 escape character (normally
197 mode switches it into command mode.
198 In command mode, the top line of
199 the terminal screen becomes the command prompt window, and
201 interprets input from the keyboard as commands to manipulate windows.
203 There are two types of commands: short commands are usually one or two
204 key strokes; long commands are strings either typed by the user in the
205 command window (see the
207 command below), or read from a file (see
213 represents one of the digits ``1'' to ``9''
214 corresponding to the windows 1 to 9.
217 .No control\- Ns Ar X ,
226 is the escape key, or
232 as the current window
233 and return to conversation mode.
237 but stay in command mode.
239 Select the previous window and return to conversation
241 This is useful for toggling between two windows.
243 Return to conversation mode.
245 Return to conversation mode and write
252 mode sends one to the current window.
255 escape is changed to some other character, that
256 character takes the place of
260 List a short summary of commands.
266 Confirmation is requested.
272 The user is prompted for the positions
273 of the upper left and lower right corners of the window.
274 The cursor is placed on the screen and the keys ``h'', ``j'',
276 move the cursor left, down, up, and right, respectively.
277 The keys ``H'', ``J'', ``K'', and ``L'' move the cursor to the respective
278 limits of the screen.
279 Typing a number before the movement keys
280 repeats the movement that number of times.
281 Return enters the cursor position
282 as the upper left corner of the window.
283 The lower right corner
284 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
290 cancels this command.
292 This window becomes the current window,
293 and is given the first available ID.
294 The default buffer size
299 Only fully visible windows can be created this way.
303 The process in the window is sent
304 the hangup signal (see
309 handle this signal correctly and cause no problems.
315 of the window is drawn on
316 the screen to indicate the new position of the window, and the same keys as
319 command are used to position the box.
321 window can be moved partially off-screen.
325 to its previous position.
327 Change the size of window
330 to enter the new lower right corner of the window.
332 is drawn to indicate the new window size.
338 are used to enter the position.
342 to its previous size.
344 Scroll the current window up by one line.
346 Scroll the current window down by one line.
348 Scroll the current window up by half the window size.
350 Scroll the current window down by half the window size.
352 Scroll the current window up by the full window size.
354 Scroll the current window down by the full window size.
356 Move the cursor of the current window left by one column.
358 Move the cursor of the current window down by one line.
360 Move the cursor of the current window up by one line.
362 Move the cursor of the current window right by one column.
365 The user is prompted to enter two points within the current
367 Then the content of the current window between those two points
368 is saved in the yank buffer.
371 The content of the yank buffer is written to the current
374 Stop output in the current window.
376 Start output in the current window.
378 Enter a line to be executed as long commands.
380 editing characters (erase character, erase word, erase line)
384 Long commands are a sequence of statements
385 parsed much like a programming language, with a syntax
386 similar to that of C.
387 Numeric and string expressions and variables
388 are supported, as well as conditional statements.
390 There are two data types: string and number.
391 A string is a sequence
392 of letters or digits beginning with a letter.
395 Alternately, non-alphanumeric characters can
396 be included in strings by quoting them in ``"'' or escaping them
398 In addition, the ``\\'' sequences of C are supported,
399 both inside and outside quotes (e.g., ``\\n'' is a new line,
400 ``\\r'' a carriage return).
401 For example, these are legal strings:
402 abcde01234, "&#$^*&#", 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 ``0'',
406 or a hexadecimal number preceded by ``0x'' or ``0X''.
408 machine integer size is used (i.e., the signed integer type
410 As in C, a non-zero number represents
413 The character ``#'' begins a comment which terminates at the
416 A statement is either a conditional or an expression.
418 statements are terminated with a new line or ``;''.
420 an expression on the next line, terminate the first line with ``\\''.
421 .Ss Conditional Statement
424 utility has a single control structure:
425 the fully bracketed if statement in the form
427 .Bd -literal -offset indent -compact
444 parts are optional, and the latter can
445 be repeated any number of times.
451 are similar to those in the
452 C language, with most C operators supported on numeric
454 In addition, some are overloaded to operate on strings.
456 When an expression is used as a statement, its value is discarded
458 Therefore, only expressions with side
459 effects (assignments and function calls) are useful as statements.
461 Single valued (no arrays) variables are supported, of both
462 numeric and string values.
463 Some variables are predefined.
467 The operators in order of increasing precedence:
477 which must be string valued,
478 is assigned the result of
494 (non-zero numeric value); returns the value of
513 Short circuit evaluation is supported
524 Logical and with short circuit evaluation.
538 Bitwise exclusive or.
555 Comparison (equal and not equal, respectively).
557 result (either 1 or 0) of the comparison is returned.
559 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.
611 argument is a string, then the other is converted to a string,
612 and the result is the concatenation of the two strings.
624 Multiplication, division, modulo.
627 .Ic \- Ns Aq Va expr ,
628 .Ic ~ Ns Aq Va expr ,
629 .Ic \&! Ns Aq Va expr ,
630 .Ic \&$ Ns Aq Va expr ,
631 .Ic \&$? Ns Aq Va expr
633 The first three are unary minus, bitwise complement and logical complement
635 The operator, ``$'', takes
638 the value of the variable of that name.
644 and it appears within an alias macro (see below),
645 then it refers to the nth argument of the alias invocation.
647 tests for the existence of the variable
650 if it exists or 0 otherwise.
652 .Ao Va expr Ac Ns Pq Aq Ar arglist
656 must be a string that is the unique
657 prefix of the name of a builtin
660 or the full name of a user defined alias macro.
661 In the case of a builtin
664 can be in one of two forms:
665 .Bd -literal -offset indent
666 <expr1>, <expr2>, ...
667 argname1 = <expr1>, argname2 = <expr2>, ...
670 The two forms can in fact be intermixed, but the result is
672 Most arguments can be omitted; default values will
673 be supplied for them.
676 can be unique prefixes
677 of the argument names.
678 The commas separating
679 arguments are used only to disambiguate, and can usually be omitted.
681 Only the first argument form is valid for user defined aliases.
683 are defined using the
685 builtin function (see below).
687 are accessed via a variant of the variable mechanism (see ``$'' operator
690 Most functions return value, but some are used for side effect
691 only and so must be used as statements.
692 When a function or an alias is used
693 as a statement, the parentheses surrounding
694 the argument list may be omitted.
695 Aliases return no value.
697 .Ss Builtin Functions
698 The arguments are listed by name in their natural
700 Optional arguments are in square brackets
703 that have no names are in angle brackets
705 An argument meant to be a boolean flag (often named
716 obvious meanings, or it can be a numeric expression,
717 in which case a non-zero value is true.
721 .Bq Aq Ar string\-list
723 If no argument is given, all currently defined alias macros are
727 is defined as an alias,
729 .Aq Ar string\-list > .
730 The previous definition of
736 .It Ic close Ns Pq Aq Ar window\-list
737 Close the windows specified in
738 .Aq Ar window\-list .
743 than all windows are closed.
744 No value is returned.
745 .It Ic cursormodes Ns Pq Bq Ar modes
746 Set the window cursor to
750 or of the mode bits defined as the variables
759 (graphics, terminal dependent).
761 value is the previous modes.
762 Default is no change.
764 .Li cursor($m_rev$m_blk)
765 sets the window cursors to blinking
767 .It Ic default_nline Ns Pq Bq Ar nline
768 Set the default buffer size to
772 Returns the old default buffer size.
775 Using a very large buffer can slow the program down
777 .It Ic default_shell Ns Pq Bq Aq Ar string\-list
778 Set the default window shell program to
779 .Aq Ar string\-list .
781 the first string in the old shell setting.
782 Default is no change.
784 the default shell is taken from the environment variable
786 .It Ic default_smooth Ns Pq Bq Ar flag
787 Set the default value of the
794 is a boolean flag (one of
803 Default is no change.
804 The old value (as a number) is returned.
805 The initial value is 1 (true).
807 .Ic echo Ns ( Op Ar window ,
808 .Bq Aq Ar string\-list )
810 Write the list of strings,
815 by spaces and terminated with a new line.
817 displayed in the window, the processes in the window are not
821 No value is returned.
823 is the current window.
824 .It Ic escape Ns Pq Bq Ar escapec
825 Set the escape character to
828 escape character as a one-character string.
832 can be a string of a single character, or
836 .No control\- Ns Ar X .
838 .Ic foreground Ns ( Bq Ar window ,
843 in or out of foreground.
846 The old foreground flag
850 is the current window,
855 .Ic label Ns ( Bq Ar window ,
871 off a label, set it to an empty string ("").
874 List the identifiers and labels of all windows.
877 .It Ic select Ns Pq Bq Ar window
881 The previous current window
883 Default is no change.
884 .It Ic source Ns Pq Ar filename
885 Read and execute the long commands in
887 Returns \-1 if the file cannot be read, 0 otherwise.
888 .It Ic terse Ns Pq Bq flag
891 In terse mode, the command window
892 stays hidden even in command mode, and errors are reported by
893 sounding the terminal's bell.
899 Returns the old terse flag.
900 Default is no change.
901 .It Ic unalias Ns Pq Ar alias
908 .It Ic unset Ns Pq Ar variable
915 .It Ic variables Ns Pq
918 No value is returned.
920 .Ic window Ns ( Bq Ar row ,
933 Open a window with upper left corner at
942 then that many lines are allocated for the text buffer.
944 the default buffer size is used.
952 the upper, left-most, lower, or right-most extremes of the
961 interpreted in the same way as the argument to
964 they mean, respectively, put a frame around this window (default true),
965 allocate pseudo-terminal for this window rather than socketpair (default
966 true), and map new line characters in this window to carriage return
967 and line feed (default true if socketpair is used, false otherwise).
968 Normally, a window is automatically closed when its process
972 to true (default false) prevents this
976 is true, the screen is updated more frequently
977 (for this window) to produce a more terminal-like behavior.
984 is a list of strings that will be used as the shell
985 program to place in the window (default is the program specified
989 The created window's identifier
990 is returned as a number.
992 .Ic write Ns ( Bq Ar window ,
993 .Bq Aq Ar string\-list )
995 Send the list of strings,
1000 by spaces but not terminated with a new line.
1001 The strings are actually
1002 given to the window as input.
1003 No value is returned.
1005 is the current window.
1007 .Ss Predefined Variables
1008 These variables are for information only.
1009 Redefining them does
1010 not affect the internal operation of
1012 .Bl -tag -width modes
1014 The baud rate as a number between 50 and 38400.
1016 The display modes (reverse video, underline, blinking, graphics)
1017 supported by the physical terminal.
1020 is the bitwise or of some of the one bit values,
1027 These values are useful
1028 in setting the window cursors' modes (see
1032 The blinking mode bit.
1034 The graphics mode bit (not very useful).
1036 The reverse video mode bit.
1038 The underline mode bit.
1040 The number of columns on the physical screen.
1042 The number of rows on the physical screen.
1045 The standard name, found in the second name
1046 field of the terminal's
1053 utility utilizes these environment variables:
1060 .Bl -tag -width /dev/[pt]ty[pq]? -compact
1062 startup command file.
1063 .It Pa /dev/[pt]ty[pq]?
1064 pseudo-terminal devices.
1067 Should be self explanatory.