TTY format: Difference between revisions

From XionKB
Jump to navigationJump to search
(Created page with "The '''TTY format''' is an ASCII text format designed to provide formatting controls within the capabilities of the original ASCII C0 control code set and with respect to the functionality of teletypewriter style printers. The recommended file extension for such files is <code>.tty</code>. ==Features== TTY text provides a subset of the usual "rich text" features, namely bold text, underlining, and differential colouring. Bold text is accomplished through a string of bac...")
 
 
(One intermediate revision by the same user not shown)
Line 16: Line 16:
===Overlap===
===Overlap===
This means the TTY format makes it possible to overlap text on top of itself within a single line, creating a kind of spooky cryptic effect normally not possible with any text rendering system. Backspaces can be used to achieve this piecewise or a carriage return may be issued that resets the write head to the line start.
This means the TTY format makes it possible to overlap text on top of itself within a single line, creating a kind of spooky cryptic effect normally not possible with any text rendering system. Backspaces can be used to achieve this piecewise or a carriage return may be issued that resets the write head to the line start.
This is also the method by which the diacritics diaeresis, acute, grave, circumflex and tilde are achieved for both capital and lowercase letters. The diacritic and the letter may appear in either order separated by a backspace.


==Rendering==
==Rendering==
The principal method of rendering is supposed to be inside a text editor, preferably one used for code editing. Writing a parser for TTY should be pretty straightforward, as it is almost entirely a task of simulating the motions of the teletypewriter according to this spec. Of course, TTY is also designed to be piped directly to 9-pin serial printers unmodified.
The principal method of rendering is supposed to be inside a text editor, preferably one used for code editing. Writing a parser for TTY should be pretty straightforward, as it is almost entirely a task of simulating the motions of the teletypewriter according to this spec.
 
Of course, TTY is also designed to be piped directly to 9-pin serial printers unmodified. Nevertheless, real world implementations will likely involve very crude "drivers" that strip out unsupported codes, such as <code>SI</code>/<code>SO</code> pairs for printers without a secondary ribbon.
 
===Automatic ligatures===
More modern rendering mediums can support automatic transformation of the ASCII source to use ligatures, smart quotation marks, and other niceties expected of finished literature. Rather than introducing Unicode into the TTY format, simple algorithms should be selectively enabled by the user at render time. The following transformations are possible:
* hyphen-minus to hyphen (U+2010) between words
* double hyphen-minus to em dash (U+2014) between words
* space-separated hyphen-minus to en dash (U+2013) between words
* opening and closing single and double quotation marks at beginning of and following words
* prime and double prime following decimal digits for latitude-longitude and imperial feet/inches
* hyphen-minus to hyphen-bullet (U+2043) at start of lines for lists
* asterisk to bullet (U+2022) at start of lines for lists
* registered symbol, copyright symbol, phonograph symbol, trademark sign and service mark sign from their parenthesised letters
* asterisk between decimal digits (optionally space-separated) to multiplication sign or middle dot
* solidus between decimal digits (optionally space-separated) to division sign
* capital S followed by period to section sign
* <code>+/-</code> to the plus-minus sign
* vulgar fractions to their Unicode counterparts
* <code>No.</code> followed by decimal digits (optionally space-separated) to numero sign
* "Tel.", "TEL.", "Fax." and "FAX." to their Unicode counterparts
* Functional programming ligatures [//archive.ph/sNLCx as seen in Fira Code, Monoid and Hasklig]


==Purpose==
==Purpose==

Latest revision as of 07:11, 21 February 2025

The TTY format is an ASCII text format designed to provide formatting controls within the capabilities of the original ASCII C0 control code set and with respect to the functionality of teletypewriter style printers. The recommended file extension for such files is .tty.

Features

TTY text provides a subset of the usual "rich text" features, namely bold text, underlining, and differential colouring. Bold text is accomplished through a string of backspaces followed by a repeating of the bolded substring, mimicking the way a typewriter would bold text by rewriting it over itself. Underlining is accomplished with the same lengthwise backspacing but followed with an equally long string of underscore characters instead of the original text. Differential colouring uses the ASCII codes shift in and shift out: one "shifts out" to the alternate colour, which is conventionally red but may be any colour the rendering user so chooses, and can later "shift back in" to the default black. Red was chosen as it has good contrast in both print and digital display.

Editors displaying TTY text should support the full dynamics of the following ASCII control codes:

  • Backspace (BS, 0x08)
  • Horizontal Tabulation (HT, 0x09)
  • Line Feed (LF, 0x0A)
  • Vertical Tabulation (VT, 0x0B)
  • Form Feed (FF, 0x0C)
  • Carriage Return (CR, 0x0D)
  • Shift Out (SO, 0x0E)
  • Shift In (SI, 0x0F)

Overlap

This means the TTY format makes it possible to overlap text on top of itself within a single line, creating a kind of spooky cryptic effect normally not possible with any text rendering system. Backspaces can be used to achieve this piecewise or a carriage return may be issued that resets the write head to the line start.

This is also the method by which the diacritics diaeresis, acute, grave, circumflex and tilde are achieved for both capital and lowercase letters. The diacritic and the letter may appear in either order separated by a backspace.

Rendering

The principal method of rendering is supposed to be inside a text editor, preferably one used for code editing. Writing a parser for TTY should be pretty straightforward, as it is almost entirely a task of simulating the motions of the teletypewriter according to this spec.

Of course, TTY is also designed to be piped directly to 9-pin serial printers unmodified. Nevertheless, real world implementations will likely involve very crude "drivers" that strip out unsupported codes, such as SI/SO pairs for printers without a secondary ribbon.

Automatic ligatures

More modern rendering mediums can support automatic transformation of the ASCII source to use ligatures, smart quotation marks, and other niceties expected of finished literature. Rather than introducing Unicode into the TTY format, simple algorithms should be selectively enabled by the user at render time. The following transformations are possible:

  • hyphen-minus to hyphen (U+2010) between words
  • double hyphen-minus to em dash (U+2014) between words
  • space-separated hyphen-minus to en dash (U+2013) between words
  • opening and closing single and double quotation marks at beginning of and following words
  • prime and double prime following decimal digits for latitude-longitude and imperial feet/inches
  • hyphen-minus to hyphen-bullet (U+2043) at start of lines for lists
  • asterisk to bullet (U+2022) at start of lines for lists
  • registered symbol, copyright symbol, phonograph symbol, trademark sign and service mark sign from their parenthesised letters
  • asterisk between decimal digits (optionally space-separated) to multiplication sign or middle dot
  • solidus between decimal digits (optionally space-separated) to division sign
  • capital S followed by period to section sign
  • +/- to the plus-minus sign
  • vulgar fractions to their Unicode counterparts
  • No. followed by decimal digits (optionally space-separated) to numero sign
  • "Tel.", "TEL.", "Fax." and "FAX." to their Unicode counterparts
  • Functional programming ligatures as seen in Fira Code, Monoid and Hasklig

Purpose

TTY exists to provide a better literate experience within the rigid and well-defined contours of monospaced teletypewriter printing. It is a low-level format that provides no "truly" rich-text experiences such as hyperlinking, tables of contents, organisational grouping tools, or diagrams of anything except those made in ASCII.

Eventually, TTY will be targeted by a roff-like "high level" format that provides such things with respect to the intended output being compatible with TTY, while also providing rendering to more conventional formats such as XHTML, PostScript, DVI and PDF.

Warts and specification

Light Lempel–Ziv compression (such as LZ4) can be used (outside the scope of the file format itself) to overcome the nominal "waste" of repeating characters to encode formatting. Such algorithms are supersets of run-length encoding using dictionaries and thus are virtually ideal for compressing such strings.

Eventually a formal specification can be put out fully describing TTY once the need arises, but for now it's more important to get it into use so that technical document authorship can commence in earnest with respect to web browsers, PDFs and printed documents alike.