Added enough features to do basic broad RP transcritptions

This commit is contained in:
Yuki Joou 2023-11-12 01:14:44 +01:00
parent 9514c8d53e
commit d866cca9cb

View file

@ -14,6 +14,9 @@ std::optional<std::string> getIPAForSIL(std::string baseCharacter,
{ {
// TODO: Use a proper data structure, like a hash map // TODO: Use a proper data structure, like a hash map
// Even better: load that data off of a file! // Even better: load that data off of a file!
// TODO: Add more characters! This is only enough for narrow RP
// transcriptions...
if (baseCharacter == "s") { if (baseCharacter == "s") {
if (silModifier == FcitxKey_equal) return "ʃ"; if (silModifier == FcitxKey_equal) return "ʃ";
} }
@ -42,6 +45,16 @@ std::optional<std::string> getIPAForSIL(std::string baseCharacter,
if (silModifier == FcitxKey_equal) return "ə"; if (silModifier == FcitxKey_equal) return "ə";
} }
if (baseCharacter == "a") {
if (silModifier == FcitxKey_less) return "æ";
if (silModifier == FcitxKey_equal) return "ɑ";
}
if (baseCharacter == "o") {
if (silModifier == FcitxKey_less) return "ɔ";
if (silModifier == FcitxKey_equal) return "ɒ";
}
return {}; return {};
} }
@ -53,6 +66,14 @@ bool isSILModifier(fcitx::KeySym key)
void SILState::handleAlphaKey(fcitx::Key key) void SILState::handleAlphaKey(fcitx::Key key)
{ {
// TODO: Don't make this a special case, have a better system for handling
// this!
if (key.check(FcitxKey_colon)) {
m_buffer.type("ː");
m_lastKey.reset();
return;
}
if (!isSILModifier(key.sym()) || !m_lastKey.has_value()) { if (!isSILModifier(key.sym()) || !m_lastKey.has_value()) {
m_lastKey = key.toString(); m_lastKey = key.toString();
m_buffer.type(key.sym()); m_buffer.type(key.sym());