This way we get rid of page_calculate_offset that involves explicit GTK
calls. Also, we can make use of page_number_to_position to align page
and viewport as desired.
I've also tried to make the code for this function a bit more readable.
The new page_set and position_set behave as delayed, but with the
immediate availability of the new positions through the document
object. We no longer need to keep delayed and non-delayed versions!
This new function adjust_view is in charge of recomputing the scale
according to adjustment settings and trigger a render_all.
adjust_view contains the old sc_adjust_window code, slightly simplified
thanks to the availability of the document_get_viewport_size.
Then it is used by sc_adjust_window, document_open and the
cb_view_resized callback. Makes slightly more sense this way than
calling the shortcut sc_adjust_window directly.
Since we 'continue' the loop if num_search_results is 0, there is no need for
the second check.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This patch adds a new configuration setting, selection-clipboard, which allows
us to choose between the PRIMARY selection, and the CLIPBOARD selection, for
determining which X clipboard to use for storing mouse-selected data. It has
only two valid values: "primary" and "clipboard", with "clipboard" being set as
the it's default value.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
Otherwise, when opening a document at page 1, and no jumps are added,
bisect does not understand it has to initialize the bisect range, and
does not move from page 1.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
After page_set cb_view_hadjustment_changed must be called so that when
zoom-center is enabled, the page is recentered.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
- Allow the user to always start with the very last (or first) jump on the
jumplist when pressing ^o (or ^i), while the jumplist iterator is
pointing to the last (or first) jump, and the document is not currently
at the position of this pointed-to jump. This is instead of jumping
directly to the previous/next jump, and skipping the last/first one.
- Don't jump to the current jump pointed to by the jumplist iterator, if
there is no more next jumps, and the jump direction is FORWARD.
- Don't jump to the current jump pointed to by the jumplist iterator, if
there is no more previous jumps, and the jump direction is BACKWARD.
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>
This patch activates the last aborted search when pressing the search shortcuts
('n' or 'N').
To avoid confusion, and to make things more predictable, I've chosen to always
reactivate an aborted search starting from the beginning (or end, in case of
'N' or '?') of the current page, as opposed to Vim which continues from the
next search term each time the search is reactivated.
Searching using '/' or '?' doesn't center the view at the current search term
like when using 'n' or 'N', so we fix this here.
Also, I managed to work around the issue of the thin rectangular margins that
show around the previously-highlighted search terms after the search is aborted
(either explicitly or as a result of following links), by redrawing the page
widget (only if it's visible) instead of redrawing the rectangles covering the
highlighted search terms.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This uses the jumplist to implement a bisect functionality between the
last two jump points. ^j and ^k are bound to bisect forward and backward
respectively.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
Call cb_view_hadjustment_changed to set horizontal position in
navigation shortcuts: sc_navigate, sc_goto.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This will not scroll the document when pressing 'f' or 'F', just to make the
behavior consistent with activating the inputbar using ':'.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
Add a new adjust mode that is set when focusing the inputbar and
disables adjusting the vertical scrollbar. As a result, focusing the
inputbar doesn't scroll the document, leading to better results when
changing pages from the inputbar (e.g. using bookmarks).
Reported-by: Marwan Tanager <marwan.tngr@gmail.com>
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>
This wasn't correct. Padding is already accounted for:
scale = (width - (pages_per_row - 1) * padding) /
(pages_per_row * cell_width)
If you add padding on the denominator, you end up with black margins on
the sides of the window, which isn't what padding is for (i.e. insert a
gap between rendered pages), and defeats the purpose of a "best-fit".
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>
The width of the vertical scrollbar (if there is one) needs to be
substracted from the width of the GtkScrolledWindow in order to obtain
the correct dimensions of the view area.
See issue 27 <http://bugs.pwmt.org/issue27>.
It also deals better with documents where pages don't all have the same
size.
Reported-by: Andreas Weinlich <business@weinlich.org>
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This is useful when the text of the link doesn't match its target. The
default key is set to 'F'.
See issue 266 <http://bugs.pwmt.org/issue266>.
Reported-by: Iron <o380770@rtrtr.com>
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
The scroll-wrap option used to only change the behavior of 'J' and 'K'
(i.e. moving one page forward/backward).
Now, if scroll-wrap is true and the top of the first page is shown,
pressing 'k' will show the bottom of the last page; conversely, when at
the bottom of the last page, pressing 'j' will show the top of the first
page.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
When set to true, it used to _not_ wrap around the begining/end. Now it
wraps if set to true, and it doesn't if set to false.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>