Clear to EOL after Enter.

This commit is contained in:
Lawrence Kesteloot 2018-08-03 00:02:40 -07:00
parent 5d453e8f58
commit fbed276344
3 changed files with 19 additions and 2 deletions

3
main.c
View File

@ -113,6 +113,8 @@ static void list_statement() {
uint8_t *line = g_program;
uint8_t *next_line;
print_newline();
while ((next_line = get_next_line(line)) != 0) {
print_int(get_line_number(line));
print_char(' ');
@ -529,6 +531,7 @@ int16_t main(void)
}
} else if (key == 13) {
// Return.
clear_to_eol();
print_char('\n');
process_input_buffer();

View File

@ -6,6 +6,7 @@
#define SCREEN_HEIGHT 24
#define SCREEN_WIDTH 40
#define SCREEN_STRIDE (3*SCREEN_WIDTH + 8)
#define CLEAR_CHAR (' ' | 0x80)
// Location of cursor in logical screen space.
uint16_t g_cursor_x = 0;
@ -65,11 +66,22 @@ void move_cursor(int16_t x, int16_t y) {
g_cursor_y = y;
}
/**
* Blanks out the rest of the line, from the cursor (inclusive) on.
* Does not move the cursor.
*/
void clear_to_eol(void) {
uint8_t *pos = cursor_pos();
hide_cursor();
memset(pos, CLEAR_CHAR, SCREEN_WIDTH - g_cursor_x);
}
/**
* Clear the screen with non-reversed spaces.
*/
void home(void) {
memset(TEXT_PAGE1_BASE, ' ' | 0x80, SCREEN_STRIDE*8);
memset(TEXT_PAGE1_BASE, CLEAR_CHAR, SCREEN_STRIDE*8);
move_cursor(0, 0);
}
@ -90,7 +102,7 @@ static void scroll_up(void) {
}
// This is provided by cc65:
memset(previous_line, ' ' | 0x80, SCREEN_WIDTH);
memset(previous_line, CLEAR_CHAR, SCREEN_WIDTH);
}
/**

View File

@ -13,6 +13,8 @@ void show_cursor(void);
void hide_cursor(void);
void move_cursor(int16_t x, int16_t y);
void clear_to_eol(void);
void home(void);
void print(uint8_t *s);