From a03f4e798eba196b614024f814e6db7f6795c2f8 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Wed, 11 Feb 2015 17:47:02 -0500 Subject: stuff --- drivers/gfx.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'drivers/gfx.c') diff --git a/drivers/gfx.c b/drivers/gfx.c index babbf27..b6bcae3 100644 --- a/drivers/gfx.c +++ b/drivers/gfx.c @@ -24,6 +24,8 @@ const uint16_t *gfx_height = &fb_height; static int cursor_x, cursor_y; uint32_t _gfx_fgcol, _gfx_bgcol; +void (*gfx_clear)(void); + void gfx_set_background(uint32_t col) { _gfx_bgcol = col; @@ -118,7 +120,7 @@ void gfx_drawchar_bg(int x, int y, int c) void gfx_putchar(int ch) { - if(ch != '\n') + if(ch != '\n' && ch != '\b') { gfx_drawchar(cursor_x, cursor_y, ch); cursor_x += FONT_WIDTH; @@ -133,7 +135,7 @@ void gfx_putchar(int ch) } } } - else + else if(ch == '\n') { cursor_x = 0; cursor_y += FONT_HEIGHT; @@ -143,6 +145,21 @@ void gfx_putchar(int ch) cursor_y = 0; } } + else if(ch == '\b') + { + int temp_x = cursor_x - FONT_WIDTH; + if(temp_x < 0) + { + cursor_x = 0; + int temp_y = cursor_y - FONT_HEIGHT; + cursor_y = (temp_y < 0) ? 0 : temp_y; + } + else + { + cursor_x = temp_x; + } + gfx_drawchar_bg(cursor_x, cursor_y, ' '); + } } void gfx_puts(const char* str) @@ -247,6 +264,11 @@ bool gfx_init(struct vbe_info_t *vbe_mode_info) printf("WARNING: BPP != 32, falling back to text mode...\n"); return false; } + + void gfx_clear_packed(void); + + gfx_clear = &gfx_clear_packed; + gfx_reset(); set_putchar(gfx_putchar); set_puts(gfx_puts); -- cgit v1.1