Correctly handle CR followed by LF

This would previously result in an empty line, because the CR resets the
current column to zero. Now we remember the last written char and column
so that we can restore the column before finishing the line.
This commit is contained in:
Klemens Schölhorn 2018-06-04 23:03:53 +02:00
parent 227dce66e9
commit 9e49f5e332

View File

@ -46,6 +46,9 @@ architecture syn of terminal is
signal rowlen_we: std_logic;
signal rowlen_wa: std_logic_vector(5 downto 0);
signal rowlen_di: std_logic_vector(6 downto 0);
signal last_written_char: std_logic_vector(7 downto 0);
signal last_cursor_col: unsigned(6 downto 0);
begin
-- writes the next character, advances the cursor and saves the length of
@ -83,6 +86,10 @@ begin
end if;
if write_enable = '1' then
-- save last written char and column for correct CR, LF handling
last_written_char <= write_data;
last_cursor_col <= cursor_col;
-- backspace
if write_data = x"08" then
cursor_col <= previous_col;
@ -97,6 +104,12 @@ begin
cursor_row <= next_line;
rowlen_we <= '1'; -- save row length
-- write the row length with was valid before CR reset the
-- cursor (for consecutive CR, LF)
if last_written_char = x"0d" then
rowlen_di <= std_logic_vector(last_cursor_col);
end if;
-- normal characters
else
charbuf_we <= '1'; -- write normal characters