Use an enum for ime_state

This commit is contained in:
Kovid Goyal
2021-03-23 10:42:07 +05:30
parent 11268ffa16
commit 84dcf8fd27
6 changed files with 30 additions and 20 deletions

View File

@@ -105,19 +105,19 @@ on_key_input(GLFWkeyevent *ev) {
id_type active_window_id = w->id;
switch(ev->ime_state) {
case 1: // update pre-edit text
case GLFW_IME_PREEDIT_CHANGED:
update_ime_position(global_state.callback_os_window, w, screen);
screen_draw_overlay_text(screen, text);
debug("updated pre-edit text: '%s'\n", text);
return;
case 2: // commit text
case GLFW_IME_COMMIT_TEXT:
if (*text) {
schedule_write_to_child(w->id, 1, text, strlen(text));
debug("committed pre-edit text: %s\n", text);
} else debug("committed pre-edit text: (null)\n");
screen_draw_overlay_text(screen, NULL);
return;
case 0:
case GLFW_IME_NONE:
// for macOS, update ime position on every key input
// because the position is required before next input
#if defined(__APPLE__)