summaryrefslogtreecommitdiff
path: root/gtk/gtktextlayout.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-09-19 15:17:13 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-09-19 15:17:13 +0000
commit257e0f26efef81772816a722f730df0387a54263 (patch)
tree13f1c2b8a78e0d2d225fdb94ff965f8e04deaba6 /gtk/gtktextlayout.c
parentf787ebb03f24399b9f862caf9116ce7c34cbd3df (diff)
downloadgtk+-gtk-new-im.tar.gz
Rip out support for multiple locales; that simple doesn't work reliablygtk-new-im
Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * modules/input/{gtkimcontextxim.[ch],imxim.c}: Rip out support for multiple locales; that simple doesn't work reliably with current Xlib * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. * modules/input/gtkimcontextxim.[ch]:
Diffstat (limited to 'gtk/gtktextlayout.c')
-rw-r--r--gtk/gtktextlayout.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index ac0530252c..5d070a5bb7 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -343,6 +343,7 @@ gtk_text_layout_set_screen_width (GtkTextLayout *layout, gint width)
* @layout: a #PangoLayout
* @preedit_string: a string to display at the insertion point
* @preedit_attrs: a #PangoAttrList of attributes that apply to @preedit_string
+ * @cursor_pos: position of cursor within preedit string in chars
*
* Set the preedit string and attributes. The preedit string is a
* string showing text that is currently being edited and not
@@ -351,7 +352,8 @@ gtk_text_layout_set_screen_width (GtkTextLayout *layout, gint width)
void
gtk_text_layout_set_preedit_string (GtkTextLayout *layout,
const gchar *preedit_string,
- PangoAttrList *preedit_attrs)
+ PangoAttrList *preedit_attrs,
+ gint cursor_pos)
{
GtkTextIter iter;
GtkTextLine *line;
@@ -372,12 +374,16 @@ gtk_text_layout_set_preedit_string (GtkTextLayout *layout,
layout->preedit_len = strlen (layout->preedit_string);
pango_attr_list_ref (preedit_attrs);
layout->preedit_attrs = preedit_attrs;
+
+ cursor_pos = CLAMP (cursor_pos, 0, g_utf8_strlen (layout->preedit_string, -1));
+ layout->preedit_cursor = g_utf8_offset_to_pointer (layout->preedit_string, cursor_pos) - layout->preedit_string;
}
else
{
layout->preedit_string = NULL;
layout->preedit_len = 0;
layout->preedit_attrs = NULL;
+ layout->preedit_cursor = 0;
}
/* Now invalidate the paragraph containing the cursor
@@ -1526,6 +1532,8 @@ gtk_text_layout_get_line_display (GtkTextLayout *layout,
else if (seg->type == &gtk_text_right_mark_type ||
seg->type == &gtk_text_left_mark_type)
{
+ gint cursor_offset = 0;
+
/* At the insertion point, add the preedit string, if any */
if (gtk_text_btree_mark_is_insert (_gtk_text_buffer_get_btree (layout->buffer),
@@ -1544,6 +1552,8 @@ gtk_text_layout_get_line_display (GtkTextLayout *layout,
memcpy (text + byte_offset, layout->preedit_string, layout->preedit_len);
byte_offset += layout->preedit_len;
+
+ cursor_offset = layout->preedit_cursor - layout->preedit_len;
}
}
@@ -1551,7 +1561,7 @@ gtk_text_layout_get_line_display (GtkTextLayout *layout,
if (seg->body.mark.visible)
{
- cursor_byte_offsets = g_slist_prepend (cursor_byte_offsets, GINT_TO_POINTER (byte_offset));
+ cursor_byte_offsets = g_slist_prepend (cursor_byte_offsets, GINT_TO_POINTER (byte_offset + cursor_offset));
cursor_segs = g_slist_prepend (cursor_segs, seg);
}
}