Updated readme...

This commit is contained in:
Ognjen Milan Robovic 2024-02-23 14:05:11 -05:00
parent 0914ab98d1
commit e7c2b97ec4
2 changed files with 46 additions and 1 deletions

View File

@ -23,4 +23,7 @@ $ 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

@ -283,6 +283,45 @@ static void highlight_fortran (void) {
syntax_define (true, true, "_", separators, '\0', colour_white, effect_italic);
}
static void highlight_shell (void) {
char * separators = ".,:;<=>+-*/%!&~^?|()[]{}@#$`'\" \t\r\n";
char * keywords [] = {
"if", "then", "else", "elif", "fi", "do", "done", "case",
"esac", "while", "until", "for", "function", "declare", "let", "local",
"alias", "shopt", "export", "in", "return", "echo", "set", "alias",
"exit", "source", "shift", "cd"
};
int word;
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, false, "${", ")", '\\', colour_yellow, effect_italic);
syntax_define (false, false, "$(", "}", '\\', colour_cyan, effect_italic);
syntax_define (false, false, "$((", "))", '\\', colour_blue, effect_italic);
syntax_define (false, true, "&&", separators, '\0', colour_cyan, effect_bold);
syntax_define (false, true, "||", separators, '\0', colour_cyan, effect_bold);
syntax_define (false, true, ";;", separators, '\0', colour_cyan, effect_bold);
syntax_define (false, true, "<<", separators, '\0', colour_cyan, effect_bold);
syntax_define (false, true, ">>", separators, '\0', colour_cyan, effect_bold);
syntax_define (false, true, "<>", separators, '\0', colour_cyan, effect_bold);
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
syntax_define (false, true, keywords [word], separators, '\0', colour_yellow, effect_bold);
}
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);
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);
}
int main (int argc, char * * argv) {
int offset = 0;
int select = 0;
@ -312,7 +351,8 @@ int main (int argc, char * * argv) {
echo ("\t -S --assembly -- General assembly syntax\n");
echo ("\t -T --flat -- Flat assembly syntax\n");
echo ("\t -F --fortran -- Fortran syntax\n");
echo ("\t -H --shell -- Bourne shell syntax\n");
echo ("\t -H --shell -- Shell syntax\n");
exit (log_success);
} else if (string_compare (argv [1], "-C") || string_compare (argv [1], "--c")) {
highlight_c ();
} else if (string_compare (argv [1], "-A") || string_compare (argv [1], "--ada")) {
@ -325,6 +365,8 @@ int main (int argc, char * * argv) {
highlight_flat_assembly ();
} else if (string_compare (argv [1], "-F") || string_compare (argv [1], "--fortran")) {
highlight_fortran ();
} else if (string_compare (argv [1], "-H") || string_compare (argv [1], "--shell")) {
highlight_shell ();
} else {
select = file_type (argv [1]);
buffer = file_import (argv [1]);