This patch implements two new ZathuraDatabaseInterface functions, save_jumplist
and load_jumplist, for both the plain and sqlite backends (along with some
cleanups).
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
Since we are now saving the adjustments ratios in the jump structures, we need
to take care of the following scenario:
- We do an action that results in a new jump structure being added to the
jumplist while the inputbar is visible (e.g., search, jumping to a
specific page, jumping to a bookmark, or following a link).
- Since we are now storing the adjustments ratios in the jump structures,
all of the above actions would result in the vertical adjustment ratio
being saved while the inputbar and/or the completion menu is visible.
- Now we are exactly on the target of the jump (note that the inputbar and
completion menu now are hidden), so suppose that we want to go back using
^o (assuming that we didn't change the adjustments after jumping), then
the check at sc_jumplist that compares the current adjustments ratios
with that of the current jump (the jump that has just been added and
which we are currently on it's position) would fail, because after the
inputbar (with possibly the completion menu in case of bookmarks) is
activated it is hidden, which results in the vertical adjustment upper
bound to change, which in turn results in the vertical adjustment ratio
returned by zathura_adjustment_get_ratio to become different from what is
stored in the current jump structure, even though we haven't changed the
adjustments at all after the jump. This would always result in taking us
back to the exact position of the jump (which would be slightly different
from the current position) when we press ^o. This can be annoying,
because it would happen, for example, every time we need to go back
quickly after jumping to a link target, a search result, or a bookmark.
So, what this patch does is essentially to make the vertical adjustment ratio
reflecting the current vertical adjustment after a jump, to always be the same
as the one stored in the newly added jump structure, since both are calculated
with zathura_adjustment_get_ratio while the inputbar is _not_ visible, so they
should be the same.
I've elaborated just to make things clear, in case the purpose of the patch
isn't obvious.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
- Don't delete the elements on the right of the current one, when
appending a new jump to the jumplist, because this makes no sense at
all; the point of the jumplist in the first place is to remember
previously jumped-to positions in the document, so there is no need
to delete anythings except to trim the oldest entries from the
beginning to maintain the maximum size. This also makes us compatible
with the Vim way of doing things.
- Make the jumplist mechanism functional on the same page; if we
followed a link to a target on the same page, remember the
adjustments before and after following the link. The same holds for
navigating search results on the same page.
- Implement position_set and use it instead of position_set_delayed
when following links in order to give zathura_jumplist_save a chance
to record the exact adjustments of the link target. Otherwise, it
will always record the adjustments after going to the target page,
but before going to the exact position within it.
- Don't consider movements with ^i and ^o as jumps :)
- Don't use page_set followed by setting the adjustments in
sc_jumplist, because this is redundant and causes clutter when using
^i and ^o, as the adjustments is set twice this way (once in page_set
and again in position_set_delayed). It's enough to only update the
page number on the statusbar and then set the adjustments.
- Hide implementation details (zathura_jumplist_save and
zathura_jumplist_append), and make things more consistent by
exporting and using only zathura_jumplist_add for adding new entries.
The end result: A more slick jumping experience :-)
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
Added config parameter "link-hadjust" with default value true. When set to false,
following internal links do not change the horizontal position of the page, only
the vertical position.
Also updates page number when following links, now.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
The last_view member in zathura_page_widget_private_s is gint64, so we should
do the same here.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This patch implements a page cache that is invalidated in a LRU fashion.
Pages are added to the cache as soon as they become visible. When the cache is
full and a new page that isn't in the cache becomes visible, the least recently
viewed page in the cache is evicted from memory and the new one takes it's
place.
The cache size is configurable using the page-cache-size configuration
variable, with a default value of 15 pages. Very large values for the cache
size are not recommended, though, as it will stress the system memory out.
The old periodic page reclaiming code is no longer necessary with this patch,
so I removed it.
Special thanks to Ignas Anikevičius, and Sebastian Ramacher for the
inspirations.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
Instead of guesstimating the values of the scrollbars adjustments after
a change in zoom level, connect callbacks to the "changed" GtkAdjustment
event (which is emitted when the bounds or page_size of the adjustment
change, e.g. when the zoom level changes), and compute the new values
from there.
The previous adjustment values are tracked in zathura->ui.hadjustment
and zathura->ui.vadjustment (and updated by signal handlers as well), so
that the view's position can be maintained while zooming.
cb_view_hadjustment_changed() centers the page horizontally if a
"best-fit" or "width" zoom is being performed, or if "zoom-center" is
true; otherwise, it keeps the view horizontally centered around the same
area of the page.
cb_view_vadjustment_changed() always keeps the view vertically centered
around the same area of the page.
Many thanks to Marwan Tanager for thoroughly reviewing the various
stages of this patch, and actually coming up with a working solution.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
If '--page [number]' (or '-P [number]') is given on the command-line,
the document is opened at the specified page number. Negative numbers
are allowed, and denote a page number starting from the end of the
document.
See issue 275 <http://bugs.pwmt.org/issue275>.
Reported-by: bob <sean258@gmail.com>
Currently, if :write is given a directory name as its argument, it fails with the "Failed to save document." error. This can sometimes be quite annoying: for instance, when viewing documents that have been downloaded to /tmp from the web, I often find myself wanting to hang on to file without changing its file name. In order to do so, I either have to leave Zathura and cp the file or else retype the whole filename after :write, neither of which are too convenient.
The following patch would make :write work sort of how mv does: if its argument is a currently existing directory, it will be inferred that the user wants to save the document in that directory using its current basename.
Signed-off-by: Sebastian Ramacher <sebastian@ramacher.at>
Both in the documentation and in function names, "synctex" was sometimes
spelled "syntex" or "syntec".
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
zathura records jumps through searches, index, links, etc. and enables to go
back and forth via ^o ^i.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
It is now possible to open multiple files by passing them as additional
arguments. The password can now be set with the -w/--password parameter
instead of the argument after the filename.