Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions libxenon/drivers/console/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions libxenon/drivers/console/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading