text: Add reset requets to protocol
Add a reset request to the text_model interface and a reset event to the input_method_context interface. Use it to reset the pre-edit buffers in the example keyboard when the cursor is moved in the example editor client. Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
ce8a4433f5
commit
c1e481efb1
@@ -548,6 +548,8 @@ text_entry_set_cursor_position(struct text_entry *entry,
|
||||
{
|
||||
entry->cursor = text_layout_xy_to_index(entry->layout, x, y);
|
||||
|
||||
text_model_reset(entry->model);
|
||||
|
||||
if (entry->cursor >= entry->preedit_cursor) {
|
||||
entry->cursor -= entry->preedit_cursor;
|
||||
}
|
||||
|
||||
@@ -303,8 +303,26 @@ input_method_context_surrounding_text(void *data,
|
||||
fprintf(stderr, "Surrounding text updated: %s\n", text);
|
||||
}
|
||||
|
||||
static void
|
||||
input_method_context_reset(void *data,
|
||||
struct input_method_context *context)
|
||||
{
|
||||
struct virtual_keyboard *keyboard = data;
|
||||
|
||||
fprintf(stderr, "Reset pre-edit buffer\n");
|
||||
|
||||
if (strlen(keyboard->preedit_string)) {
|
||||
input_method_context_preedit_string(context,
|
||||
"",
|
||||
0);
|
||||
free(keyboard->preedit_string);
|
||||
keyboard->preedit_string = strdup("");
|
||||
}
|
||||
}
|
||||
|
||||
static const struct input_method_context_listener input_method_context_listener = {
|
||||
input_method_context_surrounding_text,
|
||||
input_method_context_reset
|
||||
};
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user