Hop hop hop...

This commit is contained in:
Ognjen Milan Robovic 2023-10-03 10:36:14 -04:00
parent 4ebe017c1b
commit c0d756a07c
3 changed files with 93 additions and 23 deletions

View File

@ -1,18 +1,64 @@
#include <xolatile/xlesses.h>
#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) {
blesses_render_string ("Heyo world!", 8, 0, 0XCC6633, 0X3366CC);
blesses_render_character ('@', 8, 8, 0X3366CC, 0XCC6633);
blesses_render_character ('@', 0, 0, 0X3366CC, 0XCC6633);
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 >= 50 * 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);
}

View File

@ -12,8 +12,8 @@
#include <xolatile/xlesses.h>
char * blesses_window_title = "xolatile";
int blesses_window_width = 640;
int blesses_window_height = 480;
int blesses_window_width = 1800;
int blesses_window_height = 900;
int blesses_active = 1;
int blesses_cursor_x = 0;
int blesses_cursor_y = 0;
@ -126,7 +126,6 @@ void blesses_synchronize (void) {
}
} break;
default: {
echo ("--\n");
} break;
}
@ -140,6 +139,16 @@ void blesses_synchronize (void) {
log_out ();
}
void blesses_render_background_colour (int colour) {
int x, y;
for (y = 0; y != blesses_window_height / 2; ++y) {
for (x = 0; x != blesses_window_width / 2; ++x) {
blesses_sub_framebuffer [y * (blesses_window_width / 2) + x] = 0XFF000000 | colour;
}
}
}
void blesses_render_character (char character, int x, int y, int foreground, int background) {
const unsigned long int font_code ['~' - ' ' + 1] = {
0X0000000000000000, 0X00180018183C3C18, 0X0000000000363636, 0X006C6CFE6CFE6C6C, 0X00187ED07C16FC30, 0X0060660C18306606, 0X00DC66B61C36361C, 0X0000000000181818,
@ -156,11 +165,18 @@ void blesses_render_character (char character, int x, int y, int foreground, int
0X00663C183C660000, 0X3C607C6666660000, 0X007E0C18307E0000, 0X003018180E181830, 0X0018181818181818, 0X000C18187018180C, 0X000000000062D68C, 0X0000000000000000
};
int offset = 0;
int offset;
if ((x <= -1) || (x >= blesses_window_width / 2 - BLESSES_FONT_WIDTH)) return;
if ((y <= -1) || (y >= blesses_window_height / 2 - BLESSES_FONT_HEIGHT)) return;
log_in (LOG_WARNING, blesses_sub_framebuffer == NULL, "blesses : render_character : Sub framebuffer was not allocated.");
log_in (LOG_WARNING, blesses_framebuffer == NULL, "blesses : render_character : Framebuffer was not allocated.");
log_in (LOG_WARNING, character_is_invisible (character), "blesses : render_character : Character is not in visible ASCII range.");
log_in (LOG_WARNING, x <= -1, "blesses : render_character : X position is under lower limit.");
log_in (LOG_WARNING, y <= -1, "blesses : render_character : Y position is under lower limit.");
log_in (LOG_WARNING, x >= blesses_window_width - BLESSES_FONT_WIDTH, "blesses : render_character : X position is above upper limit.");
log_in (LOG_WARNING, y >= blesses_window_height - BLESSES_FONT_HEIGHT, "blesses : render_character : Y position is above upper limit.");
for (offset = 0; offset != BLESSES_FONT_WIDTH * BLESSES_FONT_HEIGHT; ++offset) {
int u = offset / BLESSES_FONT_WIDTH + y;
@ -172,21 +188,25 @@ void blesses_render_character (char character, int x, int y, int foreground, int
log_out ();
}
void blesses_render_string (char * string, int x, int y, int foreground, int background) {
int offset = 0;
void blesses_render_string_limit (char * string, int limit, int * x, int * y, int foreground, int background) {
int offset;
do {
for (offset = 0; offset != limit; ++offset) {
if (string [offset] == '\t') {
x += BLESSES_FONT_WIDTH * BLESSES_FONT_TABULATOR;
* x += BLESSES_FONT_WIDTH * BLESSES_FONT_TABULATOR;
} else if (string [offset] == '\n') {
y += BLESSES_FONT_HEIGHT;
x *= 0;
* y += BLESSES_FONT_HEIGHT;
* x *= 0;
} else {
blesses_render_character (string [offset], x, y, foreground, background);
}
blesses_render_character (string [offset], * x, * y, foreground, background);
x += BLESSES_FONT_WIDTH;
} while (++offset != string_length (string));
* x += BLESSES_FONT_WIDTH;
}
}
}
void blesses_render_string (char * string, int * x, int * y, int foreground, int background) {
blesses_render_string_limit (string, string_length (string), x, y, foreground, background);
}
#endif

View File

@ -45,7 +45,11 @@ extern void blesses_initialize (void);
extern void blesses_deinitialize (void);
extern void blesses_synchronize (void);
extern void blesses_render_background_colour (int);
extern void blesses_render_character (char, int, int, int, int);
extern void blesses_render_string (char *, int, int, int, int);
extern void blesses_render_string_limit (char *, int, int *, int *, int, int);
extern void blesses_render_string (char *, int *, int *, int, int);
#endif