Skip to content

Instantly share code, notes, and snippets.

@dermidgen
Created July 2, 2014 00:17
Show Gist options
  • Save dermidgen/7b62a2ada03682a5b11d to your computer and use it in GitHub Desktop.
Save dermidgen/7b62a2ada03682a5b11d to your computer and use it in GitHub Desktop.
VMS Terminal
#!/bin/sh
# vmsterm
# from an original script by Bob Ess
# key translations by Erik Ahlefeldt
#
# Script file using Xterm and telnet to connect to a VMS host
# and give a decent vt220 emulation.
#
# Usage statement
Usage(){
echo
echo " Usage : vmsterm -options"
echo
echo " Options: -80 for 80 column terminal"
echo " -132 for 132 column terminal"
echo " -bg colorname"
echo " -fg colorname"
echo " -fn fontname"
echo " -fb bold fontname"
echo " -host [crusher.saltmine.com] [earth] [192.168.7.7]"
echo ""
echo " Example: \"vmsterm -80 -fg white -bg black -fn 9x15 -fb 9x15b -host earth\""
echo " Starts a VMS session with an 80 column terminal"
echo " with a black background, white foreground, a normal"
echo " font of 9x15 and a bold font of 9x15b, and connects"
echo " to the node 'earth'"
echo ""
echo " Example: \"vmsterm -host earth\""
echo " Starts a VMS session with default terminal settings "
echo ""
echo " Example: \"vmsterm -help\""
echo " Displays vmsterm options "
echo
exit 1
}
# Default to a black foreground with a white background.
# Use the 9x15 and 9x15bold fonts. Connect to 192.168.3.3 by default.
#
FG=black
BG=white
HOST=192.168.3.3
FONT=9x15
BFONT=9x15bold
COLS=80
# Parse the command line arguments
#
while [ $# != 0 ];
do
case $1 in
-80) COLS=80
FONT=spc12x24c
BFONT=spc12x24b
shift
;;
-132) COLS=132
FONT=9x15
BFONT=9x15b
shift
;;
-fg) shift
FG=$1
shift;;
-bg) shift
BG=$1
shift;;
-fn) shift
FONT=$1
shift;;
-fb) shift
BFONT=$1
shift;;
-host) shift
HOST=$1
shift;;
-help) Usage;;
*) Usage;;
esac
done
xterm -title "VMSTERM" -sb -sl 3000 -geo ${COLS}x24 -fg ${FG} -bg ${BG} \
-cr blue -fn ${FONT} -fb ${BFONT} -xrm \
"xterm*VT100.Translations: #override \n \
~Shift <Key>F1: string(0x1b) string("OP") \n \
~Shift <Key>F2: string(0x1b) string("OQ") \n \
~Shift <Key>F3: string(0x1b) string("OR") \n \
~Shift <Key>F4: string(0x1b) string("OS") \n \
~Shift <Key>F5: string("Break") \n \
~Shift <Key>F6: string(0x1b) string("[17~") \n \
~Shift <Key>F7: string(0x1b) string("[18~") \n \
~Shift <Key>F8: string(0x1b) string("[19~") \n \
~Shift <Key>F9: string(0x1b) string("[20~") \n \
~Shift <Key>F10: string(0x1b) string("[21~") \n \
~Shift <Key>F11: string(0x1b) string("[23~") \n \
~Shift <Key>F12: string(0x1b) string("[29~") \n \
Shift <Key>F1: string(0x1b) string("[23~") \n \
Shift <Key>F2: string(0x1b) string("[24~") \n \
Shift <Key>F3: string(0x1b) string("[25~") \n \
Shift <Key>F4: string(0x1b) string("[26~") \n \
Shift <Key>F5: string(0x1b) string("[28~") \n \
Shift <Key>F6: string(0x1b) string("[29~") \n \
Shift <Key>F7: string(0x1b) string("[31~") \n \
Shift <Key>F8: string(0x1b) string("[32~") \n \
Shift <Key>F9: string(0x1b) string("[33~") \n \
Shift <Key>F10: string(0x1b) string("[34~") \n \
Shift <Key>F11: string(0x1b) string("[28~") \n \
Shift <Key>F12: string(0x1b) string("[29~") \n \
<Key>Print: string(0x1b) string("[28~") \n \
<Key>Cancel: string(0x1b) string("[29~") \n \
<Key>Pause: string(0x1b) string("Om") \n \
<Key>Insert: string(0x1b) string("[2~") \n \
<Key>Delete: string(0x1b) string("[3~") \n \
<Key>Home: string(0x1b) string("[1~") \n \
<Key>End: string(0x1b) string("[4~") \n \
<Key>Prior: string(0x1b) string("[5~") \n \
<Key>Next: string(0x1b) string("[6~") \n \
<Key>BackSpace: string(0x7f) \n \
<Key>Num_Lock: string(0x1b) string("OP") \n \
<Key>KP_Divide: string(0x1b) string("OQ") \n \
<Key>KP_Multiply: string(0x1b) string("OR") \n \
<Key>KP_Subtract: string(0x1b) string("OS") \n \
~Shift <Key>Up: string(0x1b) string("[A") \n \
Shift <Key>Up: scroll-back(1,lines) \n \
~Shift <Key>Down: string(0x1b) string("[B") \n \
Shift <Key>Down: scroll-forw(1,lines) \n \
<Key>Right: string(0x1b) string("[C") \n \
<Key>Left: string(0x1b) string("[D")" \
-e telnet $HOST

Readme file for vmsterm script.

This script is for people who wish to connect from a Linux or Unix computer to a VMS computer using telnet and get a good VT100 or VT220 emulation. The key mappings have been specifically designed to emulate the VT terminal auxiliary numeric keypad, so that you can use VMS EDT and TPU editors, as well as the many VMS applications use keys PF1 to PF4. The script should work with any recent version of Xterm using a standard extended IBM PC keyboard or a Sun keyboard.

About the keymappings. First the auxiliary numeric keypad. My prime objective with these mappings was to produce a setup that I could use with the EDT and TPU editors which make extensive use of the numeric keypad. The top row of keys PC numeric keypad (Num Lock, Divide, Multiply, Subtract) are where you find PF1, PF2, PF3, PF4 on a VT keyboard, so I have mapped them to PF1 thru PF4. The PC numeric keypad Add key (+) takes up the space of two keys which are Minus and Comma on the VT keyboard - I have mapped it to Comma (Delete Character in the EDT editor). I have then used the PC Pause key to map to VT key Minus (Delete Word in the EDT editor). The remaining keys on the auxiliary numeric keypad are the same for PC and VT.

The six keys between the main and numeric keypads on the PC (Insert, Home, Page Up, Delete End, Page Down) are usually mapped to the VT keys by either position or by (approximate) function. As I rarely use these keys I have mapped them by function as follows: PC key Insert to VT Insert Here, PC Home to VT Find, PC Page Up to VT Prev, PC Delete to VT Remove, PC End to VT Select, PC Page Down to VT Next.

Function keys. There are 12 function keys on the PC keyboard and 20 on the VT keyboard, so I map PC F1 thru F12 to VT F1 thru F12 (except for F1 thru F5 as ** below) and PC Shift F1 thru Shift F10 to VT F11 thru F20. ** The VT keys F1 thru F5 are local hardware function keys so there is nothing to emulate, however some PC to VT emulations in the past have mapped PF1 thru PF4 here, so I have done that too, even though they are already mapped on the auxiliary numeric keypad.

Xterm functionality. You lose some xterm functions when you remap the keyboard, however this script implements a scroll back buffer of 1000 lines which you scroll through using Shift and Up (a.k.a. Up Arrow or Cursor Up key) or Shift and Down.

There many different opinions on how a PC keyboard should be mapped to a VMS one - this is mine. Some VT keys are intentionally mapped twice because it seemed useful or logical to me. Please feel free to modify this script to suit yourself. I recommend the Xterm faq, the Xterm man pages, the VT220 Pro- grammer Pocket Guide and the VT220 Programmer's Reference Manual.

            PC Key     maps to   VT Key.
            ------               ------
          	F1                   PF1         
           	F2                   PF2
           	F3                   PF3
           	F4                   PF4
           	F5                   unused
           	F6                   F6
           	F7                   F7
           	F8                   F8
           	F9                   F9
           	F10                  F10
           	F11                  F11
           	F12                  F12
	Shift F1             F11
	Shift F2             F12
	Shift F3             F13
	Shift F4             F14
	Shift F5             F15 (Help)
	Shift F6             F16 (Do)
	Shift F7             F17
	Shift F8             F18
	Shift F9             F19
	Shift F10            F20
	Shift F11            F11
	Shift F12            F12
	Print                Help (F15)
	Cancel               Do   (F16)
	Pause                Keypad Minus

	Insert               Insert Here
	Delete               Remove
	Home                 Find
	End                  Select
	Prior                Prev
	Next                 Next
	BackSpace            BackSpace (sends DEL - ascii 127)

            Num_Lock             PF1
	KP_Divide            PF2
	KP_Multiply          PF3
	KP_Subtract          PF4
	KP_Add               Keypad Comma
	KP_Enter             Enter
	KP_Decimal           Period
	KP_0                 Keypad 0
	KP_1                 Keypad 1
	KP_2                 Keypad 2
	KP_3                 Keypad 3
	KP_4                 Keypad 4
	KP_5                 Keypad 5
	KP_6                 Keypad 6
	KP_7                 Keypad 7
	KP_8                 Keypad 8
	KP_9                 Keypad 9
           	Up                   Up
	Shift Up	     Scroll Back 
           	Down                 Down
	Shift Down	     Scroll Forward
      	Right                Right
      	Left                 Left       

Erik Ahlefeldt - [email protected] May 2000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment