diff options
-rw-r--r-- | hangul/hangul.h | 1 | ||||
-rw-r--r-- | hangul/hangulinputcontext.c | 14 | ||||
-rw-r--r-- | test/test.c | 17 |
3 files changed, 32 insertions, 0 deletions
diff --git a/hangul/hangul.h b/hangul/hangul.h index b55ee57..fe85124 100644 --- a/hangul/hangul.h +++ b/hangul/hangul.h @@ -90,6 +90,7 @@ enum { enum { HANGUL_IC_OPTION_AUTO_REORDER, HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE, + HANGUL_IC_OPTION_NON_CHOSEONG_COMBI, }; /* keyboard */ diff --git a/hangul/hangulinputcontext.c b/hangul/hangulinputcontext.c index 0585d71..83ce52e 100644 --- a/hangul/hangulinputcontext.c +++ b/hangul/hangulinputcontext.c @@ -236,6 +236,7 @@ struct _HangulInputContext { unsigned int use_jamo_mode_only : 1; unsigned int option_auto_reorder : 1; unsigned int option_combi_on_double_stroke : 1; + unsigned int option_non_choseong_combi : 1; }; #include "hangulkeyboard.h" @@ -870,6 +871,13 @@ hangul_ic_combine(HangulInputContext* hic, ucschar first, ucschar second) combined = hangul_combination_combine(hic->keyboard->combination, first, second); + if (!hic->option_non_choseong_combi) { + if (hangul_is_choseong(first) && hangul_is_choseong(second) && + hangul_is_jongseong(combined)) { + return 0; + } + } + return combined; } @@ -1589,6 +1597,8 @@ hangul_ic_get_option(HangulInputContext* hic, int option) return hic->option_auto_reorder; case HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE: return hic->option_combi_on_double_stroke; + case HANGUL_IC_OPTION_NON_CHOSEONG_COMBI: + return hic->option_non_choseong_combi; } return false; @@ -1604,6 +1614,9 @@ hangul_ic_set_option(HangulInputContext* hic, int option, bool value) case HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE: hic->option_combi_on_double_stroke = value; break; + case HANGUL_IC_OPTION_NON_CHOSEONG_COMBI: + hic->option_non_choseong_combi = value; + break; } } @@ -1765,6 +1778,7 @@ hangul_ic_new(const char* keyboard) hic->option_auto_reorder = false; hic->option_combi_on_double_stroke = false; + hic->option_non_choseong_combi = true; hangul_ic_set_output_mode(hic, HANGUL_OUTPUT_SYLLABLE); hangul_ic_select_keyboard(hic, keyboard); diff --git a/test/test.c b/test/test.c index def4e0a..1697720 100644 --- a/test/test.c +++ b/test/test.c @@ -392,6 +392,22 @@ START_TEST(test_hangul_ic_combi_on_double_stroke) } END_TEST +START_TEST(test_hangul_ic_non_choseong_combi) +{ + bool val = get_ic_option(HANGUL_IC_OPTION_NON_CHOSEONG_COMBI); + set_ic_option(HANGUL_IC_OPTION_NON_CHOSEONG_COMBI, true); + fail_unless(check_preedit("2", "rt", L"ㄳ")); + fail_unless(check_commit("2", "rtk", L"ㄱ")); + fail_unless(check_preedit("2", "rtk", L"사")); + + set_ic_option(HANGUL_IC_OPTION_NON_CHOSEONG_COMBI, false); + fail_unless(check_commit("2", "rt", L"ㄱ")); + fail_unless(check_preedit("2", "rt", L"ㅅ")); + + set_ic_option(HANGUL_IC_OPTION_NON_CHOSEONG_COMBI, val); +END_TEST +} + START_TEST(test_syllable_iterator) { ucschar str[] = { @@ -555,6 +571,7 @@ Suite* libhangul_suite() tcase_add_test(hangul, test_hangul_ic_process_romaja); tcase_add_test(hangul, test_hangul_ic_auto_reorder); tcase_add_test(hangul, test_hangul_ic_combi_on_double_stroke); + tcase_add_test(hangul, test_hangul_ic_non_choseong_combi); tcase_add_test(hangul, test_syllable_iterator); tcase_add_test(hangul, test_hangul_keyboard); tcase_add_test(hangul, test_hangul_jamo_to_cjamo); |