Rdb: Ruby-Nachbau der MWC /rdb-Werkzeuge
This commit is contained in:
+136
@@ -0,0 +1,136 @@
|
||||
.TH cursor "" "" "/rdb Command"
|
||||
.PC "Move the cursor to the row and column requested"
|
||||
\fBcursor \fIrow col \fB[ \fICURSOR \fB]\fR
|
||||
.PP
|
||||
.II cursor^move
|
||||
.II "move cursor"
|
||||
.II "reposition cursor"
|
||||
The command
|
||||
.B cursor
|
||||
move the cursor to screen position
|
||||
.I row
|
||||
and
|
||||
.IR column .
|
||||
You can
|
||||
.B cursor
|
||||
and the
|
||||
.B /rdb
|
||||
command
|
||||
.B clear.rdb
|
||||
to perform complex screen handling from within a shell script.
|
||||
You can paint your screen with cursor moves and
|
||||
.B echo
|
||||
commands;
|
||||
then use the
|
||||
.B read
|
||||
command to read the user's input; and finally use various
|
||||
COHERENT and
|
||||
.B /rdb
|
||||
commands to examine and confirm the input.
|
||||
You can also clear fields of the screen by moving the cursor
|
||||
and writing blanks.
|
||||
.PP
|
||||
You must give the row and column you want.
|
||||
.B cursor
|
||||
also needs the cursor movement (\fBcm\fR) entry from file
|
||||
.BR /etc/termcap .
|
||||
This can be given as an argument, but the easiest way
|
||||
is to set up the shell variable called
|
||||
.B CURSOR ;
|
||||
then
|
||||
.B cursor
|
||||
will find it in its environment automatically.
|
||||
To set up the
|
||||
.B CURSOR
|
||||
variable, do the following:
|
||||
.DM
|
||||
CURSOR=`termput cm`
|
||||
.DE
|
||||
.PP
|
||||
.\"On UNIX System 5 Release 2, use
|
||||
.\".B tput:
|
||||
.\".sp
|
||||
.\".nf
|
||||
.\"$ CURSOR=`tput cup`
|
||||
.\".fi
|
||||
.\".sp
|
||||
Another way is to use your text editor to find the entry in
|
||||
.B /etc/termcap
|
||||
and copy its
|
||||
.B cm
|
||||
entry for your terminal to your
|
||||
.BR .profile :
|
||||
.DM
|
||||
CURSOR=^[[%p1%d;%p2%dH
|
||||
.DE
|
||||
.PP
|
||||
This is the entry for the
|
||||
.B pc
|
||||
terminal.
|
||||
The uparrow bracket (^[) is the ESC character (\fB<ctrl-[>\fR).
|
||||
The function
|
||||
.I tgoto
|
||||
function from the
|
||||
.B termcap
|
||||
library
|
||||
converts it into the proper escape string.
|
||||
.SH Example
|
||||
The following moves the cursor to the middle of an 80-by-24 screen:
|
||||
.DM
|
||||
cursor 11 38
|
||||
.DE
|
||||
.SH Speed
|
||||
.B cursor
|
||||
is fast, but there is a much faster way.
|
||||
Set a shell variable like
|
||||
.B L22
|
||||
to move to the 22nd line:
|
||||
.DM
|
||||
L22=`cursor 23 0`
|
||||
.DE
|
||||
.PP
|
||||
Then you can use:
|
||||
.DM
|
||||
echo "$L22$MESSAGE\ec"
|
||||
.DE
|
||||
.PP
|
||||
in your shell programs for a fast cursor movement and to print a message.
|
||||
Note the quotation marks around the messages in case there are
|
||||
special characters.
|
||||
Also note the
|
||||
.IR \ec ,
|
||||
which tells
|
||||
.B echo
|
||||
not to print a carriage return.
|
||||
.\"In older versions of UNIX
|
||||
.\"it is
|
||||
.\".I -n
|
||||
.\"instead of
|
||||
.\".I \ec.
|
||||
.PP
|
||||
An even better trick is to use the shell feature that tests
|
||||
to see if a variable has been set and only gives it a value
|
||||
when it needs one:
|
||||
.DM
|
||||
echo "${L22:=`cursor 22 0`}$MESSAGE\ec"
|
||||
.DE
|
||||
.PP
|
||||
All of this magic causes the shell to check if
|
||||
.B L22
|
||||
has a value.
|
||||
If not, it executes the
|
||||
.B cursor
|
||||
command and assigns the value to
|
||||
.B L22.
|
||||
Then, if this line is called in a loop, the next time the
|
||||
value will have been set and will be about 20 times faster.
|
||||
.SH "See Also"
|
||||
.B
|
||||
termput
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
\&.profile,
|
||||
termcap
|
||||
.R
|
||||
Reference in New Issue
Block a user