From bf4981327a5d5985b573a2e594c31b455ec59ba6 Mon Sep 17 00:00:00 2001 From: Choe Hwanjin Date: Wed, 24 Feb 2016 15:16:35 +0900 Subject: =?UTF-8?q?hangul=20ic:=20HANGUL=5FIC=5FOPTION=5FNON=5FCHOSEONG=5F?= =?UTF-8?q?COMBI=20=EC=98=B5=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 첫음절에 유니코드 초성에 없는 글자도 조합하는 기능을 설정할 수 있게 한다. libhangul에서는 ㄳ이나 ㄺ등 초성에 없는 글자를 첫음절에서 조합하는 기능을 제공하지 않았다. 그러나 MS IME와 호환성을 높이기 위해서 이 기능을 추가하였으므로, 이 기능을 켜고 끌 수 있도록 옵션으로 처리한다. 관련 유닛테스트 코드도 추가한다. --- hangul/hangul.h | 1 + hangul/hangulinputcontext.c | 14 ++++++++++++++ test/test.c | 17 +++++++++++++++++ 3 files changed, 32 insertions(+) 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); -- cgit v1.2.1