v07i022: CRISP release 1.9 part 01/32
Brandon S. Allbery - comp.sources.misc
allbery at uunet.UU.NET
Sun Jun 11 07:20:39 AEST 1989
Posting-number: Volume 7, Issue 22
Submitted-by: fox at marlow.UUCP (Paul Fox)
Archive-name: crisp1.9/part02
[My part # is out of step with the Subject: line -- why do people insist on
using a part 0??? ++bsa]
#!/bin/sh
# shar: Shell Archiver (v1.22)
#
# This is part 1 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
#
# Run the following text with /bin/sh to create:
# HLP.README
# help/crisp/Abbrev.hlp
# help/crisp/How.hlp
# help/crisp/Intro.hlp
# help/crisp/Prompt.hlp
# help/crisp/concept/Regexp.hlp
# help/crisp/concept/Buffers.hlp
# help/crisp/concept/Files.hlp
# help/crisp/concept/Windows.hlp
# help/crisp/concept/Blocks.hlp
# help/crisp/concept/Macros.hlp
# help/crisp/concept/Register.hlp
# help/crisp/concept/Proc.hlp
# help/crisp/env/Env.hlp
# help/crisp/env/Tree.hlp
# help/crisp/env/Switches.hlp
# help/crisp/env/Startup.hlp
# help/crisp/env/Kbd.hlp
# help/crisp/features/Compile.hlp
# help/crisp/features/Filename.hlp
# help/crisp/features/Grep.hlp
# help/crisp/features/Options.hlp
# help/crisp/features/Program.hlp
# help/crisp/features/Region.hlp
# help/crisp/features/Buflist.hlp
# help/crisp/features/Spell.hlp
# help/crisp/features/Wc.hlp
# help/crisp/features/Shell.hlp
# help/crisp/features/Abbrev.hlp
# help/crisp/features/AbbFiles.hlp
# help/crisp/features/Ascii.hlp
# help/crisp/features/Calc.hlp
# help/crisp/features/Mail.hlp
# help/crisp/lang/Macros.hlp
# help/crisp/lang/Vars.hlp
# help/crisp/lang/Compiler.hlp
# help/crisp/prim/A.cmd
# help/crisp/prim/B.cmd
# help/crisp/prim/C.cmd
# help/crisp/prim/D.cmd
# help/crisp/prim/E.cmd
# help/crisp/prim/G.cmd
# help/crisp/prim/I.cmd
# help/crisp/prim/M.cmd
# help/crisp/prim/Misc.cmd
# help/crisp/prim/N.cmd
# help/crisp/prim/P.cmd
# help/crisp/prim/R.cmd
# help/crisp/prim/S.cmd
# help/crisp/prim/T.cmd
# help/crisp/prim/U.cmd
# help/crisp/prim/W.cmd
# help/crisp/prim/F.cmd
# help/crisp/prim/O.cmd
# help/crisp/prim/K.cmd
# help/crisp/prim/L.cmd
# help/crisp/prim/V.cmd
# help/crisp/prim/Q.cmd
# help/crisp/roff/page1.mm
# help/crisp/roff/Intro.mm
# help/crisp/roff/Concepts.mm
# help/crisp/roff/Features.mm
# help/crisp/roff/Lang.mm
# help/crisp/roff/Prim.mm
# help/crisp/roff/Env.mm
# help/crisp/roff/Install.mm
# help/crisp/roff/ms.mac
# help/crisp/sections/Arith
# help/crisp/sections/Misc
# help/crisp/sections/Debug
# help/crisp/sections/List
# help/crisp/sections/Kbd
# help/crisp/sections/String
# help/crisp/sections/Buffer
# help/crisp/sections/Macro
# help/crisp/sections/Movement
# help/crisp/sections/Screen
# help/crisp/sections/Env
# help/crisp/sections/Window
# help/crisp/sections/Proc
# help/crisp/sections/Scrap
# help/crisp/sections/Var
# help/crisp/sections/File
# help/crisp/sections/Search
#
if test -r s2_seq_.tmp
then echo "Must unpack archives in sequence!"
next=`cat s2_seq_.tmp`; echo "Please unpack part $next next"
exit 1; fi
echo "x - extracting HLP.README (Text)"
sed 's/^X//' << 'SHAR_EOF' > HLP.README &&
XThis is the README file for the GRIEF Help Files.
X
XThe help files are mostly pure text files which can be accessed
Xvia the <Alt-H> menus available in the MAC_1.* macro package.
XThe macro makeman.m converts these macros to a troff input
Xfile and can be used to print off a copy of the manual.
X
XAlternatively you can modify the macro to try and produce
Xoutput suitable for your own favourite word-processing package.
XThe Help files are in a format that is relatively simple to parse
Xand perform global translations on. Look at makeman.m to see how
Xand what it does.
X
XContext sensitive help is not yet supported and the kbd_help macro
Xis unfinished.
X
XLate News: Macros can now accept C style comments /* */.
X
X===
XFile Version
X============ =======
SHAR_EOF
chmod 0444 HLP.README || echo "restore of HLP.README fails"
mkdir help help/crisp >/dev/null 2>&1
echo "x - extracting help/crisp/Abbrev.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/Abbrev.hlp &&
XAbbreviations are a short-hand way of accessing certain
Xvalue-added features of the CRISP macros.
X
XThere are two types of abbreviation macros - the first
Xlevel abbreviation facility is as a short hand way of
Xtyping in the names of macros, e.g. at the <F10>
X"Command:" prompt; the other use of abbreviations is as
Xa querying mechanism to certain prompts, e.g. the
Xselection of files for the "Edit file:", and "Read
Xfile:" prompts.
X
XThe abbreviations facility is accessed by hitting the
X<Tab> key when prompted on the bottom line of the screen.
X
XIf the prompt is the "Command:" prompt, then the
Xabbreviation facility can be used to select any CRISP
Xbuiltin-macro, or user defined macro. The abbreviations
Xmacro firstly compiles a list of all macros which start
Xwith the prefix entered by the user. If there is only
Xone macro, then the current input is replaced by the
Xfull-name of the abbreviated macro. If there is more
Xthan one unique macro name, then a pop-up window is
Xplaced on the screen, with all the valid abbreviations
Xin alphabetical order. The user can use the normal
Xcursor movement keys to select an option (terminating
Xthe selection with <Enter>), or using <Esc> to abort the
Xselection.
X
XSome macros have different abbreviation facilities. For
Xexample, the following macros provide for file-name
Xabbreviations:
X
X (edit_file)
X (read_file)
X (output_file)
X
XIn this case, if the user hits <Tab> in response to the
Xcommand prompt, then a window containing a list of all
Xfiles in the current directory is popped up. If the user
Xhas already typed in part of a filename, then the
Xfile-name list will be all those files which start with
Xthe characters typed in by the user.
X
SHAR_EOF
chmod 0644 help/crisp/Abbrev.hlp || echo "restore of help/crisp/Abbrev.hlp fails"
mkdir help help/crisp >/dev/null 2>&1
echo "x - extracting help/crisp/How.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/How.hlp &&
XHelp is normally accessible by typing <Alt-H>. When this
Xis typed, a top-level menu is presented allowing the user
Xto select different help options. The help is organised in
Xan attempt to provide access to the different topics of
Xthe help, with a minimal amount of menu hunting.
X
XHelp can also be accessed from any pop-up menu by pressing
X<Alt-H>. Selection menus have help available for each
Xtopic in the menu.
X
XWhen presented with a selection menu (current entry is
Xhighlited, on color terminals this defaults to red
Xbackground with green foreground), the <Up>, <Down>,
X<PgDn>, <PgUp>, <Home>, and <End> keys may be used to move
Xaround the menus.
X
XMenu items may also be selected by typing the first letter
Xof the menu item.
SHAR_EOF
chmod 0644 help/crisp/How.hlp || echo "restore of help/crisp/How.hlp fails"
mkdir help help/crisp >/dev/null 2>&1
echo "x - extracting help/crisp/Intro.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/Intro.hlp &&
XCRISP is an extensible programmers editor which has many
Xfeatures which make the task of editing an enjoyable
Xexperience.
X
XThis section describes how to use the help system.
X
XThe Help subsystem has a number of modes. Help is
Xorganised into a number of different subject areas, and
Xthe top level menus are aimed to make it easy to get
Xhelp on the subjects you are interested in.
X
XThe help system is organised similarly to the printed
Xreference manual - some topics are descriptive in
Xnature, and describe some of the basic concepts and
Xfeatures of CRISP. Other topics are used for quick
Xon-line reference, eg syntax and usage of the macro
Xlanguage primitives.
X
SHAR_EOF
chmod 0644 help/crisp/Intro.hlp || echo "restore of help/crisp/Intro.hlp fails"
mkdir help help/crisp >/dev/null 2>&1
echo "x - extracting help/crisp/Prompt.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/Prompt.hlp &&
XSome commands and macros prompt the user for extra input
Xon the bottom line of the screen. This bottom line is
Xreferred to as the prompt line.
X
XCRISP has a number of features to help in editing the
Xprompt line. Some commands simply prompt for the data,
Xand others supply a default. Default values to prompts
Xare displayed in the highlite color.
X
XCRISP not only supports command line editing, but also
Xsupports command history, ie every time the user types
Xin text to a prompt, the response is saved and can be
Xrecalled by using the <Up> and <Down> keys at subsequent
Xprompts.
X
XCRISP also supports an abbreviations facility. When
Xtyping in a response, if the user hits the <Tab> key,
Xthen CRISP will try to fill in the partially typed word
Xif this represents a unique abbreviation. (See also
XAbbreviations).
X
XWhen typing in at the prompt line, the following
Xcharacters may be used to edit what the user has typed in:
X
X<Backspace> Used to delete previous character.
X
X<End> Move cursor to end of input text.
X
X<Enter> Terminate input.
X
X<Esc> Abort input. CRISP responds with
X 'Command cancelled.' on bottom line of
X screen.
X
X<Home> Move cursor to start of input text.
X
X<Left>, <Right> Allows user to move backwards and forwards
X along current input.
X
X<Ctrl-Left>,
X<Ctrl-Right> Move left and right one word at a time.
X
X<Up>, <Down> Allows user to scroll through previous
X responses to prompt. This is a command
X history mechanism.
X
X<Alt-D>
X<Ctrl-U> Delete all input text.
X
X<Alt-I> Toggle between insert and overtype mode.
X
X<Alt-L> Recalls the last prompt that was typed by
X the user. This is useful if user types
X in a response to the wrong response.
X
X<Alt-Q> Quote next input character. This allows user
X to type things like <Tab> and <Esc> as part
X of the input text.
SHAR_EOF
chmod 0644 help/crisp/Prompt.hlp || echo "restore of help/crisp/Prompt.hlp fails"
mkdir help help/crisp help/crisp/concept >/dev/null 2>&1
echo "x - extracting help/crisp/concept/Regexp.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/concept/Regexp.hlp &&
XThis section describes what a regular expression is, and
Xwhat the syntax is for regular expressions in CRISP.
X
X> What is a Regular Expression
X
XA Regular expression is a term used to describe a string
Xof characters used in pattern matching. Regular
Xexpressions allow certain classes of strings to be
Xmatched, and provide a very flexible way of matching
X'token's.
X
XCRISP provides a variety of features when performing
Xpattern matching:
X
X - literal pattern matching.
X - character class matching
X - wild-card matching
X - grouping
X - alternation
X - repeated expressions
X
XAll of these are described below.
X
X> Syntax of a Regular Expression
X
XA regular expression is a sequence of characters which are
Xcompared against another string, or characters from the
Xcurrent buffer.
X
XMost characters match themselves; some characters are
Xspecial and are used to provide access to the pattern
Xmatching structures mentioned above.
X
XThe special characters are as follows:
X
X <, ^ matches the beginning of a line.
X >, $ matches the end of a line.
X ? matches any single character.
X * matches zero or more characters
X [..] matches any character within the [..]
X | performs alternation.
X \c used to set the cursor after a match.
X @ matches zero or more of the previous expressions.
X + matches one or more of the previous expressions.
X {..} groups a regular expression.
X \x treat x as a normal character.
X
XA regular expression consists of a sequence of one or more
Xsimple expressions. A simple expression (SE) is one of the
Xfollowing:
X
X a sequence of characters
X < or ^
X > or $
X [..]
X ?
X *
X
XA simple regular expression (SRE) is a simple expression,
Xoptionally followed or enclosed in a modifier:
X
X {SE}
X SE@
X SE+
X SE
X
XA regular expression is a sequence of simple regular
Xexpressions as follows:
X
X SRE SRE (Concatenation)
X SRE | SRE (Alternation)
X
X> Precedence of Regular Expression Operators
X
XThe following table gives the precedence of regular
Xexpression operators, with the highest appearing first:
X
X \
X @, +, |, {..}
X <, >, ?, *, [..]
X concatenation
X
XThis means that if you have a regular expression as follows:
X
X cat | dog
X
Xthen this expression matches the pattern 'ca' followed by
Xthe character 't' or 'd', followed by 'og', i.e. it is
Xbracketed as
X
X {ca} {t|d} {og}
X
XTo match the word 'cat' or 'dog', brackets should be used:
X
X {cat} | {dog}
X
X> Character Escaping
X
XThe backslash character may be used to precede any
Xcharacter to turn off any special effects the character
Xhas. For example to match an asterisk in the text, the
Xsequence \* would be used.
X
XA common form of error when writing macros is to forget
Xthat the macro compiler strips off the first level of
Xbackslash characters. For example, if the user wants to
Xmatch an asterisk in a macro, he/she might write:
X
X (search_fwd "\*")
X
XHowever, this is wrong. The macro compiler strips off the
X'\' and leaves the expression as "*" which matches every
Xline. In order to escape this character properly, the
Xfollowing should be used:
X
X (search_fwd "\\*")
X
XIn this case, the macro compiler strips off the first level
X'\' leaving "\*" for the regular expression parser to
Xtranslate.
X
X> Beginning of line operators: < and ^
X
XThese operators match the beginning of a line. For
Xexample, in order to match the word 'dog' only if it
Xappears at the beginning of a line, use:
X
X <dog
X
XIf the '<' is omitted, then the first occurence of 'dog'
Xwill be matched whether it occurs at the beginning of a
Xline or in the middle.
X
XThe operator ^ is provided as a concession to Unix users.
X
X> End of line operators: > and $
X
XThese operators are used to match the end of a line. For
Xexample to match a comma followed by any sequence of white
Xspace at the end of a line, the following can be used:
X
X ,[ \t\n]@>
X
XThis matches a ',' followed by zero or more occurences of
Xspace, tab or newline, followed by the end of line.
X
X> The wild card operators: ? and *
X
XThe '?' operator matches a single character; '*' matches
Xzero or more characters.
X
XThe number of characters matched by a '*' depends on what
Xfollows the '*' and the search mode. (See section on
XSearch Modes).
X
XFor example, the following expression:
X
X cat*dog
X
Xmatches any line which contains the word cat followed by
Xsomewhere else on the line, the word dog.
X
X> Character Class: [..]
X
XThe square bracket operators are used to match one or more
Xcharacters from a class of characters. If the expression
Xis of the form '[..]' then a match is successful if the
Xcharacter being matched is any of the characters within
Xthe square brackets. If the first character after the '['
Xis either a '^' or '~', then the match is successful if
Xthe character is NOT equal to any of the characters in the
Xmatched class.
X
XThe characters within the square brackets form either an
Xenumeration or a range of characters. '[ABC]' is an
Xexample of an enumeration. It matches the single character
X'A', or 'B', or 'C'.
X
X'[a-z]' is an example of a range. It matches any lower
Xcase alphabetic character.
X
XRanges and enumerations may be combined, for example the
Xfollowing may be used to match a C symbol:
X
X [_A-Za-z][_A-Za-z0-9]@
X
Xwhich defines a regular expression expression consisting
Xof a single character of '_', an upper or lower case
Xalphabetic, followed by zero or more characters from the
Xclass '_', A-Z, a-z or 0-9.
X
XSpecial characters may be enclosed in the character class
Xconstruct using the \ syntax. Eg \n matches a new-line; \t
Xmatches a tab.
X
XThe characters -, and ] may be included in the class by
Xpreceding them with a backslash (e.g. \- or \]).
X
X> Repetition: @ and +
X
XThe @ and + are used to indefinitely match a previously
Xspecified pattern. A simple regular expression followed by
X'@' will be matched zero or more times; an SRE followed by
X'+' will be matched one or more times.
X
XFor example, the following regular expression can be used
Xto match a sequence of words followed by a comma (e.g. a
Xsub-phrase of a sentence):
X
X {[A-Za-z]+[ ]+}+,
X
X[A-Za-z]+ matches any word of one or more alphabetic
Xcharacters; the [ ]+ matches one or more spaces between
Xeach word. The final }+ sequence means repeat the previous
Xexpression one or more times.
X
XThe following example shows how to match the last word of
Xone sentence and the first word of the following sentence:
X
X [A-Za-z]+.[ ]@[A-Z]
X
X[A-Za-z]]+ matches the final word in a sentence. The '.'
Xmatches the full-stop after it. The expression [ ]@
Xmatches zero or more spaces which may separate the
Xfull-stop and the first letter of the next sentence.
X
X> Regular Expression Grouping: {..}
X
XThe regular expression grouping characters are used for
Xone of two purposes - alter the precedence in which the
Xregular expression is parsed, and to define groupings of
Xregular expressions for use by the translation mechanism.
X
XBy and large, the regular expressions:
X
X xyz and {xyz}
X
Xare equivalent. The major use is for bracketing in the
Xpresence of the following operators: @, +, and |. For
Xexample:
X
X {hello}@
X {cat}|{dog}
X
XThe other use for the bracket operators is to define a
Xsub-part of a regular expression for use in translation.
XEach occurence of brackets is defined as a grouping. The
Xfirst occurence of {..} is group 1, the next is group 2.
XBy grouping parts of a regular expression, translations
Xcan be made which swap fields around.
X
XFor example, say we have a piece of C code which defines a
Xtable as follows:
X
X "string1", number1,
X "string2", number2,
X ..
X
XIf we need to swap the fields around so that we have the
Xnumbers first on the line, and the strings following them,
Xthen the regular expression search pattern can be defined
Xas:
X
X <[ \t]@{"[^"]@",}[ \t]@{[0-9]+,}
X
XThis breaks down as follows: <[ \t]@ matches the spaces
Xand tabs at the beginning of the line. {"[^"]@",} matches
Xthe string field (quote followed by zero or more non-quote
Xcharacters terminated by a quote and a comma). This is the
Xfirst group. [ \t]@ matches the zero or more spaces or
Xtabs between the columns. {[0-9]+,} is the second grouping
Xand matches the number followed by a comma.
X
XIf the translation replacement pattern (see (translate))
Xis defined as follows:
X
X \t\2\t\1
X
Xthen this effects the field swap. The sequence \N where N
Xis in the range 1-9 means insert the matched group
Xdesignated by N. If N is zero, then the entire matched
Xstring is inserted.
X
X> Minimal and Maximal Matching
X
XAll Unix regular expression parsers use the '*' and '+'
Xoperators to mean repeat the previous expression zero or
Xmore, or one or more times respectively. CRISP uses the
X'@' and '+' operators for the same effect.
X
XHowever, all Unix parsers, when matching repeated groups
Xwill always try to match the longest string. Under Unix,
Xif we have the string:
X
X abbbbbbbc
X
Xand issue the search pattern:
X
X b*
X
Xthen this will match the 7 b's between the 'a' and 'c'. By
Xdefault, CRISP (and BRIEF) perform a shortest match. This
Xmeans that the regular expression:
X
X b@
X
Xwill match only the first 'b' after the 'a'. For pure
Xsearches, the difference hardly ever matters, but when
Xtranslations are performed the different is very
Ximportant. In the above example, using the following
Xtranslation from 'vi' will result in the following string:
X
X s/ab*/X/p
X Xc
X
XThis is what happens with CRISP:
X
X (translate "ab@" "X")
X Xbbbbbbbc
X
XThis is simply because the Unix parsers try to match the
Xlongest string, whereas CRISP tries to match the shortest
Xstring.
X
XCRISP provides the ability to modify this default
Xbehaviour. BRIEF calls this behaviour minimal/maximal
Xmatching and backward matching. BRIEF tries to combine
Xthese concepts without clearly explaining what they are
Xdoing.
X
XCRISP operates in a compatible manner to BRIEF, and so the
Xsame terminology will be adhered to.
X
XThe search macros - search_fwd, search_back, translate,
Xsearch_string and search_list have a parameter, labelled
X're' which is used to control the minimal/maximal
Xmatching. This parameter can have one of seven valid
Xvalues: -3, -2, -1, 0, 1, 2, 3.
X
XThe seven case are as follows:
X
X -3 maximal, backward
X -2 maximal, same as search direction
X -1 maximal, forward
X 0 forward
X 1 minimal, forward
X 2 minimal, same as in search direction
X 3 minimal, backward
X
X0 is used for non-regular expressions. The maximal
Xmatching modes are compatible with Unix.
X
X> Matching Direction
X
XIn the table above, the values show what form of matching
Xis to be performed. BRIEF and CRISP support the concept of
Xa forward and backward matching mechanism. This
Xterminology comes from BRIEF. The terminology is actually
Xnot a very good one.
X
XThe difference between the two mainly comes into effect
Xwhen performing a backward match. Consider the following
Xline:
X
X the cat sat on the mat
X _^
X
Xwith the cursor placed on the 'h' of the first word,
X'the'. In forward matching, if we are searching for the
Xword 'the', then the string 'he cat sat on the mat' will
Xbe searched, and the match will be on the word 'the'
Xbefore 'mat'. In backwards matching mode, the search can
Xstart before the cursor, and will match the word 'the' at
Xthe start of the line.
X
X> Differences between BRIEF and CRISP
X
XBRIEF was developed under DOS and provides a rich set of
Xregular expression operators. However, Unix already has a
Xde facto set of regular expression operators, which are
Xshared among programs, such as 'vi', 'ed', 'awk' and 'sed'.
X
XIt was felt unwise to force a different set of operators
Xonto Unix users. I have tried where possible to support
Xboth sets of operators under Unix, i.e. the ones that BRIEF
Xsupports, and those that are familiar to Unix users.
X
XThe full set of BRIEF operators are supported so that
XBRIEF macros can be run under CRISP with no modification.
XIn some places extensions have been made to the regular
Xexpressions accepted by CRISP to make Unix users more at
Xhome. The following sections describe the differences a
Xregular BRIEF user will see when using CRISP regular
Xexpressions, and the differences a Unix user will see when
Xusing the CRISP regular expressions.
X
X> Differences for BRIEF users
X
XThe following extensions have been added:
X
XThe ^ operator is valid as an alternative to '<' to match
Xthe beginning of a line.
X
XThe sequence [^..] is equivalent to [~..] (matches all
Xcharacters not in the character class).
X
XThe character $ is valid as a match for the end of line
Xcharacter, and is an alternative to '>'.
X
XCRISP cannot perform regular expression matches over line
Xboundaries.
X
X> Differences for Unix users
X
XThe following describes the differences between Unix
Xregular expression syntax and the CRISP regular expression
Xsyntax. If the user has selected Unix regular expression
Xsyntax, then see the next section for further details.
X
XThe character '<' may be used as an alternative to '^' to
Xmatch the beginning of a line.
X
XThe character '>' may be used as an alternative to '$' to
Xmatch the end of line.
X
XThe sequence [~..] is equivalent to [^..] and is used to
Xmatch all characters not in the character class.
X
XUsers of egrep will note that the precedence of '|' is
Xdifferent in CRISP. In egrep the expression 'dog|cat' is
Xbracketed as '{dog}|{cat}'; in CRISP, the implied
Xbracketing is '{do}{g|c}{at}'.
X
XThe \c pattern is available for cursor positioning; this
Xis not available under other Unix regular expression
Xparsers.
X
XUnder Unix, '*' is usually used as a postfix operator to
Xmean one or more occurences of the previous expression, eg
X.* matches zero or more characters. In CRISP, '*' is
Xequivalent to .*, and is an operator in its own right.
X
XThe '?' in CRISP is equivalent to '.' in Unix.
X
XThe operator '@' in CRISP is equivalent to the '*'
Xoperator in other Unix parsers.
X
XOther Unix program bracket regular expressions using the
X\(..\) syntax. CRISP uses '{..}' instead.
X
X> Regular Expression Syntax Mode
X
XCRISP allows the user to select between pure CRISP regular
Xexpression syntax, as described above, or the more
Xfamiliar Unix syntax. This is done by calling the
X(re_syntax) primitive. In CRISP mode, regular expressions
Xare exactly as described in the previous sections of this
Xchapter.
X
XIn Unix mode, the following features are enabled/disabled:
X
XThe '.' character replaces the '?' wild-card character.
X
XThe '*' character means zero or more iterations of the
Xprevious expression. This disables the CRISP '@' zero or
Xmore character.
X
XThe sequence \(..\) replaces the use of {..}. The { and }
Xcharacters become normal characters.
X
SHAR_EOF
chmod 0644 help/crisp/concept/Regexp.hlp || echo "restore of help/crisp/concept/Regexp.hlp fails"
mkdir help help/crisp help/crisp/concept >/dev/null 2>&1
echo "x - extracting help/crisp/concept/Buffers.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/concept/Buffers.hlp &&
XThis section describes what a buffer is and some of the
Xproperties of buffers.
X
X> What is a Buffer ?
X
XA buffer is an object within CRISP used to hold the
Xcontents of files. CRISP supports the dynamic creation of
Xa buffer.
X
XBuffers are like dynamic string arrays. Each line in the
Xbuffer is a variable length string (terminated with a \n
Xcharacter). The buffer grows and contracts as data is put
Xinto the buffer.
X
XBuffers can either be created empty, using the
X(create_buffer) macro, or a file may be placed into the
Xbuffer, (create_buffer) and (edit_file).
X
XA buffer has a number of attributes associated with it:
X
X - buffer name
X - filename
X - contents of buffer
X - permissions
X - status flags
X - current position
X - symbol table.
X - undo information
X
X> The Buffer and File Names
X
XEach buffer is given a name. This name is used to uniquely
Xidentify the buffer. These names usually correspond to the
Xfile names which are also associated with a buffer.
X
XA buffer may have an optional filename associated with it.
XThis file name is usually specified as the result of
Xreading a file into a buffer. The filename is used when
Xsaving the contents of a buffer (via (write_buffer)).
X
X> The Contents of a Buffer
X
XThe buffer contents is an array of lines. Lines are stored
Xinternally as a line header, plus a pointer to the data
Xwithin the line. A buffer can contain arbitrary ASCII
Xcharacters - each line has a length associated with it.
XThe C standard of using a NULL terminator is not used,
Xsince this is too inefficient.
X
XCRISP works best at editing normal ASCII files, but can be
Xused to edit binary files.
X
XEach line in the buffer has a pointer to the next and
Xprevious lines in the buffer, ie the lines in the buffer
Xare stored as a linked list. This structure makes it easy
Xto move from the beginning of the buffer to the end of the
Xbuffer - very little work is involved. Jumping to a line
Xin the middle of the buffer involves more work.
X
XThe line headers and data parts of the line are allocated
Xseparately. The idea here is that line headers are
Xallocated in big chunks, and the data for each line is
Xheld elsewhere in memory. This helps in virtual memory
Xsystems. When walking down the linked list of lines, only
Xthe pages which contain the line headers need be resident
Xin memory. The data stored for each line does not need to
Xbe in memory unless the line is being modified or being
Xdisplayed.
X
XA buffer always contains a place-holding line at the end
Xof the buffer. This line has no data but acts as a place
Xholder for the begin/end markers of the buffer. When an
Xattempt is made to modify this 'pseudo-line', CRISP
Xallocates a new line header. This allows the user to move
Xthe cursor to one line past the end of the buffer and
Xstart typing.
X
XCRISP keeps track of how many lines there are in the
Xbuffer. This allows the percentage marker to be displayed
Xon the status line. (See (echo_line)).
X
X> Permissions
X
XWhen a file is read into a buffer, a note is made of the
Xoriginal protection bits on that file. This is needed so
Xthat when the file is written away, it can give the output
Xfile the same protection bits as the original file. For
Xexample, when editing an executable shell script, the
Xexecute bits are turned on for the modified file.
X
XCRISP understands the concept of a read-only file, e.g. a
Xfile checked out from SCCS via a 'get' command. CRISP does
Xnot allow any editing to be performed on the file.
X
X> Status Flags
X
XCRISP maintains a number of status flags for each buffer,
Xe.g. whether a backup of the file associated with the buffer
Xis to be made when a (write_buffer) is performed, etc.
X
XThese flags can be inquired via the (inq_buffer_flags)
Xmacro.
X
X> Current Position
X
XCRISP maintains two separate cursor for each buffer - the
Xnormal cursor, as displayed on the screen, and a parallel
Xcursor for process buffers. (See the section on Processes).
X
XIf a buffer is not being displayed in a window, then the
Xcursor position changes as a result of text insertions,
Xdeletions, pattern searches, etc. When the buffer is
Xattached to a window, the cursor is copied into the
Xwindows data structure.
X
XThus, each window onto a buffer maintains an independent
Xcursor. This allows different parts of a buffer to be
Xviewed in different windows.
X
XWhen a buffer is detached from a window, the cursor is
Xcopied into the buffers data structure.
X
X> Symbol Tables
X
XCRISP supports the concept of a symbol table associated
Xwith a buffer. These symbols are defined via
X(make_local_variables). These symbols are in scope
Xwhenever the buffer is set to the current buffer. This
Xallows buffer specific state information to be associated
Xwith each buffer.
X
X> Undo Information
X
XIf a buffer is marked as a normal buffer (ie non-system),
Xthen all changes to the buffer are recorded in a file.
XThis allows the (undo) command to function. The (undo)
Xinformation is discarded when the buffer is deleted.
X
XCRISP also supports a (redo) facility. This allows an
X(undo) operation to be undone. The only restriction with
Xredo is that you cannot use redo unless the last operation
Xwas an undo itself.
X
X> System Buffers
X
XSystem buffers are the same as normal buffers, except no
Xundo information is maintained for them. This makes them
Xsignificantly faster at performing operations which modify
Xthe buffer. System buffers are designed for use by macros
X- ie they are not normally directly modifiable by the user.
X
X> The Scrap Buffer
X
XThe scrap buffer is a special buffer used to hold the
Xresult of scrap operations. Internally, it is just like
Xany other buffer, and looks much the same as a system
Xbuffer. However, whenever a (cut), (copy) or (paste)
Xoperation is performed, the data is explicitly taken or
Xput into the scrap buffer.
X
XAlthough the scrap buffer is an internal buffer, you can
Xwatch the contents of this buffer by exploiting a
Xmis-feature of CRISP.
X
XIf you edit the file "/-scrap-//" then CRISP will attach
Xyou to the scrap buffer. If you create another window on
Xthe screen and copy text to the scrap, you will see the
Xscrap window change its contents.
X
SHAR_EOF
chmod 0644 help/crisp/concept/Buffers.hlp || echo "restore of help/crisp/concept/Buffers.hlp fails"
mkdir help help/crisp help/crisp/concept >/dev/null 2>&1
echo "x - extracting help/crisp/concept/Files.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/concept/Files.hlp &&
XThis section describes what files are and how they are
Xmanipulated within CRISP.
X
X> What are Files ?
X
XFiles are used to store long term information. Files may
Xbe edited by CRISP. This is done by reading a file into a
Xbuffer. (See section on Buffers).
X
XOnce a file is read into a buffer, it may be edited using
Xany of the primitives which affect buffers. When a file is
Xread into memory, it is actually part of the address space
Xof CRISP. CRISP does not perform any dynamic paging -
Xinstead it relies on the virtual memory system within the
Xoperating system.
X
XThis is important to bear in mind, since editing a large
Xfile increases the process size of CRISP by an amount
Xproportional to the size of the file.
X
XIn practise, CRISP can always edit a file, and usually
Xdoes a better job of it, than say, vi, which usually
Xlimits the size of files it can edit, based on the number
Xof lines in the file.
X
XCRISP limits the editing of files based on the amount of
Xvirtual memory a process can acquire.
X
XThis makes it much faster to do certain operations on
Xfiles, e.g. global substitutes.
X
XCRISP can edit an arbitrary number of files concurrently,
Xagain limited by virtual memory.
X
X> Text and Binary Files
X
XCRISP knows how to edit binary and text files. For most
Xoperations buffers containing binary and text files are
Xtreated the same, however, the two exceptions are reading
Xa file into a buffer, and writing the file away.
X
XWhen a file is read into a buffer (via (edit_file) or
X(read_file)), CRISP examines the first two bytes of the
Xfile. If either byte is zero (0x00), or has the top bit
Xset, then CRISP assumes that the file must be binary. In
Xthis case CRISP does not treat new-line characters as line
Xterminators, but instead treats them as part of the line
Xof text. CRISP chops the lines in the file into 32 byte
Xchunks, so that you dont end up with a one line buffer
Xpossibly containing tens of thousands of characters.
X
XWhen a buffer containing a binary file is written away,
XCRISP does not insert new-line characters between
Xboundaries, but just writes the lines away as they are
X(possibly including any embedded new-lines in the buffer
Xcontents).
X
XThese two features ensure that a user can edit a binary
Xfile -- although care should be taken not to insert
Xnew-lines into the buffer, since these will be treated as
Xline terminators and ignored when the file is written away.
X
XThe state of a buffer can be tested via the (inq_buffer_flags)
Xprimitive to see if the buffer contains a binary or text file.
X
X> Operations on Files
X
XCRISP contains a number of primitives for manipulating
Xfiles. Files may either be associated with a buffer, or
Xmay be operated on independently of any buffer.
X
XThe buffer-independent file operations are limited to the
Xfollowing:
X
X - check for existence of file
X - delete a file
X - perform directory look up.
X
XA buffer may be created which is associated with a file.
XBuffers are the main editing areas for CRISP. Buffers are
Xlike dynamic arrays of strings, each line is a separate
Xstring, and allows for efficient editing, e.g. inserting and
Xdeleting characters, and for moving blocks of text around,
Xe.g. inserting and deleting entire lines.
X
XBuffers are more completely described in the section on
XBuffers. Buffers have two names associated with them - a
Xbuffer name which is used to uniquely identify each
Xbuffer, and a filename. The buffer name is usually the
Xlast part of the full path name of a file. The association
Xof a file with a buffer is done so that when the buffer is
Xsaved the buffer will be written to the same file that was
Xoriginally read in.
X
X> Backing up a File
X
XCRISP supports automatic backup of files. When a file is
Xedited, (i.e. read into a buffer), a flag is set to say that
Xwhen the file is written away, a copy of the original file
Xshould be saved.
X
XCRISP supports a number of mechanisms for saving these
Xbackup files.
X
XBacking up files are performed for a number of reasons -
Xfirstly so that the user can make a whole load of changes
Xto a file, and if during the editing session the user
Xdecides to abandon the editing, he/she can revert to the
Xoriginal version of the file. Backing up also avoids files
Xbeing lost if CRISP or the system crashes whilst saving a
Xfile.
X
XBacking up files is also useful if users do something
Xstupid, like accidently type something like 'rm * .o' when
Xthey should have typed 'rm *.o'.
X
XCRISP allows the user to turn on or off backup generation.
X(See the (set_backup) macro primitive).
X
XWhen CRISP comes to save a file, it performs the following
Xalgorithm in trying to decide how and where to save the
Xfile:
X
X 1. If the file has multiple links to it, the file
X is copied to the destination directory. (See below).
X If the file has only a single link, then it
X may be link()ed to the destination directory.
X 2. For each directory in the BBACKUP environment
X variable, try to link() the file to the
X specified directory. This operation may fail
X if the directory is on a different file
X system.
X 3. If step 2 fails, then for each directory in
X the BBACKUP environment variable, try and copy
X the file to the resultant directory. This may
X fail because of permissions.
X 4. If steps 2 & 3 fail, try and create a file with
X a .bak extension. If the file has multiple links,
X then the old file is copied to the new file. If the
X file has a single link, then it is link()ed to the .bak
X file.
X
XThe overall aim of the algorithm is to use the link()
Xsystem call to save the old file where possible. This is
Xmuch faster than copying the file block-by-block. By
Xspecifying a directory or directories in a global
Xenvironment variable, then all backup files can be saved
Xin a single directory. This is better than cluttering up
Xdirectories with .bak files. This allows the user to
Xeasily clear away all .bak files with an 'rm *' command,
Xrather than having to issue a
X
X find -name \*.bak -exec rm {} \;
X
XHaving a global backup directory is my preference. CRISP
Xgives you the user, a personal choice as to how you want
Xto do this.
X
XOnce a backup file has been made (as a result of a
X(write_buffer) macro call), no other backups will be made
Xfor that file. This is done so that a user can always go
Xback to the state a file was in when CRISP was entered,
Xnot back to the last (write_buffer) command.
X
X> Autosaving
X
XAutosaving is a mechanism in CRISP which causes all
Xcurrently modified buffers to be written to disk when
XCRISP is idle, so that in the event of a system crash,
Xetc, then an upto date copy of the files can be restored.
X
XCRISP itself does not directly implement autosaving;
Xinstead, it is a macro which is supplied with CRISP. CRISP
Xsupports the mechanism for implementing the autosave
Xfeature. If any user does not like the mechanism, then
Xhe/she can modify the macro to make it do what the user
Xreally wants.
X
XThe existing autosave macro is there because it is useful,
Xand for serious user's, they can use it as a guide for
Xwriting their own.
X
XAutosaving is implemented via the idle timer. The idle
Xtimer is a timer which is maintained by CRISP. The idle
Xtimer goes off when the user hasn't typed anything for 60
Xseconds. (This is configurable via the command line). The
Xautosave macros looks at each non-system buffer, and
Xwrites out the buffer if it has the buffer modified flag
Xset.
X
XThe autosave file is a function of the real file name. If
Xthe file is called foo.c, then the file is saved in a file
Xcalled '@foo.c@'. The use of the '@'s is to make the files
Xstand out when performing a directory listing. The prefix
X'@' is useful since if for some reason CRISP doesnt delete
Xthe autosaved files, then it is easier and safer to issue
Xan 'rm @*' command than an individual rm for each file.
XThe trailing '@' is added on so that if the user issues a
Xcommand such as:
X
X ls *.c
X
Xthen the autosaved files dont get included in the list.
XThe major objective here is to avoid sticking on a long
Xsuffix (e.g. .asv) to a file name on systems such as V.3
XUnix, which only have 14 character file names anyway).
XAdding suffixes to a filename is a dangerous game since
Xthe original filename may already be at the 14-character
Xfilename limit, and the suffix would get ignored. Having a
Xprefix and suffix seems to be the best of both worlds.
X
XAny autosaved files should be deleted when CRISP exits.
X
XWhen the autosave macro runs, it prints the message
X'Autosaving...' followed by 'Autosave complete.' when it
Xhas finished.
X
X> Editing Binary Files
X
XCRISP supports the ability to edit binary files. Binary
Xfiles may be treated as a normal ASCII file. CRISP makes a
Xreasonable attempt to display binary characters on the
Xscreen. On displays which support the ability to display
Xcharacters with the top bit set, CRISP will use this. On
Xdisplays which cannot distinguish these characters, CRISP
Xwill display the characters in octal or hexadecimal. (See
X(display_mode)).
X
SHAR_EOF
chmod 0644 help/crisp/concept/Files.hlp || echo "restore of help/crisp/concept/Files.hlp fails"
mkdir help help/crisp help/crisp/concept >/dev/null 2>&1
echo "x - extracting help/crisp/concept/Windows.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/concept/Windows.hlp &&
XThis section describes what a window is and how they are
Xused.
X
X> What is a Window ?
X
XA window is an area of the screen, through which part of a
Xbuffer may be viewed. All windows on screen have a buffer
X'attached' to them.
X
XWindows are very useful for viewing more than one file at
Xthe same time, or different parts of the same file.
X
XWindows and buffers are separate entities. Various macro
Xprimitives allow buffers to be mapped to various windows.
XA window can never be displayed on its own, it must always
Xbe attached to a buffer, otherwise CRISP gets confused.
X
XA buffer may be attached to more than one window, in which
Xcase each window can be set up to view a different part of
Xthe buffer.
X
X> Tiling and Overlapped Windows
X
XCRISP supports two forms of windows - tiled and
Xoverlapping. Tiled windows are windows which do not
Xoverlap or obscure each other. Initially CRISP starts up
Xwith a single window which occupies the whole of the screen.
X
XThis window can be split horizontally or vertically, thus
Xat all times the entire screen contains a window mapping a
Xbuffer.
X
XOverlapped windows are usually used in a pop-up mode, e.g.
Xthe buffer list macros pops up a window onto the screen
Xwhich obscures any windows sitting behind it. When the
Xmacro has terminated the window is destroyed and the
Xwindows behind it are refreshed.
X
X> Cursor Positioning
X
XEach window maintains an independent cursor onto the
Xbuffer below it. Any changes to a buffer made in one
Xwindow are displayed in the other windows displaying the
Xsame part of the same buffer.
X
SHAR_EOF
chmod 0644 help/crisp/concept/Windows.hlp || echo "restore of help/crisp/concept/Windows.hlp fails"
mkdir help help/crisp help/crisp/concept >/dev/null 2>&1
echo "x - extracting help/crisp/concept/Blocks.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/concept/Blocks.hlp &&
XThis section describes blocks (otherwise referred to as
Xregions and anchors). It also discusses the scrap, and the
Xtypes of anchors.
X
X> What is a Block/Region ?
X
XA block, or region, is a marked area of a buffer. This
Xmarked area is highlited when it is displayed on the
Xscreen so that the user can easily see exactly what has
Xbeen marked.
X
XThis following summarises the operations that may be
Xperformed on a block:
X
X - it may be copied to the scrap.
X - it may be deleted.
X - it may be written out to a file.
X - it may be indented.
X - it may be formatted.
X
XCRISP supports a number of basic operations which may be
Xperformed on blocks. The other functions are higher level
Xmacros which are built from these primitives.
X
X> Types of Regions
X
XThere are four types of regions:
X
X - non-inclusive
X - inclusive
X - line
X - column
X
X> Inclusive and Non-inclusive Region
X
XInclusive and non-inclusive regions are similar, except
Xfor non-inclusive regions, the character under the cursor
Xis not considered to be part of the marked region. The
Xeffect of this is illustrated by the following.
X
XConsider a buffer with two lines in it:
X
X This is line one.
X And this line two.
X
XFor an inclusive region, if the cursor starts out on the
X'T' and is moved down a line, then the whole of the first
Xline is highlited as well as the 'A' at the beginning of
Xthe second line. For a non-inclusive region, the region is
Xhighlited the same, except the 'A' is not highlited as
Xwell. If the inclusive region is deleted then whole of the
Xfirst line will disappear as well as the 'A' at the start
Xof the second line. For the non-inclusive region, only the
Xfirst line will be deleted.
X
X> Column Regions
X
XA column region is treated internally the same as an
Xinclusive region, except the display code knows only to
Xhilite a rectangular block of the buffer. (cut)-ing or
X(copy)-ing the column mark will be treated the same as if
Xit were an inclusive mark.
X
XColumn regions are provided for manipulating rectangular
Xregions of the buffer. The only currently supported high
Xlevel macro for use with column regions is column-delete.
XSupport for the other types will be included in a later
Xrelease.
X
X> Line Regions
X
XLine regions are used to select the entirety of a line
Xirrespective of where the cursor is on the line. Line
Xregions are very useful for moving entire lines of text.
XUsing the inclusive or non-inclusive regions is very
Xfiddly when copying lines since the cursor has to be in
Xthe correct position for (cut), (copy) and (paste) to have
Xthe desired effect.
X
SHAR_EOF
chmod 0644 help/crisp/concept/Blocks.hlp || echo "restore of help/crisp/concept/Blocks.hlp fails"
mkdir help help/crisp help/crisp/concept >/dev/null 2>&1
echo "x - extracting help/crisp/concept/Macros.hlp (Text)"
sed 's/^X//' << 'SHAR_EOF' > help/crisp/concept/Macros.hlp &&
XThis section describes what a macro is and how they are
Xused.
X
X> What is a Macro ?
X
XA macro is a sequence of instructions which performs a
Xhigh-level function. Different people have different ideas
Xabout what a programming editor should look like. Some
Xpeople want simple options, others need complicated macros
Xwhich can perform tasks as complicated as sort the
Xfunctions in a .c file into alphabetical order.
X
XCRISP is designed to allow it to be easy to customise the
Xediting tasks that a user wants, no matter how complicated
Xthe editing facility required.
X
XRather than complicate CRISP internally with hard to
Xchange ideas about what facilities should be available,
XCRISP provides a set of builtin primitives which
Xmanipulate the objects CRISP knows about, e.g. files,
Xbuffer, windows, etc.
X
XCRISP has a programming language which allows users to
Xcombine these primitives into more complex functions.
X
XFor example, CRISP provides a set of functions to search
Xthe current buffer for a string. One of the high level
Xmacros provided with CRISP matches braces, i.e. it checks
Xthat there are an equal number of opening and closing
Xbrackets. This is an example of a macro. The macro is
Xbuilt from the primitives which CRISP has compiled into
Xits code.
X
XIf you do not like the way these macros are written, then
Xyou may easily customise them.
X
X> Tools for Writing Macros
X
XCRISP provides a number of facilities to aid in writing
Xand debugging your own macros. These include a compiler
Xwhich optimises the layout of the code so that CRISP can
Xthen execute the macro as efficiently as possible.
X
XMacros are usually stored in files, and commonly have a
X'.m' extension so that their purpose stands out.
X
XCRISP comes with a macro compiler, called 'cm'. cm is used
Xto compile the macros to a more compact internal format.
XThis format allows CRISP to load the entire file in one
SHAR_EOF
echo "End of part 1"
echo "File help/crisp/concept/Macros.hlp is continued in part 2"
echo "2" > s2_seq_.tmp
exit 0
--
===================== Reuters Ltd PLC,
Tel: +44 628 891313 x. 212 Westthorpe House,
UUCP: fox%marlow.uucp at idec.stc.co.uk Little Marlow,
Bucks, England SL7 3RQ
More information about the Comp.sources.misc
mailing list