selectel / pyte

Simple VTXXX-compatible linux terminal emulator
http://pyte.readthedocs.org/
GNU Lesser General Public License v3.0
653 stars 101 forks source link

Fixes to history and page up/down logic #96

Closed acroz closed 6 years ago

acroz commented 7 years ago

I'm using the HistoryScreen with a page up/down ratio of less than 0.5, but I've been encountering some issues.

When updating the history position, prev_page and next_page appears to make the assumption that a whole screen worth of lines has been moved. This means that, with a ratio of 0.5, the position moves twice as fast as the screen does through the history. This PR modifies this behaviour so that the position is incremented by the number of lines moved.

On implementing this change, I encountered the problem that I would reach the top of the top buffer before reaching a history position of 0. This is due to the fact that the top history buffer is created with a maxlen of half the history size. Before the above fix, this length was not an issue as the top of the buffer would be reached at the same size as the position reaching zero when ratio remained at the default of 0.5. This PR therefore also modifies the top buffer to have a maxlen equal to the history size.

Finally, these changes broke the test for the logic which determined if the cursor is hidden. This logic has been modified to use history.position == history.size to determine if at the bottom of the history.

superbobry commented 7 years ago

Hi Andrew, thank you. I agree that the new behaviour is more reasonable. Could you add a short summary to CHANGES and yourself to AUTHORS?

acroz commented 6 years ago

Sorry for taking so long to get back to you about this @superbobry. I've made the changes to CHANGES and AUTHORS as requested.

superbobry commented 6 years ago

Thank you very much!