/
0026-Add-option-HANGUL_IC_OPTION_NON_CHOSEONG_COMBI.patch
128 lines (113 loc) · 4.29 KB
/
0026-Add-option-HANGUL_IC_OPTION_NON_CHOSEONG_COMBI.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
From 7c462a225b0816c0c954c834e2df56fba3670f44 Mon Sep 17 00:00:00 2001
From: Choe Hwanjin <choe.hwanjin@gmail.com>
Date: Wed, 24 Feb 2016 15:16:35 +0900
Subject: [PATCH 6/6] Add option -HANGUL_IC_OPTION_NON_CHOSEONG_COMBI
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
hangul ic: HANGUL_IC_OPTION_NON_CHOSEONG_COMBI 옵션 추가
첫음절에 유니코드 초성에 없는 글자도 조합하는 기능을 설정할 수 있게
한다. libhangul에서는 ㄳ이나 ㄺ등 초성에 없는 글자를 첫음절에서
조합하는 기능을 제공하지 않았다. 그러나 MS IME와 호환성을 높이기
위해서 이 기능을 추가하였으므로, 이 기능을 켜고 끌 수 있도록 옵션으로
처리한다.
관련 유닛테스트 코드도 추가한다.
---
Upstream-Status: Pending
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);
--
1.9.1