7. DISPLAY MODES
A "display mode" consists primarily of an algorithm that elvis uses
internally to convert the bytes in a buffer into an image in a window.
The same algorithm is also used for printing via the ":lpr" command.
The display mode also affects tag lookup, and
image-dependent operations such as
determining the column number of the cursor's location, and
moving the cursor vertically.
You can list the supported display modes by giving the
":display" command without any arguments.
Typically, the supported modes will include the following:
.--------.----------------------------------------------.
| MODE | DESCRIPTION |
|--------|----------------------------------------------|
| normal | Traditional vi, displays plain ASCII |
| syntax | Like "normal" but does syntax coloring |
| hex | Interactive hex dump, good for binary files |
| html | Simple Web page formatter |
| man | Simple Man page formatter, like "nroff -man" |
| tex | Simple subset of the TeX formatter |
^--------^----------------------------------------------^
Elvis 2.1 allows each window to be in a different display mode.
You can manually change a window's display mode via the
":display mode" command, where
mode is the name of a supported display mode.
There is also a ":no" command,
which is short for ":display normal".
7.1 Options
There are two options which pertain to display modes:
display and
bufdisplay.
The display option is associated with a window.
It always contains the name of the window's current display mode.
You aren't allowed to change the value of this option directly;
you must use the ":display mode" command to change the display mode.
This option exists solely so that you can write EX scripts which behave
differently, depending on the display mode.
The bufdisplay option is associated with a buffer.
It should be set to the name of the usual display mode for that buffer.
Typically this option will be set from the
elvis.arf initialization file,
based on the name of the file like this:
let e=tolower(dirext(filename))
if knownsyntax(filename)
then set! bufdisplay=syntax
else if os=="unix" && buflines >= 1
then 1s/^#! *[^ ]*\/\([^ ]\+\).*/set! bufdisplay="syntax \1"/x
if e<<4==".htm"
then set! bufdisplay=html
if e==".man" || e==".1"
then set! bufdisplay=man
if binary
then set! bufdisplay=hex
When a new window is created for that buffer, or
an existing window switches to that buffer,
that window's display mode will automatically be switched to the
bufdisplay mode.
The bufdisplay mode also affects the ^Wd
visual command.
This command toggles the window between the normal mode and the
bufdisplay mode.
If bufdisplay is also set to "normal", then ^Wd will toggle between
the normal and hex display modes.
7.2 Normal mode
The "normal" display mode looks like a traditional vi screen.
All characters are displayed literally except for the following...
- Tab
- The tab character is displayed as a variable number of spaces --
however many are needed to move to the next tabstop position.
- Newline
- The newline character (linefeed) marks the end of a line.
- Other control characters
- Control characters other than tab and newline are displayed as a caret
and a printable ASCII character.
For example Control-A is displayed as ^A, and NUL is displayed as ^@.
The delete character is displayed as ^?.
- Non-ASCII characters
- The appearance of non-ASCII characters (i.e., characters 128-255) is
controlled by the nonascii option.
By default, most non-ASCII characters are assumed to be ordinary printable
characters.
7.3 Syntax mode
The "syntax" display mode acts exactly like the normal mode, except that this
mode automatically uses different fonts for various types of tokens in any
supported programming language.
You can then use the :color command to
assign colors for each font.
7.3.1 Options
The following options determine which font is used for each type of token:
.---------------------.----------^-------------------------------------.
| OPTION NAMES | DEFAULT | AFFECTED TOKEN TYPE |
|---------------------|----------^-------------------------------------|
| commentfont, cfont | italic | comments |
| stringfont, sfont | fixed | string, character, & regexp literals|
| prepfont, pfont |emphasized| preprocessor directives |
| keywordfont, kfont | bold | keywords |
| functionfont, ffont | normal | identifier followed by function char|
| otherfont, ofont | bold | other special words |
| variablefont, vfont | normal | variables, fields, etc. |
^---------------------^----------^-------------------------------------^
Each of those options can be set to one of normal, bold, italic,
underlined, emphasized, or fixed.
When typing these values into a :set
command line, you are only required to type the initial letter
(n, b, i, u, e or f).
Any text that doesn't fall into one of the above groups (punctuation, mostly)
is displayed in the normal font.
There is no option that controls this; it is hard coded.
You can use the :color command to choose a
color for each font, if you wish.
Not all user interfaces support color, but the "x11" and "termcap" interfaces
do.
7.3.2 Language specification
All supported languages are described in a file named "elvis.syn".
Each time a window switches to the "syntax" display mode,
elvis scans this file for a description of the language.
If it can't find a description of the language, then nothing will be
displayed in a different font;
"syntax" mode will look exactly like "normal" mode.
The "elvis.syn" file is a text file.
In it, blank lines and lines which start with a '#' are ignored.
Other lines begin with the name of an attribute;
the remaining words in the line are values for that attribute.
Each language's description begins with an attribute named "language".
The following lines (up to the next "language" line or the end of the file)
describe that language.
The attributes names are:
- language
- This word is followed by a whitespace-delimited list of language names.
The names are case-sensitive, so you should probably give all names in
lowercase so they're easier for the user to type in.
The user can indicate which language to use by appending its name to
the name of the "syntax" display mode.
For example, ":display syntax c++" causes elvis to highlight the text
appropriately for C++.
- extension
- This word is followed by the filename extensions which are commonly used
for this language.
If the user doesn't specify which language to load, then elvis scans through
"elvis.syn" for an extension line which matches the current file name.
The extension lines must come immediately after the language line.
NOTE: This is case sensitive! If the file name extension
will often be used on case-insensitive file systems (e.g., most Microsoft)
then you'll probably want to give both uppercase and lowercase versions of
the extension. For example, the description of Microsoft batch file syntax
includes "extension .bat .BAT".
- keyword
- This word is followed by a list of words which should be shown in the
keywordfont font.
If omitted, then no words are shown in the keywordfont.
Long lists can be split into several keyword lines, if you wish.
Elvis doesn't care about the order of the words, but the list will be
easier to maintain if you keep it alphabetized.
Elvis supports three forms of keywords...
- Most keywords begin with an alphanumeric character or a character in the
startword list, and continue with zero or more
characters which are alphanumeric or in the inword
list.
- The same startword/inword
type of keywords can be made somewhat context sensitive by appending a single
character which does not appear in the inword. The
keyword will only be recognized when it is immediately followed by that
character. The HTML syntax highlighting uses this feature to display parameters
in a distinctive font.
- Rarely, you may find it convenient to have keywords which consist of
one or two punctuation characters, but which don't match the first form
of keywords.
This is mostly so that Perl's
$# variable won't be displayed as a
simple dollar sign followed by a comment.
You can list the same keyword in multiple lines (once each in
a keyword line,
a font line,
an anchor line, and
a comment line)
to specify the various attributes of each keyword.
You don't need to list it in a keyword line first;
you can introduce new keywords in any of these four line types.
- font
- This word can be used to cause certain keywords to be displayed in
some font other than the keywordfont.
The first word after
font should be the name of the font
(normal, fixed, bold, emphasized, italic, or underlined) or a one-letter
abbreviation of a font name.
The line's remaining words are keywords which will be displayed in that font.
- anchor
- This offers a way to restrict certain keywords, so they will only be
recognized as such if they occur in a particular column. The first word
after "anchor" is a column number -- 1 for the leftmost column, 9 for the
first tabstop, and so on.
You can also use ^ instead of a number to indicate that the keyword
can only appear after whitespace at the front of a line.
The remainder of the "anchor" line is the list
of keywords which are only special when they occur in that column.
- comment
- This word is followed by a keyword which marks the beginning of a comment.
The comment is assumed to end at the end of the line.
Comments are normally shown in the
commentfont font, but if you've
overridden the keyword's font via a font line in
elvis.syn, then the whole comment will be displayed in that font
instead.
You can define multiple comment keywords, and assign different fonts to
them if you wish.
The comment word can also be followed by a pair
of one- or two-character
sequences which mark the beginning and end of comments which can include
newlines.
Elvis only supports one multi-line comment style for each language, and it
will always be displayed in the
commentfont font.
- operator
- This word is followed by a keyword which the language uses as a prefix
for operators, and then by a list of characters which can appear in the
operator itself. This affects the ^] visual
command for tag searches. As far as I know, the only language that uses this
is C++, where it is specified like this:
operator operator ~!%^&*+|-=[]<>/
- preprocessor
- This word is followed by a single character which, when used at the
beginning of a line, marks the start of a preprocessor directive.
For C, this is the # character.
All preprocessor directives will then be shown in the
prepfont font.
If omitted, nothing is displayed in the prepfont.
- prepquote
- This word is followed by a single character, or a pair of single characters,
which are used as the quote characters surrounding a file name in a preprocessor
directive.
For C, this is the < and > characters.
The name of the included file will then be displayed using the
stringfont font.
If omitted, then preprocessor file names will be highlighted as though they were
arithmetic expressions.
- function
- This word is followed by a single character which, if it appears
after a word, indicates that the word should be displayed in
the functionfont font.
For most languages, this will be a ( character.
If omitted, nothing is displayed in the functionfont.
- startword
inword
- These can be followed by a list of punctuation characters which
may appear at the start of a word, or in the remainder of the word,
respectively.
Letters and digits are always legal in words; you don't need to list them.
- other
- This word indicates which types of words should be displayed in the
otherfont font.
If omitted, nothing is displayed in the otherfont.
It can be any combination of the following symbols:
.-------------.-------------------------------------------------.
| SYMBOL | HOW TO RECOGNIZE "OTHER" WORDS |
|-------------|-------------------------------------------------|
| allcaps | length >= 2 chars, no lowercase characters |
| initialcaps | 1st character is uppercase, some are lowercase |
| initialpunct| 1st character is punctuation, from "startword" |
| mixedcaps | 1st character is lowercase, some are uppercase |
| final_t | length >= 3 chars, ends with "_t" |
^-------------^-------------------------------------------------^
- string
- This word is followed by a single character,
or a pair of single characters,
which are used as the quote characters surrounding string literals.
For C, this is the " character.
String literals will then be displayed using the
stringfont font.
If omitted, then strings will not be recognized.
- strnewline
- This is followed by backslash, allowed, indent, or
empty to indicate how strings can be continued across lines.
The default is backslash which indicates a C-style backslash
is required to quote the newline characters (which C will then exclude from
the string, but elvis doesn't care about that).
The other values all indicate that a backslash is not needed, and also give
some hints that help elvis detect whether the top of the screen is inside
a multi-line string.
Specifically, the indent value means that indented lines
are rarely a continuation of a string,
empty means that empty lines are probably not part of a string,
and allowed makes no promises.
The allowed value would be too slow if strings' opening and
closing quotes are identical (e.g., if the " character appears at both ends
of a string); in this situation, elvis uses empty instead.
Note that the hints are only used for detecting whether the first line
starts in a multi-line string.
When drawing text after that,
elvis treats all non-backslash values identically.
- character
- This word is followed by a single character, or a pair of single characters, which are used as the quote
characters surrounding character literals.
For C, this is the ' character.
This is shown using the
stringfont font, like strings.
When parsing, the only difference between the two is that characters can't
span lines, but strings can.
- regexp
- This word is followed by a list of characters which can be used
for delimiting a regular expression,
which some languages support as a means for specifying strings with
metacharacters.
(See Section 5 of this manual for a description of
elvis' own implementation of regular expressions, which is a typical example.)
Regular expressions are displayed using the
stringfont font.
Note that regexp accepts a list of characters, while
string and character support only a single character.
This is because many programming languages allow the programmer to choose
from a variety of delimiting characters.
- useregexp
- The most commonly used delimiter for regular expressions is '/',
which many languages also use as the division operator.
To avoid mistakenly displaying the division operator as the start of a
regular expression, elvis must be sensitive to the context in which it
is used.
That's what this word is for.
The
useregexp word is followed by a list of
keywords and/or punctuation characters which allow the
next character to be recognized as a regular expression.
Additionally, regular expressions are allowed at the start of a line.
- useregsub
- This is used for listing keywords and punctuation
characters which may be followed by a regular expression
and then substitution text.
- ignorecase
- This word should be followed by true or false.
If true, then elvis won't distinguish between uppercase and
lowercase letters when testing whether a word is a keyword
(except that in the elvis.syn file, the keywords should be listed in lowercase).
If omitted, elvis assumes it should be false.
7.3.3 Example
The elvis.syn file shipped with elvis contains some
good examples of language descriptions.
Here's an excerpt from it, describing the Java language.
language java
extension .java .jav
keyword abstract boolean break byte byvalue case cast catch char
keyword class const continue default do double else extends false
keyword final finally float for future generic goto if implements
keyword import inner instanceof int interface long native new null
keyword operator outer package private protected public rest return
keyword short static super switch synchronized this throw throws
keyword transient true try var void volatile while
comment //
comment /* */
function (
string "
character '
startword _
inword _
other allcaps initialcaps
There is no preprocessor line, because java doesn't use a preprocessor.
The "allcaps" and "initialcaps" symbols are given so that constants and class
names will be shown in the otherfont.
7.4 Hex mode
The "hex" display mode is an interactive hex dump of the buffer.
This is good for examining or editing binary files.
One handy feature is the ability to enter characters in hex
(either in input mode or as the argument to an
r visual command)
by typing ^X followed by two hex digits.
This feature is always available regardless of the display mode...
but this is where is it most useful.
7.5 HTML mode
HTML is the language used for constructing pages on the World Wide Web.
Elvis' "html" display mode supports a subset of HTML, which it uses for
displaying the online help documentation (including this very document).
HTML is a markup language.
This means that documents contain a mixture of text and formatting instructions.
In HTML there are two types of instructions, called tags
and entities.
When the document is processed by a program such as Netscape or elvis (in
html mode), the tags are stripped out, the entities are converted to
a kind of text, and the text is formatted and presented to the user.
Ordinarily the user will never see the tags.
Since elvis is primarily an editor, not a viewer, it has two options which
allow the tags to become visible:
the showmarkups option causes a tag to become
visible if the cursor is moved onto it, and
the list option makes all tags visible
regardless of the cursor position.
There are a lot of good "How To Use HTML" documents on the Net.
This is not one of them!
I don't intend to do much more than describe the quirks of elvis'
implementation of HTML here.
I added HTML support to elvis mostly to support the online help.
Consequently, if a feature is hard to implement and the online documentation
doesn't use it, then I didn't implement that feature.
If you intend to use elvis as a browser, then I suggest you read the
appropriate section in the Tip chapter.
7.5.1 Formatting tags
Elvis supports the following HTML tags.
Unsupported tags are silently ignored.
Newline characters aren't supported within tags;
each tag must fit on a single line.
- <html> ... </html>
- The entire document should be enclosed in these tags.
They don't actually do anything to help format the document,
but they may help programs recognize that the document is, in fact, written in
HTML.
- <head> ... </head>
- These should be used to bracket the document's header, if it has one.
- <title> ... </title>
- These tags are only legal in the document's header.
Any text between the
<title> and </title> tags will be stored internally as the
title of the document.
If you print the document, elvis will display the title at the top of each
page.
- <body> ... </body>
- These should be used to bracket the body of the document.
They don't actually do anything in elvis, but real Web browsers such as
Netscape allow you to specify backgrounds and patterns via BGCOLOR=... and BACKGROUND=...
arguments, respectively.
- <h1> ... </h1>
- These tags bracket the most visible type of section header.
Elvis displays <h1> ... </h1> headers in boldface,
flush against the left edge of the page.
When printing, these headers cause a page break.
- <h2> ... </h2>
- These bracket the second most visible type of section header.
Elvis displays <h2> ... </h2> headers in boldface,
indented slightly from the left edge.
When printing, these may cause a page break if they would otherwise appear
near the bottom of a page.
- <h3> ... </h3>
- These bracket the third most visible type of section header.
Elvis displays them in boldface, indented fully from the left edge so
that it lines up with normal text.
- <h4>...</h4>
<h5>...</h5>
<h6>...</h6>
- These are very minor section headers.
Conventional wisdom says that if you're using this many section headers then
you would probably do better to split your document into several smaller
documents.
Elvis displays these headers in an italic font.
- <p>
- This tag should be placed at the start of each normal paragraph,
with the possible exception of the first paragraph after a section header.
It causes a blank line to be generated, and any later text to appear starting
on a new line.
- <br>
- This causes any later text to appear starting on a new line.
It differs from <p> in that <br> doesn't output a blank line.
- <hr>
- This outputs a "horizontal rule" -- a line all the way across the page.
- <img alt=... src=...>
- Elvis can't display graphics, but if it encounters an <img> tag
which has an alternate text form (as denoted by an img="text" parameter)
then it'll display the alternate text.
Otherwise elvis will display "src" URL.
Also, if the image isn't already part of a hypertext link, then elvis
will treat it as a link to the image's binary data; this offers you a way to
fetch images, even though elvis can't display them.
The supported URL formats are described in the
discussion of the <a> tag, below.
- <frame name=... src=...>
- Elvis can't display frames either, but it will display the frame's name,
and treat that name as a hypertext link to the frame's document.
This offers a simple work-around for elvis' lack of real frame support.
The supported URL formats are described in the
discussion of the <a> tag, below.
- <blockquote> ... </blockquote>
- This is used to mark a large chunk text which is quoted from another source.
Elvis will indent the enclosed text.
- <pre> ... </pre>
- This brackets text which has already been preformatted by the document's author.
Elvis will treat tabs and newlines literally.
(Outside of <pre> ... </pre>, they would normally be treated like
spaces.)
This has been used for presenting tables, poetry, and source code examples.
In fact, elvis has an extension that is useful for tables:
If you start with <pre graphic> then elvis will convert certain
characters into graphic line-drawing characters.
When adjacent to a hyphen character, the hyphen, period, caret are converted
into appropriate graphic characters.
Additionally, the vertical bar character is always converted to a graphic
character.
The following was done with a plain <pre>...
.--.--.
|--|--|
| | |
^--^--^
... and this was done with <pre graphic>...
.--.--.
|--|--|
| | |
^--^--^
- <table>...</table>
<tr>...</tr>
<th>...</th>
<td>...</td>
- These are used for implementing tables in HTML 3.0.
Each table should be enclosed in a <table>...</table> pair.
Within the table, each row should be delimited with a <tr>...</tr> pair.
Within each row, the information for each column should be enclosed in
either a <th>...</th> pair for headers,
or a <td>...</td> pair for data.
Elvis doesn't really support these tags very well.
Only the bare essentials of these commands have been implemented.
They are intended to make tables recognizable as being tables,
but not necessarily make them easy to read.
- <dir>...</dir>
<xmp>...</xmp>
- These are treated almost exactly like <pre> ... </pre>.
There are supposed to be some differences, but elvis doesn't support those differences.
- <dl> ... </dl>
- These are used to bracket a list of definitions.
The definitions themselves are marked with the <dt> and <dd>
tags, described below.
- <dt>
- The text after this tag is used as a term to be defined.
Elvis displays this text in bold face, indented by the same amount as
normal text.
This is only legal in a <dl>...</dl> pair.
- <dd>
- The text after this tag is used as the definition of a term.
Elvis displays it in the normal font, indented somewhat more than
normal text or the <dt> text.
This is only legal in a <dl>...</dl> pair.
- <ol> ... </ol>
- These are used to enclose an ordered list.
The official specifications say that lists may be nested inside one another,
but elvis doesn't allow ordered lists to appear inside any other type of list.
If a document uses <ol> ... </ol> inside another list,
then elvis will act as though <ul> ... </ul> had been used instead.
This means that the list items will be marked with bullets instead of numbers.
Within the list, <li> tags are used to mark the items.
- <ul> ... </ul>
- These enclose an unordered list.
Each item in the list should be marked with a <li> tag.
- <menu> ... </menu>
- These enclose an unordered list, like <ul> ... </ul>,
but other Web browsers may display <menu> ... </menu> lists
in a more compact manner.
- <li>
- This is used to mark the start of a new item in a list.
- <input type=... size=... value=...>
<textarea cols=...>
- Elvis can display a mockup of a form, so you can have some idea of how
the form would look on a real
- <C, this is the < and > characters.
The name of the included file will then be displayed using the
stringfont font.
If omitted, then preprocessor file names will be highlighted as though they were
arithmetic expressions.
- function
- This word is followed by a single character which, if it appears
after a word, indicates that the word should be displayed in
the functionfont font.
For most languages, this will be a ( character.
If omitted, nothing is displayed in the functionfont.
- startword
inword
- These can be followed by a list of punctuation characters which
may appear at the start of a word, or in the remainder of the word,
respectively.
Letters and digits are always legal in words; you don't need to list them.
- other
- This word indicates which types of words should be displayed in the
otherfont font.
If omitted, nothing is displayed in the otherfont.
It can be any combination of the following symbols:
.-------------.-------------------------------------------------.
| SYMBOL | HOW TO RECOGNIZE "OTHER" WORDS |
|-------------|-------------------------------------------------|
| allcaps | length >= 2 chars, no lowercase characters |
| initialcaps | 1st character is uppercase, some are lowercase |
| initialpunct| 1st character is punctuation, from "startword" |
| mixedcaps | 1st character is lowercase, some are uppercase |
| final_t | length >= 3 chars, ends with "_t" |
^-------------^-------------------------------------------------^
- string
- This word is followed by a single character,
or a pair of single characters,
which are used as the quote characters surrounding string literals.
For C, this is the " character.
String literals will then be displayed using the
stringfont font.
If omitted, then strings will not be recognized.
- strnewline
- This is followed by backslash, allowed, indent, or
empty to indicate how strings can be continued across lines.
The default is backslash which indicates a C-style backslash
is required to quote the newline characters (which C will then exclude from
the string, but elvis doesn't care about that).
The other values all indicate that a backslash is not needed, and also give
some hints that help elvis detect whether the top of the screen is inside
a multi-line string.
Specifically, the indent value means that indented lines
are rarely a continuation of a string,
empty means that empty lines are probably not part of a string,
and allowed makes no promises.
The allowed value would be too slow if strings' opening and
closing quotes are identical (e.g., if the " character appears at both ends
of a string); in this situation, elvis uses empty instead.
Note that the hints are only used for detecting whether the first line
starts in a multi-line string.
When drawing text after that,
elvis treats all non-backslash values identically.
- character
- This word is followed by a single character, or a pair of single characters, which are used as the quote
characters surrounding character literals.
For C, this is the ' character.
This is shown using the
stringfont font, like strings.
When parsing, the only difference between the two is that characters can't
span lines, but strings can.
- regexp
- This word is followed by a list of characters which can be used
for delimiting a regular expression,
which some languages support as a means for specifying strings with
metacharacters.
(See Section 5 of this manual for a description of
elvis' own implementation of regular expressions, which is a typical example.)
Regular expressions are displayed using the
stringfont font.
Note that regexp accepts a list of characters, while
string and character support only a single character.
This is because many programming languages allow the programmer to choose
from a variety of delimiting characters.
- useregexp
- The most commonly used delimiter for regular expressions is '/',
which many languages also use as the division operator.
To avoid mistakenly displaying the division operator as the start of a
regular expression, elvis must be sensitive to the context in which it
is used.
That's what this word is for.
The
useregexp word is followed by a list of
keywords and/or punctuation characters which allow the
next character to be recognized as a regular expression.
Additionally, regular expressions are allowed at the start of a line.
- useregsub
- This is used for listing keywords and punctuation
characters which may be followed by a regular expression
and then substitution text.
- ignorecase
- This word should be followed by true or false.
If true, then elvis won't distinguish between uppercase and
lowercase letters when testing whether a word is a keyword
(except that in the elvis.syn file, the keywords should be listed in lowercase).
If omitted, elvis assumes it should be false.
7.3.3 Example
The elvis.syn file shipped with elvis contains some
good examples of language descriptions.
Here's an excerpt from it, describing the Java language.
language java
extension .java .jav
keyword abstract boolean break byte byvalue case cast catch char
keyword class const continue default do double else extends false
keyword final finally float for future generic goto if implements
keyword import inner instanceof int interface long native new null
keyword operator outer package private protected public rest return
keyword short static super switch synchronized this throw throws
keyword transient true try var void volatile while
comment //
comment /* */
function (
string "
character '
startword _
inword _
other allcaps initialcaps
There is no preprocessor line, because java doesn't use a preprocessor.
The "allcaps" and "initialcaps" symbols are given so that constants and class
names will be shown in the otherfont.
7.4 Hex mode
The "hex" display mode is an interactive hex dump of the buffer.
This is good for examining or editing binary files.
One handy feature is the ability to enter characters in hex
(either in input mode or as the argument to an
r visual command)
by typing ^X followed by two hex digits.
This feature is always available regardless of the display mode...
but this is where is it most useful.
7.5 HTML mode
HTML is the language used for constructing pages on the World Wide Web.
Elvis' "html" display mode supports a subset of HTML, which it uses for
displaying the online help documentation (including this very document).
HTML is a markup language.
This means that documents contain a mixture of text and formatting instructions.
In HTML there are two types of instructions, called tags
and entities.
When the document is processed by a program such as Netscape or elvis (in
html mode), the tags are stripped out, the entities are converted to
a kind of text, and the text is formatted and presented to the user.
Ordinarily the user will never see the tags.
Since elvis is primarily an editor, not a viewer, it has two options which
allow the tags to become visible:
the showmarkups option causes a tag to become
visible if the cursor is moved onto it, and
the list option makes all tags visible
regardless of the cursor position.
There are a lot of good "How To Use HTML" documents on the Net.
This is not one of them!
I don't intend to do much more than describe the quirks of elvis'
implementation of HTML here.
I added HTML support to elvis mostly to support the online help.
Consequently, if a feature is hard to implement and the online documentation
doesn't use it, then I didn't implement that feature.
If you intend to use elvis as a browser, then I suggest you read the
appropriate section in the Tip chapter.
7.5.1 Formatting tags
Elvis supports the following HTML tags.
Unsupported tags are silently ignored.
Newline characters aren't supported within tags;
each tag must fit on a single line.
- <html> ... </html>
- The entire document should be enclosed in these tags.
They don't actually do anything to help format the document,
but they may help programs recognize that the document is, in fact, written in
HTML.
- <head> ... </head>
- These should be used to bracket the document's header, if it has one.
- <title> ... </title>
- These tags are only legal in the document's header.
Any text between the
<title> and </title> tags will be stored internally as the
title of the document.
If you print the document, elvis will display the title at the top of each
page.
- <body> ... </body>
- These should be used to bracket the body of the document.
They don't actually do anything in elvis, but real Web browsers such as
Netscape allow you to specify backgrounds and patterns via BGCOLOR=... and BACKGROUND=...
arguments, respectively.
- <h1> ... </h1>
- These tags bracket the most visible type of section header.
Elvis displays <h1> ... </h1> headers in boldface,
flush against the left edge of the page.
When printing, these headers cause a page break.
- <h2> ... </h2>
- These bracket the second most visible type of section header.
Elvis displays <h2> ... </h2> headers in boldface,
indented slightly from the left edge.
When printing, these may cause a page break if they would otherwise appear
near the bottom of a page.
- <h3> ... </h3>
- These bracket the third most visible type of section header.
Elvis displays them in boldface, indented fully from the left edge so
that it lines up with normal text.
- <h4>...</h4>
<h5>...</h5>
<h6>...</h6>
- These are very minor section headers.
Conventional wisdom says that if you're using this many section headers then
you would probably do better to split your document into several smaller
documents.
Elvis displays these headers in an italic font.
- <p>
- This tag should be placed at the start of each normal paragraph,
with the possible exception of the first paragraph after a section header.
It causes a blank line to be generated, and any later text to appear starting
on a new line.
- <br>
- This causes any later text to appear starting on a new line.
It differs from <p> in that <br> doesn't output a blank line.
- <hr>
- This outputs a "horizontal rule" -- a line all the way across the page.
- <img alt=... src=...>
- Elvis can't display graphics, but if it encounters an <img> tag
which has an alternate text form (as denoted by an img="text" parameter)
then it'll display the alternate text.
Otherwise elvis will display "src" URL.
Also, if the image isn't already part of a hypertext link, then elvis
will treat it as a link to the image's binary data; this offers you a way to
fetch images, even though elvis can't display them.
The supported URL formats are described in the
discussion of the <a> tag, below.
- <frame name=... src=...>
- Elvis can't display frames either, but it will display the frame's name,
and treat that name as a hypertext link to the frame's document.
This offers a simple work-around for elvis' lack of real frame support.
The supported URL formats are described in the
discussion of the <a> tag, below.
- <blockquote> ... </blockquote>
- This is used to mark a large chunk text which is quoted from another source.
Elvis will indent the enclosed text.
- <pre> ... </pre>
- This brackets text which has already been preformatted by the document's author.
Elvis will treat tabs and newlines literally.
(Outside of <pre> ... </pre>, they would normally be treated like
spaces.)
This has been used for presenting tables, poetry, and source code examples.
In fact, elvis has an extension that is useful for tables:
If you start with <pre graphic> then elvis will convert certain
characters into graphic line-drawing characters.
When adjacent to a hyphen character, the hyphen, period, caret are converted
into appropriate graphic characters.
Additionally, the vertical bar character is always converted to a graphic
character.
The following was done with a plain <pre>...
.--.--.
|--|--|
| | |
^--^--^
... and this was done with <pre graphic>...
.--.--.
|--|--|
| | |
^--^--^
- <table>...</table>
<tr>...</tr>
<th>...</th>
<td>...</td>
- These are used for implementing tables in HTML 3.0.
Each table should be enclosed in a <table>...</table> pair.
Within the table, each row should be delimited with a <tr>...</tr> pair.
Within each row, the information for each column should be enclosed in
either a <th>...</th> pair for headers,
or a <td>...</td> pair for data.
Elvis doesn't really support these tags very well.
Only the bare essentials of these commands have been implemented.
They are intended to make tables recognizable as being tables,
but not necessarily make them easy to read.
- <dir>...</dir>
<xmp>...</xmp>
- These are treated almost exactly like <pre> ... </pre>.
There are supposed to be some differences, but elvis doesn't support those differences.
- <dl> ... </dl>
- These are used to bracket a list of definitions.
The definitions themselves are marked with the <dt> and <dd>
tags, described below.
- <dt>
- The text after this tag is used as a term to be defined.
Elvis displays this text in bold face, indented by the same amount as
normal text.
This is only legal in a <dl>...</dl> pair.
- <dd>
- The text after this tag is used as the definition of a term.
Elvis displays it in the normal font, indented somewhat more than
normal text or the <dt> text.
This is only legal in a <dl>...</dl> pair.
- <ol> ... </ol>
- These are used to enclose an ordered list.
The official specifications say that lists may be nested inside one another,
but elvis doesn't allow ordered lists to appear inside any other type of list.
If a document uses <ol> ... </ol> inside another list,
then elvis will act as though <ul> ... </ul> had been used instead.
This means that the list items will be marked with bullets instead of numbers.
Within the list, <li> tags are used to mark the items.
- <ul> ... </ul>
- These enclose an unordered list.
Each item in the list should be marked with a <li> tag.
- <menu> ... </menu>
- These enclose an unordered list, like <ul> ... </ul>,
but other Web browsers may display <menu> ... </menu> lists
in a more compact manner.
- <li>
- This is used to mark the start of a new item in a list.
- <input type=... size=... value=...>
<textarea cols=...>
- Elvis can display a mockup of a form, so you can have some idea of how
the form would look on a real
- <C, this is the < and > characters.
The name of the included file will then be displayed using the
stringfont font.
If omitted, then preprocessor file names will be highlighted as though they were
arithmetic expressions.
- function
- This word is followed by a single character which, if it appears
after a word, indicates that the word should be displayed in
the functionfont font.
For most languages, this will be a ( character.
If omitted, nothing is displayed in the functionfont.
- startword
inword
- These can be followed by a list of punctuation characters which
may appear at the start of a word, or in the remainder of the word,
respectively.
Letters and digits are always legal in words; you don't need to list them.
- other
- This word indicates which types of words should be displayed in the
otherfont font.
If omitted, nothing is displayed in the otherfont.
It can be any combination of the following symbols:
.-------------.-------------------------------------------------.
| SYMBOL | HOW TO RECOGNIZE "OTHER" WORDS |
|-------------|-------------------------------------------------|
| allcaps | length >= 2 chars, no lowercase characters |
| initialcaps | 1st character is uppercase, some are lowercase |
| initialpunct| 1st character is punctuation, from "startword" |
| mixedcaps | 1st character is lowercase, some are uppercase |
| final_t | length >= 3 chars, ends with "_t" |
^-------------^-------------------------------------------------^
- string
- This word is followed by a single character,
or a pair of single characters,
which are used as the quote characters surrounding string literals.
For C, this is the " character.
String literals will then be displayed using the
stringfont font.
If omitted, then strings will not be recognized.
- strnewline
- This is followed by backslash, allowed, indent, or
empty to indicate how strings can be continued across lines.
The default is backslash which indicates a C-style backslash
is required to quote the newline characters (which C will then exclude from
the string, but elvis doesn't care about that).
The other values all indicate that a backslash is not needed, and also give
some hints that help elvis detect whether the top of the screen is inside
a multi-line string.
Specifically, the indent value means that indented lines
are rarely a continuation of a string,
empty means that empty lines are probably not part of a string,
and allowed makes no promises.
The allowed value would be too slow if strings' opening and
closing quotes are identical (e.g., if the " character appears at both ends
of a string); in this situation, elvis uses empty instead.
Note that the hints are only used for detecting whether the first line
starts in a multi-line string.
When drawing text after that,
elvis treats all non-backslash values identically.
- character
- This word is followed by a single character, or a pair of single characters, which are used as the quote
characters surrounding character literals.
For C, this is the ' character.
This is shown using the
stringfont font, like strings.
When parsing, the only difference between the two is that characters can't
span lines, but strings can.
- regexp
- This word is followed by a list of characters which can be used
for delimiting a regular expression,
which some languages support as a means for specifying strings with
metacharacters.
(See Section 5 of this manual for a description of
elvis' own implementation of regular expressions, which is a typical example.)
Regular expressions are displayed using the
stringfont font.
Note that regexp accepts a list of characters, while
string and character support only a single character.
This is because many programming languages allow the programmer to choose
from a variety of delimiting characters.
- useregexp
- The most commonly used delimiter for regular expressions is '/',
which many languages also use as the division operator.
To avoid mistakenly displaying the division operator as the start of a
regular expression, elvis must be sensitive to the context in which it
is used.
That's what this word is for.
The
useregexp word is followed by a list of
keywords and/or punctuation characters which allow the
next character to be recognized as a regular expression.
Additionally, regular expressions are allowed at the start of a line.
- useregsub
- This is used for listing keywords and punctuation
characters which may be followed by a regular expression
and then substitution text.
- ignorecase
- This word should be followed by true or false.
If true, then elvis won't distinguish between uppercase and
lowercase letters when testing whether a word is a keyword
(except that in the elvis.syn file, the keywords should be listed in lowercase).
If omitted, elvis assumes it should be false.
7.3.3 Example
The elvis.syn file shipped with elvis contains some
good examples of language descriptions.
Here's an excerpt from it, describing the Java language.
language java
extension .java .jav
keyword abstract boolean break byte byvalue case cast catch char
keyword class const continue default do double else extends false
keyword final finally float for future generic goto if implements
keyword import inner instanceof int interface long native new null
keyword operator outer package private protected public rest return
keyword short static super switch synchronized this throw throws
keyword transient true try var void volatile while
comment //
comment /* */
function (
string "
character '
startword _
inword _
other allcaps initialcaps
There is no preprocessor line, because java doesn't use a preprocessor.
The "allcaps" and "initialcaps" symbols are given so that constants and class
names will be shown in the otherfont.
7.4 Hex mode
The "hex" display mode is an interactive hex dump of the buffer.
This is good for examining or editing binary files.
One handy feature is the ability to enter characters in hex
(either in input mode or as the argument to an
r visual command)
by typing ^X followed by two hex digits.
This feature is always available regardless of the display mode...
but this is where is it most useful.
7.5 HTML mode
HTML is the language used for constru