Skip to content

Commit

Permalink
Merge pull request #9508 from keymanapp/feat/resources/7042-add-pcm-e…
Browse files Browse the repository at this point in the history
…pic-ldml

feat(resources): add pcm keyboard 🙀
  • Loading branch information
srl295 authored Aug 25, 2023
2 parents 462802a + c3a4183 commit 61ddab8
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/tests/unit/ldml/keyboards/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tests_from_cldr = [
'ja-Latn',
'pt-t-k0-abnt2',
'fr-t-k0-azerty',
'pcm',
]

tests_without_testdata = [
Expand Down
24 changes: 24 additions & 0 deletions core/tests/unit/ldml/ldml_test_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,16 @@ LdmlTestSource::parse_source_string(std::string const &s) {
if (*p == '\\') {
p++;
km_kbp_usv v;
bool had_open_curly = false;
assert(p != s.end());
if (*p == 'u' || *p == 'U') {
// Unicode value
p++;
if (*p == '{') {
p++;
assert(p != s.end());
had_open_curly = true;
}
size_t n;
std::string s1 = s.substr(p - s.begin(), 8);
v = std::stoul(s1, &n, 16);
Expand All @@ -125,6 +131,12 @@ LdmlTestSource::parse_source_string(std::string const &s) {
t += km_kbp_cp(Uni_UTF32ToSurrogate1(v));
t += km_kbp_cp(Uni_UTF32ToSurrogate2(v));
}
if (had_open_curly) {
p++;
// close what you opened
assert(*p == '}'); // close curly
assert(p != s.end());
}
} else if (*p == 'd') {
// Deadkey
// TODO, not yet supported
Expand All @@ -146,10 +158,16 @@ LdmlTestSource::parse_u8_source_string(std::string const &u8s) {
if (*p == '\\') {
p++;
km_kbp_usv v;
bool had_open_curly = false;
assert(p != s.end());
if (*p == 'u' || *p == 'U') {
// Unicode value
p++;
if (*p == '{') {
p++;
assert(p != s.end());
had_open_curly = true;
}
size_t n;
std::u16string s1 = s.substr(p - s.begin(), 8);
// TODO-LDML: convert back first?
Expand All @@ -164,6 +182,12 @@ LdmlTestSource::parse_u8_source_string(std::string const &u8s) {
t += km_kbp_cp(Uni_UTF32ToSurrogate1(v));
t += km_kbp_cp(Uni_UTF32ToSurrogate2(v));
}
if (had_open_curly) {
p++;
// close what you opened
assert(*p == '}'); // close curly
assert(p != s.end());
}
} else if (*p == 'd') {
// Deadkey
// TODO, not yet supported
Expand Down
58 changes: 58 additions & 0 deletions resources/standards-data/ldml-keyboards/techpreview/3.0/pcm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM '../dtd/ldmlKeyboard.dtd'>
<keyboard locale="pcm" conformsTo="techpreview">
<version number="1.0.0" />
<names>
<name value="Nigerian Pidgin" />
<name value="Naijíriá Píjin" />
</names>
<settings fallback="omit" />
<keys>
<import base="cldr" path="techpreview/keys-Zyyy-punctuation.xml" />
<import base="cldr" path="techpreview/keys-Zyyy-currency.xml" />
<key id="grave" to="\u{300}" />
<key id="acute" to="\u{301}" />

<!-- accented vowels -->
<key id="odot" to="" />
<key id="Odot" to="" />
<key id="edot" to="" />
<key id="Edot" to="" />

<!-- currency -->
<key id="naira" to="" />
</keys>

<layers form="iso">
<layer modifier="none">
<row keys="grave 1 2 3 4 5 6 7 8 9 0 hyphen equal" />
<row keys="acute w e r t y u i o p open-square close-square" />
<row keys="a s d f g h j k l odot edot slash" />
<row keys="slash z c v b n m comma period semi-colon apos" />
<row keys="space" />
</layer>

<layer modifier="shift">
<row keys="grave bang at hash dollar naira percent amp asterisk open-paren close-paren underscore plus" />
<row keys="acute W E R T Y U I O P open-curly close-curly" />
<row keys="A S D F G H J K L Odot Edot" />
<row keys="question Z C V B N M open-angle close-angle colon double-quote" />
<row keys="space" />
</layer>

<layer modifier="caps">
<row keys="grave 1 2 3 4 5 6 7 8 9 0 hyphen equal" />
<row keys="acute W E R T Y U I O P open-square close-square" />
<row keys="A S D F G H J K L Odot Edot slash" />
<row keys="slash Z C V B N M comma period semi-colon apos" />
<row keys="space" />
</layer>

</layers>

<transforms type="simple">
<transformGroup>
<transform from="''" to="\u{323}" /> <!-- Quick way to add dot below -->
</transformGroup>
</transforms>
</keyboard>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboardTest SYSTEM "../dtd/ldmlKeyboardTest.dtd">
<keyboardTest conformsTo="techpreview">
<info keyboard="pcm.xml" author="Team Keyboard" name="pcm-test" />
<repertoire name="simple-repertoire" chars="[a b c d e ọ Ọ ẹ Ẹ ₦]" type="simple" />
<tests name="key-tests">
<test name="abc-test">
<startContext to="abc" />
<keystroke key="d" />
<check result="abcd" />
</test>
<test name="dot-below-test">
<startContext to="" />
<keystroke key="e" />
<keystroke key="apos" />
<check result="e'" />
<keystroke key="apos" />
<check result="e\u{323}" />
</test>
</tests>
</keyboardTest>

0 comments on commit 61ddab8

Please sign in to comment.