Home
Software
Utilities
About
Reader (night2.nt)
https://centaur.pw/software/night/night2.nt
[
Direct Link
]
:clear::cursor: :center::bgblue: :black:Night User Manual :reset::.center: :center::bgcyan: :black:Version 2.2 :reset::.center: :center::bgwhite: :black:7/27/2025 :reset::.center: :center::bold::cyan:Copyright (C) Centaur, 2025.:reset::.center: :center::bold::cyan:All Rights Reserved.:reset::.center: :box::bold::green:About:reset::.box: Night is a formatting system for coloring and styling console text. :box::bold::green:Command Line Syntax:reset::.box: :purple:night2:reset: :cyan:file:reset: :bold:...:reset: :purple:night2:reset: :bold::red:"`:reset::green:cat:reset: :cyan:file:reset::bold::red:`":reset: :bold:|:reset: :bold::red:"$(:reset::green:cat:reset: :cyan:file:reset::bold::red:)":reset: :green:cat:reset: :cyan:file:reset: :bold::red:|:reset: :purple:night2:reset: :purple:night2:reset: :red:-s:reset: :bold:|:reset: :red:--string:reset: :cyan:string:reset: :bold:...:reset: :purple:night2:reset: :red:-t:reset: :bold:|:reset: :red:--test:reset: :purple:night2:reset: :red:-h:reset: :bold:|:reset: :red:--help:reset: :box::bold::green:Description:reset::.box: :purple:night2:reset: processes text color and effect codes from :cyan:file:reset: or from :cyan:string:reset: as provided on the command line. It is not strictly necessary for string to be enclosed in quotes; all command lines arguments are concatenated. The file may be specified using any of the three methods shown above, but :purple:night2:reset: also allows for stand-alone executable scripts. These scripts must begin with :none::bold::cyan:#!/usr/local/bin/night2:reset: (the standard installation directory for :purple:night2:reset:) and must be configured to allow execution. All lines beginning with :bold::cyan:#:reset: in an input file will not be displayed. All input to the program is read line-by-line. If the program is called with :cyan:file:reset:, or if a file is executed as a stand-alone script, :purple:night2:reset: reads Night codes from the specified file and outputs the result. If called with the :red:-s:reset:/:red:--string:reset: option and :cyan:string:reset:, :purple:night2:reset: reads Night codes in the string and outputs the result. Called with no parameters, :purple:night2:reset: will read Night codes from :green:standard input:reset: and output the result. This is most useful for piping to :purple:night2:reset: and executing stand- alone Night scripts. When called with :red:-t:reset:/:red:--test:reset:, the program outputs a test pattern to illustrate the effects of each code. Some terminals may incorrectly display certain codes such as :bold::blue:::none:faint::reset:, :bold::blue:::none:italic::reset:, :bold::blue:::none:underline::reset:, and :bold::blue:::none:strike::reset:; however, all are known to work correctly in :green:xterm:reset:. Centered text and box drawing are not ANSI features and are expected to behave the same on all terminals. When called with :red:-h:reset:/:red:--help:reset:, the program usage and Night code table are displayed. :box::bold::green:Night Codes:reset::.box: Night codes are case-sensitive and always begin and end with :bold::cyan:::reset: (colon character). The following information can also be viewed with :bold::cyan:night2 --help:reset:: :underline::bold:Foreground Color:reset: :underline::bold:Night Code:reset: :underline::bold:Equivalent Character Sequence:reset: :bgwhite::black:Black:reset: :bold::blue:::none:black: :green:\e[30m:reset: :red:Red:reset: :bold::blue:::none:red: :green:\e[31m:reset: :green:Green:reset: :bold::blue:::none:green: :green:\e[32m:reset: :yellow:Yellow:reset: :bold::blue:::none:yellow: :green:\e[33m:reset: :blue:Blue:reset: :bold::blue:::none:blue: :green:\e[34m:reset: :purple:Purple:reset: :bold::blue:::none:purple: :green:\e[35m:reset: :cyan:Cyan:reset: :bold::blue:::none:cyan: :green:\e[36m:reset: :white:White:reset: :bold::blue:::none:white: :green:\e[37m:reset: :bold::underline:Background Color:reset: :bold::underline:Night Code:reset: :bold::underline:Equivalent Character Sequence:reset: :bgblack:Black:reset: :bold::blue:::none:bgblack: :green:\e[40m:reset: :bgred::black:Red:reset: :bold::blue:::none:bgred: :green:\e[41m:reset: :bggreen::black:Green:reset: :bold::blue:::none:bggreen: :green:\e[42m:reset: :bgyellow::black:Yellow:reset: :bold::blue:::none:bgyellow: :green:\e[43m:reset: :bgblue::black:Blue:reset: :bold::blue:::none:bgblue: :green:\e[44m:reset: :bgpurple::black:Purple:reset: :bold::blue:::none:bgpurple: :green:\e[45m:reset: :bgcyan::black:Cyan:reset: :bold::blue:::none:bgcyan: :green:\e[46m:reset: :bgwhite::black:White:reset: :bold::blue:::none:bgwhite: :green:\e[47m:reset: :bold::underline:Text Style:reset: :bold::underline:Night Code:reset: :bold::underline:Equivalent Character Sequence:reset: :bold:Bold Text:reset: :bold::blue:::none:bold: :green:\e[1m:reset: :faint:Faint Text:reset: :bold::blue:::none:faint: :green:\e[2m:reset: :italic:Italic Text:reset: :bold::blue:::none:italic: :green:\e[3m:reset: :underline:Underline Text:reset: :bold::blue:::none:underline: :green:\e[4m:reset: :strike:Strikeout Text:reset: :bold::blue:::none:strike: :green:\e[9m:reset: :reverse:Reverse Video:reset: :bold::blue:::none:reverse: :green:\e[7m:reset: Reset All :bold::blue:::none:reset: :green:\e[0m:reset: Begin Center Text :bold::blue:::none:center::reset: :bold:N/A:reset: End Center Text :bold::blue:::none:.center::reset: :bold:N/A:reset: Begin Box :bold::blue:::none:box::reset: :bold:N/A:reset: End Box :bold::blue:::none:.box::reset: :bold:N/A:reset: Newline :bold::blue:::none:newline: :green:\n:reset: None :bold::blue:::none:none: :green:Space:reset: :bold:+ :green:\b:reset: :bold::underline:Screen and Cursor:reset: :bold::underline:Night Code:reset: :bold::underline:Equivalent Character Sequence:reset: Clear Screen :bold::blue:::none:clear: :green:\e[2J:reset: Reset Cursor :bold::blue:::none:cursor: :green:\e[;H:reset: Save Cursor :bold::blue:::none:start: :green:\e7:reset: Restore Cursor :bold::blue:::none:restore: :green:\e8:reset: Cursor Up :bold::blue:::none:up: :green:\e[1A:reset: Cursor Down :bold::blue:::none:down: :green:\e[1B:reset: Cursor Left :bold::blue:::none:left: :green:\e[1D:reset: Cursor Right :bold::blue:::none:right: :green:\e[1C:reset: :box::bold::green:Code Details:reset::.box: Foreground color codes are used to set the color of the text to be used until :bold::blue:::none:reset::reset: is encountered. Likewise, background color codes will set the background color for each character (including blank space) until :bold::blue:::none:reset::reset: is encountered. :bold::blue:::none:bold::reset:, :bold::blue:::none:faint::reset:, :bold::blue:::none:italic::reset:, :bold::blue:::none:underline::reset:, :bold::blue:::none:strike::reset:, and :bold::blue:::none:reverse::reset: follow the same rules as the color codes. :bold::blue:::none:center::reset: will center all text until :bold::blue:::none:.center::reset: is encountered according to the number of columns available on the terminal. If the text to be centered is wider than the number of columns, the text will not be centered but instead will be printed from the left of the screen. Only one line at a time can be centered; :bold::blue:::none:newline::reset: will break the formatting. Each line of text to be centered must be placed between :bold::blue:::none:center::reset: and :bold::blue:::none:.center::reset: tags on its own line. :bold::blue:::none:box::reset: will enclose all text until :bold::blue:::none:.box::reset: is encountered. Boxes are as wide as the longest line contained within. If the longest line of the enclosed text is wider than the number of columns, no error will occur but the box will be malformed. :bold::blue:::none:box::reset: definitions should be written on a single line, using :bold::blue:::none:newline::reset: to create a box with multiple lines. If the number of lines enclosed in a box exceeds the maximum number allowed (set at compile-time in :yellow:night.h:reset: source file as :bold::yellow:MAX_LINES:reset:; default value is :bold:40:reset:), the text will be printed without the box characters without causing an error. To set the border color of a box, place color codes on their own line above the :bold::blue:::none:box::reset: definition and prepend :bold::blue:::none:reset::reset: followed by other codes as desired to the enclosed text. Other Night codes can be placed directly after the :bold::blue:::none:box::reset: tag until the end of the text just before the :bold::blue:::none:.box::reset: tag and before any :bold::blue:::none:newline::reset:; then :bold::blue:::none:reset::reset: should be used followed by the same code(s) as provided on the line before the :bold::blue:::none:box::reset: definition. Repeat for each :bold::blue:::none:newline::reset: present in the text. See the :bold::green:Examples:reset: section of this document. The :bold::blue:::none:start::reset:, :bold::blue:::none:restore::reset:, :bold::blue:::none:up::reset:, :bold::blue:::none:down::reset:, :bold::blue:::none:left::reset:, and :bold::blue:::none:right::reset: codes provide a means of moving the cursor one row or column at a time in any direction so that text can be printed anywhere; for example, these codes can be used to print text on the same line as an existing box. By beginning any such operation using :bold::blue:::none:start::reset:, it will be possible to return the cursor to its original position once the operation has finished using :bold::blue:::none:restore::reset:. See the :bold::green:Examples:reset: section of this document. :bold::blue:::none:center::reset: and :bold::blue:::none:box::reset: cannot be used together. Additionally, if a box is enclosed in another box, only one box will be displayed; boxes cannot be nested nor made to appear next to one another. :bold::blue:::none:newline::reset: is primarily used to create boxes with multiple lines of text, but may be used anywhere except between :bold::blue:::none:center::reset: and :bold::blue:::none:.center::reset: tags. The :bold::blue:::none:none::reset: code prints a space and then deletes it which has no effect on the text other than preventing Night codes from being processed, in case the intention is to print the exact text of a Night code. Place :bold::blue:::none:none::reset: within any Night code to prevent processing for each individual Night code as needed. :bold::blue:::none:reset::reset: will not disable centering or box drawing; :bold::blue:::none:.center::reset: must be used at the end of centered text, and :bold::blue:::none:.box::reset: must be used at the end of enclosed text. :bold::blue:::none:center::reset: will fail to center text if it appears on the same line as :bold::blue:::none:clear:::none:cursor::reset:; it is best to place :bold::blue:::none:center::reset: on a line under these codes if they appear. :box::bold::green:Examples:reset::.box: The :bold::blue:::none:reset::reset: code marks the end of all color and effect codes before it (except :bold::blue:::none:box::reset: and :bold::blue:::none:center::reset:): :bold:::none:bold:::none:underline:::none:cyan:Night::none:reset::reset: :bold::underline::cyan:Night:reset: The foreground color codes are used to set text color: :bold:::none:blue:Blue Text::none:reset::reset: :blue:Blue Text:reset: The background color codes set the background color: :bold:::none:bgred:::none:white:White on Red::none:reset::reset: :bgred::white:White on Red:reset: Colors and styles can be combined: :bold:::none:italic:::none:red:Red Italic Text::none:reset::reset: :italic::red:Red Italic Text:reset: Both foreground and background color can be manipulated: :bold:::none:bggreen:::none:black:Black on Green Text::none:reset::reset: :bggreen::black:Black on Green Text:reset: The :bold::blue:::none:center::reset: and :bold::blue:::none:.center::reset: tags are used to center text on a terminal. These can be placed either within or outside other Night codes: :bold:::none:center:::none:green:Centered Green Text::none:reset:::none:.center::reset: :center::green:Centered Green Text:reset::.center: :bold:::none:green:::none:center:Centered Green Text::none:.center:::none:reset::reset: :green::center:Centered Green Text:.center::reset: The :bold::blue:::none:bold::reset: code bolds or brightens color; it can be used before any or no color codes: :bold:::none:bold:::none:green:Green Text::none:reset::reset: :bold::green:Green Text:reset: :bold::blue:::none:faint::reset: marks the beginning of faint text (the opposite of bold): :bold:::none:faint:Faint Text::none:reset::reset: :faint:Faint Text:reset: :bold::blue:::none:italic::reset: can give text an italic appearance. On some terminals, the text may be underlined instead of italicized: :bold:::none:italic:::none:blue:Italicized Blue Text::none:reset::reset: :italic::blue:Italicized Blue Text:reset: The :bold::blue:::none:underline::reset: code underlines text: :bold:::none:underline:Underlined Text::none:reset::reset: :underline:Underlined Text:reset: :bold::blue:::none:strike::reset: draws a horizontal line through text (not available on all terminals): :bold:::none:strike:Struck-Out Text::none:reset::reset: :strike:Struck-Out Text:reset: The :bold::blue:::none:clear::reset: code clears the screen of text: :bold:::none:clear:Empty Screen:reset: The :bold::blue:::none:cursor::reset: code sets the cursor position to the upper left corner of the screen. This is most useful when used with :bold::blue:::none:clear::reset:: :bold:::none:clear:::none:white:::none:cursor:Clear Screen::none:reset::reset: The :bold::blue:::none:reverse::reset: code sets the current text color as the background color and the background color as the text color: :bold:::none:red:::none:reverse:Black on Red Text::none:reset::reset: :red::reverse:Black on Red Text:reset: :bold::blue:::none:newline::reset: breaks a line of text. It is necessary for line breaks within boxes but can be used elsewhere: :bold:::none:box:Line 1::none:newline:Line 2::none:.box::reset: :box:Line 1:newline:Line 2:.box: Placing the :bold::blue:::none:none::reset: code anywhere within a Night code will prevent it from being processed: :bold::bo::none:none:x:Unprocessed Code:.box::none:none:::reset: :bo:none:x:Unprocessed Code:.box:none:: Set the color of a box using color codes on the line above the :bold::blue:::none:box::reset: definition: :bold:::none:purple::reset: :bold:::none:box:::none:reset:Purple Box::none:purple:::none:.box::reset: :bold:::none:reset::reset: :purple: :box::reset:Purple Box:purple::.box: :reset: Another example with multiple lines, maintaining a blue border with different color codes used on text within: :bold:::none:bold:::none:blue::reset: :bold:::none:box:::none:reset:::none:green:Line 1::none:reset:::none:bold:::none:blue::reset: :bold:::none:newline:::none:red:Line 2::none:bold:::none:blue::reset: :bold:::none:reset:::none:bold:::none:blue:::none:.box::reset: :bold:::none:reset::reset: :bold::blue: :box::reset::green:Line 1:reset::bold::blue::newline::red:Line 2:bold::blue::reset::bold::blue::.box: :reset: (Lines 2 and 3 in the above example should appear on one line.) The following two lines will print Night using bold blue in a small box, save the cursor position afterwards with :bold::blue:::none:start::reset:, move the cursor to right side of the box using :bold::blue:::none:up::reset: and :bold::blue:::none:right::reset: codes, output the URL to the Centaur website, then move the cursor back to its position after the box: :bold:::none:box:::none:bold:::none:blue:Night::none:reset:::none:.box::reset: :bold:::none:start:::none:up:::none:up:::none:right:::none:right:::none:right:::none:right:::none:right::reset: :bold:::none:right:::none:right:::none:right:::none:right::reset: :bold:::none:underline:https://www.centaur.pw::none:reset:::none:restore::reset: :bold::box::bold::blue:Night:reset::.box::reset: :bold::start::up::up::right::right::right::right::right::right::right::right::right::underline:https://www.centaur.pw:reset::restore::reset: (Lines 2 and 3 in the above example should appear on one line.) In the first line, a simple box is drawn with the text Night appearing in bold blue. On the next line, :bold::blue:::none:start::reset: is used to save the cursor position (which in this case is at the line under the box in the first column). From here, the cursor is moved up two lines and then nine columns to the right so that the URL can be printed on the right side of the box. Finally, :bold::blue:::none:restore::reset: is called to return the cursor to its original position under the box. :box::bold::green:Author:reset::.box: :bold:Jon S.:reset: <:blue:jon@centaur.pw:reset:> :underline::cyan:https://www.centaur.pw:reset: