gimp r27439 - in trunk: . app/tools
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27439 - in trunk: . app/tools
- Date: Mon, 27 Oct 2008 11:00:15 +0000 (UTC)
Author: mitch
Date: Mon Oct 27 11:00:15 2008
New Revision: 27439
URL: http://svn.gnome.org/viewvc/gimp?rev=27439&view=rev
Log:
2008-10-27 Michael Natterer <mitch gimp org>
* app/tools/gimptexttool.c (gimp_text_tool_key_press): argh, need
to speak in byte offsets not character offsets. Do so and avoid
getting the buffer's text on each keystroke just to do the
char/byte conversion. Will use the same method for all the other
places which do similar things.
(gimp_text_tool_connect): minor cleanup.
Modified:
trunk/ChangeLog
trunk/app/tools/gimptexttool.c
Modified: trunk/app/tools/gimptexttool.c
==============================================================================
--- trunk/app/tools/gimptexttool.c (original)
+++ trunk/app/tools/gimptexttool.c Mon Oct 27 11:00:15 2008
@@ -841,18 +841,25 @@
case GDK_Down:
case GDK_KP_Down:
{
- gint offset;
gint line;
+ gint line_index;
gint trailing;
PangoLayoutLine *layout_line;
- offset = gtk_text_iter_get_offset (&selection);
+ line = gtk_text_iter_get_line (&selection);
+ line_index = gtk_text_iter_get_line_index (&selection);
- pango_layout_index_to_line_x (text_tool->layout->layout,
- offset,
- FALSE, &line, &x_pos);
+ layout_line = pango_layout_get_line_readonly (text_tool->layout->layout,
+ line);
- if (text_tool->x_pos != -1)
+ pango_layout_line_index_to_x (layout_line,
+ layout_line->start_index + line_index,
+ FALSE, &x_pos);
+
+ /* try to go to the remembered x_pos if it exists *and* we are at
+ * the end of the current line
+ */
+ if (text_tool->x_pos != -1 && line_index == layout_line->length)
x_pos = text_tool->x_pos;
if (kevent->keyval == GDK_Up ||
@@ -874,6 +881,7 @@
layout_line = pango_layout_get_line_readonly (text_tool->layout->layout,
line);
+
if (! layout_line)
{
if (kevent->keyval == GDK_Up ||
@@ -892,10 +900,17 @@
break;
}
- pango_layout_line_x_to_index (layout_line, x_pos, &offset, &trailing);
+ pango_layout_line_x_to_index (layout_line, x_pos,
+ &line_index, &trailing);
+
+ line_index -= layout_line->start_index;
- gtk_text_buffer_get_iter_at_offset (text_tool->text_buffer,
- &selection, offset + trailing);
+ gtk_text_buffer_get_iter_at_line_index (text_tool->text_buffer,
+ &selection,
+ line, line_index);
+
+ while (trailing--)
+ gtk_text_iter_forward_char (&selection);
gtk_text_buffer_place_cursor (text_tool->text_buffer, &selection);
gtk_text_buffer_select_range (text_tool->text_buffer, sel_start,
@@ -1084,12 +1099,9 @@
if (text_tool->layer != layer)
{
if (text_tool->layer)
- {
- g_signal_handlers_disconnect_by_func (text_tool->layer,
- gimp_text_tool_layer_notify,
- text_tool);
- text_tool->layer = NULL;
- }
+ g_signal_handlers_disconnect_by_func (text_tool->layer,
+ gimp_text_tool_layer_notify,
+ text_tool);
text_tool->layer = layer;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]