from = cursor.from, to = from + n;
else
{
+ from = cursor.from + n;
+ to = cursor.from;
if (cursor.from == cur.from)
{
/* We are at the beginning of line. */
reseat (info.line_from);
}
update_cursor (pos, 1);
- from = cursor.from;
- to = cursor.to;
- }
- else
- {
- from = cursor.from - 1;
- to = cursor.from;
}
}
XtSetValues (CurIMStatus, arg, 1);
}
+void
+surrounding_text_handler (MInputContext *ic, MSymbol command)
+{
+ if (command == Minput_get_surrounding_text)
+ {
+ int len = (int) mplist_value (ic->plist);
+ int pos;
+ MText *surround = NULL;
+
+ if (len < 0)
+ {
+ pos = cursor.from + len;
+ if (pos < 0)
+ pos = 0;
+ surround = mtext_duplicate (mt, pos, cursor.from);
+ }
+ else if (len > 0)
+ {
+ pos = cursor.from + len;
+ if (pos > nchars)
+ pos = nchars;
+ surround = mtext_duplicate (mt, cursor.from, pos);
+ }
+ if (surround)
+ {
+ mplist_set (ic->plist, Mtext, surround);
+ m17n_object_unref (surround);
+ }
+ }
+ else if (command == Minput_delete_surrounding_text)
+ {
+ int len = (int) mplist_value (ic->plist);
+
+ if (len < 0)
+ {
+ if (corsor.from + len < 0)
+ len = - corsor.from;
+ delete_char (len);
+ }
+ else if (len > 0)
+ {
+ if (corsor.from + len > nchars)
+ len = nchars - corsor.from;
+ delete_char (len);
+ }
+ }
+}
+
int
compare_input_method (const void *elt1, const void *elt2)
{
MDatabase *mdb = mplist_value (pl);
MSymbol *tag = mdatabase_tag (mdb);
- input_method_table[i].language = tag[1];
- input_method_table[i].name = tag[2];
+ if (tag[2] == Mnil)
+ i--, num_input_methods--;
+ else
+ {
+ input_method_table[i].language = tag[1];
+ input_method_table[i].name = tag[2];
+ }
}
m17n_object_unref (plist);
}
(void *) input_status);
mplist_put (minput_driver->callback_list, Minput_status_done,
(void *) input_status);
+ mplist_put (minput_driver->callback_list, Minput_get_surrounding_text,
+ (void *) surrounding_text_handler);
+ mplist_put (minput_driver->callback_list, Minput_delete_surrounding_text,
+ (void *) surrounding_text_handler);
current_input_context = NULL;
current_input_method = -1;