-
-
Notifications
You must be signed in to change notification settings - Fork 239
Implement character table control and codepage 437 option #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6a230d3
Implement character table control and codepage 437 option
sharifhsn 4e66357
Use hyphens instead of underscores
sharifhsn c4f9195
Add default value for character table
sharifhsn 0c192e9
Make `CharTable` non-exhaustive
sharifhsn 29e3350
Rename `CharTable` to `CharacterTable`
sharifhsn e363f2f
Remove old `as_char` implementation
sharifhsn 9362c23
Attribute original author of CP437
sharifhsn 78477a9
Close quotation in help text
sharifhsn 58c8c06
Clarify use of ␀
sharifhsn 10ddbba
Use U+FB00 LATIN SMALL LIGATURE FF (ff) for FFh
sharifhsn 19f325a
Implement block character table
sharifhsn 8d5b355
Correct asterisk colorization
sharifhsn 7ef8e5a
Add test for code page 437
sharifhsn a0a7d67
Refactor color components into new module
sharifhsn dfb5d57
Remove block coloring option for refactor
sharifhsn 7ca0027
Correct docs
sharifhsn a56b3b0
Adjust color function to not include character_table
sharifhsn 1310b1d
Adjust color function to not take character_table as arg
sharifhsn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use owo_colors::{colors, Color}; | ||
|
||
pub const COLOR_NULL: &[u8] = colors::BrightBlack::ANSI_FG.as_bytes(); | ||
pub const COLOR_OFFSET: &[u8] = colors::BrightBlack::ANSI_FG.as_bytes(); | ||
pub const COLOR_ASCII_PRINTABLE: &[u8] = colors::Cyan::ANSI_FG.as_bytes(); | ||
pub const COLOR_ASCII_WHITESPACE: &[u8] = colors::Green::ANSI_FG.as_bytes(); | ||
pub const COLOR_ASCII_OTHER: &[u8] = colors::Green::ANSI_FG.as_bytes(); | ||
pub const COLOR_NONASCII: &[u8] = colors::Yellow::ANSI_FG.as_bytes(); | ||
pub const COLOR_RESET: &[u8] = colors::Default::ANSI_FG.as_bytes(); | ||
|
||
#[rustfmt::skip] | ||
pub const CP437: [char; 256] = [ | ||
// Copyright (c) 2016, Delan Azabani <delan@azabani.com> | ||
// | ||
// Permission to use, copy, modify, and/or distribute this software for any | ||
// purpose with or without fee is hereby granted, provided that the above | ||
// copyright notice and this permission notice appear in all copies. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
// | ||
// modified to use the ⋄ character instead of ␀ | ||
|
||
// use https://en.wikipedia.org/w/index.php?title=Code_page_437&oldid=978947122 | ||
// not ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT | ||
// because we want the graphic versions of 01h–1Fh + 7Fh | ||
'⋄','☺','☻','♥','♦','♣','♠','•','◘','○','◙','♂','♀','♪','♫','☼', | ||
'►','◄','↕','‼','¶','§','▬','↨','↑','↓','→','←','∟','↔','▲','▼', | ||
' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/', | ||
'0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?', | ||
'@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O', | ||
'P','Q','R','S','T','U','V','W','X','Y','Z','[','\\',']','^','_', | ||
'`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o', | ||
'p','q','r','s','t','u','v','w','x','y','z','{','|','}','~','⌂', | ||
'Ç','ü','é','â','ä','à','å','ç','ê','ë','è','ï','î','ì','Ä','Å', | ||
'É','æ','Æ','ô','ö','ò','û','ù','ÿ','Ö','Ü','¢','£','¥','₧','ƒ', | ||
'á','í','ó','ú','ñ','Ñ','ª','º','¿','⌐','¬','½','¼','¡','«','»', | ||
'░','▒','▓','│','┤','╡','╢','╖','╕','╣','║','╗','╝','╜','╛','┐', | ||
'└','┴','┬','├','─','┼','╞','╟','╚','╔','╩','╦','╠','═','╬','╧', | ||
'╨','╤','╥','╙','╘','╒','╓','╫','╪','┘','┌','█','▄','▌','▐','▀', | ||
'α','ß','Γ','π','Σ','σ','µ','τ','Φ','Θ','Ω','δ','∞','φ','ε','∩', | ||
'≡','±','≥','≤','⌠','⌡','÷','≈','°','∙','·','√','ⁿ','²','■','ff', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a leftover bug from my initial design. Originally, the colored characters were pre-colored and cached ahead of time. I changed the way that coloring works in #176 to write prefix color codes separately from the characters themselves. The caching is now unnecessary here.