-
-
Notifications
You must be signed in to change notification settings - Fork 487
Version 3.0 #137
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
Open
ctrlcctrlv
wants to merge
14
commits into
abishekvashok:master
Choose a base branch
from
ctrlcctrlv:v3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Version 3.0 #137
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
34d467e
Version 3.0
ctrlcctrlv 2928b08
Use katakana by default; fix `CHARSET_FONT`
ctrlcctrlv d44df0a
Email fix (…@…> ⇒ <…@…>
ctrlcctrlv 611134b
only `change_charset(…)` if necessary
ctrlcctrlv 755ed49
make libintl disabled by default
ctrlcctrlv 4f22912
Undo README change I don't remember making :-)
ctrlcctrlv 3c85d58
-`assert.h` include (unused)
ctrlcctrlv 951aedc
[nit] Make `CHARSETS` multiline
ctrlcctrlv 892d0e5
[charset] Fix off-by-one error
ctrlcctrlv 5625435
Fix build failure owing to null `LOCALEDIR`
ctrlcctrlv 6ca8aeb
Attempt to fix remaining gettext issues with build.
ctrlcctrlv e7094b9
Make behavior match reality in re default charset
ctrlcctrlv d452c5b
Add offset to matrix_cell.val if it will be printed.
ark231 6d2cddd
Fix Unix console
ctrlcctrlv 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 hidden or 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 hidden or 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,111 @@ | ||
| enum CHARSET { | ||
| CHARSET_INVALID = -2, | ||
| CHARSET_USERDEFINED = -1, | ||
| CHARSET_DEFAULT = 0, CHARSET_ASCII = 0, | ||
| CHARSET_KATAKANA, CHARSET_SYMBOLS, CHARSET_LAMBDA, CHARSET_FONT, | ||
| CHARSET_MAX | ||
| }; | ||
|
|
||
| // Order determined by CHARSET enum above, starting at 0. | ||
| static const uint32_t CHARSETS[CHARSET_MAX][2] = { | ||
| // DEFAULT/ASCII | ||
| // (! }) | ||
| {0x21, 0x7D}, | ||
| // KATAKANA | ||
| // (ヲ ン) | ||
| {0xFF66, 0xFF9D}, | ||
| // SYMBOLS | ||
| // (、 〾) | ||
| {0x3001, 0x303E}, | ||
| // LAMBDA (λ) | ||
| {0x3BB, 0x3BB}, | ||
| // FONT | ||
| // (¦ Ù) | ||
| {0xA6, 0xD9} | ||
| }; | ||
|
|
||
| char* codepoint_to_str(uint32_t ch) { | ||
| short len = 1; | ||
| if (ch > 0x80) len++; | ||
| if (ch > 0x800) len++; | ||
| if (ch > 0x10000) len++; | ||
| if (ch > 0x110000) return NULL; | ||
|
|
||
| char* dest = calloc(len+1, sizeof(char)); | ||
|
|
||
| switch (len) { | ||
| case 1: | ||
| dest[0] = (char)ch; | ||
| break; | ||
| case 2: | ||
| dest[0] = (ch>>6) | 0xC0; | ||
| dest[1] = (ch & 0x3F) | 0x80; | ||
| break; | ||
| case 3: | ||
| dest[0] = (ch>>12) | 0xE0; | ||
| dest[1] = ((ch>>6) & 0x3F) | 0x80; | ||
| dest[2] = (ch & 0x3F) | 0x80; | ||
| break; | ||
| case 4: | ||
| dest[0] = (ch>>18) | 0xF0; | ||
| dest[1] = ((ch>>12) & 0x3F) | 0x80; | ||
| dest[2] = ((ch>>6) & 0x3F) | 0x80; | ||
| dest[3] = (ch & 0x3F) | 0x80; | ||
| break; | ||
| } | ||
|
|
||
| return dest; | ||
| } | ||
|
|
||
| char** expand_charset(char* charset) { | ||
| char** ret = calloc(strlen(charset)+1, sizeof(char**)); | ||
| char** pt = ret; | ||
| char* tok = strtok(charset, " "); | ||
| while (tok != NULL) { | ||
| char* new_tok = calloc(5, sizeof(char*)); | ||
| strcpy(new_tok, tok); | ||
| *pt = new_tok; | ||
| pt++; | ||
| tok = strtok(NULL, " "); | ||
| } | ||
| if (pt == ret) { | ||
| char* new_tok = calloc(5, sizeof(char*)); | ||
| strcpy(new_tok, charset); | ||
| *pt = new_tok; | ||
| pt++; | ||
| } | ||
| *pt = ""; | ||
| return ret; | ||
| } | ||
|
|
||
| char* charset_to_string(const uint32_t charset[2]) { | ||
| const uint32_t minc = charset[0]; | ||
| const uint32_t maxc = charset[1]; | ||
| uint32_t maxlen = maxc - minc; | ||
| maxlen *= 5; | ||
| maxlen += 2; | ||
| char* ret = calloc(maxlen, sizeof(char)); | ||
| char* pt = ret; | ||
| for (uint32_t i = minc; i <= maxc; i++) { | ||
| char* cp = codepoint_to_str(i); | ||
| strcpy(pt, cp); | ||
| while (*pt != '\0') pt++; | ||
| if (i != maxc) { | ||
| *pt++ = ' '; | ||
| } | ||
| } | ||
| return ret; | ||
| } | ||
|
|
||
| void usage_charsets() { | ||
| printf("\nCHARSETS:\n"); | ||
| printf(" -A: Use ASCII (default)\n"); | ||
| printf("\t%s\n", charset_to_string(CHARSETS[CHARSET_DEFAULT])); | ||
| printf(" -c: Use Japanese half-width katakana, similar to original matrix. Requires appropriate fonts\n"); | ||
| printf("\t%s\n", charset_to_string(CHARSETS[CHARSET_KATAKANA])); | ||
| printf(" -l: Linux mode (uses Linux tty font)\n"); | ||
| printf(" -m: lambda mode (equivalent to -u λ)\n"); | ||
| printf(" -S: CJK symbols mode. Requires appropriate fonts\n"); | ||
| printf("\t%s\n", charset_to_string(CHARSETS[CHARSET_SYMBOLS])); | ||
| printf(" -U [charset]: user-defined (space separated values, e.g. 'あ い お')\n"); | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.