Skip to content
Snippets Groups Projects
Commit de600cd6 authored by Simon Tatham's avatar Simon Tatham
Browse files

Another rewrite of the File screen layout code.

The problem with the previous rewrite in commit 8cbc9e12 was
that now FilePosition _only_ had the ability to specify a particular
position within an item and say 'align this position to the bottom of
the screen'. Unfortunately, sometimes you want to align a toot to the
_top_ of the screen (or further down if the end of the file doesn't
permit): before the rewrite we were doing that to your next unread
mention, and also to the toot you just asked to see the thread of. But
after the rewrite, those toots end up just off the bottom of the
screen, which isn't helpful!

To fix that, I've rewritten FilePosition _again_, so that it's now a
combination of an item number and a sub-enum 'Placement', and there's
a match statement that allows each branch of Placement to cause a
completely different calculation about where things appear on the
screen. So 'put this toot at the top' and 'put the n/d point in this
toot at the bottom' use different Placement branches, and are
alternatives to each other.

The calculation in question lives in another new type ScreenLayout,
which gives the _concrete_ answer to 'what things are at the
top/bottom of the screen?', as opposed to this new very abstract
FilePosition. Translating one to the other is done by
File::make_screen_layout, which is now sophisticated enough to replace
_several_ old functions like ensure_enough_rendered and
fix_overshoot_at_top. So although the code overall has become
larger (ScreenLayout's constructor is complicated and also has a pile
of unit tests), File is simpler, and I think that's a win.

Another win is that you can add further branches of FilePosition,
and in fact I plan to do one of those in the next commit.
parent edbabb9c
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment