 |
Index for Section 1 |
|
 |
Alphabetical listing for W |
|
 |
Bottom of page |
|
window(1)
NAME
window - Implements a window environment
SYNOPSIS
window [-dft] [-c command] [-e] [escape_character]
The window command implements a window environment on ASCII terminals.
OPTIONS
-c command
Executes the string command as a long command (see Long Commands)
before doing anything else.
-d Ignores .windowrc and creates the two default windows instead.
-e escape_character
Sets the Escape character to escape_character. The escape_character
can be a single character, or in the form <Ctrl-x>, where x is any
character.
-f Does not perform any start-up action (Fast option).
-t Turns on terse mode (see the terse command later in this reference
page).
DESCRIPTION
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 and 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 to the display.
Windows can overlap and are framed as necessary. Each window is named by
one of the digits 1 to 9. This 1-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 designated to be in the foreground, in which
case it will always be on top of all normal, nonforeground 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) can be positioned to show only a portion
of its full size.
Each window has a cursor and a set of control functions. Most programmable
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, like
terminals with multiple pages of memory, each window has a text buffer that
can have more lines than the window itself.
When window starts up, the commands (see Long Commands) contained in the
.windowrc file in the user's home directory are executed. If the file does
not exist, two equal-sized windows spanning the terminal screen are created
by default.
Process Environment
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 a pseudoterminal
(pty or a UNIX domain socket, socketpair. If a pseudoterminal is used,
then its special characters and modes (see the stty command) are copied
from the physical terminal. A termcap entry tailored to this window is
created and passed as environment (environ) variable TERMCAP. 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
pseudoterminal are set to reflect the size of this window, and updated
whenever it is changed by the user. In particular, the editor vi uses this
information to redraw its display.
Operation
During normal execution, window 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.
Typing window's Escape character (normally ^P) in conversation mode
switches it into command mode. In command mode, the top line of the
terminal screen becomes the command prompt window, and window interprets
input from the keyboard as commands to manipulate windows.
There are two types of commands: short commands are usually one or two
keystrokes; long commands are strings that are typed in the command window
(see the : command under Short Commands) or read from a file (see the
built-in function source under Built-In Functions).
Short Commands
The # variable represents one of the digits 1 to 9 corresponding to the
windows 1 to 9. The sequence ^X means <Ctrl-x>, where x is any character.
In particular, ^^ is <Ctrl-^>. escape is the <Esc> key, or ^[.
# Selects window # as the current window and returns to conversation
mode.
%# Selects window #, but stays in command mode.
^^ Selects the previous window and returns to conversation mode. This is
useful for toggling between two windows.
escape
Returns to conversation mode.
^P Returns to conversation mode and writes ^P to the current window.
Thus, typing two ^Ps in conversation mode sends one to the current
window. If the window Escape character is changed to some other
character, that character takes the place of ^P here.
? Lists a short summary of commands.
^L Redraws the screen.
q Exits window after requesting confirmation.
^Z Suspends window.
w Creates a new window. You are 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>, <k>, and <l> 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.
Pressing <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. Pressing escape (see preceding description) at
any point cancels this command.
This new window becomes the current window, and is given the first
available ID. The default buffer size is used (see the built-in
function nline under Built-In Functions). Only fully visible windows
can be created this way.
c# Closes window #. The process in the window is sent the Hangup signal
(see the kill command). The csh command should handle this signal
correctly and cause no problems.
m# Moves window # 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 those for the w command are used to position the box.
The window can be moved partially off the screen.
M# Moves window # to its previous position.
s# Changes the size of window #. You are prompted to enter the new
lower-right corner of the window. A box is drawn to indicate the new
window size. The same keys used in w and m are used to enter the
position.
S# Changes window # to its previous size.
^Y Scrolls the current window up by one line.
^E Scrolls the current window down by one line.
^U Scrolls the current window up by half the window size.
^D Scrolls the current window down by half the window size.
^B Scrolls the current window up by the full window size.
^F Scrolls the current window down by the full window size.
h Moves the cursor of the current window left by one column.
j Moves the cursor of the current window down by one line.
k Moves the cursor of the current window up by one line.
l Moves the cursor of the current window right by one column.
^S Stops output in the current window.
^Q Starts output in the current window.
: Enters a line to be executed as long commands. Normal line editing
characters (erase character, erase word, erase line) are supported.
Long Commands
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. The _ (underscore) and . (dot)
characters are considered letters. Alternately, nonalphanumeric characters
can be included in strings by escaping them with a \ (backslash). In
addition, the \ sequences of C are supported, both inside and outside
quotes (that is, \n is a newline, and \r a carriage-return). The following
are also legal strings: abcde01234, &#$^*&#, ab$#cd, ab\$\#cd,
/usr/bin/window.
A number is an integer value in one of three forms: a decimal number, an
octal number preceded by 0 (zero), or a hexadecimal number preceded by 0x
or 0X. The natural machine integer size is used (the signed integer type
of the C compiler). As in C, a nonzero number represents a Boolean TRUE.
The # (number sign) begins a comment that terminates at the end of the
line.
A statement is either a conditional or an expression. Expression
statements are terminated with a newline or with the ; (semicolon)
character. To continue an expression on the next line, terminate the first
line with a \ (backslash).
Conditional Statements
The window command has a single control structure: the fully bracketed if
statement in the following form:
if <expression> then
<statement>
. . .
elsif <expression> then
<statement>
. . .
else
<statement>
. . .
endif
The else and elsif parts are optional, and the latter can be repeated any
number of times. expression must be numeric.
Expressions
Expressions in window 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 for both numeric and
string values. Some variables are predefined. They are listed as follows:
The operators in order of increasing precedence are as follows:
<expression1> = <expression2>
Assigns the variable <expression1>, which must be string valued, to the
result of <expression2>. Returns the value of <expression2>.
<expression1> ? <expression2> : <expression3>
Returns the value of <expression2> if <expression1> evaluates TRUE
(nonzero numeric value); returns the value of <expression3> otherwise.
Either <expression2> and <expression3> is evaluated, but not both.
<expression1> must be numeric.
<expression1> || <expression2>
Performs a logical OR. Numeric values only. Short circuit evaluation
is supported (that is, if <expression1> evaluates TRUE, then
<expression2> is not evaluated).
<expression1> && <expression2>
Performs a logical AND with short circuit evaluation. Numeric values
only.
<expression1> | <expression2>
Performs a bitwise OR. Numeric values only.
<expression1> ^ <expression2>
Performs a bitwise exclusive OR. Numeric values only.
<expression1> & <expression2>
Performs a bitwise AND. Numeric values only.
<expression1> == <expression2>,
<expression1> != <expression2>
Performs a comparison (equal and not equal, respectively). The Boolean
result (either 1 or 0) is returned. The operands can be numeric or
string valued. One string operand forces the other to be converted to
a string if necessary.
<expression1> < <expression2>,
<expression1> > <expression2>, <expression1> <= <expression2>,
<expression1> >= <expression2>
Performs a less than, greater than, less than or equal to, greater than
or equal to operation. Both numeric and string values, with automatic
conversion as stated previously.
<expression1> << <expression2>,
<expression1> >> <expression2>
Bit shifts <expression1> left (or right) by <expression2> bits if both
operands are numbers. If <expression1> is a string, then its first (or
last) <expression2> characters are returned (if <expression2> is also a
string, then its length is used in place of its value).
<expression1> + <expression2>,
<expression1> - <expression2>
Performs 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.
<expression1> * <expression2>,
<expression1> / <expression2>, <expression1> % <expression2>
Performs multiplication, division, modulo. Numbers only.
-<expression>, ~<expression>, !<expression>,
$<expression>, $?<expression>
Performs unary minus, bitwise complement, and logical complement on
numbers only (the first three expressions, respectively). The operator,
$, takes <expression> and returns the value of the variable of that
name. If <expression> is numeric with value n and it appears within an
alias macro (described later), then it refers to the nth argument of
the alias invocation. $? tests for the existence of the variable
<expression>, and returns 1 if it exists or 0 otherwise.
<expression>(<argument_list>)
Performs a function call. <expression> must be a string that is the
unique prefix of the name of a built-in window function or the full
name of a user-defined alias macro. In the case of a built-in
function, <argument_list> can be in one of two forms:
<expression1>, <expression2>, ...
argument1 = <expression1>, argument2 = <expression2>, ...
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. Arguments can be unique prefixes of the argument
names. The commas separating arguments are used only to prevent
ambiguity, and can usually be omitted.
Only the first argument form is valid for user-defined aliases.
Aliases are defined using the alias built-in function (described
later). Arguments are accessed through a variant of the variable
mechanism (see $ operator previously described).
Most functions return a value, but some are used for side effects only
and so must be used as statements. When a function or an alias is used
as a statement, the parentheses surrounding the argument list can be
omitted. Aliases return no value.
Built-In Functions
The arguments are listed by name in their natural order. Optional
arguments are in [ ] (brackets). Arguments that have no names are in < >
(angle brackets).
alias([<string>], [<string_list>])
Lists all currently defined alias macros, if no argument is given.
Otherwise, <string> is defined as an alias, with expansion
<string_list>. The previous definition of <string>, if any, is
returned. Default for <string_list> is no change.
close(<window_list>)
Closes the windows specified in <window_list>. If <window_list> is the
word all, all windows are closed. No value is returned.
cursormodes([modes])
Sets the window cursor to modes. modes is the bitwise OR of the mode
bits defined as the variables m_ul (underline), m_rev (reverse video),
m_blk (blinking), and m_grp (graphics, terminal dependent). Return
value is the previous modes. Default is no change. For example,
cursor($m_rev|$m_blk) sets the window cursors to blinking reverse
video.
echo([window], [<string_list>])
Writes the list of strings, <string_list>, to window, separated by
spaces and terminated with a newline. The strings are only displayed
in the window; the processes in the window are not involved (see the
built-in function write, under Built-In Functions). No value is
returned. Default is the current window.
escape([escape_character])
Sets the Escape character to escape_character. Returns the old Escape
character as a 1-character string. Default is no change.
escape_character can be a string of a single character, or in the form
^X, meaning <Ctrl-x>.
foreground([window], [flag])
Moves window in or out of foreground. flag can be on, off, yes, no,
true, or false, with obvious meanings, or it can be a numeric
expression, in which case a nonzero value is TRUE. Returns the old
foreground flag as a number. Default for window is the current window;
default for flag is no change.
label([window], [label])
Sets the label of window to label. Returns the old label as a string.
Default for window is the current window; default for label is no
change. To turn off a label, set it to an empty string (" ").
list()
Lists the identifiers and labels of all windows. No value is returned.
nline([nline])
Sets the default buffer size to nline. Initially, it is 48 lines.
Returns the old default buffer size. Default is no change. Using a
very large buffer can slow the program down considerably.
select([window])
Makes window the current window. The previous current window is
returned. Default is no change.
shell([<string_list>])
Sets the default window shell program to <string_list>. Returns the
first string in the old shell setting. Default is no change.
Initially, the default shell is taken from the SHELL environment
variable.
source(file)
Reads and executes the long commands in file. Returns -1 if the file
cannot be read, 0 otherwise.
terse([flag])
Sets terse mode to flag. In terse mode, the command window stays
hidden even in command mode, and errors are reported by sounding the
terminal's bell. The flag can take on the same values as in
foreground. Returns the old terse flag. Default is no change.
unalias(alias)
Undefines alias. Returns -1 if alias does not exist, 0 otherwise.
unset(variable)
Undefines variable. Returns -1 if variable does not exist, 0
otherwise.
variables()
Lists all variables. No value is returned.
window([row], [column], [nrow], [ncolumn], [nline], [frame],
[pty], [mapnl], [sh])
Opens a window with upper-left corner at row (row), column (column) and
of size nrow, ncolumn. If nline is specified, then that many lines are
allocated for the text buffer. Otherwise, the default buffer size is
used. Default values for row, column, nrow, and ncolumn are,
respectively, the upper, leftmost, lower, or rightmost extremes of the
screen. The frame (frame), pty, and mapnl (mapnl) are flag values
interpreted in the same way as the argument to foreground (previously
described); they mean, respectively, put a frame around this window
(default TRUE), allocate pseudoterminal for this window rather than
socketpair (default TRUE), and map newline characters in this window to
carriage-return and linefeed (default TRUE if socketpair is used, FALSE
otherwise). sh is a list of strings that will be used as the shell
program to place in the window (default is the program specified by
shell). The created window's identifier is returned as a number.
write([window], [<string_list>])
Sends the list of strings, <string_list>, to window, separated by
spaces but not terminated with a newline. The strings are actually
given to the window as input. No value is returned. Default is the
current window.
Predefined Variables
These variables are for information only. Redefining them does not affect
the internal operation of window.
baud
The baud rate as a number between 50 and 38,400.
modes
The display modes (reverse video, underline, blinking, graphics)
supported by the physical terminal. The value of modes is the bitwise
OR of some of the 1-bit values, m_blk, m_grp, m_rev, and m_ul. These
values are useful in setting the window cursor modes (see cursormodes
under Built-In Functions).
m_blk
The blinking mode bit.
m_grp
The graphics mode bit (not very useful).
m_rev
The reverse video mode bit.
m_ul
The underline mode bit.
ncol
The number of columns on the physical screen.
nrow
The number of rows on the physical screen.
term
The terminal type. The standard name, found in the second name field
of the terminal's TERMCAP entry, is used.
FILES
~/.windowrc
Start-up file.
/dev/[pt]ty[pq]?
Pseudoterminal devices.
SEE ALSO
Commands: stty(1)
The environ variable.
 |
Index for Section 1 |
|
 |
Alphabetical listing for W |
|
 |
Top of page |
|