gimp r27430 - in trunk: . app/tools
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27430 - in trunk: . app/tools
- Date: Sun, 26 Oct 2008 23:30:23 +0000 (UTC)
Author: mitch
Date: Sun Oct 26 23:30:23 2008
New Revision: 27430
URL: http://svn.gnome.org/viewvc/gimp?rev=27430&view=rev
Log:
2008-10-27 Michael Natterer <mitch gimp org>
* app/tools/gimptexttool.h: add integer x_pos member to remember
the x cursor position when moving up and down across shorter
lines.
* app/tools/gimptexttool.c (gimp_text_tool_key_press): implement
moving the cursor up and down. The x_pos probably needs to be
reset in a few more places but it seems to work pretty nicely
already.
Modified:
trunk/ChangeLog
trunk/app/tools/gimptexttool.c
trunk/app/tools/gimptexttool.h
Modified: trunk/app/tools/gimptexttool.c
==============================================================================
--- trunk/app/tools/gimptexttool.c (original)
+++ trunk/app/tools/gimptexttool.c Sun Oct 26 23:30:23 2008
@@ -291,6 +291,8 @@
"context/context-font-select-set");
text_tool->handle_rectangle_change_complete = TRUE;
+
+ text_tool->x_pos = -1;
}
static GObject *
@@ -752,11 +754,13 @@
GtkTextMark *selection_bound;
GtkTextIter cursor, selection;
GtkTextIter *sel_start;
+ gint x_pos = -1;
gboolean retval = TRUE;
if (gtk_im_context_filter_keypress (text_tool->im_context, kevent))
{
text_tool->needs_im_reset = TRUE;
+ text_tool->x_pos = -1;
return TRUE;
}
@@ -832,6 +836,73 @@
gimp_text_tool_reset_im_context (text_tool);
break;
+ case GDK_Up:
+ case GDK_KP_Up:
+ case GDK_Down:
+ case GDK_KP_Down:
+ {
+ gint offset;
+ gint line;
+ gint trailing;
+ PangoLayoutLine *layout_line;
+
+ offset = gtk_text_iter_get_offset (&selection);
+
+ pango_layout_index_to_line_x (text_tool->layout->layout,
+ offset,
+ FALSE, &line, &x_pos);
+
+ if (text_tool->x_pos != -1)
+ x_pos = text_tool->x_pos;
+
+ if (kevent->keyval == GDK_Up ||
+ kevent->keyval == GDK_KP_Up)
+ {
+ line--;
+ if (line < 0)
+ {
+ gtk_text_iter_set_line_offset (&selection, 0);
+ gtk_text_buffer_select_range (text_tool->text_buffer, sel_start,
+ &selection);
+ break;
+ }
+ }
+ else
+ {
+ line++;
+ }
+
+ layout_line = pango_layout_get_line_readonly (text_tool->layout->layout,
+ line);
+ if (! layout_line)
+ {
+ if (kevent->keyval == GDK_Up ||
+ kevent->keyval == GDK_KP_Up)
+ {
+ gtk_text_iter_set_line_offset (&selection, 0);
+ gtk_text_buffer_select_range (text_tool->text_buffer, sel_start,
+ &selection);
+ }
+ else
+ {
+ gtk_text_iter_forward_to_line_end (&selection);
+ gtk_text_buffer_select_range (text_tool->text_buffer, sel_start,
+ &selection);
+ }
+ break;
+ }
+
+ pango_layout_line_x_to_index (layout_line, x_pos, &offset, &trailing);
+
+ gtk_text_buffer_get_iter_at_offset (text_tool->text_buffer,
+ &selection, offset + trailing);
+
+ gtk_text_buffer_place_cursor (text_tool->text_buffer, &selection);
+ gtk_text_buffer_select_range (text_tool->text_buffer, sel_start,
+ &selection);
+ }
+ break;
+
case GDK_Home:
case GDK_KP_Home:
gtk_text_iter_set_line (&selection, gtk_text_iter_get_line (&selection));
@@ -851,6 +922,8 @@
retval = FALSE;
}
+ text_tool->x_pos = x_pos;
+
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
return retval;
Modified: trunk/app/tools/gimptexttool.h
==============================================================================
--- trunk/app/tools/gimptexttool.h (original)
+++ trunk/app/tools/gimptexttool.h Sun Oct 26 23:30:23 2008
@@ -67,6 +67,8 @@
gboolean text_box_fixed;
gboolean text_cursor_changing;
+ gint x_pos;
+
GimpTextLayout *layout;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]