Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Redistributions of source code and documentation must retain the above
copyright notice, this list of conditions and the following
disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed or owned by Caldera
International, Inc. Neither the name of Caldera International, Inc.
nor the names of other contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@(#)m2 8.1 (Berkeley) 8/14/93
.tr |
.mh Line Length and Indenting .pg The maximum line length for fill mode may be set with ll. The indent may be set with in; an indent applicable to only the next output line may be set with ti. The line length includes indent space but not page offset space. The line-length minus the indent is the basis for centering with ce. The effect of ll, in, or ti is delayed, if a partially collected line exists, until after that line is output. In fill mode the length of text on an output line is less than or equal to the line length minus the indent. The current line length and indent are available in registers .l and .i respectively. The length of three-part titles produced by tl (see \(sc14) is independently set by lt. .h1 .bt &ll|\(+-N 6.5\|in previous E,m Line length is set to \(+-N. In \*(TR the maximum (line-length)+(page-offset) is about 7.54 inches. .bt &in|\(+-N N\(eq\^0 previous B,E,m Indent is set to \(+-N. The indent is prepended to each output line. .bt &ti|\(+-N - ignored B,E,m Temporary indent. The next output text line will be indented a distance \(+-N with respect to the current indent. The resulting total indent may not be negative. The current indent is not changed. .mh Macros, Strings, Diversion, and Position Traps .sc Macros and strings. A macro is a named set of arbitrary lines that may be invoked by name or with a trap. A string is a named string of characters, not including a newline character, that may be interpolated by name at any point. Request, macro, and string names share the same name list. Macro and string names may be one or two characters long and may usurp previously defined request, macro, or string names. Any of these entities may be renamed with rn or removed with rm. Macros are created by de and di, and appended to by am and da; di and da cause normal output to be stored in a macro. Strings are created by ds and appended to by as. A macro is invoked in the same way as a request; a control line beginning .xx will interpolate the contents of macro xx. The remainder of the line may contain up to nine arguments. The strings x and xx are interpolated at any desired point with \e\(**x and \e\(**(xx respectively. String references and macro invocations may be nested. .sc Copy mode input interpretation. During the definition and extension of strings and macros (not by diversion) the input is read in copy mode. The input is copied without interpretation except that: .x1 \(bu The contents of number registers indicated by \en are interpolated. \(bu Strings indicated by \e\(** are interpolated. \(bu Arguments indicated by \e$ are interpolated. \(bu Concealed newlines indicated by \e(newline) are eliminated. \(bu Comments indicated by \e" are eliminated. \(bu \et and \ea are interpreted as \s-1ASCII\s+1 horizontal tab and \s-1SOH\s+1 respectively (\(sc9). \(bu \e\e is interpreted as \e. \(bu \e. is interpreted as ".". .x2 These interpretations can be suppressed by prepending a \e. For example, since \e\e maps into a \e, \e\en will copy as \en which will be interpreted as a number register indicator when the macro or string is reread. .sc Arguments. When a macro is invoked by name, the remainder of the line is taken to contain up to nine arguments. The argument separator is the space character, and arguments may be surrounded by double-quotes to permit imbedded space characters. Pairs of double-quotes may be imbedded in double-quoted arguments to represent a single double-quote. If the desired arguments won't fit on a line, a concealed newline may be used to continue on the next line. .pg When a macro is invoked the input level is pushed down and any arguments available at the previous level become unavailable until the macro is completely read and the previous level is restored. A macro's own arguments can be interpolated at any point within the macro with \e$N, which interpolates the N\^th argument (1\(<=N\^\(<=9). If an invoked argument doesn't exist, a null string results. For example, the macro xx may be defined by .x1 &de xx \e"begin definition Today is \e\e$1 the \e\e$2. &. \e"end definition .x2 and called by .x1 &xx Monday 14th .x2 to produce the text .x1 Today is Monday the 14th. .x2 Note that the \e$ was concealed in the definition with a prepended \e. The number of currently available arguments is in the .$ register. .pg No arguments are available at the top (non-macro) level in this implementation. Because string referencing is implemented as an input-level push down, no arguments are available from within a string. No arguments are available within a trap-invoked macro. .pg Arguments are copied in copy mode onto a stack where they are available for reference. The mechanism does not allow an argument to contain a direct reference to a long string (interpolated at copy time) and it is advisable to conceal string references (with an extra \e\|) to delay interpolation until argument reference time. .sc Diversions. Processed output may be diverted into a macro for purposes such as footnote processing (see Tutorial \(scT5) or determining the horizontal and vertical size of some text for conditional changing of pages or columns. A single diversion trap may be set at a specified vertical position. The number registers dn and dl respectively contain the vertical and horizontal size of the most recently ended diversion. Processed text that is diverted into a macro retains the vertical size of each of its lines when reread in nofill mode regardless of the current V. Constant-spaced (cs) or emboldened (bd) text that is diverted can be reread correctly only if these modes are again or still in effect at reread time. One way to do this is to imbed in the diversion the appropriate cs or bd requests with the transparent mechanism described in \(sc10.6. .pg Diversions may be nested and certain parameters and registers are associated with the current diversion level (the top non-diversion level may be thought of as the 0th diversion level). These are the diversion trap and associated macro, no-space mode, the internally-saved marked place (see mk and rt), the current vertical place (.d register), the current high-water text base-line (.h register), and the current diversion name (.z register). .sc Traps. Three types of trap mechanisms are available\(empage traps, a diversion trap, and an input-line-count trap. Macro-invocation traps may be planted using wh at any page position including the top. This trap position may be changed using ch. Trap positions at or below the bottom of the page have no effect unless or until moved to within the page or rendered effective by an increase in page length. Two traps may be planted at the same position only by first planting them at different positions and then moving one of the traps; the first planted trap will conceal the second unless and until the first one is moved (see Tutorial Examples \(scT5). If the first one is moved back, it again conceals the second trap. The macro associated with a page trap is automatically invoked when a line of text is output whose vertical size reaches or sweeps past the trap position. Reaching the bottom of a page springs the top-of-page trap, if any, provided there is a next page. The distance to the next trap position is available in the .t register; if there are no traps between the current position and the bottom of the page, the distance returned is the distance to the page bottom. .pg A macro-invocation trap effective in the current diversion may be planted using dt. The .t register works in a diversion; if there is no subsequent trap a large distance is returned. For a description of input-line-count traps, see the it request below. .h1 .bt &de|xx|yy - .yy=.. - Define or redefine the macro xx. The contents of the macro begin on the next input line. Input lines are copied in copy mode until the definition is terminated by a line beginning with .yy, whereupon the macro yy is called. In the absence of yy, the definition is terminated by a line beginning with "..". A macro may contain de requests provided the terminating macros differ or the contained definition terminator is concealed. ".." can be concealed as \e\e.. which will copy as \e.. and be reread as "..". .bt &am|xx|yy - .yy=.. - Append to macro (append version of de). .bt &ds|xx|string - ignored - Define a string xx containing string. Any initial double-quote in string is stripped off to permit initial blanks. .bt &as|xx|string - ignored - Append string to string xx (append version of ds). .bt &rm|xx - ignored - Remove request, macro, or string. The name xx is removed from the name list and any related storage space is freed. Subsequent references will have no effect. .bt &rn|xx|yy - ignored - Rename request, macro, or string xx to yy. If yy exists, it is first removed. .bt &di|xx - end D Divert output to macro xx. Normal text processing occurs during diversion except that page offsetting is not done. The diversion ends when the request di or da is encountered without an argument; extraneous requests of this type should not appear when nested diversions are being used. .bt &da|xx - end D Divert, appending to xx (append version of di). .bt &wh|N|xx - - v Install a trap to invoke xx at page position N; a negative N will be interpreted with respect to the page bottom. Any macro previously planted at N is replaced by xx. A zero N refers to the top of a page. In the absence of xx, the first found trap at N, if any, is removed. .bt &ch|xx|N - - v Change the trap position for macro xx to be N. In the absence of N, the trap, if any, is removed. .bt &dt|N|xx - off D,v Install a diversion trap at position N in the current diversion to invoke macro xx. Another dt will redefine the diversion trap. If no arguments are given, the diversion trap is removed. .bt &it|N|xx - off E Set an input-line-count trap to invoke the macro xx after N lines of text input have been read (control or request lines don't count). The text may be in-line text or text interpolated by inline or trap-invoked macros. .bt &em|xx none none - The macro xx will be invoked when all input has ended. The effect is the same as if the contents of xx had been at the end of the last file processed. .mh Number Registers .pg A variety of parameters are available to the user as predefined, named number registers (see Summary and Index, page 7). In addition, the user may define his own named registers. Register names are one or two characters long and do not conflict with request, macro, or string names. Except for certain predefined read-only registers, a number register can be read, written, automatically incremented or decremented, and interpolated into the input in a variety of formats. One common use of user-defined registers is to automatically number sections, paragraphs, lines, etc. A number register may be used any time numerical input is expected or desired and may be used in numerical expressions (\(sc1.4). .pg Number registers are created and modified using nr, which specifies the name, numerical value, and the auto-increment size. Registers are also modified, if accessed with an auto-incrementing sequence. If the registers x and xx both contain N and have the auto-increment size M, the following access sequences have the effect shown:
Effect on Value |
Sequence Register Interpolated |
\enx none N |
\en(xx none N |
\en+x x incremented by M N+M |
\en-x x decremented by M N-M |
\en+(xx xx incremented by M N+M |
\en-(xx xx decremented by M N-M |
Numbering |
Format Sequence |
1 0,1,2,3,4,5,... |
001 000,001,002,003,004,005,... |
i 0,i,ii,iii,iv,v,... |
I 0,I,II,III,IV,V,... |
a 0,a,b,c,...,z,aa,ab,...,zz,aaa,... |
A 0,A,B,C,...,Z,AA,AB,...,ZZ,AAA,... |