Commit Graph

213 Commits

Author SHA1 Message Date
Sebastian Ramacher
f10d847a95 CS
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-10-30 03:35:56 +01:00
Abdo Roig-Maranges
84736dc89b remove zathura->global.update_page_number global hack
The callbacks are no longer aware of it anyways
2013-10-26 17:13:57 +02:00
Abdo Roig-Maranges
ab9338cb33 get rid of a couple of static variables to remember adjustment.
Now the document object remembers it! and refresh_view is the one who
restores the position.
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
e51a3265b6 use the new document functions in sc_scroll
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.
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
ace0836a19 use the new document functions in sc_search
This way we can get rid of explicit GTK calls to the adjustment
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
4a75efd4f2 use the new document functions for the jumplist
And get rid of explicit gtk calls to the adjustment
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
f94d43d2e6 replace some page_set with refresh_view
page_set changes page and aligns the page according to settings. In
those cases we do not want to change the position, only refresh.
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
1171bffb6b replace delayed versions of page_set and position_set
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!
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
c4245600c9 move adjustment code from sc_adjust_window to adjust_view
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.
2013-10-26 17:13:56 +02:00
Abdo Roig-Maranges
a0a64832d9 move zathura_get_document_size to document.c
It makes more sense, plus now the document knows about the page layout
and can do the computation.
2013-10-26 16:02:23 +02:00
Marwan Tanager
ed27f8b88e Minor cleanup
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>
2013-10-26 15:12:33 +02:00
Marwan Tanager
cba5d8df77 Fix issue 345 (http://bugs.pwmt.org/issue345)
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-10-26 01:20:57 +02:00
Sebastian Ramacher
834bc8f4c9 CS
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-10-26 01:16:19 +02:00
Abdo Roig-Maranges
3629e3acd2 fix gtk_widget_get_requisition deprecation warning in GTK3
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-10-26 01:12:49 +02:00
Moritz Lipp
f3ef76f909 Initialize x_clipboard_text with NULL 2013-10-07 09:02:38 +02:00
Marwan Tanager
d09cd5c62c Make the X clipboard buffer configurable
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>
2013-08-31 12:30:12 +02:00
Guillaume Duranceau
c6140296cd Update page number on mouse scroll
When scrolling a document by holding the middle mouse button, page
number was not updated.
2013-07-27 01:19:25 +02:00
Moritz Lipp
71a332ede8 Fix return with no value 2013-07-26 09:04:08 +02:00
Abdó Roig-Maranges
f3229a6a5a Initialize bisect state when opening document
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>
2013-07-07 17:43:30 +02:00
Moritz Lipp
2b6fa0cfe6 Fix missing else in if condition 2013-07-07 00:40:32 +02:00
Abdo Roig-Maranges
7cdd1e7719 refresh horizontal position in page_set
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>
2013-07-07 00:14:56 +02:00
Abdó Roig-Maranges
7f42ccbdad Improve bisect setup
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-07-07 00:12:45 +02:00
Sebastian Ramacher
65da0ffa50 Decouple bisect from jumplist
Move some bisect state to zathura_t and manipulate the jumplist that much.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-07-07 00:03:52 +02:00
Marwan Tanager
7465ad6871 Jumplist: record the adjustments ratios, rather than their values
This makes jumping works accurately, even if the document is scaled up or down.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-06-29 11:35:11 +02:00
Sebastian Ramacher
e6f23fd235 CS
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-06-20 20:22:07 +02:00
Marwan Tanager
8549abaa95 Fix the segfault that happens when jumping while the jumplist is initially empty.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-06-20 20:18:07 +02:00
Marwan Tanager
5b7fc5de5f Make jumping with ^o and ^i more compatible with Vim
- 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>
2013-06-20 20:18:04 +02:00
Marwan Tanager
afd008f466 Enhancements/Cleanups for the jumplist mechansim
- 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>
2013-06-10 14:48:10 +02:00
Marwan Tanager
cc3b9aea18 More Vim-like search behavior
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>
2013-06-10 14:35:19 +02:00
Marwan Tanager
2d9ea08729 Use show-v-scrollbar instead of show-scrollbars
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-06-02 11:45:26 +02:00
Moritz Lipp
87f10baffc Allow negative offsets 2013-05-08 18:28:32 +02:00
Abdo Roig-Maranges
5563da4d91 also adjust the horizontal position in sc_bisect
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-04-02 21:46:55 +02:00
Abdo Roig-Maranges
49e5b053bf bisect functionality to navigate documents
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>
2013-04-02 21:22:20 +02:00
Abdo Roig-Maranges
1c3274bbd6 properly set horizontal position when navigating
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>
2013-04-02 20:52:46 +02:00
Marwan Tanager
8f695b8c52 Set the adjustment mode to ZATHURA_ADJUST_INPUTBAR before displaying or following links.
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>
2013-03-29 18:33:15 +01:00
Benoît Knecht
1702fb620a Don't scroll the document when focusing the inputbar
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>
2013-03-23 16:03:11 +01:00
Benoît Knecht
c9eef95492 Use signals to readjust_view_after_zooming()
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>
2013-03-23 16:02:56 +01:00
Benoît Knecht
f5b02a9751 Revert commit ce6e735
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>
2013-03-23 16:02:56 +01:00
Benoît Knecht
27c291758e Add a '--page' option to open at the specified page
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>
2013-03-17 11:30:22 +01:00
Sebastian Ramacher
99a03faed1 CS
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-03-03 02:26:08 +01:00
Marwan Tanager
7841eea2eb Scale vertical/horizontal scrolling by the contents of the numeric buffer.
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-03-03 02:23:51 +01:00
Moritz Lipp
ce6e7351ca Respect padding in sc_adjust_window
Thanks to Marwan Tanager
2013-02-07 09:26:37 +01:00
Rob Cornish
1a6b03fc62 Fixed reverse searching behaviour to be more like less/vi
Signed-off-by: Sebastian Ramacher <sebastian@ramacher.at>
2012-12-19 00:29:31 +01:00
Benoît Knecht
92c26ed28d Account for scrollbars when fitting page into window
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>
2012-12-13 18:18:03 +01:00
Benoît Knecht
a16819fdf0 Always free the GtkTreePath in sc_navigate_index
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2012-12-10 00:01:37 +01:00
Benoît Knecht
2192b7172c Add new shortcut function to display links
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>
2012-12-07 18:05:59 +01:00
Benoît Knecht
48d12f49be Also wrap when scrolling with 'j' and 'k'
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>
2012-12-06 20:39:16 +01:00
Benoît Knecht
c06d353eb7 Reverse scroll-wrap's logic
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>
2012-12-06 20:38:51 +01:00
Moritz Lipp
89e7832047 Update style 2012-10-09 01:12:18 +02:00
Moritz Lipp
94d8eef959 Toggle multi-page-mode with d 2012-10-06 14:58:07 +02:00