4.3BSD beta release manual page
[unix-history] / usr / src / usr.bin / window / window.1
... / ...
CommitLineData
1.\" @(#)window.1 3.8 %G%
2
3.\" Copyright (c) 1983 Regents of the University of California,
4.\" All rights reserved. Redistribution permitted subject to
5.\" the terms of the Berkeley Software License Agreement.
6
7.TH WINDOW 1 "2 April 1985"
8.SH NAME
9window \- window environment
10.SH SYNOPSIS
11.B window
12[
13.B \-t
14] [
15.B \-f
16] [
17.B \-d
18] [
19.B \-e escape-char
20] [
21.B \-c command
22]
23.SH DESCRIPTION
24\fIWindow\fP provides a window oriented environment
25on ordinary CRT terminals.
26.PP
27A window is a rectangular portion of the physical terminal
28screen associated with a set of processes. These processes
29communicate with the window in the same way they normally
30interact with a terminal. The window program handles the
31details of redirecting input an output to and from the
32windows. At any one time, only one window can receive
33input from the keyboard, but all windows can simultaneously send output
34to the display.
35.PP
36Windows can overlap and are framed as necessary. Each window
37is named by one of the digits ``1'' to ``9''. This one character
38identifier, as well as a user definable label string, are displayed
39with the window on the top edge of its frame. A window can be
40designated to be in the \fIforeground\fP, in which case it will always be
41on top of all normal, non-foreground windows, and can be covered
42only by other foreground windows.
43.PP
44A window need not be completely within the edges of the terminal screen.
45Thus a large window (possibly larger than the screen)
46can be positioned to show only a portion of its full size. In addition,
47both the size and the position of a window can be changed by
48the user at any time.
49.PP
50Windows are designed to have the appearance of real terminals
51both to the user and to the processes running in them. Each window
52has a cursor and a set of control functions. Most intelligent
53terminal functions such as line and
54character deletion and insertion are supported. Display modes
55such as underlining and reverse video are available if the terminal
56allows them. Also, similar to terminals with multiple pages of memory,
57each window has a text buffer which can be larger than the window.
58Different parts of the buffer can be displayed by scrolling.
59.SH OPTIONS
60When \fIwindow\fP starts up, the file \fI.windowrc\fP in the
61user's home directory is checked. If it exists, then the
62commands contained in it are executed (see \fIsource\fP command below).
63Otherwise, two equal sized windows are created by default.
64.PP
65The command line arguments are
66.TP
67.B \-t
68Turn on terse mode (see \fIterse\fP command below).
69.TP
70.B \-f
71Don't perform any startup action.
72.TP
73.B \-d
74Ignore \fI.windowrc\fP and create the two default
75windows instead.
76.TP
77.B \-e escape-char
78Set the escape character to \fIescape-char\fP. \fIEscape-char\fP
79can be a single character, or in the form \fI^X\fP where \fIX\fP
80is any character, meaning control-\fIX\fP.
81.TP
82.B \-c command
83Execute the string \fIcommand\fP as a long command (see below)
84before doing anything else.
85.SH "PROCESS ENVIRONMENT"
86With each newly created window, a shell program is spawned with its
87process environment tailored to that window. Its standard input,
88output, and diagnostic file descriptors are bound to one end of either
89a pseudo-terminal (\fIpty\fP (4)) or a UNIX domain socket
90(\fIsocketpair\fP (4)). If a pseudo-terminal is used, then its special
91characters and modes (see \fIstty\fP (1)) are copied from the physical
92terminal. A \fItermcap\fP (5) entry tailored to this window is created
93and passed as environment (\fIenviron\fP (5)) variable
94\fITERMCAP\fP. The termcap entry contains the window's size and
95characteristics as well as information from the physical terminal,
96such as the existence of underline, reverse video, and other display
97modes, and the codes produced by the terminal's function keys,
98if any. In addition to the termcap entry, a window size structure is
99associated with the pseudo-terminal (and indeed with any terminal). It
100is initialized by \fIwindow\fP at creation time, and updated whenever the
101size of the window changes, using the \fIioctl\fP (2) call
102\fITIOCSWINSZ\fP. In particular, the editor \fIvi\fP (1) uses
103this information to redraw its display.
104.SH OPERATION
105.PP
106During normal execution, \fIwindow\fP can be in one of two modes:
107conversation mode and command mode. In conversation mode, the
108terminal's real cursor is placed at the cursor position of a particular
109window--called the current window--and input from the keyboard is sent
110to the process in that window. The current window is always
111on top of all other windows, except those in foreground. In addition,
112it is set apart by highlighting its identifier and label in reverse video.
113.PP
114Typing \fIwindow\fP's escape character (normally ^P) in conversation
115mode switches it into command mode. In command mode, the top line of
116the terminal screen becomes the command prompt window, and \fIwindow\fP
117interprets input from the keyboard as commands to manipulate windows.
118.PP
119There are two types of commands: short commands are usually one or two
120key strokes; long commands are strings either typed by the user in the
121command window (see the ``:'' command below), or read from a file (see
122\fIsource\fP below).
123.SH "SHORT COMMANDS"
124Below, \fI#\fP represents one of the digits ``1'' to ``9''
125corresponding to the windows 1 to 9. \fI^X\fP means control-\fIX\fP,
126where \fPX\fP is any character. In particular, \fI^^\fP is
127control-^. \fIEscape\fP is the escape key, or \f^[\fP.
128.TP
129.B #
130Select window \fI#\fP as the current window
131and return to conversation mode.
132.TP
133.B %#
134Select window \fI#\fP but stay in command mode.
135.TP
136.B ^^
137Select the previous window and return to conversation
138mode. This is useful for toggling between two windows.
139.TP
140.B escape
141Return to conversation mode.
142.TP
143.B ^P
144Return to conversation mode and write ^P to the
145current window. Thus, typing two ^P's in conversation
146mode sends one to the current window. If the \fIwindow\fP
147escape is changed to some other character, that
148character takes the place of ^P here.
149.TP
150.B ?
151List a short summary of commands.
152.TP
153.B ^L
154Redraw the screen.
155.TP
156.B q
157Exit \fIwindow\fP. Confirmation is requested.
158.TP
159.B ^Z
160Suspend \fIwindow\fP.
161.TP
162.B w
163Create a new window. The user is prompted for the positions
164of the upper left and lower right corners of the window.
165The cursor is placed on the screen and the keys ``h'', ``j'',
166``k'', and ``l''
167move the cursor left, down, up, and right, respectively.
168The keys ``H'', ``J'', ``K'', and ``L'' move the cursor to the respective
169limits of the screen. Typing a number before the movement keys
170repeats the movement that number of times. Return enters the cursor position
171as the upper left corner of the window. The lower right corner
172is entered in the same manner. During this process,
173the placement of the new window is indicated by a rectangular
174box drawn on the screen, corresponding to where the new window
175will be framed. Typing escape at any point
176cancels this command.
177.IP
178This window becomes the current window,
179and is given the first available ID. The default buffer size
180is used (see \fInline\fP command below).
181.IP
182Only fully visible windows can be created this way.
183.TP
184.B c#
185Close window \fI#\fP. The process in the window is sent
186the hangup signal (see \fIkill\fP (1)). \fICsh\fP (1) should
187handle this signal correctly and cause no problems.
188.TP
189.B m#
190Move window \fI#\fP to another location. A box in the shape
191of the window is drawn on
192the screen to indicate the new position of the window, and the same keys as
193those for the \fIw\fP command are used to position the box. The
194window can be moved partially off-screen.
195.TP
196.B M#
197Move window \fI#\fP to its previous position.
198.TP
199.B s#
200Change the size of window \fI#\fP. The user is prompted
201to enter the new lower right corner of the window. A box
202is drawn to indicate the new window size. The same
203keys used in \fIw\fP and \fIm\fP are used to enter the position.
204.TP
205.B S#
206Change window \fI#\fP to its previous size.
207.TP
208.B ^Y
209Scroll the current window up by one line.
210.TP
211.B ^E
212Scroll the current window down by one line.
213.TP
214.B ^U
215Scroll the current window up by half the window size.
216.TP
217.B ^D
218Scroll the current window down by half the window size.
219.TP
220.B ^B
221Scroll the current window up by the full window size.
222.TP
223.B ^F
224Scroll the current window down by the full window size.
225.TP
226.B h
227Move the cursor of the current window left by one column.
228.TP
229.B j
230Move the cursor of the current window down by one line.
231.TP
232.B k
233Move the cursor of the current window up by one line.
234.TP
235.B l
236Move the cursor of the current window right by one column.
237.TP
238.B ^S
239Stop output in the current window.
240.TP
241.B ^Q
242Start output in the current window.
243.TP
244.B :
245Enter a line to be executed as long commands. Normal line
246editing characters (erase character, erase word, erase line) are
247supported.
248.SH "LONG COMMANDS"
249Long commands are a sequence of statements
250parsed much like a programming language, with a syntax
251similar to that of C. Numeric and string expressions and variables
252are supported, as well as conditional statements.
253.PP
254There are two data types: string and number. A string is a sequence
255of letters or digits beginning with a letter. ``_'' and ``.'' are
256considered letters. Alternately, non-alphanumeric characters can
257be included in strings by quoting them in ``"'' or escaping them
258with ``\\''. In addition, the ``\\'' sequences of C are supported,
259both inside and outside quotes (e.g., ``\\n'' is a new line,
260``\\r'' a carriage return). For example, these are legal strings:
261abcde01234, "&#$^*&#", ab"$#"cd, ab\\$\\#cd, "/usr/ucb/window".
262.PP
263A number is an integer value in one of three forms:
264a decimal number, an octal number preceded by ``0'',
265or a hexadecimal number preceded by ``0x'' or ``0X''. The natural
266machine integer size is used (i.e., the signed integer type
267of the C compiler). As in C, a non-zero number represents
268a boolean true.
269.PP
270The character ``#'' begins a comment which terminates at the
271end of the line.
272.PP
273A statement is either a conditional or an expression. Expression
274statements are terminated with a new line or ``;''. To continue
275an expression on the next line, terminate the first line with ``\\''.
276.SH "CONDITIONAL STATEMENT"
277\fIWindow\fP has a single control structure:
278the fully bracketed if statement in the form
279.nf
280 if <expr> then
281 <statement>
282 . . .
283 elsif <expr> then
284 <statement>
285 . . .
286 else
287 <statement>
288 . . .
289 endif
290.fi
291The \fIelse\fP and \fIelsif\fP parts are optional, and the latter can
292be repeated any number of times. \fI<Expr>\fP must be numeric.
293.SH EXPRESSIONS
294Expressions in \fIwindow\fP are similar to those in the
295C language, with most C operators supported on numeric
296operands. In addition, some are overloaded to operate on strings.
297.PP
298When an expression is used as a statement, its value is discarded
299after evaluation. Therefore, only expressions with side
300effects (assignments and function calls) are useful as statements.
301.PP
302Single valued (no arrays) variables are supported, of both
303numeric and string values. Some variables are predefined. They
304are listed below.
305.PP
306The operators in order of increasing precedence:
307.TP
308.B <expr1> = <expr2>
309Assignment. The variable of name \fI<expr1>\fP, which must be string valued,
310is assigned the result of \fI<expr2>\fP. Returns the value of \fI<expr2>\fP.
311.TP
312.B <expr1> ? <expr2> : <expr3>
313Returns the value of \fI<expr2>\fP if \fI<expr1>\fP evaluates true
314(non-zero numeric value); returns the value of \fI<expr3>\fP otherwise. Only
315one of \fI<expr2>\fP and \fI<expr3>\fP is evaluated. \fI<Expr1>\fP must
316be numeric.
317.TP
318.B <expr1> || <expr2>
319Logical or. Numeric values only. Short circuit evaluation is supported
320(i.e., if \fI<expr1>\fP evaluates true, then \fI<expr2>\fP is not evaluated).
321.TP
322.B <expr1> && <expr2>
323Logical and with short circuit evaluation. Numeric values only.
324.TP
325.B <expr1> | <expr2>
326Bitwise or. Numeric values only.
327.TP
328.B <expr1> ^ <expr2>
329Bitwise exclusive or. Numeric values only.
330.TP
331.B <expr1> & <expr2>
332Bitwise and. Numeric values only.
333.TP
334.B <expr1> == <expr2>, <expr1> != <expr2>
335Comparison (equal and not equal, respectively). The boolean
336result (either 1 or 0) of the comparison is returned. The
337operands can be numeric or string valued. One string operand
338forces the other to be converted to a string in necessary.
339.TP
340.B <expr1> < <expr2>, <expr1> > <expr2>, <expr1> <= <expr2>, <expr1> >= <expr2>
341Less than, greater than, less than or equal to,
342greater than or equal to. Both numeric and string values, with
343automatic conversion as above.
344.TP
345.B <expr1> << <expr2>, <expr1> >> <expr2>
346If both operands are numbers, \fI<expr1>\fP is bit
347shifted left (or right) by \fI<expr2>\fP bits. If \fI<expr1>\fP is
348a string, then its first (or last) \fI<expr2>\fP characters are
349returns (if \fI<expr2>\fP is also a string, then its length is used
350in place of its value).
351.TP
352.B <expr1> + <expr2>, <expr1> - <expr2>
353Addition and subtraction on numbers. For ``+'', if one
354argument is a string, then the other is converted to a string,
355and the result is the concatenation of the two strings.
356.TP
357.B <expr1> * <expr2>, <expr1> / <expr2>, <expr1> % <expr2>
358Multiplication, division, modulo. Numbers only.
359.TP
360.B -<expr>, ~<expr>, !<expr>, $<expr>, $?<expr>
361The first three are unary minus, bitwise complement and logical complement
362on numbers only. The operator, ``$'', takes \fI<expr>\fP and returns
363the value of the variable of that name. If \fI<expr>\fP is numeric
364with value \fIn\fP and it appears within an alias macro (see below),
365then it refers to the nth argument of the alias invocation. ``$?''
366tests for the existence of the variable \fI<expr>\fP, and returns 1
367if it exists or 0 otherwise.
368.TP
369.B <expr>(<arglist>)
370Function call. \fI<Expr>\fP must be a string that is the unique
371prefix of the name of a builtin \fIwindow\fP function
372or the full name of a user defined alias macro. In the case of a builtin
373function, \fI<arglist>\fP can be in one of two forms:
374.br
375 <expr1>, <expr2>, . . .
376.br
377 argname1 = <expr1>, argname2 = <expr2>, . . .
378.br
379The two forms can in fact be intermixed, but the result is
380unpredictable. Most arguments can be omitted; default values will
381be supplied for them. The \fIargnames\fP can be unique prefixes
382of the the argument names. The commas separating
383arguments are used only to disambiguate, and can usually be omitted.
384.IP
385Only the first argument form is valid for user defined aliases. Aliases
386are defined using the \fIalias\fP builtin function (see below). Arguments
387are accessed via a variant of the variable mechanism (see ``$'' operator
388above).
389.IP
390Most functions return value, but some are used for side effect
391only and so must be used as statements. When a function or an alias is used
392as a statement, the parenthesis surrounding
393the argument list may be omitted. Aliases return no value.
394.SH "BUILTIN FUNCTIONS"
395The arguments are listed by name in their natural
396order. Optional arguments are in square brackets (``[ ]''). Arguments
397that have no names are in angle brackets (``<>'').
398.TP
399.B alias([<string>], [<string-list>])
400If no argument is given, all currently defined alias macros are
401listed. Otherwise, \fI<string>\fP is defined as an alias,
402with expansion \fI<string-list>\fP. The previous definition of
403\fI<string>\fP, if any, is returned. Default for \fI<string-list>\fP
404is no change.
405.TP
406.B close(<window-list>)
407Close the windows specified in \fI<window-list>\fP. If \fI<window-list>\fP
408is the word \fIall\fP, than all windows are closed. No value is returned.
409.TP
410.B cursormodes([modes])
411Set the window cursor to \fImodes\fP. \fIModes\fP is the bitwise
412or of the mode bits defined as the variables \fIm_ul\fP (underline),
413\fIm_rev\fP (reverse video), \fIm_blk\fP (blinking),
414and \fIm_grp\fP (graphics, terminal dependent). Return
415value is the previous modes. Default is no change.
416For example, cursor($m_rev|$m_blk) sets the window cursors to blinking
417reverse video.
418.TP
419.B echo([window], [<string-list>])
420Write the list of strings, \fI<string-list>\fP, to \fIwindow\fP, separated
421by spaces and terminated with a new line. The strings are only
422displayed in the window, the process in the window are not
423involved (see \fIwrite\fP below). No value is returned. Default
424is the current window.
425.TP
426.B escape([escapec])
427Set the escape character to \fIescape-char\fP. Returns the old
428escape character as a one character string. Default is no
429change. \fPEscapec\fP can be a string of a single character, or
430in the form \fI^X\fP, meaning control-\fIX\fP.
431.TP
432.B foreground([window], [flag])
433Move \fIwindow\fP in or out of foreground. \fIFlag\fP
434can be one of \fIon\fP, \fIoff\fP,
435\fIyes\fP, \fIno\fP, \fItrue\fP, or \fIfalse\fP, with obvious
436meanings, or it can be a numeric expression, in which case
437a non-zero value is true. Returns the old foreground flag
438as a number. Default for \fIwindow\fP is the current window,
439default for \fIflag\fP is no change.
440.TP
441.B label([window], [label])
442Set the label of \fIwindow\fP to \fIlabel\fP. Returns the old
443label as a string. Default for \fIwindow\fP is the current
444window, default for \fIlabel\fP is no change. To turn
445off a label, set it to an empty string ("").
446.TP
447.B list()
448No arguments. List the identifiers and labels of all windows. No
449value is returned.
450.TP
451.B nline([nline])
452Set the default buffer size to \fInline\fP. Initially, it is
45348 lines. Returns the old default buffer size. Default is
454no change. Using a very large buffer can slow the program down
455considerably.
456.TP
457.B select([window])
458Make \fIwindow\fP the current window. The previous current window
459is returned. Default is no change.
460.TP
461.B shell([<string-list>])
462Set the default window shell program to \fI<string-list>\fP. Returns
463the first string in the old shell setting. Default is no change. Initially,
464the default shell is taken from the environment variable \fISHELL\fP.
465.TP
466.B source(filename)
467Read and execute the long commands in \fIfilename\fP. Returns
468-1 if the file cannot be read, 0 otherwise.
469.TP
470.B terse([flag])
471Set terse mode to \fIflag\fP. In terse mode, the command window
472stays hidden even in command mode, and errors are reported by
473sounding the terminal's bell. \fIFlag\fP can take on the same
474values as in \fIforeground\fP above. Returns the old terse flag.
475Default is no change.
476.TP
477.B unalias(alias)
478Undefine \fIalias\fP. Returns -1 if \fIalias\fP does not exist,
4790 otherwise.
480.TP
481.B unset(variable)
482Undefine \fIvariable\fP. Returns -1 if \fIvariable\fP does not exist,
4830 otherwise.
484.TP
485.B variables()
486No arguments. List all variables. No value is returned.
487.TP
488.B window([row], [column], [nrow], [ncol], [nline], [frame],
489.B [pty], [mapnl], [shell])
490.br
491Open a window with upper left corner at \fIrow\fP, \fIcolumn\fP
492and size \fInrow\fP, \fIncol\fP. If \fInline\fP is specified,
493then that many lines are allocated for the text buffer. Otherwise,
494the default buffer size is used. Default values for
495\fIrow\fP, \fIcolumn\fP, \fInrow\fP, and \fIncol\fP are, respectively,
496the upper, left-most, lower, or right-most extremes of the
497screen. \fIFrame\fP, \fIpty\fP, and \fImapnl\fP are flag values
498interpreted in the same way as the argument to \fIforeground\fP (see above);
499they mean, respectively, put a frame around this window (default true),
500allocate pseudo-terminal for this window rather than socketpair (default
501true), and map new line characters in this window to carriage return
502and line feed (default true if socketpair is used, false otherwise).
503\fIShell\fP is a list of strings that will be used as the shell
504program to place in the window (default is the program specified
505by \fIshell\fP, see below). The created window's identifier
506is returned as a number.
507.TP
508.B write([window], [<string-list>])
509Send the list of strings, \fI<string-list>\fP, to \fIwindow\fP, separated
510by spaces but not terminated with a new line. The strings are actually
511given to the window as input. No value is returned. Default
512is the current window.
513.SH "PREDEFINED VARIABLES"
514These variables are for information only. Redefining them does
515not affect the internal operation of \fIwindow\fP.
516.TP
517.B baud
518The baud rate as a number between 50 and 38400.
519.TP
520.B modes
521The display modes (reverse video, underline, blinking, graphics)
522supported by the physical terminal. The value of \fImodes\fP is
523the bitwise or of some of the one bit values, \fIm_blk\fP, \fIm_grp\fP,
524\fIm_rev\fP, and \fIm_ul\fP (see below). These values are useful
525in setting the window cursors' modes (see \fIcursormodes\fP above).
526.TP
527.B m_blk
528The blinking mode bit.
529.TP
530.B m_grp
531The graphics mode bit (not very useful).
532.TP
533.B m_rev
534The reverse video mode bit.
535.TP
536.B m_ul
537The underline mode bit.
538.TP
539.B ncol
540The number of columns on the physical screen.
541.TP
542.B nrow
543The number of rows on the physical screen.
544.TP
545.B term
546The terminal type. The standard name, found in the second name
547field of the terminal's \fITERMCAP\fP entry, is used.
548.SH FILES
549.ta 15
550~/.windowrc startup command file.
551.br
552/dev/[pt]ty[pq]? pseudo-terminal devices.
553.SH DIAGNOSTICS
554Should be self explanatory.
555.SH BUGS