C3270/curses

Description
c3270 is based on the curses library.

curses is a library that allows an application to do input and output on a variety of character-mode terminals and terminal emulators. Different terminals and terminal emulators use various conventions for drawing text on the screen and for representing what keys have been pressed. The curses library insulates the application from the specifics of these conventions, and instead presents an abstracted interface. The application tells curses to draw some text with a green foreground and a blue background at some particular screen coordinates, and curses translates that into the right sequence of characters to actually do that. Similarly, the user presses the F1 key, which generates a device-specific sequence of input characters, often beginning with the Esc (U+001B) key; curses delivers an input event to the application indicating that F1 was pressed.

In theory, this all works perfectly. In practice, it often does not.

Components
There are many moving parts in this process, and any of them can go wrong.

The terminal or terminal emulator
The terminal or terminal emulator may claim to be compatible with some industry-standard device, such as a DEC VT100 or an xterm. This might be true to some extent, but it might not be. Or the terminal might only implement a subset of the standard device's functionality. Or it might implement a different sub-model of the standard device than the one the author of the terminfo entry was using. Or it might emulate that device incorrectly.

The terminal name
curses decides what kind of device it is using based on a simple string: the terminal name. This name is usually stored in the TERM environment variable. The problem is that most terminal emulators allow the terminal name to be configured, and users can modify the value of TERM. This is great for ironing out issues with incorrect terminfo entries, but it is also another knob to set incorrectly. For example, by default the PuTTY terminal emulator uses a terminal name of xterm, while the most accurate terminal name for it is putty.