Project

General

Profile

Patching TERMINFO

Introduction

When using the native (NCURSES) ChUI client, some default TERMINFO definitions are broken. The vt320, vt220 and xterm definitions need to be fixed. This document details how to fix the TERMINFO definitions.

These TERMINFO definitions can be fixed on a system-wide basis or by using a private TERMINFO directory that is specific to FWD.

Using a Private TERMINFO Directory

Introduction

It is possible to configure FWD to use a private TERMINFO directory to override the system-wide TERMINFO for the subset of terminal defintions that need to be modified. Doing this has several advantages:

  • It ensures that the changes to these definitions will only affect FWD and will have no affect on other terminal applications.
  • It can be implemented in a directory that is:
    • Located in an arbitrary filesystem location.
    • Not owned by root.

The directory must be created in a location that is visible to the FWD client. In this directory there will be terminfo/(v|x)/ subdirectories which contain the modified TERMINFO definitions. Then by configuring the FWD client session to point to that directory, NCURSES will find the private TERMINFO definitions instead of the system-wide versions.

Creation

There are 2 ways to create this directory.

1. Allow FWD to automatically create it when the client starts.

By setting the client:chui:terminfo_override bootstrap configuration value to true, the FWD client will try to use any existing private directory containing TERMINFO definitions. If that directory does not exist, the FWD client will attempt to create it dynamically. It will use the TerminfoHelper class to unpack the terminfo/(v|x)/ subdirectories from the p2j.jar.

To specify the base directory in which to unpack and (later) find the private TERMINFO definitions, set the client:chui:terminfo_dirs_base to the directory name. If this bootstrap configuration value is not specified, then the same directory in which the libp2j.so is located will be used as the base directory.

2. Explicitly run the installation utility.

It is possible to create the custom TERMINFO_DIRS directory by running a utility program. To configure the directory from command line the following should be executed in a bash shell:

java -cp path/to/p2j.jar com.goldencode.p2j.ui.client.chui.driver.console.TerminfoHelper base/directory/path/

The base/directory/path/ directory must exist and the user running the command must have rights to modify that directory. The terminfo/(v|x)/ subdirectories will be unpacked from the p2j.jar and placed in that directory.

Enabling Usage at Runtime

There are 2 ways to enable this feature at runtime.

1. Set the TERMINFO_DIRS environment variable before running the FWD client.

NCURSES will look for the environment variable TERMINFO_DIRS to find its definitions. If the private directory is pre-pended to the front of this environment variable, then NCURSES will find the private definitions before it reads the system-wide definitions. This means that the TERMINFO_DIRS modifications should only occur in the FWD client processes and not in all processes (otherwise it will effectively make the edits system-wide).

For example the application deploy directory is the base for custom terminfo definitions and client.sh startup script is in deploy/client directory the TERMINFO_DIRS definition will be:

export TERMINFO_DIRS="../terminfo":$TERMINFO_DIRS

As part of the client side preparation this will modify the environment only for the time the client is executing. This ensures the system wide definition for TERMINFO_DIRS will be untouched after client session is completed.

This environment variable can be explicitly set before starting the FWD client. This will work well for any FWD client process that is launched under user control.

2. Force the FWD client to set the TERMINFO_DIRS environment variable.

For processes that are launched automatically (e.g. web clients, appserver agents, batch processes) by the FWD server, it may not be easily possible to set the environment variable. In this case, the FWD client can set the TERMINFO_DIRS environment variable itself. This will occur by setting the following bootstrap configuration values. These values can also be used in any explicit (e.g. scripted or manual) ClientDriver invocation.

To activate the feature, set the client:chui:terminfo_override bootstrap configuration value to true. This will cause the TERMINFO_DIRS environment variable to be set to the base directory.

To define the base directory explicitly, set the client:chui:terminfo_dirs_base to that directory name in which the terminfo/(v|x)/ subdirectories will exist. If not specified then the the base directory is computed at runtime as the directory from which the libp2.so native library is loading.

Editing the System-Wide TERMINFO Database

Manually Patching

Follow the next 3 steps to update the definitions (the example only shows vt320 case) manually.

Decompile the TERMINFO Entry

Use this command:

infocmp vt320 > vt320.tmp

The result will be saved in the temporary file.

Edit and Fix the Definitions

Edit the temp file vt320.tmp. Notice the TERMINFO location mentioned in the first line. It is typically: /usr/share/terminfo/v/vt320. Apply the specific changes documented here:

Definition xterm vt220 vt320
TAB n/a n/a ensure that ht=^I, exists and that knxt=^I, is deleted
HOME n/a n/a add or modify the khome= to be khome=\EOH.
END n/a add or modify the kend= to be kend=\E[F add or modify the kend= to be kend=\EOF
BACKSPACE add or modify kbs= to be kbs=\177 n/a n/a
cursor visibility n/a add or modify the civis= to be civis=\E[?25l
add or modify the cnorm= to be cnorm=\E[?25h
n/a

Save the file.

Recompile the TERMINFO Entry

Use the following command to compile the definition:

sudo tic -o/usr/share/terminfo vt320.tmp

Automating the Patching Process

Please see Automating the Patching Process for a solution.

The same patch_terminfo.sh script in the automated process can be ran manually, too:

wget https://proj.goldencode.com/attachments/download/5745/patch_terminfo.sh
chmod +x patch_terminfo.sh
sudo ./patch_terminfo.sh


© 2004-2025 Golden Code Development Corporation. ALL RIGHTS RESERVED.