goto done; } ch = im_hangul2_choseong(keyval, state); if (im_hangul_is_choseong(ch)) { im_hangul_commit(context_hangul); context_hangul->choseong = ch; context_hangul->state = 1;
im_hangul2_automata(GtkIMContextHangul *context_hangul,		    GdkEventKey *key){  guint keyval, state;  gunichar ch;  if (pref_use_dvorak) {    keyval = im_hangul_dvorak_to_qwerty(key->keyval);    state = key->state;  } else {    keyval = key->keyval;    state = key->state;  }  if (context_hangul->state == 0) {    ch = im_hangul2_choseong(keyval, state);    if (im_hangul_is_choseong(ch)) {      context_hangul->state = 1;      context_hangul->choseong = ch;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      context_hangul->state = 2;      context_hangul->choseong = 0;      context_hangul->jungseong = ch;      goto done;    }    if (im_hangul_is_backspace(key))      return FALSE;  } else if (context_hangul->state == 1) {    ch = im_hangul2_choseong(keyval, state);    if (im_hangul_is_choseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->state = 1;      context_hangul->choseong = ch;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      context_hangul->jungseong = ch;      context_hangul->state = 3;      goto done;    }    if (im_hangul_is_backspace(key)) {      context_hangul->choseong = 0;      context_hangul->state = 0;      goto done;    }  } else if (context_hangul->state == 2) {    ch = im_hangul2_choseong(keyval, state);    if (im_hangul_is_choseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->choseong = ch;      context_hangul->state = 1;      goto done;    }    ch = im_hangul2_comp_jungseong(context_hangul->jungseong, keyval, state);    if (im_hangul_is_jungseong(ch)) {      context_hangul->jungseong = ch;      context_hangul->state = 4;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->jungseong = ch;      context_hangul->state = 2;      goto done;    }    if (im_hangul_is_backspace(key)) {      context_hangul->jungseong = 0;      context_hangul->state = 0;      goto done;    }  } else if (context_hangul->state == 3) {    ch = im_hangul2_jongseong(keyval, state);    if (im_hangul_is_jongseong(ch)) {      context_hangul->jongseong = ch;      context_hangul->state = 5;      goto done;    }    ch = im_hangul2_choseong(keyval, state);    if (im_hangul_is_choseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->choseong = ch;      context_hangul->state = 1;      goto done;    }    ch = im_hangul2_comp_jungseong(context_hangul->jungseong, keyval, state);    if (im_hangul_is_jungseong(ch)) {      context_hangul->jungseong = ch;      context_hangul->state = 6;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->jungseong = ch;      context_hangul->state = 2;      goto done;    }    if (im_hangul_is_backspace(key)) {      context_hangul->jungseong = 0;      context_hangul->state = 1;      goto done;    }  } else if (context_hangul->state == 4) {    ch = im_hangul2_choseong(keyval, state);    if (im_hangul_is_choseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->choseong = ch;      context_hangul->state = 1;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->jungseong = ch;      context_hangul->state = 2;      goto done;    }    if (im_hangul_is_backspace(key)) {      context_hangul->jungseong = 		im_hangul_compjungseong_to_single(context_hangul->jungseong);      context_hangul->state = 2;      goto done;    }  } else if (context_hangul->state == 5) {    ch = im_hangul2_comp_jongseong(context_hangul->jongseong, keyval, state);    if (im_hangul_is_jongseong(ch)) {      context_hangul->jongseong = ch;      context_hangul->state = 7;      goto done;    }    ch = im_hangul2_choseong(keyval, state);    if (im_hangul_is_choseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->choseong = ch;      context_hangul->state = 1;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      gunichar choseong = 		im_hangul2_jongseong_to_choseong(context_hangul->jongseong);      context_hangul->jongseong = 0;      im_hangul_commit(context_hangul);      context_hangul->choseong = choseong;      context_hangul->jungseong = ch;      context_hangul->state = 3;      goto done;    }    if (im_hangul_is_backspace(key)) {      context_hangul->jongseong = 0;      context_hangul->state = 3;      goto done;    }  } else if (context_hangul->state == 6) {    ch = im_hangul2_jongseong(keyval, state);    if (im_hangul_is_jongseong(ch)) {      context_hangul->jongseong = ch;      context_hangul->state = 8;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->jungseong = ch;      context_hangul->state = 2;      goto done;    }    if (im_hangul_is_backspace(key)) {      context_hangul->jungseong =        im_hangul_compjungseong_to_single(context_hangul->jungseong);      context_hangul->state = 3;      goto done;    }  } else if (context_hangul->state == 7) {    ch = im_hangul2_choseong(keyval, state);    if (im_hangul_is_choseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->choseong = ch;      context_hangul->state = 1;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      /* complex final consonant       * to single final consonant and initial consonant */      gunichar choseong = 		im_hangul2_jongseong_to_choseong(context_hangul->jongseong);      context_hangul->jongseong = 		im_hangul_compjongseong_to_single(context_hangul->jongseong);      im_hangul_commit(context_hangul);      context_hangul->choseong = choseong;      context_hangul->jungseong = ch;      context_hangul->state = 3;      goto done;    }    if (im_hangul_is_backspace(key)) {      context_hangul->jongseong = 		im_hangul_compjongseong_to_single(context_hangul->jongseong);      context_hangul->state = 5;      goto done;    }  } else if (context_hangul->state == 8) {    ch = im_hangul2_comp_jongseong(context_hangul->jongseong, keyval, state);    if (im_hangul_is_jongseong(ch)) {      context_hangul->jongseong = ch;      context_hangul->state = 9;      goto done;    }    ch = im_hangul2_choseong(keyval, state);    if (im_hangul_is_choseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->choseong = ch;      context_hangul->state = 1;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      gunichar choseong = 		im_hangul2_jongseong_to_choseong(context_hangul->jongseong);      context_hangul->jongseong = 0;      im_hangul_commit(context_hangul);      context_hangul->state = 3;      context_hangul->choseong = choseong;      context_hangul->jungseong = ch;      goto done;    }    if (im_hangul_is_backspace(key)) {      context_hangul->state = 6;      context_hangul->jongseong = 0;      goto done;    }  } else if (context_hangul->state == 9) {    ch = im_hangul2_choseong(keyval, state);    if (im_hangul_is_choseong(ch)) {      im_hangul_commit(context_hangul);      context_hangul->state = 1;      context_hangul->choseong = ch;      goto done;    }    ch = im_hangul2_jungseong(keyval, state);    if (im_hangul_is_jungseong(ch)) {      /* complex final consonant       * to single final consonant and initial consonant */      gunichar choseong = 		im_hangul2_jongseong_to_choseong(context_hangul->jongseong);      context_hangul->jongseong =       		im_hangul_compjongseong_to_single(context_hangul->jongseong);      im_hangul_commit(context_hangul);      context_hangul->state = 3;      context_hangul->choseong = choseong;      context_hangul->jungseong = ch;      goto done;    }    if (im_hangul_is_backspace(key)) {      context_hangul->jongseong =       		im_hangul_compjongseong_to_single(context_hangul->jongseong);      context_hangul->state = 8;      goto done;    }  }  if (im_hangul_is_trigger(key)) {    /* hangul mode change to englishmode */    g_print("Input mode changed: Direct mode\n");    im_hangul_commit(context_hangul);    g_signal_emit_by_name (context_hangul, "preedit_changed");    im_hangul_mode_direct(context_hangul);    return TRUE;  }  if (context_hangul->state != 0) {    im_hangul_commit(context_hangul);    context_hangul->state = 0;    g_signal_emit_by_name (context_hangul, "preedit_changed");  }  return im_hangul_process_nonhangul(context_hangul, key); /* english */done:  g_signal_emit_by_name (context_hangul, "preedit_changed");  return TRUE;}