<?xml version="1.0" encoding="UTF-8"?>
<!-- **************************************************************************
.... For copyright and licensing terms, see the file named COPYING.
.... **************************************************************************
.-->
<?xml-stylesheet href="tty37.css" type="text/css"?>

<refentry id="console-tty37-viewer">

<refmeta xmlns:xi="http://www.w3.org/2001/XInclude">
<refentrytitle>console-tty37-viewer</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="manual">user commands</refmiscinfo>
<refmiscinfo class="source">nosh</refmiscinfo>
<xi:include href="version.xml" />
</refmeta>

<refnamediv>
<refname>console-tty37-viewer</refname>
<refpurpose>TUI viewer for sort-of Teletype Model 37 text</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>console-tty37-viewer</command>
<arg choice='opt'>--cursor-keypad-application-mode</arg>
<arg choice='opt'>--calculator-keypad-application-mode</arg>
<arg choice='opt'>--no-alternate-screen-buffer</arg>
<arg choice='opt'>--inversescreen <replaceable>boolean</replaceable></arg>
<arg choice='opt'>--tui-level <replaceable>level</replaceable></arg>
<group choice='opt'>
<arg choice='plain'>--squeeze-empty-lines</arg>
<arg choice='plain'>-s</arg>
</group>
<arg choice='opt' repeat='rep'><replaceable>filename(s)</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<refsection><title>Description</title>

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

<para>
The text data are read from the command's standard input, or the list of files denoted by <arg choice='plain'><replaceable>filename(s)</replaceable></arg>, and parsed at startup; before its initializes its display.
</para>

<refsection><title>Unicode Teletype Model 37 and ECMA-48 text effects</title>

<para>
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 <citerefentry><refentrytitle><envar>grotty</envar></refentrytitle><manvolnum>1</manvolnum></citerefentry> and is encoded as UTF-8 and contains a few ECMA-48 sequences.
Simply pass any that is not through <citerefentry><refentrytitle>iconv</refentrytitle><manvolnum>1</manvolnum></citerefentry> or a similar tool.
</para>

<para>
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.
</para>

<para>
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 <envar>COLUMNS</envar> 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.
</para>

<para>
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.
</para>

<para>
Several Teletype Model 37 effects are supported.
Overstriking most characters just replaces the character, with the following exceptions:
</para>
<itemizedlist>
<listitem><para>
Overstriking an underscore <quote><computeroutput>_</computeroutput></quote> 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.
</para></listitem>
<listitem><para>
Overstriking any (non-underscore) character with itself causes the position at the print head to be boldfaced.
</para></listitem>
<listitem><para>
Overstriking with SPC has no effect on the character already present, as it the case for actual line printers.
</para></listitem>
<listitem><para>
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.
</para></listitem>
</itemizedlist>

</refsection>

<refsection><title>User interface</title>

<para>
<command>console-tty37-viewer</command> opens its controlling terminal via <filename>/dev/tty</filename> and uses that for its user interface, both input and output.
</para>
<caution>
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.
</caution>

<para>
Although its behaviour is controlled by the <citerefentry><refentrytitle><envar>TERM</envar></refentrytitle><manvolnum>7</manvolnum></citerefentry> environment variable, it does not use <citerefentry><refentrytitle>terminfo</refentrytitle><manvolnum>3</manvolnum></citerefentry> or <citerefentry><refentrytitle>termcap</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
It instead uses <citerefentry><refentrytitle>TerminalCapabilities</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
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.
</para>

<para>
The user interface responds to actual arrow keys, HJKL navigation in the style of <citerefentry><refentrytitle>vi</refentrytitle><manvolnum>1</manvolnum></citerefentry>, 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.)
</para>
<note>
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.
</note>

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

<para>
The <arg choice='plain'>--cursor-keypad-application-mode</arg> and <arg choice='plain'>--calculator-keypad-application-mode</arg> command-line options instruct <command>console-tty37-viewer</command> 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 <command>console-tty37-viewer</command>, since it makes cursor and calculator keys indistinguishable from accelerator keys.
The <arg choice='plain'>--no-alternate-screen-buffer</arg> command-line option instructs <command>console-tty37-viewer</command> 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 <citerefentry><refentrytitle>setterm</refentrytitle><manvolnum>1</manvolnum></citerefentry> 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 <arg choice='plain'>--inversescreen</arg> command-line option instructs <command>console-tty37-viewer</command> to switch the DECSCNM ("light"/"dark" screen mode) private mode on or off.
The <arg choice='plain'>--tui-level</arg> command-line option constrains the use of MouseText or Unicode block graphics and line drawing characters in TUI widgets; currently none.
</para>

</refsection>

</refsection>

<refsection><title>Author</title>
<para><author><personname><firstname>Jonathan</firstname> <surname>de Boyne Pollard</surname></personname></author></para>
</refsection>

</refentry>
