Add outline of sections with titles

This commit is contained in:
The Magician 2023-11-05 18:57:30 +00:00
parent 278b8f2e83
commit 052cbc1281
1 changed files with 136 additions and 5 deletions

View File

@ -36,6 +36,7 @@ title() {
section_introduction() { section_introduction() {
title "Introduction" title "Introduction"
thebookofcolors thebookofcolors
printf ' is an in-terminal manual on ANSI escape codes, or "color codes", for use in terminal emulators.\n' printf ' is an in-terminal manual on ANSI escape codes, or "color codes", for use in terminal emulators.\n'
printf 'Examples are given not only in written form, but "practical" form -- every escape code and option described in ' printf 'Examples are given not only in written form, but "practical" form -- every escape code and option described in '
@ -47,6 +48,7 @@ section_introduction() {
section_disclaimers() { section_disclaimers() {
title "Disclaimers" title "Disclaimers"
thebookofcolors thebookofcolors
printf ' is open-source software and is provided as-is with NO WARRANTY under applicable law.\n' printf ' is open-source software and is provided as-is with NO WARRANTY under applicable law.\n'
printf 'If any escape codes persist to your terminal session after viewing ' printf 'If any escape codes persist to your terminal session after viewing '
@ -58,21 +60,28 @@ section_disclaimers() {
section_anatomy() { section_anatomy() {
title "Anatomy of an ANSI Escape Code" title "Anatomy of an ANSI Escape Code"
printf 'Escape codes begin with `\e`, `\033`, or `\x1b`. These are all three different escape sequences which insert the ASCII character 27, or ESC. (This is why they''re called ANSI "escape" codes, because they begin with a literal escape character). The syntax `\e` is used throughout ' printf 'Escape codes begin with `\e`, `\033`, or `\x1b`. These are all three different escape sequences which insert the ASCII character 27, or ESC. (This is why they''re called ANSI "escape" codes, because they begin with a literal escape character). The syntax `\e` is used throughout '
thebookofcolors thebookofcolors
printf '. The choice is arbitrary, but consistent throughout.\n' printf '. The choice is arbitrary, but consistent throughout.\n'
printf 'The next character is a `[`. This combination of characters, an escape followed by an open bracket, is called the "CSI", or "Control Sequence Introducer", which indicates the start of a control code.' printf 'The next character is a `[`. This combination of characters, an escape followed by an open bracket, is called the "CSI", or "Control Sequence Introducer", which indicates the start of a control code.\n'
newline 2 newline
printf 'Overall, a control sequence is formatted like so:\n' printf 'Overall, a control sequence is formatted like so:\n'
printf '0x1B + "[" + <zero or more numbers, separated by semicolons> + <a letter>\n' printf '0x1B + "[" + <zero or more numbers, separated by semicolons> + <a letter>\n'
printf 'The CSI sequence we''ve gone over already. The easiest way to think about this is that the letter is the name of a function, and the semicolon-delimited numbers are the arguments to said function.\n' printf 'The CSI sequence we''ve gone over already. The easiest way to think about this is that the letter is the name of a function, and the semicolon-delimited numbers are the arguments to said function.\n'
printf 'By this model of thinking about escape sequences like function calls means you would read "\\e[0;1;34m" as m(0, 1, 34), and "\\e[A" as A().' printf 'By this model of thinking about escape sequences like function calls means you would read "\\e[0;1;34m" as m(0, 1, 34), and "\\e[A" as A().\n'
newline 2 newline
printf 'The "m" function is the one we''re interested in. This is the "SGR", or "Select Graphics Rendition", code, and it tells the terminal to activate color and other text effects, which is what we''re interested in.\n' printf 'The "m" function is the one we''re interested in. This is the "SGR", or "Select Graphics Rendition", code, and it tells the terminal to activate color and other text effects, which is what we''re interested in.\n'
} }
section_regular_colors() { section_regular_colors() {
printf '\e[4;37m\e[1;37mRegular Colors\e[0m\n' title "Codes 30-37; Regular Foreground Colors"
printf 'Originally, hardware video terminals only had support for eight standard colors.\n'
printf 'The SGR control codes 30 through 37 are used to set the foreground color to each of these colors.\n'
printf 'These colors and their respective escape codes are shown in the following table:\n'
newline newline
printf '\e[30m\\e[30m Black\e[0m\n' printf '\e[30m\\e[30m Black\e[0m\n'
@ -85,6 +94,85 @@ section_regular_colors() {
printf '\e[37m\\e[37m Light grey\e[0m\n' printf '\e[37m\\e[37m Light grey\e[0m\n'
} }
section_notes_on_names() {
title "Notes on the Names of Colors"
printf 'TODO\n'
}
section_reset() {
title "Code 0; Reset"
printf 'TODO\n'
}
section_bold_colors() {
title "Code 1; Bold Color"
printf 'TODO\n'
}
section_background_colors() {
title "Codes 40-47; Regular Background Colors"
printf 'TODO\n'
}
section_256_colors() {
title "Codes 38;5 and 48;5; 256 Colors"
printf 'TODO\n'
}
section_rgb_colors() {
title "Codes 38;2 and 48;2; RGB Colors"
printf 'TODO\n'
}
section_bright_colors() {
title "Codes 90-97 and 100-107; Foreground and Background Bright Colors"
printf 'TODO\n'
}
section_italics() {
title "Code 3; Italics"
printf 'TODO\n'
}
section_underline() {
title "Code 4; Underline"
printf 'TODO\n'
}
section_dreaded_blinking_text_of_doom() {
title "Codes 5 and 6; Blinking"
printf 'TODO\n'
}
section_inverse() {
title "Code 7; Inverse"
printf 'TODO\n'
}
section_using_escape_sequences_in_shell_prompt() {
title "Using Escape Sequences in Shell Prompts"
printf 'TODO\n'
}
section_table_of_all_sgr_commands() {
title "Table of All SGR Commands"
printf 'TODO\n'
}
section_credits() {
title "Credits"
printf 'TODO\n'
}
main() { main() {
thebookofcolors thebookofcolors
newline 2 newline 2
@ -99,6 +187,49 @@ main() {
newline newline
section_regular_colors section_regular_colors
newline
section_notes_on_names
newline
section_reset
newline
section_bold_colors
newline
section_background_colors
newline
section_256_colors
newline
section_rgb_colors
newline
section_bright_colors
newline
section_italics
newline
section_underline
newline
section_dreaded_blinking_text_of_doom
newline
section_inverse
newline
section_using_escape_sequences_in_shell_prompt
newline
section_table_of_all_sgr_commands
newline
section_credits
newline
#printf 'Use \\e (or \\033) followed by the control sequence specified next to activate that color.\n' #printf 'Use \\e (or \\033) followed by the control sequence specified next to activate that color.\n'
#printf 'Use the reset sequence "[0m" to remove all set colors and styles.\n' #printf 'Use the reset sequence "[0m" to remove all set colors and styles.\n'