[gimp] app: improve cursor movement by positions when there is a selection
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: improve cursor movement by positions when there is a selection
- Date: Wed, 17 Feb 2010 12:19:18 +0000 (UTC)
commit 9974fe36d1bb74d907798ab6a29b0d3cf1ab18ae
Author: Michael Natterer <mitch gimp org>
Date: Wed Feb 17 13:17:46 2010 +0100
app: improve cursor movement by positions when there is a selection
Port over the patch I did for GtkTextView and move *to* the end of the
selection and not *from* it when there is a selection and we are
moving by characters.
app/tools/gimptexttool.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index 11d18d3..1d70a57 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -1424,6 +1424,7 @@ gimp_text_tool_move_cursor (GimpTextTool *text_tool,
GtkTextIter cursor;
GtkTextIter selection;
GtkTextIter *sel_start;
+ gboolean cancel_selection = FALSE;
gint x_pos = -1;
g_printerr ("%s: %s count = %d, select = %s\n",
@@ -1454,22 +1455,29 @@ gimp_text_tool_move_cursor (GimpTextTool *text_tool,
gtk_text_iter_order (&cursor, &selection);
sel_start = &cursor;
+
+ /* if we actually have a selection, just move *to* the beginning/end
+ * of the selection and not *from* there on LOGICAL_POSITIONS
+ * and VISUAL_POSITIONS movement
+ */
+ if (! gtk_text_iter_equal (&cursor, &selection))
+ cancel_selection = TRUE;
}
switch (step)
{
case GTK_MOVEMENT_LOGICAL_POSITIONS:
- gtk_text_iter_forward_visible_cursor_positions (&cursor, count);
+ if (! cancel_selection)
+ gtk_text_iter_forward_visible_cursor_positions (&cursor, count);
break;
case GTK_MOVEMENT_VISUAL_POSITIONS:
- if (count < 0)
- {
- gtk_text_iter_backward_cursor_position (&cursor);
- }
- else if (count > 0)
+ if (! cancel_selection)
{
- gtk_text_iter_forward_cursor_position (&cursor);
+ if (count < 0)
+ gtk_text_iter_backward_cursor_position (&cursor);
+ else if (count > 0)
+ gtk_text_iter_forward_cursor_position (&cursor);
}
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]