After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 702073 - Implement text selection with the keyboard when caret navigation is enabled
Implement text selection with the keyboard when caret navigation is enabled
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
3.9.x
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
: 491217 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-06-12 10:27 UTC by Carlos Garcia Campos
Modified: 2013-11-02 10:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Text selection (2.17 KB, patch)
2013-06-12 12:11 UTC, Antía Puentes
none Details | Review
Text selection (5.55 KB, patch)
2013-06-20 17:10 UTC, Antía Puentes
needs-work Details | Review
Text selection using the caret (5.70 KB, patch)
2013-06-21 13:04 UTC, Antía Puentes
committed Details | Review

Description Carlos Garcia Campos 2013-06-12 10:27:25 UTC
Allow to select text when moving the caret while shift key is pressed.
Comment 1 Antía Puentes 2013-06-12 12:11:35 UTC
Created attachment 246619 [details] [review]
Text selection
Comment 2 Antía Puentes 2013-06-20 17:10:34 UTC
Created attachment 247361 [details] [review]
Text selection

Update the previous patch, as it had become obsolete because EvView is using gtkbindings now.
Comment 3 Carlos Garcia Campos 2013-06-21 09:46:32 UTC
Review of attachment 247361 [details] [review]:

I like it a lot, but there are a few issues.

::: libview/ev-view.c
@@ +4963,3 @@
+select_rectangle (EvView *view,
+		  GdkRectangle *prev_rect,
+		  GdkRectangle *rect)

This method is a bit confusing, it's called select_rectangle but it receives two rectangles. The method is only used to extend the selection from the cursor, select_rectangle sounds too generic. I think this could be called something like extend_selection_from_cursor and it only receives an end point. The computation of the cursor point can be done here instead of in ev_view_move_cursor.

@@ +5064,3 @@
+		GdkRectangle prev_rect;
+
+		if (!get_caret_cursor_rect_from_offset (view, prev_offset, prev_page, &prev_rect))

There's a small problem with this approach. get_caret_cursor_rect_from_offset() is a bit confusing too, because it doesn't return the cursor_rect, but the bbox of the character where the cursor should be at. The method that actually returns the cursor_rect is get_caret_cursor_area. The problem of not using the actual cursor rect, is that in some cases, specially with spaces, the selection is one character beyond the actual cursor, so we need to make sure the end point we pass to compute_selections is exactly at the cursor position.
Comment 4 Carlos Garcia Campos 2013-06-21 10:03:07 UTC
To avoid the get_caret_cursor_rect_from_offset() confusion I've just pushed a patch to git master to merge get_caret_cursor_rect_from_offset() and get_caret_cursor_area().
Comment 5 Antía Puentes 2013-06-21 13:04:59 UTC
Created attachment 247434 [details] [review]
Text selection using the caret

Updated patch.
Comment 6 Carlos Garcia Campos 2013-06-21 13:50:53 UTC
Review of attachment 247434 [details] [review]:

Great, I've just pushed it to git master with the two comments I mention below fixed. Thanks!

::: libview/ev-view.c
@@ +5050,3 @@
+
+	/* Select text */
+	if (extend_selection) {

Instead of returning early in extend_selection_from_cursor when selection is not supported for the document, we can check it here and save all this in such case.

@@ +5062,2 @@
+		end_point.x = rect.x;
+		end_point.y = rect.y;

In previous patch you moved the y coords to the middle of the line, it is still needed.
Comment 7 Carlos Garcia Campos 2013-11-02 10:06:54 UTC
*** Bug 491217 has been marked as a duplicate of this bug. ***