mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-22 01:34:22 +00:00
Add functional dubeolsik standard layout
This commit is contained in:
parent
41c8563116
commit
603a5f2000
7 changed files with 280 additions and 2 deletions
|
@ -49,6 +49,69 @@ class HangulCombiner : Combiner {
|
|||
return createEventChainFromSequence(text, event)
|
||||
} else {
|
||||
when(jamo) {
|
||||
is HangulJamo.Consonant -> {
|
||||
val initial = jamo.toInitial()
|
||||
val final = jamo.toFinal()
|
||||
if(currentSyllable.final == null) {
|
||||
if(currentSyllable.initial != null) {
|
||||
val combination = COMBINATION_TABLE_DUBEOLSIK[currentSyllable.initial.codePoint to (initial?.codePoint ?: -1)]
|
||||
if(combination != null) {
|
||||
history += currentSyllable.copy(initial = HangulJamo.Initial(combination))
|
||||
} else {
|
||||
history += currentSyllable.copy(final = final)
|
||||
}
|
||||
} else {
|
||||
history += currentSyllable.copy(final = final)
|
||||
}
|
||||
} else {
|
||||
val pair = currentSyllable.final.codePoint to (final?.codePoint ?: -1)
|
||||
val combination = COMBINATION_TABLE_DUBEOLSIK[pair]
|
||||
if(combination != null) {
|
||||
history += currentSyllable.copy(final = HangulJamo.Final(combination, combinationPair = pair))
|
||||
} else {
|
||||
composingWord.append(currentSyllable.string)
|
||||
history.clear()
|
||||
history += HangulSyllable(initial = initial)
|
||||
}
|
||||
}
|
||||
}
|
||||
is HangulJamo.Vowel -> {
|
||||
val medial = jamo.toMedial()
|
||||
if(currentSyllable.final == null) {
|
||||
if(currentSyllable.medial != null) {
|
||||
val combination = COMBINATION_TABLE_DUBEOLSIK[currentSyllable.medial.codePoint to (medial?.codePoint ?: -1)]
|
||||
if(combination != null) {
|
||||
history += currentSyllable.copy(medial = HangulJamo.Medial(combination))
|
||||
} else {
|
||||
composingWord.append(currentSyllable.string)
|
||||
history.clear()
|
||||
history += HangulSyllable(medial = medial)
|
||||
}
|
||||
} else {
|
||||
history += currentSyllable.copy(medial = medial)
|
||||
}
|
||||
} else if(currentSyllable.final.combinationPair != null) {
|
||||
val pair = currentSyllable.final.combinationPair
|
||||
|
||||
history.removeAt(history.lastIndex)
|
||||
val final = HangulJamo.Final(pair.first)
|
||||
history += currentSyllable.copy(final = final)
|
||||
composingWord.append(syllable?.string ?: "")
|
||||
history.clear()
|
||||
val initial = HangulJamo.Final(pair.second).toConsonant()?.toInitial()
|
||||
val newSyllable = HangulSyllable(initial = initial)
|
||||
history += newSyllable
|
||||
history += newSyllable.copy(medial = medial)
|
||||
} else {
|
||||
history.removeAt(history.lastIndex)
|
||||
composingWord.append(syllable?.string ?: "")
|
||||
history.clear()
|
||||
val initial = currentSyllable.final.toConsonant()?.toInitial()
|
||||
val newSyllable = HangulSyllable(initial = initial)
|
||||
history += newSyllable
|
||||
history += newSyllable.copy(medial = medial)
|
||||
}
|
||||
}
|
||||
is HangulJamo.Initial -> {
|
||||
if(currentSyllable.initial != null) {
|
||||
val combination = COMBINATION_TABLE_SEBEOLSIK[currentSyllable.initial.codePoint to jamo.codePoint]
|
||||
|
@ -130,7 +193,7 @@ class HangulCombiner : Combiner {
|
|||
return Vowel(codePoint.toInt())
|
||||
}
|
||||
}
|
||||
data class Final(override val codePoint: Int) : HangulJamo() {
|
||||
data class Final(override val codePoint: Int, val combinationPair: Pair<Int, Int>? = null) : HangulJamo() {
|
||||
override val modern: Boolean get() = codePoint in 0x11a8 .. 0x11c2
|
||||
val ordinal: Int get() = codePoint - 0x11a7
|
||||
fun toConsonant(): Consonant? {
|
||||
|
@ -170,6 +233,8 @@ class HangulCombiner : Combiner {
|
|||
const val CONVERT_FINALS = "ᆨᆩᆪᆫᆬᆭᆮ\u0000ᆯᆰᆱᆲᆳᆴᆵᆶᆷᆸ\u0000ᆹᆺᆻᆼᆽ\u0000ᆾᆿᇀᇁᇂ"
|
||||
fun of(codePoint: Int): HangulJamo {
|
||||
return when(codePoint) {
|
||||
in 0x3131 .. 0x314e -> Consonant(codePoint)
|
||||
in 0x314f .. 0x3163 -> Vowel(codePoint)
|
||||
in 0x1100 .. 0x115f -> Initial(codePoint)
|
||||
in 0x1160 .. 0x11a7 -> Medial(codePoint)
|
||||
in 0x11a8 .. 0x11ff -> Final(codePoint)
|
||||
|
|
26
app/src/main/res/xml/kbd_korean_dubeolsik_standard.xml
Normal file
26
app/src/main/res/xml/kbd_korean_dubeolsik_standard.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2008, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<Keyboard
|
||||
xmlns:latin="http://schemas.android.com/apk/res-auto"
|
||||
>
|
||||
<include
|
||||
latin:keyboardLayout="@xml/rows_korean_dubeolsik_standard" />
|
||||
</Keyboard>
|
|
@ -24,7 +24,7 @@
|
|||
latin:supportedScript="hangul" />
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:elementKeyboard="@xml/kbd_korean_dubeolsik_standard"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
|
|
56
app/src/main/res/xml/rowkeys_korean_dubeolsik_standard_1.xml
Normal file
56
app/src/main/res/xml/rowkeys_korean_dubeolsik_standard_1.xml
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2012, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<merge xmlns:latin="http://schemas.android.com/apk/res-auto">
|
||||
<Key
|
||||
latin:keySpec="ㅂ"
|
||||
latin:keyHintLabel="ㅃ"
|
||||
latin:additionalMoreKeys="ㅃ" />
|
||||
<Key
|
||||
latin:keySpec="ㅈ"
|
||||
latin:keyHintLabel="ㅉ"
|
||||
latin:additionalMoreKeys="ㅉ" />
|
||||
<Key
|
||||
latin:keySpec="ㄷ"
|
||||
latin:keyHintLabel="ㄸ"
|
||||
latin:additionalMoreKeys="ㄸ" />
|
||||
<Key
|
||||
latin:keySpec="ㄱ"
|
||||
latin:keyHintLabel="ㄲ"
|
||||
latin:additionalMoreKeys="ㄲ" />
|
||||
<Key
|
||||
latin:keySpec="ㅅ"
|
||||
latin:keyHintLabel="ㅆ"
|
||||
latin:additionalMoreKeys="ㅆ" />
|
||||
<Key
|
||||
latin:keySpec="ㅛ" />
|
||||
<Key
|
||||
latin:keySpec="ㅕ" />
|
||||
<Key
|
||||
latin:keySpec="ㅑ" />
|
||||
<Key
|
||||
latin:keySpec="ㅐ"
|
||||
latin:keyHintLabel="ㅒ"
|
||||
latin:additionalMoreKeys="ㅒ" />
|
||||
<Key
|
||||
latin:keySpec="ㅔ"
|
||||
latin:keyHintLabel="ㅖ"
|
||||
latin:additionalMoreKeys="ㅖ" />
|
||||
</merge>
|
40
app/src/main/res/xml/rowkeys_korean_dubeolsik_standard_2.xml
Normal file
40
app/src/main/res/xml/rowkeys_korean_dubeolsik_standard_2.xml
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2012, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<merge xmlns:latin="http://schemas.android.com/apk/res-auto">
|
||||
<Key
|
||||
latin:keySpec="ㅁ" />
|
||||
<Key
|
||||
latin:keySpec="ㄴ" />
|
||||
<Key
|
||||
latin:keySpec="ㅇ" />
|
||||
<Key
|
||||
latin:keySpec="ㄹ" />
|
||||
<Key
|
||||
latin:keySpec="ㅎ" />
|
||||
<Key
|
||||
latin:keySpec="ㅗ" />
|
||||
<Key
|
||||
latin:keySpec="ㅓ" />
|
||||
<Key
|
||||
latin:keySpec="ㅏ" />
|
||||
<Key
|
||||
latin:keySpec="ㅣ" />
|
||||
</merge>
|
36
app/src/main/res/xml/rowkeys_korean_dubeolsik_standard_3.xml
Normal file
36
app/src/main/res/xml/rowkeys_korean_dubeolsik_standard_3.xml
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2012, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<merge xmlns:latin="http://schemas.android.com/apk/res-auto">
|
||||
<Key
|
||||
latin:keySpec="ㅋ" />
|
||||
<Key
|
||||
latin:keySpec="ㅌ" />
|
||||
<Key
|
||||
latin:keySpec="ㅊ" />
|
||||
<Key
|
||||
latin:keySpec="ㅍ" />
|
||||
<Key
|
||||
latin:keySpec="ㅠ" />
|
||||
<Key
|
||||
latin:keySpec="ㅜ" />
|
||||
<Key
|
||||
latin:keySpec="ㅡ" />
|
||||
</merge>
|
55
app/src/main/res/xml/rows_korean_dubeolsik_standard.xml
Normal file
55
app/src/main/res/xml/rows_korean_dubeolsik_standard.xml
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2010, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<merge
|
||||
xmlns:latin="http://schemas.android.com/apk/res-auto"
|
||||
>
|
||||
<include
|
||||
latin:keyboardLayout="@xml/key_styles_common" />
|
||||
<Row
|
||||
latin:keyWidth="10%p"
|
||||
>
|
||||
<include
|
||||
latin:keyboardLayout="@xml/rowkeys_korean_dubeolsik_standard_1" />
|
||||
</Row>
|
||||
<Row
|
||||
latin:keyWidth="10%p"
|
||||
>
|
||||
<include
|
||||
latin:keyboardLayout="@xml/rowkeys_korean_dubeolsik_standard_2"
|
||||
latin:keyXPos="5%p" />
|
||||
</Row>
|
||||
<Row
|
||||
latin:keyWidth="10%p"
|
||||
>
|
||||
<Key
|
||||
latin:keyStyle="shiftKeyStyle"
|
||||
latin:keyWidth="15%p"
|
||||
latin:visualInsetsRight="1%p" />
|
||||
<include
|
||||
latin:keyboardLayout="@xml/rowkeys_korean_dubeolsik_standard_3" />
|
||||
<Key
|
||||
latin:keyStyle="deleteKeyStyle"
|
||||
latin:keyWidth="fillRight"
|
||||
latin:visualInsetsLeft="1%p" />
|
||||
</Row>
|
||||
<include
|
||||
latin:keyboardLayout="@xml/row_qwerty4" />
|
||||
</merge>
|
Loading…
Add table
Add a link
Reference in a new issue