diff options
Diffstat (limited to 'src/features')
-rw-r--r-- | src/features/gui.c | 28 | ||||
-rw-r--r-- | src/features/psf.c | 1 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/features/gui.c b/src/features/gui.c index ddf1c60..fa0641c 100644 --- a/src/features/gui.c +++ b/src/features/gui.c @@ -11,8 +11,6 @@ struct font *font; void gui_write_char(int x, int y, const u32 c[3], char ch) { - /* const u32 c[3] = { 0xff, 0x00, 0x00 }; */ - int pos = x * vbe_bpl + y * vbe_pitch; char *draw = (char *)&fb[pos]; @@ -38,6 +36,32 @@ void gui_write(int x, int y, const u32 c[3], char *text) } } +// Abstraction +int x, y = 1; +const u32 c[3] = { 0xff, 0xff, 0xff }; +void gui_term_write_char(char ch) +{ + if (x + font->width > vbe_width) { + x = 0; + y += font->height; + } + + if (ch >= ' ' && ch <= '~') { + gui_write_char(x, y, c, ch); + x += font->width; + } else if (ch == '\n') { + x = 0; + y += font->height; + } +} + +void gui_term_write(char *text) +{ + for (u32 i = 0; i < strlen(text); i++) { + gui_term_write_char(text[i]); + } +} + void gui_init(char *font_path) { font = psf_parse(read_file(font_path)); diff --git a/src/features/psf.c b/src/features/psf.c index c713bb4..adf2aa2 100644 --- a/src/features/psf.c +++ b/src/features/psf.c @@ -44,6 +44,7 @@ struct font *psf_parse(char *data) width = ((struct psf2_header *)data)->width; char_size = ((struct psf2_header *)data)->char_size; } else { + printf("Unknown font!\n"); return 0; } |