curses

Tony L. Hansen hansen at pegasus.UUCP
Sat Jun 29 00:52:20 AEST 1985


In article <571 at umd5.UUCP> zben at umd5.UUCP (Ben Cranston) writes:
>I posted flames on the same point.  Curses does not support input translation.

The old versions of curses that come withh 4.X BSD did not support input
translations.

This feature is just one of the many features that were added by Mark Horton
to his version of curses when he rewrote it. It is also one of the reasons
that he rewrote it. His version is now a part of System Vr2.

By saying "keypad(stdscr, TRUE);", all input through stdscr is scanned for
escape sequences that match those input keys specified in the terminfo
entry. When one is found, an integer is returned whose value is #define'd in
<curses.h>. These tokens are named such things as KEY_LEFT and KEY_HOME.

Pavel Curtis' public-domain version of Mark Horton's curses also will do
this translation. I have no idea how well it works.

>I would really
>like to move in the direction of terminal capabilities database, but on input
>there are some real sticky questions.
>
>For example, when you are in column one, what does a left arrow do?  On many
>terminals it does nothing, on many more it goes to column 80 of the previous
>line, on some it goes to column 80 of the SAME line.  What does an up arrow
>do on line one?  Unix finesses all these questions by refusing to echo the
>character in these situations.  On mainframes without smart echo, one does not
>have that handy copout.  Thus, in addition to the simple question of what code
>does each key generate, these little quirks must all be represented in the
>database.

Define the action to be what you want it to be. As long as pressing the key
only causes an escape sequence to be translated, and doesn't really move the
cursor locally, you have no problems. If the cursor is only local, then you
have no knowledge whatsoever that the cursor got moved. If a sequence is
transmitted AND the cursor is moved, then you have a bad terminal. In many
cases, terminals of the last two sorts have an escape sequence that will
change the action of the function keys. This sequence should be sent out
upon startup. In terminfo, such a sequence would be defined by smkx=\Exxx.

>One additional example.  On many terminals, when you do an insert-line 
>operation, the cursor is left wherever it was.  But, on the Heathkit, the
>cursor is returned to column one!  If you REALLY want to see some brain-
>damage, look at the insert mode on the Datamedia 2000/3000 line.

Terminfo and termcap only define insert-line/delete-line when the cursor is
in column one. Mark Horton's curses will only use those capabilities when
the cursor is in column one.

					(You get what you pay for.)
					Tony Hansen
					hansen at pegasus.ATT.UUCP



More information about the Comp.unix.wizards mailing list