diff --git a/main.c b/main.c index 3398cbf..6d6a063 100644 --- a/main.c +++ b/main.c @@ -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(); diff --git a/runtime.c b/runtime.c index 6b657b9..d4339fb 100644 --- a/runtime.c +++ b/runtime.c @@ -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); } /** diff --git a/runtime.h b/runtime.h index 53b9a0c..3f26293 100644 --- a/runtime.h +++ b/runtime.h @@ -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);