p-e-w / finalterm

At last – a modern terminal emulator (NO LONGER MAINTAINED)
http://finalterm.org
GNU General Public License v3.0
3.84k stars 179 forks source link

IND/RI/NEL control sequence implementations #350

Open cepko33 opened 9 years ago

cepko33 commented 9 years ago

This is the first in what will be a series of control sequence implementations, starting off with INDEX, REVERSE_INDEX, and NEXT_LINE. Currently, the steps used for each are:

  1. inc/dec the scroll_offset
  2. move cursor down/up
  3. allocate/deallocate line views

In addition, the VERTICAL_TAB case was modified to allocate new line views and then scroll to the bottom of the terminal view

My main use case for this feature was man, so once I could successfully scroll up and down, I knew that progress had been made.

Some potential future control sequences have been added to the enum along with markings specifying which sequences have been implemented or not.

Bugs Introduced: While running the vttest display test (option 1) the scroll_offset seems to become negative to around -37 or so, and I'm interested in the function erase_range_screen which seems to be accessing terminal space with an "absolute position"

private void erase_range_screen(CursorPosition start_position = {1, 1},
    CursorPosition end_position = {terminal.lines, terminal.columns + 1}) {
    var absolute_start_position = get_absolute_position(start_position);
    var absolute_end_position = get_absolute_position(end_position);

    // Constrain positions to permissible range
    absolute_start_position.line = int.min(absolute_start_position.line, size - 1);

    absolute_start_position.column = int.min(absolute_start_position.column, //<- Fails here
        get(absolute_start_position.line).get_length()); //<-------- due to negative index

    absolute_end_position.line = int.min(absolute_end_position.line, size - 1);
    absolute_end_position.column = int.min(absolute_end_position.column,
        get(absolute_end_position.line).get_length());

    erase_range(absolute_start_position, absolute_end_position);
    }
cepko33 commented 9 years ago

For the changes to the VERTICAL_TAB and REVERSE_INDEX switches, my test case was the man program, and only with the changes that I made do I get the expected scrolling behavior.