pcvt 3.0, with some performance enhancements by Joerg Wunsch and me.
This commit is contained in:
parent
c461cc3066
commit
22fac0402f
|
@ -0,0 +1,214 @@
|
|||
.\" Copyright (c) 1992,1993,1994 Hellmuth Michaelis and Joerg Wunsch
|
||||
.\"
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by
|
||||
.\" Hellmuth Michaelis and Joerg Wunsch
|
||||
.\" 4. The name authors may not be used to endorse or promote products
|
||||
.\" derived from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)scon.1, 3.00, Last Edit-Date: [Mon Jan 10 21:30:48 1994]
|
||||
.\"
|
||||
.Dd December 31, 1993
|
||||
.Dt SCON 1
|
||||
.Sh NAME
|
||||
.Nm scon
|
||||
.Nd controls screen modes for pcvt video driver
|
||||
.Sh SYNOPSIS
|
||||
.Nm scon
|
||||
.Op Fl a
|
||||
.Op Fl c Ar screenno
|
||||
.Op Fl d Ar device
|
||||
.Op Fl f Ar on|off
|
||||
.Op Fl h
|
||||
.Op Fl H
|
||||
.Op Fl l
|
||||
.Op Fl m
|
||||
.Op Fl v
|
||||
.Op Fl V
|
||||
.Op Fl s Ar lines
|
||||
.br
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Op Fl d Ar device
|
||||
.Fl p Ar entry,red,green,blue
|
||||
.br
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Op Fl d Ar device
|
||||
.Fl p Ar default
|
||||
.br
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Op Fl d Ar device
|
||||
.Fl p Ar list
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Fl t Ar timeout
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Fl 1 | Fl 8
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm scon
|
||||
utility controls several aspects of the runtime behaviour of the pcvt vt220
|
||||
driver.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl a
|
||||
Returns a string describing the video adaptor found by pcvt, the string
|
||||
returned could be MDA, HGC, CGA, EGA, VGA or UNKNOWN.
|
||||
.It Fl c
|
||||
Specify the screen number the current (displayed) screen should be switched
|
||||
to.
|
||||
.It Fl d
|
||||
Specify the device filename (i.e. /dev/ttyv2) further operations specified on
|
||||
the command line should be applied to.
|
||||
.It Fl f
|
||||
Some programs which silently assume 24 lines when they run on a VT220 show
|
||||
incorrent behaviour when the terminal has really 25 lines. To support full
|
||||
VT220 behaviour, it is possible to force pcvt to select only 24 lines when
|
||||
it is running in 25-lines pure VT mode and/or in 28-lines HP-mode. The
|
||||
.Fl f
|
||||
option requires one additional parameter, the string 'on' or 'off' to switch
|
||||
this mode for a virtual screen on or off respectively. This mode has no effect
|
||||
if any other vertical resolutions are selected than the two above mentioned.
|
||||
.It Fl h
|
||||
Prints a usage/help text.
|
||||
.It Fl l
|
||||
Lists the current configuration of runtime changable options and fixed
|
||||
parameters (such as the type of the adaptor, and in case of a VGA adaptor,
|
||||
the Manufacturer, Chipset and 132 column support) of the output portion
|
||||
of the pcvt driver.
|
||||
.It Fl m
|
||||
Returns a string describing the connected display monitor type found by pcvt,
|
||||
the string returned can be MONO, COLOR or UNKNOWN.
|
||||
.It Fl v
|
||||
Specify verbose operation of the program.
|
||||
.It Fl V
|
||||
Switch the specified/current screen into a pure VT220 mode without recognizing
|
||||
any HP escape sequences and without displaying function key labels.
|
||||
.It Fl H
|
||||
Switch the specified/current screen into a mixed HP/VT220 mode. That is, that
|
||||
in addition to the full VT220 emulation, the HP function key labels and the
|
||||
escape sequences for handling the labels are available to the user.
|
||||
.It Fl s
|
||||
Specify the number of character lines on the screen. Possible parameters are
|
||||
25, 28, 35, 40, 43 or 50. To use all this screen sizes, the fonts required
|
||||
for proper operation of a desired size have to be downloaded to the EGA/VGA
|
||||
font ram. This option is available only for EGA and VGA boards.
|
||||
.It Fl p
|
||||
Modify VGA palette
|
||||
.Pq DAC .
|
||||
The
|
||||
.Fl p
|
||||
is mutually exclusive with
|
||||
.Fl s ,
|
||||
.Fl H ,
|
||||
and
|
||||
.Fl V .
|
||||
Naturally, option
|
||||
.Fl p
|
||||
is available only for VGA boards. Three flavors are available.
|
||||
|
||||
If used with argument
|
||||
.Dq Ar default ,
|
||||
this flag will restore the default palette
|
||||
.Po
|
||||
as installed by VGA ROM BIOS after hardware reset
|
||||
.Pc .
|
||||
|
||||
If used with argument
|
||||
.Dq Ar list ,
|
||||
the current VGA DAC palette entries are listed. Each entry contains
|
||||
the table index, values for red, green, and blue, and if there's a
|
||||
known name for this entry, the color name. Trailing empty table
|
||||
slots (RGB values all zero) are omitted.
|
||||
|
||||
Otherwise, four comma-separated arguments are expected. The first
|
||||
denotes the number of palette entry to be modified. This may be either
|
||||
a number between 0 and 255, or the usual name of an associated color
|
||||
.Pq case-insensitive .
|
||||
The following values for red, green and blue are restricted to 0 through 63
|
||||
due to VGA DAC conventions.
|
||||
Note that the first delimiter within such an argument may be a colon
|
||||
.Dq \&:
|
||||
instead of a comma
|
||||
.Dq \&,
|
||||
for better readability, but this violates common command argument
|
||||
conventions.
|
||||
Multiple
|
||||
.Fl p
|
||||
options may be specified if unambiguous.
|
||||
.It Fl t
|
||||
Specifying
|
||||
.Fl t
|
||||
will activate the screen saver. The behaviour depends on
|
||||
.Ar timeout :
|
||||
if
|
||||
.Ar timeout
|
||||
is given as 0, the screen saver is turned off. Otherwise,
|
||||
.Ar timeout
|
||||
is taken as a number of seconds to wait until activating the
|
||||
screen saver.
|
||||
NOTE: the
|
||||
.Fl t
|
||||
option is only available if screen saver support has been compiled into
|
||||
the driver !
|
||||
.It Fl 1
|
||||
Sets 132 columns mode
|
||||
.Pq only available on VGA adaptors .
|
||||
.It Fl 8
|
||||
Sets 80 columns mode.
|
||||
.El
|
||||
.Pp
|
||||
When switching between HP and VT mode, when switching the force 24 lines
|
||||
mode on and off, or when switching between 80 and 132 columns operation,
|
||||
the screen is cleared, the scrolling
|
||||
region is reset and the cursor is placed in the home position.
|
||||
.Sh EXAMPLES
|
||||
The command
|
||||
.Dq Li scon Fl H s Ar 28
|
||||
places the current screen into HP mode and sets the screen size to 28x80.
|
||||
|
||||
Invoking
|
||||
.Do
|
||||
.Li scon Fl p
|
||||
.Ar lightgray,0,15,0
|
||||
.Fl p
|
||||
.Ar 0:45,45,45
|
||||
.Dc
|
||||
will result in green on gray output for normal text.
|
||||
Note that normal text color is light gray, and not white as one might expect.
|
||||
.Sh BUGS
|
||||
the
|
||||
.Fl c
|
||||
and
|
||||
.Fl d
|
||||
options collide somehow, this will change in a future release.
|
||||
.Sh SEE ALSO
|
||||
.Xr loadfont 1 ,
|
||||
.Xr cursor 1 ,
|
||||
.Xr pcvt 8
|
|
@ -0,0 +1,131 @@
|
|||
.TH VT220 1
|
||||
.UC 4
|
||||
.SH NAME
|
||||
vt220 \- define SHIFTED function keys on VT220 terminal
|
||||
.SH SYNTAX
|
||||
.B vt220
|
||||
[
|
||||
.B \-cil
|
||||
]
|
||||
[ keyname keystring ] ...
|
||||
.SH DESCRIPTION
|
||||
.I Vt220
|
||||
sets up a "vt220 terminal" in vt200 mode to allow user
|
||||
definition of the SHIFTED function keys. Each
|
||||
\f2keyname\f1 specified on the command line will be loaded with
|
||||
the corresponding \f2keystring\f1.
|
||||
A \f2keyname\f1 is one of the following "words":
|
||||
F6 F7 F8 F9 F10 F11 ESC F12 BS F13 LF F14 HELP DO F17 F18 F19 F20.
|
||||
\f2Keystrings\f1
|
||||
must be quoted if spaces, tabs, or shell metacharacters are included.
|
||||
.PP
|
||||
.B Vt220
|
||||
expects to receive some combination of option flags and/or
|
||||
argument pair(s), otherwised an usage message
|
||||
is printed.
|
||||
.PP
|
||||
The options are:
|
||||
.TP
|
||||
.B \-c
|
||||
Clears all SHIFTED function key definitions before setting them to user
|
||||
defined strings.
|
||||
.TP
|
||||
.B \-i
|
||||
Read the initialization file
|
||||
.I $HOME/.vt220rc
|
||||
for SHIFTED function key definitions. This is done before any
|
||||
argument pair specified on the command line is processed.
|
||||
Each line in the file must consist of two fields (separated by spaces
|
||||
or tabs) where the first field is the
|
||||
\f2keyname\f1 and the second field is the \f2keystring\f1.
|
||||
The second field extends to the end of the line, thus a
|
||||
\f2keystring\f1
|
||||
may include spaces or tabs. A newline (return) may be specified
|
||||
within the string by using the C Language notation for newline (\\n).
|
||||
.TP
|
||||
.B \-l
|
||||
Locks the function keys from further definition.
|
||||
Locking occurs after processing the initialization file (if the "i"
|
||||
option is specified) and any argument
|
||||
pairs.
|
||||
The only way
|
||||
to unlock is by turning the power off.
|
||||
.SH EXAMPLES
|
||||
vt220 -ci
|
||||
.br
|
||||
vt220 F6 'nroff -ms '
|
||||
.br
|
||||
vt220 -i F20 'cc -O -c '
|
||||
.br
|
||||
vt220 -l HELP man
|
||||
.SH "OTHER FEATURES"
|
||||
Pressing the function keys without using the shift key, generates
|
||||
a string of characters. With
|
||||
\f2csh\f1(1) this string can be aliased to some command. For example:
|
||||
.br
|
||||
alias ^[[17~ "ls -CR | more"
|
||||
.br
|
||||
where ^[[17~ is what is generated by pressing the F6 key. Therefore
|
||||
F6 can perform two commands, depending if pressed with/without the SHIFT
|
||||
key.
|
||||
.PP
|
||||
.B Vt220
|
||||
can be called from your .login or .profile file. Typically an user
|
||||
will create a initialization file and include a line like
|
||||
.br
|
||||
vt220 -ci
|
||||
.br
|
||||
OR
|
||||
.br
|
||||
vt220 -cil
|
||||
.br
|
||||
in the above mentioned files. This way the SHIFTED function keys
|
||||
will be set to your favorite commands when logging in.
|
||||
.SH CAVEATS
|
||||
If the SHIFTED function keys are unlocked, redefinition of a SHIFTED
|
||||
function key will rewrite the old string.
|
||||
.PP
|
||||
There are 256 bytes available for the SHIFTED function keys. Space is
|
||||
supplied on a first-come/first-serve basis. After the 256 bytes are
|
||||
used, you can't define any more keys unless space is cleared. This
|
||||
can be done by redefining a key to contain a string of fewer bytes.
|
||||
.PP
|
||||
All key definitions are stored in volatile RAM, and are lost when
|
||||
terminal power is lost.
|
||||
.PP
|
||||
The ESC key (unshifted) no longer generates the proper escape character. This
|
||||
is of particular importance since many editors require use of the
|
||||
ESC key. Here are some available alternatives:
|
||||
.sp
|
||||
.in +.5i
|
||||
The escape character can be generated by typing ^[ (control-[).
|
||||
.sp
|
||||
Use
|
||||
.B vt220
|
||||
as follows (note ^[ is control-[)
|
||||
.br
|
||||
.in +.5i
|
||||
vt220 ESC '^['
|
||||
.in
|
||||
.br
|
||||
This will require you
|
||||
to press the SHIFT key and ESC to generate the escape sequence.
|
||||
.sp
|
||||
Some editors, allow other character(s) to be substituted for the
|
||||
escape character. For example with
|
||||
.B emacs
|
||||
include this line in your .emacs_pro:
|
||||
.br
|
||||
(bind-to-key "ESC-prefix" "\\033[23~")
|
||||
.br
|
||||
Thus when the ESC key is pressed, emacs will allow the characters
|
||||
generated (^[[23~) to perform the same function as the escape
|
||||
character.
|
||||
.in
|
||||
.SH FILES
|
||||
$HOME/.vt220rc \- initialization file
|
||||
.SH "SEE ALSO"
|
||||
VT220 Programmer Reference Manual
|
||||
.br
|
||||
VT220 Programmer Pocket Guide
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
.TH VTTEST 1 "LOCAL"
|
||||
.SH NAME
|
||||
vttest \- test VT100-type terminal
|
||||
.SH SYNOPSIS
|
||||
.B vttest
|
||||
.SH DESCRIPTION
|
||||
.I Vttest
|
||||
is a program designed to test the functionality of a VT100 terminal
|
||||
(or emulator thereof).
|
||||
It tests both display (escape sequence handling) and keyboard.
|
||||
.PP
|
||||
The program is menu\-driven and contains full on\-line operating
|
||||
instructions.
|
|
@ -0,0 +1,133 @@
|
|||
.\"
|
||||
.\" Copyright (c) 1994 Joerg Wunsch
|
||||
.\"
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This program is free software.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by Joerg Wunsch
|
||||
.\" 4. The name of the developer may not be used to endorse or promote
|
||||
.\" products derived from this software without specific prior written
|
||||
.\" permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Header: /cvsroot/src/share/man/man8/man8.i386/Attic/vgaio.8,v 1.1 1994/03/29 02:47:23 mycroft Exp $
|
||||
.\"
|
||||
.Dd January 8, 1994
|
||||
.Dt VGAIO 8
|
||||
.Sh NAME
|
||||
.Nm vgaio
|
||||
.Nd perform input/output on a Video Graphics Array
|
||||
.Sh SYNOPSIS
|
||||
.Nm vgaio
|
||||
.Op Fl d
|
||||
.Sh DESCRIPTION
|
||||
.Ss Purpose
|
||||
.Nm Vgaio
|
||||
is used to perform register-level input/output on a Video Graphics Array.
|
||||
Since some of the sequences required to access those registers are very
|
||||
silly,
|
||||
.Nm vgaio
|
||||
cares of all the things necessary and allows the user to access the
|
||||
registers of several register groups with their symbolic names.
|
||||
|
||||
.Ss Options
|
||||
.Bl -tag -width 10n -offset indent
|
||||
.It Fl d
|
||||
Turn on the grammar parser debugger.
|
||||
|
||||
.El
|
||||
.Ss Command language
|
||||
The command language of
|
||||
.Nm
|
||||
constitutes of some very simple tokens and rules. Commands are executed
|
||||
line by line as they are entered. Each line may contain any number of
|
||||
semicolon-separated input/output commands.
|
||||
|
||||
Symbolic register names look like:
|
||||
|
||||
.D1 Ao Em reggroup Ac Ao Em regnumber Ac
|
||||
|
||||
with
|
||||
.Aq Em regnumber
|
||||
being any hexadecimal number
|
||||
.Pq without a leading Em 0x ,
|
||||
and
|
||||
.Aq Em reggroup
|
||||
one of the strings
|
||||
.Dq Em ar ,
|
||||
.Dq Em cr ,
|
||||
.Dq Em gr ,
|
||||
or
|
||||
.Dq Em sr ,
|
||||
standing for the
|
||||
.Em Attribute controller ,
|
||||
.Em CRT controller ,
|
||||
.Em Graphics controller ,
|
||||
or
|
||||
.Em Timing sequencer ,
|
||||
respectively.
|
||||
|
||||
An input instruction has the form
|
||||
|
||||
.D1 Ao Em regname Ac ?
|
||||
|
||||
and will cause
|
||||
.Nm
|
||||
to output a line like
|
||||
|
||||
.Bd -ragged -offset indent
|
||||
.Ao Em regname Ac \& = 0x Ns
|
||||
.Aq Em number
|
||||
.Ed
|
||||
|
||||
An output instruction looks like
|
||||
|
||||
.Bd -ragged -offset indent
|
||||
.Ao Em regname Ac =
|
||||
.Aq Em number
|
||||
.Ed
|
||||
|
||||
Spaces or Tabs between the
|
||||
.Aq Em reggroup ,
|
||||
the
|
||||
.Aq Em regnumber ,
|
||||
or any of the other tokens are ignored. They are not required anyway.
|
||||
|
||||
.Ss Access control
|
||||
The caller must have uid 0 in order to gain the required access to
|
||||
the IO registers.
|
||||
|
||||
.Sh HISTORY
|
||||
This program is considered
|
||||
.Dq hackware .
|
||||
It has been developed in order to simplify the process of developing other
|
||||
software that needs to program the Video Graphics Array.
|
||||
|
||||
.Sh AUTHOR
|
||||
The program has been contributed by
|
||||
.if n Joerg Wunsch,
|
||||
.if t J\(:org Wunsch,
|
||||
Dresden
|
||||
.Aq joerg_wunsch@uriah.sax.de .
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
* Copyright (c) 1994 Joerg Wunsch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Joerg Wunsch
|
||||
* 4. The name authors may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* @(#)mcon.c, 3.00, Last Edit-Date: [Mon Jan 10 21:29:33 1994]
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
*
|
||||
* history:
|
||||
*
|
||||
* -jw initial version; includes a basic mapping between PeeCee
|
||||
* scan codes and key names
|
||||
* -hm changed sys/pcvt_ioctl.h -> machine/pcvt_ioctl.h
|
||||
*
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Utility program to wire the mouse emulator control ioctl to the
|
||||
* user level. Allows setting of any configurable parameter, or
|
||||
* display the current configuration.
|
||||
*/
|
||||
|
||||
#include <machine/pcvt_ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
static const char *keynames[] = {
|
||||
"", "esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
|
||||
"-", "+", "bksp", "tab", "q", "w", "e", "r", "t", "y", "u",
|
||||
"i", "o", "p", "[", "]", "enter", "ctrl", "a", "s", "d", "f",
|
||||
"g", "h", "j", "k", "l", ";", "\"", "`", "lshift", "\\",
|
||||
"z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "rshift",
|
||||
"prtscr", "alt", "space", "caps", "f1", "f2", "f3", "f4",
|
||||
"f5", "f6", "f7", "f8", "f9", "f10", "numlock", "scrolllock",
|
||||
"kp7", "kp8", "kp9", "kp-", "kp4", "kp5", "kp6", "kp+",
|
||||
"kp1", "kp2", "kp3", "kp0", "kp."
|
||||
};
|
||||
|
||||
|
||||
const char *scantoname(int scan) {
|
||||
if(scan >= sizeof keynames / sizeof(const char *))
|
||||
return "???";
|
||||
else
|
||||
return keynames[scan];
|
||||
}
|
||||
|
||||
int nametoscan(const char *name) {
|
||||
int i;
|
||||
for(i = 0; i < sizeof keynames / sizeof(const char *); i++)
|
||||
if(strcmp(keynames[i], name) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int c, errs = 0, fd, do_set = 0;
|
||||
int left = 0, mid = 0, right = 0, accel = 0, sticky = -1;
|
||||
struct mousedefs mdef;
|
||||
|
||||
while((c = getopt(argc, argv, "l:m:r:a:s:")) != EOF)
|
||||
switch(c) {
|
||||
case 'l':
|
||||
left = nametoscan(optarg);
|
||||
do_set = 1;
|
||||
if(left == -1) goto keynameerr;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
mid = nametoscan(optarg);
|
||||
do_set = 1;
|
||||
if(mid == -1) goto keynameerr;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
right = nametoscan(optarg);
|
||||
do_set = 1;
|
||||
if(right == -1) goto keynameerr;
|
||||
break;
|
||||
|
||||
keynameerr:
|
||||
{
|
||||
fprintf(stderr, "unknown key name: %s\n",
|
||||
optarg);
|
||||
errs++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
accel = 1000 * strtol(optarg, 0, 10);
|
||||
do_set = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if(strcmp(optarg, "0") == 0
|
||||
|| strcmp(optarg, "false") == 0
|
||||
|| strcmp(optarg, "no") == 0)
|
||||
sticky = 0;
|
||||
else if(strcmp(optarg, "1") == 0
|
||||
|| strcmp(optarg, "true") == 0
|
||||
|| strcmp(optarg, "yes") == 0)
|
||||
sticky = 1;
|
||||
else {
|
||||
fprintf(stderr, "invalid argument to -s: %s\n",
|
||||
optarg);
|
||||
errs++;
|
||||
}
|
||||
do_set = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
errs++;
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if(errs || argc != 1) {
|
||||
fprintf(stderr, "usage: "
|
||||
"mouse [-l key][-m key][-r key][-a acctime][-s 0|1] "
|
||||
"mousedev\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if((fd = open(argv[0], O_RDONLY)) < 0) {
|
||||
perror("open(mousedev)");
|
||||
return 2;
|
||||
}
|
||||
if(ioctl(fd, KBDMOUSEGET, &mdef) < 0) {
|
||||
perror("ioctl(KBDMOUSEGET)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!do_set) {
|
||||
printf("Current mouse emulator definitions:\n"
|
||||
"left button: %s\n"
|
||||
"middle button: %s\n"
|
||||
"right button: %s\n"
|
||||
"acceleration limit: %d msec\n"
|
||||
"sticky buttons: %s\n",
|
||||
scantoname(mdef.leftbutton),
|
||||
scantoname(mdef.middlebutton),
|
||||
scantoname(mdef.rightbutton),
|
||||
mdef.acceltime / 1000,
|
||||
mdef.stickybuttons? "yes": "no");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(left) mdef.leftbutton = left & 0x7f;
|
||||
if(mid) mdef.middlebutton = mid & 0x7f;
|
||||
if(right) mdef.rightbutton = right & 0x7f;
|
||||
|
||||
if(accel) mdef.acceltime = accel;
|
||||
if(sticky != -1) mdef.stickybuttons = sticky;
|
||||
|
||||
if(ioctl(fd, KBDMOUSESET, &mdef) < 0) {
|
||||
perror("ioctl(KBDMOUSESET)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
.if !exists(${.CURDIR}/../Makefile.inc)
|
||||
error:
|
||||
@echo
|
||||
@echo " You MUST link/copy"
|
||||
@echo
|
||||
@echo " ../Makefile.inc.NetBSD or ../Makefile.inc.FreeBSD"
|
||||
@echo
|
||||
@echo " to ../Makefile.inc before you can proceed !"
|
||||
@echo
|
||||
.else
|
||||
|
||||
PROG = scon
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
$(PROG): $(INCDIR)/pcvt_ioctl.h
|
||||
|
||||
.endif
|
|
@ -0,0 +1,214 @@
|
|||
.\" Copyright (c) 1992,1993,1994 Hellmuth Michaelis and Joerg Wunsch
|
||||
.\"
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by
|
||||
.\" Hellmuth Michaelis and Joerg Wunsch
|
||||
.\" 4. The name authors may not be used to endorse or promote products
|
||||
.\" derived from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)scon.1, 3.00, Last Edit-Date: [Mon Jan 10 21:30:48 1994]
|
||||
.\"
|
||||
.Dd December 31, 1993
|
||||
.Dt SCON 1
|
||||
.Sh NAME
|
||||
.Nm scon
|
||||
.Nd controls screen modes for pcvt video driver
|
||||
.Sh SYNOPSIS
|
||||
.Nm scon
|
||||
.Op Fl a
|
||||
.Op Fl c Ar screenno
|
||||
.Op Fl d Ar device
|
||||
.Op Fl f Ar on|off
|
||||
.Op Fl h
|
||||
.Op Fl H
|
||||
.Op Fl l
|
||||
.Op Fl m
|
||||
.Op Fl v
|
||||
.Op Fl V
|
||||
.Op Fl s Ar lines
|
||||
.br
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Op Fl d Ar device
|
||||
.Fl p Ar entry,red,green,blue
|
||||
.br
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Op Fl d Ar device
|
||||
.Fl p Ar default
|
||||
.br
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Op Fl d Ar device
|
||||
.Fl p Ar list
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Fl t Ar timeout
|
||||
.Nm scon
|
||||
.Op Fl v
|
||||
.Fl 1 | Fl 8
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm scon
|
||||
utility controls several aspects of the runtime behaviour of the pcvt vt220
|
||||
driver.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl a
|
||||
Returns a string describing the video adaptor found by pcvt, the string
|
||||
returned could be MDA, HGC, CGA, EGA, VGA or UNKNOWN.
|
||||
.It Fl c
|
||||
Specify the screen number the current (displayed) screen should be switched
|
||||
to.
|
||||
.It Fl d
|
||||
Specify the device filename (i.e. /dev/ttyv2) further operations specified on
|
||||
the command line should be applied to.
|
||||
.It Fl f
|
||||
Some programs which silently assume 24 lines when they run on a VT220 show
|
||||
incorrent behaviour when the terminal has really 25 lines. To support full
|
||||
VT220 behaviour, it is possible to force pcvt to select only 24 lines when
|
||||
it is running in 25-lines pure VT mode and/or in 28-lines HP-mode. The
|
||||
.Fl f
|
||||
option requires one additional parameter, the string 'on' or 'off' to switch
|
||||
this mode for a virtual screen on or off respectively. This mode has no effect
|
||||
if any other vertical resolutions are selected than the two above mentioned.
|
||||
.It Fl h
|
||||
Prints a usage/help text.
|
||||
.It Fl l
|
||||
Lists the current configuration of runtime changable options and fixed
|
||||
parameters (such as the type of the adaptor, and in case of a VGA adaptor,
|
||||
the Manufacturer, Chipset and 132 column support) of the output portion
|
||||
of the pcvt driver.
|
||||
.It Fl m
|
||||
Returns a string describing the connected display monitor type found by pcvt,
|
||||
the string returned can be MONO, COLOR or UNKNOWN.
|
||||
.It Fl v
|
||||
Specify verbose operation of the program.
|
||||
.It Fl V
|
||||
Switch the specified/current screen into a pure VT220 mode without recognizing
|
||||
any HP escape sequences and without displaying function key labels.
|
||||
.It Fl H
|
||||
Switch the specified/current screen into a mixed HP/VT220 mode. That is, that
|
||||
in addition to the full VT220 emulation, the HP function key labels and the
|
||||
escape sequences for handling the labels are available to the user.
|
||||
.It Fl s
|
||||
Specify the number of character lines on the screen. Possible parameters are
|
||||
25, 28, 35, 40, 43 or 50. To use all this screen sizes, the fonts required
|
||||
for proper operation of a desired size have to be downloaded to the EGA/VGA
|
||||
font ram. This option is available only for EGA and VGA boards.
|
||||
.It Fl p
|
||||
Modify VGA palette
|
||||
.Pq DAC .
|
||||
The
|
||||
.Fl p
|
||||
is mutually exclusive with
|
||||
.Fl s ,
|
||||
.Fl H ,
|
||||
and
|
||||
.Fl V .
|
||||
Naturally, option
|
||||
.Fl p
|
||||
is available only for VGA boards. Three flavors are available.
|
||||
|
||||
If used with argument
|
||||
.Dq Ar default ,
|
||||
this flag will restore the default palette
|
||||
.Po
|
||||
as installed by VGA ROM BIOS after hardware reset
|
||||
.Pc .
|
||||
|
||||
If used with argument
|
||||
.Dq Ar list ,
|
||||
the current VGA DAC palette entries are listed. Each entry contains
|
||||
the table index, values for red, green, and blue, and if there's a
|
||||
known name for this entry, the color name. Trailing empty table
|
||||
slots (RGB values all zero) are omitted.
|
||||
|
||||
Otherwise, four comma-separated arguments are expected. The first
|
||||
denotes the number of palette entry to be modified. This may be either
|
||||
a number between 0 and 255, or the usual name of an associated color
|
||||
.Pq case-insensitive .
|
||||
The following values for red, green and blue are restricted to 0 through 63
|
||||
due to VGA DAC conventions.
|
||||
Note that the first delimiter within such an argument may be a colon
|
||||
.Dq \&:
|
||||
instead of a comma
|
||||
.Dq \&,
|
||||
for better readability, but this violates common command argument
|
||||
conventions.
|
||||
Multiple
|
||||
.Fl p
|
||||
options may be specified if unambiguous.
|
||||
.It Fl t
|
||||
Specifying
|
||||
.Fl t
|
||||
will activate the screen saver. The behaviour depends on
|
||||
.Ar timeout :
|
||||
if
|
||||
.Ar timeout
|
||||
is given as 0, the screen saver is turned off. Otherwise,
|
||||
.Ar timeout
|
||||
is taken as a number of seconds to wait until activating the
|
||||
screen saver.
|
||||
NOTE: the
|
||||
.Fl t
|
||||
option is only available if screen saver support has been compiled into
|
||||
the driver !
|
||||
.It Fl 1
|
||||
Sets 132 columns mode
|
||||
.Pq only available on VGA adaptors .
|
||||
.It Fl 8
|
||||
Sets 80 columns mode.
|
||||
.El
|
||||
.Pp
|
||||
When switching between HP and VT mode, when switching the force 24 lines
|
||||
mode on and off, or when switching between 80 and 132 columns operation,
|
||||
the screen is cleared, the scrolling
|
||||
region is reset and the cursor is placed in the home position.
|
||||
.Sh EXAMPLES
|
||||
The command
|
||||
.Dq Li scon Fl H s Ar 28
|
||||
places the current screen into HP mode and sets the screen size to 28x80.
|
||||
|
||||
Invoking
|
||||
.Do
|
||||
.Li scon Fl p
|
||||
.Ar lightgray,0,15,0
|
||||
.Fl p
|
||||
.Ar 0:45,45,45
|
||||
.Dc
|
||||
will result in green on gray output for normal text.
|
||||
Note that normal text color is light gray, and not white as one might expect.
|
||||
.Sh BUGS
|
||||
the
|
||||
.Fl c
|
||||
and
|
||||
.Fl d
|
||||
options collide somehow, this will change in a future release.
|
||||
.Sh SEE ALSO
|
||||
.Xr loadfont 1 ,
|
||||
.Xr cursor 1 ,
|
||||
.Xr pcvt 8
|
|
@ -0,0 +1,855 @@
|
|||
/*
|
||||
* Copyright (c) 1992,1993,1994 Hellmuth Michaelis and Joerg Wunsch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by
|
||||
* Hellmuth Michaelis and Joerg Wunsch
|
||||
* 4. The name authors may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
static char *id =
|
||||
"@(#)scon.c, 3.00, Last Edit-Date: [Mon Jan 10 21:31:39 1994]";
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
*
|
||||
* history:
|
||||
*
|
||||
* -hm moving fd for default device from 1 -> 0 for such things
|
||||
* as "scon -p list | more" to be possible
|
||||
* (reported by Gordon L. Burditt, gordon@sneaky.lonestar.org)
|
||||
* -hm adding option "a" for just returning the type of video adaptor
|
||||
* -hm removing explicit HGC support, same as MDA ...
|
||||
* -hm vga type/family/132col support info on -l
|
||||
* -hm force 24 lines in DEC 25 lines mode and HP 28 lines mode
|
||||
* -hm fixed bug with 132 column mode display status display
|
||||
* -jw added 132/80 col mode switching
|
||||
* -hm removed -h flag, use -? now ... ;-)
|
||||
* -hm S3 chipsets ..
|
||||
* -hm Cirrus chipsets support from Onno van der Linden
|
||||
* -hm -m option, display monitor type
|
||||
*
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <machine/pcvt_ioctl.h>
|
||||
|
||||
#define DEFAULTFD 0
|
||||
|
||||
int aflag = -1;
|
||||
int lflag = -1;
|
||||
int mflag = -1;
|
||||
int current = -1;
|
||||
int pflag = -1;
|
||||
int hflag = -1;
|
||||
int res = -1;
|
||||
char *device;
|
||||
int dflag = -1;
|
||||
int vflag = 0;
|
||||
int Pflag = 0;
|
||||
int tflag = 0;
|
||||
int fflag = -1;
|
||||
int colms = 0;
|
||||
char *onoff;
|
||||
|
||||
unsigned timeout;
|
||||
struct screeninfo screeninfo;
|
||||
|
||||
#define NVGAPEL 256
|
||||
|
||||
struct rgb {
|
||||
unsigned r, g, b;
|
||||
int dothis;
|
||||
};
|
||||
|
||||
static struct rgb palette[NVGAPEL] = {
|
||||
{ 0x00, 0x00, 0x00, 0}, /* 0 - black */
|
||||
{ 0x00, 0x00, 0x2a, 0}, /* 1 - blue */
|
||||
{ 0x00, 0x2a, 0x00, 0}, /* 2 - green */
|
||||
{ 0x00, 0x2a, 0x2a, 0}, /* 3 - cyan */
|
||||
{ 0x2a, 0x00, 0x00, 0}, /* 4 - red */
|
||||
{ 0x2a, 0x00, 0x2a, 0}, /* 5 - magenta */
|
||||
{ 0x2a, 0x2a, 0x00, 0}, /* 6 */
|
||||
{ 0x2a, 0x2a, 0x2a, 0}, /* 7 - lightgray */
|
||||
{ 0x00, 0x00, 0x15, 0}, /* 8 */
|
||||
{ 0x00, 0x00, 0x3f, 0}, /* 9 */
|
||||
{ 0x00, 0x2a, 0x15, 0}, /* 10 */
|
||||
{ 0x00, 0x2a, 0x3f, 0}, /* 11 */
|
||||
{ 0x2a, 0x00, 0x15, 0}, /* 12 */
|
||||
{ 0x2a, 0x00, 0x3f, 0}, /* 13 */
|
||||
{ 0x2a, 0x2a, 0x15, 0}, /* 14 */
|
||||
{ 0x2a, 0x2a, 0x3f, 0}, /* 15 */
|
||||
{ 0x00, 0x15, 0x00, 0}, /* 16 */
|
||||
{ 0x00, 0x15, 0x2a, 0}, /* 17 */
|
||||
{ 0x00, 0x3f, 0x00, 0}, /* 18 */
|
||||
{ 0x00, 0x3f, 0x2a, 0}, /* 19 */
|
||||
{ 0x2a, 0x15, 0x00, 0}, /* 20 - brown */
|
||||
{ 0x2a, 0x15, 0x2a, 0}, /* 21 */
|
||||
{ 0x2a, 0x3f, 0x00, 0}, /* 22 */
|
||||
{ 0x2a, 0x3f, 0x2a, 0}, /* 23 */
|
||||
{ 0x00, 0x15, 0x15, 0}, /* 24 */
|
||||
{ 0x00, 0x15, 0x3f, 0}, /* 25 */
|
||||
{ 0x00, 0x3f, 0x15, 0}, /* 26 */
|
||||
{ 0x00, 0x3f, 0x3f, 0}, /* 27 */
|
||||
{ 0x2a, 0x15, 0x15, 0}, /* 28 */
|
||||
{ 0x2a, 0x15, 0x3f, 0}, /* 29 */
|
||||
{ 0x2a, 0x3f, 0x15, 0}, /* 30 */
|
||||
{ 0x2a, 0x3f, 0x3f, 0}, /* 31 */
|
||||
{ 0x15, 0x00, 0x00, 0}, /* 32 */
|
||||
{ 0x15, 0x00, 0x2a, 0}, /* 33 */
|
||||
{ 0x15, 0x2a, 0x00, 0}, /* 34 */
|
||||
{ 0x15, 0x2a, 0x2a, 0}, /* 35 */
|
||||
{ 0x3f, 0x00, 0x00, 0}, /* 36 */
|
||||
{ 0x3f, 0x00, 0x2a, 0}, /* 37 */
|
||||
{ 0x3f, 0x2a, 0x00, 0}, /* 38 */
|
||||
{ 0x3f, 0x2a, 0x2a, 0}, /* 39 */
|
||||
{ 0x15, 0x00, 0x15, 0}, /* 40 */
|
||||
{ 0x15, 0x00, 0x3f, 0}, /* 41 */
|
||||
{ 0x15, 0x2a, 0x15, 0}, /* 42 */
|
||||
{ 0x15, 0x2a, 0x3f, 0}, /* 43 */
|
||||
{ 0x3f, 0x00, 0x15, 0}, /* 44 */
|
||||
{ 0x3f, 0x00, 0x3f, 0}, /* 45 */
|
||||
{ 0x3f, 0x2a, 0x15, 0}, /* 46 */
|
||||
{ 0x3f, 0x2a, 0x3f, 0}, /* 47 */
|
||||
{ 0x15, 0x15, 0x00, 0}, /* 48 */
|
||||
{ 0x15, 0x15, 0x2a, 0}, /* 49 */
|
||||
{ 0x15, 0x3f, 0x00, 0}, /* 50 */
|
||||
{ 0x15, 0x3f, 0x2a, 0}, /* 51 */
|
||||
{ 0x3f, 0x15, 0x00, 0}, /* 52 */
|
||||
{ 0x3f, 0x15, 0x2a, 0}, /* 53 */
|
||||
{ 0x3f, 0x3f, 0x00, 0}, /* 54 */
|
||||
{ 0x3f, 0x3f, 0x2a, 0}, /* 55 */
|
||||
{ 0x15, 0x15, 0x15, 0}, /* 56 - darkgray */
|
||||
{ 0x15, 0x15, 0x3f, 0}, /* 57 - lightblue */
|
||||
{ 0x15, 0x3f, 0x15, 0}, /* 58 - lightgreen */
|
||||
{ 0x15, 0x3f, 0x3f, 0}, /* 59 - lightcyan */
|
||||
{ 0x3f, 0x15, 0x15, 0}, /* 60 - lightred */
|
||||
{ 0x3f, 0x15, 0x3f, 0}, /* 61 - lightmagenta */
|
||||
{ 0x3f, 0x3f, 0x15, 0}, /* 62 - yellow */
|
||||
{ 0x3f, 0x3f, 0x3f, 0}, /* 63 - white */
|
||||
{ 0x00, 0x00, 0x00, 0} /* 64 ... - empty */
|
||||
};
|
||||
|
||||
static struct colname {
|
||||
const char *name;
|
||||
unsigned idx;
|
||||
} colnames[] = {
|
||||
{"black", 0},
|
||||
{"blue", 1},
|
||||
{"green", 2},
|
||||
{"cyan", 3},
|
||||
{"red", 4},
|
||||
{"magenta", 5},
|
||||
{"brown", 20},
|
||||
{"lightgray", 7},
|
||||
{"lightgrey", 7},
|
||||
{"darkgray", 56},
|
||||
{"darkgrey", 56},
|
||||
{"lightblue", 57},
|
||||
{"lightgreen", 58},
|
||||
{"lightcyan", 59},
|
||||
{"lightred", 60},
|
||||
{"lightmagenta", 61},
|
||||
{"yellow", 62},
|
||||
{"white", 63},
|
||||
/* must be terminator: */ {(const char *)NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
static void parsepopt(char *arg, unsigned *idx,
|
||||
unsigned *r, unsigned *g, unsigned *b);
|
||||
static void printpalette(int fd);
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
extern int optind;
|
||||
extern int opterr;
|
||||
extern char *optarg;
|
||||
|
||||
int c;
|
||||
int fd;
|
||||
|
||||
while( (c = getopt(argc, argv, "ac:d:f:HVlms:t:vp:18")) != EOF)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case 'a':
|
||||
aflag = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
mflag = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
current = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
device = optarg;
|
||||
dflag = 1;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
onoff = optarg;
|
||||
fflag = 1;
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
pflag = 1;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
hflag = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if (!strncmp(optarg, "25", 2))
|
||||
res = SIZ_25ROWS;
|
||||
else if(!strncmp(optarg, "28", 2))
|
||||
res = SIZ_28ROWS;
|
||||
else if(!strncmp(optarg, "35", 2))
|
||||
res = SIZ_35ROWS;
|
||||
else if(!strncmp(optarg, "40", 2))
|
||||
res = SIZ_40ROWS;
|
||||
else if(!strncmp(optarg, "43", 2))
|
||||
res = SIZ_43ROWS;
|
||||
else if(!strncmp(optarg, "50", 2))
|
||||
res = SIZ_50ROWS;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
vflag++;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if(!strcmp(optarg, "list"))
|
||||
{
|
||||
if(Pflag)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"-p list is mutual exclusive "
|
||||
"with other -p options\n");
|
||||
return 2;
|
||||
}
|
||||
Pflag = 3;
|
||||
}
|
||||
else if(!strcmp(optarg, "default"))
|
||||
{
|
||||
if(Pflag)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"multiple -p default not "
|
||||
"allowed\n");
|
||||
return 2;
|
||||
}
|
||||
Pflag = 2;
|
||||
} else {
|
||||
unsigned idx, r, g, b;
|
||||
|
||||
if(Pflag > 1)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"-p default and -p i,r,g,b "
|
||||
"ambiguous\n");
|
||||
return 2;
|
||||
}
|
||||
Pflag = 1;
|
||||
parsepopt(optarg, &idx, &r, &g, &b);
|
||||
if(idx >= NVGAPEL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"index %u in -p option "
|
||||
"out of range\n", idx);
|
||||
return 2;
|
||||
}
|
||||
palette[idx].r = r;
|
||||
palette[idx].g = g;
|
||||
palette[idx].b = b;
|
||||
palette[idx].dothis = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 't':
|
||||
tflag++;
|
||||
timeout = atoi(optarg);
|
||||
break;
|
||||
|
||||
case '1':
|
||||
colms = 132;
|
||||
break;
|
||||
|
||||
case '8':
|
||||
colms = 80;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if((pflag == 1) && (hflag == 1))
|
||||
usage();
|
||||
|
||||
if(dflag == -1 && lflag == -1 && current == -1 && pflag == -1 &&
|
||||
hflag == -1 && res == -1 && Pflag == 0 && tflag == 0 && fflag == -1
|
||||
&& colms == 0 && mflag == -1)
|
||||
{
|
||||
lflag = 1;
|
||||
}
|
||||
|
||||
if(dflag == -1)
|
||||
{
|
||||
if(vflag)
|
||||
printf("using current device\n");
|
||||
fd = DEFAULTFD; /* -hm, Feb 12 1993 */
|
||||
}
|
||||
else
|
||||
{
|
||||
if((fd = open(device, O_RDWR)) == -1)
|
||||
{
|
||||
char buffer[80];
|
||||
strcpy(buffer,"ERROR opening ");
|
||||
strcat(buffer,device);
|
||||
perror(buffer);
|
||||
exit(1);
|
||||
}
|
||||
if(vflag)
|
||||
printf("using device %s\n",device);
|
||||
}
|
||||
|
||||
if(aflag == 1) /* return adaptor type */
|
||||
{
|
||||
printadaptor(fd);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(mflag == 1) /* return monitor type */
|
||||
{
|
||||
printmonitor(fd);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(lflag == 1) /* list information */
|
||||
{
|
||||
if(vflag)
|
||||
printf("processing option -l, listing screen info\n");
|
||||
printinfo(fd);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(tflag) /* set screen saver timeout */
|
||||
{
|
||||
if(vflag)
|
||||
{
|
||||
printf(
|
||||
"processing option -t, setting screen saver timeout: "
|
||||
);
|
||||
if(timeout)
|
||||
printf("new timeout = %d s\n", timeout);
|
||||
else
|
||||
printf("turned off\n");
|
||||
}
|
||||
|
||||
if(ioctl(fd, VGASCREENSAVER, &timeout) < 0)
|
||||
{
|
||||
perror("ioctl(VGASCREENSAVER)");
|
||||
fprintf(stderr, "Check the driver, the screensaver is probably not compiled in!\n");
|
||||
exit(2);
|
||||
}
|
||||
goto success;
|
||||
}
|
||||
|
||||
if(colms)
|
||||
{
|
||||
if(vflag)
|
||||
printf("Setting number of columns to %d\n", colms);
|
||||
if(ioctl(fd, VGASETCOLMS, &colms) < 0)
|
||||
{
|
||||
perror("ioctl(VGASETCOLMS)");
|
||||
exit(2);
|
||||
}
|
||||
goto success;
|
||||
}
|
||||
|
||||
if(Pflag == 3)
|
||||
{
|
||||
/* listing VGA palette */
|
||||
if(vflag)
|
||||
printf("processing option -p list, "
|
||||
"listing VGA palette\n");
|
||||
|
||||
printpalette(fd);
|
||||
goto success;
|
||||
}
|
||||
|
||||
if(Pflag)
|
||||
{
|
||||
unsigned int idx;
|
||||
|
||||
/* setting VGA palette */
|
||||
if(vflag)
|
||||
printf("processing option -p, setting VGA palette%s\n",
|
||||
Pflag == 2? " to default": "");
|
||||
|
||||
for(idx = 0; idx < NVGAPEL; idx++)
|
||||
if(Pflag == 2 || palette[idx].dothis)
|
||||
{
|
||||
struct vgapel p;
|
||||
p.idx = idx;
|
||||
p.r = palette[idx].r;
|
||||
p.g = palette[idx].g;
|
||||
p.b = palette[idx].b;
|
||||
if(ioctl(fd, VGAWRITEPEL, (caddr_t)&p) < 0)
|
||||
{
|
||||
perror("ioctl(fd, VGAWRITEPEL)");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
goto success;
|
||||
}
|
||||
|
||||
screeninfo.screen_no = -1; /* We are using fd */
|
||||
screeninfo.current_screen = current;
|
||||
screeninfo.pure_vt_mode = -1;
|
||||
screeninfo.screen_size = res;
|
||||
|
||||
if(current != -1) /* set current screen */
|
||||
{
|
||||
if(vflag)
|
||||
printf("processing option -c, setting current screen to %d\n",current);
|
||||
|
||||
|
||||
if(ioctl(1, VGASETSCREEN, &screeninfo) == -1)
|
||||
{
|
||||
perror("ioctl VGASETSCREEN failed");
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(pflag == 1)
|
||||
{
|
||||
if(vflag)
|
||||
printf("processing option -V, setting emulation to pure VT220\n");
|
||||
screeninfo.pure_vt_mode = M_PUREVT;
|
||||
}
|
||||
else if(hflag == 1)
|
||||
{
|
||||
if(vflag)
|
||||
printf("processing option -H, setting emulation to VT220 + HP Labels\n");
|
||||
screeninfo.pure_vt_mode = M_HPVT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(vflag)
|
||||
printf("no change in terminal emulation\n");
|
||||
}
|
||||
|
||||
if(vflag)
|
||||
{
|
||||
if(res == -1)
|
||||
printf("no change in screen resolution\n");
|
||||
else if(res == SIZ_25ROWS)
|
||||
printf("change screen resolution to 25 lines\n");
|
||||
else if(res == SIZ_28ROWS)
|
||||
printf("change screen resolution to 28 lines\n");
|
||||
else if(res == SIZ_35ROWS)
|
||||
printf("change screen resolution to 35 lines\n");
|
||||
else if(res == SIZ_40ROWS)
|
||||
printf("change screen resolution to 40 lines\n");
|
||||
else if(res == SIZ_43ROWS)
|
||||
printf("change screen resolution to 43 lines\n");
|
||||
else if(res == SIZ_50ROWS)
|
||||
printf("change screen resolution to 50 lines\n");
|
||||
}
|
||||
|
||||
if(fflag == 1) /* force 24 lines on/off */
|
||||
{
|
||||
if(!strcmp(onoff, "on"))
|
||||
{
|
||||
fflag = 1;
|
||||
}
|
||||
else if(!strcmp(onoff, "off"))
|
||||
{
|
||||
fflag = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"you must specify 'on' or 'off' with -f option!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
screeninfo.force_24lines = fflag;
|
||||
|
||||
if(ioctl(fd, VGASETSCREEN, &screeninfo) == -1)
|
||||
{
|
||||
perror("ioctl VGASETSCREEN failed");
|
||||
exit(1);
|
||||
}
|
||||
success:
|
||||
if(vflag)
|
||||
printf("successful execution of ioctl VGASETSCREEN!\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr,"\nscon - screen control utility for the pcvt video driver\n");
|
||||
fprintf(stderr,"usage: scon -a -l -m -v -c [n] -d [dev] -f [on|off] -V -H -s [n]\n");
|
||||
fprintf(stderr,"usage: scon -p [default | list | i,r,g,b] | -t [sec] | -1 | -8\n");
|
||||
fprintf(stderr," -a list video adaptor type (MDA,CGA,EGA or VGA)\n");
|
||||
fprintf(stderr," -c <screen no> switch current virtual screen to <screen no>\n");
|
||||
fprintf(stderr," -d <device> set parameters(-V|-H|-s) for virtual device\n");
|
||||
fprintf(stderr," -f <on|off> force 24 lines in VT 25 lines and HP 28 lines mode\n");
|
||||
fprintf(stderr," -H set VT220/HP emulation mode for a virtual screen\n");
|
||||
fprintf(stderr," -l list current parameters for a virtual screen\n");
|
||||
fprintf(stderr," -m report monitor type (MONO/COLOR)\n");
|
||||
fprintf(stderr," -p default set default VGA palette\n");
|
||||
fprintf(stderr," -p list list current VGA palette\n");
|
||||
fprintf(stderr," -p <i,r,g,b> set VGA palette entry i to r/g/b\n");
|
||||
fprintf(stderr," -p <name,r,g,b> set VGA palette entry for color name to r/g/b\n");
|
||||
fprintf(stderr," -s <lines> set 25, 28, 35, 40, 43 or 50 lines for a virtual screen\n");
|
||||
fprintf(stderr," -t <timeout> set screen saver timeout [seconds]\n");
|
||||
fprintf(stderr," -1 set 132 columns mode\n");
|
||||
fprintf(stderr," -8 set 80 columns mode\n");
|
||||
fprintf(stderr," -v verbose mode\n");
|
||||
fprintf(stderr," -V set pure VT220 emulation for a virtual screen\n");
|
||||
fprintf(stderr," -? display help (this message)\n\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printadaptor(fd)
|
||||
int fd;
|
||||
{
|
||||
if(ioctl(fd, VGAGETSCREEN, &screeninfo) == -1)
|
||||
{
|
||||
perror("ioctl VGAGETSCREEN failed");
|
||||
exit(1);
|
||||
}
|
||||
switch(screeninfo.adaptor_type)
|
||||
{
|
||||
default:
|
||||
case UNKNOWN_ADAPTOR:
|
||||
printf("UNKNOWN\n");
|
||||
break;
|
||||
|
||||
case MDA_ADAPTOR:
|
||||
printf("MDA\n");
|
||||
break;
|
||||
|
||||
case CGA_ADAPTOR:
|
||||
printf("CGA\n");
|
||||
break;
|
||||
|
||||
case EGA_ADAPTOR:
|
||||
printf("EGA\n");
|
||||
break;
|
||||
|
||||
case VGA_ADAPTOR:
|
||||
printf("VGA\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printmonitor(fd)
|
||||
int fd;
|
||||
{
|
||||
if(ioctl(fd, VGAGETSCREEN, &screeninfo) == -1)
|
||||
{
|
||||
perror("ioctl VGAGETSCREEN failed");
|
||||
exit(1);
|
||||
}
|
||||
switch(screeninfo.monitor_type)
|
||||
{
|
||||
default:
|
||||
printf("UNKNOWN\n");
|
||||
break;
|
||||
|
||||
case MONITOR_MONO:
|
||||
printf("MONO\n");
|
||||
break;
|
||||
|
||||
case MONITOR_COLOR:
|
||||
printf("COLOR\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char *vga_type(int number)
|
||||
{
|
||||
static char *vga_tab[] = {
|
||||
"Generic VGA",
|
||||
"ET4000",
|
||||
"ET3000",
|
||||
"PVGA1A",
|
||||
"WD90C00",
|
||||
"WD90C10",
|
||||
"WD90C11",
|
||||
"VIDEO 7 VEGA",
|
||||
"VIDEO 7 FAST",
|
||||
"VIDEO 7 VER5",
|
||||
"VIDEO 7 1024I",
|
||||
"Unknown VIDEO 7",
|
||||
"TVGA 8800BR",
|
||||
"TVGA 8800CS",
|
||||
"TVGA 8900B",
|
||||
"TVGA 8900C",
|
||||
"TVGA 8900CL",
|
||||
"TVGA 9000",
|
||||
"TVGA 9100",
|
||||
"TVGA 9200",
|
||||
"Unknown TRIDENT",
|
||||
"S3 80C911",
|
||||
"S3 80C924",
|
||||
"S3 80C801/80C805",
|
||||
"S3 80C928",
|
||||
"Unknown S3",
|
||||
"CL-GD5402",
|
||||
"CL-GD5402r1",
|
||||
"CL-GD5420",
|
||||
"CL-GD5420r1",
|
||||
"CL-GD5422",
|
||||
"CL-GD5424",
|
||||
"CL-GD5426",
|
||||
"CL-GD5428",
|
||||
|
||||
};
|
||||
return(vga_tab[number]);
|
||||
}
|
||||
|
||||
char *vga_family(int number)
|
||||
{
|
||||
static char *vga_tab[] = {
|
||||
"Generic VGA",
|
||||
"Tseng Labs",
|
||||
"Western Digital",
|
||||
"Video Seven",
|
||||
"Trident",
|
||||
"S3 Incorporated",
|
||||
"Cirrus Logic",
|
||||
};
|
||||
return(vga_tab[number]);
|
||||
}
|
||||
|
||||
printinfo(fd)
|
||||
int fd;
|
||||
{
|
||||
if(ioctl(fd, VGAGETSCREEN, &screeninfo) == -1)
|
||||
{
|
||||
perror("ioctl VGAGETSCREEN failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf( "\nVideo Adaptor Type = ");
|
||||
|
||||
switch(screeninfo.adaptor_type)
|
||||
{
|
||||
default:
|
||||
case UNKNOWN_ADAPTOR:
|
||||
printf("UNKNOWN Video Adaptor\n");
|
||||
break;
|
||||
|
||||
case MDA_ADAPTOR:
|
||||
printf("MDA - Monochrome Display Adaptor\n");
|
||||
break;
|
||||
|
||||
case CGA_ADAPTOR:
|
||||
printf("CGA - Color Graphics Adaptor\n");
|
||||
break;
|
||||
|
||||
case EGA_ADAPTOR:
|
||||
printf("EGA - Enhanced Graphics Adaptor\n");
|
||||
break;
|
||||
|
||||
case VGA_ADAPTOR:
|
||||
printf("VGA - Video Graphics Adaptor/Array\n");
|
||||
printf(" VGA Chipset Manufacturer = %s\n",
|
||||
vga_family(screeninfo.vga_family));
|
||||
printf(" VGA Chipset Type = %s\n",
|
||||
vga_type(screeninfo.vga_type));
|
||||
printf(" Support for 132 Column Mode = %s\n",
|
||||
screeninfo.vga_132 ? "Yes" : "No");
|
||||
break;
|
||||
}
|
||||
|
||||
printf( "Display Monitor Type = ");
|
||||
|
||||
switch(screeninfo.monitor_type)
|
||||
{
|
||||
default:
|
||||
printf("UNKNOWN Monitor Type\n");
|
||||
break;
|
||||
|
||||
case MONITOR_MONO:
|
||||
printf("Monochrome Monitor\n");
|
||||
break;
|
||||
|
||||
case MONITOR_COLOR:
|
||||
printf("Color Monitor\n");
|
||||
break;
|
||||
}
|
||||
|
||||
printf( "Number of Downloadable Fonts = %d\n",screeninfo.totalfonts);
|
||||
printf( "Number of Virtual Screens = %d\n",screeninfo.totalscreens);
|
||||
printf( "Info Request Screen Number = %d\n",screeninfo.screen_no);
|
||||
printf( "Current Displayed Screen = %d\n",screeninfo.current_screen);
|
||||
|
||||
if(screeninfo.pure_vt_mode == M_PUREVT)
|
||||
printf( "Terminal Emulation Mode = VT220\n");
|
||||
else
|
||||
printf( "Terminal Emulation Mode = VT220 with HP Features\n");
|
||||
|
||||
printf( "Lines = ");
|
||||
|
||||
switch(screeninfo.screen_size)
|
||||
{
|
||||
case SIZ_25ROWS:
|
||||
printf( "25\n");
|
||||
break;
|
||||
|
||||
case SIZ_28ROWS:
|
||||
printf( "28\n");
|
||||
break;
|
||||
|
||||
case SIZ_35ROWS:
|
||||
printf( "35\n");
|
||||
break;
|
||||
|
||||
case SIZ_40ROWS:
|
||||
printf( "40\n");
|
||||
break;
|
||||
|
||||
case SIZ_43ROWS:
|
||||
printf( "43\n");
|
||||
break;
|
||||
|
||||
case SIZ_50ROWS:
|
||||
printf( "50\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
printf( "UNKNOWN\n");
|
||||
break;
|
||||
}
|
||||
printf( "Force 24 Lines = %s",
|
||||
screeninfo.force_24lines ? "Yes" : "No");
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
static const char *findname(unsigned idx)
|
||||
{
|
||||
/* try to find a name for palette entry idx */
|
||||
/* if multiple names exist, returns first matching */
|
||||
register struct colname *cnp;
|
||||
|
||||
for(cnp = colnames; cnp->name; cnp++)
|
||||
if(cnp->idx == idx)
|
||||
return cnp->name;
|
||||
|
||||
/* not found */
|
||||
return (const char *)NULL;
|
||||
}
|
||||
|
||||
static void printpalette(int fd)
|
||||
{
|
||||
register unsigned idx, last;
|
||||
|
||||
for(idx = 0; idx < NVGAPEL; idx++)
|
||||
{
|
||||
struct vgapel p;
|
||||
p.idx = idx;
|
||||
if(ioctl(fd, VGAREADPEL, &p) < 0)
|
||||
{
|
||||
perror("ioctl(VGAREADPEL)");
|
||||
exit(2);
|
||||
}
|
||||
palette[idx].r = p.r;
|
||||
palette[idx].g = p.g;
|
||||
palette[idx].b = p.b;
|
||||
}
|
||||
|
||||
/* find last non-empty entry */
|
||||
for(last = NVGAPEL - 1; last; last--)
|
||||
if(palette[last].r || palette[last].g || palette[last].b)
|
||||
break;
|
||||
|
||||
if(last != NVGAPEL - 1)
|
||||
last++;
|
||||
|
||||
/* now, everything's collected. print out table */
|
||||
printf("VGA palette status\n");
|
||||
printf("index red green blue name\n");
|
||||
for(idx = 0; idx < last; idx++)
|
||||
{
|
||||
const char *cp;
|
||||
printf("%5d %5d %5d %5d",
|
||||
idx, palette[idx].r, palette[idx].g, palette[idx].b);
|
||||
if(cp = findname(idx))
|
||||
printf(" %s\n", cp);
|
||||
else
|
||||
putchar('\n');
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
|
||||
static void parsepopt(char *arg, unsigned *idx,
|
||||
unsigned *r, unsigned *g, unsigned *b)
|
||||
{
|
||||
char firstarg[21];
|
||||
register unsigned i;
|
||||
|
||||
if(sscanf(arg, "%20[a-zA-Z0-9]%*[,:]%u,%u,%u", firstarg, r, g, b) < 4
|
||||
|| strlen(firstarg) == 0) {
|
||||
fprintf(stderr, "too few args in -p i,r,g,b\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if(firstarg[0] >= '0' && firstarg[0] <= '9') {
|
||||
*idx = strtoul(firstarg, NULL, 10);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0; colnames[i].name; i++)
|
||||
if(strcasecmp(colnames[i].name, firstarg) == 0) {
|
||||
*idx = colnames[i].idx;
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "arg ``%s'' in -p option not recognized\n",
|
||||
firstarg);
|
||||
exit(2);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
.if !exists(${.CURDIR}/../Makefile.inc)
|
||||
error:
|
||||
@echo
|
||||
@echo " You MUST link/copy"
|
||||
@echo
|
||||
@echo " ../Makefile.inc.NetBSD or ../Makefile.inc.FreeBSD"
|
||||
@echo
|
||||
@echo " to ../Makefile.inc before you can proceed !"
|
||||
@echo
|
||||
.else
|
||||
|
||||
PROG= vt220keys
|
||||
CLEANFILES+= core.vt220keys vt220keys.core
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
.endif
|
|
@ -0,0 +1,131 @@
|
|||
.TH VT220 1
|
||||
.UC 4
|
||||
.SH NAME
|
||||
vt220 \- define SHIFTED function keys on VT220 terminal
|
||||
.SH SYNTAX
|
||||
.B vt220
|
||||
[
|
||||
.B \-cil
|
||||
]
|
||||
[ keyname keystring ] ...
|
||||
.SH DESCRIPTION
|
||||
.I Vt220
|
||||
sets up a "vt220 terminal" in vt200 mode to allow user
|
||||
definition of the SHIFTED function keys. Each
|
||||
\f2keyname\f1 specified on the command line will be loaded with
|
||||
the corresponding \f2keystring\f1.
|
||||
A \f2keyname\f1 is one of the following "words":
|
||||
F6 F7 F8 F9 F10 F11 ESC F12 BS F13 LF F14 HELP DO F17 F18 F19 F20.
|
||||
\f2Keystrings\f1
|
||||
must be quoted if spaces, tabs, or shell metacharacters are included.
|
||||
.PP
|
||||
.B Vt220
|
||||
expects to receive some combination of option flags and/or
|
||||
argument pair(s), otherwised an usage message
|
||||
is printed.
|
||||
.PP
|
||||
The options are:
|
||||
.TP
|
||||
.B \-c
|
||||
Clears all SHIFTED function key definitions before setting them to user
|
||||
defined strings.
|
||||
.TP
|
||||
.B \-i
|
||||
Read the initialization file
|
||||
.I $HOME/.vt220rc
|
||||
for SHIFTED function key definitions. This is done before any
|
||||
argument pair specified on the command line is processed.
|
||||
Each line in the file must consist of two fields (separated by spaces
|
||||
or tabs) where the first field is the
|
||||
\f2keyname\f1 and the second field is the \f2keystring\f1.
|
||||
The second field extends to the end of the line, thus a
|
||||
\f2keystring\f1
|
||||
may include spaces or tabs. A newline (return) may be specified
|
||||
within the string by using the C Language notation for newline (\\n).
|
||||
.TP
|
||||
.B \-l
|
||||
Locks the function keys from further definition.
|
||||
Locking occurs after processing the initialization file (if the "i"
|
||||
option is specified) and any argument
|
||||
pairs.
|
||||
The only way
|
||||
to unlock is by turning the power off.
|
||||
.SH EXAMPLES
|
||||
vt220 -ci
|
||||
.br
|
||||
vt220 F6 'nroff -ms '
|
||||
.br
|
||||
vt220 -i F20 'cc -O -c '
|
||||
.br
|
||||
vt220 -l HELP man
|
||||
.SH "OTHER FEATURES"
|
||||
Pressing the function keys without using the shift key, generates
|
||||
a string of characters. With
|
||||
\f2csh\f1(1) this string can be aliased to some command. For example:
|
||||
.br
|
||||
alias ^[[17~ "ls -CR | more"
|
||||
.br
|
||||
where ^[[17~ is what is generated by pressing the F6 key. Therefore
|
||||
F6 can perform two commands, depending if pressed with/without the SHIFT
|
||||
key.
|
||||
.PP
|
||||
.B Vt220
|
||||
can be called from your .login or .profile file. Typically an user
|
||||
will create a initialization file and include a line like
|
||||
.br
|
||||
vt220 -ci
|
||||
.br
|
||||
OR
|
||||
.br
|
||||
vt220 -cil
|
||||
.br
|
||||
in the above mentioned files. This way the SHIFTED function keys
|
||||
will be set to your favorite commands when logging in.
|
||||
.SH CAVEATS
|
||||
If the SHIFTED function keys are unlocked, redefinition of a SHIFTED
|
||||
function key will rewrite the old string.
|
||||
.PP
|
||||
There are 256 bytes available for the SHIFTED function keys. Space is
|
||||
supplied on a first-come/first-serve basis. After the 256 bytes are
|
||||
used, you can't define any more keys unless space is cleared. This
|
||||
can be done by redefining a key to contain a string of fewer bytes.
|
||||
.PP
|
||||
All key definitions are stored in volatile RAM, and are lost when
|
||||
terminal power is lost.
|
||||
.PP
|
||||
The ESC key (unshifted) no longer generates the proper escape character. This
|
||||
is of particular importance since many editors require use of the
|
||||
ESC key. Here are some available alternatives:
|
||||
.sp
|
||||
.in +.5i
|
||||
The escape character can be generated by typing ^[ (control-[).
|
||||
.sp
|
||||
Use
|
||||
.B vt220
|
||||
as follows (note ^[ is control-[)
|
||||
.br
|
||||
.in +.5i
|
||||
vt220 ESC '^['
|
||||
.in
|
||||
.br
|
||||
This will require you
|
||||
to press the SHIFT key and ESC to generate the escape sequence.
|
||||
.sp
|
||||
Some editors, allow other character(s) to be substituted for the
|
||||
escape character. For example with
|
||||
.B emacs
|
||||
include this line in your .emacs_pro:
|
||||
.br
|
||||
(bind-to-key "ESC-prefix" "\\033[23~")
|
||||
.br
|
||||
Thus when the ESC key is pressed, emacs will allow the characters
|
||||
generated (^[[23~) to perform the same function as the escape
|
||||
character.
|
||||
.in
|
||||
.SH FILES
|
||||
$HOME/.vt220rc \- initialization file
|
||||
.SH "SEE ALSO"
|
||||
VT220 Programmer Reference Manual
|
||||
.br
|
||||
VT220 Programmer Pocket Guide
|
||||
|
|
@ -0,0 +1,297 @@
|
|||
/*
|
||||
* Trivial program to load VT220 Function keys with strings,
|
||||
* note that the values only get sent when the key is shifted
|
||||
* (shoulda been an option to flip the shift set like the Z19!)
|
||||
*
|
||||
* Typing no args gives help, basically pairs of keyname/value
|
||||
* strings.
|
||||
*
|
||||
* Author, Author: Barry Shein, Boston University
|
||||
*
|
||||
* HISTORY
|
||||
{1} 30-Oct-85 Kenneth J. Lester (ken) at ektools
|
||||
|
||||
Added the necessary code to read an initialization file. This
|
||||
should make it easier to used this program. Also added code
|
||||
that will set-up the terminal in vt200 (this saves the user the
|
||||
trouble of checking if the set-up is in vt200).
|
||||
|
||||
Restructed the main function to use getopt, for argument
|
||||
processing.
|
||||
|
||||
Alterated usage function to include new "i" option (init file)
|
||||
|
||||
|
||||
-hm minor modifications for pcvt 2.0 release
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/*
|
||||
* The default toupper() macro is stupid, will toupper anything
|
||||
*/
|
||||
|
||||
#ifdef toupper
|
||||
#undef toupper
|
||||
#endif
|
||||
#define toupper(c) (islower(c) ? ((c)-' ') : c)
|
||||
|
||||
#define VT200_7BIT 1
|
||||
#define ESC 033
|
||||
#define INITFILE ".vt220rc"
|
||||
|
||||
struct keynames {
|
||||
char *name ;
|
||||
char *string ;
|
||||
} keys[] = {
|
||||
"F6", "17",
|
||||
"F7", "18",
|
||||
"F8", "19",
|
||||
"F9", "20",
|
||||
"F10", "21",
|
||||
"F11", "23",
|
||||
"ESC", "23",
|
||||
"F12", "24",
|
||||
"BS", "24",
|
||||
"F13", "25",
|
||||
"LF", "25",
|
||||
"F14", "26",
|
||||
"HELP", "28",
|
||||
"DO", "29",
|
||||
"F17", "31",
|
||||
"F18", "32",
|
||||
"F19", "33",
|
||||
"F20", "34",
|
||||
NULL, NULL
|
||||
};
|
||||
|
||||
char prog[BUFSIZ];
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
/* these are defined in the getopt routine */
|
||||
extern char *optarg; /* argument give to an option */
|
||||
extern int optind; /* argv index after option processing */
|
||||
|
||||
int option; /* option character returned by getopt */
|
||||
int initf = 0; /* read initialization file */
|
||||
int lockf = 0; /* lock keys after loading strings */
|
||||
int clearf = 0; /* clear all keys before loading strings */
|
||||
char *strcpy();
|
||||
|
||||
(void) strcpy(prog, *argv); /* store program name */
|
||||
|
||||
if(argc == 1) usage(); /* program requires options */
|
||||
|
||||
/* get options */
|
||||
while ((option = getopt(argc, argv, "cli")) != EOF)
|
||||
switch(option)
|
||||
{
|
||||
case 'c' :
|
||||
clearf++;
|
||||
break;
|
||||
case 'l' :
|
||||
lockf++;
|
||||
break;
|
||||
case 'i' :
|
||||
initf++;
|
||||
break;
|
||||
case '?' :
|
||||
usage();
|
||||
}
|
||||
|
||||
if (VT200_7BIT)
|
||||
printf("\033[62;1\"p"); /* vt200 7 bits */
|
||||
else
|
||||
printf("\033[62;2\"p"); /* vt200 8 bits */
|
||||
|
||||
if(clearf) clearkeys();
|
||||
|
||||
if (initf) getinit();
|
||||
|
||||
/* process {key, key string} pairs. Note optind is index to argv
|
||||
for first pair. By adding 1 to optind insures that a pair exists
|
||||
i.e. the last key has a key string. */
|
||||
|
||||
while(optind + 1 < argc)
|
||||
{
|
||||
dokey(argv[optind], argv[optind+1]);
|
||||
optind += 2;
|
||||
}
|
||||
|
||||
if(lockf) lockkeys();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/*
|
||||
* Load the VT220 SHIFT-FNKEY value, the basic pattern is
|
||||
* "\EP1;1|"+KEYNAME+"/"+VAL_AS_HEX+"\E\\"
|
||||
* that is, literally what is in quotes (w/o quotes) then the
|
||||
* name of the key from the keytable above (a numeric string)
|
||||
* then a slash, then the string value as hex pairs then ESC-BACKSLASH
|
||||
*
|
||||
* Note: you can gang together key defns with semicolons but that
|
||||
* would complicate things, especially error handling, so do it all
|
||||
* for each pair, who cares, really.
|
||||
*/
|
||||
|
||||
dokey(nm,val) char *nm, *val;
|
||||
{
|
||||
register char *scr;
|
||||
register struct keynames *kp;
|
||||
|
||||
for(scr = nm; *scr = toupper(*scr); scr++)
|
||||
;
|
||||
for(kp = keys; kp->name != NULL; kp++)
|
||||
if(strcmp(nm,kp->name) == 0) {
|
||||
printf("%cP1;1|%s/",ESC,kp->string);
|
||||
while(*val) printf("%02x",*val++);
|
||||
printf("%c\\",ESC);
|
||||
fflush(stdout);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr,"Bad key name: %s\n",nm);
|
||||
usage(); /* bad key name, give up */
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
clearkeys()
|
||||
{
|
||||
printf("%cP0;1|%c\\",ESC,ESC);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
lockkeys()
|
||||
{
|
||||
printf("%cP1;0|%c\\",ESC,ESC);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
usage()
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(stderr,"Usage: %s [-cil] [keyname string keyname string...]\n\n",prog);
|
||||
fprintf(stderr,"The following options are available\n");
|
||||
fprintf(stderr,"\t-c\tclears keys first\n");
|
||||
fprintf(stderr,"\t-l\t[sets then] locks further setting\n");
|
||||
fprintf(stderr,"\t-i\tfirst read initialization file $HOME/%s\n",INITFILE);
|
||||
fprintf(stderr,"(note that the only way to unlock is via Set-Up)\n\n");
|
||||
fprintf(stderr,"Keyname is one of:\n\t");
|
||||
for(i=0; keys[i].name != NULL; i++)
|
||||
fprintf(stderr,"%s ",keys[i].name);
|
||||
fprintf(stderr,"\nKeyname is SHIFTED function key that sends the string\n\n");
|
||||
fprintf(stderr,"Strings may need quoting to protect from shell\n");
|
||||
fprintf(stderr,"You must specify an option or key,string pairs\n\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* This routine process the INITFILE. This file expects lines in the format
|
||||
|
||||
<ws> keyname ws string
|
||||
|
||||
Where ws is white space (spaces or tabs) and <ws> is optional white space.
|
||||
The string may include spaces or tabs and need not be quoted. If the
|
||||
string has the sequence of "\n" then a newline character is included in
|
||||
the string.
|
||||
|
||||
examples:
|
||||
|
||||
F6 ls -lg\n
|
||||
F7 uulog -s
|
||||
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
getinit()
|
||||
{
|
||||
char *home; /* user's home directory */
|
||||
char path[BUFSIZ]; /* full path name of init file */
|
||||
char buf[BUFSIZ]; /* buffer to hold 1 line from init file */
|
||||
char key[BUFSIZ]; /* buffer, to hold specified fcn key */
|
||||
char keystr[BUFSIZ]; /* string associated with fcn key */
|
||||
char *ptr; /* pointer to transverse buf */
|
||||
int i, j; /* array indices */
|
||||
int statflag; /* whether init file is regular & readable */
|
||||
struct stat statbuf; /* stat of the init file */
|
||||
FILE *fp; /* file pointer to init file */
|
||||
|
||||
/* system calls and subroutines */
|
||||
FILE *fopen();
|
||||
char *strcpy();
|
||||
char *strcat();
|
||||
char *fgets();
|
||||
char *getenv();
|
||||
|
||||
/* construct full path name for init file */
|
||||
home = getenv("HOME");
|
||||
(void) strcpy(path, home);
|
||||
(void) strcat(path,"/");
|
||||
(void) strcat(path,INITFILE);
|
||||
|
||||
/* check status if init file */
|
||||
if (stat(path, &statbuf) != -1)
|
||||
{
|
||||
statflag = statbuf.st_mode & S_IFREG && statbuf.st_mode & S_IREAD;
|
||||
if (!statflag || (fp = fopen(path, "r")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "couldn't open initalization file: %s\n", path);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* process lines from init file */
|
||||
while (fgets(buf, BUFSIZ, fp) != NULL)
|
||||
{
|
||||
/* variable initializations */
|
||||
i = 0; j = 0;
|
||||
key[0] = '\0'; keystr[0] = '\0';
|
||||
ptr = buf;
|
||||
|
||||
while (*ptr == ' ' || *ptr == '\t') ptr++; /*skip whitespace*/
|
||||
|
||||
if (*ptr == '\n') break; /* we hit an emtpy line */
|
||||
|
||||
while (!isspace(*ptr) && *ptr != '\0') /* get keyname */
|
||||
key[i++] = *ptr++;
|
||||
key[i] = '\0'; /* place EOS in buffer */
|
||||
|
||||
while (*ptr == ' ' || *ptr == '\t') ptr++; /*skip whitespace*/
|
||||
|
||||
while (*ptr != '\n' && *ptr != '\0') /* get string */
|
||||
{
|
||||
/* check if string is to include newline i.e. \n */
|
||||
if (*ptr == '\\' && *(ptr+1) == 'n')
|
||||
{
|
||||
keystr[j] = '\012';
|
||||
ptr++;
|
||||
}
|
||||
else
|
||||
keystr[j] = *ptr;
|
||||
j++; ptr++;
|
||||
}
|
||||
keystr[j] = '\0'; /* place EOS in buffer */
|
||||
dokey(key, keystr); /* load key with string */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "init file %s not found\n\n", path);
|
||||
usage();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION
|
||||
CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION
|
||||
CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION
|
||||
|
||||
THE USE OF THIS PROGRAM MAY DESTROY YOUR MONITOR !!!
|
||||
====================================================
|
||||
|
||||
IF YOU DON'T KNOW WHAT YOU ARE DOING, STAY AWAY FROM IT !!!
|
||||
===========================================================
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION
|
||||
CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION
|
||||
CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION CAUTION
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
.if !exists(${.CURDIR}/../Makefile.inc)
|
||||
error:
|
||||
@echo
|
||||
@echo " You MUST link/copy"
|
||||
@echo
|
||||
@echo " ../Makefile.inc.NetBSD or ../Makefile.inc.FreeBSD"
|
||||
@echo
|
||||
@echo " to ../Makefile.inc before you can proceed !"
|
||||
@echo
|
||||
.else
|
||||
|
||||
PROG= vgaio
|
||||
|
||||
SRCS= vgaio.y lex.l
|
||||
YACC= bison
|
||||
YFLAGS+= -yd
|
||||
#YFLAGS+= -v # verbose
|
||||
LFLAGS+= -I
|
||||
|
||||
MAN8= vgaio.0
|
||||
|
||||
CFLAGS+= -I ${.CURDIR}/obj -I ${.CURDIR} -g
|
||||
|
||||
CLEANFILES+= y.tab.h
|
||||
CLEANFILES+= y.output # comment file from bison
|
||||
|
||||
install: $(PROG) $(MAN8)
|
||||
@echo "vgaio is not installed automatically ...."
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
.endif
|
|
@ -0,0 +1,79 @@
|
|||
%{
|
||||
/*
|
||||
* Copyright (c) 1994 Joerg Wunsch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Joerg Wunsch
|
||||
* 4. The name of the developer may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ident "$Header: /cvsroot/src/sys/arch/i386/isa/pcvt/Util/vgaio/Attic/lex.l,v 1.1 1994/03/29 02:47:20 mycroft Exp $"
|
||||
|
||||
/*
|
||||
* $Log: lex.l,v $
|
||||
* Revision 1.1 1994/03/29 02:47:20 mycroft
|
||||
* pcvt 3.0, with some performance enhancements by Joerg Wunsch and me.
|
||||
*
|
||||
* Revision 1.2 1994/01/08 17:42:58 j
|
||||
* cleanup
|
||||
* made multiple commands per line work
|
||||
* wrote man page
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "vgaio.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
%}
|
||||
|
||||
D [0-9a-fA-F]
|
||||
|
||||
%%
|
||||
|
||||
cr|CR { return CR; }
|
||||
|
||||
ar|AR { return AR; }
|
||||
|
||||
gr|GR { return GR; }
|
||||
|
||||
sr|SR { return SR; }
|
||||
|
||||
{D}({D}*) { sscanf(yytext, "%x", &yylval.num); return NUM; }
|
||||
|
||||
[ \t] { /* ignore */ }
|
||||
|
||||
\n { return NEWLINE; }
|
||||
|
||||
. { return yytext[0]; }
|
|
@ -0,0 +1,133 @@
|
|||
.\"
|
||||
.\" Copyright (c) 1994 Joerg Wunsch
|
||||
.\"
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This program is free software.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by Joerg Wunsch
|
||||
.\" 4. The name of the developer may not be used to endorse or promote
|
||||
.\" products derived from this software without specific prior written
|
||||
.\" permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Header: /cvsroot/src/sys/arch/i386/isa/pcvt/Util/vgaio/Attic/vgaio.8,v 1.1 1994/03/29 02:47:23 mycroft Exp $
|
||||
.\"
|
||||
.Dd January 8, 1994
|
||||
.Dt VGAIO 8
|
||||
.Sh NAME
|
||||
.Nm vgaio
|
||||
.Nd perform input/output on a Video Graphics Array
|
||||
.Sh SYNOPSIS
|
||||
.Nm vgaio
|
||||
.Op Fl d
|
||||
.Sh DESCRIPTION
|
||||
.Ss Purpose
|
||||
.Nm Vgaio
|
||||
is used to perform register-level input/output on a Video Graphics Array.
|
||||
Since some of the sequences required to access those registers are very
|
||||
silly,
|
||||
.Nm vgaio
|
||||
cares of all the things necessary and allows the user to access the
|
||||
registers of several register groups with their symbolic names.
|
||||
|
||||
.Ss Options
|
||||
.Bl -tag -width 10n -offset indent
|
||||
.It Fl d
|
||||
Turn on the grammar parser debugger.
|
||||
|
||||
.El
|
||||
.Ss Command language
|
||||
The command language of
|
||||
.Nm
|
||||
constitutes of some very simple tokens and rules. Commands are executed
|
||||
line by line as they are entered. Each line may contain any number of
|
||||
semicolon-separated input/output commands.
|
||||
|
||||
Symbolic register names look like:
|
||||
|
||||
.D1 Ao Em reggroup Ac Ao Em regnumber Ac
|
||||
|
||||
with
|
||||
.Aq Em regnumber
|
||||
being any hexadecimal number
|
||||
.Pq without a leading Em 0x ,
|
||||
and
|
||||
.Aq Em reggroup
|
||||
one of the strings
|
||||
.Dq Em ar ,
|
||||
.Dq Em cr ,
|
||||
.Dq Em gr ,
|
||||
or
|
||||
.Dq Em sr ,
|
||||
standing for the
|
||||
.Em Attribute controller ,
|
||||
.Em CRT controller ,
|
||||
.Em Graphics controller ,
|
||||
or
|
||||
.Em Timing sequencer ,
|
||||
respectively.
|
||||
|
||||
An input instruction has the form
|
||||
|
||||
.D1 Ao Em regname Ac ?
|
||||
|
||||
and will cause
|
||||
.Nm
|
||||
to output a line like
|
||||
|
||||
.Bd -ragged -offset indent
|
||||
.Ao Em regname Ac \& = 0x Ns
|
||||
.Aq Em number
|
||||
.Ed
|
||||
|
||||
An output instruction looks like
|
||||
|
||||
.Bd -ragged -offset indent
|
||||
.Ao Em regname Ac =
|
||||
.Aq Em number
|
||||
.Ed
|
||||
|
||||
Spaces or Tabs between the
|
||||
.Aq Em reggroup ,
|
||||
the
|
||||
.Aq Em regnumber ,
|
||||
or any of the other tokens are ignored. They are not required anyway.
|
||||
|
||||
.Ss Access control
|
||||
The caller must have uid 0 in order to gain the required access to
|
||||
the IO registers.
|
||||
|
||||
.Sh HISTORY
|
||||
This program is considered
|
||||
.Dq hackware .
|
||||
It has been developed in order to simplify the process of developing other
|
||||
software that needs to program the Video Graphics Array.
|
||||
|
||||
.Sh AUTHOR
|
||||
The program has been contributed by
|
||||
.if n Joerg Wunsch,
|
||||
.if t J\(:org Wunsch,
|
||||
Dresden
|
||||
.Aq joerg_wunsch@uriah.sax.de .
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 1994 Joerg Wunsch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Joerg Wunsch
|
||||
* 4. The name of the developer may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Header
|
||||
* The author may be reached unter <joerg_wunsch@uriah.sax.de>
|
||||
*
|
||||
* $Log: vgaio.h,v $
|
||||
* Revision 1.1 1994/03/29 02:47:25 mycroft
|
||||
* pcvt 3.0, with some performance enhancements by Joerg Wunsch and me.
|
||||
*
|
||||
* Revision 1.2 1994/01/08 17:42:58 j
|
||||
* cleanup
|
||||
* made multiple commands per line work
|
||||
* wrote man page
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/* common structure to hold the definition for a VGA register */
|
||||
|
||||
#ifndef VGAIO_H
|
||||
#define VGAIO_H
|
||||
|
||||
struct reg {
|
||||
int group, num;
|
||||
};
|
||||
|
||||
#endif /* VGAIO_H */
|
|
@ -0,0 +1,209 @@
|
|||
%{
|
||||
/*
|
||||
* Copyright (c) 1994 Joerg Wunsch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Joerg Wunsch
|
||||
* 4. The name of the developer may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ident "$Header: /cvsroot/src/sys/arch/i386/isa/pcvt/Util/vgaio/Attic/vgaio.y,v 1.1 1994/03/29 02:47:27 mycroft Exp $"
|
||||
|
||||
/*
|
||||
* $Log: vgaio.y,v $
|
||||
* Revision 1.1 1994/03/29 02:47:27 mycroft
|
||||
* pcvt 3.0, with some performance enhancements by Joerg Wunsch and me.
|
||||
*
|
||||
* Revision 1.2 1994/01/08 17:42:58 j
|
||||
* cleanup
|
||||
* made multiple commands per line work
|
||||
* wrote man page
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/console.h>
|
||||
|
||||
#include "vgaio.h"
|
||||
|
||||
void setreg(struct reg r, int val);
|
||||
void getreg(struct reg r);
|
||||
void yyerror(const char *msg);
|
||||
|
||||
#define YYDEBUG 1
|
||||
|
||||
unsigned short vgabase;
|
||||
|
||||
%}
|
||||
|
||||
%union {
|
||||
int num;
|
||||
struct reg reg;
|
||||
}
|
||||
|
||||
%token GR CR SR AR NEWLINE
|
||||
%token <num> NUM
|
||||
|
||||
%type <num> reggroup
|
||||
%type <reg> register
|
||||
|
||||
%%
|
||||
|
||||
interpret: lines ;
|
||||
|
||||
lines: line
|
||||
| lines line
|
||||
;
|
||||
|
||||
line: statements NEWLINE
|
||||
| NEWLINE
|
||||
| error NEWLINE { fprintf(stderr, "bing!\n"); }
|
||||
;
|
||||
|
||||
statements: statement
|
||||
| statements ';' statement
|
||||
;
|
||||
|
||||
statement: register '?' { getreg($1); }
|
||||
| register '=' NUM { setreg($1, $3); }
|
||||
| /* lambda */
|
||||
;
|
||||
|
||||
register: reggroup NUM { $$.num = $2; $$.group = $1; }
|
||||
;
|
||||
|
||||
reggroup: GR { $$ = GR; }
|
||||
| CR { $$ = CR; }
|
||||
| SR { $$ = SR; }
|
||||
| AR { $$ = AR; }
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
static struct {
|
||||
int id;
|
||||
const char *name;
|
||||
} regnames[] = {
|
||||
{GR, "gr"}, {CR, "cr"}, {SR, "sr"}, {AR, "ar"},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
const char *getname(struct reg r) {
|
||||
int idx;
|
||||
for(idx = 0; regnames[idx].id; idx++)
|
||||
if(regnames[idx].id == r.group)
|
||||
return regnames[idx].name;
|
||||
return "??";
|
||||
}
|
||||
|
||||
void getreg(struct reg r) {
|
||||
unsigned char val;
|
||||
|
||||
switch(r.group) {
|
||||
case GR:
|
||||
outb(0x3ce, r.num);
|
||||
val = inb(0x3cf);
|
||||
break;
|
||||
|
||||
case AR:
|
||||
r.num &= 0x1f;
|
||||
(void)inb(vgabase + 0x0a);
|
||||
outb(0x3c0, r.num + 0x20);
|
||||
val = inb(0x3c1);
|
||||
break;
|
||||
|
||||
case CR:
|
||||
outb(vgabase + 4, r.num);
|
||||
val = inb(vgabase + 5);
|
||||
break;
|
||||
|
||||
case SR:
|
||||
outb(0x3c4, r.num);
|
||||
val = inb(0x3c5);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("%s%x = 0x%x\n", getname(r), r.num, val);
|
||||
}
|
||||
|
||||
void setreg(struct reg r, int val) {
|
||||
switch(r.group) {
|
||||
case GR:
|
||||
outb(0x3ce, r.num);
|
||||
outb(0x3cf, val);
|
||||
break;
|
||||
|
||||
case AR:
|
||||
r.num &= 0x1f;
|
||||
(void)inb(vgabase + 0x0a);
|
||||
outb(0x3c0, r.num);
|
||||
outb(0x3c0, val);
|
||||
outb(0x3c0, r.num + 0x20);
|
||||
break;
|
||||
|
||||
case CR:
|
||||
outb(vgabase + 4, r.num);
|
||||
outb(vgabase + 5, val);
|
||||
break;
|
||||
|
||||
case SR:
|
||||
outb(0x3c4, r.num);
|
||||
outb(0x3c5, val);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("%s%x set to 0x%x now\n", getname(r), r.num, val);
|
||||
}
|
||||
|
||||
void yyerror(const char *msg) {
|
||||
fprintf(stderr, "yyerror: %s\n", msg);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int fd;
|
||||
|
||||
if(argc > 1) yydebug = 1;
|
||||
|
||||
if((fd = open("/dev/console", O_RDONLY)) < 0)
|
||||
fd = 0;
|
||||
|
||||
if(ioctl(fd, KDENABIO, 0) < 0) {
|
||||
perror("ioctl(KDENABIO)");
|
||||
return 1;
|
||||
}
|
||||
vgabase = (inb(0x3cc) & 1)? 0x3d0: 0x3b0;
|
||||
yyparse();
|
||||
|
||||
(void)ioctl(fd, KDDISABIO, 0);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
.if !exists(${.CURDIR}/../Makefile.inc)
|
||||
error:
|
||||
@echo
|
||||
@echo " You MUST link/copy"
|
||||
@echo
|
||||
@echo " ../Makefile.inc.NetBSD or ../Makefile.inc.FreeBSD"
|
||||
@echo
|
||||
@echo " to ../Makefile.inc before you can proceed !"
|
||||
@echo
|
||||
.else
|
||||
|
||||
PROG= vttest
|
||||
CFLAGS+= -traditional -DUSEMYSTTY
|
||||
SRCS= main.c esc.c
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
.endif
|
|
@ -0,0 +1,57 @@
|
|||
NOTES FROM THE MOD.SOURCES MODERATOR:
|
||||
I split the source up into the three separate pieces it now is.
|
||||
In doing this, I put lines like "int reading;" in a header file
|
||||
that both C modules include. If your Unix requires one of these
|
||||
to be "extern int reading;" then you will have some editing to do.
|
||||
Also note that this program uses FIONREAD, which must be implemented
|
||||
differently in SystemV, etc., and check out the setjmp() call...
|
||||
/Rich $alz
|
||||
Oh, yeah: I also wrote the Makefile and manpage, such as they are.
|
||||
-------------------------------------------------------------------
|
||||
|
||||
This is a program to test the compatibility (or to demonstrate the
|
||||
non-compatibility) of so-called "VT100-compatible" terminals. In
|
||||
conformance of the good old hacker traditions, the only documentation
|
||||
of this program is the source code itself. To understand it, you also
|
||||
need a copy of the original VT100 manual from DEC.
|
||||
|
||||
Comments and bug reports: Since this is a release (via USENET) to the
|
||||
whole world, a lot of people are going to have opinions and fresh
|
||||
ideas about it. (What -- bugs in MY program? Aww...) I can't deal
|
||||
with everyone sending me a hacked version, but if you have found a
|
||||
serious bug, or ported it to VMS, do tell me. I can't promise any new
|
||||
version release, though. From this version on (1.7b) VTTEST will have
|
||||
to live its own life without its father holding its hand.
|
||||
|
||||
My adress is:
|
||||
|
||||
Network-mail adress: (mcvax,seismo)!enea!suadb!lindberg
|
||||
|
||||
Real-world-mail address: Per Lindberg
|
||||
QZ, Stockholm University Computing Center
|
||||
Box 27322
|
||||
S - 102 54 Stockholm
|
||||
SWEDEN
|
||||
|
||||
The original version of this program is written for the Sargasso C
|
||||
compiler for the DECsystem-10. Many thanks to all sales persons with
|
||||
quote VT100-compatible unquote terminals, who prompted me to write
|
||||
this program, and also to:
|
||||
|
||||
-- Bo Kleve, LIDAC, Linkoping University, Sweden
|
||||
for the portation to DECSYSTEM-20 with the Sargasso C compiler
|
||||
|
||||
-- Johan Widen, TTDS, Royal Institute of Technology, Stockholm, Sweden
|
||||
for the portation to various UNIX systems (incl. System III and Xenix)
|
||||
|
||||
-- Russ Herman, AES Data Inc., Missisauga, Ont. Canada
|
||||
for fixes and code for the VT102 test
|
||||
|
||||
Thanx also to JMR "Gremlin" at KTH, and Goran Wallberg at QZ
|
||||
for suggestions, bug fixes, etc.
|
||||
|
||||
This program does not have support for all the different variations
|
||||
of VT100, like VT125, VT131 nor the new VT200 series. Feel free to
|
||||
add that yourself. Happy Hacking!
|
||||
|
||||
/TMP
|
|
@ -0,0 +1,398 @@
|
|||
#include "header.h"
|
||||
|
||||
println(s) char *s; {
|
||||
printf("%s\n", s);
|
||||
}
|
||||
|
||||
esc(s) char *s; {
|
||||
printf("%c%s", 27, s);
|
||||
}
|
||||
|
||||
esc2(s1, s2) char s1, s2; {
|
||||
printf("%c%s%s", 27, s1, s2);
|
||||
}
|
||||
|
||||
brcstr(ps, c) char *ps, c; {
|
||||
printf("%c[%s%c", 27, ps, c);
|
||||
}
|
||||
|
||||
brc(pn,c) int pn; char c; {
|
||||
printf("%c[%d%c", 27, pn, c);
|
||||
}
|
||||
|
||||
brc2(pn1, pn2 ,c) int pn1, pn2; char c; {
|
||||
printf("%c[%d;%d%c", 27, pn1, pn2, c);
|
||||
}
|
||||
|
||||
cub(pn) int pn; { /* Cursor Backward */
|
||||
brc(pn,'D');
|
||||
}
|
||||
cud(pn) int pn; { /* Cursor Down */
|
||||
brc(pn,'B');
|
||||
}
|
||||
cuf(pn) int pn; { /* Cursor Forward */
|
||||
brc(pn,'C');
|
||||
}
|
||||
cup(pn1, pn2) int pn1, pn2; { /* Cursor Position */
|
||||
brc2(pn1, pn2, 'H');
|
||||
}
|
||||
cuu(pn) int pn; { /* Cursor Up */
|
||||
brc(pn,'A');
|
||||
}
|
||||
da() { /* Device Attributes */
|
||||
brc(0,'c');
|
||||
}
|
||||
decaln() { /* Screen Alignment Display */
|
||||
esc("#8");
|
||||
}
|
||||
decdhl(lower) int lower; { /* Double Height Line (also double width) */
|
||||
if (lower) esc("#4");
|
||||
else esc("#3");
|
||||
}
|
||||
decdwl() { /* Double Wide Line */
|
||||
esc("#6");
|
||||
}
|
||||
deckpam() { /* Keypad Application Mode */
|
||||
esc("=");
|
||||
}
|
||||
deckpnm() { /* Keypad Numeric Mode */
|
||||
esc(">");
|
||||
}
|
||||
decll(ps) char *ps; { /* Load LEDs */
|
||||
brcstr(ps, 'q');
|
||||
}
|
||||
decrc() { /* Restore Cursor */
|
||||
esc("8");
|
||||
}
|
||||
decreqtparm(pn) int pn; { /* Request Terminal Parameters */
|
||||
brc(pn,'x');
|
||||
}
|
||||
decsc() { /* Save Cursor */
|
||||
esc("7");
|
||||
}
|
||||
decstbm(pn1, pn2) int pn1, pn2; { /* Set Top and Bottom Margins */
|
||||
if (pn1 || pn2) brc2(pn1, pn2, 'r');
|
||||
else esc("[r");
|
||||
/* Good for >24-line terminals */
|
||||
}
|
||||
decswl() { /* Single With Line */
|
||||
esc("#5");
|
||||
}
|
||||
dectst(pn) int pn; { /* Invoke Confidence Test */
|
||||
brc2(2, pn, 'y');
|
||||
}
|
||||
dsr(pn) int pn; { /* Device Status Report */
|
||||
brc(pn, 'n');
|
||||
}
|
||||
ed(pn) int pn; { /* Erase in Display */
|
||||
brc(pn, 'J');
|
||||
}
|
||||
el(pn) int pn; { /* Erase in Line */
|
||||
brc(pn,'K');
|
||||
}
|
||||
hts() { /* Horizontal Tabulation Set */
|
||||
esc("H");
|
||||
}
|
||||
hvp(pn1, pn2) int pn1, pn2; { /* Horizontal and Vertical Position */
|
||||
brc2(pn1, pn2, 'f');
|
||||
}
|
||||
ind() { /* Index */
|
||||
esc("D");
|
||||
}
|
||||
nel() { /* Next Line */
|
||||
esc("E");
|
||||
}
|
||||
ri() { /* Reverse Index */
|
||||
esc("M");
|
||||
}
|
||||
ris() { /* Reset to Initial State */
|
||||
esc("c");
|
||||
}
|
||||
rm(ps) char *ps; { /* Reset Mode */
|
||||
brcstr(ps, 'l');
|
||||
}
|
||||
scs(g,c) int g; char c; { /* Select character Set */
|
||||
printf("%c%c%c%c%c%c%c", 27, g ? ')' : '(', c,
|
||||
27, g ? '(' : ')', 'B',
|
||||
g ? 14 : 15);
|
||||
}
|
||||
sgr(ps) char *ps; { /* Select Graphic Rendition */
|
||||
brcstr(ps, 'm');
|
||||
}
|
||||
sm(ps) char *ps; { /* Set Mode */
|
||||
brcstr(ps, 'h');
|
||||
}
|
||||
tbc(pn) int pn; { /* Tabulation Clear */
|
||||
brc(pn, 'g');
|
||||
}
|
||||
|
||||
vt52cup(l,c) int l,c; {
|
||||
printf("%cY%c%c", 27, l + 31, c + 31);
|
||||
}
|
||||
|
||||
char inchar() {
|
||||
|
||||
/*
|
||||
* Wait until a character is typed on the terminal
|
||||
* then read it, without waiting for CR.
|
||||
*/
|
||||
|
||||
#ifdef UNIX
|
||||
int lval, waittime, getpid(); static int val; char ch;
|
||||
|
||||
fflush(stdout);
|
||||
lval = val;
|
||||
brkrd = 0;
|
||||
reading = 1;
|
||||
read(0,&ch,1);
|
||||
reading = 0;
|
||||
if (brkrd)
|
||||
val = 0177;
|
||||
else
|
||||
val = ch;
|
||||
if ((val==0177) && (val==lval))
|
||||
kill(getpid(), (int) SIGTERM);
|
||||
#endif
|
||||
#ifdef SARG10
|
||||
int val, waittime;
|
||||
|
||||
waittime = 0;
|
||||
while(!uuo(051,2,&val)) { /* TTCALL 2, (INCHRS) */
|
||||
zleep(100); /* Wait 0.1 seconds */
|
||||
if ((waittime += ttymode) > 600) /* Time-out, in case */
|
||||
return('\177'); /* of hung in ttybin(1) */
|
||||
}
|
||||
#endif
|
||||
#ifdef SARG20 /* try to fix a time-out function */
|
||||
int val, waittime;
|
||||
|
||||
waittime = 0;
|
||||
while(jsys(SIBE,2,_PRIIN) == 0) { /* Is input empty? */
|
||||
zleep(100);
|
||||
if ((waittime += ttymode) > 600)
|
||||
return('\177');
|
||||
}
|
||||
ejsys(BIN,_PRIIN);
|
||||
val = jsac[2];
|
||||
#endif
|
||||
return(val);
|
||||
}
|
||||
|
||||
char *instr() {
|
||||
|
||||
/*
|
||||
* Get an unfinished string from the terminal:
|
||||
* wait until a character is typed on the terminal,
|
||||
* then read it, and all other available characters.
|
||||
* Return a pointer to that string.
|
||||
*/
|
||||
|
||||
|
||||
int i, val, crflag; long l1; char ch;
|
||||
static char result[80];
|
||||
|
||||
i = 0;
|
||||
result[i++] = inchar();
|
||||
/* Wait 0.1 seconds (1 second in vanilla UNIX) */
|
||||
#ifdef SARG10
|
||||
if (trmop(01031,0) < 5) zleep(500); /* wait longer if low speed */
|
||||
else zleep(100);
|
||||
#else
|
||||
zleep(100);
|
||||
#endif
|
||||
#ifdef UNIX
|
||||
fflush(stdout);
|
||||
#ifdef XENIX
|
||||
while(rdchk(0)) {
|
||||
read(0,result+i,1);
|
||||
if (i++ == 78) break;
|
||||
}
|
||||
#else
|
||||
#ifdef SIII
|
||||
while(read(2,result+i,1) == 1)
|
||||
if (i++ == 78) break;
|
||||
#else
|
||||
while(ioctl(0,FIONREAD,&l1), l1 > 0L) {
|
||||
while(l1-- > 0L) {
|
||||
read(0,result+i,1);
|
||||
if (i++ == 78) goto out1;
|
||||
}
|
||||
}
|
||||
out1:
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SARG10
|
||||
while(uuo(051,2,&val)) { /* TTCALL 2, (INCHRS) */
|
||||
if (!(val == '\012' && crflag)) /* TOPS-10 adds LF to CR */
|
||||
result[i++] = val;
|
||||
crflag = val == '\015';
|
||||
if (i == 79) break;
|
||||
zleep(50); /* Wait 0.05 seconds */
|
||||
}
|
||||
#endif
|
||||
#ifdef SARG20
|
||||
while(jsys(SIBE,2,_PRIIN) != 0) { /* read input until buffer is empty */
|
||||
ejsys(BIN,_PRIIN);
|
||||
result[i++] = jsac[2];
|
||||
if (i == 79) break;
|
||||
zleep(50); /* Wait 0.05 seconds */
|
||||
}
|
||||
#endif
|
||||
result[i] = '\0';
|
||||
return(result);
|
||||
}
|
||||
|
||||
ttybin(bin) int bin; {
|
||||
#ifdef SARG10
|
||||
#define OPEN 050
|
||||
#define IO_MOD 0000017
|
||||
#define _IOPIM 2
|
||||
#define _IOASC 0
|
||||
#define _TOPAG 01021
|
||||
#define _TOSET 01000
|
||||
|
||||
int v;
|
||||
static int arglst[] = {
|
||||
_IOPIM,
|
||||
`TTY`,
|
||||
0
|
||||
};
|
||||
arglst[0] = bin ? _IOPIM : _IOASC;
|
||||
v = uuo(OPEN, 1, &arglst[0]);
|
||||
if (!v) { printf("OPEN failed"); exit(); }
|
||||
trmop(_TOPAG + _TOSET, bin ? 0 : 1);
|
||||
ttymode = bin;
|
||||
#endif
|
||||
#ifdef SARG20
|
||||
/* TTYBIN will set the line in BINARY/ASCII mode
|
||||
* BINARY mode is needed to send control characters
|
||||
* Bit 28 must be 0 (we don't flip it).
|
||||
* Bit 29 is used for the mode change.
|
||||
*/
|
||||
|
||||
#define _TTASC 0000100
|
||||
#define _MOXOF 0000043
|
||||
|
||||
int v;
|
||||
|
||||
ejsys(RFMOD,_CTTRM);
|
||||
v = ejsys(SFMOD,_CTTRM, bin ? (~_TTASC & jsac[2]) : (_TTASC | jsac[2]));
|
||||
if (v) { printf("SFMOD failed"); exit(); }
|
||||
v = ejsys(MTOPR,_CTTRM,_MOXOF,0);
|
||||
if (v) { printf("MTOPR failed"); exit(); }
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SARG20
|
||||
/*
|
||||
* SUPERBIN turns off/on all input character interrupts
|
||||
* This affects ^C, ^O, ^T
|
||||
* Beware where and how you use it !!!!!!!
|
||||
*/
|
||||
|
||||
superbin(bin) int bin; {
|
||||
int v;
|
||||
|
||||
v = ejsys(STIW,(0//-5), bin ? 0 : -1);
|
||||
if (v) { printf("STIW superbinary setting failed"); exit(); }
|
||||
ttymode = bin;
|
||||
}
|
||||
|
||||
/*
|
||||
* PAGE affects the ^S/^Q handshake.
|
||||
* Set bit 34 to turn it on. Clear it for off.
|
||||
*/
|
||||
|
||||
page(bin) int bin; {
|
||||
int v;
|
||||
|
||||
#define TT_PGM 0000002
|
||||
|
||||
ejsys(RFMOD,_CTTRM); /* Get the current terminal status */
|
||||
v = ejsys(STPAR,_CTTRM, bin ? (TT_PGM | jsac[2]) : (~TT_PGM & jsac[2]));
|
||||
if (v) { printf("STPAR failed"); exit(); }
|
||||
}
|
||||
#endif
|
||||
|
||||
trmop(fc,arg) int fc, arg; {
|
||||
#ifdef SARG10
|
||||
int retvalp;
|
||||
int arglst[3];
|
||||
|
||||
/* TRMOP is a TOPS-10 monitor call that does things to the terminal. */
|
||||
|
||||
/* Find out TTY nbr (PA1050 barfs if TRMOP get -1 instead of udx) */
|
||||
/* A TRMNO monitor call returns the udx (Universal Device Index) */
|
||||
|
||||
arglst[0] = fc; /* function code */
|
||||
arglst[1] = calli(0115, -1); /* udx, TRMNO. UUO */
|
||||
arglst[2] = arg; /* Optional argument */
|
||||
|
||||
if (calli(0116, 3 // &arglst[0], &retvalp)) /* TRMOP. UUO */
|
||||
return (retvalp);
|
||||
else {
|
||||
printf("?Error return in TRMOP.");
|
||||
exit();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inputline(s) char *s; {
|
||||
scanf("%s",s);
|
||||
#ifdef SARG10
|
||||
readnl();
|
||||
#endif
|
||||
#ifdef SARG20
|
||||
readnl();
|
||||
#endif
|
||||
}
|
||||
|
||||
inflush() {
|
||||
|
||||
/*
|
||||
* Flush input buffer, make sure no pending input character
|
||||
*/
|
||||
|
||||
int val;
|
||||
|
||||
#ifdef UNIX
|
||||
#ifdef XENIX
|
||||
while(rdchk(0)) read(0,&val,1);
|
||||
#else
|
||||
#ifdef SIII
|
||||
while(read(2,&val,1));
|
||||
#else
|
||||
long l1;
|
||||
ioctl (0, FIONREAD, &l1);
|
||||
while(l1-- > 0L) read(0,&val,1);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SARG10
|
||||
while(uuo(051,2,&val)) /* TTCALL 2, (INCHRS) */
|
||||
;
|
||||
#endif
|
||||
#ifdef SARG20
|
||||
ejsys(CFIBF,_PRIIN); /* Clear input buffer */
|
||||
#endif
|
||||
}
|
||||
|
||||
zleep(t) int t; {
|
||||
|
||||
/*
|
||||
* Sleep and do nothing (don't waste CPU) for t milliseconds
|
||||
*/
|
||||
|
||||
#ifdef SARG10
|
||||
calli(072,t); /* (HIBER) t milliseconds */
|
||||
#endif
|
||||
#ifdef SARG20
|
||||
ejsys(DISMS,t); /* DISMISS for t milliseconds */
|
||||
#endif
|
||||
#ifdef UNIX
|
||||
t = t / 1000;
|
||||
if (t == 0) t = 1;
|
||||
sleep(t); /* UNIX can only sleep whole seconds */
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
#define VERSION "1.7b 1985-04-19"
|
||||
|
||||
/* Choose one of these */
|
||||
|
||||
/* #define XENIX /* XENIX implies UNIX */
|
||||
/* #define SIII /* SIII implies UNIX, (NDELAY a la System III) */
|
||||
#define UNIX /* UNIX */
|
||||
/* #define VMS /* VMS not done yet -- send me your version!!!! */
|
||||
/* #define SARG20 /* Sargasso C for TOPS-20 */
|
||||
/* #define SARG10 /* Sargasso C for TOPS-10 */
|
||||
|
||||
/* These #ifdef:s are implementation dependent stuff for the Sargasso C */
|
||||
/* Unix C barfs on directives like "#strings", so we keep them */
|
||||
/* indented. Then unix c can't find them, but Sargasso C *can*. */
|
||||
/* Admittedly kludgey, but it works...) */
|
||||
#ifdef SARG10
|
||||
#define _UNIXCON /* Make UNIX-flavored I/O on TOPS */
|
||||
#strings low /* put strings in lowseg mem so we can modify them. */
|
||||
#endif
|
||||
#ifdef SARG20
|
||||
#define _UNIXCON /* Make UNIX-flavored I/O on TOPS */
|
||||
#strings low /* put strings in lowseg mem so we can modify them. */
|
||||
#include <TOPS20.HDR>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef UNIX
|
||||
#include <ctype.h>
|
||||
#include <sgtty.h>
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
jmp_buf intrenv;
|
||||
struct sgttyb sgttyOrg, sgttyNew;
|
||||
char stdioBuf[BUFSIZ];
|
||||
int brkrd, reading;
|
||||
extern onterm(), onbrk();
|
||||
#ifdef SIII
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
int ttymode;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,13 @@
|
|||
.TH VTTEST 1 "LOCAL"
|
||||
.SH NAME
|
||||
vttest \- test VT100-type terminal
|
||||
.SH SYNOPSIS
|
||||
.B vttest
|
||||
.SH DESCRIPTION
|
||||
.I Vttest
|
||||
is a program designed to test the functionality of a VT100 terminal
|
||||
(or emulator thereof).
|
||||
It tests both display (escape sequence handling) and keyboard.
|
||||
.PP
|
||||
The program is menu\-driven and contains full on\-line operating
|
||||
instructions.
|
Loading…
Reference in New Issue