Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
It  is	possible to use	the cursor optimization	functions of this
screen package without the overhead and	additional  size  of  the
screen updating	functions.  The	screen updating	functions are de-
signed for uses	where parts of the screen are  changed,	 but  the
overall	 image	remains	the same.  This	includes such programs as

actually uses these functions, does not.  Certain other	 programs
will  find  it	difficult  to  use these functions in this manner
without	considerable unnecessary program overhead.  For	such  ap-
plications, such as some

Graphics  programs  designed  to run on	character-oriented termi-
nals.  I could name many, but they come	and go,	so the list would
be  quickly out	of date.  Recently, there have been programs such
as and and optimizing programs,	all that is needed is the  motion
optimizations.	This, therefore, is a description of what some of
what goes on at	the lower levels of this screen	package.  The de-
scriptions  assume  a certain amount of	familiarity with program-
ming problems and some finer points of C.  None	of it is terribly
difficult,  but	you should be forewarned.  In order to use a ter-
minal's	features to the	best of	a program's  abilities,	 it  must
first know what	they are.

If this	comes as any surprise to you, there's this tower in Paris
they're	thinking of junking that I can let you have for	 a  song.
The   describes	these, but a certain amount of decoding	is neces-
sary, and there	are, of	course,	both  efficient	 and  inefficient
ways  of  reading  them	in.  The algorithm that	the uses is taken
from and is hideously efficient.  It reads them	in a  tight  loop
into  a	 set  of  variables whose names	are two	uppercase letters
with some mnemonic value.  For example,	is a string  which  moves
the cursor to the "home" position.

These names are	identical to those variables used in the
 to describe each capability.  See Appendix A for a complete list
of those read, and the manual page for a  full	description.   As
there  are  two	 types of variables involving ttys, there are two
routines.  The first, sets some	 variables  based  upon	 the  tty
modes accessed by and The second, a larger task	by reading in the
descriptions from the  .  This is the way these	routines are used
by if (isatty(0)) {
       if ((sp=getenv("TERM")) != NULL)
	       setterm(sp);	      else		     set-
term(Defterm); } else
       setterm(Defterm); puts(TI); puts(VS);  checks  to  see  if
file descriptor	0 is a terminal.

is defined in the default C library function routines.	It does	a
on the descriptor and checks the return	value.	If  it	is,  sets
the  terminal  description modes from a	is then	called to get the
name of	the terminal, and that value (if there is one) is  passed
to  which reads	in the variables from associated with that termi-
nal.  returns a	pointer	to a string containing the  name  of  the
terminal,  which  we  save  in	the  character pointer If returns
false, the default terminal is used.  The and sequences	 initial-
ize  the  terminal  is	a  macro which uses (see and to	put out	a
string).  undoes these things.	Now that we have all this  useful
information, it	would be nice to do something with it.

Actually,  it  be emotionally fulfilling just to get the informa-
tion.  This is usually only true, however, if you have the social
life  of  a  kumquat.  The most	difficult thing	to do properly is
motion optimization.  When you consider	how many  different  fea-
tures  various	terminals  have	 (tabs,	backtabs, non-destructive
space, home sequences, absolute	tabs, .....)  you  can	see  that
deciding  how  to  get from here to there can be a decidedly non-
trivial	task.  The editor uses many of these  features,	 and  the
routines  it  uses to do this take up many pages of code.  Fortu-
nately,	I was able to liberate them with the author's permission,
and  use them here.  After using and to	get the	terminal descrip-
tions, the function deals with this task.  It  usage  is  simple:
you  simply  tell  it where you	are now	and where you want to go.
For example mvcur(00LINES/2COLS/2) would move the cursor from the
home  position	(00) to	the middle of the screen.  If you wish to
force absolute addressing, you can use the function from the rou-
tines,	or  you	 can  tell that	you are	impossibly far away, like
Cleveland.  For	example, to absolutely	address	 the  lower  left
hand  corner  of the screen from anywhere just claim that you are
in the upper right hand	corner:	mvcur(0COLS-1LINES-10)

Want to link to this manual page? Use this URL:

home | help