Commit 850e8a7b authored by Léo Grange's avatar Léo Grange
Browse files

add VT100 'clear screen' escape code

parent 0b81fd9a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -18,7 +18,9 @@ const struct text_display fx9860_text_display = {
	.flush = &fx9860_tdisp_flush,

	.set_cursor_pos = &fx9860_tdisp_set_cursor_pos,
	.set_cursor = &fx9860_tdisp_set_cursor
	.set_cursor = &fx9860_tdisp_set_cursor,

	.clear = &fx9860_tdisp_clear
};


@@ -115,3 +117,8 @@ void fx9860_tdisp_set_cursor_pos(struct tdisp_data *disp, size_t posx,
void fx9860_tdisp_set_cursor(struct tdisp_data *disp, enum text_cursor curs) {
	disp->cursor = curs;
}


void fx9860_tdisp_clear(struct tdisp_data *disp) {
	memset(disp->vram, disp->back ? 0xFF : 0x00, 1024);
}
+1 −0
Original line number Diff line number Diff line
@@ -37,5 +37,6 @@ void fx9860_tdisp_set_cursor_pos(struct tdisp_data *disp, size_t posx,

void fx9860_tdisp_set_cursor(struct tdisp_data *disp, enum text_cursor curs);

void fx9860_tdisp_clear(struct tdisp_data *disp);

#endif //_DEVICE_TERMINAL_FX9860_TEXT_DISPLAY_H
+8 −0
Original line number Diff line number Diff line
@@ -79,6 +79,14 @@ struct text_display {
	 * Set cursor type, if supported.
	 */
	void (*set_cursor)(struct tdisp_data *disp, enum text_cursor curs);


	/**
	 * Clear the whole screen (using the current background color).
	 * TODO should be more generic, to allow erasing of a given part
	 * of the screen.
	 */
	void (*clear)(struct tdisp_data *disp);
};


+11 −2
Original line number Diff line number Diff line
@@ -304,7 +304,15 @@ static int vt_parse_escape_code(struct vt_instance *term, char str_char) {
		break;
	case 'J':
		// TODO Erase the screen down to the bottom from the current line. If an argument is given and == 1, erase up to the top instead.
		// If an argument is given and == 2, clear the whole screen with the background color and go to cursor home.			
		if(term->esc_state.arguments_index >= 0 
				&& term->esc_state.arguments[0] == 2)
		{
			// If an argument is given and == 2, clear the whole screen with the
			// background color and go to cursor home.
			_tdisp->clear(& term->disp);
			vt_move_cursor(term, 0, 0);
			vt_delay_flush();
		}
		break;
	case 'p':
		// TODO Bind a string to a keyboard key
@@ -348,7 +356,6 @@ static void vt_read_escape_code(struct vt_instance *term, char str_char) {
				term->esc_state.arguments_index++;
				// check if there are too much arguments for our simple parser
				if(term->esc_state.arguments_index == VT100_MAX_INTARGS) {
					vt_clear_escape_code(term);
					newstate = VT100_STATE_NONE;
				}
			} else {
@@ -368,6 +375,8 @@ static void vt_read_escape_code(struct vt_instance *term, char str_char) {
		break;
	}

	if(newstate == VT100_STATE_NONE)
		vt_clear_escape_code(term);
	term->esc_state.discovery_state = newstate;
}