

########
#
# This file describes attributes of video terminals for use by `ve'.  It is
# converted to binary by `vconv':
#	vconv <vattr.src >vattr
# The binary can be converted back to source:
#	vconv -s <vattr >vattr.src
#
# Data representation in this file closely follows the C language.  Numbers
# range from 0 to 255 and may be base 8, 10 or 16, e.g.  017  15  and  0xF
# all mean fifteen.  Character constants range from 0 to 255 and, if ASCII
# printable, may be represented directly, e.g.  'a'  '!'  '1' .  Unprintable
# chars require a special notation:
#	'\n'	ASCII LF
#	'\r'	ASCII CR
#	'\b'	ASCII BS
#	'\e'	ASCII ESC
#	'\t'	ASCII HT
# The  \  maps other chars to themselves, notably
#	'\"'	double-quote
#	'\''	single-quote
#	'\\'	backslash
# All chars, including those from 128 to 255, are expressible in octal, e.g.
#	'\12'	ASCII LF
#	'\012'	ASCII LF
#	'\377'	decimal 255
# Another notation is available, as used by `ve' itself:
#	'^@'	ASCII NUL
#	'^J'	ASCII LF
#	'^['	ASCII ESC
# Strings are represented as printable chars surrounded by  "  "  quotes.
# Unprintable chars may be included by using the special notations for chars.
#
# Each entry in the file consists of the `term' keyword, then a string, then
# the entry body braced by `{' and `}'.  The string supplies one or more
# names, separated by the | symbol, by which users refer to the entry.  The
# entry body consists of zero or more attribute definitions.  An attribute
# may be of type integer, string or boolean.
#
# Integer attributes are evaluated at `ve' run-time.  The attribute name is
# followed by an expression comprising the infix operators  *  /  +  -  and
# grouping with  (  )  and the following forms of operands:
#	* numbers, e.g.  15  017  0xF
#	* char constants, e.g.  'j'  '\12'  '\n'  '^J'
#	* positional parameters, e.g.  $1  $2  $3
#	* window report parameters, e.g.  ^1  ^2  ^3
#	* the repeat parameter  &
# Parameters are described below.
#
# String attributes closely resemble the `printf' function in C.  The
# attribute name is followed by a format string, then a list of zero or more
# comma-separated arguments, which have the same syntax as the expressions
# used by integer attributes.  While integer attributes yield a value when
# evaluated, a string attribute is evaluated to generate output, usually an
# escape sequence.  As the string is scanned, any char which is not a  %  is
# output directly.  Otherwise, a conversion is performed according to the
# following char.  First, the next argument in the list is evaluated.  The
# resultant integer is then converted and output:
#	%c	output the byte directly
#	%d	convert to digits (base 10) and output
#
# A boolean definition consists of the attribute name, followed by the keyword
# `true' or `false'.
#
# If the string attribute `wreport' is defined, `ve' evaluates it at startup.
# The terminal or window must respond with an ANSI-standard escape sequence,
# which `ve' saves in the window report parameters.  These parameters may be
# referenced by any integer expression, especially by the integer attributes
# `lines' and `cols'.
#
# Some escape sequences (e.g. ANSI) permit an iteration count.  If ten lines
# need to be deleted, the `ldelete' string attribute could be evaluated ten
# times.  However, if `ldelete' uses the repeat parameter  &  then the string
# is evaluated only once: only one escape sequence is output.  The repeat
# param is only meaningful with certain attributes: see the attribute table
# below.
#
# Certain terminal functions require extra info, e.g. the cursor seek function
# obviously needs the line and column.  `ve' supplies this info via the
# positional parameters.  The positional params supplied will depend on the
# particular attribute: see the attribute table below.
#
# The following attributes are supported:
# attribute	notes	description & positional params (if any)
# ---------	----	----------------------------------------
# latin1	(B)	tty supports ISO Latin 1 characters, otherwise ASCII
# wreport	(S)	request window size info
# init		(S)	terminal initialization, e.g. setting tabs
# lines		I	how many lines of display
# cols		I	how many columns of display
# seek		S	move cursor to line $1, column $2
# up		(S)	move cursor straight up one line
# right		(S)	move cursor right one column without erasing
# lopen		S &	open blank line before current, shift down
# ldelete	S &	delete current line, shift up
# eoserase	S	erase to end-of-screen
# eolerase	S	erase to end-of-line
# starti	S ?	start insert character mode
# stopi		S ?	stop insert mode
# cinsert	S & ?	insert a blank before current char
# cdelete	S &	delete current char
# normal_attr	S a	set normal char attribute
# zone_attr	(S)	set attribute for chars in a zone
# error_attr	(S)	set char attribute for error messages
# normal_cursor	(S)	set normal cursor appearance
# insert_cursor	(S)	set cursor appearance when inserting
#
# Notes:	I	is type integer
#		S	is type string
#		B	is type boolean
#		()	optional
#		&	repeat parameter is available
#		?	either starti/stopi or cinsert must be defined
#		a	optional if both zone_attr & error_attr omitted


# Zenith/Heathkit
#
term "z19|h19" {
	lines		24
	cols		80
	seek		"\eY%c%c", $1+' ', $2+' '
	up		"\eA"
	right		"\eC"
	lopen		"\eL"
	ldelete		"\eM"
	eoserase	"\eJ"
	eolerase	"\eK"
	starti		"\e@"
	stopi		"\eO"
	cdelete		"\eN"
	normal_attr	"\eq"
	zone_attr	"\ep"
	error_attr	"\ep"
}

# Zenith/Heathkit
#
term "z29|h29" {
	lines		24
	cols		80
	seek		"\eY%c%c", $1+' ', $2+' '
	up		"\eA"
	right		"\eC"
	lopen		"\eL"
	ldelete		"\eM"
	eoserase	"\eJ"
	eolerase	"\eK"
	starti		"\e@"
	stopi		"\eO"
	cdelete		"\eN"
	normal_attr	"\es0"
	zone_attr	"\es1"
	error_attr	"\es1"
}

# SUN Shelltool
#
term "sun" {
	wreport		"\e[18t"
	lines		^2
	cols		^3
	seek		"\e[%d;%dH", $1+1, $2+1
	up		"\e[A"
	right		"\e[C"
	lopen		"\e[%dL", &
	ldelete		"\e[%dM", &
	eoserase	"\e[J"
	eolerase	"\e[K"
	cinsert		"\e[%d@", &
	cdelete		"\e[%dP", &
	normal_attr	"\e[0m"
	zone_attr	"\e[7m"
	error_attr	"\e[7m"
}

# MacTerminal
#
term "mac" {
	lines		24
	cols		80
	seek		"\e[%d;%dH", $1+1, $2+1
	lopen		"\e[%dL\r", &
	ldelete		"\e[%dM\r", &
	eoserase	"\e[J"
	eolerase	"\e[K"
	cinsert		"\e[%d@", &
	cdelete		"\e[%dP", &
	normal_attr	"\e[0m"
	zone_attr	"\e[1m"
	error_attr	"\e[7m"
}

# Amiga console (Z19 but 25 lines).
#
term "aconsole" {
	lines		25
	cols		80
	seek		"\eY%c%c", $1+' ', $2+' '
	up		"\eA"
	right		"\eC"
	lopen		"\eL"
	ldelete		"\eM"
	eoserase	"\eJ"
	eolerase	"\eK"
	starti		"\e@"
	stopi		"\eO"
	cdelete		"\eN"
	normal_attr	"\eq"
	zone_attr	"\ep"
	error_attr	"\ep"
}

# Amix screens & windowing system (vaguely ansi standard)
#
term "amiga" {
	lines		24
	cols		79
	seek		"\e[%d;%dH", $1+1, $2+1
	up		"\e[A"
	right		"\e[C"
	lopen		"\e[L"
	ldelete		"\e[M"
	eoserase	"\e[J"
	eolerase	"\e[K"
	cinsert		"\e[%d@", &
	cdelete		"\e[%dP", &
	normal_attr	"\e[m"
	zone_attr	"\e[7m\e[2m"		# works on screens & windows
	error_attr	"\e[7m"
}

# the Amiga windowing system (vaguely ansi standard)
# Rico's version has window size report a la SUN Shelltool.
#
term "amiga.rico" {
	latin1		true
	wreport		"\e[18t"
	lines		^2
	cols		^3 + 1
	seek		"\e[%d;%dH", 24-^2+$1+1, $2+1
	up		"\e[A"
	right		"\e[C"
	lopen		"\e[L"
	ldelete		"\e[M"
	eoserase	"\e[J"
	eolerase	"\e[K"
	cinsert		"\e[%d@", &
	cdelete		"\e[%dP", &
	normal_attr	"\e[m"
	zone_attr	"\e[2m"
	error_attr	"\e[4m"
}

# ANSI terminal (e.g. Erich's SCO odtterm, xterm, bebox Terminal)
# This has window size reporting via escape sequence.
#
term "beterm|ansi|xterm" {
	latin1		true
	wreport		"\e[999;999H\e[6n\r"
	lines		^1
	cols		^2
	seek		"\e[%d;%dH", $1+1, $2+1
	up		"\e[A"
	right		"\e[C"
	lopen		"\e[%dL", &
	ldelete		"\e[%dM", &
	eoserase	"\e[J"
	eolerase	"\e[K"
	cinsert		"\e[%d@", &
	cdelete		"\e[%dP", &
	normal_attr	"\e[m"
	zone_attr	"\e[31m"
	error_attr	"\e[35;7m"
}

# ansi terminal
# This entry is used with SCO full screen virtual terminals, because they
# don't support window size reporting.
#
term "ansi80x25" {
	lines		25
	cols		80
	seek		"\e[%d;%dH", $1+1, $2+1
	up		"\e[A"
	right		"\e[C"
	lopen		"\e[%dL", &
	ldelete		"\e[%dM", &
	eoserase	"\e[J"
	eolerase	"\e[K"
	cinsert		"\e[%d@", &
	cdelete		"\e[%dP", &
	normal_attr	"\e[m"
	zone_attr	"\e[1m"
	error_attr	"\e[7m"
}

# bebox newsh (not ansi)
#
term "bebox" {
	init		"\eX  "
	lines		25
	cols		88
	seek		"\eH%c%c", $1, $2
	lopen		"\eL%c ",  &
	ldelete		"\eM%c ",  &
	eoserase	"\eJ  "
	eolerase	"\eK  "
	cinsert		"\e@%c ",  &
	cdelete		"\eP%c ",  &
	normal_attr	"\en  "
	zone_attr	"\ez  "
	error_attr	"\ee  "
}
