summaryrefslogtreecommitdiff
path: root/gtk/gtktextdisplay.c
diff options
context:
space:
mode:
authorPaolo Borelli <pborelli@gnome.org>2011-11-27 15:12:36 +0100
committerPaolo Borelli <pborelli@gnome.org>2011-12-01 01:22:39 +0100
commit3c6842222abb1284e0f13760bc0f0c48d41b0c8f (patch)
tree4370090a5cfe79d0eeb675f14e3ec16f28b59458 /gtk/gtktextdisplay.c
parent0bff1af7a20948a7275a4e9e1fa3fac903a422f8 (diff)
downloadgtk+-3c6842222abb1284e0f13760bc0f0c48d41b0c8f.tar.gz
Use the split-cursor setting for textview cursors
Explicitely check the split-cursor setting when drawing the textview insertion cursor instead of relying on the cursor_direction set in the textlayout. This makes the cursor drawin code more uniform with other widgets in preparation to refactoring the cursor drawing code in a shared function. https://bugzilla.gnome.org/show_bug.cgi?id=640317
Diffstat (limited to 'gtk/gtktextdisplay.c')
-rw-r--r--gtk/gtktextdisplay.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 6911dae0ee..dad8e40d4b 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -912,39 +912,56 @@ gtk_text_layout_draw (GtkTextLayout *layout,
{
int index;
PangoRectangle strong_pos, weak_pos;
+ PangoRectangle *cursor1, *cursor2;
+ gboolean split_cursor;
+ GtkTextDirection dir1, dir2;
GdkRectangle cursor_location;
index = g_array_index(line_display->cursors, int, i);
pango_layout_get_cursor_pos (line_display->layout, index, &strong_pos, &weak_pos);
- cursor_location.x = line_display->x_offset + PANGO_PIXELS (strong_pos.x);
- cursor_location.y = line_display->top_margin + PANGO_PIXELS (strong_pos.y);
- cursor_location.width = 0;
- cursor_location.height = PANGO_PIXELS (strong_pos.height);
+ dir1 = line_display->direction;
+ dir2 = GTK_TEXT_DIR_NONE;
+
+ g_object_get (gtk_widget_get_settings (widget),
+ "gtk-split-cursor", &split_cursor,
+ NULL);
- if (layout->cursor_direction == GTK_TEXT_DIR_NONE ||
- line_display->direction == layout->cursor_direction)
+ if (split_cursor)
{
- gtk_draw_insertion_cursor (widget, cr,
- &cursor_location, TRUE, line_display->direction,
- layout->cursor_direction != GTK_TEXT_DIR_NONE);
+ cursor1 = &strong_pos;
+ if (strong_pos.x != weak_pos.x || strong_pos.y != weak_pos.y)
+ {
+ dir2 = (line_display->direction == GTK_TEXT_DIR_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
+ cursor2 = &weak_pos;
+ }
}
-
- if ((strong_pos.x != weak_pos.x || strong_pos.y != weak_pos.y) &&
- (layout->cursor_direction == GTK_TEXT_DIR_NONE ||
- line_display->direction != layout->cursor_direction))
+ else
{
- GtkTextDirection dir;
+ if (layout->keyboard_direction == line_display->direction)
+ cursor1 = &strong_pos;
+ else
+ cursor1 = &weak_pos;
+ }
+
+ cursor_location.x = line_display->x_offset + PANGO_PIXELS (cursor1->x);
+ cursor_location.y = line_display->top_margin + PANGO_PIXELS (cursor1->y);
+ cursor_location.width = 0;
+ cursor_location.height = PANGO_PIXELS (cursor1->height);
- dir = (line_display->direction == GTK_TEXT_DIR_RTL) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
+ gtk_draw_insertion_cursor (widget, cr,
+ &cursor_location, TRUE, dir1,
+ dir2 != GTK_TEXT_DIR_NONE);
- cursor_location.x = line_display->x_offset + PANGO_PIXELS (weak_pos.x);
- cursor_location.y = line_display->top_margin + PANGO_PIXELS (weak_pos.y);
+ if (dir2 != GTK_TEXT_DIR_NONE)
+ {
+ cursor_location.x = line_display->x_offset + PANGO_PIXELS (cursor2->x);
+ cursor_location.y = line_display->top_margin + PANGO_PIXELS (cursor2->y);
cursor_location.width = 0;
- cursor_location.height = PANGO_PIXELS (weak_pos.height);
+ cursor_location.height = PANGO_PIXELS (cursor2->height);
gtk_draw_insertion_cursor (widget, cr,
- &cursor_location, FALSE, dir,
+ &cursor_location, FALSE, dir2,
TRUE);
}
}