console-tty37-viewer 1 user commands nosh
console-tty37-viewer TUI viewer for sort-of Teletype Model 37 text
`console-tty37-viewer` --cursor-keypad-application-mode --calculator-keypad-application-mode --no-alternate-screen-buffer --inversescreen boolean --tui-level level --squeeze-empty-lines -s filename(s)

## Description

`console-tty37-viewer` is a simple TUI viewer for text that is in the format emitted by `grotty` 1 and others. It is designed to be a safer `MANPAGER` than pagers that attempt to pass through control sequences in some "raw" mode. `console-tty37-viewer` fully decodes all of its input per ECMA-48, and emits its own control sequences constructed from scratch.

The text data are read from the command's standard input, or the list of files denoted by filename(s), and parsed at startup; before its initializes its display.

### Unicode Teletype Model 37 and ECMA-48 text effects

Text data are treated as if they were being output to a modernized Teletype Model 37 printer, that actually understands UTF-8 and a small part of ECMA-48. Most text in practice, nowadays, in this form is the output of commands like `grotty` 1 and is encoded as UTF-8 and contains a few ECMA-48 sequences. Simply pass any that is not through iconv 1 or a similar tool.

Text input operates on a virtual print line, with a moving print head. Normal printable output overstrikes the current position and moves the print head along, with not yet printed to positions taken to contain SPC. Carriage Return and Backspace can be used to return the print head to the first column and move the print head backwards one column, respectively. TAB emits enough SPC characters to move to the next fixed tabstop, at a multiple of 8 columns.

All four of Newline, Line Feed, Vertical Tab, and Form Feed move to the first column on a new line; as will attempting to print beyond the right margin. The right margin is taken from the value of the `COLUMNS` environment variable, falling back to the width of the output terminal device, falling back to a hardwired setting of 80 columns. There is no reverse scrolling or cursor addressing; once output has moved to the next virtual print line there is no way to affect the last one.

All ECMA-48 escape sequences, control sequences, and operating system control sequences are stripped and ignored, except for SGR. The SGR control sequence changes character colours and attributes. Boldface, italics, underline, faint, strikethrough, reverse video, and invisible are all supported; although the rendering terminal might itself not be capable of some of these.

Several Teletype Model 37 effects are supported. Overstriking most characters just replaces the character, with the following exceptions:

- Overstriking an underscore `_` with something else, or something else with an underscore, causes the position at the print head to be that something else, underlined. As a special case, overstriking an underscore with itself becomes a doubly-underscored SPC.

- Overstriking any (non-underscore) character with itself causes the position at the print head to be boldfaced.

- Overstriking with SPC has no effect on the character already present, as it the case for actual line printers.

- Overstriking characters with Unicode combining characters attempts to perform the Unicode normalization into precomposed forms. If there is no defined composition, the overstruck character is replaced with SPC, which always has a precomposed form for combining diacritics.

### User interface

`console-tty37-viewer` opens its controlling terminal via `/dev/tty` and uses that for its user interface, both input and output.

If its standard input is also its controlling terminal, odd behaviour may result, determined by how the operating system kernel decides to route input. This is not a sensible usage of the program; so simply do not do this.

Although its behaviour is controlled by the `TERM` 7 environment variable, it does not use terminfo 3 or termcap 3. It instead uses TerminalCapabilities 3. The terminal type determines a few terminal capabilities (such as whether the terminal can actually handle DEC private mode control sequences at all, and its degree of ISO 8613-6/ITU T.416 support), but most processing adheres to the ECMA-48 and ISO 8613-6 de jure standard control sequences and the DEC VT, DTTerm, and AIXTerm de facto standard ones.

The user interface responds to actual arrow keys, HJKL navigation in the style of vi 1, and WASD navigation. (The command only knows about characters and escape/control sequences coming from the terminal. Thus the latter two are not particularly ergonomic on several countries' standard keyboard layouts.)

The cursor is initially positioned on the first line, so the screen will not begin to scroll until the cursor is moved to the bottom.

Various common control characters with conventional special meanings may be used to quit, although the simplest way of quitting is simply `q`.

The --cursor-keypad-application-mode and --calculator-keypad-application-mode command-line options instruct `console-tty37-viewer` to switch, respectively, the cursor keypad and the calculator keypad of the realizing terminal into their "application" modes. Otherwise it switches them into their "normal" modes. "application" mode is generally not useful to `console-tty37-viewer`, since it makes cursor and calculator keys indistinguishable from accelerator keys. The --no-alternate-screen-buffer command-line option instructs `console-tty37-viewer` to not switch to the alternative screen buffer. This has two uses. First, it allows one to retain visibility of displayed information after the program has exited (although setterm 1 provides access to the alternative screen buffer). Second, it works around problems with some (yet more!) broken terminal emulators that attempt to be and fail at being like XTerm, which forcibly change cursor and editing keys into application mode when the alternative screen buffer is active. The --inversescreen command-line option instructs `console-tty37-viewer` to switch the DECSCNM ("light"/"dark" screen mode) private mode on or off. The --tui-level command-line option constrains the use of MouseText or Unicode block graphics and line drawing characters in TUI widgets; currently none.

## Author

Jonathan de Boyne Pollard