diff --git a/libxenon/drivers/console/console.c b/libxenon/drivers/console/console.c index faab3870..704c8640 100644 --- a/libxenon/drivers/console/console.c +++ b/libxenon/drivers/console/console.c @@ -98,10 +98,17 @@ void console_clrscr() { } void console_clrline() { - char sp[max_x]; - memset(sp,' ', max_x); - sp[max_x-1]='\0'; - printf("\r%s\r",sp); + console_clear_to_eol(0); +} + +void console_clear_to_eol(int startpos) { + char sp[max_x - startpos]; + memset(sp,' ', max_x - startpos); + sp[max_x - startpos - 1]='\0'; + + cursor_x = startpos; + printf("%s",sp); + cursor_x = startpos; } static void console_scroll32(const unsigned int lines) { @@ -206,6 +213,33 @@ void console_get_dimensions(unsigned int * width,unsigned int * height){ if (height) *height=max_y; } +int console_get_cursor_x(void) +{ + return cursor_x; +} + +int console_get_cursor_y(void) +{ + return cursor_y; +} + +int console_get_cursor_max_x(void) +{ + return max_x; +} + +int console_get_cursor_max_y(void) +{ + return max_y; +} + + +void console_set_cursor(int x, int y) +{ + cursor_x = x; + cursor_y = y; +} + void console_open(void) { stdout_hook = console_stdout_hook; diff --git a/libxenon/drivers/console/console.h b/libxenon/drivers/console/console.h index d1394986..f6b33539 100644 --- a/libxenon/drivers/console/console.h +++ b/libxenon/drivers/console/console.h @@ -41,12 +41,20 @@ void console_get_dimensions(unsigned int * width,unsigned int * height); void console_putch(const char c); void console_clrscr(); void console_clrline(); +void console_clear_to_eol(int start_pos); + void console_init(void); void console_open(void); void console_close(void); void console_pset(int x, int y, unsigned char r, unsigned char g, unsigned char b); void console_pset_right(int x, int y, unsigned char r, unsigned char g, unsigned char b); +int console_get_cursor_x(void); +int console_get_cursor_y(void); +int console_get_cursor_max_x(void); +int console_get_cursor_max_y(void); +void console_set_cursor(int x, int y); + #ifdef __cplusplus }; #endif