Major fixup of stupid things...

This commit is contained in:
xolatile 2024-10-03 08:45:12 -04:00
parent 9a49f3a2cf
commit 02c1a362d7
14 changed files with 166 additions and 167 deletions

View File

@ -1,20 +1,19 @@
# xighlight
xighlight -- Program for highlighting program output, source code and various text files in terminal.
## xighlight -- Program for highlighting program output, source code and various text files in terminal.
- Everything related to my libraries is clean of all warning options on Clang, GCC and Valgrind.
Install: `$ sudo sh install.sh`
Compile: `$ sh compile.sh`
This library depends on:
- xtandard: https://gitlab.com/xolatile/xtandard
- xyntax: https://gitlab.com/xolatile/xyntax
About this program:
- You can easily add new syntax support with it, for your own language or some that I didn't include.
- There are 2 ways to use this program, you can see them below, or use -h / --help to see it.
Compile:
```bash
$ sh compile.sh
```
Install:
```bash
$ sudo sh install.sh
```
- There are 3 ways to use this program, you can see them below, or use -h / --help to see it.
- Everything related to my libraries is clean of all warning options on Clang, GCC and Valgrind.
Use:
```bash
@ -23,5 +22,4 @@ $ cat my_program.ext | xighlight [extension] -- "You need to specify the languag
$ xighlight [extension] < my_program.ext -- "Again, since it's reading from standard stream..."
```
Currently supported programming and scripting languages are:
- C, Ada, C++, assembly, Flat assembly, Fortran, shell.
![screenshot](screenshot.png)

View File

@ -2,6 +2,8 @@
set -xe
mkdir -p /usr/local/include/xolatile
cp xighlight /usr/local/bin/xighlight
exit

View File

@ -16,18 +16,18 @@ static void highlight_ada (void) {
int word;
xyntax_define (false, false, "--", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, false, "--", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
xyntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
syntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
}
xyntax_define (true, false, "()", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,:;<=>+-*/&|'", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "()", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,:;<=>+-*/&|'", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
}

View File

@ -35,23 +35,23 @@ static void highlight_assembly (void) {
int word;
xyntax_define (false, false, ";", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, false, ";", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
for (word = 0; word != (int) (sizeof (instructions) / sizeof (instructions [0])); ++word) {
xyntax_define (false, true, instructions [word], separators, '\0', colour_yellow, effect_bold);
syntax_define (false, true, instructions [word], separators, '\0', colour_yellow, effect_bold);
}
for (word = 0; word != (int) (sizeof (registers) / sizeof (registers [0])); ++word) {
xyntax_define (false, true, registers [word], separators, '\0', colour_cyan, effect_bold);
syntax_define (false, true, registers [word], separators, '\0', colour_cyan, effect_bold);
}
xyntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,+*-/%$<>", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,+*-/%$<>", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
xyntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
syntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
}

View File

@ -16,21 +16,21 @@ static void highlight_cpp (void) {
int word;
xyntax_define (false, false, "/*", "*/", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "//", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "#", "\n", '\\', colour_yellow, effect_italic);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, false, "/*", "*/", '\0', colour_grey, effect_bold);
syntax_define (false, false, "//", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "#", "\n", '\\', colour_yellow, effect_italic);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
xyntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
syntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
}
xyntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
xyntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
syntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
}

View File

@ -10,21 +10,21 @@ static void highlight_c (void) {
int word;
xyntax_define (false, false, "/*", "*/", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "//", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "#", "\n", '\\', colour_yellow, effect_italic);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, false, "/*", "*/", '\0', colour_grey, effect_bold);
syntax_define (false, false, "//", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "#", "\n", '\\', colour_yellow, effect_italic);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
xyntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
syntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
}
xyntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
xyntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
syntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
}

View File

@ -42,28 +42,28 @@ static void highlight_eaxhla (void) {
int word;
xyntax_define (false, false, "#", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "//", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, false, "#", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "//", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
for (word = 0; word != (int) (sizeof (declarations) / sizeof (declarations [0])); ++word) {
xyntax_define (false, true, declarations [word], separators, '\0', colour_yellow, effect_italic);
syntax_define (false, true, declarations [word], separators, '\0', colour_yellow, effect_italic);
}
for (word = 0; word != (int) (sizeof (instructions) / sizeof (instructions [0])); ++word) {
xyntax_define (false, true, instructions [word], separators, '\0', colour_yellow, effect_bold);
syntax_define (false, true, instructions [word], separators, '\0', colour_yellow, effect_bold);
}
for (word = 0; word != (int) (sizeof (registers) / sizeof (registers [0])); ++word) {
xyntax_define (false, true, registers [word], separators, '\0', colour_cyan, effect_bold);
syntax_define (false, true, registers [word], separators, '\0', colour_cyan, effect_bold);
}
xyntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,+*-/%$<>", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,+*-/%$<>", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
xyntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
syntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
}

View File

@ -40,27 +40,27 @@ static void highlight_flat (void) {
int word;
xyntax_define (false, false, ";", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, false, ";", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
for (word = 0; word != (int) (sizeof (instructions) / sizeof (instructions [0])); ++word) {
xyntax_define (false, true, instructions [word], separators, '\0', colour_yellow, effect_bold);
syntax_define (false, true, instructions [word], separators, '\0', colour_yellow, effect_bold);
}
for (word = 0; word != (int) (sizeof (registers) / sizeof (registers [0])); ++word) {
xyntax_define (false, true, registers [word], separators, '\0', colour_cyan, effect_bold);
syntax_define (false, true, registers [word], separators, '\0', colour_cyan, effect_bold);
}
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
xyntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_italic);
syntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_italic);
}
xyntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,+-=:;%$<>", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,+-=:;%$<>", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
xyntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
syntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
}

View File

@ -19,23 +19,23 @@ static void highlight_fortran (void) {
int word;
xyntax_define (false, false, "!", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, false, "!", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
xyntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
syntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
}
for (word = 0; word != (int) (sizeof (constants) / sizeof (constants [0])); ++word) {
xyntax_define (false, true, constants [word], separators, '\0', colour_yellow, effect_italic);
syntax_define (false, true, constants [word], separators, '\0', colour_yellow, effect_italic);
}
xyntax_define (true, false, "()[]", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ",:<=>+-*/&", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "()[]", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ",:<=>+-*/&", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
xyntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
syntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
}

View File

@ -10,30 +10,30 @@ static void highlight_shell (void) {
int word;
xyntax_define (false, false, "#", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
xyntax_define (false, true, "$#", " ", '\0', colour_pink, effect_italic);
xyntax_define (false, false, "$((", "))", '\0', colour_blue, effect_italic);
xyntax_define (false, false, "${", "}", '\0', colour_yellow, effect_italic);
xyntax_define (false, false, "$(", ")", '\0', colour_cyan, effect_italic);
syntax_define (false, false, "#", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, true, "$#", " ", '\0', colour_pink, effect_italic);
syntax_define (false, false, "$((", "))", '\0', colour_blue, effect_italic);
syntax_define (false, false, "${", "}", '\0', colour_yellow, effect_italic);
syntax_define (false, false, "$(", ")", '\0', colour_cyan, effect_italic);
xyntax_define (false, true, "&&", " ", '\0', colour_yellow, effect_italic);
xyntax_define (false, true, "||", " ", '\0', colour_yellow, effect_italic);
xyntax_define (false, true, ";;", " ", '\0', colour_yellow, effect_italic);
xyntax_define (false, true, "<<", " ", '\0', colour_yellow, effect_italic);
xyntax_define (false, true, ">>", " ", '\0', colour_yellow, effect_italic);
xyntax_define (false, true, "<>", " ", '\0', colour_yellow, effect_italic);
syntax_define (false, true, "&&", " ", '\0', colour_yellow, effect_italic);
syntax_define (false, true, "||", " ", '\0', colour_yellow, effect_italic);
syntax_define (false, true, ";;", " ", '\0', colour_yellow, effect_italic);
syntax_define (false, true, "<<", " ", '\0', colour_yellow, effect_italic);
syntax_define (false, true, ">>", " ", '\0', colour_yellow, effect_italic);
syntax_define (false, true, "<>", " ", '\0', colour_yellow, effect_italic);
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
xyntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
syntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
}
xyntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,:;<=>+*-/%!&~^?|@#$`", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,:;<=>+*-/%!&~^?|@#$`", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
xyntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
syntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
}

View File

@ -1,38 +1,38 @@
static void highlight_valgrind (void) {
char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
xyntax_define (false, false, "==", " ", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "//", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, false, "==", " ", '\0', colour_grey, effect_bold);
syntax_define (false, false, "//", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
xyntax_define (false, false, "Memcheck", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "Copyright", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "Using", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "Command", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "Memcheck", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "Copyright", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "Using", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "Command", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, true, "HEAP", separators, '\0', colour_pink, effect_italic);
xyntax_define (false, true, "LEAK", separators, '\0', colour_pink, effect_italic);
xyntax_define (false, true, "ERROR", separators, '\0', colour_pink, effect_italic);
xyntax_define (false, true, "SUMMARY", separators, '\0', colour_pink, effect_italic);
syntax_define (false, true, "HEAP", separators, '\0', colour_pink, effect_italic);
syntax_define (false, true, "LEAK", separators, '\0', colour_pink, effect_italic);
syntax_define (false, true, "ERROR", separators, '\0', colour_pink, effect_italic);
syntax_define (false, true, "SUMMARY", separators, '\0', colour_pink, effect_italic);
xyntax_define (false, true, "bytes", separators, '\0', colour_pink, effect_italic);
xyntax_define (false, true, "blocks", separators, '\0', colour_pink, effect_italic);
syntax_define (false, true, "bytes", separators, '\0', colour_pink, effect_italic);
syntax_define (false, true, "blocks", separators, '\0', colour_pink, effect_italic);
xyntax_define (false, false, "definitely", " ", '\0', colour_red, effect_bold);
xyntax_define (false, false, "indirectly", " ", '\0', colour_red, effect_bold);
xyntax_define (false, false, "possibly", " ", '\0', colour_red, effect_bold);
xyntax_define (false, false, "still", " ", '\0', colour_red, effect_bold);
xyntax_define (false, false, "suppressed", " ", '\0', colour_red, effect_bold);
xyntax_define (false, false, "reachable", " ", '\0', colour_red, effect_bold);
xyntax_define (false, false, "lost", " ", '\0', colour_red, effect_bold);
syntax_define (false, false, "definitely", " ", '\0', colour_red, effect_bold);
syntax_define (false, false, "indirectly", " ", '\0', colour_red, effect_bold);
syntax_define (false, false, "possibly", " ", '\0', colour_red, effect_bold);
syntax_define (false, false, "still", " ", '\0', colour_red, effect_bold);
syntax_define (false, false, "suppressed", " ", '\0', colour_red, effect_bold);
syntax_define (false, false, "reachable", " ", '\0', colour_red, effect_bold);
syntax_define (false, false, "lost", " ", '\0', colour_red, effect_bold);
xyntax_define (false, false, "(", ")\n", '\0', colour_blue, effect_normal);
syntax_define (false, false, "(", ")\n", '\0', colour_blue, effect_normal);
xyntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_normal);
}

View File

@ -10,23 +10,23 @@ static void highlight_xofya (void) {
int word;
xyntax_define (false, false, "!", "\n", '\0', colour_red, effect_bold);
xyntax_define (false, false, "---", "\n", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "--!", "!--", '\0', colour_grey, effect_bold);
xyntax_define (false, false, "@", "\n", '\0', colour_red, effect_italic);
xyntax_define (false, false, "<!>", "\n", '\0', colour_red, effect_normal);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "!", "\n", '\0', colour_red, effect_bold);
syntax_define (false, false, "---", "\n", '\0', colour_grey, effect_bold);
syntax_define (false, false, "--!", "!--", '\0', colour_grey, effect_bold);
syntax_define (false, false, "@", "\n", '\0', colour_red, effect_italic);
syntax_define (false, false, "<!>", "\n", '\0', colour_red, effect_normal);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
xyntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
syntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
}
xyntax_define (true, false, "(){}", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', colour_cyan, effect_normal);
syntax_define (true, false, "(){}", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
xyntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
xyntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
xyntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', colour_white, effect_normal);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', colour_white, effect_bold);
syntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
}

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -1,4 +1,3 @@
#include <xolatile/xtandard.h>
#include <xolatile/xyntax.h>
#include "language/ada.h"
@ -32,11 +31,11 @@ static struct {
static void highlight_common (void) {
char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\"@#$` \t\r\n";
xyntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
xyntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
xyntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
xyntax_define (true, false, ".,:;<=>+*-/%!&~^?|@#$`", "", '\0', colour_cyan, effect_normal);
xyntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
syntax_define (false, false, "'", "'", '\\', colour_pink, effect_bold);
syntax_define (false, false, "\"", "\"", '\\', colour_pink, effect_normal);
syntax_define (true, false, "()[]{}", "", '\0', colour_blue, effect_normal);
syntax_define (true, false, ".,:;<=>+*-/%!&~^?|@#$`", "", '\0', colour_cyan, effect_normal);
syntax_define (true, true, "0123456789", separators, '\0', colour_pink, effect_bold);
}
int main (int argc, char * * argv) {
@ -83,7 +82,7 @@ int main (int argc, char * * argv) {
}
}
if (xyntax_active == false) {
if (syntax_active == false) {
select = file_type (argv [1]);
buffer = file_import (argv [1]);
}
@ -94,7 +93,7 @@ int main (int argc, char * * argv) {
buffer = record ();
}
if (xyntax_active == false) {
if (syntax_active == false) {
if ((select == file_type_c_source) || (select == file_type_c_header)) {
highlight_c ();
} else if ((select == file_type_ada_body) || (select == file_type_ada_specification)) {
@ -115,12 +114,12 @@ int main (int argc, char * * argv) {
}
for (offset = 0; buffer [offset] != '\0'; offset += length) {
select = xyntax_select (& buffer [offset], & length);
select = syntax_select (& buffer [offset], & length);
if (select >= xyntax_count) {
if (select >= syntax_count) {
terminal_colour (colour_white, effect_normal);
} else {
terminal_colour (xyntax_colour [select], xyntax_effect [select]);
terminal_colour (syntax_colour [select], syntax_effect [select]);
}
out (& buffer [offset], length);