. User's Guide to the Z Editor Mark Zbikowski 4 August 1986 Table of Contents Starting Z..................................................... 1 Editing Functions.............................................. 4 Editing Switches and Flags.................................... 15 Keystroke Macros.............................................. 17 Index......................................................... 21 Revision History.............................................. 23 Z User's Guide Printed: November 5, 1986 11:52 AM What is the Z editor? Z is an editor, a program for creating and altering files. The editor creates the file specified or copies an existing file from disk into memory. Then when the file is "saved", the copy in Z overwrites the copy on disk. The copy that was overlayed may be retrieved with the UNDEL command (see UNDEL.HLP and also the "backup" switch below). Z makes your screen into a window on the file you are editing. The window can move forwards or backwards to any point in the file. The cursor identifies the focus of each edit operation. The simplest editing operation is to move the cursor to the place you want to change and start typing characters. What you type is stored in the corresponding location in the copy of the file in Z. If you are in INSERT mode, then the characters you type are inserted at the cursor location instead of overwriting what is already there. The editor interprets ASCII control characters and some ASCII character sequences as commands. Each control character has an editing command associated with it. You can change the association between editor commands and control characters or character sequences with the command. Starting Z Z uses several environment variables during its start-up. First, Z looks for a file called TOOLS.INI by searching all the directories contained in the USER environment variable. Contained in this TOOLS.INI file are any customizations you wish to make to the editor function assignments and editor switch settings. This file is optional. Starting Z with the /D switch prevents TOOLS.INI from being read. Z uses a scratch file during it execution. Normally, this file (Z.VM) is created in the root directory on the default drive when Z is started. If you want this file to be created elsewhere, for example on a ram- drive, you may use the TMP environment variable to direct Z to place it elsewhere. The TMP variable is also used to locate other temporary files that Z uses. The TOOLS.INI file is used to maintain configuration information. The files are divided into sections by tags which are the name of a tool surrounded by square brackets. In the case of the Z editor, the following tags are used: [z] following this tag should be general Z initialization [z-x.y] following this tag should be Z initialization peculiar to a particular version of MSDOS. Z User's Guide Printed: November 5, 1986 11:52 AM For a sample of user initialization, see the TOOLS.INI file. The definitions in these files have one of several forms. Below are the forms and a description of each. NAME=xx yy zz... This assignment directs Z to view the sequence of characters xx yy zz ... (in hexadecimal) as a single keystroke. This is often used for naming function keys on your terminal. NAME="chars" Similar to the previous form except that the characters are named explicitly. Quotes may be preceded with the "\" character to allow you to enter them directly. function:=function1 function2... Defines a new function in terms of existing functions. This is called a MACRO. When the new function is executed by Z, each function contained in the definition is executed in order. Further information is contained in the Keyboard Macros section below. function:keys Causes Z to execute the named function when the specified keys are read from the keyboard. The keys are either a key name as defined above or a sequence of characters to be used. Note that ^X in such a sequence stands for CONTROL-X rather than up-arrow-X. You may have several keys or key sequences assigned to a particular editing function, but you may have ONLY one function on a key or sequence. A description of the available editing functions is below. switch:value Set a particular configuration switch in Z to a value. See the "switches and flags" section below for more information. Anyway, when Z is through initializing, it attempts to read the file specified on the command line. If Z was invoked without an argument, it will attempt to read in the most recently edited file. When the file has been read in, Z will display the file on the top 23 lines of the screen. The bottom two lines are used as follows: The 24th line is used as a dialog line. Prompts and messages appear on this line. The 25th line is used as a status line. The information that appears is (from left-to-right): filename of file being edited type of file (a guess based on the extension) - 2 - Z User's Guide Printed: November 5, 1986 11:52 AM the word modified, if you have changed the file the length in lines of the file the position in (row, column) form of the upper-left corner of the screen relative to the first byte of the file. (1,1) is the top of the file Now for the interesting part. Normally, when a key sequence is recognized by Z as being attached to an editing function, Z will execute that function. Most functions have a 'default' action which is unchangeable. You may change this action by preceding the editing function with an argument and/or a mode- function modifier. Arguments are introduced by the editor function. When you enter the function, Z will reverse the video at the current cursor position. You may then enter the argument as follows: A sequence of cursor movements: If the cursor ends up on top of the then the argument is called a nullarg and represents either the remainder of the line up to (and possibly including the line break) or represents the next space-terminated word on the line depending on the editing function. If the cursor ends up on the same line but on a different column, the argument is called a streamarg and represents all text from the leftmost of the and cursor up to one character position to the left of the rightmost of the and cursor. If the cursor ends up in the same column as the then the argument is called a linearg and represents the range of lines beginning with the line that contains the up to and including the line that contains the cursor. If the cursor ends up on a different line and column from the , the arg is known as a boxarg and may represent either a rectangle of text whose diagonal is delimited by the and cursor or the sequence of characters beginning at the uppermost of and cursor through the bottommost of and cursor including the line breaks. This distinction is made by the editing function itself. You may also type normal characters. You are prompted, on the dialog line, to enter an argument. The types of textual arguments are: ASCII text. This is called a textarg. The argument to the function is merely the text you have typed. A number. This is called a numarg and is the same as if you had moved the cursor either upward or downward the specified number of lines. - 3 - Z User's Guide Printed: November 5, 1986 11:52 AM A bookmark. This is called a markarg. This is the same as if you had moved the cursor to the bookmark position. To define a bookmark, see the command. The only mode-command modifier at the present is the command. Its effect on each function is described in that function's description. Editing Functions Here is the current set of Z functions with a description of the allowed arguments and a description of how they affect the command's operation. Also, in each function description is the default assignment. (^X) introduces an argument to modify a subsequent operation. To cancel an , enter the command. There are no modifiers or arguments allowed for this command. (^^) makes a Z configuration change. An argument MUST be specified and be of the form described for TOOLS.INI above: linearg treats each line as a separate assignment or key definition. textarg treats textarg as an assignment or a key definition. nullarg treats the remainder of the line to the right of the cursor but not including the line break as an assignment or a key definition. streamarg treats the outlined text as an assignment or a key definition. The special case of ? displays all the current keyboard assignments. (SHIFT-TAB) is a cursor movement function. It will move the cursor leftward to the next tabstop. Tabstops are defined to be every nth character where n is settable by the tabstops editor switch. Being a cursor movement function, takes no arguments nor mode-command modifiers. (END) is a cursor movement function that places the cursor on the first non-blank character on the line. places the cursor on the first character position on the line regardless of the contents of the line. (^C) will cancel the current operation in progress. Depending on your operating system, some of these operations may be completed before the is read. will always cancel an argument so it never takes an argument nor a mode-command modifier. - 4 - Z User's Guide Printed: November 5, 1986 11:52 AM (BACKSPACE or ^H) will attempt to delete the previous character. Note that this function will NOT delete line breaks. For that function, see the function below. If the cursor is in column 1, will move the cursor to the previous line and place it just to the right of the last character on that line. If issued while an argument was being issued, is treated as a cursor-left command. If issued in insert mode, will delete the previous character from the line, reducing the length of the line by 1. If there is nothing but whitespace on the line to the left of the cursor, the cursor is placed in column 1 of the line. If the cursor is beyond the last non- whitespace character on the line, it is moved to the character immediately to the right of the end of line. Otherwise, the cursor is moved one position to the left and a space replaces the character under the cursor. (^U) is used to perform background compilations and to review error messages from them. will read the next error message and attempt to parse it into file, row, column and message. If it is successful, Z will read in the file, place the cursor on the appropriate row and column, and display the message on the dialog line. currently works with GREP, Lattice C, Microsoft C, and the C-based Microsoft Assembler. will read error messages and advance to the first message that is NOT for the current file. nullarg will attempt to compile the current file, resulting in the current file being compiled and linked. The command and arguments used to compile the file are determined by the extension of the file and can be changed by the extmake: switch . textarg uses a special command and arguments to compile the specified text. This can be changed by using the extmake: switch with extension "text". streamarg as above but uses the text selected on the screen as the arguments for the command. textarg will invoke the text as a program. The program is assumed to display its errors in file row column message format. This is often useful to find text in a series of files by using GREP: grep /l pat files ; zibo grep grep -n pat files ; *NIX grep (ALT-D) is a predefined macro that will insert the current date at the current cursor position. is a predefined macro that will insert the current day at the current cursor position. - 5 - Z User's Guide Printed: November 5, 1986 11:52 AM is a predefined macro that is the extension of the most recently switched file. is a predefined macro that is the file name of the most recently switched file. (ALT-T) is a predefined macro that will insert the current time at the current cursor position. is a predefined macro that will insert the name of the current user at the current cursor position. This uses the MAILNAME environment variable. (DOWN arrow) is a cursor movement function that moves the cursor to the line below the current one. If this results in the cursor moving off the bottom of the screen, the window is adjusted appropriately. Being a cursor movement function, takes no arguments. moves the cursor to the same column position but to the last displayed line on the current window. (CTRL-BACKSPACE) behaves identically to except that at the beginning of a line while in insert mode, will delete the line break between the current line and the previous line, joining the two lines together. (unassigned) behaves identically to except that when in insert mode, it will break the current line at the current cursor position. (PGDN) moves the cursor beyond the last character on a line. moves the cursor to the column corresponding to the right- most edge of the screen. (F9) is used to terminating an editing session. There are editing flags and switches that modify the behaviour of the command: askexit/noaskexit, backup, entab, tmpsav (see Editing Switches and Flags section). saves the current file if it has been modified. Z saves its temporary file and scans the set of in-core files. If any are modified, Z will ask you to confirm the exit. is identical to except that it skips the save of the current file. See for details of the saving operation. is identical to except that Z does not exit but advances to the next file on the command line. is identical to except that Z does not save the current file. - 6 - Z User's Guide Printed: November 5, 1986 11:52 AM (HOME) is a cursor movement function that places the cursor in the upper-left-hand corner of the current window. (F1) saves the current file and 's to the information file which contains a list of all files in core along with the current set of files that you have edited. The size of this list is controlled by the tmpsav switch. (F2) causes Z to reread the user configuration files. This is useful when initially configuring your editor and when attempting to use someone else's keyboard assignments. rereads all the Z switches for the user configuration files. text rereads all the Z switches for the system and reads the user switches from the section of the user's TOOLS.INI that is tagged [Z- text]. (^N) toggles the state of the insert mode switch. This switch is easily seen on the right hand side of the status line. When insert mode is on, each graphic character is inserted at the current cursor position, the remainder of the line is shifted one character to the right and the cursor is advanced one position. Note, however, that the function is NOT a graphic character and does NOT cause insertion of a line break. For this, please see the function. Z normally is started in overstrike mode. You can use the editor flag enterinsmode to cause Z to begin execution in insert mode. (^F) deletes a range of lines or a box within a series of lines. deletes the current line and places it into the pick buffer. deletes from the cursor up to the end of line and places that text into the pick buffer. Note that it does not join the current line with the next line. linearg deletes all lines specified and places the block into the pick buffer. boxarg deletes the box specified from the file and places it into the pick buffer. streamarg deletes the specified characters (treated as a box one line high). (LEFT arrow) moves the cursor one position to the left. If this results in the cursor being off the screen, then the window is adjusted appropriately by scrolling a number of columns defined by the hscroll editor switch. moves the cursor to the leftmost position on the screen. - 7 - Z User's Guide Printed: November 5, 1986 11:52 AM (^D) inserts blank lines. inserts one blank line underneath the cursor. inserts or deletes blanks at the beginning of a line to make the first non-blank character appear under the cursor. linearg inserts the indicated range of blank lines. boxarg inserts an empty box in the indicated range. streamarg inserts an empty region (treated as a box one line high). (^P) goes to a specified spot in a file. goes to beginning of file. restores the screen to its previous location. Z remembers only one previous location. is used to flip between two viewpoints in the file. numarg moves the cursor to the beginning of the specified line. text defines a bookmark at the current cursor location. That bookmark can now be addressed with the specified textual name. text moves the cursor to the indicated bookmark. If it was not previously defined, Z will use the editor switch markfile to find a file that contains bookmark definitions. This file contains lines of the form: bookmark file row column (ESC) is a function modifier. It is used to prefix functions to change their behaviour. See the individual function description for more information. (^W) adjusts the window on the file a few lines towards the beginning of the file. adjusts the window backwards in the file. The number of lines it is moved is determined by the editor switch vscroll. moves the window until the line that the cursor is on is at the bottom of the screen. numarg moves the window backwards the specified number of lines. (^Q) moves the window back by pages. moves the window backwards in the file by one screen's worth of lines. - 8 - Z User's Guide Printed: November 5, 1986 11:52 AM moves the window all the way back to the beginning of the file. numarg moves the window the specified number of pages backward in the file. (CTRL-PGUP) moves the cursor backwards by paragraphs. Paragraphs are blocks of text separated by blank lines. moves the cursor backwards one paragraph and places the cursor on the first line of the paragraph moves the cursor backwards one paragraph and places the cursor just beyond the last line of the paragraph. (^E) searches backwards in a file for a string or a regular expression. If the editor switch case is set then case is significant in the search otherwise case is ignored. searches backwards for the previously defined string or pattern. If the string/pattern is found, then the window is moved to display it and the matched string/pattern is highlighted. If it was not found, no cursor movement takes place. streamarg searches backwards for the selected text. In this case, the text is treated as a simple string. text searches backwards for the text. In this case, the text is treated as a simple string. streamarg text searches backwards for a regular expression. The patterns that Z understands are called "regular expressions". These are true regular expressions (plus some optimizations) rather than the much-weakened form that is used on the *NIX xGREPs. The simplest form of regular expression is just a string, like "hello". This pattern will match occurrences of the word "hello", or substrings of words like "othello". It will even match the string "Hello" if the nocase editor switch is given. Most characters in a regular expression match themselves, but some characters (one of "{}()[]!~:?^$+*@#") have a special meaning to the pattern matcher. These special characters are used to specify more complex patterns: \ "escape"; ignore the special meaning of the next character and just match that character. "\?" matches the question-mark and "\\" matches a single backslash. ? "wildcard"; match any character. [class] "character class"; this is used to match one of a set of characters. "[abc]" matches an "a", "b", or "c". The character "-" - 9 - Z User's Guide Printed: November 5, 1986 11:52 AM is used here to specify a range of characters; "[a-zA-z0-9]" matches a letter or a number. [~class] "not character class"; this is used to match a character that is NOT in the specified set of characters. ^ "beginning of line"; this matches or "anchors" a pattern to the beginning of the line. $ "end of line"; matches the end of a line. In the following, X denotes some regular expression: X* "closure"; this matches zero or more occurrences of the pattern X. It will match as few X's as it can, e.g. if the pattern is "?*ab" then it will match the first "ab" in "abababab". If the pattern is "?*ab$", then it will match the entire string "abababab", with the "?*" portion of the pattern matching "ababab". X+ "plus"; this is just a shorthand for XX+. It will match one or more occurrences of the pattern X. X@ "greedy closure"; this matches zero or more occurrences of the pattern X, but it starts out by matching as many X's as it can. and backs off on this choice ONLY if the rest of the pattern doesn't match. So, the pattern "?@ab" will match the whole string "abababab", unlike "?*ab" above. X# "greedy plus"; a shorthand for XX@. (X1!X2!...!Xn) "alternation"; this will match either X1, or X2, ... or Xn. It tries them in that order and it will switch from Xi to Xi+1 only if the rest of the pattern fails to match. ~X "not" or "guard"; this pattern matches nothing, but it checks to see if the string matches X at this point, and fails if it does. For example, "^~(foo!bar)?*$" will match all lines that don't begin with "foo" or "bar". X^n "power"; this pattern matches exactly n copies of X. The following commonly used patters are defined for your typing convenience. To use them, just put : in your pattern: :a [a-zA-Z0-9] alphanumeric :b ([ \t]#) whitespace :c [a-zA-Z] alphabetic :d [0-9] digit :f ([~ "\[\]\:<|>+=;,.]#) file part :h ([0-9a-zA-Z]#) hex number :i ([a-zA-Z_$][a-zA-Z0-9_$]@) identifier :n ([0-9]#.[0-9]@![0-9]@.[0-9]#![0-9]#) number :p (([a-z]\:!)(\\!)(:f(.:f!)\\)@:f(.:f!)) path :q ("[~"]@"!'[~']@') quoted string - 10 - Z User's Guide Printed: November 5, 1986 11:52 AM :w ([a-zA-Z]#) word :z ([0-9]#) integer (unassigned) moves the cursor backwards by words. moves the cursor backwards one word and places the cursor on the beginning of the word. moves the cursor backwards one word and places the cursor just beyond the end of the word. (ENTER or ^M) moves the cursor to a new line. moves the cursor to the beginning of the next line. If the editor switch softcr is set, then Z will attempt to place the cursor on a meaningfully tabbed-in position based on the type of file. If the file is a C program, then Z will attempt to correctly tab in based on continuation of lines and on open blocks. Otherwise, if the next line is blank, Z will place the cursor in the column corresponding to the first non-blank character in the previous line. If all else fails, Z places the cursor on the first non-blank character of the line. moves the cursor to the real beginning of the next line. (^V) balances parenthesis and brackets. scans backwards through the file balancing parenthesis and brackets. When the first unbalanced one is found, the matching character is placed into the file at the cursor position. If it is found in the visible window, Z will alter its color for a short interval. If it is found and it is not visible, Z will display the matching line on the dialog line. scans forward for unbalanced characters. (^K) grabs text from the file and places it into the pick buffer. This allows simple copy-and-paste operations. places the current line into the pick buffer. places the text from the current cursor position up to the end-of- line into the pick buffer. Note that the line break is not picked up. linearg places the specified range of lines into the pick buffer. boxarg places the text of specified box into the pick buffer. text places the text into the pick buffer. - 11 - Z User's Guide Printed: November 5, 1986 11:52 AM numarg places the specified range of lines into the pick buffer. markarg places the range of text between the cursor and the location of the bookmark into the pick buffer. (^T) adjusts the window on the file a few lines towards the end of the file. adjusts the window forward in the file. The number of lines it is moved is determined by the editor switch vscroll. moves the window until the line that the cursor is on is at the top of the screen. numarg moves the window forward the specified number of lines. (^L) moves the window forward by pages. moves the window forwards in the file by one screen's worth of lines. moves the window all the way to the end of the file. numarg moves the window the specified number of pages forward in the file. (CTRL-PGDN) moves the cursor forwards by paragraphs. Paragraphs are blocks of text separated by blank lines. moves the cursor forwards one paragraph and places the cursor on the first line of the paragraph moves the cursor forwards one paragraph and places the cursor just beyond the last line of the paragraph. (^R) searches forwards in a file for a string or a regular expression. See for the definition of the regular expression patterns. searches forwards for the previously defined string or pattern. If the string/pattern is found, then the window is moved to display it and the matched string/pattern is highlighted. If it was not found, no cursor movement takes place. streamarg searches forwards for the selected text. In this case, the text is treated as a simple string. text searches forwards for the text. In this case, the text is treated as a simple string. streamarg text searched forwards for a regular expression. - 12 - Z User's Guide Printed: November 5, 1986 11:52 AM (^Z) runs the command shell. Depending on the OS, you either get COMMAND.COM or SH. saves the current file and runs the shell. does not save the current file and runs the shell. See for a description of the save operation. uses the text on the screen from the cursor up to end-of- line as a command to the shell. text uses the text as a command to the shell. (^G) inserts the text of the pick buffer into the file beginning at the current cursor position. The insertion depends on the type of text stored in the pick buffer: text streamarg places the specified text into the pick buffer and inserts the specified text at the current cursor position. text interprets text as a filename and will insert the contents of the specified file into the current file at the current cursor position. lines are inserted directly before the cursor and do not break the line. boxes are inserted in the current line and all succeeding lines. streams break the current line and are inserted at the cursor. (unassigned) moves the cursor forwards by words. moves the cursor forwards one word and places the cursor on the beginning of the word. moves the cursor forwards one word and places the cursor just beyond the end of the word. (CTRL-ENTER or ^J) performs global search and replace but prompts for confirmation of each replacement. See . (unassigned) reads one keystroke from the keyboard and treats it literally. This is useful for inserting text into a file that happens to be assigned to an editor function. (F10) reloads or discards the current file. prompts and rereads the file from disk, discarding all edits. prompts and discards the file from the editor memory. (^O) performs global search and replace. The editor switch case indicates whether case is significant for comparison. - 13 - Z User's Guide Printed: November 5, 1986 11:52 AM perform simple search and replace, prompting you for the search string and for the replacement string. The search begins at the cursor position and continues through the end of file. linearg performs the search and replace on the specified line range. numarg performs the search and replace on the specified line range. boxarg performs the search and replace within the specified box. markarg performs the search and replace between the cursor and the specified bookmark. linearg numarg boxarg markarg all perform the same as above except that the search pattern is a regular expression and the replacement pattern can select special tagged sections of the search for selective replacement. If the regular expression contains {...} these are not matched directly (except when preceded with a \). They indicate the beginning and end of tagged sections. You can select from these in the replacement string by $n where n is a digit from 0 to 9. $0 represents the entire matched string. For example, if the pattern is "^{[a-zA-Z]@} #{[0-9]@}$" and the string is "Fahrenheit 451", the first pair of curly braces will mark off "Fahrenheit", and the second pair will delimit "451". You can refer to the first field as $1, the second as $2, and the whole matched string as $0. is a predefined macro that restores the current cursor position saved with . (RIGHT arrow) moves the cursor one position to the right. If this results in the cursor being off the screen, then the window is adjusted appropriately by scrolling the number of columns specified by the hscroll editor switch. moves the cursor to the rightmost position on the screen. is a predefined macro that saves the current cursor position to be restored with . - 14 - Z User's Guide Printed: November 5, 1986 11:52 AM (^S) deletes a stream of text. This includes line breaks and parallels what simpler editors (vi, emacs) do. delete one character under the cursor. This does not delete line breaks. It does not place that character into the pick buffer. delete from the cursor through the end-of-line, joining the following line with the current line the cursor position. The text deleted (including the line break) is placed into the pick buffer. streamarg delete the indicated stream of text. linearg boxarg markarg delete the text beginning at the bookmark and ending at the cursor including all line breaks. All removed text is entered into the pick buffer. (^B) switches the file currently being edited, optionally saving any changes to the current file. If the name of the file you indicate contains any meta-characters (? or *) Z will display a menu of all matching files. If the file to be save is read-only, Z will prompt you for another name under which to save the file. Z will also allow you to specify a environment variable as part of the name to be searched. For example, if you have a batch file FOO.BAT somewhere in your execution path, you can use to visit it by entering $PATH:FOO.BAT. switches to the most-recently edited file saving any changes. Toggling between two file is accomplished by repeated 's. switches to the file name that begins at the cursor and ends on the first blank, saving any changes made to the current file. If the text indicated is in actuality a directory, Z will change its working directory to that specified. text switches to the specified text. If the text indicated is in actuality a directory, Z will change its working directory to that specified. text as above but disables the saving of changes to the current file. text saves the current file under the specified name. saves the current file. (^]) redisplays the screen and adjusts the window. - 15 - Z User's Guide Printed: November 5, 1986 11:52 AM redisplays the entire screen. redisplays the line that the cursor is on. adjusts the window so that the cursor position is in the upper left. (^A) inserts streams of blank space. inserts a single blank space. inserts a line break at the current cursor position, splitting the line at the cursor. linearg boxarg markarg break the line at the bookmark and insert the appropriate number of blank lines and spaces. (TAB or ^I) is a cursor movement function. It will move the cursor rightward to the next tabstop. Tabstops are defined to be every nth character where n is settable by the tabstops editor switch. Being a cursor movement function, takes no arguments nor mode- command modifiers. (UP arrow) is a cursor movement function that moves the cursor to the line above the current one. If this results in the cursor moving off the top of the screen, the window is adjusted appropriately. Being a cursor movement function, takes no arguments. moves the cursor to the same column position but to the top of the displayed window. (^Y) creates, destroys and moves between editing windows. Z allows the screen to be broken up into up to 8 non-overlapping editing windows that each can contain different files. moves to the next window to the right of or below the current window. splits the current window horizontally at the cursor. splits the current window vertically at the cursor. merges the current window with one to the right or below. Editing Switches and Flags Editing switches that take numerical values and their default values. bgcolor (0) gives the background color for the editing screen. This is available only on the IBM PC version. - 16 - Z User's Guide Printed: November 5, 1986 11:52 AM debug (0) controls display of macros while they are being executed. See the documentation on keystroke macros below. entab (1) controls the degree of tabification that Z performs when outputting a file. entab:0 directs Z to output the file with no tabs. entab:1 directs Z to attempt to entab all multiple spaces outside of quoted strings. These strings are delimited either with quotes (") or apostrophes ('). entab:2 directs Z to maximally entab the line. errcolor (4) is the color used when displaying error messages on the screen. This is available only on the IBM PC version. fgcolor (7) is the color used for foreground display of the editing windows. This is available only on the IBM PC version. height (23) is the number of lines that Z uses in the editing window. This is useful when using a nonstandard display device: EGA in 43- line mode on the IBM PC and Ambassador terminals are simple examples. hike (4) is the location on the screen of the cursor when the cursor is moved by editing functions. Some of the cursor movement commands above move the cursor as opposed to scroll the cursor. Scrolling is controlled by the hscroll and vscroll parameters below. For direct movement, hike is the position in the editing window where Z will place the cursor on the direct movement. hscroll (10) is the number of columns scrolled when the cursor is scrolled off of the editing window. infcolor (6) is the color used for information messages. This is available only on the IBM PC version. rmargin (72) is the right margin column used in wordwrap mode. Any space hit to the right of this margin causes a line break as does any character hit beyond the rmargin+4 position. Wordwrap mode is set by the wordwrap switch below. stacolor (3) is the color used for the status line. This is available only on the IBM PC version. tabstops (4) is the number of spaces between each logical tab stop on the editing screen. Note that these tabstops are attached to the file and not to the window. tmpsav (20) is the number of files that Z remembers between editing sessions. When you exit Z, the specified number of files are saved in a temp file along with the position of the window and cursor within each. Also saved is the layout of the windows you had created. - 17 - Z User's Guide Printed: November 5, 1986 11:52 AM vscroll (7) is the number of lines scrolled when the cursor is scrolled off the editing window. It is also the number of lines scrolled by the and editing functions. Editing switches that are boolean in nature. To set switch put switch: in TOOLS.INI, to reset switch put noswitch: in tools.ini, e.g. askexit: or noaskexit. askexit (off) causes Z to prompt for confirmation when you exit. askrtn (on) causes Z to prompt for confirmation when you return to after autosave (on) causes Z to save the current file whenever you switch away from it. Some users prefer to issue a command to save the file rather than have Z "know" when to do it for them. case (off) causes Z to consider case to be significant for search and replace operations. enterinsmode (off) causes Z to start up in insert mode as opposed to overstrike mode. softcr (on) lets Z guess at proper indentation when the or editing functions are hit. trailspace (off) causes Z to remember trailing spaces in text. Normally, Z discards trailing spaces. wordwrap (off) causes Z to break lines of text on word boundaries when you edit them beyond the margin specified by rmargin. Editing switches that are textual in nature: backup (undel)is the method used for creating backup versions of edited files. The text that follows is one of the following: none perform no backup operation. undel delete the file so that the UNDEL command can retrieve it. bak place the previous version in a version with the extension .bak. extmake (none)is used to associate a compiler and command line with a particular extension for use by the command. The text that follows the switch is of the form: extension command arguments where extension is the extension of the file to match, command is a command to execute and arguments are the parameters to be passed to the command. There may be a %s in the arguments section that is replaced with the name of the current file or with the selected text (see ). The special extension "text" is used to set the compiler command for when the user enters text. - 18 - Z User's Guide Printed: November 5, 1986 11:52 AM markfile (none)is the name of the file Z searches when looking for a bookmark that is not in the in-memory set. readonly (none)is the command that will be invoked when z attempts to overwrite a readonly file. The current file name will be appended to the command, e.g. readonly: chmode -r Keystroke Macros The above set of editing functions are a fairly comprehensive set of functions that you can use in your day-to-day editing. Often, however, you can come up with a set of operations that are commonly executed together. Instead of entering each function separately, a tedious operation of the keyboard is not comfortably laid out, you can define new editing functions that are defined in terms of the previously defined set of functions. This is done in two steps. First, a definition of the editing function in terms of the components needs to be done. You would use the function or your TOOLS.INI file to create this definition. Remember that editing the TOOLS.INI does not define the function, you must either exit Z or use the function to process it. Remember too, that if you use the function to define an editing function, you will lose this definition if you exit Z. This operation defines the new editing function. The next step is to assign a keyboard sequence to this function, causing the function to be executed each time the specific keys are pressed. Again, this can be accomplished either by editing the TOOLS.INI or by using the editing function. Let's try two examples. First, define and assign a function that will delete from the cursor through the end of the current or next word. Normally, this is accomplished by entering the following editing functions: ; define the beginning of a sdelete argument ; move to end of current/next word ; delete from arg through the current cursor position ; including all line breaks. Let's call this new function worddelete. To define it in the TOOLS.INI file all we need to do is locate the [Z] tagged section and add the following line: worddelete:=arg meta pword sdelete Easy, eh? To assign this to a keystroke sequence, say ALT-D on the IBM PC keyboard, we'd also enter the line: - 19 - Z User's Guide Printed: November 5, 1986 11:52 AM worddelete:ALT-D Once we'd reinitialize the editor (either via the command or by exiting Z and then starting it up again), each time we'd hit ALT- D, a word would disappear. To insert actual text into the file inside a macro all you need to do is enclose that text in quotes. The second example below shows how. Let's define a function that inserts a C-language "if" statement before the line with the cursor. You'd do this normally by typing: 2 ; insert two blank lines ; let Z guess at the indentation "if () {" ; place in the first part of the if "}" ; close the consequent ; put the cursor back onto the if The TOOLS.INI entries for this are: insert-if:=arg "2" linsert up newline "if () {" newline "}" up begline insert-if:ALT-I All editing functions have return codes. These values may be tested and acted upon by the following macro statements: :>label defines a label that can be referenced in any of the below macro commands. =>label is a direct transfer to the specified label. If label is omitted then the current macro is exited. ->label directs transfer to the specified label iff the previous editor function returned FALSE. If label is omitted then the current macro is exited. +>label directs transfer to the specified label iff the previous editor function returned TRUE. If label is omitted then the current macro is exited. - 20 - Z User's Guide Printed: November 5, 1986 11:52 AM Below is a list of all the editor functions and their return conditions. Function Condition for TRUE Condition for FALSE arg Always Never assign Assignment was successful Invalid arg or assignment backtab Cursor moved Cursor was at left margin begline Cursor moved Cursor did not move cancel Always Never cdelete Cursor moved Cursor did not move compile Exec of compiler succeeded Bad arg, compiler not found down Cursor moved Cursor did not move emacscdel Cursor moved Cursor did not move emacsnewl Always Never endline Cursor moved Cursor did not move exit No return No return home Cursor moved Cursor did not move information Always Never initialize Successful initialization Bad arg insertmode If insert mode was on If insert mode was off ldelete Successful line delete Bad arg left Cursor moved Cursor did not move linsert Successful line insert Bad arg mark Succ. definition or move Bad arg or mark not found meta If meta was on If meta was off mlines Successful movement Bad arg mpage Successful movement Bad arg mpara Successful movement Bad arg msearch Found string Bad arg or not found mword Cursor moved Cursor did not move newline Always Never pbal Balance was successful Bad arg or not balanced pick Successful pick Bad arg plines Successful movement Bad arg ppage Successful movement Bad arg ppara Successful movement Bad arg psearch Found string Bad arg or not found push Successful push Bad arg or prog not found put Always Never pword Cursor moved Cursor did not move qreplace >= 1 replacement Not found, invalid pattern quote Always Never refresh File was read in/deleted Canceled, bad arg replace >=1 replacement Not found, invalid pattern right Cursor over text of line Cursor beyond end of line sdelete Successful delete Bad arg setfile Not canceled, changed Bad arg, canceled setwindow Successful window change Bad arg sinsert Successful insert Bad arg tab Cursor moved Cursor did not move up Cursor moved Cursor did not move window Successful split/join/move Any error - 21 - Z User's Guide Printed: November 5, 1986 11:52 AM Index commands (^X)................................................... 4 (^^)................................................ 4 (SHIFT-TAB)........................................ 4 (END).............................................. 4 (^C)................................................ 4 (BACKSPACE or ^H).................................. 4 (^U)............................................... 5 (ALT-D)........................................... 5 ..................................................... 5 ................................................. 5 ................................................. 5 (ALT-T)........................................... 5 .................................................... 5 (DOWN arrow).......................................... 5 (CTRL-BACKSPACE)................................. 6 (unassigned)..................................... 6 (PGDN)............................................. 6 (F9).................................................. 6 (HOME)................................................ 6 (F1)........................................... 6 (F2)............................................ 6 (^N)............................................ 6 (^F)............................................... 7 (LEFT arrow).......................................... 7 (^D)............................................... 7 (^P).................................................. 7 (ESC)................................................. 8 (^W)................................................ 8 (^Q)................................................. 8 (CTRL-PGUP).......................................... 8 (^E)............................................... 8 (unassigned)........................................ 10 (ENTER or ^M)..................................... 10 (^V)................................................. 10 (^K)................................................. 10 (^T)............................................... 11 (^L)................................................ 11 (CTRL-PGDN)......................................... 11 (^R).............................................. 11 (^Z)................................................. 12 (^G).................................................. 12 (unassigned)........................................ 12 (CTRL-ENTER or ^J)............................... 12 (unassigned)........................................ 12 (F10)............................................. 12 (^O).............................................. 13 ................................................... 13 (RIGHT arrow)....................................... 13 .................................................. 13 - 22 - Z User's Guide Printed: November 5, 1986 11:52 AM (^S).............................................. 14 (^B).............................................. 14 (^])............................................ 14 (^A).............................................. 15 (TAB or ^I)........................................... 15 (UP arrow)............................................. 15 (^Y)............................................... 15 switches boolean..................................................... 16 askexit (off)............................................. 16 askrtn (on)............................................... 16 autosave (on)............................................. 16 case (off)................................................ 17 enterinsmode (off)........................................ 17 softcr (on)............................................... 17 trailspace (off).......................................... 17 wordwrap (off)............................................ 17 numerical................................................... 15 bgcolor (0)............................................... 15 debug (0)................................................. 15 entab (1)................................................. 15 errcolor (4).............................................. 16 fgcolor (7)............................................... 16 height (23)............................................... 16 hike (4).................................................. 16 hscroll (10).............................................. 16 infcolor (6).............................................. 16 rmargin (72).............................................. 16 stacolor (3).............................................. 16 tabstops (4).............................................. 16 tmpsav (20)............................................... 16 vscroll (7)............................................... 16 textual..................................................... 17 backup (undel)............................................ 17 extmake (none)............................................ 17 markfile (none)........................................... 17 readonly (none)........................................... 17 - 23 - Z User's Guide Printed: November 5, 1986 11:52 AM Revision History 3 November 1986 version 7.43 Create unique file name for temp file. Code and data shrinkage by removing redundant routines. 23 September 1986 version 7.42 Fix fScan from scanning one beyond EOF. Make pBal use setAllScan. Add ability to enter arbitrary characters into , , , and pattern and replacement strings. Preserve tabbing and spaces in non-edited lines. Fix shortname processing from the command line. Fix problem with AdjustLines and deleting at top of file. 19 August 1986 version 7.41 Fix undetected out-of-stack problem introduced in 7.35. 19 August 1986 version 7.40 Fix bug in not highlighting search arguments when using default search from startup. 18 August 1986 version 7.39 Fix bug introduced in 7.26 in . Optimize file loading code. 8 August 1986 version 7.38 Fix bug introduced in 7.36 for reading TOOLS.INI. Fix bug introduced in 7.37 for Z.$ temp file creation. 4 August 1986 version 7.37 Fix problem in using TMP environment variable to locate temporary message file. 1 August 1986 version 7.36 Allow path searching for temp files (Z.MSG, Z.$). Allow path searching of files. Speed up initialization. 7 July 1986 version 7.35 Shrink several VM routines. Better out-of- space messages from VM. Bug fix in textarg copying text from screen. Bug fix in macro redefinition while macros in progress. 6 Jun 1986 version 7.34 Add macros savecur, restcur, curFileNam, curFileExt and editing switches readonly, askrtn, default ALT-T and ALT- D for curtime, curdate. 13 May 1986 version 7.33 Recompiled using C 4.02. 24 April 1986 version 7.32 Change to remove dirty bit after successful save. 10 April 1986 version 7.31 Fix bug that incorrectly updated the screen on line insert/delete at top of single window screen. Add default assignments to , , and . 9 April 1986 version 7.30 When deleting/inserting lines, adjust other window instances to prevent rippling of displays in windows that are not affected by the deletion or insertion. 8 April 1986 version 7.29 Fix problem in Z invocation with no arguments changing directory to the root. - 24 - Z User's Guide Printed: November 5, 1986 11:52 AM 8 April 1986 version 7.28 Renumbered for first public release. 7 April 1986 version 7.27 Add /D switch to prevent user TOOLS.INI processing. Add environment variable searching capability to all filename processing. 3 April 1986 version 7.26 Add file put capability to . Add default time, date, and user macros. 2 April 1986 version 7.25 Add autosave switch. Remove savemeta switch. Fix bug that caused all new files to be NL-terminated. 24 March 1986 version 7.24 Create dir search temp file on device specified by TMP directory. Fixes problem of leaving temp file around in root. 22 March 1986 version 7.23 Preserve LF-ness of files. 14 March 1986 version 7.22 Make successful read first message. 12 March 1986 version 7.21 Replace bakfile switch with backup. 11 March 1986 version 7.20 Clear dialog line after clearing screen after . 11 March 1986 version 7.19 Reset video mode after prompt in . 24 Feb 1986 version 7.18 Change internal page hashing for less clustering of swap pages. Add register optimization in redraw. 23 Feb 1986 version 7.17 Hook ^Break to quickly detect during searches and other time-consumptive operations. Use INT 16h to read from the keyboard. Remove erroneous message if no user TOOLS.INI is present. Saving file under another name changes the internal name too. 18 Feb 1986 version 7.16 Restore/save video mode during . Allow assignment to . 14 Feb 1986 version 7.15 Remove necessity for system-wide TOOLS.INI. Fix problem with DOS MAKE returning pseudo-files in errors. 12 Feb 1986 version 7.14 With bakfile set and saving to a new file, Z was incorrectly reporting that it could not rename the new file to newfile.bak. 30 Jan 1986 version 7.13 Cooking ^@ resulted in a NUL string. 28 Jan 1986 version 7.12 Problems on XENIX with filenames with no name (like .profile). 24 Jan 1986 version 7.11 Fix incorrect scrolling at top of screen and at left of screen. Off-by-1 error. Add message and prompt after successful . - 25 - Z User's Guide Printed: November 5, 1986 11:52 AM 15 Jan 1986 version 7.10 Fix incorrect buffer usage in code that prevented use of streamarg. 13 Jan 1986 version 7.9 If on EGA and height:41 then set EGA into 43- line mode. 10 Jan 1986 version 7.8 Fix bug when final putlflush encounters full disk it did not report the error. 10 Jan 1986 version 7.7 Fix bug in that prevented graphic characters at the end of a macro. 7 Jan 1986 version 7.6 Adjust return code semantics of to allow for generation of a keystroke macro. Added conditional description to document. 6 Jan 1986 version 7.5 PC version no longer requires VT52.SYS. Extmake to control commands. Please send all comments in machine readable form to tools. - 26 -