text: Add support for pre-edit string

Add support of preedit-string to the example editor client. Also add a
preedit_string request to the input_method_context interface and use
that in the example weston keyboard to first create a pre-edit string
when entering keys and commit it on space.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
diff --git a/clients/editor.c b/clients/editor.c
index b0b400e..b6a1742 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -209,6 +209,9 @@
 				      uint32_t button,
 				      enum wl_pointer_button_state state, void *data);
 static void text_entry_insert_at_cursor(struct text_entry *entry, const char *text);
+static void text_entry_set_preedit(struct text_entry *entry,
+				   const char *preedit_text,
+				   int preedit_cursor);
 
 static void
 text_model_commit_string(void *data,
@@ -234,6 +237,16 @@
 			  const char *text,
 			  uint32_t index)
 {
+	struct text_entry *entry = data;
+
+	if (index > strlen(text)) {
+		fprintf(stderr, "Invalid cursor index %d\n", index);
+		index = strlen(text);
+	}
+
+	text_entry_set_preedit(entry, text, index);
+
+	widget_schedule_redraw(entry->widget);
 }
 
 static void