.\" Copyright (c) 1985, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\" This code is derived from software contributed to Berkeley by
.\" Edward Wang at The University of California, Berkeley.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)window.1 8.1 (Berkeley) 6/6/93
implements a window environment on
A window is a rectangular portion of the physical terminal
screen associated with a set of processes. Its size and
position can be changed by the user at any time. Processes
communicate with their window in the same way they normally
interact with a terminal\-through their standard input, output,
and diagnostic file descriptors. The window program handles the
details of redirecting input an output to and from the
windows. At any one time, only one window can receive
input from the keyboard, but all windows can simultaneously send output
starts up, the commands (see long commands below)
in the user's home directory are
executed. If it does not exist, two equal sized windows spanning
the terminal screen are created by default.
The command line options are
Fast. Don't perform any startup action.
and create the two default
Set the escape character to
can be a single character, or in the form
is any character, meaning
as a long command (see below)
before doing anything else.
Windows can overlap and are framed as necessary. Each window
is named by one of the digits ``1'' to ``9''. This one-character
identifier, as well as a user definable label string, are displayed
with the window on the top edge of its frame. A window can be
in which case it will always be
on top of all normal, non-foreground windows, and can be covered
only by other foreground windows. A window need not be completely
within the edges of the terminal screen. Thus a large window
(possibly larger than the screen) may be positioned to show only
a portion of its full size.
Each window has a cursor and a set of control functions. Most intelligent
terminal operations such as line and
character deletion and insertion are supported. Display modes
such as underlining and reverse video are available if they are
supported by the terminal. In addition,
similar to terminals with multiple pages of memory,
each window has a text buffer which can have more lines than the window
With each newly created window, a shell program is spawned with its
process environment tailored to that window. Its standard input,
output, and diagnostic file descriptors are bound to one end of either
If a pseudo-terminal is used, then its special
characters and modes (see
are copied from the physical
entry tailored to this window is created
and passed as environment
The termcap entry contains the window's size and
characteristics as well as information from the physical terminal,
such as the existence of underline, reverse video, and other display
modes, and the codes produced by the terminal's function keys,
if any. In addition, the window size attributes of the pseudo-terminal
are set to reflect the size of this window, and updated whenever
it is changed by the user. In particular, the editor
this information to redraw its display.
can be in one of two states:
conversation mode and command mode. In conversation mode, the
terminal's real cursor is placed at the cursor position of a particular
window--called the current window--and input from the keyboard is sent
to the process in that window. The current window is always
on top of all other windows, except those in foreground. In addition,
it is set apart by highlighting its identifier and label in reverse video.
escape character (normally
mode switches it into command mode. In command mode, the top line of
the terminal screen becomes the command prompt window, and
interprets input from the keyboard as commands to manipulate windows.
There are two types of commands: short commands are usually one or two
key strokes; long commands are strings either typed by the user in the
command below), or read from a file (see
represents one of the digits ``1'' to ``9''
corresponding to the windows 1 to 9.
is any character. In particular,
and return to conversation mode.
but stay in command mode.
Select the previous window and return to conversation
mode. This is useful for toggling between two windows.
Return to conversation mode.
Return to conversation mode and write
current window. Thus, typing two
mode sends one to the current window. If the
escape is changed to some other character, that
character takes the place of
List a short summary of commands.
Confirmation is requested.
Create a new window. The user is prompted for the positions
of the upper left and lower right corners of the window.
The cursor is placed on the screen and the keys ``h'', ``j'',
move the cursor left, down, up, and right, respectively.
The keys ``H'', ``J'', ``K'', and ``L'' move the cursor to the respective
limits of the screen. Typing a number before the movement keys
repeats the movement that number of times. Return enters the cursor position
as the upper left corner of the window. The lower right corner
is entered in the same manner. During this process,
the placement of the new window is indicated by a rectangular
box drawn on the screen, corresponding to where the new window
will be framed. Typing escape at any point
This window becomes the current window,
and is given the first available ID. The default buffer size
Only fully visible windows can be created this way.
The process in the window is sent
handle this signal correctly and cause no problems.
to another location. A box in the shape
of the window is drawn on
the screen to indicate the new position of the window, and the same keys as
command are used to position the box. The
window can be moved partially off-screen.
to its previous position.
Change the size of window
to enter the new lower right corner of the window. A box
is drawn to indicate the new window size. The same
are used to enter the position.
Scroll the current window up by one line.
Scroll the current window down by one line.
Scroll the current window up by half the window size.
Scroll the current window down by half the window size.
Scroll the current window up by the full window size.
Scroll the current window down by the full window size.
Move the cursor of the current window left by one column.
Move the cursor of the current window down by one line.
Move the cursor of the current window up by one line.
Move the cursor of the current window right by one column.
Yank. The user is prompted to enter two points within the current
window. Then the content of the current window between those two points
is saved in the yank buffer.
Put. The content of the yank buffer is written to the current
Stop output in the current window.
Start output in the current window.
Enter a line to be executed as long commands.
editing characters (erase character, erase word, erase line)
Long commands are a sequence of statements
parsed much like a programming language, with a syntax
similar to that of C. Numeric and string expressions and variables
are supported, as well as conditional statements.
There are two data types: string and number. A string is a sequence
of letters or digits beginning with a letter. ``_'' and ``.'' are
considered letters. Alternately, non-alphanumeric characters can
be included in strings by quoting them in ``"'' or escaping them
with ``\\''. In addition, the ``\\'' sequences of C are supported,
both inside and outside quotes (e.g., ``\\n'' is a new line,
``\\r'' a carriage return). For example, these are legal strings:
abcde01234, "&#$^*&#", ab"$#"cd, ab\\$\\#cd, "/usr/ucb/window".
A number is an integer value in one of three forms:
a decimal number, an octal number preceded by ``0'',
or a hexadecimal number preceded by ``0x'' or ``0X''. The natural
machine integer size is used (i.e., the signed integer type
of the C compiler). As in C, a non-zero number represents
The character ``#'' begins a comment which terminates at the
A statement is either a conditional or an expression. Expression
statements are terminated with a new line or ``;''. To continue
an expression on the next line, terminate the first line with ``\\''.
.Ss Conditional Statement
has a single control structure:
the fully bracketed if statement in the form
.Bd -literal -offset indent -compact
parts are optional, and the latter can
be repeated any number of times.
are similar to those in the
C language, with most C operators supported on numeric
operands. In addition, some are overloaded to operate on strings.
When an expression is used as a statement, its value is discarded
after evaluation. Therefore, only expressions with side
effects (assignments and function calls) are useful as statements.
Single valued (no arrays) variables are supported, of both
numeric and string values. Some variables are predefined. They
The operators in order of increasing precedence:
Assignment. The variable of name
which must be string valued,
is assigned the result of
(non-zero numeric value); returns the value of
Logical or. Numeric values only. Short circuit evaluation is supported
Logical and with short circuit evaluation. Numeric values only.
Bitwise or. Numeric values only.
Bitwise exclusive or. Numeric values only.
Bitwise and. Numeric values only.
Comparison (equal and not equal, respectively). The boolean
result (either 1 or 0) of the comparison is returned. The
operands can be numeric or string valued. One string operand
forces the other to be converted to a string in necessary.
Less than, greater than, less than or equal to,
greater than or equal to. Both numeric and string values, with
automatic conversion as above.
If both operands are numbers,
shifted left (or right) by
a string, then its first (or last)
is also a string, then its length is used
Addition and subtraction on numbers. For ``+'', if one
argument is a string, then the other is converted to a string,
and the result is the concatenation of the two strings.
Multiplication, division, modulo. Numbers only.
The first three are unary minus, bitwise complement and logical complement
on numbers only. The operator, ``$'', takes
the value of the variable of that name. If
and it appears within an alias macro (see below),
then it refers to the nth argument of the alias invocation. ``$?''
tests for the existence of the variable
if it exists or 0 otherwise.
.Ao Va expr Ac Ns Pq Aq Ar arglist
must be a string that is the unique
prefix of the name of a builtin
or the full name of a user defined alias macro. In the case of a builtin
can be in one of two forms:
.Bd -literal -offset indent
argname1 = <expr1>, argname2 = <expr2>, ...
The two forms can in fact be intermixed, but the result is
unpredictable. Most arguments can be omitted; default values will
be supplied for them. The
of the the argument names. The commas separating
arguments are used only to disambiguate, and can usually be omitted.
Only the first argument form is valid for user defined aliases. Aliases
builtin function (see below). Arguments
are accessed via a variant of the variable mechanism (see ``$'' operator
Most functions return value, but some are used for side effect
only and so must be used as statements. When a function or an alias is used
as a statement, the parenthesis surrounding
the argument list may be omitted. Aliases return no value.
The arguments are listed by name in their natural
order. Optional arguments are in square brackets
that have no names are in angle brackets
An argument meant to be a boolean flag (often named
obvious meanings, or it can be a numeric expression,
in which case a non-zero value is true.
.Ic alias Ns Po Bq Aq Ar string ,
.Bq Aq Ar string\-list Pc
If no argument is given, all currently defined alias macros are
The previous definition of
if any, is returned. Default for
.It Ic close Ns Pq Aq Ar window\-list
Close the windows specified in
than all windows are closed. No value is returned.
.It Ic cursormodes Ns Pq Bq Ar modes
or of the mode bits defined as the variables
(graphics, terminal dependent). Return
value is the previous modes. Default is no change.
sets the window cursors to blinking
.It Ic default_nline Ns Pq Bq Ar nline
Set the default buffer size to
48 lines. Returns the old default buffer size. Default is
no change. Using a very large buffer can slow the program down
.It Ic default_shell Ns Pq Bq Aq Ar string\-list
Set the default window shell program to
the first string in the old shell setting. Default is no change. Initially,
the default shell is taken from the environment variable
.It Ic default_smooth Ns Pq Bq Ar flag
Set the default value of the
(see below). The argument
is a boolean flag (one of
as described above). Default is no change.
The old value (as a number) is returned.
The initial value is 1 (true).
.Ic echo Ns ( Op Ar window ,
Write the list of strings,
by spaces and terminated with a new line. The strings are only
displayed in the window, the processes in the window are not
below). No value is returned. Default
.It Ic escape Ns Pq Bq Ar escapec
Set the escape character to
escape character as a one-character string. Default is no
can be a string of a single character, or
.Ic foreground Ns ( Bq Ar window ,
is a boolean value. The old foreground flag
.Ic label Ns ( Bq Ar window ,
label as a string. Default for
off a label, set it to an empty string ("").
No arguments. List the identifiers and labels of all windows. No
.It Ic select Ns Pq Bq Ar window
the current window. The previous current window
is returned. Default is no change.
.It Ic source Ns Pq Ar filename
Read and execute the long commands in
Returns \-1 if the file cannot be read, 0 otherwise.
.It Ic terse Ns Pq Bq flag
In terse mode, the command window
stays hidden even in command mode, and errors are reported by
sounding the terminal's bell.
above. Returns the old terse flag.
.It Ic unalias Ns Pq Ar alias
.It Ic unset Ns Pq Ar variable
No arguments. List all variables. No value is returned.
.Ic window Ns ( Bq Ar row ,
Open a window with upper left corner at
then that many lines are allocated for the text buffer. Otherwise,
the default buffer size is used. Default values for
the upper, left-most, lower, or right-most extremes of the
interpreted in the same way as the argument to
they mean, respectively, put a frame around this window (default true),
allocate pseudo-terminal for this window rather than socketpair (default
true), and map new line characters in this window to carriage return
and line feed (default true if socketpair is used, false otherwise).
Normally, a window is automatically closed when its process
to true (default false) prevents this
is true, the screen is updated more frequently
(for this window) to produce a more terminal-like behavior.
is a list of strings that will be used as the shell
program to place in the window (default is the program specified
see above). The created window's identifier
.Ic write Ns ( Bq Ar window ,
Send the list of strings,
by spaces but not terminated with a new line. The strings are actually
given to the window as input. No value is returned. Default
These variables are for information only. Redefining them does
not affect the internal operation of
The baud rate as a number between 50 and 38400.
The display modes (reverse video, underline, blinking, graphics)
supported by the physical terminal. The value of
is the bitwise or of some of the one bit values,
in setting the window cursors' modes (see
The graphics mode bit (not very useful).
The reverse video mode bit.
The number of columns on the physical screen.
The number of rows on the physical screen.
The terminal type. The standard name, found in the second name
utilizes these environment variables:
.Bl -tag -width /dev/[pt]ty[pq]? -compact
Should be self explanatory.