FSC-0037
Updates: FSC-0025






                                                Pittsburgh, PA
                                                1 May 1989



                          A   V   A   T   A   R

        Advanced Video Attribute Terminal Assembler and Recreator

                           George A. Stanislav

                            Fidonet 1:129/39.0





         Information

            This FSC is being distributed to members of the FidoNet
            community in order to solicit their reactions to the
            proposals contained in it.  While the issues discussed may
            not be directly relevant to FidoNet standards,  they may be
            interesting to implementers.  Distribution of this document
            is unlimited.











   Revised on 25 November 1989



                               Definitions


Avatar, level 0 - The Avatar protocol as presented at Fidocon '88 and
        described in AVATAR0.C, dated 23 August 1989, plus extensions
        defined in this document.

AVT/0   -  An abbreviation for Avatar, level 0, suggested by Joaquim
        Homrighausen.

Current attribute - Video attribute defined by the last ^V^A, ^V^L, ^V^M or ^L
        AVT/0 command whichever happened last. In AVT/0, ^L sets the value
        of current attribute to 3, ^V^L, ^V^M and ^V^A to an explicit value.
        In addition, ^V^B turns blink on.



                            Extending AVT/0


It has become clear some of the Avatar commands originally reserved for
AVT/1 would be very useful in AVT/0. I was hesitant to add them for one
simple reason: Any addition on level 0 will break all existing Avatar
emulating software.

However, at present there are only three programs I know of that have
implemented Avatar emulation: My own TinyTerm, Joaquim Homrighausen's
FrontDoor and Jason Galanter's Jterm.

Both Joaquim and Jason have assured me they would put the new commands in
their programs, thus nothing will be broken. With that assurance in mind,
I feel confident no chaos will result from adding these new commands.


                New Commands (brief definitions)

        <^V><^I>  -  Turn insert mode ON. It stays on until any other AVT/0
                     command except <^Y> and <^V><^Y> is encountered after
                     which it is turned off;

        <^V><^J><numlines><upper><left><lower><right> - scroll area up;

        <^V><^K><numlines><upper><left><lower><right> - scroll area down;

        <^V><^L><attr><lines><columns>  - clear area, set attribute;

        <^V><^M><attr><char><lines><columns>  - initialize area, set attribute;

        <^V><^N>        -  delete character, scroll rest of line left;

        <^V><^Y><numchars><char>[...]<count>  -  repeat pattern.



                      Detailed Description


Insert mode: Insert mode controls the way characters are printed on the
        screen. Insert mode is always assumed OFF unless explicitly set ON
        by the ^V^I command after which it stays on until another AVT/0
        command except for ^Y or ^V^Y is encountered. Then it reverses back
        to off.

        Whenever insert mode is OFF, characters are printed on the screen
        like this:

        1. Print character at current cursor position using current attribute,
           overwriting whatever was previously displayed at current cursor
           position;

        2. Move cursor to next position, usually one character to the right.
           At end of the line, move the cursor to next line (possibly
           scrolling the display or current window if in AVT/1).

        Whenever insert mode is ON, characters are printed on the screen
        as follows:

        1. Starting at current cursor position and going all the way to the
           second last character on current line, scroll the text one
           character to the right;

        2. Discard the character previously at the end of the line, do NOT
           move it at the beginning of the next line;

        3. Print character at current cursor position using current attribute;

        4. Move cursor to next position, precisely as in par. 2 of insert
           mode off.

If ^Y or ^V^Y are encountered, the string of characters they compress is
first expanded, then treated as an ordinary stream of characters printed
according to the above rules.

Any other AVT/0 command turns insert mode back off. Please note that in
either case the cursor is moved to its next position in an identical manner.
The mere fact the cursor is moved to next line, or even scrolls the screen
a line up, does NOT turn insert mode off. Only an AVT/0 except as mentioned
above can change insert mode on or off.

If control characters are a part of the text stream, they are interpreted
indentically in insert mode on and off as follows:

        Carriage return  -  move cursor at the beginning of the same line;

        Line feed        -  move cursor one line down (scroll screen or
                            window [in AVT/1] if necessary), do not change
                            cursor column;
        Back space       -  move cursor one position to the left. Do NOT
                            overwrite the character at that position.
                            Do nothing if already at the leftmost position;

        Tab              -  move cursor to next tab position without
                            overwriting anything. Tab positions are
                            multiples of 8. Do nothing if already at the
                            rightmost position.

A space is treated as a character, not as a control character.


Scrolling an area (^V^J and ^V^K): The area defined by its upper, left, lower
        and right coordinates is scrolled up <^V^J) or down (^V^K) by
        <numlines> lines filling the gap with blank spaces using current
        attribute. If the value of <numlines> is zero or exceeds the actual
        number of lines within the scrolled area, the area is filled with
        blanks using current attribute.

        These two commands do NOT change the position of the cursor, nor
        do they define the scrolled area as the default window.

        The coordinates are relative to the upper left corner of the screen
        (or current window in AVT/1). The coordinates of upper left corner
        are 1,1. If a coordinate contains 0, it is to be changed to 1.

Initializing an area (^V^M): This command contains several steps:

        1. Set current attribute to <attr>;

        2. Starting at current cursor position (inclusively), ending
           at current cursor position plus number of <lines> and <columns>,
           print <char> at all position inside the defined area. Do not
           move the cursor. If the number of columns or lines exceeds whatever
           is available to the right and below current cursor position,
           truncate the dimensions to fit within the limits of the screen
           (or current window in AVT/1).

Clearing an area (^V^L): This is a shortcut version of the ^V^M command.
        The character to be used to initialize the area of the screen is
        assumed to be a blank space. In other words, it sets current
        attribute and clears an area of the screen starting at current
        cursor position (which remains unchanged).

Please note that the usual 7-bit restriction applies to ^V^L  That means
that the attribute byte should be anded with 7f hex before applying. If
blinking is desired, ^V^B should be used next.

On the other hand, requiring to ignore the high bit in ^V^M would make it
impossible to fill the area of the screen with a blinking pattern (something
I have seen used very creatively by Chris Gaal of PittNet). Therefore, if
bit 7 of attr is set in ^V^M, current attribute is set to <attr> AND 7f hex
and blink is turned on before filling the area with a character.
Deleting a character (^V^N): Starting at the column one character to the right
        of current cursor position all the way to end of the line, scroll
        the text one character position to the left. This effectively
        deletes the character at current cursor position. Print a blank space
        using current attribute at the rightmost end of the line to fill the
        gap. Do not change current cursor position. If the cursor is at the
        end of the line, simply overwrite the last character with a blank
        space using current attribute.

Repeat pattern: This is an extension of the ^Y command which allows a group
        of characters to form a repetititious pattern. <numchars> determines
        the number of characters in the pattern, <count> the number of times
        the pattern is to be printed out. The pattern may contain AVT/0 codes.

For example, <^V><^Y><#3>ABC<#4> expands to "ABCABCABCABC".


                        Scrolling Philosophy


An important philosophical question has not been answered yet: When scrolling
the contents of an area (in the scrolling commands ^V^J and ^V^J, in insert
mode ON and in deleting characters ^V^N) should only the text be scrolled
and the attribute of the scrolled areas remain where they are or should the
attributes move as well.

A case can be made for either approach. Obviously, the gaps created by
scrolling are filled with current attribute, therefore, it seems more logical
to scroll the attributes along with the text (else there would be no need
to fill the gaps). Thus we follow a consistent principle of video attributes
belonging to a character (be it a blank, a digit, or a true character), not
to a location. Whenever a character is scrolled to a different location, it
takes its attribute along.


