Commit Briefs

Omar Polo

move TAB_LAZY flipping from switch_to_tab in load_url

load_url needs to know when a tab passes from lazy to not lazy to correctly saves the scrolling position (see follow-up commit.)


Omar Polo

save and restore scroll position

Save the offset to the first and current line of the buffers and restore it when the page is loaded. This restores almost the exact viewport: we save the offset of the *real* line in the document, but they get wrapped before being displayed, so the actual restored position may be slightly above from the original one (think of a long paragraph that gets wrapped over multiple visual lines.) In practice, this isn't a drawback but only an improvement over the current behaviour. In the future we could save also the offset *inside* the line, to restore the exact position, but that felt unnecessary for now. Persisting the postion on the session file ensures that even when re-opening telescope the scroll position is correct. There are some very active pages, such as antenna or other aggregator, where this feature doesn't really work well if you re-open the page after a while, since new links are available, but otherwise is a god sent! See also github issue #1


Omar Polo

avoid possible use after free

`url' may be a pointer to a string of the buffer which gets corrupted upon tab_stop. This bug shows when loadfn is load_about_url, because in make_fs_request we first tab_stop, and then send the request, which ends up sending to the fs process a free'd string. At least on OpenBSD with Otto' malloc is (partially) corrupted and will either make the fs process abort or return a not found page. One solution may be to rework make_fs_request to process things in a different order, but that would only hide the problem. Instead, use the newly created history element as url given to the loadfns: that is guaranteed to be valid up to the next load_url call. Reported by Brian Callahan, thanks!


Omar Polo

simplify load_url_in_tab


Omar Polo

move util.c declarations in utils.h

it's not spelled `util.h' because otherwise it'd get included instead of /usr/include/util.h


Omar Polo

simplify the caching API

- don't expose the evbuffer where we store the cached page - cache to/from tabs instead of buffers


Omar Polo

fix start_loading_animation usage

the idiom if (load_next_page(...)) start_loading_anim(...); is fundamentally wrong because `load_next_page' (or previous page, or anything else that call into load_url) *may* load all the page before returning (thanks to the cache, but not only, cf. load_page_from_str.) Instead, let's call start_loadign_anim at the start of make_request so it's always called in the right moment. Cache and other special pages don't end up calling make_request anyway, and we already call stop_loading_anim when a request finishes (or fails.) move start_loading_anim up in make_request.


Omar Polo

provide a way to bypass the cache

This changes the last argument of load_url to be a `mode' bitmap instead of a boolean ``nohist''. LU_MODE_NOHIST is the old 1, LU_MODE_NONE is provided just for readability and the new LU_MODE_NOCACHE allows to bypass the caching when loading a page. Telescope only uses the cache when: - re-opens a closed tab - navigates backward and forward in the history All other situations result in the usual network request.



Omar Polo

add an in-memory cache store

see github issue #1


Omar Polo

append killed tabs when parsing session to preserve the order

The other option, less intrusive, would be to send the killed tabs in reverse order, but it'd seems strange when looking at the session file otherwise. So, add a `append' flag to kill_tab to optionally append the killed tab instead of pre-pending it.


Omar Polo

allow to re-open closed tabs

Save closed tabs to a "killed tabs" queue, for up to a max of "max-killed-tabs", and allow to re-open them. Keep the tab history but not its content. This integrates nicely with the session file, just add the "killed" flag as alias for TAB_KILLED and put it in the ktabshead queue upon initalization. It's thus possible to re-open closed tabs even after telescope has been closed, and tabs keeps their history! Add a new cmd, cmd_tab_undo_close, to try to re-open the most recently closed tab and bind it to `u'. While here, add a TODO for the tab history memory leak.


Omar Polo

move know_host parsing to the fs process and load the store via imsgs

Like previously did with the session file, now the main process doesn't parse anything with the only exception being the configuration file. With this in, the only bit from fs.h still used in the main process is the path to the configuration file.



Omar Polo

implement persistent tab history

The session file is now overloaded with the history info, that means that upon startup telescope can repopulate each tab history! The price to pay is that one can't start an old telescope with a new session file, otherwise will get a lot of fancy '<' and '>' tabs...