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
36 .\" $FreeBSD: src/usr.bin/window/window.1,v 1.5.2.6 2002/06/21 15:30:19 charnier Exp $
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. Its size and
60 position can be changed by the user at any time. Processes
61 communicate with their window in the same way they normally
62 interact with a terminal\-through their standard input, output,
63 and diagnostic file descriptors. The window program handles the
64 details of redirecting input and output to and from the
65 windows. At any one time, only one window can receive
66 input from the keyboard, but all windows can simultaneously send output
71 starts up, the commands (see long commands below)
74 in the user's home directory are
75 executed. 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
85 Fast. Don't perform any startup action.
89 and create the two default
91 .It Fl e Ar escape-char
92 Set the escape character to
95 can be a single character, or in the form
99 is any character, meaning
100 .No control\- Ns Ar X .
104 as a long command (see below)
105 before doing anything else.
108 Windows can overlap and are framed as necessary. Each window
109 is named by one of the digits ``1'' to ``9''. This one-character
110 identifier, as well as a user definable label string, are displayed
111 with the window on the top edge of its frame. A window can be
112 designated to be in the
114 in which case it will always be
115 on top of all normal, non-foreground windows, and can be covered
116 only by other foreground windows. A window need not be completely
117 within the edges of the terminal screen. Thus a large window
118 (possibly larger than the screen) may be positioned to show only
119 a portion of its full size.
121 Each window has a cursor and a set of control functions. Most intelligent
122 terminal operations such as line and
123 character deletion and insertion are supported. Display modes
124 such as underlining and reverse video are available if they are
125 supported by the terminal. In addition,
126 similar to terminals with multiple pages of memory,
127 each window has a text buffer which can have more lines than the window
129 .Ss Process Environment
130 With each newly created window, a shell program is spawned with its
131 process environment tailored to that window. Its standard input,
132 output, and diagnostic file descriptors are bound to one end of either
133 a pseudo-terminal (see
139 If a pseudo-terminal is used, then its special
140 characters and modes (see
142 are copied from the physical
145 entry tailored to this window is created
146 and passed as environment (see
150 The termcap entry contains the window's size and
151 characteristics as well as information from the physical terminal,
152 such as the existence of underline, reverse video, and other display
153 modes, and the codes produced by the terminal's function keys,
154 if any. In addition, the window size attributes of the pseudo-terminal
155 are set to reflect the size of this window, and updated whenever
156 it is changed by the user. In particular, the editor
159 this information to redraw its display.
161 During normal execution,
163 can be in one of two states:
164 conversation mode and command mode. In conversation mode, the
165 terminal's real cursor is placed at the cursor position of a particular
166 window--called the current window--and input from the keyboard is sent
167 to the process in that window. The current window is always
168 on top of all other windows, except those in foreground. In addition,
169 it is set apart by highlighting its identifier and label in reverse video.
173 escape character (normally
176 mode switches it into command mode. In command mode, the top line of
177 the terminal screen becomes the command prompt window, and
179 interprets input from the keyboard as commands to manipulate windows.
181 There are two types of commands: short commands are usually one or two
182 key strokes; long commands are strings either typed by the user in the
183 command window (see the
185 command below), or read from a file (see
191 represents one of the digits ``1'' to ``9''
192 corresponding to the windows 1 to 9.
195 .No control\- Ns Ar X ,
198 is any character. In particular,
203 is the escape key, or
209 as the current window
210 and return to conversation mode.
214 but stay in command mode.
216 Select the previous window and return to conversation
217 mode. This is useful for toggling between two windows.
219 Return to conversation mode.
221 Return to conversation mode and write
224 current window. Thus, typing two
227 mode sends one to the current window. If the
229 escape is changed to some other character, that
230 character takes the place of
234 List a short summary of commands.
240 Confirmation is requested.
245 Create a new window. The user is prompted for the positions
246 of the upper left and lower right corners of the window.
247 The cursor is placed on the screen and the keys ``h'', ``j'',
249 move the cursor left, down, up, and right, respectively.
250 The keys ``H'', ``J'', ``K'', and ``L'' move the cursor to the respective
251 limits of the screen. Typing a number before the movement keys
252 repeats the movement that number of times. Return enters the cursor position
253 as the upper left corner of the window. The lower right corner
254 is entered in the same manner. During this process,
255 the placement of the new window is indicated by a rectangular
256 box drawn on the screen, corresponding to where the new window
257 will be framed. Typing escape at any point
258 cancels this command.
260 This window becomes the current window,
261 and is given the first available ID. The default buffer size
266 Only fully visible windows can be created this way.
270 The process in the window is sent
271 the hangup signal (see
275 handle this signal correctly and cause no problems.
279 to another location. A box in the shape
280 of the window is drawn on
281 the screen to indicate the new position of the window, and the same keys as
284 command are used to position the box. The
285 window can be moved partially off-screen.
289 to its previous position.
291 Change the size of window
294 to enter the new lower right corner of the window. A box
295 is drawn to indicate the new window size. The same
300 are used to enter the position.
304 to its previous size.
306 Scroll the current window up by one line.
308 Scroll the current window down by one line.
310 Scroll the current window up by half the window size.
312 Scroll the current window down by half the window size.
314 Scroll the current window up by the full window size.
316 Scroll the current window down by the full window size.
318 Move the cursor of the current window left by one column.
320 Move the cursor of the current window down by one line.
322 Move the cursor of the current window up by one line.
324 Move the cursor of the current window right by one column.
326 Yank. The user is prompted to enter two points within the current
327 window. Then the content of the current window between those two points
328 is saved in the yank buffer.
330 Put. The content of the yank buffer is written to the current
333 Stop output in the current window.
335 Start output in the current window.
337 Enter a line to be executed as long commands.
339 editing characters (erase character, erase word, erase line)
343 Long commands are a sequence of statements
344 parsed much like a programming language, with a syntax
345 similar to that of C. Numeric and string expressions and variables
346 are supported, as well as conditional statements.
348 There are two data types: string and number. A string is a sequence
349 of letters or digits beginning with a letter. ``_'' and ``.'' are
350 considered letters. Alternately, non-alphanumeric characters can
351 be included in strings by quoting them in ``"'' or escaping them
352 with ``\\''. In addition, the ``\\'' sequences of C are supported,
353 both inside and outside quotes (e.g., ``\\n'' is a new line,
354 ``\\r'' a carriage return). For example, these are legal strings:
355 abcde01234, "&#$^*&#", ab"$#"cd, ab\\$\\#cd, "/usr/ucb/window".
357 A number is an integer value in one of three forms:
358 a decimal number, an octal number preceded by ``0'',
359 or a hexadecimal number preceded by ``0x'' or ``0X''. The natural
360 machine integer size is used (i.e., the signed integer type
361 of the C compiler). As in C, a non-zero number represents
364 The character ``#'' begins a comment which terminates at the
367 A statement is either a conditional or an expression. Expression
368 statements are terminated with a new line or ``;''. To continue
369 an expression on the next line, terminate the first line with ``\\''.
370 .Ss Conditional Statement
373 utility has a single control structure:
374 the fully bracketed if statement in the form
376 .Bd -literal -offset indent -compact
393 parts are optional, and the latter can
394 be repeated any number of times.
400 are similar to those in the
401 C language, with most C operators supported on numeric
402 operands. In addition, some are overloaded to operate on strings.
404 When an expression is used as a statement, its value is discarded
405 after evaluation. Therefore, only expressions with side
406 effects (assignments and function calls) are useful as statements.
408 Single valued (no arrays) variables are supported, of both
409 numeric and string values. Some variables are predefined. They
412 The operators in order of increasing precedence:
419 Assignment. The variable of name
421 which must be string valued,
422 is assigned the result of
438 (non-zero numeric value); returns the value of
454 Logical or. Numeric values only. Short circuit evaluation is supported
465 Logical and with short circuit evaluation. Numeric values only.
471 Bitwise or. Numeric values only.
477 Bitwise exclusive or. Numeric values only.
483 Bitwise and. Numeric values only.
492 Comparison (equal and not equal, respectively). The boolean
493 result (either 1 or 0) of the comparison is returned. The
494 operands can be numeric or string valued. One string operand
495 forces the other to be converted to a string in necessary.
507 Less than, greater than, less than or equal to,
508 greater than or equal to. Both numeric and string values, with
509 automatic conversion as above.
518 If both operands are numbers,
521 shifted left (or right) by
526 a string, then its first (or last)
531 is also a string, then its length is used
532 in place of its value).
541 Addition and subtraction on numbers. For ``+'', if one
542 argument is a string, then the other is converted to a string,
543 and the result is the concatenation of the two strings.
555 Multiplication, division, modulo. Numbers only.
557 .Ic \- Ns Aq Va expr ,
558 .Ic ~ Ns Aq Va expr ,
559 .Ic \&! Ns Aq Va expr ,
560 .Ic \&$ Ns Aq Va expr ,
561 .Ic \&$? Ns Aq Va expr
563 The first three are unary minus, bitwise complement and logical complement
564 on numbers only. The operator, ``$'', takes
567 the value of the variable of that name. If
572 and it appears within an alias macro (see below),
573 then it refers to the nth argument of the alias invocation. ``$?''
574 tests for the existence of the variable
577 if it exists or 0 otherwise.
579 .Ao Va expr Ac Ns Pq Aq Ar arglist
583 must be a string that is the unique
584 prefix of the name of a builtin
587 or the full name of a user defined alias macro. In the case of a builtin
590 can be in one of two forms:
591 .Bd -literal -offset indent
592 <expr1>, <expr2>, ...
593 argname1 = <expr1>, argname2 = <expr2>, ...
596 The two forms can in fact be intermixed, but the result is
597 unpredictable. Most arguments can be omitted; default values will
598 be supplied for them. The
600 can be unique prefixes
601 of the argument names. The commas separating
602 arguments are used only to disambiguate, and can usually be omitted.
604 Only the first argument form is valid for user defined aliases. Aliases
605 are defined using the
607 builtin function (see below). Arguments
608 are accessed via a variant of the variable mechanism (see ``$'' operator
611 Most functions return value, but some are used for side effect
612 only and so must be used as statements. When a function or an alias is used
613 as a statement, the parentheses surrounding
614 the argument list may be omitted. Aliases return no value.
616 .Ss Builtin Functions
617 The arguments are listed by name in their natural
618 order. Optional arguments are in square brackets
621 that have no names are in angle brackets
623 An argument meant to be a boolean flag (often named
634 obvious meanings, or it can be a numeric expression,
635 in which case a non-zero value is true.
639 .Bq Aq Ar string\-list
641 If no argument is given, all currently defined alias macros are
644 is defined as an alias,
646 .Aq Ar string\-list > .
647 The previous definition of
649 if any, is returned. Default for
652 .It Ic close Ns Pq Aq Ar window\-list
653 Close the windows specified in
654 .Aq Ar window\-list .
659 than all windows are closed. No value is returned.
660 .It Ic cursormodes Ns Pq Bq Ar modes
661 Set the window cursor to
665 or of the mode bits defined as the variables
674 (graphics, terminal dependent). Return
675 value is the previous modes. Default is no change.
677 .Li cursor($m_rev$m_blk)
678 sets the window cursors to blinking
680 .It Ic default_nline Ns Pq Bq Ar nline
681 Set the default buffer size to
684 48 lines. Returns the old default buffer size. Default is
685 no change. Using a very large buffer can slow the program down
687 .It Ic default_shell Ns Pq Bq Aq Ar string\-list
688 Set the default window shell program to
689 .Aq Ar string\-list .
691 the first string in the old shell setting. Default is no change. Initially,
692 the default shell is taken from the environment variable
694 .It Ic default_smooth Ns Pq Bq Ar flag
695 Set the default value of the
700 (see below). The argument
701 is a boolean flag (one of
709 as described above). Default is no change.
710 The old value (as a number) is returned.
711 The initial value is 1 (true).
713 .Ic echo Ns ( Op Ar window ,
714 .Bq Aq Ar string\-list )
716 Write the list of strings,
721 by spaces and terminated with a new line. The strings are only
722 displayed in the window, the processes in the window are not
725 below). No value is returned. Default
726 is the current window.
727 .It Ic escape Ns Pq Bq Ar escapec
728 Set the escape character to
731 escape character as a one-character string. Default is no
734 can be a string of a single character, or
738 .No control\- Ns Ar X .
740 .Ic foreground Ns ( Bq Ar window ,
745 in or out of foreground.
747 is a boolean value. The old foreground flag
748 is returned. Default for
750 is the current window,
755 .Ic label Ns ( Bq Ar window ,
763 label as a string. Default for
768 is no change. To turn
769 off a label, set it to an empty string ("").
771 No arguments. List the identifiers and labels of all windows. No
773 .It Ic select Ns Pq Bq Ar window
776 the current window. The previous current window
777 is returned. Default is no change.
778 .It Ic source Ns Pq Ar filename
779 Read and execute the long commands in
781 Returns \-1 if the file cannot be read, 0 otherwise.
782 .It Ic terse Ns Pq Bq flag
785 In terse mode, the command window
786 stays hidden even in command mode, and errors are reported by
787 sounding the terminal's bell.
792 above. Returns the old terse flag.
793 Default is no change.
794 .It Ic unalias Ns Pq Ar alias
801 .It Ic unset Ns Pq Ar variable
808 .It Ic variables Ns Pq
809 No arguments. List all variables. No value is returned.
811 .Ic window Ns ( Bq Ar row ,
824 Open a window with upper left corner at
833 then that many lines are allocated for the text buffer. Otherwise,
834 the default buffer size is used. Default values for
841 the upper, left-most, lower, or right-most extremes of the
850 interpreted in the same way as the argument to
853 they mean, respectively, put a frame around this window (default true),
854 allocate pseudo-terminal for this window rather than socketpair (default
855 true), and map new line characters in this window to carriage return
856 and line feed (default true if socketpair is used, false otherwise).
857 Normally, a window is automatically closed when its process
860 to true (default false) prevents this
863 is true, the screen is updated more frequently
864 (for this window) to produce a more terminal-like behavior.
871 is a list of strings that will be used as the shell
872 program to place in the window (default is the program specified
875 see above). The created window's identifier
876 is returned as a number.
878 .Ic write Ns ( Bq Ar window ,
879 .Bq Aq Ar string\-list )
881 Send the list of strings,
886 by spaces but not terminated with a new line. The strings are actually
887 given to the window as input. No value is returned. Default
888 is the current window.
890 .Ss Predefined Variables
891 These variables are for information only. Redefining them does
892 not affect the internal operation of
894 .Bl -tag -width modes
896 The baud rate as a number between 50 and 38400.
898 The display modes (reverse video, underline, blinking, graphics)
899 supported by the physical terminal. The value of
901 is the bitwise or of some of the one bit values,
908 These values are useful
909 in setting the window cursors' modes (see
913 The blinking mode bit.
915 The graphics mode bit (not very useful).
917 The reverse video mode bit.
919 The underline mode bit.
921 The number of columns on the physical screen.
923 The number of rows on the physical screen.
925 The terminal type. The standard name, found in the second name
926 field of the terminal's
933 utility utilizes these environment variables:
940 .Bl -tag -width /dev/[pt]ty[pq]? -compact
942 startup command file.
943 .It Pa /dev/[pt]ty[pq]?
944 pseudo-terminal devices.
952 Should be self explanatory.