xlesses/example/base.c

65 lines
1.9 KiB
C

#include <xolatile/xtandard.c>
#include <xolatile/xyntax.c>
#include <xolatile/xlesses.c>
int main (void) {
int x;
int y;
int offset;
int length;
int select;
char * buffer;
char separator [29] = ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n";
char * c_keywords [32] = {
"register", "volatile", "auto", "const", "static", "extern", "if", "else",
"do", "while", "for", "continue", "switch", "case", "default", "break",
"enum", "union", "struct", "typedef", "goto", "void", "return", "sizeof",
"char", "short", "int", "long", "signed", "unsigned", "float", "double"
};
(void) syntax_insert (0, 0, "#", " ", '\\', 0XCC33CC, 0);
(void) syntax_insert (0, 0, "/*", "*/", '\0', 0X333333, 0);
(void) syntax_insert (0, 0, "'", "'", '\\', 0XCC1133, 0);
(void) syntax_insert (0, 0, "\"", "\"", '\\', 0XCC1133, 0);
(void) syntax_insert (1, 0, ".,:;<=>+-*/%!&~^?|()[]{}", "", '\0', 0X1133CC, 0);
for (offset = 0; offset != 32; ++offset) {
(void) syntax_insert (0, 1, c_keywords [offset], separator, '\0', 0XCCCC33, 0);
}
(void) syntax_insert (1, 1, "0123456789", separator, '\0', 0X33CCCC, 0);
(void) syntax_insert (1, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_", separator, '\0', 0XCCCCCC, 0);
buffer = file_import ("./example/base.c");
blesses_initialize ();
while (blesses_active != 0) {
x = 0;
y = 0;
blesses_render_background_colour (0X111111);
for (offset = 0; buffer [offset] != '\0'; offset += length) {
select = syntax_select (& buffer [offset], & length);
if (y >= 100 * BLESSES_FONT_WIDTH) break;
blesses_render_string_limit (& buffer [offset], length, & x, & y, syntax_colour [select], 0X111111);
}
blesses_synchronize ();
}
blesses_deinitialize ();
buffer = deallocate (buffer);
syntax_delete ();
return (EXIT_SUCCESS);
}