Skip to content

Commit 61ddab8

Browse files
authored
Merge pull request #9508 from keymanapp/feat/resources/7042-add-pcm-epic-ldml
feat(resources): add pcm keyboard 🙀
2 parents 462802a + c3a4183 commit 61ddab8

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

core/tests/unit/ldml/keyboards/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tests_from_cldr = [
1111
'ja-Latn',
1212
'pt-t-k0-abnt2',
1313
'fr-t-k0-azerty',
14+
'pcm',
1415
]
1516

1617
tests_without_testdata = [

core/tests/unit/ldml/ldml_test_source.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,16 @@ LdmlTestSource::parse_source_string(std::string const &s) {
109109
if (*p == '\\') {
110110
p++;
111111
km_kbp_usv v;
112+
bool had_open_curly = false;
112113
assert(p != s.end());
113114
if (*p == 'u' || *p == 'U') {
114115
// Unicode value
115116
p++;
117+
if (*p == '{') {
118+
p++;
119+
assert(p != s.end());
120+
had_open_curly = true;
121+
}
116122
size_t n;
117123
std::string s1 = s.substr(p - s.begin(), 8);
118124
v = std::stoul(s1, &n, 16);
@@ -125,6 +131,12 @@ LdmlTestSource::parse_source_string(std::string const &s) {
125131
t += km_kbp_cp(Uni_UTF32ToSurrogate1(v));
126132
t += km_kbp_cp(Uni_UTF32ToSurrogate2(v));
127133
}
134+
if (had_open_curly) {
135+
p++;
136+
// close what you opened
137+
assert(*p == '}'); // close curly
138+
assert(p != s.end());
139+
}
128140
} else if (*p == 'd') {
129141
// Deadkey
130142
// TODO, not yet supported
@@ -146,10 +158,16 @@ LdmlTestSource::parse_u8_source_string(std::string const &u8s) {
146158
if (*p == '\\') {
147159
p++;
148160
km_kbp_usv v;
161+
bool had_open_curly = false;
149162
assert(p != s.end());
150163
if (*p == 'u' || *p == 'U') {
151164
// Unicode value
152165
p++;
166+
if (*p == '{') {
167+
p++;
168+
assert(p != s.end());
169+
had_open_curly = true;
170+
}
153171
size_t n;
154172
std::u16string s1 = s.substr(p - s.begin(), 8);
155173
// TODO-LDML: convert back first?
@@ -164,6 +182,12 @@ LdmlTestSource::parse_u8_source_string(std::string const &u8s) {
164182
t += km_kbp_cp(Uni_UTF32ToSurrogate1(v));
165183
t += km_kbp_cp(Uni_UTF32ToSurrogate2(v));
166184
}
185+
if (had_open_curly) {
186+
p++;
187+
// close what you opened
188+
assert(*p == '}'); // close curly
189+
assert(p != s.end());
190+
}
167191
} else if (*p == 'd') {
168192
// Deadkey
169193
// TODO, not yet supported
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE keyboard SYSTEM '../dtd/ldmlKeyboard.dtd'>
3+
<keyboard locale="pcm" conformsTo="techpreview">
4+
<version number="1.0.0" />
5+
<names>
6+
<name value="Nigerian Pidgin" />
7+
<name value="Naijíriá Píjin" />
8+
</names>
9+
<settings fallback="omit" />
10+
<keys>
11+
<import base="cldr" path="techpreview/keys-Zyyy-punctuation.xml" />
12+
<import base="cldr" path="techpreview/keys-Zyyy-currency.xml" />
13+
<key id="grave" to="\u{300}" />
14+
<key id="acute" to="\u{301}" />
15+
16+
<!-- accented vowels -->
17+
<key id="odot" to="" />
18+
<key id="Odot" to="" />
19+
<key id="edot" to="" />
20+
<key id="Edot" to="" />
21+
22+
<!-- currency -->
23+
<key id="naira" to="" />
24+
</keys>
25+
26+
<layers form="iso">
27+
<layer modifier="none">
28+
<row keys="grave 1 2 3 4 5 6 7 8 9 0 hyphen equal" />
29+
<row keys="acute w e r t y u i o p open-square close-square" />
30+
<row keys="a s d f g h j k l odot edot slash" />
31+
<row keys="slash z c v b n m comma period semi-colon apos" />
32+
<row keys="space" />
33+
</layer>
34+
35+
<layer modifier="shift">
36+
<row keys="grave bang at hash dollar naira percent amp asterisk open-paren close-paren underscore plus" />
37+
<row keys="acute W E R T Y U I O P open-curly close-curly" />
38+
<row keys="A S D F G H J K L Odot Edot" />
39+
<row keys="question Z C V B N M open-angle close-angle colon double-quote" />
40+
<row keys="space" />
41+
</layer>
42+
43+
<layer modifier="caps">
44+
<row keys="grave 1 2 3 4 5 6 7 8 9 0 hyphen equal" />
45+
<row keys="acute W E R T Y U I O P open-square close-square" />
46+
<row keys="A S D F G H J K L Odot Edot slash" />
47+
<row keys="slash Z C V B N M comma period semi-colon apos" />
48+
<row keys="space" />
49+
</layer>
50+
51+
</layers>
52+
53+
<transforms type="simple">
54+
<transformGroup>
55+
<transform from="''" to="\u{323}" /> <!-- Quick way to add dot below -->
56+
</transformGroup>
57+
</transforms>
58+
</keyboard>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE keyboardTest SYSTEM "../dtd/ldmlKeyboardTest.dtd">
3+
<keyboardTest conformsTo="techpreview">
4+
<info keyboard="pcm.xml" author="Team Keyboard" name="pcm-test" />
5+
<repertoire name="simple-repertoire" chars="[a b c d e ọ Ọ ẹ Ẹ ₦]" type="simple" />
6+
<tests name="key-tests">
7+
<test name="abc-test">
8+
<startContext to="abc" />
9+
<keystroke key="d" />
10+
<check result="abcd" />
11+
</test>
12+
<test name="dot-below-test">
13+
<startContext to="" />
14+
<keystroke key="e" />
15+
<keystroke key="apos" />
16+
<check result="e'" />
17+
<keystroke key="apos" />
18+
<check result="e\u{323}" />
19+
</test>
20+
</tests>
21+
</keyboardTest>

0 commit comments

Comments
 (0)