C3270/keymap

Description
How to create a c3270 custom keymap.

First steps
First, you might want to make sure that the action you want isn't already defined in the default keymap. The default keymap defines common actions. For example, the Reset action, which unlocks the keyboard, is defined as Ctrl-R.

Defining a Simple Keymap in .c3270pro
Using your favorite text editor, create a file called  in your home directory. In that file, put the following: ! Use the 'mine' keymap, defined below c3270.keymap: mine ! Definition of the 'mine' keymap c3270.keymap.mine: \ &lt;Key>PPAGE: PF(7)\n\ &lt;Key>NPAGE: PF(8)

The first entry tells c3270 to use the keymap named. The second entry is the definition of the  keymap itself.

Now, run c3270, and do not specify a -keymap command-line option. The PPAGE key (usually labelled Page Up) will now emulate the 3270 PF7 key, and the NPAGE key (usually labelled Page Down) will emulate the 3270 PF8 key. (If you do not have a Page Up or Page Down key, or if these keys are not properly defined in your terminfo database, this will not work.)

Rules for Keymap Definitions
You may now edit the keymap to create your own custom definition. Here is the full set of rules. c3270.keymap.name: \ where name is replaced by the name of the keymap you want to define. (Note the backslash, which must be the last character on the line). modifier &lt;Key> keyname... : Action(args)\n\ where: such as semicolon (the ';' key) or BACKSPACE (the Backspace key) Action is a c3270 action such as Enter or PF args are the optional action arguments, such as a number to specify which PF key to transmit.  Note that each body line must end with the three characters '\n\'. The last line is the same as the body lines, but must not have the '\n\' at the end:  modifier &lt;Key> keyname : Action(args) </ul> </ul>
 * The first line is always:
 * The body (middle) lines always have the format:
 * modifier is an optional keyboard modifier such as Ctrl or Alt.
 * keyname is a curses key name: a symbolic name for a key,

How to Find the Key Names The names for alphanumeric keys can be entered literally, e.g., a</tt> for the A</tt> key. They can also be entered using ISO 8859-1 standard names, such as colon</tt> for the :</tt> key (which would otherwise confuse the keymap syntax). Finally, Unicode values (U+</tt>nnnn) can be used.

The list of names for special keys, such as NPAGE, PPAGE and BACKSPACE, is on the ncurses man page curs_getch.

To find out which key name or sequence of key names is being generated for any given key on your keyboard, start c3270 with the -trace option, and do not connect to a host. Then press the key(s) in question. Then exit c3270. c3270 will create the file /tmp/x3trc.pid</tt>. In that file, several lines of text will be generated for each key you press. Each entry will begin with the text for the left-hand side of a keymap entry that will match the key you pressed. You can cut and paste the text into your keymap definition.

How to Find the Actions These are documented on the <a href="c3270-man.html#actions">c3270 manual page</a>.

How to Debug Your Keymap There are two c3270 options to aid with keymap debugging. The -trace command-line option causes c3270 to create a trace file, /tmp/x3trc.pid</tt>. That file traces each keyboard and mouse event that c3270 processes. The information traced includes the keymap (and line within the keymap) that matched the event, the c3270 action that was run in response, and if for some reason the action did not work, why it did not work. The show keymap command at the c3270> prompt displays the current keymap. This tells you exactly which keymap entries are active. Often times it will point out that c3270 isn't using the keymap you thought it was, or that some of your keymap entries are interfering with one another.

Note that one of the commonest problems in configuring c3270 is figuring out where resources are being defined. Keymaps are defined using resources, so this problem can complicate keymap definitions. c3270 resources can be defined in a number of different places:
 * In the definitions compiled into c3270.
 * In the file  in your home directory.
 * In session file.
 * From -xrm command-line options.