WINDOW(1,C) AIX Commands Reference WINDOW(1,C) ------------------------------------------------------------------------------- window PURPOSE Window environment. SYNTAX +--------+ +------------------+ +--------------+ window ---| +----+ |---| |---| |---| +-| -t |-+ +- -e escape-char -+ +- -c command -+ ^| -f || || -d || |+----+| +------+ Note: This command does not have MBCS support. DESCRIPTION The window command implements a window environment on ASCII terminals and PS/2s not on 3270 terminals. 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 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 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 designated to be in the foreground, in which case it is always 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 itself. Processed November 8, 1990 WINDOW(1,C) 1 WINDOW(1,C) AIX Commands Reference WINDOW(1,C) FLAGS When window starts up, the commands (see long commands below) contained in the file .windowrc 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. -t Turn on terse mode (see terse command below). -f Fast. Don't perform any startup action. -d Ignore .windowrc. and create the two default windows instead. -e escape-char Set the escape character to escape-char. Escape-char can be a single character, or in the form ^X where X is any character, meaning controlX. -c command Execute the string command as a long command (see below) before doing anything else. 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 pseudo-terminal (pty special files in AIX Technical Reference Vol II) or a UNIX domain socket (socketpair AIX Technical Reference Vol I). If a pseudo-terminal is used, then its special characters and modes (see stty) are copied from the physical terminal. The TERMINFO variable points to the terminfo entry tailored to this window which is created in the user's directory. The terminfo entry contains the window's characteristics and information from the physical terminal such as the existence of underline, reverse video, and other display modes and codes produced by any terminal function keys. 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 vi uses this information to redraw its display. Note: Processes can be run only from windows that use pseudo-terminals (pty). Windows that use socketpairs can be used only to display information, such as error messages. PROCESSING During normal execution, window can be 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. Processed November 8, 1990 WINDOW(1,C) 2 WINDOW(1,C) AIX Commands Reference WINDOW(1,C) 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 key strokes; long commands are strings either typed by the user in the command window (see the ":" command below), or read from a file see source below). SHORT WINDOW Below, # represents one of the digits "1" to "9" corresponding to the windows 1 to 9. ^X means control-X, where X is any character. In particular, ^^ is control-^. Escape is the escape key, or ^]. # Select window # as the current window and return to conversation mode. % # Select window # but stay in command mode. ^^ Select the previous window and return to conversation mode. This is useful for toggling between two windows. escape Return to conversation mode. ^P Return to conversation mode and write ^P to the current window. Thus, typing two ^P's in conversation mode sends one to the current window. If the window escape is changed to some other character, that character takes the place of ^P here. ? List a short summary of commands ^L Redraw the screen. q Exit window. Confirmation is requested. ^Z Suspend window. w Create a new window. The user is prompted for the position 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. 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 is framed. Typing escape at any point cancels this command. This window becomes the current window, and is given the first available ID. The default buffer size is used (see nline command below.) Processed November 8, 1990 WINDOW(1,C) 3 WINDOW(1,C) AIX Commands Reference WINDOW(1,C) Only fully visible windows can be created this way. c# Close window #. The process in the window is sent the hangup signal (see kill). The csh command should handle this signal correctly and cause no problems. m# Move 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-screen. M# Move window # to its previous position. s# Change the size of window #. The user is 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# Change window # to its previous size. ^Y Scroll the current window up by one line. ^E Scroll the window down by one line. ^U Scroll the window up by half the window size. ^D Scroll the window down by half the window size. ^B Scroll the window up by the full window size. ^F Scroll the current window down by the full window size. h Move the cursor of the current window left by one column. j Move the cursor of the current window down by one line. k Move the cursor of the current window up by one line. l Move the cursor of the current window right by one column. ^S Stop output in the current window. ^Q Start output in the current window. : Enter a line to be executed as long commands. Normal line editing characters (erase character, erase word, erase line) are supported. LONG WINDOW Processed November 8, 1990 WINDOW(1,C) 4 WINDOW(1,C) AIX Commands Reference WINDOW(1,C) 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 of 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. (That is "\\n" is a new line, and "\\r" a carriage return). These are also 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 (the signed integer type of the C compiler). As in C, a non-zero number represents a Boolean true. The character "#" begins a comment which terminates at the end of the line. A statement is either a conditional or an expression. Expression statements are terminated with a new line or ";". To continue an expression on the nest line, terminate the first line with "\\". CONDITIONAL STATEMENT Window has a single control structure: the fully bracketed if statement in the form. if then elsif then else endif The else and elsif parts are optional, and the latter can be repeated any number of times. must be numeric. EXPRESSIONS Expressions in window are similar to those on 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 (see "Predefined Variables"). Processed November 8, 1990 WINDOW(1,C) 5 WINDOW(1,C) AIX Commands Reference WINDOW(1,C) The operators in order of increasing precedence: = Assignment. The variable of name expr1, which must be string valued, is assigned the result of expr2. Returns the value of expr2. ? : Returns the value of expr2 if expr1 evalutes true (non-zero numeric value) : returns the value of expr3 otherwise. Only one of expr2 and expr3 is evaluated. Expr1 must be numeric. || Logical or. Numeric values only. Short circuit evaluation is supported (that is, if expr1 evaluates true, then expr2 is not evaluated). && 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, expr1 is bit shifted left (or right) by expr2 bits. If expr1 is a string, then its first (or last) expr2 characters are returns (if expr2 is also a string, then its length is used in place of its value). + , - Additions and subtractions of 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. Processed November 8, 1990 WINDOW(1,C) 6 WINDOW(1,C) AIX Commands Reference WINDOW(1,C) * , / , % Multiplication, division, modulo. Numbers only. -, (degree_symbol), !, $, $? The first three are unary minus, bitwise complement and logical compliment on numbers only. The operator, "$", takes expr and returns the value of the variable of that name. If expr is numeric with value n 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 expr, and returns 1 if it exists or 0 otherwise. () Function call. expr 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, argkist can be in one of two forms: , , . . . argname1 = , argname2 = , . . . The two forms can in fact be intermixed, but the result is unpredictable. Most arguments can be omitted; default values are supplied for them. The argnames can be unique prefixes of 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 are defined using the alias built-in function (see below). Arguments are accessed via a variant of the variable mechanism "$" operator above). 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. BUILT-IN FUNCTION The arguments are listed by name in their natural order. Optional arguments are in square brackets ("[ ]"). Arguments that have no names are in angle brackets ("<>"). alias([], []) If no argument is given, all currently defined alias macros are listed. Otherwise, string is defined as an alias, with expansion string-list. The previous definition of string, if any, is returned. Default for string-listis no change. close() Close the windows specified in window-list. If window-list is the word all, than all windows are closed. No value is returned. Processed November 8, 1990 WINDOW(1,C) 7 WINDOW(1,C) AIX Commands Reference WINDOW(1,C) cursormodes([modes]) Set 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(Sm_rev|Sm_blk) sets the window cursors to blinking reverse video. echo([window] []) Write the lists of strings, string-list, to window, separated by spaces and terminated with a new line. The strings are only displayed in the window; the processes in the window are not involved (see write below). No value is returned. Default is the current window. escape([escapec]) Set the escape character to escapec. Returns the old escape character as a one character string. Default is no change. escapec can be a string of a single character, or in the form ^X, meaning control -X. foreground([window], [flag]) Move window in or out of foreground. Flag can be one of on, off, yes, no, true, or false, with obvious meanings, or it can be a numeric expression, in which case a non-zero 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]) Set 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() No arguments. List the identifiers and labels of all windows. No value is returned. nline([nline]) Set 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]) Make window the current window. The previous current window is returned. Default is no change. shell([]) Set 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 form the environment variable SHELL. source(filename) Read and execute the long commands in filename. Returns -1 if the file cannot be read, 0 otherwise. Processed November 8, 1990 WINDOW(1,C) 8 WINDOW(1,C) AIX Commands Reference WINDOW(1,C) terse([flag]) Set 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. Flag can take on the same values as in foreground above. Returns the old terse flag. Default is no change. unalias(alias) Undefine alias. Returns -1 if alias does not exist, 0 otherwise. unset(variable) Undefine variable. Returns -1 if variable does not exist, 0 otherwise. variable() No arguments. List all variables. No value is returned. window(row column nrow ncol [nline] [label] [pty] [frame] [mapnl] [shell]) Open a window with upper left corner at row, column and size nrow, ncol. 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 ncol are, respectively, the upper, left-most, lower, or right-most extremes of the screen. Frame, pty, and mapnl are flag values interpreted in the same way as the argument to foreground (see above); 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). Shell is a list of strings that are used as the shell program to place on the window (default is the program specified by shell, see below). The created window's identifier is returned as a number. write([window], []) Send the list of strings, string-list, to window, separated by spaces but not terminated with a new line. 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 38400. 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 one bit values, m blk, m grp, m rev, and m ul (see below). These values are useful in setting the window cursors modes (see cursormodes above). Processed November 8, 1990 WINDOW(1,C) 9 WINDOW(1,C) AIX Commands Reference WINDOW(1,C) m_blk The blinking mode bit. m_grp The graphics mode bit. 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 terminfo entry, is used. FILES $HOME/.windowrc Startup command file. Processed November 8, 1990 WINDOW(1,C) 10