diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..5cb45537d --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: Chromium +SortIncludes: false diff --git a/.github/workflows/commit-ci.yml b/.github/workflows/commit-ci.yml index d6f45d8fc..9753ff4de 100644 --- a/.github/workflows/commit-ci.yml +++ b/.github/workflows/commit-ci.yml @@ -9,11 +9,24 @@ on: pull_request: jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout last commit + uses: actions/checkout@v3 + - name: Install clang-format + run: sudo apt install -y clang-format + - name: Lint + run: find src -name '*.cc' -o -name '*.h' | xargs clang-format -Werror --dry-run || { echo Please lint your code by '"'"find src -name '*.cc' -o -name '*.h' | xargs clang-format -i"'"'.; false; } + linux: + needs: lint uses: ./.github/workflows/linux-build.yml macos: + needs: lint uses: ./.github/workflows/macos-build.yml windows: + needs: lint uses: ./.github/workflows/windows-build.yml diff --git a/src/rime/algo/algebra.cc b/src/rime/algo/algebra.cc index b07629cfa..9983e6ba0 100644 --- a/src/rime/algo/algebra.cc +++ b/src/rime/algo/algebra.cc @@ -36,8 +36,7 @@ void Script::Merge(const string& s, auto e = std::find(m.begin(), m.end(), x); if (e == m.end()) { m.push_back(y); - } - else { + } else { SpellingProperties& zz(e->properties); if (yy.type < zz.type) zz.type = yy.type; @@ -53,11 +52,9 @@ void Script::Dump(const string& file_name) const { for (const value_type& v : *this) { bool first = true; for (const Spelling& s : v.second) { - out << (first ? v.first : "") << '\t' - << s.str << '\t' - << "-ac?!"[s.properties.type] << '\t' - << s.properties.credibility << '\t' - << s.properties.tips << std::endl; + out << (first ? v.first : "") << '\t' << s.str << '\t' + << "-ac?!"[s.properties.type] << '\t' << s.properties.credibility + << '\t' << s.properties.tips << std::endl; first = false; } } @@ -65,7 +62,8 @@ void Script::Dump(const string& file_name) const { } bool Projection::Load(an settings) { - if (!settings) return false; + if (!settings) + return false; calculation_.clear(); Calculus calc; bool success = true; @@ -76,12 +74,11 @@ bool Projection::Load(an settings) { success = false; break; } - const string &formula(v->str()); + const string& formula(v->str()); an x; try { x.reset(calc.Parse(formula)); - } - catch (boost::regex_error& e) { + } catch (boost::regex_error& e) { LOG(ERROR) << "Error parsing formula '" << formula << "': " << e.what(); } if (!x) { @@ -107,8 +104,7 @@ bool Projection::Apply(string* value) { try { if (x->Apply(&s)) modified = true; - } - catch (std::runtime_error& e) { + } catch (std::runtime_error& e) { LOG(ERROR) << "Error applying calculation: " << e.what(); return false; } @@ -132,8 +128,7 @@ bool Projection::Apply(Script* value) { bool applied = false; try { applied = x->Apply(&s); - } - catch (std::runtime_error& e) { + } catch (std::runtime_error& e) { LOG(ERROR) << "Error applying calculation: " << e.what(); return false; } @@ -145,8 +140,7 @@ bool Projection::Apply(Script* value) { if (x->addition() && !s.str.empty()) { temp.Merge(s.str, s.properties, v.second); } - } - else { + } else { temp.Merge(v.first, SpellingProperties(), v.second); } } diff --git a/src/rime/algo/algebra.h b/src/rime/algo/algebra.h index 7cf087243..70326ae51 100644 --- a/src/rime/algo/algebra.h +++ b/src/rime/algo/algebra.h @@ -33,6 +33,7 @@ class Projection { RIME_API bool Apply(string* value); // {z, y, x} -> {a, b, c, d} RIME_API bool Apply(Script* value); + protected: vector> calculation_; }; diff --git a/src/rime/algo/calculus.cc b/src/rime/algo/calculus.cc index 96fb80c5d..38b0bcf70 100644 --- a/src/rime/algo/calculus.cc +++ b/src/rime/algo/calculus.cc @@ -11,8 +11,8 @@ namespace rime { -const double kAbbreviationPenalty = -0.6931471805599453; // log(0.5) -const double kFuzzySpellingPenalty = -0.6931471805599453; // log(0.5) +const double kAbbreviationPenalty = -0.6931471805599453; // log(0.5) +const double kFuzzySpellingPenalty = -0.6931471805599453; // log(0.5) Calculus::Calculus() { Register("xlit", &Transliteration::Parse); @@ -23,8 +23,7 @@ Calculus::Calculus() { Register("abbrev", &Abbreviation::Parse); } -void Calculus::Register(const string& token, - Calculation::Factory* factory) { +void Calculus::Register(const string& token, Calculation::Factory* factory) { factories_[token] = factory; } @@ -55,8 +54,7 @@ Calculation* Transliteration::Parse(const vector& args) { const char* pr = right.c_str(); uint32_t cl, cr; map char_map; - while ((cl = utf8::unchecked::next(pl)), - (cr = utf8::unchecked::next(pr)), + while ((cl = utf8::unchecked::next(pl)), (cr = utf8::unchecked::next(pr)), cl && cr) { char_map[cl] = cr; } @@ -113,8 +111,7 @@ Calculation* Transformation::Parse(const vector& args) { bool Transformation::Apply(Spelling* spelling) { if (!spelling || spelling->str.empty()) return false; - string result = boost::regex_replace(spelling->str, - pattern_, replacement_); + string result = boost::regex_replace(spelling->str, pattern_, replacement_); if (result == spelling->str) return false; spelling->str.swap(result); diff --git a/src/rime/algo/calculus.h b/src/rime/algo/calculus.h index 92b4bc5bf..1bd540db7 100644 --- a/src/rime/algo/calculus.h +++ b/src/rime/algo/calculus.h @@ -18,7 +18,7 @@ namespace rime { class Calculation { public: - using Factory = Calculation* (const vector& args); + using Factory = Calculation*(const vector& args); Calculation() = default; virtual ~Calculation() = default; diff --git a/src/rime/algo/dynamics.h b/src/rime/algo/dynamics.h index dbd0cdaaa..3db4286af 100644 --- a/src/rime/algo/dynamics.h +++ b/src/rime/algo/dynamics.h @@ -10,9 +10,9 @@ inline double formula_d(double d, double t, double da, double ta) { inline double formula_p(double s, double u, double t, double d) { const double kM = 1 / (1 - exp(-0.005)); double m = s - (s - u) * pow((1 - exp(-t / 10000)), 10); - return (d < 20) ? m + (0.5 - m) * (d / kM) : - m + (1 - m) * (pow(4, (d / kM)) - 1) / 3; + return (d < 20) ? m + (0.5 - m) * (d / kM) + : m + (1 - m) * (pow(4, (d / kM)) - 1) / 3; } -} -} +} // namespace algo +} // namespace rime diff --git a/src/rime/algo/encoder.cc b/src/rime/algo/encoder.cc index 15064a927..8f117a96d 100644 --- a/src/rime/algo/encoder.cc +++ b/src/rime/algo/encoder.cc @@ -19,14 +19,12 @@ string RawCode::ToString() const { return strings::join(*this, " "); } -void RawCode::FromString(const string &code_str) { - *dynamic_cast *>(this) = - strings::split(code_str, " "); +void RawCode::FromString(const string& code_str) { + *dynamic_cast*>(this) = strings::split(code_str, " "); } TableEncoder::TableEncoder(PhraseCollector* collector) - : Encoder(collector), loaded_(false), max_phrase_length_(0) { -} + : Encoder(collector), loaded_(false), max_phrase_length_(0) {} /* # sample encoder configuration (from cangjie5.dict.yaml) @@ -50,7 +48,8 @@ bool TableEncoder::LoadSettings(Config* config) { exclude_patterns_.clear(); tail_anchor_.clear(); - if (!config) return false; + if (!config) + return false; if (auto rules = config->GetList("encoder/rules")) { for (auto it = rules->begin(); it != rules->end(); ++it) { @@ -72,10 +71,8 @@ bool TableEncoder::LoadSettings(Config* config) { if (max_phrase_length_ < length) { max_phrase_length_ = length; } - } - else if (auto range = As(rule->Get("length_in_range"))) { - if (range->size() != 2 || - !range->GetValueAt(0) || + } else if (auto range = As(rule->Get("length_in_range"))) { + if (range->size() != 2 || !range->GetValueAt(0) || !range->GetValueAt(1) || !range->GetValueAt(0)->GetInt(&r.min_word_length) || !range->GetValueAt(1)->GetInt(&r.max_word_length) || @@ -113,7 +110,7 @@ bool TableEncoder::ParseFormula(const string& formula, LOG(ERROR) << "bad formula: '%s'" << formula; return false; } - for (auto it = formula.cbegin(), end = formula.cend(); it != end; ) { + for (auto it = formula.cbegin(), end = formula.cend(); it != end;) { CodeCoords c; if (*it < 'A' || *it > 'Z') { LOG(ERROR) << "invalid character index in formula: '%s'" << formula; @@ -161,8 +158,7 @@ bool TableEncoder::Encode(const RawCode& code, string* result) { if (c.char_index < 0) { continue; // 'abc def' ~ 'Xa' } - if (current.char_index < 0 && - c.char_index < encoded.char_index) { + if (current.char_index < 0 && c.char_index < encoded.char_index) { continue; // 'abc def' ~ '(AaBa)Ya' // 'abc def' ~ '(AaBa)Aa' is OK } @@ -170,8 +166,8 @@ bool TableEncoder::Encode(const RawCode& code, string* result) { if (c.char_index == encoded.char_index) { start_index = encoded.code_index + 1; } - c.code_index = CalculateCodeIndex(code[c.char_index], c.code_index, - start_index); + c.code_index = + CalculateCodeIndex(code[c.char_index], c.code_index, start_index); if (c.code_index >= static_cast(code[c.char_index].length())) { continue; // 'abc def' ~ 'Ad' } @@ -207,10 +203,9 @@ bool TableEncoder::Encode(const RawCode& code, string* result) { // beyond `start` is used to locate the encoding character at index -1. // returns string index in `code` for the character at virtual `index`. // may return a negative number if `index` does not exist in `code`. -int TableEncoder::CalculateCodeIndex(const string& code, int index, - int start) { - DLOG(INFO) << "code = " << code - << ", index = " << index << ", start = " << start; +int TableEncoder::CalculateCodeIndex(const string& code, int index, int start) { + DLOG(INFO) << "code = " << code << ", index = " << index + << ", start = " << start; // tail_anchor = '|' const int n = static_cast(code.length()); int k = 0; @@ -224,24 +219,20 @@ int TableEncoder::CalculateCodeIndex(const string& code, int index, k = static_cast(tail) - 1; } while (++index < 0) { - while (--k >= 0 && - tail_anchor_.find(code[k]) != string::npos) { + while (--k >= 0 && tail_anchor_.find(code[k]) != string::npos) { } } - } - else { + } else { // 'ab|cd|ef|g' ~ '(AaAb)Ac' -> 'abc'; index = 2 while (index-- > 0) { - while (++k < n && - tail_anchor_.find(code[k]) != string::npos) { + while (++k < n && tail_anchor_.find(code[k]) != string::npos) { } } } return k; } -bool TableEncoder::EncodePhrase(const string& phrase, - const string& value) { +bool TableEncoder::EncodePhrase(const string& phrase, const string& value) { size_t phrase_length = utf8::unchecked::distance( phrase.c_str(), phrase.c_str() + phrase.length()); if (static_cast(phrase_length) > max_phrase_length_) @@ -267,8 +258,7 @@ bool TableEncoder::DfsEncode(const string& phrase, << "[" << code->ToString() << "] -> [" << encoded << "]"; collector_->CreateEntry(phrase, encoded, value); return true; - } - else { + } else { DLOG(WARNING) << "failed to encode '" << phrase << "': " << "[" << code->ToString() << "]"; return false; @@ -298,12 +288,9 @@ bool TableEncoder::DfsEncode(const string& phrase, return ret; } -ScriptEncoder::ScriptEncoder(PhraseCollector* collector) - : Encoder(collector) { -} +ScriptEncoder::ScriptEncoder(PhraseCollector* collector) : Encoder(collector) {} -bool ScriptEncoder::EncodePhrase(const string& phrase, - const string& value) { +bool ScriptEncoder::EncodePhrase(const string& phrase, const string& value) { size_t phrase_length = utf8::unchecked::distance( phrase.c_str(), phrase.c_str() + phrase.length()); if (static_cast(phrase_length) > kMaxPhraseLength) diff --git a/src/rime/algo/encoder.h b/src/rime/algo/encoder.h index ecbe76ef0..0a50c6275 100644 --- a/src/rime/algo/encoder.h +++ b/src/rime/algo/encoder.h @@ -16,7 +16,7 @@ namespace rime { class RawCode : public vector { public: RIME_API string ToString() const; - RIME_API void FromString(const string &code_str); + RIME_API void FromString(const string& code_str); }; class PhraseCollector { @@ -28,8 +28,7 @@ class PhraseCollector { const string& code_str, const string& value) = 0; // return a list of alternative code for the given word - virtual bool TranslateWord(const string& word, - vector* code) = 0; + virtual bool TranslateWord(const string& word, vector* code) = 0; }; class Config; @@ -39,12 +38,9 @@ class Encoder { Encoder(PhraseCollector* collector) : collector_(collector) {} virtual ~Encoder() = default; - virtual bool LoadSettings(Config* config) { - return false; - } + virtual bool LoadSettings(Config* config) { return false; } - virtual bool EncodePhrase(const string& phrase, - const string& value) = 0; + virtual bool EncodePhrase(const string& phrase, const string& value) = 0; void set_collector(PhraseCollector* collector) { collector_ = collector; } @@ -87,8 +83,11 @@ class TableEncoder : public Encoder { protected: bool ParseFormula(const string& formula, TableEncodingRule* rule); int CalculateCodeIndex(const string& code, int index, int start); - bool DfsEncode(const string& phrase, const string& value, - size_t start_pos, RawCode* code, int* limit); + bool DfsEncode(const string& phrase, + const string& value, + size_t start_pos, + RawCode* code, + int* limit); bool loaded_; // settings @@ -107,8 +106,11 @@ class ScriptEncoder : public Encoder { bool EncodePhrase(const string& phrase, const string& value); private: - bool DfsEncode(const string& phrase, const string& value, - size_t start_pos, RawCode* code, int* limit); + bool DfsEncode(const string& phrase, + const string& value, + size_t start_pos, + RawCode* code, + int* limit); }; } // namespace rime diff --git a/src/rime/algo/spelling.h b/src/rime/algo/spelling.h index bcc2028a0..cbba2105e 100644 --- a/src/rime/algo/spelling.h +++ b/src/rime/algo/spelling.h @@ -12,9 +12,14 @@ namespace rime { -enum SpellingType { kNormalSpelling, kFuzzySpelling, - kAbbreviation, kCompletion, kAmbiguousSpelling, - kInvalidSpelling }; +enum SpellingType { + kNormalSpelling, + kFuzzySpelling, + kAbbreviation, + kCompletion, + kAmbiguousSpelling, + kInvalidSpelling +}; struct SpellingProperties { SpellingType type = kNormalSpelling; @@ -30,8 +35,8 @@ struct Spelling { Spelling() = default; Spelling(const string& _str) : str(_str) {} - bool operator== (const Spelling& other) { return str == other.str; } - bool operator< (const Spelling& other) { return str < other.str; } + bool operator==(const Spelling& other) { return str == other.str; } + bool operator<(const Spelling& other) { return str < other.str; } }; } // namespace rime diff --git a/src/rime/algo/strings.cc b/src/rime/algo/strings.cc index 801e9e43c..a0ab82626 100644 --- a/src/rime/algo/strings.cc +++ b/src/rime/algo/strings.cc @@ -3,7 +3,9 @@ namespace rime { namespace strings { -vector split(const string& str, const string& delim, SplitBehavior behavior) { +vector split(const string& str, + const string& delim, + SplitBehavior behavior) { vector strings; size_t lastPos, pos; if (behavior == SplitBehavior::SkipEmpty) { @@ -16,22 +18,21 @@ vector split(const string& str, const string& delim, SplitBehavior behav while (std::string::npos != pos || std::string::npos != lastPos) { strings.emplace_back(str.substr(lastPos, pos - lastPos)); if (behavior == SplitBehavior::SkipEmpty) { - lastPos = str.find_first_not_of(delim, pos); + lastPos = str.find_first_not_of(delim, pos); } else { - if (pos == std::string::npos) { - break; - } - lastPos = pos + 1; + if (pos == std::string::npos) { + break; + } + lastPos = pos + 1; } - pos = str.find_first_of(delim, lastPos); - } - return strings; + pos = str.find_first_of(delim, lastPos); + } + return strings; }; vector split(const string& str, const string& delim) { - return split(str, delim, SplitBehavior::SkipEmpty); + return split(str, delim, SplitBehavior::SkipEmpty); }; -} // namespace strings -} // namespace rime - +} // namespace strings +} // namespace rime diff --git a/src/rime/algo/strings.h b/src/rime/algo/strings.h index ba4f262f7..2bd570f1c 100644 --- a/src/rime/algo/strings.h +++ b/src/rime/algo/strings.h @@ -9,35 +9,37 @@ namespace strings { enum class SplitBehavior { KeepEmpty, SkipEmpty }; -vector split(const string& str, const string& delim, SplitBehavior behavior); +vector split(const string& str, + const string& delim, + SplitBehavior behavior); vector split(const string& str, const string& delim); template -string join(Iter start, Iter end, T &&delim) { - string result; - if (start != end) { - result += (*start); - start++; - } - for (; start != end; start++) { - result += (delim); - result += (*start); - } - return result; +string join(Iter start, Iter end, T&& delim) { + string result; + if (start != end) { + result += (*start); + start++; + } + for (; start != end; start++) { + result += (delim); + result += (*start); + } + return result; } template -inline string join(C &&container, T &&delim) { - return join(std::begin(container), std::end(container), delim); +inline string join(C&& container, T&& delim) { + return join(std::begin(container), std::end(container), delim); } template -inline string join(std::initializer_list &&container, T &&delim) { - return join(std::begin(container), std::end(container), delim); +inline string join(std::initializer_list&& container, T&& delim) { + return join(std::begin(container), std::end(container), delim); } -} // namespace strings -} // namespace rime +} // namespace strings +} // namespace rime -#endif // RIME_STRINGS_H_ +#endif // RIME_STRINGS_H_ diff --git a/src/rime/algo/syllabifier.cc b/src/rime/algo/syllabifier.cc index 718d48d43..a729ad9d4 100644 --- a/src/rime/algo/syllabifier.cc +++ b/src/rime/algo/syllabifier.cc @@ -16,16 +16,15 @@ namespace rime { using namespace corrector; using Vertex = pair; -using VertexQueue = std::priority_queue, - std::greater>; +using VertexQueue = + std::priority_queue, std::greater>; -const double kCompletionPenalty = -0.6931471805599453; // log(0.5) -const double kCorrectionCredibility = -4.605170185988091; // log(0.01) +const double kCompletionPenalty = -0.6931471805599453; // log(0.5) +const double kCorrectionCredibility = -4.605170185988091; // log(0.01) -int Syllabifier::BuildSyllableGraph(const string &input, - Prism &prism, - SyllableGraph *graph) { +int Syllabifier::BuildSyllableGraph(const string& input, + Prism& prism, + SyllableGraph* graph) { if (input.empty()) return 0; @@ -42,8 +41,8 @@ int Syllabifier::BuildSyllableGraph(const string &input, if (graph->vertices.find(current_pos) == graph->vertices.end()) { graph->vertices.insert(vertex); // preferred spelling type comes first } else { -// graph->vertices[current_pos] = -// std::min(vertex.second, graph->vertices[current_pos]); + // graph->vertices[current_pos] = + // std::min(vertex.second, graph->vertices[current_pos]); continue; // discard worse spelling types } @@ -57,17 +56,16 @@ int Syllabifier::BuildSyllableGraph(const string &input, auto current_input = input.substr(current_pos); prism.CommonPrefixSearch(current_input, &matches); if (corrector_) { - for (auto &m : matches) { + for (auto& m : matches) { exact_match_syllables.insert(m.value); } Corrections corrections; corrector_->ToleranceSearch(prism, current_input, &corrections, 5); - for (const auto &m : corrections) { + for (const auto& m : corrections) { for (auto accessor = prism.QuerySpelling(m.first); - !accessor.exhausted(); - accessor.Next()) { + !accessor.exhausted(); accessor.Next()) { if (accessor.properties().type == kNormalSpelling) { - matches.push_back({ m.first, m.second.length }); + matches.push_back({m.first, m.second.length}); break; } } @@ -77,7 +75,8 @@ int Syllabifier::BuildSyllableGraph(const string &input, if (!matches.empty()) { auto& end_vertices(graph->edges[current_pos]); for (const auto& m : matches) { - if (m.length == 0) continue; + if (m.length == 0) + continue; size_t end_pos = current_pos + m.length; // consume trailing delimiters while (end_pos < input.length() && @@ -94,18 +93,15 @@ int Syllabifier::BuildSyllableGraph(const string &input, while (!accessor.exhausted()) { SyllableId syllable_id = accessor.syllable_id(); EdgeProperties props(accessor.properties()); - if (strict_spelling_ && - matches_input && + if (strict_spelling_ && matches_input && props.type != kNormalSpelling) { // disqualify fuzzy spelling or abbreviation as single word - } - else { + } else { props.end_pos = end_pos; // add a syllable with properties to the edge's // spelling-to-syllable map - if (corrector_ && - exact_match_syllables.find(m.value) == - exact_match_syllables.end()) { + if (corrector_ && exact_match_syllables.find(m.value) == + exact_match_syllables.end()) { props.is_correction = true; props.credibility = kCorrectionCredibility; } @@ -135,8 +131,8 @@ int Syllabifier::BuildSyllableGraph(const string &input, end_vertex_type = vertex.second; } queue.push(Vertex{end_pos, end_vertex_type}); - DLOG(INFO) << "added to syllable graph, edge: [" - << current_pos << ", " << end_pos << ")"; + DLOG(INFO) << "added to syllable graph, edge: [" << current_pos << ", " + << end_pos << ")"; } } } @@ -145,13 +141,13 @@ int Syllabifier::BuildSyllableGraph(const string &input, set good; good.insert(farthest); // fuzzy spellings are immune to invalidation by normal spellings - SpellingType last_type = (std::max)(graph->vertices[farthest], - kFuzzySpelling); + SpellingType last_type = + (std::max)(graph->vertices[farthest], kFuzzySpelling); for (int i = farthest - 1; i >= 0; --i) { if (graph->vertices.find(i) == graph->vertices.end()) continue; // remove stale edges - for (auto j = graph->edges[i].begin(); j != graph->edges[i].end(); ) { + for (auto j = graph->edges[i].begin(); j != graph->edges[i].end();) { if (good.find(j->first) == good.end()) { // not connected graph->edges[i].erase(j++); @@ -160,15 +156,14 @@ int Syllabifier::BuildSyllableGraph(const string &input, // remove disqualified syllables (eg. matching abbreviated spellings) // when there is a path of more favored type SpellingType edge_type = kInvalidSpelling; - for (auto k = j->second.begin(); k != j->second.end(); ) { + for (auto k = j->second.begin(); k != j->second.end();) { if (k->second.is_correction) { ++k; - continue; // Don't care correction edges + continue; // Don't care correction edges } if (k->second.type > last_type) { j->second.erase(k++); - } - else { + } else { if (k->second.type < edge_type) edge_type = k->second.type; ++k; @@ -176,8 +171,7 @@ int Syllabifier::BuildSyllableGraph(const string &input, } if (j->second.empty()) { graph->edges[i].erase(j++); - } - else { + } else { if (edge_type < kAbbreviation) CheckOverlappedSpellings(graph, i, j->first); ++j; @@ -205,7 +199,8 @@ int Syllabifier::BuildSyllableGraph(const string &input, auto& end_vertices(graph->edges[current_pos]); auto& spellings(end_vertices[end_pos]); for (const auto& m : keys) { - if (m.length < code_length) continue; + if (m.length < code_length) + continue; // when spelling algebra is enabled, // a spelling evaluates to a set of syllables; // otherwise, it resembles exactly the syllable itself. @@ -227,10 +222,9 @@ int Syllabifier::BuildSyllableGraph(const string &input, if (spellings.empty()) { DLOG(INFO) << "no completion could be made."; end_vertices.erase(end_pos); - } - else { - DLOG(INFO) << "added to syllable graph, completion: [" - << current_pos << ", " << end_pos << ")"; + } else { + DLOG(INFO) << "added to syllable graph, completion: [" << current_pos + << ", " << end_pos << ")"; farthest = end_pos; } } @@ -246,9 +240,11 @@ int Syllabifier::BuildSyllableGraph(const string &input, return farthest; } -void Syllabifier::CheckOverlappedSpellings(SyllableGraph *graph, - size_t start, size_t end) { - const double kPenaltyForAmbiguousSyllable = -23.025850929940457; // log(1e-10) +void Syllabifier::CheckOverlappedSpellings(SyllableGraph* graph, + size_t start, + size_t end) { + const double kPenaltyForAmbiguousSyllable = + -23.025850929940457; // log(1e-10) if (!graph || graph->edges.find(start) == graph->edges.end()) return; // if "Z" = "YX", mark the vertex between Y and X an ambiguous syllable joint @@ -256,13 +252,15 @@ void Syllabifier::CheckOverlappedSpellings(SyllableGraph *graph, // enumerate Ys for (const auto& y : y_end_vertices) { size_t joint = y.first; - if (joint >= end) break; + if (joint >= end) + break; // test X if (graph->edges.find(joint) == graph->edges.end()) continue; auto& x_end_vertices(graph->edges[joint]); for (auto& x : x_end_vertices) { - if (x.first < end) continue; + if (x.first < end) + continue; if (x.first == end) { // discourage syllables at an ambiguous joint // bad cases include pinyin syllabification "niju'ede" diff --git a/src/rime/algo/syllabifier.h b/src/rime/algo/syllabifier.h index 54766c0e7..1d46682c0 100644 --- a/src/rime/algo/syllabifier.h +++ b/src/rime/algo/syllabifier.h @@ -20,7 +20,7 @@ class Corrector; using SyllableId = int32_t; struct EdgeProperties : SpellingProperties { - EdgeProperties(SpellingProperties sup): SpellingProperties(sup) {}; + EdgeProperties(SpellingProperties sup) : SpellingProperties(sup){}; EdgeProperties() = default; bool is_correction = false; }; @@ -45,22 +45,20 @@ struct SyllableGraph { class Syllabifier { public: Syllabifier() = default; - explicit Syllabifier(const string &delimiters, + explicit Syllabifier(const string& delimiters, bool enable_completion = false, bool strict_spelling = false) : delimiters_(delimiters), enable_completion_(enable_completion), - strict_spelling_(strict_spelling) { - } + strict_spelling_(strict_spelling) {} - RIME_API int BuildSyllableGraph(const string &input, - Prism &prism, - SyllableGraph *graph); + RIME_API int BuildSyllableGraph(const string& input, + Prism& prism, + SyllableGraph* graph); RIME_API void EnableCorrection(Corrector* corrector); protected: - void CheckOverlappedSpellings(SyllableGraph *graph, - size_t start, size_t end); + void CheckOverlappedSpellings(SyllableGraph* graph, size_t start, size_t end); void Transpose(SyllableGraph* graph); string delimiters_; diff --git a/src/rime/algo/utilities.cc b/src/rime/algo/utilities.cc index d96283712..8000eb1bf 100644 --- a/src/rime/algo/utilities.cc +++ b/src/rime/algo/utilities.cc @@ -12,9 +12,12 @@ namespace rime { int CompareVersionString(const string& x, const string& y) { - if (x.empty() && y.empty()) return 0; - if (x.empty()) return -1; - if (y.empty()) return 1; + if (x.empty() && y.empty()) + return 0; + if (x.empty()) + return -1; + if (y.empty()) + return 1; vector xx, yy; boost::split(xx, x, boost::is_any_of(".")); boost::split(yy, y, boost::is_any_of(".")); @@ -22,12 +25,16 @@ int CompareVersionString(const string& x, const string& y) { for (; i < xx.size() && i < yy.size(); ++i) { int dx = atoi(xx[i].c_str()); int dy = atoi(yy[i].c_str()); - if (dx != dy) return dx - dy; + if (dx != dy) + return dx - dy; int c = xx[i].compare(yy[i]); - if (c != 0) return c; + if (c != 0) + return c; } - if (i < xx.size()) return 1; - if (i < yy.size()) return -1; + if (i < xx.size()) + return 1; + if (i < yy.size()) + return -1; return 0; } diff --git a/src/rime/algo/utilities.h b/src/rime/algo/utilities.h index 4231b16b8..5813b1d0f 100644 --- a/src/rime/algo/utilities.h +++ b/src/rime/algo/utilities.h @@ -13,8 +13,7 @@ namespace rime { -int CompareVersionString(const string& x, - const string& y); +int CompareVersionString(const string& x, const string& y); class ChecksumComputer { public: diff --git a/src/rime/candidate.cc b/src/rime/candidate.cc index 048d65ae0..ffd0b39ce 100644 --- a/src/rime/candidate.cc +++ b/src/rime/candidate.cc @@ -8,27 +8,24 @@ namespace rime { -static an -UnpackShadowCandidate(const an& cand) { +static an UnpackShadowCandidate(const an& cand) { auto shadow = As(cand); return shadow ? shadow->item() : cand; } -an -Candidate::GetGenuineCandidate(const an& cand) { +an Candidate::GetGenuineCandidate(const an& cand) { auto uniquified = As(cand); return UnpackShadowCandidate(uniquified ? uniquified->items().front() : cand); } -vector> -Candidate::GetGenuineCandidates(const an& cand) { +vector> Candidate::GetGenuineCandidates( + const an& cand) { vector> result; if (auto uniquified = As(cand)) { for (const auto& item : uniquified->items()) { result.push_back(UnpackShadowCandidate(item)); } - } - else { + } else { result.push_back(UnpackShadowCandidate(cand)); } return result; diff --git a/src/rime/candidate.h b/src/rime/candidate.h index d184f0758..70fdd1ee4 100644 --- a/src/rime/candidate.h +++ b/src/rime/candidate.h @@ -14,17 +14,12 @@ namespace rime { class Candidate { public: Candidate() = default; - Candidate(const string& type, - size_t start, - size_t end, - double quality = 0.) + Candidate(const string& type, size_t start, size_t end, double quality = 0.) : type_(type), start_(start), end_(end), quality_(quality) {} virtual ~Candidate() = default; - static an - GetGenuineCandidate(const an& cand); - static vector> - GetGenuineCandidates(const an& cand); + static an GetGenuineCandidate(const an& cand); + static vector> GetGenuineCandidates(const an& cand); // recognized by translators in learning phase const string& type() const { return type_; } @@ -67,7 +62,9 @@ class SimpleCandidate : public Candidate { const string& comment = string(), const string& preedit = string()) : Candidate(type, start, end), - text_(text), comment_(comment), preedit_(preedit) {} + text_(text), + comment_(comment), + preedit_(preedit) {} const string& text() const { return text_; } string comment() const { return comment_; } @@ -91,18 +88,16 @@ class ShadowCandidate : public Candidate { const string& comment = string(), const bool inherit_comment = true) : Candidate(type, item->start(), item->end(), item->quality()), - text_(text), comment_(comment), - item_(item), inherit_comment_(inherit_comment) {} + text_(text), + comment_(comment), + item_(item), + inherit_comment_(inherit_comment) {} - const string& text() const { - return text_.empty() ? item_->text() : text_; - } + const string& text() const { return text_.empty() ? item_->text() : text_; } string comment() const { return inherit_comment_ && comment_.empty() ? item_->comment() : comment_; } - string preedit() const { - return item_->preedit(); - } + string preedit() const { return item_->preedit(); } const an& item() const { return item_; } @@ -120,17 +115,17 @@ class UniquifiedCandidate : public Candidate { const string& text = string(), const string& comment = string()) : Candidate(type, item->start(), item->end(), item->quality()), - text_(text), comment_(comment) { + text_(text), + comment_(comment) { Append(item); } const string& text() const { - return text_.empty() && !items_.empty() ? - items_.front()->text() : text_; + return text_.empty() && !items_.empty() ? items_.front()->text() : text_; } string comment() const { - return comment_.empty() && !items_.empty() ? - items_.front()->comment() : comment_; + return comment_.empty() && !items_.empty() ? items_.front()->comment() + : comment_; } string preedit() const { return !items_.empty() ? items_.front()->preedit() : string(); diff --git a/src/rime/commit_history.cc b/src/rime/commit_history.cc index dbec66d15..622ceebda 100644 --- a/src/rime/commit_history.cc +++ b/src/rime/commit_history.cc @@ -22,16 +22,14 @@ void CommitHistory::Push(const KeyEvent& key_event) { if (key_event.keycode() == XK_BackSpace || key_event.keycode() == XK_Return) { clear(); - } - else if (key_event.keycode() >= 0x20 && key_event.keycode() <= 0x7e) { + } else if (key_event.keycode() >= 0x20 && key_event.keycode() <= 0x7e) { // printable ascii character Push(CommitRecord(key_event.keycode())); } } } -void CommitHistory::Push(const Composition& composition, - const string& input) { +void CommitHistory::Push(const Composition& composition, const string& input) { CommitRecord* last = NULL; size_t end = 0; for (const Segment& seg : composition) { @@ -39,8 +37,7 @@ void CommitHistory::Push(const Composition& composition, if (last && last->type == cand->type()) { // join adjacent text of same type last->text += cand->text(); - } - else { + } else { // new record Push({cand->type(), cand->text()}); last = &back(); @@ -50,8 +47,7 @@ void CommitHistory::Push(const Composition& composition, last = NULL; } end = cand->end(); - } - else { + } else { // no translation for the segment Push({"raw", input.substr(seg.start, seg.end - seg.start)}); end = seg.end; diff --git a/src/rime/commit_history.h b/src/rime/commit_history.h index dfe8ea0fe..03b0714c8 100644 --- a/src/rime/commit_history.h +++ b/src/rime/commit_history.h @@ -29,9 +29,7 @@ class CommitHistory : public list { void Push(const KeyEvent& key_event); void Push(const Composition& composition, const string& input); string repr() const; - string latest_text() const { - return empty() ? string() : back().text; - } + string latest_text() const { return empty() ? string() : back().text; } }; } // Namespace rime diff --git a/src/rime/common.h b/src/rime/common.h index c05cd36ca..a658ef12d 100644 --- a/src/rime/common.h +++ b/src/rime/common.h @@ -43,6 +43,7 @@ namespace rime { +using boost::optional; using std::function; using std::list; using std::make_pair; @@ -52,7 +53,6 @@ using std::pair; using std::set; using std::string; using std::vector; -using boost::optional; template using hash_map = std::unordered_map; @@ -87,8 +87,8 @@ inline an New(Args&&... args) { using boost::signals2::connection; using boost::signals2::signal; #else -using boost::signals::connection; using boost::signal; +using boost::signals::connection; #endif } // namespace rime diff --git a/src/rime/component.h b/src/rime/component.h index 5c5adccc9..786929114 100644 --- a/src/rime/component.h +++ b/src/rime/component.h @@ -34,9 +34,7 @@ struct Class { template struct Component : public T::Component { public: - T* Create(typename T::Initializer arg) { - return new T(arg); - } + T* Create(typename T::Initializer arg) { return new T(arg); } }; } // namespace rime diff --git a/src/rime/composition.cc b/src/rime/composition.cc index 3c009c3cd..7581e60f7 100644 --- a/src/rime/composition.cc +++ b/src/rime/composition.cc @@ -21,7 +21,8 @@ bool Composition::HasFinishedComposition() const { return at(k).status >= Segment::kSelected; } -Preedit Composition::GetPreedit(const string& full_input, size_t caret_pos, +Preedit Composition::GetPreedit(const string& full_input, + size_t caret_pos, const string& caret) const { Preedit preedit; preedit.caret_pos = string::npos; @@ -37,15 +38,13 @@ Preedit Composition::GetPreedit(const string& full_input, size_t caret_pos, if (cand) { end = cand->end(); preedit.text += cand->text(); - } - else { // raw input + } else { // raw input end = at(i).end; if (!at(i).HasTag("phony")) { preedit.text += input_.substr(start, end - start); } } - } - else { // highlighted + } else { // highlighted preedit.sel_start = preedit.text.length(); preedit.sel_end = string::npos; if (cand && !cand->preedit().empty()) { @@ -63,8 +62,7 @@ Preedit Composition::GetPreedit(const string& full_input, size_t caret_pos, } else { preedit.text += cand->preedit(); } - } - else { + } else { end = at(i).end; preedit.text += input_.substr(start, end - start); } @@ -107,8 +105,7 @@ string Composition::GetCommitText() const { if (auto cand = seg.GetSelectedCandidate()) { end = cand->end(); result += cand->text(); - } - else { + } else { end = seg.end; if (!seg.HasTag("phony")) { result += input_.substr(seg.start, seg.end - seg.start); @@ -166,7 +163,8 @@ string Composition::GetDebugText() const { } string Composition::GetTextBefore(size_t pos) const { - if (empty()) return string(); + if (empty()) + return string(); for (const auto& seg : boost::adaptors::reverse(*this)) { if (seg.end <= pos) { if (auto cand = seg.GetSelectedCandidate()) { diff --git a/src/rime/composition.h b/src/rime/composition.h index 7bbb2bdfc..8fe6a97e7 100644 --- a/src/rime/composition.h +++ b/src/rime/composition.h @@ -23,7 +23,8 @@ class Composition : public Segmentation { Composition() = default; bool HasFinishedComposition() const; - Preedit GetPreedit(const string& full_input, size_t caret_pos, + Preedit GetPreedit(const string& full_input, + size_t caret_pos, const string& caret) const; string GetPrompt() const; string GetCommitText() const; diff --git a/src/rime/config/auto_patch_config_plugin.cc b/src/rime/config/auto_patch_config_plugin.cc index 52fb9a90e..397db5b32 100644 --- a/src/rime/config/auto_patch_config_plugin.cc +++ b/src/rime/config/auto_patch_config_plugin.cc @@ -9,8 +9,9 @@ namespace rime { static string remove_suffix(const string& input, const string& suffix) { - return boost::ends_with(input, suffix) ? - input.substr(0, input.length() - suffix.length()) : input; + return boost::ends_with(input, suffix) + ? input.substr(0, input.length() - suffix.length()) + : input; } // auto-patch applies to all loaded config resources, including dependencies. @@ -25,8 +26,8 @@ bool AutoPatchConfigPlugin::ReviewCompileOutput(ConfigCompiler* compiler, return true; auto patch_resource_id = remove_suffix(resource->resource_id, ".schema") + ".custom"; - LOG(INFO) << "auto-patch " << resource->resource_id << ":/__patch: " - << patch_resource_id << ":/patch?"; + LOG(INFO) << "auto-patch " << resource->resource_id + << ":/__patch: " << patch_resource_id << ":/patch?"; compiler->Push(resource); compiler->AddDependency( New(Reference{patch_resource_id, "patch", true})); diff --git a/src/rime/config/build_info_plugin.cc b/src/rime/config/build_info_plugin.cc index 4df1e6581..a60b6b56a 100644 --- a/src/rime/config/build_info_plugin.cc +++ b/src/rime/config/build_info_plugin.cc @@ -10,13 +10,13 @@ namespace rime { -bool BuildInfoPlugin::ReviewCompileOutput( - ConfigCompiler* compiler, an resource) { +bool BuildInfoPlugin::ReviewCompileOutput(ConfigCompiler* compiler, + an resource) { return true; } -bool BuildInfoPlugin::ReviewLinkOutput( - ConfigCompiler* compiler, an resource) { +bool BuildInfoPlugin::ReviewLinkOutput(ConfigCompiler* compiler, + an resource) { auto build_info = (*resource)["__build_info"]; build_info["rime_version"] = RIME_VERSION; auto timestamps = build_info["timestamps"]; @@ -35,7 +35,7 @@ bool BuildInfoPlugin::ReviewLinkOutput( } // TODO: store as 64-bit number to avoid the year 2038 problem timestamps[resource->resource_id] = - (int) boost::filesystem::last_write_time(file_name); + (int)boost::filesystem::last_write_time(file_name); }); return true; } diff --git a/src/rime/config/config_compiler.cc b/src/rime/config/config_compiler.cc index 053ab948f..3ddc2f68f 100644 --- a/src/rime/config/config_compiler.cc +++ b/src/rime/config/config_compiler.cc @@ -9,11 +9,11 @@ namespace rime { -std::ostream& operator<< (std::ostream& stream, const Reference& reference) { +std::ostream& operator<<(std::ostream& stream, const Reference& reference) { return stream << reference.repr(); } -std::ostream& operator<< (std::ostream& stream, const Dependency& dependency) { +std::ostream& operator<<(std::ostream& stream, const Dependency& dependency) { return stream << dependency.repr(); } @@ -42,7 +42,8 @@ struct ConfigDependencyGraph { string ConfigDependencyGraph::current_resource_id() const { return key_stack.empty() ? string() - : boost::trim_right_copy_if(key_stack.front(), boost::is_any_of(":")); + : boost::trim_right_copy_if(key_stack.front(), + boost::is_any_of(":")); } string Reference::repr() const { @@ -149,22 +150,23 @@ static constexpr const char* EQU_SUFFIX_OPERATOR = "/="; inline static bool IsAppending(const string& key) { return key == ConfigCompiler::APPEND_DIRECTIVE || - boost::ends_with(key, ADD_SUFFIX_OPERATOR); + boost::ends_with(key, ADD_SUFFIX_OPERATOR); } inline static bool IsMerging(const string& key, const an& value, bool merge_tree) { return key == ConfigCompiler::MERGE_DIRECTIVE || - boost::ends_with(key, ADD_SUFFIX_OPERATOR) || - (merge_tree && (!value || Is(value)) && - !boost::ends_with(key, EQU_SUFFIX_OPERATOR)); + boost::ends_with(key, ADD_SUFFIX_OPERATOR) || + (merge_tree && (!value || Is(value)) && + !boost::ends_with(key, EQU_SUFFIX_OPERATOR)); } inline static string StripOperator(const string& key, bool adding) { return (key == ConfigCompiler::APPEND_DIRECTIVE || - key == ConfigCompiler::MERGE_DIRECTIVE) ? "" : - boost::erase_last_copy( - key, adding ? ADD_SUFFIX_OPERATOR : EQU_SUFFIX_OPERATOR); + key == ConfigCompiler::MERGE_DIRECTIVE) + ? "" + : boost::erase_last_copy( + key, adding ? ADD_SUFFIX_OPERATOR : EQU_SUFFIX_OPERATOR); } // defined in config_data.cc @@ -193,9 +195,9 @@ static bool EditNode(an head, if ((appending || merging) && **target) { DLOG(INFO) << "writer: editing node"; return !value || // no-op - (appending && (AppendToString(target, As(value)) || - AppendToList(target, As(value)))) || - (merging && MergeTree(target, As(value))); + (appending && (AppendToString(target, As(value)) || + AppendToList(target, As(value)))) || + (merging && MergeTree(target, As(value))); } else { DLOG(INFO) << "writer: overwriting node"; *target = value; @@ -231,7 +233,8 @@ static void InsertByPriority(vector>& list, void ConfigDependencyGraph::Add(an dependency) { DLOG(INFO) << "ConfigDependencyGraph::Add(), node_stack.size() = " << node_stack.size(); - if (node_stack.empty()) return; + if (node_stack.empty()) + return; const auto& target = node_stack.back(); dependency->TargetedAt(target); auto target_path = ConfigData::JoinPath(key_stack); @@ -240,7 +243,7 @@ void ConfigDependencyGraph::Add(an dependency) { InsertByPriority(target_deps, dependency); DLOG(INFO) << "target_path = " << target_path << ", #deps = " << target_deps.size(); - if (target_was_pending || // so was all ancestors + if (target_was_pending || // so was all ancestors key_stack.size() == 1) { // this is the progenitor return; } @@ -259,7 +262,7 @@ void ConfigDependencyGraph::Add(an dependency) { DLOG(INFO) << "parent_path = " << parent_path << ", #deps = " << parent_deps.size(); if (parent_was_pending || // so was all ancestors - keys.size() == 1) { // this parent is the progenitor + keys.size() == 1) { // this parent is the progenitor return; } } @@ -269,24 +272,23 @@ ConfigCompiler::ConfigCompiler(ResourceResolver* resource_resolver, ConfigCompilerPlugin* plugin) : resource_resolver_(resource_resolver), plugin_(plugin), - graph_(new ConfigDependencyGraph) { -} + graph_(new ConfigDependencyGraph) {} -ConfigCompiler::~ConfigCompiler() { -} +ConfigCompiler::~ConfigCompiler() {} Reference ConfigCompiler::CreateReference(const string& qualified_path) { auto end = qualified_path.find_last_of("?"); bool optional = end != string::npos; auto separator = qualified_path.find_first_of(":"); string resource_id = resource_resolver_->ToResourceId( - (separator == string::npos || separator == 0) ? - graph_->current_resource_id() : - qualified_path.substr(0, separator)); - string local_path = (separator == string::npos) ? - qualified_path.substr(0, end) : - qualified_path.substr(separator + 1, - optional ? end - separator - 1 : end); + (separator == string::npos || separator == 0) + ? graph_->current_resource_id() + : qualified_path.substr(0, separator)); + string local_path = + (separator == string::npos) + ? qualified_path.substr(0, end) + : qualified_path.substr(separator + 1, + optional ? end - separator - 1 : end); return Reference{resource_id, local_path, optional}; } @@ -299,15 +301,12 @@ void ConfigCompiler::Push(an resource) { } void ConfigCompiler::Push(an config_list, size_t index) { - graph_->Push( - New(nullptr, config_list, index), - ConfigData::FormatListIndex(index)); + graph_->Push(New(nullptr, config_list, index), + ConfigData::FormatListIndex(index)); } void ConfigCompiler::Push(an config_map, const string& key) { - graph_->Push( - New(nullptr, config_map, key), - key); + graph_->Push(New(nullptr, config_map, key), key); } void ConfigCompiler::Pop() { @@ -315,7 +314,7 @@ void ConfigCompiler::Pop() { } void ConfigCompiler::EnumerateResources( - function resource)> process_resource) { + function resource)> process_resource) { for (const auto& r : graph_->resources) { process_resource(r.second); } @@ -355,7 +354,8 @@ static bool ResolveBlockingDependencies(ConfigCompiler* compiler, static an GetResolvedItem(ConfigCompiler* compiler, an resource, const string& path) { - DLOG(INFO) << "GetResolvedItem(" << resource->resource_id << ":" << path << ")"; + DLOG(INFO) << "GetResolvedItem(" << resource->resource_id << ":" << path + << ")"; string node_path = resource->resource_id + ":"; an node = resource; if (path.empty() || path == "/") { @@ -369,7 +369,7 @@ static an GetResolvedItem(ConfigCompiler* compiler, // CAVEAT: continuing accessing subtree with this failure may result in // referencing outdated data - sometimes an expected behavior. // relaxing this requires checking for circular dependencies. - //return nullptr; + // return nullptr; } an item = **node; if (Is(item)) { @@ -397,8 +397,8 @@ static an GetResolvedItem(ConfigCompiler* compiler, bool ConfigCompiler::blocking(const string& full_path) const { auto found = graph_->deps.find(full_path); - return found != graph_->deps.end() && !found->second.empty() - && found->second.back()->blocking(); + return found != graph_->deps.end() && !found->second.empty() && + found->second.back()->blocking(); } bool ConfigCompiler::pending(const string& full_path) const { @@ -436,8 +436,7 @@ static an ResolveReference(ConfigCompiler* compiler, // Includes contents of nodes at specified paths. // __include: path/to/local/node // __include: filename[.yaml]:/path/to/external/node -static bool ParseInclude(ConfigCompiler* compiler, - const an& item) { +static bool ParseInclude(ConfigCompiler* compiler, const an& item) { if (Is(item)) { auto path = As(item)->str(); DLOG(INFO) << "ParseInclude(" << path << ")"; @@ -470,8 +469,7 @@ static bool ParseList(bool (*parser)(ConfigCompiler*, const an&), // __patch: path/to/node // __patch: filename[.yaml]:/path/to/node // __patch: { key/alpha: value, key/beta: value } -static bool ParsePatch(ConfigCompiler* compiler, - const an& item) { +static bool ParsePatch(ConfigCompiler* compiler, const an& item) { if (Is(item)) { auto path = As(item)->str(); DLOG(INFO) << "ParsePatch(" << path << ")"; @@ -506,7 +504,7 @@ bool ConfigCompiler::Link(an target) { return false; } return ResolveDependencies(found->first + ":") && - (plugin_ ? plugin_->ReviewLinkOutput(this, target) : true); + (plugin_ ? plugin_->ReviewLinkOutput(this, target) : true); } static bool HasCircularDependencies(ConfigDependencyGraph* graph, @@ -531,7 +529,7 @@ bool ConfigCompiler::ResolveDependencies(const string& path) { } graph_->resolve_chain.push_back(path); auto& deps = found->second; - for (auto iter = deps.begin(); iter != deps.end(); ) { + for (auto iter = deps.begin(); iter != deps.end();) { if (!(*iter)->Resolve(this)) { LOG(ERROR) << "unresolved dependency: " << **iter; return false; diff --git a/src/rime/config/config_compiler.h b/src/rime/config/config_compiler.h index a6cdd45c0..5bfa41d6b 100644 --- a/src/rime/config/config_compiler.h +++ b/src/rime/config/config_compiler.h @@ -18,14 +18,9 @@ struct ConfigResource : ConfigItemRef { bool loaded = false; ConfigResource(const string& _id, an _data) - : ConfigItemRef(nullptr), resource_id(_id), data(_data) { - } - an GetItem() const override { - return data->root; - } - void SetItem(an item) override { - data->root = item; - } + : ConfigItemRef(nullptr), resource_id(_id), data(_data) {} + an GetItem() const override { return data->root; } + void SetItem(an item) override { data->root = item; } }; struct Reference { @@ -36,7 +31,7 @@ struct Reference { string repr() const; }; -std::ostream& operator<< (std::ostream& stream, const Reference& reference); +std::ostream& operator<<(std::ostream& stream, const Reference& reference); class ConfigCompilerPlugin; class ResourceResolver; @@ -63,7 +58,7 @@ class ConfigCompiler { void Pop(); void EnumerateResources( - function resource)> process_resource); + function resource)> process_resource); an GetCompiledResource(const string& resource_id) const; an Compile(const string& file_name); bool Link(an target); diff --git a/src/rime/config/config_compiler_impl.h b/src/rime/config/config_compiler_impl.h index bd4cf701c..4529e6743 100644 --- a/src/rime/config/config_compiler_impl.h +++ b/src/rime/config/config_compiler_impl.h @@ -22,9 +22,7 @@ struct Dependency { an target; virtual DependencyPriority priority() const = 0; - bool blocking() const { - return priority() > kPendingChild; - } + bool blocking() const { return priority() > kPendingChild; } virtual string repr() const = 0; Dependency& TargetedAt(an target) { this->target = target; @@ -33,63 +31,43 @@ struct Dependency { virtual bool Resolve(ConfigCompiler* compiler) = 0; }; -std::ostream& operator<< (std::ostream& stream, const Dependency& dependency); +std::ostream& operator<<(std::ostream& stream, const Dependency& dependency); struct PendingChild : Dependency { string child_path; an child_ref; PendingChild(const string& path, const an& ref) - : child_path(path), child_ref(ref) { - } - DependencyPriority priority() const override { - return kPendingChild; - } - string repr() const override { - return "PendingChild(" + child_path + ")"; - } + : child_path(path), child_ref(ref) {} + DependencyPriority priority() const override { return kPendingChild; } + string repr() const override { return "PendingChild(" + child_path + ")"; } bool Resolve(ConfigCompiler* compiler) override; }; struct IncludeReference : Dependency { Reference reference; - IncludeReference(const Reference& r) : reference(r) { - } - DependencyPriority priority() const override { - return kInclude; - } - string repr() const override { - return "Include(" + reference.repr() + ")"; - } + IncludeReference(const Reference& r) : reference(r) {} + DependencyPriority priority() const override { return kInclude; } + string repr() const override { return "Include(" + reference.repr() + ")"; } bool Resolve(ConfigCompiler* compiler) override; }; struct PatchReference : Dependency { Reference reference; - PatchReference(const Reference& r) : reference(r) { - } - DependencyPriority priority() const override { - return kPatch; - } - string repr() const override { - return "Patch(" + reference.repr() + ")"; - } + PatchReference(const Reference& r) : reference(r) {} + DependencyPriority priority() const override { return kPatch; } + string repr() const override { return "Patch(" + reference.repr() + ")"; } bool Resolve(ConfigCompiler* compiler) override; }; struct PatchLiteral : Dependency { an patch; - PatchLiteral(an map) : patch(map) { - } - DependencyPriority priority() const override { - return kPatch; - } - string repr() const override { - return "Patch()"; - } + PatchLiteral(an map) : patch(map) {} + DependencyPriority priority() const override { return kPatch; } + string repr() const override { return "Patch()"; } bool Resolve(ConfigCompiler* compiler) override; }; diff --git a/src/rime/config/config_component.cc b/src/rime/config/config_component.cc index 2319b5094..740e90888 100644 --- a/src/rime/config/config_component.cc +++ b/src/rime/config/config_component.cc @@ -142,9 +142,8 @@ void Config::SetItem(an item) { set_modified(); } -const ResourceType ConfigResourceProvider::kDefaultResourceType = { - "config", "", ".yaml" -}; +const ResourceType ConfigResourceProvider::kDefaultResourceType = {"config", "", + ".yaml"}; ResourceResolver* ConfigResourceProvider::CreateResourceResolver( const ResourceType& resource_type) { @@ -152,8 +151,7 @@ ResourceResolver* ConfigResourceProvider::CreateResourceResolver( } const ResourceType DeployedConfigResourceProvider::kDefaultResourceType = { - "compiled_config", "", ".yaml" -}; + "compiled_config", "", ".yaml"}; ResourceResolver* DeployedConfigResourceProvider::CreateResourceResolver( const ResourceType& resource_type) { @@ -161,8 +159,7 @@ ResourceResolver* DeployedConfigResourceProvider::CreateResourceResolver( } const ResourceType UserConfigResourceProvider::kDefaultResourceType = { - "user_config", "", ".yaml" -}; + "user_config", "", ".yaml"}; ResourceResolver* UserConfigResourceProvider::CreateResourceResolver( const ResourceType& resource_type) { @@ -170,11 +167,9 @@ ResourceResolver* UserConfigResourceProvider::CreateResourceResolver( } ConfigComponentBase::ConfigComponentBase(ResourceResolver* resource_resolver) - : resource_resolver_(resource_resolver) { -} + : resource_resolver_(resource_resolver) {} -ConfigComponentBase::~ConfigComponentBase() { -} +ConfigComponentBase::~ConfigComponentBase() {} Config* ConfigComponentBase::Create(const string& file_name) { return new Config(GetConfigData(file_name)); @@ -196,8 +191,8 @@ an ConfigComponentBase::GetConfigData(const string& file_name) { an ConfigLoader::LoadConfig(ResourceResolver* resource_resolver, const string& config_id) { auto data = New(); - data->LoadFromFile( - resource_resolver->ResolvePath(config_id).string(), nullptr); + data->LoadFromFile(resource_resolver->ResolvePath(config_id).string(), + nullptr); data->set_auto_save(auto_save_); return data; } @@ -214,18 +209,16 @@ template struct MultiplePlugins : ConfigCompilerPlugin { Container& plugins; - MultiplePlugins(Container& _plugins) - : plugins(_plugins) { - } + MultiplePlugins(Container& _plugins) : plugins(_plugins) {} bool ReviewCompileOutput(ConfigCompiler* compiler, an resource) override { - return ReviewedByAll(&ConfigCompilerPlugin::ReviewCompileOutput, - compiler, resource); + return ReviewedByAll(&ConfigCompilerPlugin::ReviewCompileOutput, compiler, + resource); } bool ReviewLinkOutput(ConfigCompiler* compiler, an resource) override { - return ReviewedByAll(&ConfigCompilerPlugin::ReviewLinkOutput, - compiler, resource); + return ReviewedByAll(&ConfigCompilerPlugin::ReviewLinkOutput, compiler, + resource); } typedef bool (ConfigCompilerPlugin::*Reviewer)(ConfigCompiler* compiler, an resource); @@ -239,7 +232,7 @@ bool MultiplePlugins::ReviewedByAll(Reviewer reviewer, ConfigCompiler* compiler, an resource) { for (const auto& plugin : plugins) { - if(!((*plugin).*reviewer)(compiler, resource)) + if (!((*plugin).*reviewer)(compiler, resource)) return false; } return true; diff --git a/src/rime/config/config_component.h b/src/rime/config/config_component.h index f52bd6c29..7add9f5b0 100644 --- a/src/rime/config/config_component.h +++ b/src/rime/config/config_component.h @@ -72,20 +72,20 @@ struct ConfigResource; struct ConfigResourceProvider { RIME_API static const ResourceType kDefaultResourceType; - RIME_API static ResourceResolver* - CreateResourceResolver(const ResourceType& resource_type); + RIME_API static ResourceResolver* CreateResourceResolver( + const ResourceType& resource_type); }; struct DeployedConfigResourceProvider { RIME_API static const ResourceType kDefaultResourceType; - RIME_API static ResourceResolver* - CreateResourceResolver(const ResourceType& resource_type); + RIME_API static ResourceResolver* CreateResourceResolver( + const ResourceType& resource_type); }; struct UserConfigResourceProvider { RIME_API static const ResourceType kDefaultResourceType; - RIME_API static ResourceResolver* - CreateResourceResolver(const ResourceType& resource_type); + RIME_API static ResourceResolver* CreateResourceResolver( + const ResourceType& resource_type); }; class ConfigComponentBase : public Config::Component { @@ -104,18 +104,18 @@ class ConfigComponentBase : public Config::Component { }; template - class ConfigComponent : public ConfigComponentBase { +class ConfigComponent : public ConfigComponentBase { public: ConfigComponent(const ResourceType& resource_type = - ResourceProvider::kDefaultResourceType) + ResourceProvider::kDefaultResourceType) : ConfigComponentBase( ResourceProvider::CreateResourceResolver(resource_type)) {} - ConfigComponent(function setup) - : ConfigComponentBase( - ResourceProvider::CreateResourceResolver( - ResourceProvider::kDefaultResourceType)) { + ConfigComponent(function setup) + : ConfigComponentBase(ResourceProvider::CreateResourceResolver( + ResourceProvider::kDefaultResourceType)) { setup(&loader_); } + private: an LoadConfig(const string& config_id) override { return loader_.LoadConfig(resource_resolver_.get(), config_id); @@ -128,6 +128,7 @@ class ConfigLoader { RIME_API an LoadConfig(ResourceResolver* resource_resolver, const string& config_id); void set_auto_save(bool auto_save) { auto_save_ = auto_save; } + private: bool auto_save_ = false; }; @@ -138,8 +139,9 @@ class ConfigBuilder { RIME_API virtual ~ConfigBuilder(); RIME_API an LoadConfig(ResourceResolver* resource_resolver, const string& config_id); - void InstallPlugin(ConfigCompilerPlugin *plugin); + void InstallPlugin(ConfigCompilerPlugin* plugin); bool ApplyPlugins(ConfigCompiler* compiler, an resource); + private: vector> plugins_; }; diff --git a/src/rime/config/config_cow_ref.h b/src/rime/config/config_cow_ref.h index d4d40e528..a83365f45 100644 --- a/src/rime/config/config_cow_ref.h +++ b/src/rime/config/config_cow_ref.h @@ -16,8 +16,7 @@ template class ConfigCowRef : public ConfigItemRef { public: ConfigCowRef(an parent, string key) - : ConfigItemRef(nullptr), parent_(parent), key_(key) { - } + : ConfigItemRef(nullptr), parent_(parent), key_(key) {} an GetItem() const override { auto container = As(**parent_); return container ? Read(container, key_) : nullptr; @@ -30,6 +29,7 @@ class ConfigCowRef : public ConfigItemRef { } Write(container, key_, item); } + protected: static an CopyOnWrite(const an& container, const string& key); static an Read(const an& container, const string& key); diff --git a/src/rime/config/config_data.cc b/src/rime/config/config_data.cc index 50f22e03b..0151f94b4 100644 --- a/src/rime/config/config_data.cc +++ b/src/rime/config/config_data.cc @@ -34,8 +34,7 @@ bool ConfigData::LoadFromStream(std::istream& stream) { try { YAML::Node doc = YAML::Load(stream); root = ConvertFromYaml(doc, nullptr); - } - catch (YAML::Exception& e) { + } catch (YAML::Exception& e) { LOG(ERROR) << "Error parsing YAML: " << e.what(); return false; } @@ -50,8 +49,7 @@ bool ConfigData::SaveToStream(std::ostream& stream) { try { YAML::Emitter emitter(stream); EmitYaml(root, &emitter, 0); - } - catch (YAML::Exception& e) { + } catch (YAML::Exception& e) { LOG(ERROR) << "Error emitting YAML: " << e.what(); return false; } @@ -72,8 +70,7 @@ bool ConfigData::LoadFromFile(const string& file_name, try { YAML::Node doc = YAML::LoadFile(file_name); root = ConvertFromYaml(doc, compiler); - } - catch (YAML::Exception& e) { + } catch (YAML::Exception& e) { LOG(ERROR) << "Error parsing YAML: " << e.what(); return false; } @@ -107,7 +104,8 @@ static const string kBefore("before"); static const string kLast("last"); static const string kNext("next"); -size_t ConfigData::ResolveListIndex(an item, const string& key, +size_t ConfigData::ResolveListIndex(an item, + const string& key, bool read_only) { if (!IsListItemReference(key)) { return 0; @@ -122,12 +120,10 @@ size_t ConfigData::ResolveListIndex(an item, const string& key, if (key.compare(cursor, kNext.length(), kNext) == 0) { cursor += kNext.length(); index = list->size(); - } - else if (key.compare(cursor, kBefore.length(), kBefore) == 0) { + } else if (key.compare(cursor, kBefore.length(), kBefore) == 0) { cursor += kBefore.length(); will_insert = true; - } - else if (key.compare(cursor, kAfter.length(), kAfter) == 0) { + } else if (key.compare(cursor, kAfter.length(), kAfter) == 0) { cursor += kAfter.length(); index += 1; // after i == before i+1 will_insert = true; @@ -141,8 +137,7 @@ size_t ConfigData::ResolveListIndex(an item, const string& key, if (index != 0) { // when list is empty, (before|after) last == 0 --index; } - } - else { + } else { index += std::strtoul(key.c_str() + cursor, NULL, 10); } if (will_insert && !read_only) { @@ -153,14 +148,10 @@ size_t ConfigData::ResolveListIndex(an item, const string& key, class ConfigDataRootRef : public ConfigItemRef { public: - ConfigDataRootRef(ConfigData* data) : ConfigItemRef(nullptr), data_(data) { - } - an GetItem() const override { - return data_->root; - } - void SetItem(an item) override { - data_->root = item; - } + ConfigDataRootRef(ConfigData* data) : ConfigItemRef(nullptr), data_(data) {} + an GetItem() const override { return data_->root; } + void SetItem(an item) override { data_->root = item; } + private: ConfigData* data_; }; @@ -245,16 +236,15 @@ an ConfigData::Traverse(const string& path) { } if (node_type == ConfigItem::kList) { p = As(p)->GetAt(list_index); - } - else { + } else { p = As(p)->Get(*it); } } return p; } -an ConvertFromYaml( - const YAML::Node& node, ConfigCompiler* compiler) { +an ConvertFromYaml(const YAML::Node& node, + ConfigCompiler* compiler) { if (YAML::NodeType::Null == node.Type()) { return nullptr; } @@ -273,8 +263,7 @@ an ConvertFromYaml( } } return config_list; - } - else if (YAML::NodeType::Map == node.Type()) { + } else if (YAML::NodeType::Map == node.Type()) { auto config_map = New(); for (auto it = node.begin(), end = node.end(); it != end; ++it) { string key = it->first.as(); @@ -297,22 +286,21 @@ an ConvertFromYaml( void EmitScalar(const string& str_value, YAML::Emitter* emitter) { if (str_value.find_first_of("\r\n") != string::npos) { *emitter << YAML::Literal; - } - else if (!boost::algorithm::all(str_value, - boost::algorithm::is_alnum() || - boost::algorithm::is_any_of("_."))) { + } else if (!boost::algorithm::all(str_value, + boost::algorithm::is_alnum() || + boost::algorithm::is_any_of("_."))) { *emitter << YAML::DoubleQuoted; } *emitter << str_value; } void EmitYaml(an node, YAML::Emitter* emitter, int depth) { - if (!node || !emitter) return; + if (!node || !emitter) + return; if (node->type() == ConfigItem::kScalar) { auto value = As(node); EmitScalar(value->str(), emitter); - } - else if (node->type() == ConfigItem::kList) { + } else if (node->type() == ConfigItem::kList) { if (depth >= 3) { *emitter << YAML::Flow; } @@ -322,8 +310,7 @@ void EmitYaml(an node, YAML::Emitter* emitter, int depth) { EmitYaml(*it, emitter, depth + 1); } *emitter << YAML::EndSeq; - } - else if (node->type() == ConfigItem::kMap) { + } else if (node->type() == ConfigItem::kMap) { if (depth >= 3) { *emitter << YAML::Flow; } diff --git a/src/rime/config/config_data.h b/src/rime/config/config_data.h index 5d6245dc6..e3c23f069 100644 --- a/src/rime/config/config_data.h +++ b/src/rime/config/config_data.h @@ -30,7 +30,8 @@ class ConfigData { static string JoinPath(const vector& keys); static bool IsListItemReference(const string& key); static string FormatListIndex(size_t index); - static size_t ResolveListIndex(an list, const string& key, + static size_t ResolveListIndex(an list, + const string& key, bool read_only = false); const string& file_name() const { return file_name_; } diff --git a/src/rime/config/config_types.cc b/src/rime/config/config_types.cc index 99d2ca3d6..47429f0b3 100644 --- a/src/rime/config/config_types.cc +++ b/src/rime/config/config_types.cc @@ -14,28 +14,23 @@ namespace rime { // ConfigValue members -ConfigValue::ConfigValue(bool value) - : ConfigItem(kScalar) { +ConfigValue::ConfigValue(bool value) : ConfigItem(kScalar) { SetBool(value); } -ConfigValue::ConfigValue(int value) - : ConfigItem(kScalar) { +ConfigValue::ConfigValue(int value) : ConfigItem(kScalar) { SetInt(value); } -ConfigValue::ConfigValue(double value) - : ConfigItem(kScalar) { +ConfigValue::ConfigValue(double value) : ConfigItem(kScalar) { SetDouble(value); } ConfigValue::ConfigValue(const char* value) - : ConfigItem(kScalar), value_(value) { -} + : ConfigItem(kScalar), value_(value) {} ConfigValue::ConfigValue(const string& value) - : ConfigItem(kScalar), value_(value) { -} + : ConfigItem(kScalar), value_(value) {} bool ConfigValue::GetBool(bool* value) const { if (!value || value_.empty()) @@ -45,12 +40,10 @@ bool ConfigValue::GetBool(bool* value) const { if ("true" == bstr) { *value = true; return true; - } - else if ("false" == bstr) { + } else if ("false" == bstr) { *value = false; return true; - } - else + } else return false; } @@ -69,8 +62,7 @@ bool ConfigValue::GetInt(int* value) const { // decimal try { *value = boost::lexical_cast(value_); - } - catch (...) { + } catch (...) { return false; } return true; @@ -81,15 +73,15 @@ bool ConfigValue::GetDouble(double* value) const { return false; try { *value = boost::lexical_cast(value_); - } - catch (...) { + } catch (...) { return false; } return true; } bool ConfigValue::GetString(string* value) const { - if (!value) return false; + if (!value) + return false; *value = value_; return true; } diff --git a/src/rime/config/config_types.h b/src/rime/config/config_types.h index 6131091b7..9278a7afd 100644 --- a/src/rime/config/config_types.h +++ b/src/rime/config/config_types.h @@ -23,9 +23,7 @@ class ConfigItem { ValueType type() const { return type_; } - virtual bool empty() const { - return type_ == kNull; - } + virtual bool empty() const { return type_ == kNull; } protected: ConfigItem(ValueType type) : type_(type) {} @@ -55,9 +53,7 @@ class ConfigValue : public ConfigItem { const string& str() const { return value_; } - bool empty() const override { - return value_.empty(); - } + bool empty() const override { return value_.empty(); } protected: string value_; @@ -81,9 +77,7 @@ class ConfigList : public ConfigItem { Iterator begin(); Iterator end(); - bool empty() const override { - return seq_.empty(); - } + bool empty() const override { return seq_.empty(); } protected: Sequence seq_; @@ -105,9 +99,7 @@ class ConfigMap : public ConfigItem { Iterator begin(); Iterator end(); - bool empty() const override { - return map_.empty(); - } + bool empty() const override { return map_.empty(); } protected: Map map_; @@ -135,19 +127,15 @@ class ConfigItemRef { public: ConfigItemRef(ConfigData* data) : data_(data) {} virtual ~ConfigItemRef() = default; - operator an () const { - return GetItem(); - } - an operator* () const { - return GetItem(); - } + operator an() const { return GetItem(); } + an operator*() const { return GetItem(); } template - ConfigItemRef& operator= (const T& x) { + ConfigItemRef& operator=(const T& x) { SetItem(AsConfigItem(x, std::is_convertible>())); return *this; } - ConfigListEntryRef operator[] (size_t index); - ConfigMapEntryRef operator[] (const string& key); + ConfigListEntryRef operator[](size_t index); + ConfigMapEntryRef operator[](const string& key); RIME_API bool IsNull() const; bool IsValue() const; @@ -184,14 +172,14 @@ class ConfigListEntryRef : public ConfigItemRef { ConfigListEntryRef(ConfigData* data, an list, size_t index) : ConfigItemRef(data), list_(list), index_(index) {} using ConfigItemRef::operator=; + protected: - an GetItem() const { - return list_->GetAt(index_); - } + an GetItem() const { return list_->GetAt(index_); } void SetItem(an item) { list_->SetAt(index_, item); set_modified(); } + private: an list_; size_t index_; @@ -202,24 +190,24 @@ class ConfigMapEntryRef : public ConfigItemRef { ConfigMapEntryRef(ConfigData* data, an map, const string& key) : ConfigItemRef(data), map_(map), key_(key) {} using ConfigItemRef::operator=; + protected: - an GetItem() const { - return map_->Get(key_); - } + an GetItem() const { return map_->Get(key_); } void SetItem(an item) { map_->Set(key_, item); set_modified(); } + private: an map_; string key_; }; -inline ConfigListEntryRef ConfigItemRef::operator[] (size_t index) { +inline ConfigListEntryRef ConfigItemRef::operator[](size_t index) { return ConfigListEntryRef(data_, AsList(), index); } -inline ConfigMapEntryRef ConfigItemRef::operator[] (const string& key) { +inline ConfigMapEntryRef ConfigItemRef::operator[](const string& key) { return ConfigMapEntryRef(data_, AsMap(), key); } diff --git a/src/rime/config/default_config_plugin.cc b/src/rime/config/default_config_plugin.cc index 91a9c18bf..bc9c28b56 100644 --- a/src/rime/config/default_config_plugin.cc +++ b/src/rime/config/default_config_plugin.cc @@ -9,19 +9,18 @@ namespace rime { -bool DefaultConfigPlugin::ReviewCompileOutput( - ConfigCompiler* compiler, an resource) { +bool DefaultConfigPlugin::ReviewCompileOutput(ConfigCompiler* compiler, + an resource) { return true; } -bool DefaultConfigPlugin::ReviewLinkOutput( - ConfigCompiler* compiler, an resource) { +bool DefaultConfigPlugin::ReviewLinkOutput(ConfigCompiler* compiler, + an resource) { if (!boost::ends_with(resource->resource_id, ".schema")) return true; auto target = Cow(resource, "menu"); Reference reference{"default", "menu", true}; - if (!IncludeReference{reference} - .TargetedAt(target).Resolve(compiler)) { + if (!IncludeReference{reference}.TargetedAt(target).Resolve(compiler)) { LOG(ERROR) << "failed to include section " << reference; return false; } diff --git a/src/rime/config/legacy_dictionary_config_plugin.cc b/src/rime/config/legacy_dictionary_config_plugin.cc index c7e8d4786..1a2516d98 100644 --- a/src/rime/config/legacy_dictionary_config_plugin.cc +++ b/src/rime/config/legacy_dictionary_config_plugin.cc @@ -8,13 +8,15 @@ namespace rime { bool LegacyDictionaryConfigPlugin::ReviewCompileOutput( - ConfigCompiler* compiler, an resource) { + ConfigCompiler* compiler, + an resource) { // TODO: unimplemented return true; } bool LegacyDictionaryConfigPlugin::ReviewLinkOutput( - ConfigCompiler* compiler, an resource) { + ConfigCompiler* compiler, + an resource) { // TODO: unimplemented return true; } diff --git a/src/rime/config/legacy_preset_config_plugin.cc b/src/rime/config/legacy_preset_config_plugin.cc index 865e5ee7e..908d18434 100644 --- a/src/rime/config/legacy_preset_config_plugin.cc +++ b/src/rime/config/legacy_preset_config_plugin.cc @@ -10,12 +10,13 @@ namespace rime { bool LegacyPresetConfigPlugin::ReviewCompileOutput( - ConfigCompiler* compiler, an resource) { + ConfigCompiler* compiler, + an resource) { return true; } -bool LegacyPresetConfigPlugin::ReviewLinkOutput( - ConfigCompiler* compiler, an resource) { +bool LegacyPresetConfigPlugin::ReviewLinkOutput(ConfigCompiler* compiler, + an resource) { if (!boost::ends_with(resource->resource_id, ".schema")) return true; if (auto preset = resource->data->Traverse("key_binder/import_preset")) { @@ -33,8 +34,7 @@ bool LegacyPresetConfigPlugin::ReviewLinkOutput( (*target)["bindings"] = nullptr; } Reference reference{preset_config_id, "key_binder", false}; - if (!IncludeReference{reference} - .TargetedAt(target).Resolve(compiler)) { + if (!IncludeReference{reference}.TargetedAt(target).Resolve(compiler)) { LOG(ERROR) << "failed to include section " << reference; return false; } @@ -52,7 +52,8 @@ bool LegacyPresetConfigPlugin::ReviewLinkOutput( LOG(INFO) << "interpreting punctuator/import_preset: " << preset_config_id; Reference reference{preset_config_id, "punctuator", false}; if (!IncludeReference{reference} - .TargetedAt(Cow(resource, "punctuator")).Resolve(compiler)) { + .TargetedAt(Cow(resource, "punctuator")) + .Resolve(compiler)) { LOG(ERROR) << "failed to include section " << reference; return false; } @@ -64,7 +65,8 @@ bool LegacyPresetConfigPlugin::ReviewLinkOutput( LOG(INFO) << "interpreting recognizer/import_preset: " << preset_config_id; Reference reference{preset_config_id, "recognizer", false}; if (!IncludeReference{reference} - .TargetedAt(Cow(resource, "recognizer")).Resolve(compiler)) { + .TargetedAt(Cow(resource, "recognizer")) + .Resolve(compiler)) { LOG(ERROR) << "failed to include section " << reference; return false; } diff --git a/src/rime/config/plugins.h b/src/rime/config/plugins.h index 3ec266207..4e1a963d9 100644 --- a/src/rime/config/plugins.h +++ b/src/rime/config/plugins.h @@ -14,8 +14,7 @@ struct ConfigResource; class ConfigCompilerPlugin { public: - typedef bool Review(ConfigCompiler* compiler, - an resource); + typedef bool Review(ConfigCompiler* compiler, an resource); virtual ~ConfigCompilerPlugin() = default; diff --git a/src/rime/config/save_output_plugin.cc b/src/rime/config/save_output_plugin.cc index 0aee483e6..f1e088aee 100644 --- a/src/rime/config/save_output_plugin.cc +++ b/src/rime/config/save_output_plugin.cc @@ -11,24 +11,21 @@ namespace rime { -static const ResourceType kCompiledConfig = { - "compiled_config", "", ".yaml" -}; +static const ResourceType kCompiledConfig = {"compiled_config", "", ".yaml"}; SaveOutputPlugin::SaveOutputPlugin() : resource_resolver_( - Service::instance().CreateStagingResourceResolver(kCompiledConfig)) { -} + Service::instance().CreateStagingResourceResolver(kCompiledConfig)) {} SaveOutputPlugin::~SaveOutputPlugin() {} -bool SaveOutputPlugin::ReviewCompileOutput( - ConfigCompiler* compiler, an resource) { +bool SaveOutputPlugin::ReviewCompileOutput(ConfigCompiler* compiler, + an resource) { return true; } -bool SaveOutputPlugin::ReviewLinkOutput( - ConfigCompiler* compiler, an resource) { +bool SaveOutputPlugin::ReviewLinkOutput(ConfigCompiler* compiler, + an resource) { auto file_path = resource_resolver_->ResolvePath(resource->resource_id); return resource->data->SaveToFile(file_path.string()); } diff --git a/src/rime/context.cc b/src/rime/context.cc index c3f62f294..905ced34e 100644 --- a/src/rime/context.cc +++ b/src/rime/context.cc @@ -63,8 +63,7 @@ bool Context::PushInput(char ch) { if (caret_pos_ >= input_.length()) { input_.push_back(ch); caret_pos_ = input_.length(); - } - else { + } else { input_.insert(caret_pos_, 1, ch); ++caret_pos_; } @@ -76,8 +75,7 @@ bool Context::PushInput(const string& str) { if (caret_pos_ >= input_.length()) { input_ += str; caret_pos_ = input_.length(); - } - else { + } else { input_.insert(caret_pos_, str); caret_pos_ += str.length(); } @@ -124,7 +122,7 @@ bool Context::Select(size_t index) { } bool Context::DeleteCandidate( - function (Segment& seg)> get_candidate) { + function(Segment& seg)> get_candidate) { if (composition_.empty()) return false; Segment& seg(composition_.back()); @@ -138,16 +136,12 @@ bool Context::DeleteCandidate( bool Context::DeleteCandidate(size_t index) { return DeleteCandidate( - [index](Segment& seg) { - return seg.GetCandidateAt(index); - }); + [index](Segment& seg) { return seg.GetCandidateAt(index); }); } bool Context::DeleteCurrentSelection() { return DeleteCandidate( - [](Segment& seg) { - return seg.GetSelectedCandidate(); - }); + [](Segment& seg) { return seg.GetSelectedCandidate(); }); } bool Context::ConfirmCurrentSelection() { @@ -158,8 +152,7 @@ bool Context::ConfirmCurrentSelection() { if (auto cand = seg.GetSelectedCandidate()) { DLOG(INFO) << "Confirmed: '" << cand->text() << "', selected_index = " << seg.selected_index; - } - else { + } else { if (seg.end == seg.start) { // fluid_editor will confirm the whole sentence return false; @@ -274,8 +267,7 @@ bool Context::get_option(const string& name) const { return false; } -void Context::set_property(const string& name, - const string& value) { +void Context::set_property(const string& name, const string& value) { properties_[name] = value; property_update_notifier_(this, name); } @@ -290,13 +282,12 @@ string Context::get_property(const string& name) const { void Context::ClearTransientOptions() { auto opt = options_.lower_bound("_"); - while (opt != options_.end() && - !opt->first.empty() && opt->first[0] == '_') { + while (opt != options_.end() && !opt->first.empty() && opt->first[0] == '_') { options_.erase(opt++); } auto prop = properties_.lower_bound("_"); - while (prop != properties_.end() && - !prop->first.empty() && prop->first[0] == '_') { + while (prop != properties_.end() && !prop->first.empty() && + prop->first[0] == '_') { properties_.erase(prop++); } } diff --git a/src/rime/context.h b/src/rime/context.h index d624f0203..58ea39aa5 100644 --- a/src/rime/context.h +++ b/src/rime/context.h @@ -18,13 +18,12 @@ class KeyEvent; class Context { public: - using Notifier = signal; - using OptionUpdateNotifier = - signal; + using Notifier = signal; + using OptionUpdateNotifier = signal; using PropertyUpdateNotifier = - signal; + signal; using KeyEventNotifier = - signal; + signal; Context() = default; ~Context() = default; @@ -87,9 +86,7 @@ class Context { PropertyUpdateNotifier& property_update_notifier() { return property_update_notifier_; } - KeyEventNotifier& unhandled_key_notifier() { - return unhandled_key_notifier_; - } + KeyEventNotifier& unhandled_key_notifier() { return unhandled_key_notifier_; } private: string GetSoftCursor() const; diff --git a/src/rime/core_module.cc b/src/rime/core_module.cc index abb295692..43c3cb090 100644 --- a/src/rime/core_module.cc +++ b/src/rime/core_module.cc @@ -20,8 +20,8 @@ static void rime_core_initialize() { LOG(INFO) << "registering core components."; Registry& r = Registry::instance(); - auto config_builder = new ConfigComponent( - [&](ConfigBuilder* builder) { + auto config_builder = + new ConfigComponent([&](ConfigBuilder* builder) { builder->InstallPlugin(new AutoPatchConfigPlugin); builder->InstallPlugin(new DefaultConfigPlugin); builder->InstallPlugin(new LegacyPresetConfigPlugin); @@ -38,9 +38,7 @@ static void rime_core_initialize() { auto user_config = new ConfigComponent( - [](ConfigLoader* loader) { - loader->set_auto_save(true); - }); + [](ConfigLoader* loader) { loader->set_auto_save(true); }); r.Register("user_config", user_config); } diff --git a/src/rime/deployer.cc b/src/rime/deployer.cc index fc43344e6..1394679b2 100644 --- a/src/rime/deployer.cc +++ b/src/rime/deployer.cc @@ -12,13 +12,13 @@ namespace rime { -Deployer::Deployer() : shared_data_dir("."), - user_data_dir("."), - prebuilt_data_dir("build"), - staging_dir("build"), - sync_dir("sync"), - user_id("unknown") { -} +Deployer::Deployer() + : shared_data_dir("."), + user_data_dir("."), + prebuilt_data_dir("build"), + staging_dir("build"), + sync_dir("sync"), + user_id("unknown") {} Deployer::~Deployer() { JoinWorkThread(); @@ -86,15 +86,14 @@ bool Deployer::Run() { ++success; else ++failure; - //boost::this_thread::interruption_point(); + // boost::this_thread::interruption_point(); } - LOG(INFO) << success + failure << " tasks ran: " - << success << " success, " << failure << " failure."; + LOG(INFO) << success + failure << " tasks ran: " << success << " success, " + << failure << " failure."; message_sink_("deploy", !failure ? "success" : "failure"); // new tasks could have been enqueued while we were sending the message. // before quitting, double check if there is nothing left to do. - } - while (HasPendingTasks()); + } while (HasPendingTasks()); return !failure; } @@ -107,8 +106,8 @@ bool Deployer::StartWork(bool maintenance_mode) { if (pending_tasks_.empty()) { return false; } - LOG(INFO) << "starting work thread for " - << pending_tasks_.size() << " tasks."; + LOG(INFO) << "starting work thread for " << pending_tasks_.size() + << " tasks."; work_ = std::async(std::launch::async, [this] { Run(); }); return work_.valid(); } diff --git a/src/rime/dict/corrector.cc b/src/rime/dict/corrector.cc index 590fb22b5..f092eb8b8 100644 --- a/src/rime/dict/corrector.cc +++ b/src/rime/dict/corrector.cc @@ -65,21 +65,28 @@ static hash_map> keyboard_map = { {'/', {'.'}}, }; -void DFSCollect(const string &origin, const string ¤t, size_t ed, Script &result); +void DFSCollect(const string& origin, + const string& current, + size_t ed, + Script& result); Script SymDeleteCollector::Collect(size_t edit_distance) { // TODO: specifically for 1 length str Script script; - for (auto &v : syllabary_) { + for (auto& v : syllabary_) { DFSCollect(v, v, edit_distance, script); } return script; } -void DFSCollect(const string &origin, const string ¤t, size_t ed, Script &result) { - if (ed <= 0) return; +void DFSCollect(const string& origin, + const string& current, + size_t ed, + Script& result) { + if (ed <= 0) + return; for (size_t i = 0; i < current.size(); i++) { string temp = current; temp.erase(i, 1); @@ -90,9 +97,9 @@ void DFSCollect(const string &origin, const string ¤t, size_t ed, Script & } } -void EditDistanceCorrector::ToleranceSearch(const Prism &prism, - const string &key, - Corrections *results, +void EditDistanceCorrector::ToleranceSearch(const Prism& prism, + const string& key, + Corrections* results, size_t threshold) { if (key.empty()) return; @@ -100,24 +107,25 @@ void EditDistanceCorrector::ToleranceSearch(const Prism &prism, vector jump_pos(key_len); - auto match_next = [&](size_t &node, size_t &point) -> bool { + auto match_next = [&](size_t& node, size_t& point) -> bool { auto res_val = trie_->traverse(key.c_str(), node, point, point + 1); - if (res_val == -2) return false; + if (res_val == -2) + return false; if (res_val >= 0) { - for (auto accessor = QuerySpelling(res_val); !accessor.exhausted(); accessor.Next()) { + for (auto accessor = QuerySpelling(res_val); !accessor.exhausted(); + accessor.Next()) { auto origin = accessor.properties().tips; auto current_input = key.substr(0, point); if (origin == current_input) { - continue; // early termination: this comparision is O(n) + continue; // early termination: this comparision is O(n) } auto distance = RestrictedDistance(origin, current_input, threshold); - if (distance <= threshold) { // only trace near words + if (distance <= threshold) { // only trace near words SyllableId corrected; if (prism.GetValue(origin, &corrected)) { - results->Alter(corrected, { distance, corrected, point }); + results->Alter(corrected, {distance, corrected, point}); } } - } } return true; @@ -127,21 +135,23 @@ void EditDistanceCorrector::ToleranceSearch(const Prism &prism, size_t max_match = 0; for (size_t next_node = 0; max_match < key_len;) { jump_pos[max_match] = next_node; - if (!match_next(next_node, max_match)) break; + if (!match_next(next_node, max_match)) + break; } // start at the next position of deleted char for (size_t del_pos = 0; del_pos <= max_match; del_pos++) { size_t next_node = jump_pos[del_pos]; for (size_t key_point = del_pos + 1; key_point < key_len;) { - if (!match_next(next_node, key_point)) break; + if (!match_next(next_node, key_point)) + break; } } } - inline uint8_t SubstCost(char left, char right) { - if (left == right) return 0; + if (left == right) + return 0; if (keyboard_map[left].find(right) != keyboard_map[left].end()) { return 1; } @@ -150,7 +160,8 @@ inline uint8_t SubstCost(char left, char right) { // This nice O(min(m, n)) implementation is from // https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#C++ -Distance EditDistanceCorrector::LevenshteinDistance(const std::string &s1, const std::string &s2) { +Distance EditDistanceCorrector::LevenshteinDistance(const std::string& s1, + const std::string& s2) { // To change the type this function manipulates and returns, change // the return type and the types of the two variables below. auto s1len = (size_t)s1.size(); @@ -166,11 +177,8 @@ Distance EditDistanceCorrector::LevenshteinDistance(const std::string &s1, const auto last_diagonal = x - column_start; for (auto y = column_start; y <= s1len; y++) { auto old_diagonal = column[y]; - auto possibilities = { - column[y] + 1, - column[y - 1] + 1, - last_diagonal + SubstCost(s1[y - 1], s2[x - 1]) - }; + auto possibilities = {column[y] + 1, column[y - 1] + 1, + last_diagonal + SubstCost(s1[y - 1], s2[x - 1])}; column[y] = (std::min)(possibilities); last_diagonal = old_diagonal; @@ -183,27 +191,25 @@ Distance EditDistanceCorrector::LevenshteinDistance(const std::string &s1, const // L's distance with transposition allowed Distance EditDistanceCorrector::RestrictedDistance(const std::string& s1, - const std::string& s2, - Distance threshold) { + const std::string& s2, + Distance threshold) { auto len1 = s1.size(), len2 = s2.size(); vector d((len1 + 1) * (len2 + 1)); - auto index = [len1, len2](size_t i, size_t j) { - return i * (len2 + 1) + j; - }; + auto index = [len1, len2](size_t i, size_t j) { return i * (len2 + 1) + j; }; d[0] = 0; - for(size_t i = 1; i <= len1; ++i) d[index(i, 0)] = i * 2; - for(size_t i = 1; i <= len2; ++i) d[index(0, i)] = i * 2; + for (size_t i = 1; i <= len1; ++i) + d[index(i, 0)] = i * 2; + for (size_t i = 1; i <= len2; ++i) + d[index(0, i)] = i * 2; - for(size_t i = 1; i <= len1; ++i) { + for (size_t i = 1; i <= len1; ++i) { auto min_d = threshold + 1; - for(size_t j = 1; j <= len2; ++j) { - d[index(i, j)] = (std::min)({ - d[index(i - 1, j)] + 2, - d[index(i, j - 1)] + 2, - d[index(i - 1, j - 1)] + SubstCost(s1[i - 1], s2[j - 1]) - }); + for (size_t j = 1; j <= len2; ++j) { + d[index(i, j)] = (std::min)( + {d[index(i - 1, j)] + 2, d[index(i, j - 1)] + 2, + d[index(i - 1, j - 1)] + SubstCost(s1[i - 1], s2[j - 1])}); if (i > 1 && j > 1 && s1[i - 2] == s2[j - 1] && s1[i - 1] == s2[j - 2]) { d[index(i, j)] = (std::min)(d[index(i, j)], d[index(i - 2, j - 2)] + 2); } @@ -215,13 +221,13 @@ Distance EditDistanceCorrector::RestrictedDistance(const std::string& s1, } return (uint8_t)d[index(len1, len2)]; } -bool EditDistanceCorrector::Build(const Syllabary &syllabary, - const Script *script, +bool EditDistanceCorrector::Build(const Syllabary& syllabary, + const Script* script, uint32_t dict_file_checksum, uint32_t schema_file_checksum) { Syllabary correct_syllabary; if (script && !script->empty()) { - for (auto &v : *script) { + for (auto& v : *script) { correct_syllabary.insert(v.first); } } else { @@ -231,17 +237,18 @@ bool EditDistanceCorrector::Build(const Syllabary &syllabary, SymDeleteCollector collector(correct_syllabary); auto correction_script = collector.Collect((size_t)1); - return Prism::Build(syllabary, &correction_script, dict_file_checksum, schema_file_checksum); + return Prism::Build(syllabary, &correction_script, dict_file_checksum, + schema_file_checksum); } -EditDistanceCorrector::EditDistanceCorrector(const string &file_name) : Prism(file_name) {} +EditDistanceCorrector::EditDistanceCorrector(const string& file_name) + : Prism(file_name) {} -void -NearSearchCorrector::ToleranceSearch(const Prism &prism, - const string &key, - Corrections *results, - size_t threshold) { +void NearSearchCorrector::ToleranceSearch(const Prism& prism, + const string& key, + Corrections* results, + size_t threshold) { if (key.empty()) - return ; + return; using record = struct { size_t node_pos; @@ -251,47 +258,47 @@ NearSearchCorrector::ToleranceSearch(const Prism &prism, }; std::queue queue; - queue.push({ 0, 0, 0, key[0] }); + queue.push({0, 0, 0, key[0]}); for (auto subst : keyboard_map[key[0]]) { - queue.push({ 0, 0, 1, subst }); + queue.push({0, 0, 1, subst}); } for (; !queue.empty(); queue.pop()) { - auto &rec = queue.front(); + auto& rec = queue.front(); char ch = rec.ch; - char &exchange(const_cast(key.c_str())[rec.idx]); + char& exchange(const_cast(key.c_str())[rec.idx]); std::swap(ch, exchange); - auto val = prism.trie().traverse(key.c_str(), rec.node_pos, rec.idx, rec.idx + 1); + auto val = + prism.trie().traverse(key.c_str(), rec.node_pos, rec.idx, rec.idx + 1); std::swap(ch, exchange); - if (val == -2) continue; + if (val == -2) + continue; if (val >= 0) { - results->Alter(val, { rec.distance, val, rec.idx }); + results->Alter(val, {rec.distance, val, rec.idx}); } if (rec.idx < key.size()) { - queue.push({ rec.node_pos, rec.idx, rec.distance, key[rec.idx] }); + queue.push({rec.node_pos, rec.idx, rec.distance, key[rec.idx]}); if (rec.distance < threshold) { for (auto subst : keyboard_map[key[rec.idx]]) { - queue.push({ rec.node_pos, rec.idx, rec.distance + 1, subst }); + queue.push({rec.node_pos, rec.idx, rec.distance + 1, subst}); } } } } } -void CorrectorComponent::Unified::ToleranceSearch(const Prism &prism, - const string &key, - Corrections *results, +void CorrectorComponent::Unified::ToleranceSearch(const Prism& prism, + const string& key, + Corrections* results, size_t tolerance) { - for (auto &c : contents) { + for (auto& c : contents) { c->ToleranceSearch(prism, key, results, tolerance); } } CorrectorComponent::CorrectorComponent() - : resolver_(Service::instance().CreateDeployedResourceResolver({ - "corrector", "", ".correction.bin" - })) { -} + : resolver_(Service::instance().CreateDeployedResourceResolver( + {"corrector", "", ".correction.bin"})) {} -Corrector *CorrectorComponent::Create(const Ticket &ticket) noexcept { +Corrector* CorrectorComponent::Create(const Ticket& ticket) noexcept { // Don't use edit distance based correction for now. #if 0 if (!ticket.schema) return nullptr; diff --git a/src/rime/dict/corrector.h b/src/rime/dict/corrector.h index aa8fe7c82..48f07183a 100644 --- a/src/rime/dict/corrector.h +++ b/src/rime/dict/corrector.h @@ -20,7 +20,8 @@ struct Ticket; class SymDeleteCollector { public: - explicit SymDeleteCollector(const Syllabary& syllabary): syllabary_(syllabary) {} + explicit SymDeleteCollector(const Syllabary& syllabary) + : syllabary_(syllabary) {} Script Collect(size_t edit_distance); @@ -41,12 +42,13 @@ class Corrections : public hash_map { /// \param syllable /// \param correction inline void Alter(SyllableId syllable, Correction correction) { - if (find(syllable) == end() || correction.distance < (*this)[syllable].distance) { + if (find(syllable) == end() || + correction.distance < (*this)[syllable].distance) { (*this)[syllable] = correction; } }; }; -} // namespace corrector +} // namespace corrector /** * The unify interface of correctors @@ -54,9 +56,9 @@ class Corrections : public hash_map { class Corrector : public Class { public: virtual ~Corrector() = default; - RIME_API virtual void ToleranceSearch(const Prism &prism, - const string &key, - corrector::Corrections *results, + RIME_API virtual void ToleranceSearch(const Prism& prism, + const string& key, + corrector::Corrections* results, size_t tolerance) = 0; }; @@ -64,23 +66,24 @@ class CorrectorComponent : public Corrector::Component { public: CorrectorComponent(); ~CorrectorComponent() override = default; - Corrector *Create(const Ticket& ticket) noexcept override; + Corrector* Create(const Ticket& ticket) noexcept override; + private: - template - static Corrector *Combine(Cs ...args); + template + static Corrector* Combine(Cs... args); the resolver_; class Unified : public Corrector { public: Unified() = default; - RIME_API void ToleranceSearch(const Prism &prism, - const string &key, - corrector::Corrections *results, + RIME_API void ToleranceSearch(const Prism& prism, + const string& key, + corrector::Corrections* results, size_t tolerance) override; - template - void Add(Cs ...args) { - contents = { args... }; + template + void Add(Cs... args) { + contents = {args...}; } private: @@ -88,8 +91,7 @@ class CorrectorComponent : public Corrector::Component { }; }; -class EditDistanceCorrector : public Corrector, - public Prism { +class EditDistanceCorrector : public Corrector, public Prism { public: ~EditDistanceCorrector() override = default; RIME_API explicit EditDistanceCorrector(const string& file_name); @@ -99,31 +101,34 @@ class EditDistanceCorrector : public Corrector, uint32_t dict_file_checksum = 0, uint32_t schema_file_checksum = 0); - RIME_API void ToleranceSearch(const Prism &prism, - const string &key, - corrector::Corrections *results, + RIME_API void ToleranceSearch(const Prism& prism, + const string& key, + corrector::Corrections* results, size_t tolerance) override; - corrector::Distance LevenshteinDistance(const std::string &s1, const std::string &s2); - corrector::Distance RestrictedDistance(const std::string& s1, const std::string& s2, corrector::Distance threshold); + corrector::Distance LevenshteinDistance(const std::string& s1, + const std::string& s2); + corrector::Distance RestrictedDistance(const std::string& s1, + const std::string& s2, + corrector::Distance threshold); }; class NearSearchCorrector : public Corrector { public: NearSearchCorrector() = default; ~NearSearchCorrector() override = default; - RIME_API void ToleranceSearch(const Prism &prism, - const string &key, - corrector::Corrections *results, + RIME_API void ToleranceSearch(const Prism& prism, + const string& key, + corrector::Corrections* results, size_t tolerance) override; }; -template -Corrector *CorrectorComponent::Combine(Cs ...args) { +template +Corrector* CorrectorComponent::Combine(Cs... args) { auto u = new Unified(); u->Add(args...); return u; } -} // namespace rime +} // namespace rime -#endif //RIME_CORRECTOR_H +#endif // RIME_CORRECTOR_H diff --git a/src/rime/dict/db.cc b/src/rime/dict/db.cc index d84c57271..241e5e567 100644 --- a/src/rime/dict/db.cc +++ b/src/rime/dict/db.cc @@ -21,9 +21,7 @@ bool DbAccessor::MatchesPrefix(const string& key) { // DbComponentBase -static const ResourceType kDbResourceType = { - "db", "", "" -}; +static const ResourceType kDbResourceType = {"db", "", ""}; DbComponentBase::DbComponentBase() : db_resource_resolver_( @@ -39,8 +37,7 @@ string DbComponentBase::DbFilePath(const string& name, // Db members Db::Db(const string& file_name, const string& name) - : name_(name), - file_name_(file_name) {} + : name_(name), file_name_(file_name) {} bool Db::Exists() const { return boost::filesystem::exists(file_name()); @@ -57,7 +54,7 @@ bool Db::Remove() { bool Db::CreateMetadata() { LOG(INFO) << "creating metadata for db '" << name_ << "'."; return MetaUpdate("/db_name", name_) && - MetaUpdate("/rime_version", RIME_VERSION); + MetaUpdate("/rime_version", RIME_VERSION); } } // namespace rime diff --git a/src/rime/dict/db.h b/src/rime/dict/db.h index 1cade68f5..6c0163b26 100644 --- a/src/rime/dict/db.h +++ b/src/rime/dict/db.h @@ -16,13 +16,12 @@ namespace rime { class DbAccessor { public: DbAccessor() = default; - explicit DbAccessor(const string& prefix) - : prefix_(prefix) {} + explicit DbAccessor(const string& prefix) : prefix_(prefix) {} virtual ~DbAccessor() = default; virtual bool Reset() = 0; - virtual bool Jump(const string &key) = 0; - virtual bool GetNextRecord(string *key, string *value) = 0; + virtual bool Jump(const string& key) = 0; + virtual bool GetNextRecord(string* key, string* value) = 0; virtual bool exhausted() = 0; protected: @@ -52,10 +51,10 @@ class Db : public Class { virtual an QueryMetadata() = 0; virtual an QueryAll() = 0; - virtual an Query(const string &key) = 0; - virtual bool Fetch(const string &key, string *value) = 0; - virtual bool Update(const string &key, const string &value) = 0; - virtual bool Erase(const string &key) = 0; + virtual an Query(const string& key) = 0; + virtual bool Fetch(const string& key, string* value) = 0; + virtual bool Update(const string& key, const string& value) = 0; + virtual bool Erase(const string& key) = 0; const string& name() const { return name_; } const string& file_name() const { return file_name_; } @@ -81,6 +80,7 @@ class Transactional { virtual bool AbortTransaction() { return false; } virtual bool CommitTransaction() { return false; } bool in_transaction() const { return in_transaction_; } + protected: bool in_transaction_ = false; }; @@ -105,8 +105,7 @@ class DbComponentBase { }; template -class DbComponent : public DbClass::Component, - protected DbComponentBase { +class DbComponent : public DbClass::Component, protected DbComponentBase { public: virtual string extension() const; diff --git a/src/rime/dict/db_utils.cc b/src/rime/dict/db_utils.cc index 6a884afba..a3f28d524 100644 --- a/src/rime/dict/db_utils.cc +++ b/src/rime/dict/db_utils.cc @@ -25,8 +25,7 @@ int Source::Dump(Sink* sink) { return num_entries; } -DbSink::DbSink(Db* db) : db_(db) { -} +DbSink::DbSink(Db* db) : db_(db) {} bool DbSink::MetaPut(const string& key, const string& value) { return db_ && db_->MetaUpdate(key, value); @@ -37,10 +36,7 @@ bool DbSink::Put(const string& key, const string& value) { } DbSource::DbSource(Db* db) - : db_(db), - metadata_(db->QueryMetadata()), - data_(db->QueryAll()) { -} + : db_(db), metadata_(db->QueryMetadata()), data_(db->QueryAll()) {} bool DbSource::MetaGet(string* key, string* value) { return metadata_ && metadata_->GetNextRecord(key, value); diff --git a/src/rime/dict/db_utils.h b/src/rime/dict/db_utils.h index 68a9d3bd8..692f5501e 100644 --- a/src/rime/dict/db_utils.h +++ b/src/rime/dict/db_utils.h @@ -18,7 +18,7 @@ class Sink { virtual bool Put(const string& key, const string& value) = 0; template - int operator<< (SourceType& source); + int operator<<(SourceType& source); }; class Source { @@ -28,18 +28,18 @@ class Source { virtual bool Get(string* key, string* value) = 0; template - int operator>> (SinkType& sink); + int operator>>(SinkType& sink); int Dump(Sink* sink); }; template -int Sink::operator<< (SourceType& source) { +int Sink::operator<<(SourceType& source) { return source.Dump(this); } template -int Source::operator>> (SinkType& sink) { +int Source::operator>>(SinkType& sink) { return Dump(&sink); } diff --git a/src/rime/dict/dict_compiler.cc b/src/rime/dict/dict_compiler.cc index c448f0499..33f89c6b9 100644 --- a/src/rime/dict/dict_compiler.cc +++ b/src/rime/dict/dict_compiler.cc @@ -26,17 +26,15 @@ namespace fs = boost::filesystem; namespace rime { -DictCompiler::DictCompiler(Dictionary *dictionary) +DictCompiler::DictCompiler(Dictionary* dictionary) : dict_name_(dictionary->name()), packs_(dictionary->packs()), prism_(dictionary->prism()), tables_(dictionary->tables()), source_resolver_( - Service::instance().CreateResourceResolver( - {"source_file", "", ""})), - target_resolver_( - Service::instance().CreateStagingResourceResolver( - {"target_file", "", ""})) {} + Service::instance().CreateResourceResolver({"source_file", "", ""})), + target_resolver_(Service::instance().CreateStagingResourceResolver( + {"target_file", "", ""})) {} DictCompiler::~DictCompiler() {} @@ -52,7 +50,7 @@ static bool get_dict_files_from_settings(vector* dict_files, DictSettings& settings, ResourceResolver* source_resolver) { if (auto tables = settings.GetTables()) { - for(auto it = tables->begin(); it != tables->end(); ++it) { + for (auto it = tables->begin(); it != tables->end(); ++it) { string dict_name = As(*it)->str(); auto dict_file = source_resolver->ResolvePath(dict_name + ".dict.yaml"); if (!fs::exists(dict_file)) { @@ -81,7 +79,7 @@ static uint32_t compute_dict_file_checksum(uint32_t initial_checksum, return cc.Checksum(); } -bool DictCompiler::Compile(const string &schema_file) { +bool DictCompiler::Compile(const string& schema_file) { LOG(INFO) << "compiling dictionary for " << schema_file; bool build_table_from_source = true; DictSettings settings; @@ -89,14 +87,12 @@ bool DictCompiler::Compile(const string &schema_file) { if (!boost::filesystem::exists(dict_file)) { LOG(ERROR) << "source file '" << dict_file << "' does not exist."; build_table_from_source = false; - } - else if (!load_dict_settings_from_file(&settings, dict_file)) { + } else if (!load_dict_settings_from_file(&settings, dict_file)) { LOG(ERROR) << "failed to load settings from '" << dict_file << "'."; return false; } vector dict_files; - if (!get_dict_files_from_settings(&dict_files, - settings, + if (!get_dict_files_from_settings(&dict_files, settings, source_resolver_.get())) { return false; } @@ -118,8 +114,8 @@ bool DictCompiler::Compile(const string &schema_file) { } else if (build_table_from_source) { rebuild_table = true; } else { - LOG(ERROR) << "neither " << dict_name_ << ".dict.yaml nor " - << dict_name_ << ".table.bin exists."; + LOG(ERROR) << "neither " << dict_name_ << ".dict.yaml nor " << dict_name_ + << ".table.bin exists."; return false; } if (prism_->Exists() && prism_->Load()) { @@ -134,12 +130,10 @@ bool DictCompiler::Compile(const string &schema_file) { LOG(INFO) << schema_file << " (" << schema_file_checksum << ")"; { the resolver( - Service::instance().CreateDeployedResourceResolver({ - "find_reverse_db", "", ".reverse.bin" - })); + Service::instance().CreateDeployedResourceResolver( + {"find_reverse_db", "", ".reverse.bin"})); ReverseDb reverse_db(resolver->ResolvePath(dict_name_).string()); - if (!reverse_db.Exists() || - !reverse_db.Load() || + if (!reverse_db.Exists() || !reverse_db.Load() || reverse_db.dict_file_checksum() != dict_file_checksum) { rebuild_table = true; } @@ -153,19 +147,13 @@ bool DictCompiler::Compile(const string &schema_file) { Syllabary syllabary; if (rebuild_table) { EntryCollector collector; - if (!BuildTable(0, - collector, - &settings, - dict_files, - dict_file_checksum)) { + if (!BuildTable(0, collector, &settings, dict_files, dict_file_checksum)) { return false; } syllabary = std::move(collector.syllabary); } if (rebuild_prism && - !BuildPrism(schema_file, - dict_file_checksum, - schema_file_checksum)) { + !BuildPrism(schema_file, dict_file_checksum, schema_file_checksum)) { return false; } if (rebuild_table) { @@ -183,17 +171,13 @@ bool DictCompiler::Compile(const string &schema_file) { continue; } vector dict_files; - if (!get_dict_files_from_settings(&dict_files, - settings, + if (!get_dict_files_from_settings(&dict_files, settings, source_resolver_.get())) { continue; } uint32_t pack_file_checksum = compute_dict_file_checksum(dict_file_checksum, dict_files, settings); - if (!BuildTable(table_index, - collector, - &settings, - dict_files, + if (!BuildTable(table_index, collector, &settings, dict_files, pack_file_checksum)) { LOG(ERROR) << "failed to build pack: " << pack_name; } @@ -216,8 +200,8 @@ bool DictCompiler::BuildTable(int table_index, const vector& dict_files, uint32_t dict_file_checksum) { auto& table = tables_[table_index]; - auto target_path = relocate_target(table->file_name(), - target_resolver_.get()); + auto target_path = + relocate_target(table->file_name(), target_resolver_.get()); LOG(INFO) << "building table: " << target_path; table = New(target_path.string()); @@ -258,9 +242,7 @@ bool DictCompiler::BuildTable(int table_index, vocabulary.SortHomophones(); } table->Remove(); - if (!table->Build(collector.syllabary, - vocabulary, - collector.num_entries, + if (!table->Build(collector.syllabary, vocabulary, collector.num_entries, dict_file_checksum) || !table->Save()) { return false; @@ -268,10 +250,7 @@ bool DictCompiler::BuildTable(int table_index, } // build reverse db for the primary table if (table_index == 0 && - !BuildReverseDb(settings, - collector, - vocabulary, - dict_file_checksum)) { + !BuildReverseDb(settings, collector, vocabulary, dict_file_checksum)) { return false; } return true; @@ -282,14 +261,11 @@ bool DictCompiler::BuildReverseDb(DictSettings* settings, const Vocabulary& vocabulary, uint32_t dict_file_checksum) { // build .reverse.bin - auto target_path = relocate_target(dict_name_ + ".reverse.bin", - target_resolver_.get()); + auto target_path = + relocate_target(dict_name_ + ".reverse.bin", target_resolver_.get()); ReverseDb reverse_db(target_path.string()); - if (!reverse_db.Build(settings, - collector.syllabary, - vocabulary, - collector.stems, - dict_file_checksum) || + if (!reverse_db.Build(settings, collector.syllabary, vocabulary, + collector.stems, dict_file_checksum) || !reverse_db.Save()) { LOG(ERROR) << "error building reversedb."; return false; @@ -297,22 +273,21 @@ bool DictCompiler::BuildReverseDb(DictSettings* settings, return true; } -bool DictCompiler::BuildPrism(const string &schema_file, +bool DictCompiler::BuildPrism(const string& schema_file, uint32_t dict_file_checksum, uint32_t schema_file_checksum) { LOG(INFO) << "building prism..."; - auto target_path = relocate_target(prism_->file_name(), - target_resolver_.get()); + auto target_path = + relocate_target(prism_->file_name(), target_resolver_.get()); prism_ = New(target_path.string()); // get syllabary from primary table, which may not be rebuilt Syllabary syllabary; const auto& primary_table = tables_[0]; - if (!primary_table->Load() || - !primary_table->GetSyllabary(&syllabary) || + if (!primary_table->Load() || !primary_table->GetSyllabary(&syllabary) || syllabary.empty()) return false; - // apply spelling algebra and prepare corrections (if enabled) + // apply spelling algebra and prepare corrections (if enabled) Script script; if (!schema_file.empty()) { Config config; diff --git a/src/rime/dict/dict_compiler.h b/src/rime/dict/dict_compiler.h index 64c78d9f6..330377261 100644 --- a/src/rime/dict/dict_compiler.h +++ b/src/rime/dict/dict_compiler.h @@ -31,10 +31,10 @@ class DictCompiler { kDump = 4, }; - RIME_API explicit DictCompiler(Dictionary *dictionary); + RIME_API explicit DictCompiler(Dictionary* dictionary); RIME_API virtual ~DictCompiler(); - RIME_API bool Compile(const string &schema_file); + RIME_API bool Compile(const string& schema_file); void set_options(int options) { options_ = options; } private: diff --git a/src/rime/dict/dict_module.cc b/src/rime/dict/dict_module.cc index 90903c87a..7131fa8cf 100644 --- a/src/rime/dict/dict_module.cc +++ b/src/rime/dict/dict_module.cc @@ -31,19 +31,17 @@ static void rime_dict_initialize() { r.Register("userdb", new UserDbComponent); // NOTE: register a legacy_userdb component in your plugin if you wish to // upgrade userdbs from an old file format (eg. TreeDb) during maintenance. - //r.Register("legacy_userdb", ...); + // r.Register("legacy_userdb", ...); r.Register("corrector", new CorrectorComponent); r.Register("dictionary", new DictionaryComponent); - r.Register("reverse_lookup_dictionary", - new ReverseLookupDictionaryComponent); + r.Register("reverse_lookup_dictionary", new ReverseLookupDictionaryComponent); r.Register("user_dictionary", new UserDictionaryComponent); r.Register("userdb_recovery_task", new UserDbRecoveryTaskComponent); } -static void rime_dict_finalize() { -} +static void rime_dict_finalize() {} RIME_REGISTER_MODULE(dict) diff --git a/src/rime/dict/dict_settings.cc b/src/rime/dict/dict_settings.cc index 8ad18dad8..f2438ee49 100644 --- a/src/rime/dict/dict_settings.cc +++ b/src/rime/dict/dict_settings.cc @@ -10,8 +10,7 @@ namespace rime { -DictSettings::DictSettings() { -} +DictSettings::DictSettings() {} bool DictSettings::LoadDictHeader(std::istream& stream) { if (!stream.good()) { @@ -55,7 +54,7 @@ string DictSettings::sort_order() { bool DictSettings::use_preset_vocabulary() { return (*this)["use_preset_vocabulary"].ToBool() || - (*this)["vocabulary"].IsValue(); + (*this)["vocabulary"].IsValue(); } static const string kDefaultVocabulary = "essay"; @@ -99,9 +98,12 @@ an DictSettings::GetTables() { int DictSettings::GetColumnIndex(const string& column_label) { if ((*this)["columns"].IsNull()) { // default - if (column_label == "text") return 0; - if (column_label == "code") return 1; - if (column_label == "weight") return 2; + if (column_label == "text") + return 0; + if (column_label == "code") + return 1; + if (column_label == "weight") + return 2; return -1; } auto columns = (*this)["columns"].AsList(); diff --git a/src/rime/dict/dictionary.cc b/src/rime/dict/dictionary.cc index 0e8c922a9..7a802ebcc 100644 --- a/src/rime/dict/dictionary.cc +++ b/src/rime/dict/dictionary.cc @@ -33,8 +33,13 @@ struct Chunk { Chunk(Table* t, const TableAccessor& a, double cr = 0.0) : Chunk(t, a, string(), cr) {} Chunk(Table* t, const TableAccessor& a, const string& r, double cr = 0.0) - : table(t), code(a.index_code()), entries(a.entry()), - size(a.remaining()), cursor(0), remaining_code(r), credibility(cr) {} + : table(t), + code(a.index_code()), + entries(a.entry()), + size(a.remaining()), + cursor(0), + remaining_code(r), + credibility(cr) {} }; struct QueryResult { @@ -42,16 +47,20 @@ struct QueryResult { }; bool compare_chunk_by_head_element(const Chunk& a, const Chunk& b) { - if (!a.entries || a.cursor >= a.size) return false; - if (!b.entries || b.cursor >= b.size) return true; + if (!a.entries || a.cursor >= a.size) + return false; + if (!b.entries || b.cursor >= b.size) + return true; if (a.remaining_code.length() != b.remaining_code.length()) return a.remaining_code.length() < b.remaining_code.length(); return a.credibility + a.entries[a.cursor].weight > b.credibility + b.entries[b.cursor].weight; // by weight desc } -size_t match_extra_code(const table::Code* extra_code, size_t depth, - const SyllableGraph& syll_graph, size_t current_pos) { +size_t match_extra_code(const table::Code* extra_code, + size_t depth, + const SyllableGraph& syll_graph, + size_t current_pos) { if (!extra_code || depth >= extra_code->size) return current_pos; // success if (current_pos >= syll_graph.interpreted_length) @@ -65,9 +74,10 @@ size_t match_extra_code(const table::Code* extra_code, size_t depth, return 0; size_t best_match = 0; for (const SpellingProperties* props : spellings->second) { - size_t match_end_pos = match_extra_code(extra_code, depth + 1, - syll_graph, props->end_pos); - if (!match_end_pos) continue; + size_t match_end_pos = + match_extra_code(extra_code, depth + 1, syll_graph, props->end_pos); + if (!match_end_pos) + continue; if (match_end_pos > best_match) best_match = match_end_pos; } @@ -87,11 +97,9 @@ void DictEntryIterator::AddChunk(dictionary::Chunk&& chunk) { void DictEntryIterator::Sort() { auto& chunks = query_result_->chunks; // partial-sort remaining chunks, move best match to chunk_index_ - std::partial_sort( - chunks.begin() + chunk_index_, - chunks.begin() + chunk_index_ + 1, - chunks.end(), - dictionary::compare_chunk_by_head_element); + std::partial_sort(chunks.begin() + chunk_index_, + chunks.begin() + chunk_index_ + 1, chunks.end(), + dictionary::compare_chunk_by_head_element); } void DictEntryIterator::AddFilter(DictEntryFilter filter) { @@ -113,7 +121,7 @@ an DictEntryIterator::Peek() { entry_ = New(); entry_->code = chunk.code; entry_->text = chunk.table->GetEntryText(e); - const double kS = 18.420680743952367; // log(1e8) + const double kS = 18.420680743952367; // log(1e8) entry_->weight = e.weight - kS + chunk.credibility; if (!chunk.remaining_code.empty()) { entry_->comment = "~" + chunk.remaining_code; @@ -155,7 +163,8 @@ bool DictEntryIterator::Next() { // Note: does not apply filters bool DictEntryIterator::Skip(size_t num_entries) { while (num_entries > 0) { - if (exhausted()) return false; + if (exhausted()) + return false; auto& chunk = query_result_->chunks[chunk_index_]; if (chunk.cursor + num_entries < chunk.size) { chunk.cursor += num_entries; @@ -171,7 +180,6 @@ bool DictEntryIterator::exhausted() const { return chunk_index_ >= query_result_->chunks.size(); } - // Dictionary members Dictionary::Dictionary(string name, @@ -205,31 +213,29 @@ static void lookup_table(Table* table, do { size_t actual_end_pos = dictionary::match_extra_code( a.extra_code(), 0, syllable_graph, end_pos); - if (actual_end_pos == 0) continue; + if (actual_end_pos == 0) + continue; (*collector)[actual_end_pos].AddChunk( {table, a.code(), a.entry(), cr}); - } - while (a.Next()); - } - else { + } while (a.Next()); + } else { (*collector)[end_pos].AddChunk({table, a, cr}); } } } } -an -Dictionary::Lookup(const SyllableGraph& syllable_graph, - size_t start_pos, - double initial_credibility) { +an Dictionary::Lookup(const SyllableGraph& syllable_graph, + size_t start_pos, + double initial_credibility) { if (!loaded()) return nullptr; auto collector = New(); for (const auto& table : tables_) { if (!table->IsOpen()) continue; - lookup_table(table.get(), collector.get(), - syllable_graph, start_pos, initial_credibility); + lookup_table(table.get(), collector.get(), syllable_graph, start_pos, + initial_credibility); } if (collector->empty()) return nullptr; @@ -250,8 +256,7 @@ size_t Dictionary::LookupWords(DictEntryIterator* result, vector keys; if (predictive) { prism_->ExpandSearch(str_code, &keys, expand_search_limit); - } - else { + } else { Prism::Match match{0, 0}; if (prism_->GetValue(str_code, &match.value)) { keys.push_back(match); @@ -265,7 +270,8 @@ size_t Dictionary::LookupWords(DictEntryIterator* result, SyllableId syllable_id = accessor.syllable_id(); SpellingType type = accessor.properties().type; accessor.Next(); - if (type > kNormalSpelling) continue; + if (type > kNormalSpelling) + continue; string remaining_code; if (match.length > code_length) { string syllable = primary_table()->GetSyllableById(syllable_id); @@ -300,13 +306,13 @@ bool Dictionary::Decode(const Code& code, vector* result) { } bool Dictionary::Exists() const { - return boost::filesystem::exists(prism_->file_name()) && - !tables_.empty() && - boost::filesystem::exists(tables_[0]->file_name()); + return boost::filesystem::exists(prism_->file_name()) && !tables_.empty() && + boost::filesystem::exists(tables_[0]->file_name()); } bool Dictionary::Remove() { - if (loaded()) return false; + if (loaded()) + return false; prism_->Remove(); for (const auto& table : tables_) { table->Remove(); @@ -341,19 +347,14 @@ bool Dictionary::Load() { } bool Dictionary::loaded() const { - return !tables_.empty() && tables_[0]->IsOpen() && - prism_ && prism_->IsOpen(); + return !tables_.empty() && tables_[0]->IsOpen() && prism_ && prism_->IsOpen(); } // DictionaryComponent members -static const ResourceType kPrismResourceType = { - "prism", "", ".prism.bin" -}; +static const ResourceType kPrismResourceType = {"prism", "", ".prism.bin"}; -static const ResourceType kTableResourceType = { - "table", "", ".table.bin" -}; +static const ResourceType kTableResourceType = {"table", "", ".table.bin"}; DictionaryComponent::DictionaryComponent() : prism_resource_resolver_( @@ -363,11 +364,11 @@ DictionaryComponent::DictionaryComponent() Service::instance().CreateDeployedResourceResolver( kTableResourceType)) {} -DictionaryComponent::~DictionaryComponent() { -} +DictionaryComponent::~DictionaryComponent() {} Dictionary* DictionaryComponent::Create(const Ticket& ticket) { - if (!ticket.schema) return nullptr; + if (!ticket.schema) + return nullptr; Config* config = ticket.schema->config(); string dict_name; if (!config->GetString(ticket.name_space + "/dictionary", &dict_name)) { @@ -390,9 +391,7 @@ Dictionary* DictionaryComponent::Create(const Ticket& ticket) { } } } - return Create(std::move(dict_name), - std::move(prism_name), - std::move(packs)); + return Create(std::move(dict_name), std::move(prism_name), std::move(packs)); } Dictionary* DictionaryComponent::Create(string dict_name, @@ -418,10 +417,8 @@ Dictionary* DictionaryComponent::Create(string dict_name, } tables.push_back(std::move(table)); } - return new Dictionary(std::move(dict_name), - std::move(packs), - std::move(tables), - std::move(prism)); + return new Dictionary(std::move(dict_name), std::move(packs), + std::move(tables), std::move(prism)); } } // namespace rime diff --git a/src/rime/dict/dictionary.h b/src/rime/dict/dictionary.h index ede26be2c..99dae4fce 100644 --- a/src/rime/dict/dictionary.h +++ b/src/rime/dict/dictionary.h @@ -28,9 +28,9 @@ class DictEntryIterator : public DictEntryFilterBinder { RIME_API DictEntryIterator(); virtual ~DictEntryIterator() = default; DictEntryIterator(const DictEntryIterator& other) = default; - DictEntryIterator& operator= (const DictEntryIterator& other) = default; + DictEntryIterator& operator=(const DictEntryIterator& other) = default; DictEntryIterator(DictEntryIterator&& other) = default; - DictEntryIterator& operator= (DictEntryIterator&& other) = default; + DictEntryIterator& operator=(DictEntryIterator&& other) = default; void AddChunk(dictionary::Chunk&& chunk); void Sort(); @@ -79,7 +79,8 @@ class Dictionary : public Class { // return num of matching keys. RIME_API size_t LookupWords(DictEntryIterator* result, const string& str_code, - bool predictive, size_t limit = 0); + bool predictive, + size_t limit = 0); // translate syllable id sequence to string code RIME_API bool Decode(const Code& code, vector* result); @@ -105,9 +106,7 @@ class DictionaryComponent : public Dictionary::Component { DictionaryComponent(); ~DictionaryComponent() override; Dictionary* Create(const Ticket& ticket) override; - Dictionary* Create(string dict_name, - string prism_name, - vector packs); + Dictionary* Create(string dict_name, string prism_name, vector packs); private: map> prism_map_; diff --git a/src/rime/dict/entry_collector.cc b/src/rime/dict/entry_collector.cc index 455a4e0e5..968405b90 100644 --- a/src/rime/dict/entry_collector.cc +++ b/src/rime/dict/entry_collector.cc @@ -17,8 +17,7 @@ namespace rime { EntryCollector::EntryCollector() {} EntryCollector::EntryCollector(Syllabary&& fixed_syllabary) - : syllabary(std::move(fixed_syllabary)), - build_syllabary(false) {} + : syllabary(std::move(fixed_syllabary)), build_syllabary(false) {} EntryCollector::~EntryCollector() {} @@ -29,8 +28,7 @@ void EntryCollector::Configure(DictSettings* settings) { if (settings->use_rule_based_encoder()) { encoder.reset(new TableEncoder(this)); - } - else { + } else { encoder.reset(new ScriptEncoder(this)); } encoder->LoadSettings(settings); @@ -78,7 +76,8 @@ void EntryCollector::Collect(const string& dict_file) { while (getline(fin, line)) { boost::algorithm::trim_right(line); // skip empty lines and comments - if (line.empty()) continue; + if (line.empty()) + continue; if (enable_comment && line[0] == '#') { if (line == "# no comment") { // a "# no comment" line disables further comments @@ -97,21 +96,20 @@ void EntryCollector::Collect(const string& dict_file) { string code_str; string weight_str; string stem_str; - if (code_column != -1 && - num_columns > code_column && !row[code_column].empty()) + if (code_column != -1 && num_columns > code_column && + !row[code_column].empty()) code_str = row[code_column]; - if (weight_column != -1 && - num_columns > weight_column && !row[weight_column].empty()) + if (weight_column != -1 && num_columns > weight_column && + !row[weight_column].empty()) weight_str = row[weight_column]; - if (stem_column != -1 && - num_columns > stem_column && !row[stem_column].empty()) + if (stem_column != -1 && num_columns > stem_column && + !row[stem_column].empty()) stem_str = row[stem_column]; // collect entry collection.insert(word); if (!code_str.empty()) { CreateEntry(word, code_str, weight_str); - } - else { + } else { encode_queue.push({word, weight_str}); } if (!stem_str.empty() && !code_str.empty()) { @@ -150,9 +148,9 @@ void EntryCollector::Finish() { LOG(INFO) << "Pass 3: total " << num_entries << " entries collected."; } -void EntryCollector::CreateEntry(const string &word, - const string &code_str, - const string &weight_str) { +void EntryCollector::CreateEntry(const string& word, + const string& code_str, + const string& weight_str) { RawDictEntry e; e.raw_code.FromString(code_str); e.text = word; @@ -164,20 +162,16 @@ void EntryCollector::CreateEntry(const string &word, if (scaled) { double percentage = 100.0; try { - percentage = std::stod( - weight_str.substr(0, weight_str.length() - 1)); - } - catch (...) { + percentage = std::stod(weight_str.substr(0, weight_str.length() - 1)); + } catch (...) { LOG(WARNING) << "invalid entry definition at #" << num_entries << "."; percentage = 100.0; } e.weight *= percentage / 100.0; - } - else if (!weight_str.empty()) { // absolute weight + } else if (!weight_str.empty()) { // absolute weight try { e.weight = std::stod(weight_str); - } - catch (...) { + } catch (...) { LOG(WARNING) << "invalid entry definition at #" << num_entries << "."; e.weight = 0.0; } @@ -189,7 +183,7 @@ void EntryCollector::CreateEntry(const string &word, syllabary.insert(s); } else { LOG(ERROR) << "dropping entry '" << e.text - << "' with invalid syllable: " << s; + << "' with invalid syllable: " << s; return; } } @@ -198,8 +192,8 @@ void EntryCollector::CreateEntry(const string &word, bool is_word = (e.raw_code.size() == 1); if (is_word) { if (words[e.text].find(code_str) != words[e.text].end()) { - LOG(WARNING) << "duplicate word definition '" - << e.text << "': [" << code_str << "]."; + LOG(WARNING) << "duplicate word definition '" << e.text << "': [" + << code_str << "]."; return; } words[e.text][code_str] += e.weight; @@ -209,8 +203,7 @@ void EntryCollector::CreateEntry(const string &word, ++num_entries; } -bool EntryCollector::TranslateWord(const string& word, - vector* result) { +bool EntryCollector::TranslateWord(const string& word, vector* result) { const auto& s = stems.find(word); if (s != stems.end()) { for (const string& stem : s->second) { @@ -220,7 +213,7 @@ bool EntryCollector::TranslateWord(const string& word, } const auto& w = words.find(word); if (w != words.end()) { - for (const auto& v : w->second) { + for (const auto& v : w->second) { const double kMinimalWeight = 0.05; // 5% double min_weight = total_weight[word] * kMinimalWeight; if (v.second < min_weight) @@ -239,10 +232,9 @@ void EntryCollector::Dump(const string& file_name) const { out << "# - " << syllable << std::endl; } out << std::endl; - for (const auto &e : entries) { - out << e->text << '\t' - << e->raw_code.ToString() << '\t' - << e->weight << std::endl; + for (const auto& e : entries) { + out << e->text << '\t' << e->raw_code.ToString() << '\t' << e->weight + << std::endl; } out.close(); } diff --git a/src/rime/dict/entry_collector.h b/src/rime/dict/entry_collector.h index d7842c6b5..b7b610570 100644 --- a/src/rime/dict/entry_collector.h +++ b/src/rime/dict/entry_collector.h @@ -50,15 +50,15 @@ class EntryCollector : public PhraseCollector { // export contents of table and prism to text files void Dump(const string& file_name) const; - void CreateEntry(const string &word, - const string &code_str, - const string &weight_str); - bool TranslateWord(const string& word, - vector* code); + void CreateEntry(const string& word, + const string& code_str, + const string& weight_str); + bool TranslateWord(const string& word, vector* code); + protected: void LoadPresetVocabulary(DictSettings* settings); // call Collect() multiple times for all required tables - void Collect(const string &dict_file); + void Collect(const string& dict_file); // encode all collected entries void Finish(); @@ -66,7 +66,7 @@ class EntryCollector : public PhraseCollector { the preset_vocabulary; the encoder; EncodeQueue encode_queue; - set collection; + set collection; WordMap words; WeightMap total_weight; }; diff --git a/src/rime/dict/level_db.cc b/src/rime/dict/level_db.cc index 859605e57..f17bbad64 100644 --- a/src/rime/dict/level_db.cc +++ b/src/rime/dict/level_db.cc @@ -26,21 +26,13 @@ struct LevelDbCursor { iterator = db->NewIterator(options); } - bool IsValid() const { - return iterator && iterator->Valid(); - } + bool IsValid() const { return iterator && iterator->Valid(); } - string GetKey() const { - return iterator->key().ToString(); - } + string GetKey() const { return iterator->key().ToString(); } - string GetValue() const { - return iterator->value().ToString(); - } + string GetValue() const { return iterator->value().ToString(); } - void Next() { - iterator->Next(); - } + void Next() { iterator->Next(); } bool Jump(const string& key) { if (!iterator) { @@ -71,9 +63,7 @@ struct LevelDbWrapper { ptr = nullptr; } - LevelDbCursor* CreateCursor() { - return new LevelDbCursor(ptr); - } + LevelDbCursor* CreateCursor() { return new LevelDbCursor(ptr); } bool Fetch(const string& key, string* value) { auto status = ptr->Get(leveldb::ReadOptions(), key, value); @@ -98,25 +88,21 @@ struct LevelDbWrapper { return status.ok(); } - void ClearBatch() { - batch.Clear(); - } + void ClearBatch() { batch.Clear(); } bool CommitBatch() { auto status = ptr->Write(leveldb::WriteOptions(), &batch); return status.ok(); } - }; // LevelDbAccessor memebers -LevelDbAccessor::LevelDbAccessor() { -} +LevelDbAccessor::LevelDbAccessor() {} -LevelDbAccessor::LevelDbAccessor(LevelDbCursor* cursor, - const string& prefix) - : DbAccessor(prefix), cursor_(cursor), +LevelDbAccessor::LevelDbAccessor(LevelDbCursor* cursor, const string& prefix) + : DbAccessor(prefix), + cursor_(cursor), is_metadata_query_(prefix == kMetaCharacter) { Reset(); } @@ -157,9 +143,7 @@ bool LevelDbAccessor::exhausted() { LevelDb::LevelDb(const string& file_name, const string& db_name, const string& db_type) - : Db(file_name, db_name), - db_type_(db_type) { -} + : Db(file_name, db_name), db_type_(db_type) {} LevelDb::~LevelDb() { if (loaded()) @@ -226,8 +210,8 @@ bool LevelDb::Restore(const string& snapshot_file) { // TODO(chen): suppose we only use this method for user dbs. bool success = UserDbHelper(this).UniformRestore(snapshot_file); if (!success) { - LOG(ERROR) << "failed to restore db '" << name() - << "' from '" << snapshot_file << "'."; + LOG(ERROR) << "failed to restore db '" << name() << "' from '" + << snapshot_file << "'."; } return success; } @@ -272,8 +256,7 @@ bool LevelDb::Open() { Close(); } } - } - else { + } else { LOG(ERROR) << "Error opening db '" << name() << "': " << status.ToString(); } return loaded_; @@ -307,8 +290,7 @@ bool LevelDb::Close() { } bool LevelDb::CreateMetadata() { - return Db::CreateMetadata() && - MetaUpdate("/db_type", db_type_); + return Db::CreateMetadata() && MetaUpdate("/db_type", db_type_); } bool LevelDb::MetaFetch(const string& key, string* value) { @@ -352,7 +334,6 @@ string UserDbComponent::extension() const { template <> UserDbWrapper::UserDbWrapper(const string& file_name, const string& db_name) - : LevelDb(file_name, db_name, "userdb") { -} + : LevelDb(file_name, db_name, "userdb") {} } // namespace rime diff --git a/src/rime/dict/level_db.h b/src/rime/dict/level_db.h index e63eca934..d597abbd8 100644 --- a/src/rime/dict/level_db.h +++ b/src/rime/dict/level_db.h @@ -19,8 +19,7 @@ class LevelDb; class LevelDbAccessor : public DbAccessor { public: LevelDbAccessor(); - LevelDbAccessor(LevelDbCursor* cursor, - const string& prefix); + LevelDbAccessor(LevelDbCursor* cursor, const string& prefix); virtual ~LevelDbAccessor(); virtual bool Reset(); @@ -33,9 +32,7 @@ class LevelDbAccessor : public DbAccessor { bool is_metadata_query_ = false; }; -class LevelDb : public Db, - public Recoverable, - public Transactional { +class LevelDb : public Db, public Recoverable, public Transactional { public: LevelDb(const string& file_name, const string& db_name, diff --git a/src/rime/dict/mapped_file.cc b/src/rime/dict/mapped_file.cc index bdb9a9876..98539d8e1 100644 --- a/src/rime/dict/mapped_file.cc +++ b/src/rime/dict/mapped_file.cc @@ -20,20 +20,19 @@ #ifdef _WIN32 #include -#define RESIZE_FILE(P,SZ) (resize_file_api(P, SZ) != 0) +#define RESIZE_FILE(P, SZ) (resize_file_api(P, SZ) != 0) static BOOL resize_file_api(const char* p, boost::uintmax_t size) { HANDLE handle = CreateFileA(p, GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); LARGE_INTEGER sz; sz.QuadPart = size; - return handle != INVALID_HANDLE_VALUE - && ::SetFilePointerEx(handle, sz, 0, FILE_BEGIN) - && ::SetEndOfFile(handle) - && ::CloseHandle(handle); + return handle != INVALID_HANDLE_VALUE && + ::SetFilePointerEx(handle, sz, 0, FILE_BEGIN) && + ::SetEndOfFile(handle) && ::CloseHandle(handle); } #else #include -#define RESIZE_FILE(P,SZ) (::truncate(P, SZ) == 0) +#define RESIZE_FILE(P, SZ) (::truncate(P, SZ) == 0) #endif // _WIN32 #endif // BOOST_RESIZE_FILE @@ -51,32 +50,25 @@ class MappedFileImpl { boost::interprocess::mode_t file_mapping_mode = (mode == kOpenReadOnly) ? boost::interprocess::read_only : boost::interprocess::read_write; - file_.reset(new boost::interprocess::file_mapping(file_name.c_str(), file_mapping_mode)); - region_.reset(new boost::interprocess::mapped_region(*file_, file_mapping_mode)); + file_.reset(new boost::interprocess::file_mapping(file_name.c_str(), + file_mapping_mode)); + region_.reset( + new boost::interprocess::mapped_region(*file_, file_mapping_mode)); } ~MappedFileImpl() { region_.reset(); file_.reset(); } - bool Flush() { - return region_->flush(); - } - void* get_address() const { - return region_->get_address(); - } - size_t get_size() const { - return region_->get_size(); - } + bool Flush() { return region_->flush(); } + void* get_address() const { return region_->get_address(); } + size_t get_size() const { return region_->get_size(); } private: the file_; the region_; - }; -MappedFile::MappedFile(const string& file_name) - : file_name_(file_name) { -} +MappedFile::MappedFile(const string& file_name) : file_name_(file_name) {} MappedFile::~MappedFile() { if (file_) { @@ -88,13 +80,12 @@ bool MappedFile::Create(size_t capacity) { if (Exists()) { LOG(INFO) << "overwriting file '" << file_name_ << "'."; Resize(capacity); - } - else { + } else { LOG(INFO) << "creating file '" << file_name_ << "'."; std::filebuf fbuf; - fbuf.open(file_name_.c_str(), - std::ios_base::in | std::ios_base::out | - std::ios_base::trunc | std::ios_base::binary); + fbuf.open(file_name_.c_str(), std::ios_base::in | std::ios_base::out | + std::ios_base::trunc | + std::ios_base::binary); if (capacity > 0) { fbuf.pubseekoff(capacity - 1, std::ios_base::beg); fbuf.sputc(0); @@ -165,8 +156,7 @@ bool MappedFile::Resize(size_t capacity) { Close(); try { RESIZE_FILE(file_name_.c_str(), capacity); - } - catch (...) { + } catch (...) { return false; } return true; diff --git a/src/rime/dict/mapped_file.h b/src/rime/dict/mapped_file.h index a79a41d34..f2ac1ffa7 100644 --- a/src/rime/dict/mapped_file.h +++ b/src/rime/dict/mapped_file.h @@ -25,30 +25,24 @@ class OffsetPtr { OffsetPtr(Offset offset) : offset_(offset) {} OffsetPtr(const T* ptr) : OffsetPtr(to_offset(ptr)) {} OffsetPtr(const OffsetPtr& ptr) : OffsetPtr(ptr.get()) {} - OffsetPtr& operator= (const OffsetPtr& ptr) { + OffsetPtr& operator=(const OffsetPtr& ptr) { offset_ = to_offset(ptr.get()); return *this; } - OffsetPtr& operator= (const T* ptr) { + OffsetPtr& operator=(const T* ptr) { offset_ = to_offset(ptr); return *this; } - operator bool() const { - return !!offset_; - } - T* operator-> () const { - return get(); - } - T& operator* () const { - return *get(); - } - T& operator[] (size_t index) const { - return *(get() + index); - } + operator bool() const { return !!offset_; } + T* operator->() const { return get(); } + T& operator*() const { return *get(); } + T& operator[](size_t index) const { return *(get() + index); } T* get() const { - if (!offset_) return NULL; + if (!offset_) + return NULL; return reinterpret_cast((char*)&offset_ + offset_); } + private: Offset to_offset(const T* ptr) const { return ptr ? (char*)ptr - (char*)(&offset_) : 0; @@ -131,7 +125,7 @@ class MappedFile : boost::noncopyable { // member function definitions -# define RIME_ALIGNED(size, T) ((size + alignof(T) - 1) & ~(alignof(T) - 1)) +#define RIME_ALIGNED(size, T) ((size + alignof(T) - 1) & ~(alignof(T) - 1)) template T* MappedFile::Allocate(size_t count) { @@ -144,7 +138,7 @@ T* MappedFile::Allocate(size_t count) { if (used_space + required_space > file_size) { // not enough space; grow the file size_t new_size = (std::max)(used_space + required_space, file_size * 2); - if(!Resize(new_size) || !OpenReadWrite()) + if (!Resize(new_size) || !OpenReadWrite()) return NULL; } T* ptr = reinterpret_cast(address() + used_space); diff --git a/src/rime/dict/preset_vocabulary.cc b/src/rime/dict/preset_vocabulary.cc index 8fb817b59..cb2512c74 100644 --- a/src/rime/dict/preset_vocabulary.cc +++ b/src/rime/dict/preset_vocabulary.cc @@ -14,9 +14,7 @@ namespace rime { -static const ResourceType kVocabularyResourceType = { - "vocabulary", "", ".txt" -}; +static const ResourceType kVocabularyResourceType = {"vocabulary", "", ".txt"}; struct VocabularyDb : public TextDb { VocabularyDb(const string& path, const string& name); @@ -25,8 +23,7 @@ struct VocabularyDb : public TextDb { }; VocabularyDb::VocabularyDb(const string& path, const string& name) - : TextDb(path, name, kVocabularyResourceType.name, VocabularyDb::format) { -} + : TextDb(path, name, kVocabularyResourceType.name, VocabularyDb::format) {} static bool rime_vocabulary_entry_parser(const Tsv& row, string* key, @@ -42,16 +39,16 @@ static bool rime_vocabulary_entry_parser(const Tsv& row, static bool rime_vocabulary_entry_formatter(const string& key, const string& value, Tsv* tsv) { - //Tsv& row(*tsv); - //row.push_back(key); - //row.push_back(value); + // Tsv& row(*tsv); + // row.push_back(key); + // row.push_back(value); return true; } const TextFormat VocabularyDb::format = { - rime_vocabulary_entry_parser, - rime_vocabulary_entry_formatter, - "Rime vocabulary", + rime_vocabulary_entry_parser, + rime_vocabulary_entry_formatter, + "Rime vocabulary", }; string PresetVocabulary::DictFilePath(const string& vocabulary) { @@ -72,14 +69,13 @@ PresetVocabulary::~PresetVocabulary() { db_->Close(); } -bool PresetVocabulary::GetWeightForEntry(const string &key, double *weight) { +bool PresetVocabulary::GetWeightForEntry(const string& key, double* weight) { string weight_str; if (!db_ || !db_->Fetch(key, &weight_str)) return false; try { *weight = boost::lexical_cast(weight_str); - } - catch (...) { + } catch (...) { return false; } return true; @@ -90,14 +86,13 @@ void PresetVocabulary::Reset() { db_->cursor->Reset(); } -bool PresetVocabulary::GetNextEntry(string *key, string *value) { +bool PresetVocabulary::GetNextEntry(string* key, string* value) { if (!db_ || !db_->cursor) return false; bool got = false; do { got = db_->cursor->GetNextRecord(key, value); - } - while (got && !IsQualifiedPhrase(*key, *value)); + } while (got && !IsQualifiedPhrase(*key, *value)); return got; } diff --git a/src/rime/dict/preset_vocabulary.h b/src/rime/dict/preset_vocabulary.h index ba2634eb8..a45a9e768 100644 --- a/src/rime/dict/preset_vocabulary.h +++ b/src/rime/dict/preset_vocabulary.h @@ -23,8 +23,7 @@ class PresetVocabulary { // traversing void Reset(); bool GetNextEntry(string* key, string* value); - bool IsQualifiedPhrase(const string& phrase, - const string& weight_str); + bool IsQualifiedPhrase(const string& phrase, const string& weight_str); void set_max_phrase_length(int length) { max_phrase_length_ = length; } void set_min_phrase_weight(double weight) { min_phrase_weight_ = weight; } diff --git a/src/rime/dict/prism.cc b/src/rime/dict/prism.cc index e749f0781..61a7476df 100644 --- a/src/rime/dict/prism.cc +++ b/src/rime/dict/prism.cc @@ -43,7 +43,7 @@ bool SpellingAccessor::Next() { if (exhausted()) return false; if (!iter_ || ++iter_ >= end_) - spelling_id_ = -1; + spelling_id_ = -1; return exhausted(); } @@ -70,8 +70,7 @@ SpellingProperties SpellingAccessor::properties() const { } Prism::Prism(const string& file_name) - : MappedFile(file_name), trie_(new Darts::DoubleArray) { -} + : MappedFile(file_name), trie_(new Darts::DoubleArray) {} bool Prism::Load() { LOG(INFO) << "loading prism file: " << file_name(); @@ -137,8 +136,7 @@ bool Prism::Build(const Syllabary& syllabary, keys[key_id] = it->first.c_str(); map_size += it->second.size(); } - } - else { + } else { for (auto it = syllabary.begin(); it != syllabary.end(); ++it, ++key_id) { keys[key_id] = it->c_str(); } @@ -151,7 +149,8 @@ bool Prism::Build(const Syllabary& syllabary, size_t array_size = trie_->size(); size_t image_size = trie_->total_size(); const size_t kDescriptorExtraSize = 12; - size_t estimated_map_size = num_spellings * 12 + + size_t estimated_map_size = + num_spellings * 12 + map_size * (4 + sizeof(prism::SpellingDescriptor) + kDescriptorExtraSize); const size_t kReservedSize = 1024; if (!Create(image_size + estimated_map_size + kReservedSize)) { @@ -250,14 +249,13 @@ bool Prism::GetValue(const string& key, int* value) const { // Given a key, search all the keys in the tree that share // a common prefix with that key. -void Prism::CommonPrefixSearch(const string& key, - vector* result) { +void Prism::CommonPrefixSearch(const string& key, vector* result) { if (!result || key.empty()) return; size_t len = key.length(); result->resize(len); - size_t num_results = trie_->commonPrefixSearch(key.c_str(), - &result->front(), len, len); + size_t num_results = + trie_->commonPrefixSearch(key.c_str(), &result->front(), len, len); result->resize(num_results); } @@ -271,7 +269,7 @@ void Prism::ExpandSearch(const string& key, size_t node_pos = 0; size_t key_pos = 0; int ret = trie_->traverse(key.c_str(), node_pos, key_pos); - //key is not a valid path + // key is not a valid path if (ret == -2) return; if (ret != -1) { @@ -281,23 +279,21 @@ void Prism::ExpandSearch(const string& key, } std::queue q; q.push({key, node_pos}); - while(!q.empty()) { + while (!q.empty()) { node_t node = q.front(); q.pop(); - const char* c = (format_ > 1.0 - DBL_EPSILON) ? metadata_->alphabet - : kDefaultAlphabet; + const char* c = + (format_ > 1.0 - DBL_EPSILON) ? metadata_->alphabet : kDefaultAlphabet; for (; *c; ++c) { string k = node.key + *c; size_t k_pos = node.key.length(); size_t n_pos = node.node_pos; ret = trie_->traverse(k.c_str(), n_pos, k_pos); if (ret <= -2) { - //ignore - } - else if (ret == -1) { + // ignore + } else if (ret == -1) { q.push({k, n_pos}); - } - else { + } else { q.push({k, n_pos}); result->push_back(Match{ret, k_pos}); if (limit && ++count >= limit) diff --git a/src/rime/dict/prism.h b/src/rime/dict/prism.h index c0a120224..be557970c 100644 --- a/src/rime/dict/prism.h +++ b/src/rime/dict/prism.h @@ -79,7 +79,9 @@ class Prism : public MappedFile { RIME_API bool HasKey(const string& key); RIME_API bool GetValue(const string& key, int* value) const; RIME_API void CommonPrefixSearch(const string& key, vector* result); - RIME_API void ExpandSearch(const string& key, vector* result, size_t limit); + RIME_API void ExpandSearch(const string& key, + vector* result, + size_t limit); SpellingAccessor QuerySpelling(SyllableId spelling_id); RIME_API size_t array_size() const; diff --git a/src/rime/dict/reverse_lookup_dictionary.cc b/src/rime/dict/reverse_lookup_dictionary.cc index 40b32f0b0..f12faf7f2 100644 --- a/src/rime/dict/reverse_lookup_dictionary.cc +++ b/src/rime/dict/reverse_lookup_dictionary.cc @@ -28,9 +28,7 @@ const size_t kReverseFormatPrefixLen = sizeof(kReverseFormatPrefix) - 1; static const char* kStemKeySuffix = "\x1fstem"; -ReverseDb::ReverseDb(const string& file_name) - : MappedFile(file_name) { -} +ReverseDb::ReverseDb(const string& file_name) : MappedFile(file_name) {} bool ReverseDb::Load() { LOG(INFO) << "loading reversedb: " << file_name(); @@ -49,8 +47,8 @@ bool ReverseDb::Load() { Close(); return false; } - if (strncmp(metadata_->format, - kReverseFormatPrefix, kReverseFormatPrefixLen)) { + if (strncmp(metadata_->format, kReverseFormatPrefix, + kReverseFormatPrefixLen)) { LOG(ERROR) << "invalid metadata."; Close(); return false; @@ -63,10 +61,10 @@ bool ReverseDb::Load() { return false; } - key_trie_.reset(new StringTable(metadata_->key_trie.get(), - metadata_->key_trie_size)); - value_trie_.reset(new StringTable(metadata_->value_trie.get(), - metadata_->value_trie_size)); + key_trie_.reset( + new StringTable(metadata_->key_trie.get(), metadata_->key_trie_size)); + value_trie_.reset( + new StringTable(metadata_->value_trie.get(), metadata_->value_trie_size)); return true; } @@ -138,10 +136,9 @@ bool ReverseDb::Build(DictSettings* settings, const size_t kReservedSize = 1024; size_t key_trie_image_size = key_trie_builder.BinarySize(); size_t value_trie_image_size = value_trie_builder.BinarySize(); - size_t estimated_data_size = kReservedSize + - dict_settings.length() + - entry_count * sizeof(StringId) + - key_trie_image_size + value_trie_image_size; + size_t estimated_data_size = kReservedSize + dict_settings.length() + + entry_count * sizeof(StringId) + + key_trie_image_size + value_trie_image_size; if (!Create(estimated_data_size)) { LOG(ERROR) << "Error creating prism file '" << file_name() << "'."; return false; @@ -155,7 +152,7 @@ bool ReverseDb::Build(DictSettings* settings, } metadata_->dict_file_checksum = dict_file_checksum; if (!dict_settings.empty()) { - if(!CopyString(dict_settings, &metadata_->dict_settings)) { + if (!CopyString(dict_settings, &metadata_->dict_settings)) { LOG(ERROR) << "Error saving dict settings."; return false; } @@ -206,9 +203,7 @@ uint32_t ReverseDb::dict_file_checksum() const { return metadata_ ? metadata_->dict_file_checksum : 0; } -ReverseLookupDictionary::ReverseLookupDictionary(an db) - : db_(db) { -} +ReverseLookupDictionary::ReverseLookupDictionary(an db) : db_(db) {} bool ReverseLookupDictionary::Load() { return db_ && (db_->IsOpen() || db_->Load()); @@ -217,11 +212,9 @@ bool ReverseLookupDictionary::Load() { bool ReverseLookupDictionary::ReverseLookup(const string& text, string* result) { return db_->Lookup(text, result); - } -bool ReverseLookupDictionary::LookupStems(const string& text, - string* result) { +bool ReverseLookupDictionary::LookupStems(const string& text, string* result) { return db_->Lookup(text + kStemKeySuffix, result); } @@ -239,18 +232,15 @@ an ReverseLookupDictionary::GetDictSettings() { return settings; } -static const ResourceType kReverseDbResourceType = { - "reverse_db", "", ".reverse.bin" -}; +static const ResourceType kReverseDbResourceType = {"reverse_db", "", + ".reverse.bin"}; ReverseLookupDictionaryComponent::ReverseLookupDictionaryComponent() - : resource_resolver_( - Service::instance().CreateDeployedResourceResolver( - kReverseDbResourceType)) { -} + : resource_resolver_(Service::instance().CreateDeployedResourceResolver( + kReverseDbResourceType)) {} -ReverseLookupDictionary* -ReverseLookupDictionaryComponent::Create(const string& dict_name) { +ReverseLookupDictionary* ReverseLookupDictionaryComponent::Create( + const string& dict_name) { auto db = db_pool_[dict_name].lock(); if (!db) { auto file_path = resource_resolver_->ResolvePath(dict_name).string(); @@ -260,13 +250,13 @@ ReverseLookupDictionaryComponent::Create(const string& dict_name) { return new ReverseLookupDictionary(db); }; -ReverseLookupDictionary* -ReverseLookupDictionaryComponent::Create(const Ticket& ticket) { - if (!ticket.schema) return NULL; +ReverseLookupDictionary* ReverseLookupDictionaryComponent::Create( + const Ticket& ticket) { + if (!ticket.schema) + return NULL; Config* config = ticket.schema->config(); string dict_name; - if (!config->GetString(ticket.name_space + "/dictionary", - &dict_name)) { + if (!config->GetString(ticket.name_space + "/dictionary", &dict_name)) { // missing! return NULL; } diff --git a/src/rime/dict/reverse_lookup_dictionary.h b/src/rime/dict/reverse_lookup_dictionary.h index 58632381e..007fa9769 100644 --- a/src/rime/dict/reverse_lookup_dictionary.h +++ b/src/rime/dict/reverse_lookup_dictionary.h @@ -80,6 +80,7 @@ class ReverseLookupDictionaryComponent ReverseLookupDictionaryComponent(); ReverseLookupDictionary* Create(const Ticket& ticket); ReverseLookupDictionary* Create(const string& dict_name); + private: map> db_pool_; the resource_resolver_; diff --git a/src/rime/dict/string_table.cc b/src/rime/dict/string_table.cc index 871204fe8..c3b68efed 100644 --- a/src/rime/dict/string_table.cc +++ b/src/rime/dict/string_table.cc @@ -25,10 +25,9 @@ bool StringTable::HasKey(const string& key) { StringId StringTable::Lookup(const string& key) { marisa::Agent agent; agent.set_query(key.c_str()); - if(trie_.lookup(agent)) { + if (trie_.lookup(agent)) { return agent.key().id(); - } - else { + } else { return kInvalidStringId; } } @@ -43,8 +42,7 @@ void StringTable::CommonPrefixMatch(const string& query, } } -void StringTable::Predict(const string& query, - vector* result) { +void StringTable::Predict(const string& query, vector* result) { marisa::Agent agent; agent.set_query(query.c_str()); result->clear(); @@ -58,8 +56,7 @@ string StringTable::GetString(StringId string_id) { agent.set_query(string_id); try { trie_.reverse_lookup(agent); - } - catch (const marisa::Exception& /*ex*/) { + } catch (const marisa::Exception& /*ex*/) { LOG(ERROR) << "invalid id for string table: " << string_id; return string(); } diff --git a/src/rime/dict/string_table.h b/src/rime/dict/string_table.h index 6aa067e7a..d9c70b6e5 100644 --- a/src/rime/dict/string_table.h +++ b/src/rime/dict/string_table.h @@ -26,10 +26,8 @@ class StringTable { bool HasKey(const string& key); StringId Lookup(const string& key); - void CommonPrefixMatch(const string& query, - vector* result); - void Predict(const string& query, - vector* result); + void CommonPrefixMatch(const string& query, vector* result); + void Predict(const string& query, vector* result); string GetString(StringId string_id); size_t NumKeys() const; @@ -39,9 +37,10 @@ class StringTable { marisa::Trie trie_; }; -class StringTableBuilder: public StringTable { +class StringTableBuilder : public StringTable { public: - void Add(const string& key, double weight = 1.0, + void Add(const string& key, + double weight = 1.0, StringId* reference = nullptr); void Clear(); void Build(); diff --git a/src/rime/dict/table.cc b/src/rime/dict/table.cc index f0059c240..a750d12fe 100644 --- a/src/rime/dict/table.cc +++ b/src/rime/dict/table.cc @@ -23,12 +23,9 @@ const size_t kTableFormatPrefixLen = sizeof(kTableFormatPrefix) - 1; class TableQuery { public: - TableQuery(table::Index* index) : lv1_index_(index) { - Reset(); - } + TableQuery(table::Index* index) : lv1_index_(index) { Reset(); } - TableAccessor Access(SyllableId syllable_id, - double credibility = 0.0) const; + TableAccessor Access(SyllableId syllable_id, double credibility = 0.0) const; // down to next level bool Advance(SyllableId syllable_id, double credibility = 0.0); @@ -61,8 +58,7 @@ TableAccessor::TableAccessor(const Code& index_code, : index_code_(index_code), entries_(list->at.get()), size_(list->size), - credibility_(credibility) { -} + credibility_(credibility) {} TableAccessor::TableAccessor(const Code& index_code, const Array* array, @@ -70,8 +66,7 @@ TableAccessor::TableAccessor(const Code& index_code, : index_code_(index_code), entries_(array->at), size_(array->size), - credibility_(credibility) { -} + credibility_(credibility) {} TableAccessor::TableAccessor(const Code& index_code, const table::TailIndex* code_map, @@ -79,8 +74,7 @@ TableAccessor::TableAccessor(const Code& index_code, : index_code_(index_code), long_entries_(code_map->at), size_(code_map->size), - credibility_(credibility) { -} + credibility_(credibility) {} bool TableAccessor::exhausted() const { if (entries_ || long_entries_) { @@ -174,16 +168,14 @@ static table::TrunkIndexNode* find_node(table::TrunkIndexNode* first, bool TableQuery::Walk(SyllableId syllable_id) { if (level_ == 0) { - if (!lv1_index_ || - syllable_id < 0 || + if (!lv1_index_ || syllable_id < 0 || syllable_id >= static_cast(lv1_index_->size)) return false; auto node = &lv1_index_->at[syllable_id]; if (!node->next_level) return false; lv2_index_ = &node->next_level->trunk(); - } - else if (level_ == 1) { + } else if (level_ == 1) { if (!lv2_index_) return false; auto node = find_node(lv2_index_->begin(), lv2_index_->end(), syllable_id); @@ -192,8 +184,7 @@ bool TableQuery::Walk(SyllableId syllable_id) { if (!node->next_level) return false; lv3_index_ = &node->next_level->trunk(); - } - else if (level_ == 2) { + } else if (level_ == 2) { if (!lv3_index_) return false; auto node = find_node(lv3_index_->begin(), lv3_index_->end(), syllable_id); @@ -202,8 +193,7 @@ bool TableQuery::Walk(SyllableId syllable_id) { if (!node->next_level) return false; lv4_index_ = &node->next_level->tail(); - } - else { + } else { return false; } return true; @@ -218,25 +208,22 @@ TableAccessor TableQuery::Access(SyllableId syllable_id, double credibility) const { credibility += credibility_.back(); if (level_ == 0) { - if (!lv1_index_ || - syllable_id < 0 || + if (!lv1_index_ || syllable_id < 0 || syllable_id >= static_cast(lv1_index_->size)) return TableAccessor(); auto node = &lv1_index_->at[syllable_id]; - return TableAccessor(add_syllable(index_code_, syllable_id), - &node->entries, credibility); - } - else if (level_ == 1 || level_ == 2) { + return TableAccessor(add_syllable(index_code_, syllable_id), &node->entries, + credibility); + } else if (level_ == 1 || level_ == 2) { auto index = (level_ == 1) ? lv2_index_ : lv3_index_; if (!index) return TableAccessor(); auto node = find_node(index->begin(), index->end(), syllable_id); if (node == index->end()) return TableAccessor(); - return TableAccessor(add_syllable(index_code_, syllable_id), - &node->entries, credibility); - } - else if (level_ == 3) { + return TableAccessor(add_syllable(index_code_, syllable_id), &node->entries, + credibility); + } else if (level_ == 3) { if (!lv4_index_) return TableAccessor(); return TableAccessor(index_code_, lv4_index_, credibility); @@ -257,7 +244,8 @@ string Table::GetString(const table::StringType& x) { return string_table_->GetString(x.str_id()); } -bool Table::AddString(const string& src, table::StringType* dest, +bool Table::AddString(const string& src, + table::StringType* dest, double weight) { string_table_builder_->Add(src, weight, &dest->str_id()); return true; @@ -289,11 +277,9 @@ bool Table::OnLoad() { return true; } -Table::Table(const string& file_name) : MappedFile(file_name) { -} +Table::Table(const string& file_name) : MappedFile(file_name) {} -Table::~Table() { -} +Table::~Table() {} bool Table::Load() { LOG(INFO) << "loading table file: " << file_name(); @@ -356,11 +342,14 @@ uint32_t Table::dict_file_checksum() const { return metadata_ ? metadata_->dict_file_checksum : 0; } -bool Table::Build(const Syllabary& syllabary, const Vocabulary& vocabulary, - size_t num_entries, uint32_t dict_file_checksum) { +bool Table::Build(const Syllabary& syllabary, + const Vocabulary& vocabulary, + size_t num_entries, + uint32_t dict_file_checksum) { const size_t kReservedSize = 4096; size_t num_syllables = syllabary.size(); - size_t estimated_file_size = kReservedSize + 32 * num_syllables + 64 * num_entries; + size_t estimated_file_size = + kReservedSize + 32 * num_syllables + 64 * num_entries; LOG(INFO) << "building table."; LOG(INFO) << "num syllables: " << num_syllables; LOG(INFO) << "num entries: " << num_entries; @@ -389,8 +378,7 @@ bool Table::Build(const Syllabary& syllabary, const Vocabulary& vocabulary, if (!syllabary_) { LOG(ERROR) << "Error creating syllabary."; return false; - } - else { + } else { size_t i = 0; for (const string& syllable : syllabary) { AddString(syllable, &syllabary_->at[i++], 0.0); @@ -418,8 +406,8 @@ bool Table::Build(const Syllabary& syllabary, const Vocabulary& vocabulary, table::Index* Table::BuildIndex(const Vocabulary& vocabulary, size_t num_syllables) { - return reinterpret_cast(BuildHeadIndex(vocabulary, - num_syllables)); + return reinterpret_cast( + BuildHeadIndex(vocabulary, num_syllables)); } table::HeadIndex* Table::BuildHeadIndex(const Vocabulary& vocabulary, @@ -433,7 +421,7 @@ table::HeadIndex* Table::BuildHeadIndex(const Vocabulary& vocabulary, auto& node(index->at[syllable_id]); const auto& entries(v.second.entries); if (!BuildEntryList(entries, &node.entries)) { - return NULL; + return NULL; } if (v.second.next_level) { Code code; @@ -461,7 +449,7 @@ table::TrunkIndex* Table::BuildTrunkIndex(const Code& prefix, node.key = syllable_id; const auto& entries(v.second.entries); if (!BuildEntryList(entries, &node.entries)) { - return NULL; + return NULL; } if (v.second.next_level) { Code code(prefix); @@ -473,8 +461,7 @@ table::TrunkIndex* Table::BuildTrunkIndex(const Code& prefix, } node.next_level = reinterpret_cast(next_level_index); - } - else { + } else { auto tail_index = BuildTailIndex(code, *v.second.next_level); if (!tail_index) { return NULL; @@ -510,8 +497,7 @@ table::TailIndex* Table::BuildTailIndex(const Code& prefix, LOG(ERROR) << "Error creating code sequence; file size: " << file_size(); return NULL; } - std::copy(src->code.begin() + Code::kIndexCodeMaxLength, - src->code.end(), + std::copy(src->code.begin() + Code::kIndexCodeMaxLength, src->code.end(), dest.extra_code.begin()); BuildEntry(*src, &dest.entry); } @@ -570,8 +556,7 @@ bool Table::GetSyllabary(Syllabary* result) { return true; } string Table::GetSyllableById(SyllableId syllable_id) { - if (!syllabary_ || - syllable_id < 0 || + if (!syllabary_ || syllable_id < 0 || syllable_id >= static_cast(syllabary_->size)) return string(); return GetString(syllabary_->at[syllable_id]); @@ -595,11 +580,10 @@ TableAccessor Table::QueryPhrases(const Code& code) { return query.Access(-1); } -bool Table::Query(const SyllableGraph& syll_graph, size_t start_pos, +bool Table::Query(const SyllableGraph& syll_graph, + size_t start_pos, TableQueryResult* result) { - if (!result || - !index_ || - start_pos >= syll_graph.interpreted_length) + if (!result || !index_ || start_pos >= syll_graph.interpreted_length) return false; result->clear(); std::queue> q; diff --git a/src/rime/dict/table.h b/src/rime/dict/table.h index 1e4c018c4..ea87d92eb 100644 --- a/src/rime/dict/table.h +++ b/src/rime/dict/table.h @@ -15,26 +15,24 @@ #include #include -#define RIME_TABLE_UNION(U, V, A, a, B, b) \ - struct U { \ - V value; \ - const A& a() const { return *reinterpret_cast(this); } \ - const B& b() const { return *reinterpret_cast(this); } \ - A& a() { return *reinterpret_cast(this); } \ - B& b() { return *reinterpret_cast(this); } \ - } +#define RIME_TABLE_UNION(U, V, A, a, B, b) \ + struct U { \ + V value; \ + const A& a() const { return *reinterpret_cast(this); } \ + const B& b() const { return *reinterpret_cast(this); } \ + A& a() { return *reinterpret_cast(this); } \ + B& b() { return *reinterpret_cast(this); } \ + } namespace rime { namespace table { -//union StringType { -// String str; -// StringId str_id; -//}; -RIME_TABLE_UNION(StringType, int32_t, - String, str, - StringId, str_id); +// union StringType { +// String str; +// StringId str_id; +// }; +RIME_TABLE_UNION(StringType, int32_t, String, str, StringId, str_id); using Syllabary = Array; @@ -71,13 +69,11 @@ using TrunkIndex = Array; using TailIndex = Array; -//union PhraseIndex { -// TrunkIndex trunk; -// TailIndex tail; -//}; -RIME_TABLE_UNION(PhraseIndex, Array, - TrunkIndex, trunk, - TailIndex, tail); +// union PhraseIndex { +// TrunkIndex trunk; +// TailIndex tail; +// }; +RIME_TABLE_UNION(PhraseIndex, Array, TrunkIndex, trunk, TailIndex, tail); using Index = HeadIndex; @@ -101,11 +97,14 @@ struct Metadata { class TableAccessor { public: TableAccessor() = default; - TableAccessor(const Code& index_code, const List* entries, + TableAccessor(const Code& index_code, + const List* entries, double credibility = 0.0); - TableAccessor(const Code& index_code, const Array* entries, + TableAccessor(const Code& index_code, + const Array* entries, double credibility = 0.0); - TableAccessor(const Code& index_code, const table::TailIndex* code_map, + TableAccessor(const Code& index_code, + const table::TailIndex* code_map, double credibility = 0.0); RIME_API bool Next(); @@ -156,23 +155,22 @@ class Table : public MappedFile { uint32_t dict_file_checksum() const; private: - table::Index* BuildIndex(const Vocabulary& vocabulary, - size_t num_syllables); + table::Index* BuildIndex(const Vocabulary& vocabulary, size_t num_syllables); table::HeadIndex* BuildHeadIndex(const Vocabulary& vocabulary, size_t num_syllables); table::TrunkIndex* BuildTrunkIndex(const Code& prefix, const Vocabulary& vocabulary); table::TailIndex* BuildTailIndex(const Code& prefix, const Vocabulary& vocabulary); - bool BuildPhraseIndex(Code code, const Vocabulary& vocabulary, + bool BuildPhraseIndex(Code code, + const Vocabulary& vocabulary, map* index_data); Array* BuildEntryArray(const ShortDictEntryList& entries); bool BuildEntryList(const ShortDictEntryList& src, List* dest); bool BuildEntry(const ShortDictEntry& dict_entry, table::Entry* entry); string GetString(const table::StringType& x); - bool AddString(const string& src, table::StringType* dest, - double weight); + bool AddString(const string& src, table::StringType* dest, double weight); bool OnBuildStart(); bool OnBuildFinish(); bool OnLoad(); diff --git a/src/rime/dict/table_db.cc b/src/rime/dict/table_db.cc index 611a55161..0b92ba2e5 100644 --- a/src/rime/dict/table_db.cc +++ b/src/rime/dict/table_db.cc @@ -19,8 +19,7 @@ namespace rime { static bool rime_table_entry_parser(const Tsv& row, string* key, string* value) { - if (row.size() < 2 || - row[0].empty() || row[1].empty()) { + if (row.size() < 2 || row[0].empty() || row[1].empty()) { return false; } string code(row[1]); @@ -32,8 +31,7 @@ static bool rime_table_entry_parser(const Tsv& row, v.commits = boost::lexical_cast(row[2]); const double kS = 1e8; v.dee = (v.commits + 1) / kS; - } - catch (...) { + } catch (...) { } } *value = v.Pack(); @@ -45,10 +43,8 @@ static bool rime_table_entry_formatter(const string& key, Tsv* tsv) { Tsv& row(*tsv); // key ::= code phrase - boost::algorithm::split(row, key, - boost::algorithm::is_any_of("\t")); - if (row.size() != 2 || - row[0].empty() || row[1].empty()) + boost::algorithm::split(row, key, boost::algorithm::is_any_of("\t")); + if (row.size() != 2 || row[0].empty() || row[1].empty()) return false; UserDbValue v(value); if (v.commits < 0) // deleted entry @@ -60,20 +56,20 @@ static bool rime_table_entry_formatter(const string& key, } const TextFormat TableDb::format = { - rime_table_entry_parser, - rime_table_entry_formatter, - "Rime table", + rime_table_entry_parser, + rime_table_entry_formatter, + "Rime table", }; TableDb::TableDb(const string& file_name, const string& db_name) - : TextDb(file_name, db_name, "tabledb", TableDb::format) { -} + : TextDb(file_name, db_name, "tabledb", TableDb::format) {} StableDb::StableDb(const string& file_name, const string& db_name) : TableDb(file_name, db_name) {} bool StableDb::Open() { - if (loaded()) return false; + if (loaded()) + return false; if (!Exists()) { LOG(INFO) << "stabledb '" << name() << "' does not exist."; return false; diff --git a/src/rime/dict/text_db.cc b/src/rime/dict/text_db.cc index c5f5b5c89..4e5ef9c4b 100644 --- a/src/rime/dict/text_db.cc +++ b/src/rime/dict/text_db.cc @@ -11,14 +11,12 @@ namespace rime { // TextDbAccessor memebers -TextDbAccessor::TextDbAccessor(const TextDbData& data, - const string& prefix) +TextDbAccessor::TextDbAccessor(const TextDbData& data, const string& prefix) : DbAccessor(prefix), data_(data) { Reset(); } -TextDbAccessor::~TextDbAccessor() { -} +TextDbAccessor::~TextDbAccessor() {} bool TextDbAccessor::Reset() { iter_ = prefix_.empty() ? data_.begin() : data_.lower_bound(prefix_); @@ -49,8 +47,7 @@ TextDb::TextDb(const string& file_name, const string& db_name, const string& db_type, TextFormat format) - : Db(file_name, db_name), db_type_(db_type), format_(format) { -} + : Db(file_name, db_name), db_type_(db_type), format_(format) {} TextDb::~TextDb() { if (loaded()) @@ -116,8 +113,7 @@ bool TextDb::Open() { Close(); } } - } - else { + } else { LOG(ERROR) << "Error opening db '" << name() << "'."; } modified_ = false; @@ -132,8 +128,7 @@ bool TextDb::OpenReadOnly() { loaded_ = Exists() && LoadFromFile(file_name()); if (loaded_) { readonly_ = true; - } - else { + } else { LOG(ERROR) << "Error opening db '" << name_ << "' read-only."; } modified_ = false; @@ -141,7 +136,8 @@ bool TextDb::OpenReadOnly() { } bool TextDb::Close() { - if (!loaded()) return false; + if (!loaded()) + return false; if (modified_ && !SaveToFile(file_name())) { return false; } @@ -173,8 +169,8 @@ bool TextDb::Restore(const string& snapshot_file) { if (!loaded() || readonly()) return false; if (!LoadFromFile(snapshot_file)) { - LOG(ERROR) << "failed to restore db '" << name() - << "' from '" << snapshot_file << "'."; + LOG(ERROR) << "failed to restore db '" << name() << "' from '" + << snapshot_file << "'."; return false; } modified_ = false; @@ -182,8 +178,7 @@ bool TextDb::Restore(const string& snapshot_file) { } bool TextDb::CreateMetadata() { - return Db::CreateMetadata() && - MetaUpdate("/db_type", db_type_); + return Db::CreateMetadata() && MetaUpdate("/db_type", db_type_); } bool TextDb::MetaFetch(const string& key, string* value) { @@ -212,8 +207,7 @@ bool TextDb::LoadFromFile(const string& file) { int entries = 0; try { entries = reader >> sink; - } - catch (std::exception& ex) { + } catch (std::exception& ex) { LOG(ERROR) << ex.what(); return false; } @@ -228,8 +222,7 @@ bool TextDb::SaveToFile(const string& file) { int entries = 0; try { entries = writer << source; - } - catch (std::exception& ex) { + } catch (std::exception& ex) { LOG(ERROR) << ex.what(); return false; } diff --git a/src/rime/dict/tsv.cc b/src/rime/dict/tsv.cc index 7fe6b3332..733d1958c 100644 --- a/src/rime/dict/tsv.cc +++ b/src/rime/dict/tsv.cc @@ -12,8 +12,9 @@ namespace rime { -int TsvReader::operator() (Sink* sink) { - if (!sink) return 0; +int TsvReader::operator()(Sink* sink) { + if (!sink) + return 0; LOG(INFO) << "reading tsv file: " << path_; std::ifstream fin(path_.c_str()); string line, key, value; @@ -25,29 +26,25 @@ int TsvReader::operator() (Sink* sink) { ++line_no; boost::algorithm::trim_right(line); // skip empty lines and comments - if (line.empty()) continue; + if (line.empty()) + continue; if (enable_comment && line[0] == '#') { if (boost::starts_with(line, "#@")) { // metadata line.erase(0, 2); - boost::algorithm::split(row, line, - boost::algorithm::is_any_of("\t")); - if (row.size() != 2 || - !sink->MetaPut(row[0], row[1])) { + boost::algorithm::split(row, line, boost::algorithm::is_any_of("\t")); + if (row.size() != 2 || !sink->MetaPut(row[0], row[1])) { LOG(WARNING) << "invalid metadata at line " << line_no << "."; } - } - else if (line == "# no comment") { + } else if (line == "# no comment") { // a "# no comment" line disables further comments enable_comment = false; } continue; } // read a tsv entry - boost::algorithm::split(row, line, - boost::algorithm::is_any_of("\t")); - if (!parser_(row, &key, &value) || - !sink->Put(key, value)) { + boost::algorithm::split(row, line, boost::algorithm::is_any_of("\t")); + if (!parser_(row, &key, &value) || !sink->Put(key, value)) { LOG(WARNING) << "invalid entry at line " << line_no << "."; continue; } @@ -57,8 +54,9 @@ int TsvReader::operator() (Sink* sink) { return num_entries; } -int TsvWriter::operator() (Source* source) { - if (!source) return 0; +int TsvWriter::operator()(Source* source) { + if (!source) + return 0; LOG(INFO) << "writing tsv file: " << path_; std::ofstream fout(path_.c_str()); if (!file_description.empty()) { diff --git a/src/rime/dict/tsv.h b/src/rime/dict/tsv.h index d3a6852dd..2b82394e4 100644 --- a/src/rime/dict/tsv.h +++ b/src/rime/dict/tsv.h @@ -7,18 +7,14 @@ #ifndef RIME_TSV_H_ #define RIME_TSV_H_ - namespace rime { using Tsv = vector; -using TsvParser = function; +using TsvParser = function; -using TsvFormatter = function; +using TsvFormatter = + function; class Sink; class Source; @@ -26,10 +22,10 @@ class Source; class TsvReader { public: TsvReader(const string& path, TsvParser parser) - : path_(path), parser_(parser) { - } + : path_(path), parser_(parser) {} // return number of records read - int operator() (Sink* sink); + int operator()(Sink* sink); + protected: string path_; TsvParser parser_; @@ -38,34 +34,35 @@ class TsvReader { class TsvWriter { public: TsvWriter(const string& path, TsvFormatter formatter) - : path_(path), formatter_(formatter) { - } + : path_(path), formatter_(formatter) {} // return number of records written - int operator() (Source* source); + int operator()(Source* source); + protected: string path_; TsvFormatter formatter_; + public: string file_description; }; template -int operator<< (SinkType& sink, TsvReader& reader) { +int operator<<(SinkType& sink, TsvReader& reader) { return reader(&sink); } template -int operator>> (TsvReader& reader, SinkType& sink) { +int operator>>(TsvReader& reader, SinkType& sink) { return reader(&sink); } template -int operator<< (TsvWriter& writer, SourceType& source) { +int operator<<(TsvWriter& writer, SourceType& source) { return writer(&source); } template -int operator>> (SourceType& source, TsvWriter& writer) { +int operator>>(SourceType& source, TsvWriter& writer) { return writer(&source); } diff --git a/src/rime/dict/user_db.cc b/src/rime/dict/user_db.cc index c35efac33..22b448051 100644 --- a/src/rime/dict/user_db.cc +++ b/src/rime/dict/user_db.cc @@ -20,8 +20,7 @@ UserDbValue::UserDbValue(const string& value) { } string UserDbValue::Pack() const { - return boost::str(boost::format("c=%1% d=%2% t=%3%") % - commits % dee % tick); + return boost::str(boost::format("c=%1% d=%2% t=%3%") % commits % dee % tick); } bool UserDbValue::Unpack(const string& value) { @@ -36,17 +35,14 @@ bool UserDbValue::Unpack(const string& value) { try { if (k == "c") { commits = boost::lexical_cast(v); - } - else if (k == "d") { + } else if (k == "d") { dee = (std::min)(10000.0, boost::lexical_cast(v)); - } - else if (k == "t") { + } else if (k == "t") { tick = boost::lexical_cast(v); } - } - catch (...) { - LOG(ERROR) << "failed in parsing key-value from userdb entry '" - << k_eq_v << "'."; + } catch (...) { + LOG(ERROR) << "failed in parsing key-value from userdb entry '" << k_eq_v + << "'."; return false; } } @@ -66,11 +62,8 @@ string UserDb::snapshot_extension() { // key ::= code phrase -static bool userdb_entry_parser(const Tsv& row, - string* key, - string* value) { - if (row.size() < 2 || - row[0].empty() || row[1].empty()) { +static bool userdb_entry_parser(const Tsv& row, string* key, string* value) { + if (row.size() < 2 || row[0].empty() || row[1].empty()) { return false; } string code(row[0]); @@ -89,26 +82,23 @@ static bool userdb_entry_formatter(const string& key, const string& value, Tsv* tsv) { Tsv& row(*tsv); - boost::algorithm::split(row, key, - boost::algorithm::is_any_of("\t")); - if (row.size() != 2 || - row[0].empty() || row[1].empty()) + boost::algorithm::split(row, key, boost::algorithm::is_any_of("\t")); + if (row.size() != 2 || row[0].empty() || row[1].empty()) return false; row.push_back(value); return true; } static TextFormat plain_userdb_format = { - userdb_entry_parser, - userdb_entry_formatter, - "Rime user dictionary", + userdb_entry_parser, + userdb_entry_formatter, + "Rime user dictionary", }; template <> UserDbWrapper::UserDbWrapper(const string& file_name, const string& db_name) - : TextDb(file_name, db_name, "userdb", plain_userdb_format) { -} + : TextDb(file_name, db_name, "userdb", plain_userdb_format) {} bool UserDbHelper::UpdateUserInfo() { Deployer& deployer(Service::instance().deployer()); @@ -120,15 +110,13 @@ bool UserDbHelper::IsUniformFormat(const string& file_name) { } bool UserDbHelper::UniformBackup(const string& snapshot_file) { - LOG(INFO) << "backing up userdb '" << db_->name() << "' to " - << snapshot_file; + LOG(INFO) << "backing up userdb '" << db_->name() << "' to " << snapshot_file; TsvWriter writer(snapshot_file, plain_userdb_format.formatter); writer.file_description = plain_userdb_format.file_description; DbSource source(db_); try { writer << source; - } - catch (std::exception& ex) { + } catch (std::exception& ex) { LOG(ERROR) << ex.what(); return false; } @@ -142,8 +130,7 @@ bool UserDbHelper::UniformRestore(const string& snapshot_file) { DbSink sink(db_); try { reader >> sink; - } - catch (std::exception& ex) { + } catch (std::exception& ex) { LOG(ERROR) << ex.what(); return false; } @@ -184,8 +171,7 @@ static TickCount get_tick_count(Db* db) { if (db && db->MetaFetch("/tick", &tick)) { try { return boost::lexical_cast(tick); - } - catch (...) { + } catch (...) { } } return 1; @@ -206,15 +192,15 @@ bool UserDbMerger::MetaPut(const string& key, const string& value) { try { their_tick_ = boost::lexical_cast(value); max_tick_ = (std::max)(our_tick_, their_tick_); - } - catch (...) { + } catch (...) { } } return true; } bool UserDbMerger::Put(const string& key, const string& value) { - if (!db_) return false; + if (!db_) + return false; UserDbValue v(value); if (v.tick < their_tick_) { v.dee = algo::formula_d(0, (double)their_tick_, v.dee, (double)v.tick); @@ -228,7 +214,7 @@ bool UserDbMerger::Put(const string& key, const string& value) { o.dee = algo::formula_d(0, (double)our_tick_, o.dee, (double)o.tick); } if (std::abs(o.commits) < std::abs(v.commits)) - o.commits = v.commits; + o.commits = v.commits; o.dee = (std::max)(o.dee, v.dee); o.tick = max_tick_; return db_->Update(key, o.Pack()) && ++merged_entries_; @@ -241,26 +227,24 @@ void UserDbMerger::CloseMerge() { try { db_->MetaUpdate("/tick", boost::lexical_cast(max_tick_)); db_->MetaUpdate("/user_id", deployer.user_id); - } - catch (...) { + } catch (...) { LOG(ERROR) << "failed to update tick count."; return; } - LOG(INFO) << "total " << merged_entries_ << " entries merged, tick = " - << max_tick_; + LOG(INFO) << "total " << merged_entries_ + << " entries merged, tick = " << max_tick_; merged_entries_ = 0; } -UserDbImporter::UserDbImporter(Db* db) - : db_(db) { -} +UserDbImporter::UserDbImporter(Db* db) : db_(db) {} bool UserDbImporter::MetaPut(const string& key, const string& value) { return true; } bool UserDbImporter::Put(const string& key, const string& value) { - if (!db_) return false; + if (!db_) + return false; UserDbValue v(value); UserDbValue o; string old_value; @@ -270,8 +254,7 @@ bool UserDbImporter::Put(const string& key, const string& value) { if (v.commits > 0) { o.commits = (std::max)(o.commits, v.commits); o.dee = (std::max)(o.dee, v.dee); - } - else if (v.commits < 0) { // mark as deleted + } else if (v.commits < 0) { // mark as deleted o.commits = (std::min)(v.commits, -std::abs(o.commits)); } return db_->Update(key, o.Pack()); diff --git a/src/rime/dict/user_db.h b/src/rime/dict/user_db.h index 8823cea0b..418708118 100644 --- a/src/rime/dict/user_db.h +++ b/src/rime/dict/user_db.h @@ -52,18 +52,14 @@ class UserDb { } UserDb() = delete; - }; /// A helper class to provide extra functionalities related to user db. class UserDbHelper { public: - UserDbHelper(Db* db) : db_(db) { - } - UserDbHelper(const the& db) : db_(db.get()) { - } - UserDbHelper(const an& db) : db_(db.get()) { - } + UserDbHelper(Db* db) : db_(db) {} + UserDbHelper(const the& db) : db_(db.get()) {} + UserDbHelper(const an& db) : db_(db.get()) {} bool UpdateUserInfo(); static bool IsUniformFormat(const string& name); @@ -86,25 +82,23 @@ class UserDbWrapper : public BaseDb { RIME_API UserDbWrapper(const string& file_name, const string& db_name); virtual bool CreateMetadata() { - return BaseDb::CreateMetadata() && - UserDbHelper(this).UpdateUserInfo(); + return BaseDb::CreateMetadata() && UserDbHelper(this).UpdateUserInfo(); } virtual bool Backup(const string& snapshot_file) { - return UserDbHelper::IsUniformFormat(snapshot_file) ? - UserDbHelper(this).UniformBackup(snapshot_file) : - BaseDb::Backup(snapshot_file); + return UserDbHelper::IsUniformFormat(snapshot_file) + ? UserDbHelper(this).UniformBackup(snapshot_file) + : BaseDb::Backup(snapshot_file); } virtual bool Restore(const string& snapshot_file) { - return UserDbHelper::IsUniformFormat(snapshot_file) ? - UserDbHelper(this).UniformRestore(snapshot_file) : - BaseDb::Restore(snapshot_file); + return UserDbHelper::IsUniformFormat(snapshot_file) + ? UserDbHelper(this).UniformRestore(snapshot_file) + : BaseDb::Restore(snapshot_file); } }; /// Implements a component that serves as a factory for a user db class. template -class UserDbComponent : public UserDb::Component, - protected DbComponentBase { +class UserDbComponent : public UserDb::Component, protected DbComponentBase { public: using UserDbImpl = UserDbWrapper; Db* Create(const string& name) override { diff --git a/src/rime/dict/user_db_recovery_task.cc b/src/rime/dict/user_db_recovery_task.cc index b50ae8afa..c15582fec 100644 --- a/src/rime/dict/user_db_recovery_task.cc +++ b/src/rime/dict/user_db_recovery_task.cc @@ -26,7 +26,7 @@ bool UserDbRecoveryTask::Run(Deployer* deployer) { if (!db_) { return false; } - BOOST_SCOPE_EXIT( (&db_) ) { + BOOST_SCOPE_EXIT((&db_)) { db_->enable(); } BOOST_SCOPE_EXIT_END @@ -87,8 +87,7 @@ UserDbRecoveryTask* UserDbRecoveryTaskComponent::Create(TaskInitializer arg) { try { auto db = boost::any_cast>(arg); return new UserDbRecoveryTask(db); - } - catch (const boost::bad_any_cast&) { + } catch (const boost::bad_any_cast&) { return NULL; } } diff --git a/src/rime/dict/user_dictionary.cc b/src/rime/dict/user_dictionary.cc index 438941dd5..d77fd20f1 100644 --- a/src/rime/dict/user_dictionary.cc +++ b/src/rime/dict/user_dictionary.cc @@ -127,8 +127,7 @@ bool UserDictEntryIterator::Next() { // UserDictionary members UserDictionary::UserDictionary(const string& name, an db) - : name_(name), db_(db) { -} + : name_(name), db_(db) {} UserDictionary::~UserDictionary() { if (loaded()) { @@ -136,8 +135,7 @@ UserDictionary::~UserDictionary() { } } -void UserDictionary::Attach(const an
& table, - const an& prism) { +void UserDictionary::Attach(const an
& table, const an& prism) { table_ = table; prism_ = prism; } @@ -204,7 +202,7 @@ void UserDictionary::DfsLookup(const SyllableGraph& syll_graph, << ", syll_id: " << spelling.first << ", num_spellings: " << spelling.second.size(); state->code.push_back(spelling.first); - BOOST_SCOPE_EXIT( (&state) ) { + BOOST_SCOPE_EXIT((&state)) { state->code.pop_back(); } BOOST_SCOPE_EXIT_END @@ -214,9 +212,9 @@ void UserDictionary::DfsLookup(const SyllableGraph& syll_graph, auto props = spelling.second[i]; if (i > 0 && props->type >= kAbbreviation) continue; - state->credibility.push_back( - state->credibility.back() + props->credibility); - BOOST_SCOPE_EXIT( (&state) ) { + state->credibility.push_back(state->credibility.back() + + props->credibility); + BOOST_SCOPE_EXIT((&state)) { state->credibility.pop_back(); } BOOST_SCOPE_EXIT_END @@ -253,11 +251,11 @@ static an collect(map* source) { return result; } -an -UserDictionary::Lookup(const SyllableGraph& syll_graph, - size_t start_pos, - size_t depth_limit, - double initial_credibility) { +an UserDictionary::Lookup( + const SyllableGraph& syll_graph, + size_t start_pos, + size_t depth_limit, + double initial_credibility) { if (!table_ || !prism_ || !loaded() || start_pos >= syll_graph.interpreted_length) return nullptr; @@ -346,7 +344,8 @@ bool UserDictionary::UpdateEntry(const DictEntry& entry, int commits) { return UpdateEntry(entry, commits, ""); } -bool UserDictionary::UpdateEntry(const DictEntry& entry, int commits, +bool UserDictionary::UpdateEntry(const DictEntry& entry, + int commits, const string& new_entry_prefix) { string code_str(entry.custom_code); if (code_str.empty() && !TranslateCodeToString(entry.code, &code_str)) @@ -359,8 +358,7 @@ bool UserDictionary::UpdateEntry(const DictEntry& entry, int commits, if (v.tick > tick_) { v.tick = tick_; // fix abnormal timestamp } - } - else if (!new_entry_prefix.empty()) { + } else if (!new_entry_prefix.empty()) { key.insert(0, new_entry_prefix); } if (commits > 0) { @@ -369,12 +367,10 @@ bool UserDictionary::UpdateEntry(const DictEntry& entry, int commits, v.commits += commits; UpdateTickCount(1); v.dee = algo::formula_d(commits, (double)tick_, v.dee, (double)v.tick); - } - else if (commits == 0) { + } else if (commits == 0) { const double k = 0.1; v.dee = algo::formula_d(k, (double)tick_, v.dee, (double)v.tick); - } - else if (commits < 0) { // mark as deleted + } else if (commits < 0) { // mark as deleted v.commits = (std::min)(-1, -v.commits); v.dee = algo::formula_d(0.0, (double)tick_, v.dee, (double)v.tick); } @@ -386,8 +382,7 @@ bool UserDictionary::UpdateTickCount(TickCount increment) { tick_ += increment; try { return db_->MetaUpdate("/tick", boost::lexical_cast(tick_)); - } - catch (...) { + } catch (...) { return false; } } @@ -400,14 +395,12 @@ bool UserDictionary::FetchTickCount() { string value; try { // an earlier version mistakenly wrote tick count into an empty key - if (!db_->MetaFetch("/tick", &value) && - !db_->Fetch("", &value)) + if (!db_->MetaFetch("/tick", &value) && !db_->Fetch("", &value)) return false; tick_ = boost::lexical_cast(value); return true; - } - catch (...) { - //tick_ = 0; + } catch (...) { + // tick_ = 0; return false; } } @@ -425,7 +418,7 @@ bool UserDictionary::RevertRecentTransaction() { auto db = As(db_); if (!db || !db->in_transaction()) return false; - if (time(NULL) - transaction_time_ > 3/*seconds*/) + if (time(NULL) - transaction_time_ > 3 /*seconds*/) return false; return db->AbortTransaction(); } @@ -438,9 +431,9 @@ bool UserDictionary::CommitPendingTransaction() { return false; } -bool UserDictionary::TranslateCodeToString(const Code& code, - string* result) { - if (!table_ || !result) return false; +bool UserDictionary::TranslateCodeToString(const Code& code, string* result) { + if (!table_ || !result) + return false; result->clear(); for (const SyllableId& syllable_id : code) { string spelling = table_->GetSyllableById(syllable_id); @@ -456,10 +449,10 @@ bool UserDictionary::TranslateCodeToString(const Code& code, } an UserDictionary::CreateDictEntry(const string& key, - const string& value, - TickCount present_tick, - double credibility, - string* full_code) { + const string& value, + TickCount present_tick, + double credibility, + string* full_code) { an e; size_t separator_pos = key.find('\t'); if (separator_pos == string::npos) @@ -476,16 +469,13 @@ an UserDictionary::CreateDictEntry(const string& key, e->text = key.substr(separator_pos + 1); e->commit_count = v.commits; // TODO: argument s not defined... - double weight = algo::formula_p(0, - (double)v.commits / present_tick, - (double)present_tick, - v.dee); + double weight = algo::formula_p(0, (double)v.commits / present_tick, + (double)present_tick, v.dee); e->weight = log(weight > 0 ? weight : DBL_EPSILON) + credibility; if (full_code) { *full_code = key.substr(0, separator_pos); } - DLOG(INFO) << "text = '" << e->text - << "', code_len = " << e->code.size() + DLOG(INFO) << "text = '" << e->text << "', code_len = " << e->code.size() << ", weight = " << e->weight << ", commit_count = " << e->commit_count << ", present_tick = " << present_tick; @@ -494,10 +484,10 @@ an UserDictionary::CreateDictEntry(const string& key, // UserDictionaryComponent members -UserDictionaryComponent::UserDictionaryComponent() { -} +UserDictionaryComponent::UserDictionaryComponent() {} -UserDictionary* UserDictionaryComponent::Create(const string& dict_name, const string& db_class) { +UserDictionary* UserDictionaryComponent::Create(const string& dict_name, + const string& db_class) { auto db = db_pool_[dict_name].lock(); if (!db) { auto component = Db::Require(db_class); @@ -522,12 +512,10 @@ UserDictionary* UserDictionaryComponent::Create(const Ticket& ticket) { string dict_name; if (config->GetString(ticket.name_space + "/user_dict", &dict_name)) { // user specified name - } - else if (config->GetString(ticket.name_space + "/dictionary", &dict_name)) { + } else if (config->GetString(ticket.name_space + "/dictionary", &dict_name)) { // {dictionary: luna_pinyin.extra} implies {user_dict: luna_pinyin} dict_name = Language::get_language_component(dict_name); - } - else { + } else { LOG(ERROR) << ticket.name_space << "/dictionary not specified in schema '" << ticket.schema->schema_id() << "'."; return NULL; diff --git a/src/rime/dict/user_dictionary.h b/src/rime/dict/user_dictionary.h index 062fb6905..653164eb2 100644 --- a/src/rime/dict/user_dictionary.h +++ b/src/rime/dict/user_dictionary.h @@ -26,12 +26,8 @@ class UserDictEntryIterator : public DictEntryFilterBinder { void AddFilter(DictEntryFilter filter) override; an Peek(); bool Next(); - bool exhausted() const { - return index_ >= cache_.size(); - } - size_t cache_size() const { - return cache_.size(); - } + bool exhausted() const { return index_ >= cache_.size(); } + size_t cache_size() const { return cache_.size(); } protected: bool FindNextEntry(); @@ -70,7 +66,8 @@ class UserDictionary : public Class { size_t limit = 0, string* resume_key = NULL); bool UpdateEntry(const DictEntry& entry, int commits); - bool UpdateEntry(const DictEntry& entry, int commits, + bool UpdateEntry(const DictEntry& entry, + int commits, const string& new_entry_prefix); bool UpdateTickCount(TickCount increment); @@ -91,7 +88,8 @@ class UserDictionary : public Class { bool Initialize(); bool FetchTickCount(); bool TranslateCodeToString(const Code& code, string* result); - void DfsLookup(const SyllableGraph& syll_graph, size_t current_pos, + void DfsLookup(const SyllableGraph& syll_graph, + size_t current_pos, const string& current_prefix, DfsState* state); @@ -109,6 +107,7 @@ class UserDictionaryComponent : public UserDictionary::Component { UserDictionaryComponent(); UserDictionary* Create(const Ticket& ticket); UserDictionary* Create(const string& dict_name, const string& db_class); + private: map> db_pool_; }; diff --git a/src/rime/dict/vocabulary.cc b/src/rime/dict/vocabulary.cc index 18a8577e5..1328c3c4f 100644 --- a/src/rime/dict/vocabulary.cc +++ b/src/rime/dict/vocabulary.cc @@ -12,7 +12,7 @@ namespace rime { -bool Code::operator< (const Code& other) const { +bool Code::operator<(const Code& other) const { if (size() != other.size()) return size() < other.size(); for (size_t i = 0; i < size(); ++i) { @@ -22,7 +22,7 @@ bool Code::operator< (const Code& other) const { return false; } -bool Code::operator== (const Code& other) const { +bool Code::operator==(const Code& other) const { if (size() != other.size()) return false; for (size_t i = 0; i < size(); ++i) { @@ -40,9 +40,7 @@ void Code::CreateIndex(Code* index_code) { index_code_size = size(); } index_code->resize(index_code_size); - std::copy(begin(), - begin() + index_code_size, - index_code->begin()); + std::copy(begin(), begin() + index_code_size, index_code->begin()); } string Code::ToString() const { @@ -51,8 +49,7 @@ string Code::ToString() const { for (SyllableId syllable_id : *this) { if (first) { first = false; - } - else { + } else { stream << ","; } stream << syllable_id; @@ -64,20 +61,20 @@ inline ShortDictEntry DictEntry::ToShort() const { return {text, code, weight}; } -bool ShortDictEntry::operator< (const ShortDictEntry& other) const { +bool ShortDictEntry::operator<(const ShortDictEntry& other) const { // Sort different entries sharing the same code by weight desc. if (weight != other.weight) return weight > other.weight; // reduce carbon emission - return 0; //text < other.text; + return 0; // text < other.text; } -bool DictEntry::operator< (const DictEntry& other) const { +bool DictEntry::operator<(const DictEntry& other) const { // Sort different entries sharing the same code by weight desc. if (weight != other.weight) return weight > other.weight; // reduce carbon emission - return 0; //text < other.text; + return 0; // text < other.text; } template @@ -86,12 +83,13 @@ inline bool dereference_less(const T& a, const T& b) { } template -inline void sort(C &container) { - std::sort(std::begin(container), std::end(container), dereference_less); +inline void sort(C& container) { + std::sort(std::begin(container), std::end(container), + dereference_less); } template -inline void sort_range(C &container, size_t start, size_t count) { +inline void sort_range(C& container, size_t start, size_t count) { if (start >= container.size()) return; auto i(std::begin(container) + start); @@ -118,8 +116,7 @@ void DictEntryList::SortRange(size_t start, size_t count) { void DictEntryFilterBinder::AddFilter(DictEntryFilter filter) { if (!filter_) { filter_.swap(filter); - } - else { + } else { DictEntryFilter previous_filter(std::move(filter_)); filter_ = [previous_filter, filter](an e) { return previous_filter(e) && filter(e); @@ -137,8 +134,7 @@ ShortDictEntryList* Vocabulary::LocateEntries(const Code& code) { auto& page((*v)[key]); if (i == n - 1 || i == Code::kIndexCodeMaxLength) { return &page.entries; - } - else { + } else { if (!page.next_level) { page.next_level = New(); } diff --git a/src/rime/dict/vocabulary.h b/src/rime/dict/vocabulary.h index 28afabd5b..ec40fc1a1 100644 --- a/src/rime/dict/vocabulary.h +++ b/src/rime/dict/vocabulary.h @@ -22,8 +22,8 @@ class Code : public vector { public: static const size_t kIndexCodeMaxLength = 3; - bool operator< (const Code& other) const; - bool operator== (const Code& other) const; + bool operator<(const Code& other) const; + bool operator==(const Code& other) const; void CreateIndex(Code* index_code); @@ -36,14 +36,14 @@ struct ShortDictEntry { double weight = 0.0; ShortDictEntry() = default; - bool operator< (const ShortDictEntry& other) const; + bool operator<(const ShortDictEntry& other) const; }; struct DictEntry { string text; string comment; string preedit; - Code code; // multi-syllable code from prism + Code code; // multi-syllable code from prism string custom_code; // user defined code double weight = 0.0; int commit_count = 0; @@ -51,7 +51,7 @@ struct DictEntry { DictEntry() = default; ShortDictEntry ToShort() const; - bool operator< (const DictEntry& other) const; + bool operator<(const DictEntry& other) const; }; class ShortDictEntryList : public vector> { @@ -66,7 +66,7 @@ class DictEntryList : public vector> { void SortRange(size_t start, size_t count); }; -using DictEntryFilter = function entry)>; +using DictEntryFilter = function entry)>; class DictEntryFilterBinder { public: diff --git a/src/rime/engine.cc b/src/rime/engine.cc index 91834bb34..2e8c9d588 100644 --- a/src/rime/engine.cc +++ b/src/rime/engine.cc @@ -60,8 +60,7 @@ Engine* Engine::Create() { return new ConcreteEngine; } -Engine::Engine() : schema_(new Schema), context_(new Context) { -} +Engine::Engine() : schema_(new Schema), context_(new Context) {} Engine::~Engine() { context_.reset(); @@ -71,10 +70,8 @@ Engine::~Engine() { ConcreteEngine::ConcreteEngine() { LOG(INFO) << "starting engine."; // receive context notifications - context_->commit_notifier().connect( - [this](Context* ctx) { OnCommit(ctx); }); - context_->select_notifier().connect( - [this](Context* ctx) { OnSelect(ctx); }); + context_->commit_notifier().connect([this](Context* ctx) { OnCommit(ctx); }); + context_->select_notifier().connect([this](Context* ctx) { OnSelect(ctx); }); context_->update_notifier().connect( [this](Context* ctx) { OnContextUpdate(ctx); }); context_->option_update_notifier().connect( @@ -98,16 +95,20 @@ bool ConcreteEngine::ProcessKey(const KeyEvent& key_event) { ProcessResult ret = kNoop; for (auto& processor : processors_) { ret = processor->ProcessKeyEvent(key_event); - if (ret == kRejected) break; - if (ret == kAccepted) return true; + if (ret == kRejected) + break; + if (ret == kAccepted) + return true; } // record unhandled keys, eg. spaces, numbers, bksp's. context_->commit_history().Push(key_event); // post-processing for (auto& processor : post_processors_) { ret = processor->ProcessKeyEvent(key_event); - if (ret == kRejected) break; - if (ret == kAccepted) return true; + if (ret == kRejected) + break; + if (ret == kAccepted) + return true; } // notify interested parties context_->unhandled_key_notifier()(context_.get(), key_event); @@ -115,12 +116,14 @@ bool ConcreteEngine::ProcessKey(const KeyEvent& key_event) { } void ConcreteEngine::OnContextUpdate(Context* ctx) { - if (!ctx) return; + if (!ctx) + return; Compose(ctx); } void ConcreteEngine::OnOptionUpdate(Context* ctx, const string& option) { - if (!ctx) return; + if (!ctx) + return; LOG(INFO) << "updated option: " << option; // apply new option to active segment if (ctx->IsComposing()) { @@ -133,7 +136,8 @@ void ConcreteEngine::OnOptionUpdate(Context* ctx, const string& option) { } void ConcreteEngine::OnPropertyUpdate(Context* ctx, const string& property) { - if (!ctx) return; + if (!ctx) + return; LOG(INFO) << "updated property: " << property; // notification string value = ctx->get_property(property); @@ -142,7 +146,8 @@ void ConcreteEngine::OnPropertyUpdate(Context* ctx, const string& property) { } void ConcreteEngine::Compose(Context* ctx) { - if (!ctx) return; + if (!ctx) + return; Composition& comp = ctx->composition(); const string active_input = ctx->input().substr(0, ctx->caret_pos()); DLOG(INFO) << "active input: " << active_input; @@ -253,16 +258,14 @@ void ConcreteEngine::OnSelect(Context* ctx) { ctx->Commit(); else ctx->composition().Forward(); - } - else { + } else { bool reached_caret_pos = (seg.end >= ctx->caret_pos()); ctx->composition().Forward(); if (reached_caret_pos) { // finished converting current segment // move caret to the end of input ctx->set_caret_pos(ctx->input().length()); - } - else { + } else { Compose(ctx); } } @@ -308,8 +311,7 @@ void ConcreteEngine::InitializeComponents() { if (auto c = Processor::Require(ticket.klass)) { an p(c->Create(ticket)); processors_.push_back(p); - } - else { + } else { LOG(ERROR) << "error creating processor: '" << ticket.klass << "'"; } } @@ -325,8 +327,7 @@ void ConcreteEngine::InitializeComponents() { if (auto c = Segmentor::Require(ticket.klass)) { an s(c->Create(ticket)); segmentors_.push_back(s); - } - else { + } else { LOG(ERROR) << "error creating segmentor: '" << ticket.klass << "'"; } } @@ -342,8 +343,7 @@ void ConcreteEngine::InitializeComponents() { if (auto c = Translator::Require(ticket.klass)) { an t(c->Create(ticket)); translators_.push_back(t); - } - else { + } else { LOG(ERROR) << "error creating translator: '" << ticket.klass << "'"; } } @@ -359,8 +359,7 @@ void ConcreteEngine::InitializeComponents() { if (auto c = Filter::Require(ticket.klass)) { an f(c->Create(ticket)); filters_.push_back(f); - } - else { + } else { LOG(ERROR) << "error creating filter: '" << ticket.klass << "'"; } } @@ -369,16 +368,14 @@ void ConcreteEngine::InitializeComponents() { if (auto c = Formatter::Require("shape_formatter")) { an f(c->Create(Ticket(this))); formatters_.push_back(f); - } - else { + } else { LOG(WARNING) << "shape_formatter not available."; } // create post-processors if (auto c = Processor::Require("shape_processor")) { an p(c->Create(Ticket(this))); post_processors_.push_back(p); - } - else { + } else { LOG(WARNING) << "shape_processor not available."; } } diff --git a/src/rime/engine.h b/src/rime/engine.h index 5a45c6aea..2e1c8b812 100644 --- a/src/rime/engine.h +++ b/src/rime/engine.h @@ -19,7 +19,7 @@ class Context; class Engine : public Messenger { public: - using CommitSink = signal; + using CommitSink = signal; virtual ~Engine(); virtual bool ProcessKey(const KeyEvent& key_event) { return false; } @@ -31,12 +31,8 @@ class Engine : public Messenger { Context* context() const { return context_.get(); } CommitSink& sink() { return sink_; } - Engine* active_engine() { - return active_engine_ ? active_engine_ : this; - } - void set_active_engine(Engine* engine = nullptr) { - active_engine_ = engine; - } + Engine* active_engine() { return active_engine_ ? active_engine_ : this; } + void set_active_engine(Engine* engine = nullptr) { active_engine_ = engine; } RIME_API static Engine* Create(); diff --git a/src/rime/filter.h b/src/rime/filter.h index b399899b2..fd987d48d 100644 --- a/src/rime/filter.h +++ b/src/rime/filter.h @@ -26,14 +26,12 @@ class Filter : public Class { virtual ~Filter() = default; virtual an Apply(an translation, - CandidateList* candidates) = 0; + CandidateList* candidates) = 0; + + virtual bool AppliesToSegment(Segment* segment) { return true; } - virtual bool AppliesToSegment(Segment* segment) { - return true; - } - string name_space() const { return name_space_; } - + protected: Engine* engine_; string name_space_; diff --git a/src/rime/gear/abc_segmentor.cc b/src/rime/gear/abc_segmentor.cc index 90f6159e3..a8b3e41cc 100644 --- a/src/rime/gear/abc_segmentor.cc +++ b/src/rime/gear/abc_segmentor.cc @@ -44,8 +44,7 @@ bool AbcSegmentor::Proceed(Segmentation* segmentation) { bool expecting_an_initial = true; for (; k < input.length(); ++k) { bool is_letter = alphabet_.find(input[k]) != string::npos; - bool is_delimiter = - (k != j) && (delimiter_.find(input[k]) != string::npos); + bool is_delimiter = (k != j) && (delimiter_.find(input[k]) != string::npos); if (!is_letter && !is_delimiter) break; bool is_initial = initials_.find(input[k]) != string::npos; diff --git a/src/rime/gear/affix_segmentor.cc b/src/rime/gear/affix_segmentor.cc index cb5d77652..4a2eec99b 100644 --- a/src/rime/gear/affix_segmentor.cc +++ b/src/rime/gear/affix_segmentor.cc @@ -38,8 +38,7 @@ bool AffixSegmentor::Proceed(Segmentation* segmentation) { if (!segmentation->back().HasTag(tag_)) { if (segmentation->size() >= 2) { Segment& previous_segment(*(segmentation->rbegin() + 1)); - if (previous_segment.HasTag("partial") && - previous_segment.HasTag(tag_)) { + if (previous_segment.HasTag("partial") && previous_segment.HasTag(tag_)) { // the remaining part of a partial selection should inherit the tag segmentation->back().tags.insert(tag_); // without adding new tag "abc" @@ -92,8 +91,7 @@ bool AffixSegmentor::Proceed(Segmentation* segmentation) { k -= suffix_.length(); if (k == segmentation->back().start) { segmentation->pop_back(); // code is empty - } - else { + } else { segmentation->back().end = k; } Segment suffix_segment(k, k + suffix_.length()); diff --git a/src/rime/gear/ascii_composer.cc b/src/rime/gear/ascii_composer.cc index 20919396c..bba38a035 100644 --- a/src/rime/gear/ascii_composer.cc +++ b/src/rime/gear/ascii_composer.cc @@ -18,13 +18,11 @@ namespace rime { static struct AsciiModeSwitchStyleDefinition { const char* repr; AsciiModeSwitchStyle style; -} ascii_mode_switch_styles[] = { - { "inline_ascii", kAsciiModeSwitchInline }, - { "commit_text", kAsciiModeSwitchCommitText }, - { "commit_code", kAsciiModeSwitchCommitCode }, - { "clear", kAsciiModeSwitchClear }, - { NULL, kAsciiModeSwitchNoop } -}; +} ascii_mode_switch_styles[] = {{"inline_ascii", kAsciiModeSwitchInline}, + {"commit_text", kAsciiModeSwitchCommitText}, + {"commit_code", kAsciiModeSwitchCommitCode}, + {"clear", kAsciiModeSwitchClear}, + {NULL, kAsciiModeSwitchNoop}}; static void load_bindings(const an& src, AsciiModeSwitchKeyBindings* dest) { @@ -49,8 +47,7 @@ static void load_bindings(const an& src, } } -AsciiComposer::AsciiComposer(const Ticket& ticket) - : Processor(ticket) { +AsciiComposer::AsciiComposer(const Ticket& ticket) : Processor(ticket) { LoadConfig(ticket.schema); } @@ -59,8 +56,8 @@ AsciiComposer::~AsciiComposer() { } ProcessResult AsciiComposer::ProcessKeyEvent(const KeyEvent& key_event) { - if ((key_event.shift() && key_event.ctrl()) || - key_event.alt() || key_event.super()) { + if ((key_event.shift() && key_event.ctrl()) || key_event.alt() || + key_event.super()) { shift_key_pressed_ = ctrl_key_pressed_ = false; return kNoop; } @@ -75,8 +72,7 @@ ProcessResult AsciiComposer::ProcessKeyEvent(const KeyEvent& key_event) { shift_key_pressed_ = ctrl_key_pressed_ = false; ToggleAsciiModeWithKey(ch); return kAccepted; - } - else { + } else { return kRejected; } } @@ -92,8 +88,7 @@ ProcessResult AsciiComposer::ProcessKeyEvent(const KeyEvent& key_event) { shift_key_pressed_ = ctrl_key_pressed_ = false; return kNoop; } - } - else if (!(shift_key_pressed_ || ctrl_key_pressed_)) { // first key down + } else if (!(shift_key_pressed_ || ctrl_key_pressed_)) { // first key down if (is_shift) shift_key_pressed_ = true; else @@ -101,7 +96,7 @@ ProcessResult AsciiComposer::ProcessKeyEvent(const KeyEvent& key_event) { // will not toggle unless the toggle key is released shortly const auto toggle_duration_limit = std::chrono::milliseconds(500); auto now = std::chrono::steady_clock::now(); - toggle_expired_= now + toggle_duration_limit; + toggle_expired_ = now + toggle_duration_limit; } return kNoop; } @@ -147,14 +142,12 @@ ProcessResult AsciiComposer::ProcessCapsLock(const KeyEvent& key_event) { // here we assume IBus' behavior and invert caps with ! operation. SwitchAsciiMode(!key_event.caps(), caps_lock_switch_style_); return kAccepted; - } - else { + } else { return kRejected; } } if (key_event.caps()) { - if (!good_old_caps_lock_ && - !key_event.release() && !key_event.ctrl() && + if (!good_old_caps_lock_ && !key_event.release() && !key_event.ctrl() && isascii(ch) && isalpha(ch)) { // output ascii characters ignoring Caps Lock if (islower(ch)) @@ -163,8 +156,7 @@ ProcessResult AsciiComposer::ProcessCapsLock(const KeyEvent& key_event) { ch = tolower(ch); engine_->CommitText(string(1, ch)); return kAccepted; - } - else { + } else { return kRejected; } } @@ -188,10 +180,9 @@ void AsciiComposer::LoadConfig(Schema* schema) { } if (auto bindings = config->GetMap("ascii_composer/switch_key")) { load_bindings(bindings, &bindings_); - } - else if (auto bindings = preset_config - ? preset_config->GetMap("ascii_composer/switch_key") - : nullptr) { + } else if (auto bindings = preset_config ? preset_config->GetMap( + "ascii_composer/switch_key") + : nullptr) { load_bindings(bindings, &bindings_); } else { LOG(ERROR) << "Missing ascii bindings."; @@ -232,15 +223,12 @@ void AsciiComposer::SwitchAsciiMode(bool ascii_mode, connection_ = ctx->update_notifier().connect( [this](Context* ctx) { OnContextUpdate(ctx); }); } - } - else if (style == kAsciiModeSwitchCommitText) { + } else if (style == kAsciiModeSwitchCommitText) { ctx->ConfirmCurrentSelection(); - } - else if (style == kAsciiModeSwitchCommitCode) { + } else if (style == kAsciiModeSwitchCommitCode) { ctx->ClearNonConfirmedComposition(); ctx->Commit(); - } - else if (style == kAsciiModeSwitchClear) { + } else if (style == kAsciiModeSwitchClear) { ctx->Clear(); } } diff --git a/src/rime/gear/ascii_composer.h b/src/rime/gear/ascii_composer.h index 1882f6f7d..c008b0cab 100644 --- a/src/rime/gear/ascii_composer.h +++ b/src/rime/gear/ascii_composer.h @@ -25,8 +25,7 @@ enum AsciiModeSwitchStyle { kAsciiModeSwitchClear, }; -using AsciiModeSwitchKeyBindings = map; +using AsciiModeSwitchKeyBindings = map; class AsciiComposer : public Processor { public: diff --git a/src/rime/gear/ascii_segmentor.cc b/src/rime/gear/ascii_segmentor.cc index c5f1045de..32e3de859 100644 --- a/src/rime/gear/ascii_segmentor.cc +++ b/src/rime/gear/ascii_segmentor.cc @@ -14,8 +14,7 @@ namespace rime { -AsciiSegmentor::AsciiSegmentor(const Ticket& ticket) : Segmentor(ticket) { -} +AsciiSegmentor::AsciiSegmentor(const Ticket& ticket) : Segmentor(ticket) {} bool AsciiSegmentor::Proceed(Segmentation* segmentation) { if (!engine_->context()->get_option("ascii_mode")) diff --git a/src/rime/gear/charset_filter.cc b/src/rime/gear/charset_filter.cc index bcec40e61..4b6e62a05 100644 --- a/src/rime/gear/charset_filter.cc +++ b/src/rime/gear/charset_filter.cc @@ -4,7 +4,7 @@ // // 2014-03-31 Chongyu Zhu // -#include // for uint32_t +#include // for uint32_t #include #include #include @@ -13,11 +13,9 @@ #include #include - namespace rime { -bool is_extended_cjk(uint32_t ch) -{ +bool is_extended_cjk(uint32_t ch) { if ((ch >= 0x3400 && ch <= 0x4DBF) || // CJK Unified Ideographs Extension A (ch >= 0x20000 && ch <= 0x2A6DF) || // CJK Unified Ideographs Extension B (ch >= 0x2A700 && ch <= 0x2B73F) || // CJK Unified Ideographs Extension C @@ -29,15 +27,15 @@ bool is_extended_cjk(uint32_t ch) (ch >= 0x3300 && ch <= 0x33FF) || // CJK Compatibility (ch >= 0xFE30 && ch <= 0xFE4F) || // CJK Compatibility Forms (ch >= 0xF900 && ch <= 0xFAFF) || // CJK Compatibility Ideographs - (ch >= 0x2F800 && ch <= 0x2FA1F)) // CJK Compatibility Ideographs Supplement + (ch >= 0x2F800 && + ch <= 0x2FA1F)) // CJK Compatibility Ideographs Supplement return true; return false; } -bool contains_extended_cjk(const string& text) -{ - const char *p = text.c_str(); +bool contains_extended_cjk(const string& text) { + const char* p = text.c_str(); uint32_t ch; while ((ch = utf8::unchecked::next(p)) != 0) { @@ -96,11 +94,10 @@ bool CharsetFilter::FilterDictEntry(an entry) { } CharsetFilter::CharsetFilter(const Ticket& ticket) - : Filter(ticket), TagMatching(ticket) { -} + : Filter(ticket), TagMatching(ticket) {} -an CharsetFilter::Apply( - an translation, CandidateList* candidates) { +an CharsetFilter::Apply(an translation, + CandidateList* candidates) { if (name_space_.empty() && !engine_->context()->get_option("extended_charset")) { return New(translation); diff --git a/src/rime/gear/charset_filter.h b/src/rime/gear/charset_filter.h index a8f5b7c9d..22b6530a2 100644 --- a/src/rime/gear/charset_filter.h +++ b/src/rime/gear/charset_filter.h @@ -38,9 +38,7 @@ class CharsetFilter : public Filter, TagMatching { virtual an Apply(an translation, CandidateList* candidates); - virtual bool AppliesToSegment(Segment* segment) { - return TagsMatch(segment); - } + virtual bool AppliesToSegment(Segment* segment) { return TagsMatch(segment); } // return true to accept, false to reject the tested item static bool FilterText(const string& text); diff --git a/src/rime/gear/chord_composer.cc b/src/rime/gear/chord_composer.cc index 68649686a..639fcbde4 100644 --- a/src/rime/gear/chord_composer.cc +++ b/src/rime/gear/chord_composer.cc @@ -66,35 +66,32 @@ ProcessResult ChordComposer::ProcessFunctionKey(const KeyEvent& key_event) { // Note: QWERTY layout only. static const char map_to_base_layer[] = { - " 1'3457'908=,-./" - "0123456789;;,=./" - "2abcdefghijklmno" - "pqrstuvwxyz[\\]6-" - "`abcdefghijklmno" - "pqrstuvwxyz[\\]`" -}; + " 1'3457'908=,-./" + "0123456789;;,=./" + "2abcdefghijklmno" + "pqrstuvwxyz[\\]6-" + "`abcdefghijklmno" + "pqrstuvwxyz[\\]`"}; inline static int get_base_layer_key_code(const KeyEvent& key_event) { int ch = key_event.keycode(); bool is_shift = key_event.shift(); - return (is_shift && ch >= 0x20 && ch <= 0x7e) - ? map_to_base_layer[ch - 0x20] : ch; + return (is_shift && ch >= 0x20 && ch <= 0x7e) ? map_to_base_layer[ch - 0x20] + : ch; } ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) { if (key_event.ctrl() || key_event.alt()) { raw_sequence_.clear(); } - if ((key_event.ctrl() && !use_control_) || - (key_event.alt() && !use_alt_) || + if ((key_event.ctrl() && !use_control_) || (key_event.alt() && !use_alt_) || (key_event.shift() && !use_shift_)) { ClearChord(); return kNoop; } int ch = get_base_layer_key_code(key_event); // non chording key - if (std::find(chording_keys_.begin(), - chording_keys_.end(), + if (std::find(chording_keys_.begin(), chording_keys_.end(), KeyEvent{ch, 0}) == chording_keys_.end()) { ClearChord(); return kNoop; @@ -226,8 +223,8 @@ void ChordComposer::OnUnhandledKey(Context* ctx, const KeyEvent& key) { // directly committed ascii should not be captured into the raw sequence // test case: // 3.14{Return} should not commit an extra sequence '14' - if ((key.modifier() & ~kShiftMask) == 0 && - key.keycode() >= 0x20 && key.keycode() <= 0x7e) { + if ((key.modifier() & ~kShiftMask) == 0 && key.keycode() >= 0x20 && + key.keycode() <= 0x7e) { raw_sequence_.clear(); DLOG(INFO) << "clear raw sequence."; } diff --git a/src/rime/gear/contextual_translation.cc b/src/rime/gear/contextual_translation.cc index 8e3336774..604d96cce 100644 --- a/src/rime/gear/contextual_translation.cc +++ b/src/rime/gear/contextual_translation.cc @@ -15,13 +15,13 @@ bool ContextualTranslation::Replenish() { while (!translation_->exhausted() && cache_.size() + queue.size() < kContextualSearchLimit) { auto cand = translation_->Peek(); - DLOG(INFO) << cand->text() << " cache/queue: " - << cache_.size() << "/" << queue.size(); + DLOG(INFO) << cand->text() << " cache/queue: " << cache_.size() << "/" + << queue.size(); if (cand->type() == "phrase" || cand->type() == "user_phrase" || - cand->type() == "table" || cand->type() == "user_table") { + cand->type() == "table" || cand->type() == "user_table") { if (end_pos != cand->end() || last_type != cand->type()) { end_pos = cand->end(); - last_type = cand->type(); + last_type = cand->type(); AppendToCache(queue); } queue.push_back(Evaluate(As(cand))); @@ -39,11 +39,8 @@ bool ContextualTranslation::Replenish() { an ContextualTranslation::Evaluate(an phrase) { bool is_rear = phrase->end() == input_.length(); - double weight = Grammar::Evaluate(preceding_text_, - phrase->text(), - phrase->weight(), - is_rear, - grammar_); + double weight = Grammar::Evaluate(preceding_text_, phrase->text(), + phrase->weight(), is_rear, grammar_); phrase->set_weight(weight); DLOG(INFO) << "contextual suggestion: " << phrase->text() << " weight: " << phrase->weight(); @@ -55,7 +52,8 @@ static bool compare_by_weight_desc(const an& a, const an& b) { } void ContextualTranslation::AppendToCache(vector>& queue) { - if (queue.empty()) return; + if (queue.empty()) + return; DLOG(INFO) << "appending to cache " << queue.size() << " candidates."; std::sort(queue.begin(), queue.end(), compare_by_weight_desc); std::copy(queue.begin(), queue.end(), std::back_inserter(cache_)); diff --git a/src/rime/gear/echo_translator.cc b/src/rime/gear/echo_translator.cc index 6ea483db0..1391610f6 100644 --- a/src/rime/gear/echo_translator.cc +++ b/src/rime/gear/echo_translator.cc @@ -16,10 +16,8 @@ namespace rime { class EchoTranslation : public UniqueTranslation { public: EchoTranslation(const an& candidate) - : UniqueTranslation(candidate) { - } - virtual int Compare(an other, - const CandidateList& candidates) { + : UniqueTranslation(candidate) {} + virtual int Compare(an other, const CandidateList& candidates) { if (!candidates.empty() || (other && !other->exhausted())) { set_exhausted(true); } @@ -27,18 +25,14 @@ class EchoTranslation : public UniqueTranslation { } }; -EchoTranslator::EchoTranslator(const Ticket& ticket) - : Translator(ticket) { -} +EchoTranslator::EchoTranslator(const Ticket& ticket) : Translator(ticket) {} an EchoTranslator::Query(const string& input, const Segment& segment) { - DLOG(INFO) << "input = '" << input - << "', [" << segment.start << ", " << segment.end << ")"; - auto candidate = New("raw", - segment.start, - segment.end, - input); + DLOG(INFO) << "input = '" << input << "', [" << segment.start << ", " + << segment.end << ")"; + auto candidate = + New("raw", segment.start, segment.end, input); if (candidate) { candidate->set_quality(-100); // lowest priority } diff --git a/src/rime/gear/echo_translator.h b/src/rime/gear/echo_translator.h index ff9b0c323..55e838d57 100644 --- a/src/rime/gear/echo_translator.h +++ b/src/rime/gear/echo_translator.h @@ -15,8 +15,7 @@ class EchoTranslator : public Translator { public: EchoTranslator(const Ticket& ticket); - virtual an Query(const string& input, - const Segment& segment); + virtual an Query(const string& input, const Segment& segment); }; } // namespace rime diff --git a/src/rime/gear/editor.cc b/src/rime/gear/editor.cc index d20198382..7247be029 100644 --- a/src/rime/gear/editor.cc +++ b/src/rime/gear/editor.cc @@ -17,29 +17,26 @@ namespace rime { static Editor::ActionDef editor_action_definitions[] = { - { "confirm", &Editor::Confirm }, - { "toggle_selection", &Editor::ToggleSelection }, - { "commit_comment", &Editor::CommitComment }, - { "commit_raw_input", &Editor::CommitRawInput }, - { "commit_script_text", &Editor::CommitScriptText }, - { "commit_composition", &Editor::CommitComposition }, - { "revert", &Editor::RevertLastEdit }, - { "back", &Editor::BackToPreviousInput }, - { "back_syllable", &Editor::BackToPreviousSyllable }, - { "delete_candidate", &Editor::DeleteCandidate }, - { "delete", &Editor::DeleteChar }, - { "cancel", &Editor::CancelComposition }, - Editor::kActionNoop -}; + {"confirm", &Editor::Confirm}, + {"toggle_selection", &Editor::ToggleSelection}, + {"commit_comment", &Editor::CommitComment}, + {"commit_raw_input", &Editor::CommitRawInput}, + {"commit_script_text", &Editor::CommitScriptText}, + {"commit_composition", &Editor::CommitComposition}, + {"revert", &Editor::RevertLastEdit}, + {"back", &Editor::BackToPreviousInput}, + {"back_syllable", &Editor::BackToPreviousSyllable}, + {"delete_candidate", &Editor::DeleteCandidate}, + {"delete", &Editor::DeleteChar}, + {"cancel", &Editor::CancelComposition}, + Editor::kActionNoop}; static struct EditorCharHandlerDef { const char* name; Editor::CharHandlerPtr action; -} editor_char_handler_definitions[] = { - { "direct_commit", &Editor::DirectCommit }, - { "add_to_input", &Editor::AddToInput }, - { "noop", nullptr } -}; +} editor_char_handler_definitions[] = {{"direct_commit", &Editor::DirectCommit}, + {"add_to_input", &Editor::AddToInput}, + {"noop", nullptr}}; Editor::Editor(const Ticket& ticket, bool auto_commit) : Processor(ticket), KeyBindingProcessor(editor_action_definitions) { @@ -52,17 +49,16 @@ ProcessResult Editor::ProcessKeyEvent(const KeyEvent& key_event) { int ch = key_event.keycode(); Context* ctx = engine_->context(); if (ctx->IsComposing()) { - auto result = KeyBindingProcessor::ProcessKeyEvent( - key_event, ctx, 0, FallbackOptions::All); + auto result = KeyBindingProcessor::ProcessKeyEvent(key_event, ctx, 0, + FallbackOptions::All); if (result != kNoop) { return result; } } - if (char_handler_ && - !key_event.ctrl() && !key_event.alt() && !key_event.super() && - ch > 0x20 && ch < 0x7f) { - DLOG(INFO) << "input char: '" << (char)ch << "', " << ch - << ", '" << key_event.repr() << "'"; + if (char_handler_ && !key_event.ctrl() && !key_event.alt() && + !key_event.super() && ch > 0x20 && ch < 0x7f) { + DLOG(INFO) << "input char: '" << (char)ch << "', " << ch << ", '" + << key_event.repr() << "'"; return RIME_THIS_CALL(char_handler_)(ctx, ch); } // not handled @@ -82,8 +78,7 @@ void Editor::LoadConfig() { } if (!p->action && p->name != value->str()) { LOG(WARNING) << "invalid char_handler: " << value->str(); - } - else { + } else { char_handler_ = p->action; } } @@ -95,8 +90,7 @@ bool Editor::Confirm(Context* ctx) { } bool Editor::ToggleSelection(Context* ctx) { - ctx->ReopenPreviousSegment() || - ctx->ConfirmCurrentSelection(); + ctx->ReopenPreviousSegment() || ctx->ConfirmCurrentSelection(); return true; } @@ -136,8 +130,7 @@ bool Editor::RevertLastEdit(Context* ctx) { } bool Editor::BackToPreviousInput(Context* ctx) { - ctx->ReopenPreviousSegment() || - ctx->ReopenPreviousSelection() || + ctx->ReopenPreviousSegment() || ctx->ReopenPreviousSelection() || ctx->PopInput(); return true; } @@ -187,9 +180,9 @@ ProcessResult Editor::DirectCommit(Context* ctx, int ch) { } ProcessResult Editor::AddToInput(Context* ctx, int ch) { - ctx->PushInput(ch); - ctx->ConfirmPreviousSelection(); - return kAccepted; + ctx->PushInput(ch); + ctx->ConfirmPreviousSelection(); + return kAccepted; } FluidEditor::FluidEditor(const Ticket& ticket) : Editor(ticket, false) { @@ -197,7 +190,7 @@ FluidEditor::FluidEditor(const Ticket& ticket) : Editor(ticket, false) { keymap.Bind({XK_space, 0}, &Editor::Confirm); keymap.Bind({XK_BackSpace, 0}, &Editor::BackToPreviousInput); // keymap.Bind({XK_BackSpace, kControlMask}, &Editor::BackToPreviousSyllable); - keymap.Bind({XK_Return, 0}, &Editor::CommitComposition); // + keymap.Bind({XK_Return, 0}, &Editor::CommitComposition); // keymap.Bind({XK_Return, kControlMask}, &Editor::CommitRawInput); // keymap.Bind({XK_Return, kShiftMask}, &Editor::CommitScriptText); // keymap.Bind({XK_Return, kControlMask | kShiftMask}, &Editor::CommitComment); @@ -213,7 +206,7 @@ ExpressEditor::ExpressEditor(const Ticket& ticket) : Editor(ticket, true) { keymap.Bind({XK_space, 0}, &Editor::Confirm); keymap.Bind({XK_BackSpace, 0}, &Editor::RevertLastEdit); // keymap.Bind({XK_BackSpace, kControlMask}, &Editor::BackToPreviousSyllable); - keymap.Bind({XK_Return, 0}, &Editor::CommitRawInput); // + keymap.Bind({XK_Return, 0}, &Editor::CommitRawInput); // keymap.Bind({XK_Return, kControlMask}, &Editor::CommitScriptText); // keymap.Bind({XK_Return, kControlMask | kShiftMask}, &Editor::CommitComment); keymap.Bind({XK_Delete, 0}, &Editor::DeleteChar); diff --git a/src/rime/gear/fallback_segmentor.cc b/src/rime/gear/fallback_segmentor.cc index 3c10581f2..bef53ea5c 100644 --- a/src/rime/gear/fallback_segmentor.cc +++ b/src/rime/gear/fallback_segmentor.cc @@ -11,8 +11,7 @@ namespace rime { FallbackSegmentor::FallbackSegmentor(const Ticket& ticket) - : Segmentor(ticket) { -} + : Segmentor(ticket) {} bool FallbackSegmentor::Proceed(Segmentation* segmentation) { int len = segmentation->GetCurrentSegmentLength(); @@ -37,8 +36,8 @@ bool FallbackSegmentor::Proceed(Segmentation* segmentation) { // append one character to the last raw segment if (last.HasTag("raw")) { last.end = k + 1; - DLOG(INFO) << "extend previous raw segment to [" - << last.start << ", " << last.end << ")"; + DLOG(INFO) << "extend previous raw segment to [" << last.start << ", " + << last.end << ")"; // mark redo translation (in case it's been previously translated) last.Clear(); last.tags.insert("raw"); @@ -47,8 +46,8 @@ bool FallbackSegmentor::Proceed(Segmentation* segmentation) { } { Segment segment(k, k + 1); - DLOG(INFO) << "add a raw segment [" - << segment.start << ", " << segment.end << ")"; + DLOG(INFO) << "add a raw segment [" << segment.start << ", " << segment.end + << ")"; segment.tags.insert("raw"); segmentation->Forward(); segmentation->AddSegment(segment); diff --git a/src/rime/gear/filter_commons.h b/src/rime/gear/filter_commons.h index 2c8fbf337..de1a58da9 100644 --- a/src/rime/gear/filter_commons.h +++ b/src/rime/gear/filter_commons.h @@ -7,7 +7,6 @@ #ifndef RIME_FILTER_COMMONS_H_ #define RIME_FILTER_COMMONS_H_ - namespace rime { struct Segment; diff --git a/src/rime/gear/gears_module.cc b/src/rime/gear/gears_module.cc index d1feaff32..a41e1468d 100644 --- a/src/rime/gear/gears_module.cc +++ b/src/rime/gear/gears_module.cc @@ -90,7 +90,6 @@ static void rime_gears_initialize() { r.Register("shape_formatter", new Component); } -static void rime_gears_finalize() { -} +static void rime_gears_finalize() {} RIME_REGISTER_MODULE(gears) diff --git a/src/rime/gear/grammar.h b/src/rime/gear/grammar.h index 9d545ed78..f80733350 100644 --- a/src/rime/gear/grammar.h +++ b/src/rime/gear/grammar.h @@ -20,9 +20,9 @@ class Grammar : public Class { double entry_weight, bool is_rear, Grammar* grammar) { - const double kPenalty = -18.420680743952367; // log(1e-8) + const double kPenalty = -18.420680743952367; // log(1e-8) return entry_weight + - (grammar ? grammar->Query(context, entry_text, is_rear) : kPenalty); + (grammar ? grammar->Query(context, entry_text, is_rear) : kPenalty); } }; diff --git a/src/rime/gear/history_translator.cc b/src/rime/gear/history_translator.cc index eb4469c9d..d49c72441 100644 --- a/src/rime/gear/history_translator.cc +++ b/src/rime/gear/history_translator.cc @@ -16,10 +16,7 @@ namespace rime { HistoryTranslator::HistoryTranslator(const Ticket& ticket) - : Translator(ticket), - tag_("abc"), - size_(1), - initial_quality_(1000) { + : Translator(ticket), tag_("abc"), size_(1), initial_quality_(1000) { if (ticket.name_space == "translator") { name_space_ = "history"; } @@ -29,8 +26,7 @@ HistoryTranslator::HistoryTranslator(const Ticket& ticket) config->GetString(name_space_ + "/tag", &tag_); config->GetString(name_space_ + "/input", &input_); config->GetInt(name_space_ + "/size", &size_); - config->GetDouble(name_space_ + "/initial_quality", - &initial_quality_); + config->GetDouble(name_space_ + "/initial_quality", &initial_quality_); } an HistoryTranslator::Query(const string& input, @@ -47,15 +43,15 @@ an HistoryTranslator::Query(const string& input, auto it = history.rbegin(); int count = 0; for (; it != history.rend(); ++it) { - if (it->type == "thru") continue; - auto candidate = New(it->type, - segment.start, - segment.end, - it->text); + if (it->type == "thru") + continue; + auto candidate = + New(it->type, segment.start, segment.end, it->text); candidate->set_quality(initial_quality_); translation->Append(candidate); count++; - if (size_ == count) break; + if (size_ == count) + break; } return translation; } diff --git a/src/rime/gear/history_translator.h b/src/rime/gear/history_translator.h index b039d78ea..eaebd9cae 100644 --- a/src/rime/gear/history_translator.h +++ b/src/rime/gear/history_translator.h @@ -15,8 +15,7 @@ class HistoryTranslator : public Translator { public: HistoryTranslator(const Ticket& ticket); - virtual an Query(const string& input, - const Segment& segment); + virtual an Query(const string& input, const Segment& segment); protected: string tag_; diff --git a/src/rime/gear/key_binder.cc b/src/rime/gear/key_binder.cc index b5000fa53..32631e3a9 100644 --- a/src/rime/gear/key_binder.cc +++ b/src/rime/gear/key_binder.cc @@ -32,13 +32,11 @@ enum KeyBindingCondition { static struct KeyBindingConditionDef { KeyBindingCondition condition; const char* name; -} condition_definitions[] = { - { kWhenPaging, "paging" }, - { kWhenHasMenu, "has_menu" }, - { kWhenComposing, "composing" }, - { kAlways, "always" }, - { kNever, NULL } -}; +} condition_definitions[] = {{kWhenPaging, "paging"}, + {kWhenHasMenu, "has_menu"}, + {kWhenComposing, "composing"}, + {kAlways, "always"}, + {kNever, NULL}}; static KeyBindingCondition translate_condition(const string& str) { for (auto* d = condition_definitions; d->name; ++d) { @@ -51,15 +49,12 @@ static KeyBindingCondition translate_condition(const string& str) { struct KeyBinding { KeyBindingCondition whence; KeySequence target; - function action; + function action; - bool operator< (const KeyBinding& o) const { - return whence < o.whence; - } + bool operator<(const KeyBinding& o) const { return whence < o.whence; } }; -class KeyBindings : public map> { +class KeyBindings : public map> { public: void LoadBindings(const an& bindings); void Bind(const KeyEvent& key, const KeyBinding& binding); @@ -68,8 +63,7 @@ class KeyBindings : public mapget_option(option.option_name) != value) { ctx->set_option(option.option_name, value); @@ -87,7 +81,8 @@ static Switches::SwitchOption switch_by_index(Switches& switches, try { size_t index = boost::lexical_cast(option.substr(1)); return switches.ByIndex(index); - } catch (...) {} + } catch (...) { + } return {}; } @@ -96,16 +91,13 @@ static void toggle_option(Engine* engine, const string& option) { return; Context* ctx = engine->context(); Switches switches(engine->schema()->config()); - auto the_option = is_switch_index(option) - ? switch_by_index(switches, option) - : switches.OptionByName(option); + auto the_option = is_switch_index(option) ? switch_by_index(switches, option) + : switches.OptionByName(option); if (the_option.found() && the_option.type == Switches::kRadioGroup) { auto selected_option = switches.FindRadioGroupOption( - the_option.the_switch, - [ctx](Switches::SwitchOption option) { - return ctx->get_option(option.option_name) - ? Switches::kFound - : Switches::kContinue; + the_option.the_switch, [ctx](Switches::SwitchOption option) { + return ctx->get_option(option.option_name) ? Switches::kFound + : Switches::kContinue; }); if (!selected_option.found()) { // invalid state: none is selected. select the given option. @@ -162,8 +154,7 @@ static void select_schema(Engine* engine, const string& schema) { if (schema == ".next") { Switcher switcher(engine); switcher.SelectNextSchema(); - } - else { + } else { engine->ApplySchema(new Schema(schema)); } } @@ -199,26 +190,20 @@ void KeyBindings::LoadBindings(const an& bindings) { LOG(WARNING) << "invalid key binding #" << i << "."; continue; } - } - else if (auto target = map->GetValue("send_sequence")) { + } else if (auto target = map->GetValue("send_sequence")) { if (!binding.target.Parse(target->str())) { LOG(WARNING) << "invalid key sequence #" << i << "."; continue; } - } - else if (auto option = map->GetValue("toggle")) { + } else if (auto option = map->GetValue("toggle")) { binding.action = std::bind(&toggle_option, _1, option->str()); - } - else if (auto option = map->GetValue("set_option")) { + } else if (auto option = map->GetValue("set_option")) { binding.action = std::bind(&set_option, _1, option->str()); - } - else if (auto option = map->GetValue("unset_option")) { + } else if (auto option = map->GetValue("unset_option")) { binding.action = std::bind(&unset_option, _1, option->str()); - } - else if (auto schema = map->GetValue("select")) { + } else if (auto schema = map->GetValue("select")) { binding.action = std::bind(&select_schema, _1, schema->str()); - } - else { + } else { LOG(WARNING) << "invalid key binding #" << i << "."; continue; } @@ -233,10 +218,11 @@ void KeyBindings::Bind(const KeyEvent& key, const KeyBinding& binding) { vec.insert(lb, binding); } -KeyBinder::KeyBinder(const Ticket& ticket) : Processor(ticket), - key_bindings_(new KeyBindings), - redirecting_(false), - last_key_(0) { +KeyBinder::KeyBinder(const Ticket& ticket) + : Processor(ticket), + key_bindings_(new KeyBindings), + redirecting_(false), + last_key_(0) { LoadConfig(); } @@ -283,8 +269,7 @@ ProcessResult KeyBinder::ProcessKeyEvent(const KeyEvent& key_event) { void KeyBinder::PerformKeyBinding(const KeyBinding& binding) { if (binding.action) { binding.action(engine_); - } - else { + } else { redirecting_ = true; for (const KeyEvent& key_event : binding.target) { engine_->ProcessKey(key_event); @@ -316,8 +301,8 @@ bool KeyBinder::ReinterpretPagingKey(const KeyEvent& key_event) { Context* ctx = engine_->context(); const string& input(ctx->input()); if (!input.empty() && input[input.length() - 1] != '.') { - LOG(INFO) << "reinterpreted key: '" << last_key_ - << "', successor: '" << (char)ch << "'"; + LOG(INFO) << "reinterpreted key: '" << last_key_ << "', successor: '" + << (char)ch << "'"; ctx->PushInput(last_key_); ret = true; } diff --git a/src/rime/gear/key_binding_processor_impl.h b/src/rime/gear/key_binding_processor_impl.h index a3de636af..e283770b1 100644 --- a/src/rime/gear/key_binding_processor_impl.h +++ b/src/rime/gear/key_binding_processor_impl.h @@ -7,7 +7,7 @@ namespace rime { template const typename KeyBindingProcessor::ActionDef - KeyBindingProcessor::kActionNoop = { "noop", nullptr }; + KeyBindingProcessor::kActionNoop = {"noop", nullptr}; template ProcessResult KeyBindingProcessor::ProcessKeyEvent( @@ -27,18 +27,15 @@ ProcessResult KeyBindingProcessor::ProcessKeyEvent( if (key_event.shift()) { if ((fallback_options & ShiftAsControl) != 0) { KeyEvent shift_as_control{ - key_event.keycode(), - (key_event.modifier() & ~kShiftMask) | kControlMask - }; + key_event.keycode(), + (key_event.modifier() & ~kShiftMask) | kControlMask}; if (Accept(shift_as_control, ctx, keymap)) { return kAccepted; } } if ((fallback_options & IgnoreShift) != 0) { - KeyEvent ignore_shift{ - key_event.keycode(), - key_event.modifier() & ~kShiftMask - }; + KeyEvent ignore_shift{key_event.keycode(), + key_event.modifier() & ~kShiftMask}; if (Accept(ignore_shift, ctx, keymap)) { return kAccepted; } @@ -75,8 +72,7 @@ void KeyBindingProcessor::Keymap::Bind(KeyEvent key_event, HandlerPtr action) { if (action) { (*this)[key_event] = action; - } - else { + } else { this->erase(key_event); } } diff --git a/src/rime/gear/matcher.cc b/src/rime/gear/matcher.cc index 469c06b38..22968c642 100644 --- a/src/rime/gear/matcher.cc +++ b/src/rime/gear/matcher.cc @@ -25,15 +25,15 @@ bool Matcher::Proceed(Segmentation* segmentation) { return true; auto match = patterns_.GetMatch(segmentation->input(), *segmentation); if (match.found()) { - DLOG(INFO) << "match: " << match.tag - << " [" << match.start << ", " << match.end << ")"; + DLOG(INFO) << "match: " << match.tag << " [" << match.start << ", " + << match.end << ")"; while (segmentation->GetCurrentStartPosition() > match.start) segmentation->pop_back(); Segment segment(match.start, match.end); segment.tags.insert(match.tag); segmentation->AddSegment(segment); // terminate this round? - //return false; + // return false; } return true; } diff --git a/src/rime/gear/memory.cc b/src/rime/gear/memory.cc index 3bc7671d8..ad475caba 100644 --- a/src/rime/gear/memory.cc +++ b/src/rime/gear/memory.cc @@ -27,14 +27,12 @@ void CommitEntry::Clear() { void CommitEntry::AppendPhrase(const an& phrase) { text += phrase->text(); - code.insert(code.end(), - phrase->code().begin(), phrase->code().end()); + code.insert(code.end(), phrase->code().begin(), phrase->code().end()); if (auto sentence = As(phrase)) { for (const DictEntry& e : sentence->components()) { elements.push_back(&e); } - } - else { + } else { elements.push_back(&phrase->entry()); } } @@ -69,13 +67,13 @@ Memory::Memory(const Ticket& ticket) { // user dictionary is named after language; dictionary name may have an // optional suffix separated from the language component by dot. language_.reset( - user_dict_ ? new Language{user_dict_->name()} : - dict_ ? new Language{Language::get_language_component(dict_->name())} : - nullptr); + user_dict_ ? new Language{user_dict_->name()} + : dict_ ? new Language{Language::get_language_component(dict_->name())} + : nullptr); Context* ctx = ticket.engine->context(); - commit_connection_ = ctx->commit_notifier().connect( - [this](Context* ctx) { OnCommit(ctx); }); + commit_connection_ = + ctx->commit_notifier().connect([this](Context* ctx) { OnCommit(ctx); }); delete_connection_ = ctx->delete_notifier().connect( [this](Context* ctx) { OnDeleteEntry(ctx); }); unhandled_key_connection_ = ctx->unhandled_key_notifier().connect( @@ -101,13 +99,13 @@ bool Memory::DiscardSession() { } void Memory::OnCommit(Context* ctx) { - if (!user_dict_|| user_dict_->readonly()) + if (!user_dict_ || user_dict_->readonly()) return; StartSession(); CommitEntry commit_entry(this); for (auto& seg : ctx->composition()) { - auto phrase = As(Candidate::GetGenuineCandidate( - seg.GetSelectedCandidate())); + auto phrase = + As(Candidate::GetGenuineCandidate(seg.GetSelectedCandidate())); bool recognized = Language::intelligible(phrase, this); if (recognized) { commit_entry.AppendPhrase(phrase); @@ -120,13 +118,10 @@ void Memory::OnCommit(Context* ctx) { } void Memory::OnDeleteEntry(Context* ctx) { - if (!user_dict_ || - user_dict_->readonly() || - !ctx || - !ctx->HasMenu()) + if (!user_dict_ || user_dict_->readonly() || !ctx || !ctx->HasMenu()) return; - auto phrase = As(Candidate::GetGenuineCandidate( - ctx->GetSelectedCandidate())); + auto phrase = + As(Candidate::GetGenuineCandidate(ctx->GetSelectedCandidate())); if (Language::intelligible(phrase, this)) { const DictEntry& entry(phrase->entry()); LOG(INFO) << "deleting entry: '" << entry.text << "'."; diff --git a/src/rime/gear/navigator.cc b/src/rime/gear/navigator.cc index 0423d2b64..3b51c449a 100644 --- a/src/rime/gear/navigator.cc +++ b/src/rime/gear/navigator.cc @@ -18,20 +18,17 @@ namespace rime { static Navigator::ActionDef navigation_actions[] = { - { "rewind", &Navigator::Rewind }, - { "left_by_char", &Navigator::LeftByChar }, - { "right_by_char", &Navigator::RightByChar }, - { "left_by_syllable", &Navigator::LeftBySyllable }, - { "right_by_syllable", &Navigator::RightBySyllable }, - { "home", &Navigator::Home }, - { "end", &Navigator::End }, - Navigator::kActionNoop -}; + {"rewind", &Navigator::Rewind}, + {"left_by_char", &Navigator::LeftByChar}, + {"right_by_char", &Navigator::RightByChar}, + {"left_by_syllable", &Navigator::LeftBySyllable}, + {"right_by_syllable", &Navigator::RightBySyllable}, + {"home", &Navigator::Home}, + {"end", &Navigator::End}, + Navigator::kActionNoop}; Navigator::Navigator(const Ticket& ticket) - : Processor(ticket), - KeyBindingProcessor(navigation_actions) -{ + : Processor(ticket), KeyBindingProcessor(navigation_actions) { // default key bindings { auto& keymap = get_keymap(Horizontal); @@ -72,9 +69,9 @@ ProcessResult Navigator::ProcessKeyEvent(const KeyEvent& key_event) { if (!ctx->IsComposing()) return kNoop; TextOrientation text_orientation = - ctx->get_option("_vertical") ? Vertical : Horizontal; - return KeyBindingProcessor::ProcessKeyEvent( - key_event, ctx, text_orientation, FallbackOptions::All); + ctx->get_option("_vertical") ? Vertical : Horizontal; + return KeyBindingProcessor::ProcessKeyEvent(key_event, ctx, text_orientation, + FallbackOptions::All); } bool Navigator::LeftBySyllable(Context* ctx) { @@ -94,10 +91,9 @@ bool Navigator::Rewind(Context* ctx) { BeginMove(ctx); // take a jump leftwards when there are multiple spans, // but not from the middle of a span. - ( - spans_.Count() > 1 && spans_.HasVertex(ctx->caret_pos()) - ? JumpLeft(ctx) : MoveLeft(ctx) - ) || GoToEnd(ctx); + (spans_.Count() > 1 && spans_.HasVertex(ctx->caret_pos()) ? JumpLeft(ctx) + : MoveLeft(ctx)) || + GoToEnd(ctx); return true; } @@ -132,10 +128,9 @@ void Navigator::BeginMove(Context* ctx) { if (input_ != ctx->input() || ctx->caret_pos() > spans_.end()) { input_ = ctx->input(); spans_.Clear(); - for (const auto &seg : ctx->composition()) { + for (const auto& seg : ctx->composition()) { if (auto phrase = As( - Candidate::GetGenuineCandidate( - seg.GetSelectedCandidate()))) { + Candidate::GetGenuineCandidate(seg.GetSelectedCandidate()))) { spans_.AddSpans(phrase->spans()); } spans_.AddSpan(seg.start, seg.end); diff --git a/src/rime/gear/poet.cc b/src/rime/gear/poet.cc index 7cf9ce17d..2345867d0 100644 --- a/src/rime/gear/poet.cc +++ b/src/rime/gear/poet.cc @@ -29,22 +29,17 @@ struct Line { static const Line kEmpty; - bool empty() const { - return !predecessor && !entry; - } + bool empty() const { return !predecessor && !entry; } - string last_word() const { - return entry ? entry->text : string(); - } + string last_word() const { return entry ? entry->text : string(); } struct Components { vector lines; Components(const Line* line) { - for (const Line* cursor = line; - !cursor->empty(); + for (const Line* cursor = line; !cursor->empty(); cursor = cursor->predecessor) { - lines.push_back(cursor); + lines.push_back(cursor); } } @@ -56,9 +51,10 @@ struct Line { string context() const { // look back 2 words - return empty() ? string() : - !predecessor || predecessor->empty() ? last_word() : - predecessor->last_word() + last_word(); + return empty() ? string() + : !predecessor || predecessor->empty() + ? last_word() + : predecessor->last_word() + last_word(); } vector word_lengths() const { @@ -94,16 +90,18 @@ bool Poet::CompareWeight(const Line& one, const Line& other) { // returns true if one is less than other. bool Poet::LeftAssociateCompare(const Line& one, const Line& other) { - if (one.weight < other.weight) return true; + if (one.weight < other.weight) + return true; if (one.weight == other.weight) { auto one_word_lens = one.word_lengths(); auto other_word_lens = other.word_lengths(); // less words is more favorable - if (one_word_lens.size() > other_word_lens.size()) return true; + if (one_word_lens.size() > other_word_lens.size()) + return true; if (one_word_lens.size() == other_word_lens.size()) { return std::lexicographical_compare( - one_word_lens.begin(), one_word_lens.end(), - other_word_lens.begin(), other_word_lens.end()); + one_word_lens.begin(), one_word_lens.end(), other_word_lens.begin(), + other_word_lens.end()); } } return false; @@ -113,22 +111,24 @@ bool Poet::LeftAssociateCompare(const Line& one, const Line& other) { using LineCandidates = hash_map; template -static vector find_top_candidates( - const LineCandidates& candidates, Poet::Compare compare) { +static vector find_top_candidates(const LineCandidates& candidates, + Poet::Compare compare) { vector top; top.reserve(N + 1); for (const auto& candidate : candidates) { auto pos = std::upper_bound( top.begin(), top.end(), &candidate.second, - [&](const Line* a, const Line* b) { return compare(*b, *a); }); // desc - if (pos - top.begin() >= N) continue; + [&](const Line* a, const Line* b) { return compare(*b, *a); }); // desc + if (pos - top.begin() >= N) + continue; top.insert(pos, &candidate.second); - if (top.size() > N) top.pop_back(); + if (top.size() > N) + top.pop_back(); } return top; } -using UpdateLineCandidate = function; +using UpdateLineCandidate = function; struct BeamSearch { using State = LineCandidates; @@ -169,9 +169,7 @@ struct BeamSearch { struct DynamicProgramming { using State = Line; - static void Initiate(State& initial_state) { - initial_state = Line::kEmpty; - } + static void Initiate(State& initial_state) { initial_state = Line::kEmpty; } static void ForEachCandidate(const State& state, Poet::Compare compare, @@ -201,38 +199,34 @@ an Poet::MakeSentenceWithStrategy(const WordGraph& graph, continue; DLOG(INFO) << "start pos: " << start_pos; const auto& source_state = states[start_pos]; - const auto update = - [this, &states, &sv, start_pos, total_length, &preceding_text] - (const Line& candidate) { - for (const auto& ev : sv.second) { - size_t end_pos = ev.first; - if (start_pos == 0 && end_pos == total_length) - continue; // exclude single word from the result - DLOG(INFO) << "end pos: " << end_pos; - bool is_rear = end_pos == total_length; - auto& target_state = states[end_pos]; - // extend candidates with dict entries on a valid edge. - const DictEntryList& entries = ev.second; - for (const auto& entry : entries) { - const string& context = - candidate.empty() ? preceding_text : candidate.context(); - double weight = candidate.weight + - Grammar::Evaluate(context, - entry->text, - entry->weight, - is_rear, - grammar_.get()); - Line new_line{&candidate, entry.get(), end_pos, weight}; - Line& best = Strategy::BestLineToUpdate(target_state, new_line); - if (best.empty() || compare_(best, new_line)) { - DLOG(INFO) << "updated line ending at " << end_pos - << " with text: ..." << new_line.last_word() - << " weight: " << new_line.weight; - best = new_line; - } - } + const auto update = [this, &states, &sv, start_pos, total_length, + &preceding_text](const Line& candidate) { + for (const auto& ev : sv.second) { + size_t end_pos = ev.first; + if (start_pos == 0 && end_pos == total_length) + continue; // exclude single word from the result + DLOG(INFO) << "end pos: " << end_pos; + bool is_rear = end_pos == total_length; + auto& target_state = states[end_pos]; + // extend candidates with dict entries on a valid edge. + const DictEntryList& entries = ev.second; + for (const auto& entry : entries) { + const string& context = + candidate.empty() ? preceding_text : candidate.context(); + double weight = candidate.weight + + Grammar::Evaluate(context, entry->text, entry->weight, + is_rear, grammar_.get()); + Line new_line{&candidate, entry.get(), end_pos, weight}; + Line& best = Strategy::BestLineToUpdate(target_state, new_line); + if (best.empty() || compare_(best, new_line)) { + DLOG(INFO) << "updated line ending at " << end_pos + << " with text: ..." << new_line.last_word() + << " weight: " << new_line.weight; + best = new_line; } - }; + } + } + }; Strategy::ForEachCandidate(source_state, compare_, update); } auto found = states.find(total_length); @@ -241,7 +235,8 @@ an Poet::MakeSentenceWithStrategy(const WordGraph& graph, const Line& best = Strategy::BestLineInState(found->second, compare_); auto sentence = New(language_); for (const auto* c : best.components()) { - if (!c->entry) continue; + if (!c->entry) + continue; sentence->Extend(*c->entry, c->end_pos, c->weight); } return sentence; @@ -250,11 +245,10 @@ an Poet::MakeSentenceWithStrategy(const WordGraph& graph, an Poet::MakeSentence(const WordGraph& graph, size_t total_length, const string& preceding_text) { - return grammar_ ? - MakeSentenceWithStrategy( - graph, total_length, preceding_text) : - MakeSentenceWithStrategy( - graph, total_length, preceding_text); + return grammar_ ? MakeSentenceWithStrategy(graph, total_length, + preceding_text) + : MakeSentenceWithStrategy( + graph, total_length, preceding_text); } } // namespace rime diff --git a/src/rime/gear/poet.h b/src/rime/gear/poet.h index c9cc822ea..2e2af15cc 100644 --- a/src/rime/gear/poet.h +++ b/src/rime/gear/poet.h @@ -26,12 +26,13 @@ struct Line; class Poet { public: // Line "less", used to compare composed line of the same input range. - using Compare = function; + using Compare = function; static bool CompareWeight(const Line& one, const Line& other); static bool LeftAssociateCompare(const Line& one, const Line& other); - Poet(const Language* language, Config* config, + Poet(const Language* language, + Config* config, Compare compare = CompareWeight); ~Poet(); @@ -51,8 +52,8 @@ class Poet { if (preceding_text.empty()) { return translation; } - return New( - translation, input, preceding_text, grammar_.get()); + return New(translation, input, preceding_text, + grammar_.get()); } private: diff --git a/src/rime/gear/punctuator.cc b/src/rime/gear/punctuator.cc index 8a01eda02..a391b8515 100644 --- a/src/rime/gear/punctuator.cc +++ b/src/rime/gear/punctuator.cc @@ -59,13 +59,13 @@ static bool punctuation_is_translated(Context* ctx) { } ProcessResult Punctuator::ProcessKeyEvent(const KeyEvent& key_event) { - if (key_event.release() || - key_event.ctrl() || key_event.alt() || key_event.super()) + if (key_event.release() || key_event.ctrl() || key_event.alt() || + key_event.super()) return kNoop; int ch = key_event.keycode(); if (ch < 0x20 || ch >= 0x7f) return kNoop; - Context *ctx = engine_->context(); + Context* ctx = engine_->context(); if (ctx->get_option("ascii_punct")) { return kNoop; } @@ -76,8 +76,7 @@ ProcessResult Punctuator::ProcessKeyEvent(const KeyEvent& key_event) { const CommitHistory& history(ctx->commit_history()); if (!history.empty()) { const CommitRecord& cr(history.back()); - if (cr.type == "thru" && - cr.text.length() == 1 && isdigit(cr.text[0])) { + if (cr.type == "thru" && cr.text.length() == 1 && isdigit(cr.text[0])) { return kRejected; } } @@ -89,11 +88,9 @@ ProcessResult Punctuator::ProcessKeyEvent(const KeyEvent& key_event) { return kNoop; DLOG(INFO) << "punct key: '" << punct_key << "'"; if (!AlternatePunct(punct_key, punct_definition)) { - ctx->PushInput(ch) && - punctuation_is_translated(ctx) && + ctx->PushInput(ch) && punctuation_is_translated(ctx) && (ConfirmUniquePunct(punct_definition) || - AutoCommitPunct(punct_definition) || - PairPunct(punct_definition)); + AutoCommitPunct(punct_definition) || PairPunct(punct_definition)); } return kAccepted; } @@ -107,8 +104,7 @@ bool Punctuator::AlternatePunct(const string& key, if (comp.empty()) return false; Segment& segment(comp.back()); - if (segment.status > Segment::kVoid && - segment.HasTag("punct") && + if (segment.status > Segment::kVoid && segment.HasTag("punct") && key == ctx->input().substr(segment.start, segment.end - segment.start)) { if (!segment.menu || segment.menu->Prepare(segment.selected_index + 2) == 0) { @@ -181,22 +177,21 @@ bool PunctSegmentor::Proceed(Segmentation* segmentation) { return true; { Segment segment(k, k + 1); - DLOG(INFO) << "add a punctuation segment [" - << segment.start << ", " << segment.end << ")"; + DLOG(INFO) << "add a punctuation segment [" << segment.start << ", " + << segment.end << ")"; segment.tags.insert("punct"); segmentation->AddSegment(segment); } return false; // exclusive } -PunctTranslator::PunctTranslator(const Ticket& ticket) - : Translator(ticket) { +PunctTranslator::PunctTranslator(const Ticket& ticket) : Translator(ticket) { const bool load_symbols = true; config_.LoadConfig(engine_, load_symbols); } -an -CreatePunctCandidate(const string& punct, const Segment& segment) { +an CreatePunctCandidate(const string& punct, + const Segment& segment) { const char half_shape[] = "\xe3\x80\x94\xe5\x8d\x8a\xe8\xa7\x92\xe3\x80\x95"; // 〔半角〕 const char full_shape[] = @@ -209,29 +204,35 @@ CreatePunctCandidate(const string& punct, const Segment& segment) { bool is_ascii = (ch >= 0x20 && ch < 0x7F); bool is_ideographic_space = (ch == 0x3000); bool is_full_shape_ascii = (ch >= 0xFF01 && ch <= 0xFF5E); - bool is_kana = ((ch >= 0x30A1 && ch <= 0x30FC) || ch == 0x3001 || ch == 0x3002 || ch == 0x300C || ch == 0x300D || ch == 0x309B || ch == 0x309C); + bool is_kana = + ((ch >= 0x30A1 && ch <= 0x30FC) || ch == 0x3001 || ch == 0x3002 || + ch == 0x300C || ch == 0x300D || ch == 0x309B || ch == 0x309C); bool is_half_shape_kana = (ch >= 0xFF61 && ch <= 0xFF9F); - bool is_hangul = (ch >= 0x3131 && ch <= 0x3164); + bool is_hangul = (ch >= 0x3131 && ch <= 0x3164); bool is_half_shape_hangul = (ch >= 0xFFA0 && ch <= 0xFFDC); - bool is_full_shape_narrow_symbol = (ch == 0xFF5F || ch == 0xFF60 || (ch >= 0xFFE0 && ch <= 0xFFE6)); - bool is_narrow_symbol = (ch == 0x00A2 || ch == 0x00A3 || ch == 0x00A5 || ch == 0x00A6 || ch == 0x00AC || ch == 0x00AF || ch == 0x2985 || ch == 0x2986); + bool is_full_shape_narrow_symbol = + (ch == 0xFF5F || ch == 0xFF60 || (ch >= 0xFFE0 && ch <= 0xFFE6)); + bool is_narrow_symbol = + (ch == 0x00A2 || ch == 0x00A3 || ch == 0x00A5 || ch == 0x00A6 || + ch == 0x00AC || ch == 0x00AF || ch == 0x2985 || ch == 0x2986); bool is_half_shape_wide_symbol = (ch >= 0xFFE8 && ch <= 0xFFEE); - bool is_wide_symbol = ((ch >= 0x2190 && ch <= 0x2193) || ch == 0x2502 || ch == 0x25A0 || ch == 0x25CB); - is_half_shape = is_ascii || is_half_shape_kana || is_half_shape_hangul || is_narrow_symbol || is_half_shape_wide_symbol; - is_full_shape = is_ideographic_space || is_full_shape_ascii || is_kana || is_hangul || is_full_shape_narrow_symbol || is_wide_symbol; + bool is_wide_symbol = ((ch >= 0x2190 && ch <= 0x2193) || ch == 0x2502 || + ch == 0x25A0 || ch == 0x25CB); + is_half_shape = is_ascii || is_half_shape_kana || is_half_shape_hangul || + is_narrow_symbol || is_half_shape_wide_symbol; + is_full_shape = is_ideographic_space || is_full_shape_ascii || is_kana || + is_hangul || is_full_shape_narrow_symbol || is_wide_symbol; } bool one_key = (segment.end - segment.start == 1); - return New("punct", - segment.start, - segment.end, - punct, - (is_half_shape ? half_shape : - is_full_shape ? full_shape : ""), + return New("punct", segment.start, segment.end, punct, + (is_half_shape ? half_shape + : is_full_shape ? full_shape + : ""), one_key ? punct : ""); } an PunctTranslator::Query(const string& input, - const Segment& segment) { + const Segment& segment) { if (!segment.HasTag("punct")) return nullptr; config_.LoadConfig(engine_); @@ -239,63 +240,63 @@ an PunctTranslator::Query(const string& input, if (!definition) return nullptr; DLOG(INFO) << "populating punctuation candidates for '" << input << "'."; - auto translation = TranslateUniquePunct(input, segment, - As(definition)); + auto translation = + TranslateUniquePunct(input, segment, As(definition)); if (!translation) - translation = TranslateAlternatingPunct(input, segment, - As(definition)); + translation = + TranslateAlternatingPunct(input, segment, As(definition)); if (!translation) - translation = TranslateAutoCommitPunct(input, segment, - As(definition)); + translation = + TranslateAutoCommitPunct(input, segment, As(definition)); if (!translation) - translation = TranslatePairedPunct(input, segment, - As(definition)); - //if (translation) { - // const char tips[] = - // "\xe3\x80\x94\xe7\xac\xa6\xe8\x99\x9f\xe3\x80\x95"; // 〔符號〕 - // const_cast(&segment)->prompt = tips; - //} + translation = + TranslatePairedPunct(input, segment, As(definition)); + // if (translation) { + // const char tips[] = + // "\xe3\x80\x94\xe7\xac\xa6\xe8\x99\x9f\xe3\x80\x95"; // 〔符號〕 + // const_cast(&segment)->prompt = tips; + // } return translation; } -an -PunctTranslator::TranslateUniquePunct(const string& key, - const Segment& segment, - const an& definition) { +an PunctTranslator::TranslateUniquePunct( + const string& key, + const Segment& segment, + const an& definition) { if (!definition) return nullptr; return New( CreatePunctCandidate(definition->str(), segment)); } -an -PunctTranslator::TranslateAlternatingPunct(const string& key, - const Segment& segment, - const an& definition) { +an PunctTranslator::TranslateAlternatingPunct( + const string& key, + const Segment& segment, + const an& definition) { if (!definition) return nullptr; auto translation = New(); for (size_t i = 0; i < definition->size(); ++i) { auto value = definition->GetValueAt(i); if (!value) { - LOG(WARNING) << "invalid alternating punct at index " << i - << " for '" << key << "'."; + LOG(WARNING) << "invalid alternating punct at index " << i << " for '" + << key << "'."; continue; } translation->Append(CreatePunctCandidate(value->str(), segment)); } if (!translation->size()) { - LOG(WARNING) << "empty candidate list for alternating punct '" - << key << "'."; + LOG(WARNING) << "empty candidate list for alternating punct '" << key + << "'."; translation.reset(); } return translation; } -an -PunctTranslator::TranslateAutoCommitPunct(const string& key, - const Segment& segment, - const an& definition) { +an PunctTranslator::TranslateAutoCommitPunct( + const string& key, + const Segment& segment, + const an& definition) { if (!definition || !definition->HasKey("commit")) return nullptr; auto value = definition->GetValue("commit"); @@ -306,10 +307,10 @@ PunctTranslator::TranslateAutoCommitPunct(const string& key, return New(CreatePunctCandidate(value->str(), segment)); } -an -PunctTranslator::TranslatePairedPunct(const string& key, - const Segment& segment, - const an& definition) { +an PunctTranslator::TranslatePairedPunct( + const string& key, + const Segment& segment, + const an& definition) { if (!definition || !definition->HasKey("pair")) return nullptr; auto list = As(definition->Get("pair")); @@ -321,15 +322,15 @@ PunctTranslator::TranslatePairedPunct(const string& key, for (size_t i = 0; i < list->size(); ++i) { auto value = list->GetValueAt(i); if (!value) { - LOG(WARNING) << "invalid paired punct at index " << i - << " for '" << key << "'."; + LOG(WARNING) << "invalid paired punct at index " << i << " for '" << key + << "'."; continue; } translation->Append(CreatePunctCandidate(value->str(), segment)); } if (translation->size() != 2) { - LOG(WARNING) << "invalid num of candidate for paired punct '" - << key << "'."; + LOG(WARNING) << "invalid num of candidate for paired punct '" << key + << "'."; translation.reset(); } return translation; diff --git a/src/rime/gear/punctuator.h b/src/rime/gear/punctuator.h index dc4713f1b..836ec3aab 100644 --- a/src/rime/gear/punctuator.h +++ b/src/rime/gear/punctuator.h @@ -22,6 +22,7 @@ class PunctConfig { public: void LoadConfig(Engine* engine, bool load_symbols = false); an GetPunctDefinition(const string key); + protected: string shape_; an mapping_; @@ -56,26 +57,21 @@ class PunctSegmentor : public Segmentor { class PunctTranslator : public Translator { public: PunctTranslator(const Ticket& ticket); - virtual an Query(const string& input, - const Segment& segment); + virtual an Query(const string& input, const Segment& segment); protected: - an - TranslateUniquePunct(const string& key, - const Segment& segment, - const an& definition); - an - TranslateAlternatingPunct(const string& key, - const Segment& segment, - const an& definition); - an - TranslateAutoCommitPunct(const string& key, - const Segment& segment, - const an& definition); - an - TranslatePairedPunct(const string& key, - const Segment& segment, - const an& definition); + an TranslateUniquePunct(const string& key, + const Segment& segment, + const an& definition); + an TranslateAlternatingPunct(const string& key, + const Segment& segment, + const an& definition); + an TranslateAutoCommitPunct(const string& key, + const Segment& segment, + const an& definition); + an TranslatePairedPunct(const string& key, + const Segment& segment, + const an& definition); PunctConfig config_; }; diff --git a/src/rime/gear/recognizer.cc b/src/rime/gear/recognizer.cc index 0582379ef..6ceffd603 100644 --- a/src/rime/gear/recognizer.cc +++ b/src/rime/gear/recognizer.cc @@ -26,8 +26,8 @@ static void load_patterns(RecognizerPatterns* patterns, an map) { boost::regex pattern(value->str()); (*patterns)[it->first] = pattern; } catch (boost::regex_error& e) { - LOG(ERROR) << "error parsing pattern /" << value->str() << "/: " - << e.what(); + LOG(ERROR) << "error parsing pattern /" << value->str() + << "/: " << e.what(); } } } @@ -36,9 +36,9 @@ void RecognizerPatterns::LoadConfig(Config* config) { load_patterns(this, config->GetMap("recognizer/patterns")); } -RecognizerMatch -RecognizerPatterns::GetMatch(const string& input, - const Segmentation& segmentation) const { +RecognizerMatch RecognizerPatterns::GetMatch( + const string& input, + const Segmentation& segmentation) const { size_t j = segmentation.GetCurrentEndPosition(); size_t k = segmentation.GetConfirmedPosition(); string active_input = input.substr(k); @@ -51,16 +51,16 @@ RecognizerPatterns::GetMatch(const string& input, if (end != input.length()) continue; if (start == j) { - DLOG(INFO) << "input [" << start << ", " << end << ") '" - << m.str() << "' matches pattern: " << v.first; + DLOG(INFO) << "input [" << start << ", " << end << ") '" << m.str() + << "' matches pattern: " << v.first; return {v.first, start, end}; } for (const Segment& seg : segmentation) { if (start < seg.start) break; if (start == seg.start) { - DLOG(INFO) << "input [" << start << ", " << end << ") '" - << m.str() << "' matches pattern: " << v.first; + DLOG(INFO) << "input [" << start << ", " << end << ") '" << m.str() + << "' matches pattern: " << v.first; return {v.first, start, end}; } } @@ -79,14 +79,12 @@ Recognizer::Recognizer(const Ticket& ticket) : Processor(ticket) { } ProcessResult Recognizer::ProcessKeyEvent(const KeyEvent& key_event) { - if (patterns_.empty() || - key_event.ctrl() || key_event.alt() || key_event.super() || - key_event.release()) { + if (patterns_.empty() || key_event.ctrl() || key_event.alt() || + key_event.super() || key_event.release()) { return kNoop; } int ch = key_event.keycode(); - if ((use_space_ && ch == ' ') || - (ch > 0x20 && ch < 0x80)) { + if ((use_space_ && ch == ' ') || (ch > 0x20 && ch < 0x80)) { // pattern matching against the input string plus the incoming character Context* ctx = engine_->context(); string input = ctx->input(); diff --git a/src/rime/gear/reverse_lookup_filter.cc b/src/rime/gear/reverse_lookup_filter.cc index 671c6a513..796f552af 100644 --- a/src/rime/gear/reverse_lookup_filter.cc +++ b/src/rime/gear/reverse_lookup_filter.cc @@ -18,8 +18,7 @@ class ReverseLookupFilterTranslation : public CacheTranslation { public: ReverseLookupFilterTranslation(an translation, ReverseLookupFilter* filter) - : CacheTranslation(translation), filter_(filter) { - } + : CacheTranslation(translation), filter_(filter) {} virtual an Peek(); protected: @@ -58,8 +57,8 @@ void ReverseLookupFilter::Initialize() { } } -an ReverseLookupFilter::Apply( - an translation, CandidateList* candidates) { +an ReverseLookupFilter::Apply(an translation, + CandidateList* candidates) { if (!initialized_) { Initialize(); } diff --git a/src/rime/gear/reverse_lookup_filter.h b/src/rime/gear/reverse_lookup_filter.h index 104c72236..e297ed5db 100644 --- a/src/rime/gear/reverse_lookup_filter.h +++ b/src/rime/gear/reverse_lookup_filter.h @@ -21,11 +21,9 @@ class ReverseLookupFilter : public Filter, TagMatching { explicit ReverseLookupFilter(const Ticket& ticket); virtual an Apply(an translation, - CandidateList* candidates); + CandidateList* candidates); - virtual bool AppliesToSegment(Segment* segment) { - return TagsMatch(segment); - } + virtual bool AppliesToSegment(Segment* segment) { return TagsMatch(segment); } void Process(const an& cand); diff --git a/src/rime/gear/reverse_lookup_translator.cc b/src/rime/gear/reverse_lookup_translator.cc index dcdf5bb4c..9fb4aa144 100644 --- a/src/rime/gear/reverse_lookup_translator.cc +++ b/src/rime/gear/reverse_lookup_translator.cc @@ -18,10 +18,9 @@ #include #include - -//static const char* quote_left = "\xef\xbc\x88"; -//static const char* quote_right = "\xef\xbc\x89"; -//static const char* separator = "\xef\xbc\x8c"; +// static const char* quote_left = "\xef\xbc\x88"; +// static const char* quote_right = "\xef\xbc\x89"; +// static const char* separator = "\xef\xbc\x8c"; namespace rime { @@ -30,17 +29,24 @@ class ReverseLookupTranslation : public TableTranslation { ReverseLookupTranslation(ReverseLookupDictionary* dict, TranslatorOptions* options, const string& input, - size_t start, size_t end, + size_t start, + size_t end, const string& preedit, DictEntryIterator&& iter, bool quality) - : TableTranslation( - options, NULL, input, start, end, preedit, std::move(iter)), - dict_(dict), options_(options), quality_(quality) { - } + : TableTranslation(options, + NULL, + input, + start, + end, + preedit, + std::move(iter)), + dict_(dict), + options_(options), + quality_(quality) {} virtual an Peek(); - virtual int Compare(an other, - const CandidateList& candidates); + virtual int Compare(an other, const CandidateList& candidates); + protected: ReverseLookupDictionary* dict_; TranslatorOptions* options_; @@ -57,17 +63,13 @@ an ReverseLookupTranslation::Peek() { if (options_) { options_->comment_formatter().Apply(&tips); } - //if (!tips.empty()) { - // boost::algorithm::replace_all(tips, " ", separator); - //} + // if (!tips.empty()) { + // boost::algorithm::replace_all(tips, " ", separator); + // } } - an cand = New( - "reverse_lookup", - start_, - end_, - entry->text, - !tips.empty() ? tips : entry->comment, - preedit_); + an cand = + New("reverse_lookup", start_, end_, entry->text, + !tips.empty() ? tips : entry->comment, preedit_); return cand; } @@ -121,8 +123,7 @@ void ReverseLookupTranslator::Initialize() { } if (dict_) { dict_->Load(); - } - else { + } else { return; } auto rev_component = @@ -140,15 +141,15 @@ void ReverseLookupTranslator::Initialize() { } an ReverseLookupTranslator::Query(const string& input, - const Segment& segment) { + const Segment& segment) { if (!segment.HasTag(tag_)) return nullptr; if (!initialized_) Initialize(); // load reverse dict at first use if (!dict_ || !dict_->loaded()) return nullptr; - DLOG(INFO) << "input = '" << input - << "', [" << segment.start << ", " << segment.end << ")"; + DLOG(INFO) << "input = '" << input << "', [" << segment.start << ", " + << segment.end << ")"; const string& preedit(input); @@ -172,36 +173,28 @@ an ReverseLookupTranslator::Query(const string& input, if (start < input.length()) { if (options_ && options_->enable_completion()) { dict_->LookupWords(&iter, code, true, 100); - quality = !iter.exhausted() && - (iter.Peek()->remaining_code_length == 0); - } - else { + quality = !iter.exhausted() && (iter.Peek()->remaining_code_length == 0); + } else { // 2012-04-08 gongchen: fetch multi-syllable words from rev-lookup table SyllableGraph graph; Syllabifier syllabifier("", true, options_->strict_spelling()); - size_t consumed = syllabifier.BuildSyllableGraph(code, - *dict_->prism(), - &graph); + size_t consumed = + syllabifier.BuildSyllableGraph(code, *dict_->prism(), &graph); if (consumed == code.length()) { auto collector = dict_->Lookup(graph, 0); if (collector && !collector->empty() && collector->rbegin()->first == consumed) { iter = std::move(collector->rbegin()->second); quality = !graph.vertices.empty() && - (graph.vertices.rbegin()->second == kNormalSpelling); + (graph.vertices.rbegin()->second == kNormalSpelling); } } } } if (!iter.exhausted()) { - return Cached(rev_dict_.get(), - options_.get(), - code, - segment.start, - segment.end, - preedit, - std::move(iter), - quality); + return Cached(rev_dict_.get(), options_.get(), + code, segment.start, segment.end, + preedit, std::move(iter), quality); } return nullptr; } diff --git a/src/rime/gear/reverse_lookup_translator.h b/src/rime/gear/reverse_lookup_translator.h index 3db01c4f3..7ca038f61 100644 --- a/src/rime/gear/reverse_lookup_translator.h +++ b/src/rime/gear/reverse_lookup_translator.h @@ -21,8 +21,7 @@ class ReverseLookupTranslator : public Translator { public: ReverseLookupTranslator(const Ticket& ticket); - virtual an Query(const string& input, - const Segment& segment); + virtual an Query(const string& input, const Segment& segment); protected: void Initialize(); diff --git a/src/rime/gear/schema_list_translator.cc b/src/rime/gear/schema_list_translator.cc index b44985cff..4a9b6138b 100644 --- a/src/rime/gear/schema_list_translator.cc +++ b/src/rime/gear/schema_list_translator.cc @@ -20,8 +20,7 @@ class SchemaSelection : public SimpleCandidate, public SwitcherCommand { public: SchemaSelection(Schema* schema) : SimpleCandidate("schema", 0, 0, schema->schema_name()), - SwitcherCommand(schema->schema_id()) { - } + SwitcherCommand(schema->schema_id()) {} virtual void Apply(Switcher* switcher); }; @@ -40,12 +39,10 @@ void SchemaSelection::Apply(Switcher* switcher) { class SchemaAction : public ShadowCandidate, public SwitcherCommand { public: - SchemaAction(an schema, - an command) + SchemaAction(an schema, an command) : ShadowCandidate(schema, command->type()), SwitcherCommand(As(schema)->keyword()), - command_(As(command)) { - } + command_(As(command)) {} virtual void Apply(Switcher* switcher); private: @@ -60,11 +57,8 @@ void SchemaAction::Apply(Switcher* switcher) { class SchemaListTranslation : public FifoTranslation { public: - SchemaListTranslation(Switcher* switcher) { - LoadSchemaList(switcher); - } - virtual int Compare(an other, - const CandidateList& candidates); + SchemaListTranslation(Switcher* switcher) { LoadSchemaList(switcher); } + virtual int Compare(an other, const CandidateList& candidates); protected: void LoadSchemaList(Switcher* switcher); @@ -107,23 +101,21 @@ void SchemaListTranslation::LoadSchemaList(Switcher* switcher) { size_t fixed = candies_.size(); time_t now = time(NULL); // load the rest schema list - Switcher::ForEachSchemaListEntry( - config, - [this, current_schema, user_config, now](const string& schema_id) { - if (current_schema && schema_id == current_schema->schema_id()) - return /* continue = */true; - Schema schema(schema_id); - auto cand = New(&schema); - int timestamp = 0; - if (user_config && - user_config->GetInt("var/schema_access_time/" + schema_id, - ×tamp)) { - if (timestamp <= now) - cand->set_quality(timestamp); - } - Append(cand); - return /* continue = */true; - }); + Switcher::ForEachSchemaListEntry(config, [this, current_schema, user_config, + now](const string& schema_id) { + if (current_schema && schema_id == current_schema->schema_id()) + return /* continue = */ true; + Schema schema(schema_id); + auto cand = New(&schema); + int timestamp = 0; + if (user_config && user_config->GetInt( + "var/schema_access_time/" + schema_id, ×tamp)) { + if (timestamp <= now) + cand->set_quality(timestamp); + } + Append(cand); + return /* continue = */ true; + }); DLOG(INFO) << "num schemata: " << candies_.size(); bool fix_order = false; config->GetBool("switcher/fix_schema_list_order", &fix_order); @@ -131,17 +123,16 @@ void SchemaListTranslation::LoadSchemaList(Switcher* switcher) { return; // reorder schema list by recency std::stable_sort(candies_.begin() + fixed, candies_.end(), - [](const an& x, const an& y) { - return x->quality() > y->quality(); - }); + [](const an& x, const an& y) { + return x->quality() > y->quality(); + }); } SchemaListTranslator::SchemaListTranslator(const Ticket& ticket) - : Translator(ticket) { -} + : Translator(ticket) {} an SchemaListTranslator::Query(const string& input, - const Segment& segment) { + const Segment& segment) { auto switcher = dynamic_cast(engine_); if (!switcher) { return nullptr; diff --git a/src/rime/gear/schema_list_translator.h b/src/rime/gear/schema_list_translator.h index ce32703c6..fd0d17205 100644 --- a/src/rime/gear/schema_list_translator.h +++ b/src/rime/gear/schema_list_translator.h @@ -16,8 +16,7 @@ class SchemaListTranslator : public Translator { public: SchemaListTranslator(const Ticket& ticket); - virtual an Query(const string& input, - const Segment& segment); + virtual an Query(const string& input, const Segment& segment); }; } // namespace rime diff --git a/src/rime/gear/script_translator.cc b/src/rime/gear/script_translator.cc index e220aed9c..9506c9e7c 100644 --- a/src/rime/gear/script_translator.cc +++ b/src/rime/gear/script_translator.cc @@ -26,9 +26,8 @@ #include #include - -//static const char* quote_left = "\xef\xbc\x88"; -//static const char* quote_right = "\xef\xbc\x89"; +// static const char* quote_left = "\xef\xbc\x88"; +// static const char* quote_right = "\xef\xbc\x89"; namespace rime { @@ -38,13 +37,17 @@ struct SyllabifyTask { const Code& code; const SyllableGraph& graph; size_t target_pos; - function push; - function pop; + function + push; + function pop; }; static bool syllabify_dfs(SyllabifyTask* task, - size_t depth, size_t current_pos) { + size_t depth, + size_t current_pos) { if (depth == task->code.size()) { return current_pos == task->target_pos; } @@ -76,7 +79,9 @@ class ScriptSyllabifier : public PhraseSyllabifier { Corrector* corrector, const string& input, size_t start) - : translator_(translator), input_(input), start_(start), + : translator_(translator), + input_(input), + start_(start), syllabifier_(translator->delimiters(), translator->enable_completion(), translator->strict_spelling()) { @@ -111,8 +116,8 @@ class ScriptTranslation : public Translation { : translator_(translator), poet_(poet), start_(start), - syllabifier_(New( - translator, corrector, input, start)), + syllabifier_( + New(translator, corrector, input, start)), enable_correction_(corrector) { set_exhausted(true); } @@ -152,9 +157,7 @@ class ScriptTranslation : public Translation { // ScriptTranslator implementation ScriptTranslator::ScriptTranslator(const Ticket& ticket) - : Translator(ticket), - Memory(ticket), - TranslatorOptions(ticket) { + : Translator(ticket), Memory(ticket), TranslatorOptions(ticket) { if (!engine_) return; if (Config* config = engine_->schema()->config()) { @@ -178,23 +181,19 @@ an ScriptTranslator::Query(const string& input, return nullptr; if (!segment.HasTag(tag_)) return nullptr; - DLOG(INFO) << "input = '" << input - << "', [" << segment.start << ", " << segment.end << ")"; + DLOG(INFO) << "input = '" << input << "', [" << segment.start << ", " + << segment.end << ")"; FinishSession(); - bool enable_user_dict = user_dict_ && user_dict_->loaded() && - !IsUserDictDisabledFor(input); + bool enable_user_dict = + user_dict_ && user_dict_->loaded() && !IsUserDictDisabledFor(input); // the translator should survive translations it creates - auto result = New(this, - corrector_.get(), - poet_.get(), - input, - segment.start); - if (!result || - !result->Evaluate(dict_.get(), - enable_user_dict ? user_dict_.get() : NULL)) { + auto result = New(this, corrector_.get(), poet_.get(), + input, segment.start); + if (!result || !result->Evaluate( + dict_.get(), enable_user_dict ? user_dict_.get() : NULL)) { return nullptr; } auto deduped = New(result); @@ -215,16 +214,15 @@ string ScriptTranslator::Spell(const Code& code) { vector syllables; if (!dict_ || !dict_->Decode(code, &syllables) || syllables.empty()) return result; - result = boost::algorithm::join(syllables, - string(1, delimiters_.at(0))); + result = boost::algorithm::join(syllables, string(1, delimiters_.at(0))); comment_formatter_.Apply(&result); return result; } string ScriptTranslator::GetPrecedingText(size_t start) const { - return !contextual_suggestions_ ? string() : - start > 0 ? engine_->context()->composition().GetTextBefore(start) : - engine_->context()->commit_history().latest_text(); + return !contextual_suggestions_ ? string() + : start > 0 ? engine_->context()->composition().GetTextBefore(start) + : engine_->context()->commit_history().latest_text(); } bool ScriptTranslator::Memorize(const CommitEntry& commit_entry) { @@ -255,17 +253,10 @@ Spans ScriptSyllabifier::Syllabify(const Phrase* phrase) { vector vertices; vertices.push_back(start_); SyllabifyTask task{ - phrase->code(), - syllable_graph_, - phrase->end() - start_, - [&](SyllabifyTask* task, size_t depth, - size_t current_pos, size_t next_pos) { - vertices.push_back(start_ + next_pos); - }, - [&](SyllabifyTask* task, size_t depth) { - vertices.pop_back(); - } - }; + phrase->code(), syllable_graph_, phrase->end() - start_, + [&](SyllabifyTask* task, size_t depth, size_t current_pos, + size_t next_pos) { vertices.push_back(start_ + next_pos); }, + [&](SyllabifyTask* task, size_t depth) { vertices.pop_back(); }}; if (syllabify_dfs(&task, 0, phrase->start() - start_)) { result.set_vertices(std::move(vertices)); } @@ -273,40 +264,36 @@ Spans ScriptSyllabifier::Syllabify(const Phrase* phrase) { } size_t ScriptSyllabifier::BuildSyllableGraph(Prism& prism) { - return (size_t)syllabifier_.BuildSyllableGraph(input_, - prism, + return (size_t)syllabifier_.BuildSyllableGraph(input_, prism, &syllable_graph_); } -bool ScriptSyllabifier::IsCandidateCorrection(const rime::Phrase &cand) const { +bool ScriptSyllabifier::IsCandidateCorrection(const rime::Phrase& cand) const { std::stack results; - // Perform DFS on syllable graph to find whether this candidate is a correction - SyllabifyTask task { - cand.code(), - syllable_graph_, - cand.end() - start_, - [&](SyllabifyTask* task, size_t depth, - size_t current_pos, size_t next_pos) { - auto id = cand.code()[depth]; - auto it_s = syllable_graph_.edges.find(current_pos); - // C++ prohibit operator [] of const map - // if (syllable_graph_.edges[current_pos][next_pos][id].type == kCorrection) - if (it_s != syllable_graph_.edges.end()) { - auto it_e = it_s->second.find(next_pos); - if (it_e != it_s->second.end()) { - auto it_type = it_e->second.find(id); - if (it_type != it_e->second.end()) { - results.push(it_type->second.is_correction); - return; - } - } - } - results.push(false); - }, - [&](SyllabifyTask* task, size_t depth) { - results.pop(); - } - }; + // Perform DFS on syllable graph to find whether this candidate is a + // correction + SyllabifyTask task{cand.code(), syllable_graph_, cand.end() - start_, + [&](SyllabifyTask* task, size_t depth, size_t current_pos, + size_t next_pos) { + auto id = cand.code()[depth]; + auto it_s = syllable_graph_.edges.find(current_pos); + // C++ prohibit operator [] of const map + // if + // (syllable_graph_.edges[current_pos][next_pos][id].type + // == kCorrection) + if (it_s != syllable_graph_.edges.end()) { + auto it_e = it_s->second.find(next_pos); + if (it_e != it_s->second.end()) { + auto it_type = it_e->second.find(id); + if (it_type != it_e->second.end()) { + results.push(it_type->second.is_correction); + return; + } + } + } + results.push(false); + }, + [&](SyllabifyTask* task, size_t depth) { results.pop(); }}; if (syllabify_dfs(&task, 0, cand.start() - start_)) { for (; !results.empty(); results.pop()) { if (results.top()) @@ -320,29 +307,25 @@ string ScriptSyllabifier::GetPreeditString(const Phrase& cand) const { const auto& delimiters = translator_->delimiters(); std::stack lengths; string output; - SyllabifyTask task{ - cand.code(), - syllable_graph_, - cand.end() - start_, - [&](SyllabifyTask* task, size_t depth, - size_t current_pos, size_t next_pos) { - size_t len = output.length(); - if (depth > 0 && len > 0 && - delimiters.find(output[len - 1]) == string::npos) { - output += delimiters.at(0); - } - output += input_.substr(current_pos, next_pos - current_pos); - lengths.push(len); - }, - [&](SyllabifyTask* task, size_t depth) { - output.resize(lengths.top()); - lengths.pop(); - } - }; + SyllabifyTask task{cand.code(), syllable_graph_, cand.end() - start_, + [&](SyllabifyTask* task, size_t depth, size_t current_pos, + size_t next_pos) { + size_t len = output.length(); + if (depth > 0 && len > 0 && + delimiters.find(output[len - 1]) == string::npos) { + output += delimiters.at(0); + } + output += + input_.substr(current_pos, next_pos - current_pos); + lengths.push(len); + }, + [&](SyllabifyTask* task, size_t depth) { + output.resize(lengths.top()); + lengths.pop(); + }}; if (syllabify_dfs(&task, 0, cand.start() - start_)) { return translator_->FormatPreedit(output); - } - else { + } else { return string(); } } @@ -409,8 +392,7 @@ bool ScriptTranslation::Next() { if (!uter.Next()) { ++user_phrase_iter_; } - } - else if (phrase_code_length > 0) { + } else if (phrase_code_length > 0) { DictEntryIterator& iter(phrase_iter_->second); if (!iter.Next()) { ++phrase_iter_; @@ -423,9 +405,8 @@ bool ScriptTranslation::Next() { } is_correction = syllabifier_->IsCandidateCorrection(*candidate_); } - } while ( // limit the number of correction candidates - enable_correction_ && - is_correction && + } while ( // limit the number of correction candidates + enable_correction_ && is_correction && correction_count_ > max_corrections_); if (is_correction) { ++correction_count_; @@ -436,7 +417,7 @@ bool ScriptTranslation::Next() { bool ScriptTranslation::IsNormalSpelling() const { const auto& syllable_graph = syllabifier_->syllable_graph(); return !syllable_graph.vertices.empty() && - (syllable_graph.vertices.rbegin()->second == kNormalSpelling); + (syllable_graph.vertices.rbegin()->second == kNormalSpelling); } an ScriptTranslation::Peek() { @@ -449,10 +430,9 @@ an ScriptTranslation::Peek() { } if (candidate_->comment().empty()) { auto spelling = syllabifier_->GetOriginalSpelling(*candidate_); - if (!spelling.empty() && - (translator_->always_show_comments() || - spelling != candidate_->preedit())) { - candidate_->set_comment(/*quote_left + */spelling/* + quote_right*/); + if (!spelling.empty() && (translator_->always_show_comments() || + spelling != candidate_->preedit())) { + candidate_->set_comment(/*quote_left + */ spelling /* + quote_right*/); } } candidate_->set_syllabifier(syllabifier_); @@ -483,28 +463,19 @@ void ScriptTranslation::PrepareCandidate() { const auto& entry = uter.Peek(); DLOG(INFO) << "user phrase '" << entry->text << "', code length: " << user_phrase_code_length; - cand = New(translator_->language(), - "user_phrase", - start_, - start_ + user_phrase_code_length, - entry); - cand->set_quality(std::exp(entry->weight) + - translator_->initial_quality() + - (IsNormalSpelling() ? 0.5 : -0.5)); - } - else if (phrase_code_length > 0) { + cand = New(translator_->language(), "user_phrase", start_, + start_ + user_phrase_code_length, entry); + cand->set_quality(std::exp(entry->weight) + translator_->initial_quality() + + (IsNormalSpelling() ? 0.5 : -0.5)); + } else if (phrase_code_length > 0) { DictEntryIterator& iter = phrase_iter_->second; const auto& entry = iter.Peek(); DLOG(INFO) << "phrase '" << entry->text << "', code length: " << phrase_code_length; - cand = New(translator_->language(), - "phrase", - start_, - start_ + phrase_code_length, - entry); - cand->set_quality(std::exp(entry->weight) + - translator_->initial_quality() + - (IsNormalSpelling() ? 0 : -1)); + cand = New(translator_->language(), "phrase", start_, + start_ + phrase_code_length, entry); + cand->set_quality(std::exp(entry->weight) + translator_->initial_quality() + + (IsNormalSpelling() ? 0 : -1)); } candidate_ = cand; } @@ -541,17 +512,15 @@ an ScriptTranslation::MakeSentence(Dictionary* dict, auto& same_start_pos = graph[x.first]; if (user_dict) { EnrollEntries(same_start_pos, - user_dict->Lookup(syllable_graph, - x.first, + user_dict->Lookup(syllable_graph, x.first, kMaxSyllablesForUserPhraseQuery)); } // merge lookup results EnrollEntries(same_start_pos, dict->Lookup(syllable_graph, x.first)); } if (auto sentence = - poet_->MakeSentence(graph, - syllable_graph.interpreted_length, - translator_->GetPrecedingText(start_))) { + poet_->MakeSentence(graph, syllable_graph.interpreted_length, + translator_->GetPrecedingText(start_))) { sentence->Offset(start_); sentence->set_syllabifier(syllabifier_); return sentence; diff --git a/src/rime/gear/script_translator.h b/src/rime/gear/script_translator.h index a681a1147..f13a37eaa 100644 --- a/src/rime/gear/script_translator.h +++ b/src/rime/gear/script_translator.h @@ -30,8 +30,7 @@ class ScriptTranslator : public Translator, public: ScriptTranslator(const Ticket& ticket); - virtual an Query(const string& input, - const Segment& segment); + virtual an Query(const string& input, const Segment& segment); virtual bool Memorize(const CommitEntry& commit_entry); string FormatPreedit(const string& preedit); diff --git a/src/rime/gear/selector.cc b/src/rime/gear/selector.cc index f55719c04..06874103d 100644 --- a/src/rime/gear/selector.cc +++ b/src/rime/gear/selector.cc @@ -17,19 +17,17 @@ namespace rime { static Selector::ActionDef selector_actions[] = { - { "previous_candidate", &Selector::PreviousCandidate }, - { "next_candidate", &Selector::NextCandidate }, - { "previous_page", &Selector::PreviousPage }, - { "next_page", &Selector::NextPage }, - { "home", &Selector::Home }, - { "end", &Selector::End }, - Selector::kActionNoop, + {"previous_candidate", &Selector::PreviousCandidate}, + {"next_candidate", &Selector::NextCandidate}, + {"previous_page", &Selector::PreviousPage}, + {"next_page", &Selector::NextPage}, + {"home", &Selector::Home}, + {"end", &Selector::End}, + Selector::kActionNoop, }; Selector::Selector(const Ticket& ticket) - : Processor(ticket), - KeyBindingProcessor(selector_actions) -{ + : Processor(ticket), KeyBindingProcessor(selector_actions) { // default key bindings { auto& keymap = get_keymap(Horizontal | Stacked); @@ -113,13 +111,12 @@ inline static bool is_vertical_text(Context* ctx) { inline static bool is_linear_layout(Context* ctx) { return ctx->get_option("_linear") || - // Deprecated. equivalent to {_linear: true, _vertical: false} - ctx->get_option("_horizontal"); + // Deprecated. equivalent to {_linear: true, _vertical: false} + ctx->get_option("_horizontal"); } ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) { - if (key_event.release() || - key_event.alt() || key_event.super()) + if (key_event.release() || key_event.alt() || key_event.super()) return kNoop; Context* ctx = engine_->context(); if (ctx->composition().empty()) @@ -129,14 +126,12 @@ ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) { return kNoop; TextOrientation text_orientation = - is_vertical_text(ctx) ? Vertical : Horizontal; + is_vertical_text(ctx) ? Vertical : Horizontal; CandidateListLayout candidate_list_layout = - is_linear_layout(ctx) ? Linear : Stacked; + is_linear_layout(ctx) ? Linear : Stacked; auto result = KeyBindingProcessor::ProcessKeyEvent( - key_event, - ctx, - text_orientation | candidate_list_layout, - FallbackOptions::None); + key_event, ctx, text_orientation | candidate_list_layout, + FallbackOptions::None); if (result != kNoop) { return result; } @@ -144,15 +139,12 @@ ProcessResult Selector::ProcessKeyEvent(const KeyEvent& key_event) { int ch = key_event.keycode(); int index = -1; const string& select_keys(engine_->schema()->select_keys()); - if (!select_keys.empty() && - !key_event.ctrl() && - ch >= 0x20 && ch < 0x7f) { + if (!select_keys.empty() && !key_event.ctrl() && ch >= 0x20 && ch < 0x7f) { size_t pos = select_keys.find((char)ch); if (pos != string::npos) { index = static_cast(pos); } - } - else if (ch >= XK_0 && ch <= XK_9) + } else if (ch >= XK_0 && ch <= XK_9) index = ((ch - XK_0) + 9) % 10; else if (ch >= XK_KP_0 && ch <= XK_KP_9) index = ((ch - XK_KP_0) + 9) % 10; @@ -186,7 +178,7 @@ bool Selector::NextPage(Context* ctx) { int candidate_count = comp.back().menu->Prepare(page_start + page_size); if (candidate_count <= page_start) { bool page_down_cycle = engine_->schema()->page_down_cycle(); - if (page_down_cycle) {// Cycle back to page 1 if true + if (page_down_cycle) { // Cycle back to page 1 if true index = 0; } else { // no-op; consume the key event so that page down is not sent to the app. diff --git a/src/rime/gear/shape.cc b/src/rime/gear/shape.cc index 937346c48..37a078896 100644 --- a/src/rime/gear/shape.cc +++ b/src/rime/gear/shape.cc @@ -24,12 +24,10 @@ void ShapeFormatter::Format(string* text) { for (char ch : *text) { if (ch == 0x20) { oss << "\xe3\x80\x80"; - } - else if (ch > 0x20 && ch <= 0x7e) { + } else if (ch > 0x20 && ch <= 0x7e) { ch -= 0x20; - oss << '\xef' << char('\xbc' + ch / 0x40) << char('\x80' + ch % 0x40); - } - else { + oss << '\xef' << char('\xbc' + ch / 0x40) << char('\x80' + ch % 0x40); + } else { oss << ch; } } diff --git a/src/rime/gear/shape.h b/src/rime/gear/shape.h index 5a4fca093..16ba53a11 100644 --- a/src/rime/gear/shape.h +++ b/src/rime/gear/shape.h @@ -15,16 +15,14 @@ namespace rime { class ShapeFormatter : public Formatter { public: - ShapeFormatter(const Ticket& ticket) : Formatter(ticket) { - } + ShapeFormatter(const Ticket& ticket) : Formatter(ticket) {} virtual void Format(string* text); }; class ShapeProcessor : public Processor { public: - ShapeProcessor(const Ticket& ticket) : Processor(ticket), - formatter_(ticket) { - } + ShapeProcessor(const Ticket& ticket) + : Processor(ticket), formatter_(ticket) {} virtual ProcessResult ProcessKeyEvent(const KeyEvent& key_event); private: diff --git a/src/rime/gear/simplifier.cc b/src/rime/gear/simplifier.cc index 9e233396e..4ff3c7514 100644 --- a/src/rime/gear/simplifier.cc +++ b/src/rime/gear/simplifier.cc @@ -18,14 +18,14 @@ #include #include #include -#include // Place OpenCC #includes here to avoid VS2015 compilation errors +#include // Place OpenCC #includes here to avoid VS2015 compilation errors #include #include #include #include #include -static const char* quote_left = "\xe3\x80\x94"; //"\xef\xbc\x88"; +static const char* quote_left = "\xe3\x80\x94"; //"\xef\xbc\x88"; static const char* quote_right = "\xe3\x80\x95"; //"\xef\xbc\x89"; namespace rime { @@ -38,16 +38,16 @@ class Opencc { try { converter_ = config.NewFromFile(config_path); const list conversions = - converter_->GetConversionChain()->GetConversions(); + converter_->GetConversionChain()->GetConversions(); dict_ = conversions.front()->GetDict(); - } - catch (...) { + } catch (...) { LOG(ERROR) << "opencc config not found: " << config_path; } } bool ConvertWord(const string& text, vector* forms) { - if (dict_ == nullptr) return false; + if (dict_ == nullptr) + return false; opencc::Optional item = dict_->Match(text); if (item.IsNull()) { // Match not found @@ -62,11 +62,13 @@ class Opencc { } bool RandomConvertText(const string& text, string* simplified) { - if (dict_ == nullptr) return false; - const char *phrase = text.c_str(); + if (dict_ == nullptr) + return false; + const char* phrase = text.c_str(); std::ostringstream buffer; for (const char* pstr = phrase; *pstr != '\0';) { - opencc::Optional matched = dict_->MatchPrefix(pstr); + opencc::Optional matched = + dict_->MatchPrefix(pstr); size_t matchedLength; if (matched.IsNull()) { matchedLength = opencc::UTF8Util::NextCharLength(pstr); @@ -83,20 +85,21 @@ class Opencc { } bool ConvertText(const string& text, string* simplified) { - if (converter_ == nullptr) return false; + if (converter_ == nullptr) + return false; *simplified = converter_->Convert(text); return *simplified != text; } private: - opencc::ConverterPtr converter_; - opencc::DictPtr dict_; + opencc::ConverterPtr converter_; + opencc::DictPtr dict_; }; // Simplifier -Simplifier::Simplifier(const Ticket& ticket) : Filter(ticket), - TagMatching(ticket) { +Simplifier::Simplifier(const Ticket& ticket) + : Filter(ticket), TagMatching(ticket) { if (name_space_ == "filter") { name_space_ = "simplifier"; } @@ -104,8 +107,9 @@ Simplifier::Simplifier(const Ticket& ticket) : Filter(ticket), string tips; if (config->GetString(name_space_ + "/tips", &tips) || config->GetString(name_space_ + "/tip", &tips)) { - tips_level_ = (tips == "all") ? kTipsAll : - (tips == "char") ? kTipsChar : kTipsNone; + tips_level_ = (tips == "all") ? kTipsAll + : (tips == "char") ? kTipsChar + : kTipsNone; } config->GetBool(name_space_ + "/show_in_comment", &show_in_comment_); config->GetBool(name_space_ + "/inherit_comment", &inherit_comment_); @@ -147,25 +151,21 @@ void Simplifier::Initialize() { (shared_config_path /= "opencc") /= opencc_config_path; if (exists(user_config_path)) { opencc_config_path = user_config_path; - } - else if (exists(shared_config_path)) { + } else if (exists(shared_config_path)) { opencc_config_path = shared_config_path; } } try { opencc_.reset(new Opencc(opencc_config_path.string())); - } - catch (opencc::Exception& e) { + } catch (opencc::Exception& e) { LOG(ERROR) << "Error initializing opencc: " << e.what(); } } class SimplifiedTranslation : public PrefetchTranslation { public: - SimplifiedTranslation(an translation, - Simplifier* simplifier) - : PrefetchTranslation(translation), simplifier_(simplifier) { - } + SimplifiedTranslation(an translation, Simplifier* simplifier) + : PrefetchTranslation(translation), simplifier_(simplifier) {} protected: virtual bool Replenish(); @@ -173,7 +173,6 @@ class SimplifiedTranslation : public PrefetchTranslation { Simplifier* simplifier_; }; - bool SimplifiedTranslation::Replenish() { auto next = translation_->Peek(); translation_->Next(); @@ -184,7 +183,7 @@ bool SimplifiedTranslation::Replenish() { } an Simplifier::Apply(an translation, - CandidateList* candidates) { + CandidateList* candidates) { if (!engine_->context()->get_option(option_name_)) { // off return translation; } @@ -198,13 +197,15 @@ an Simplifier::Apply(an translation, } void Simplifier::PushBack(const an& original, - CandidateQueue* result, const string& simplified) { + CandidateQueue* result, + const string& simplified) { string tips; string text; - size_t length = utf8::unchecked::distance(original->text().c_str(), - original->text().c_str() - + original->text().length()); - bool show_tips = (tips_level_ == kTipsChar && length == 1) || tips_level_ == kTipsAll; + size_t length = utf8::unchecked::distance( + original->text().c_str(), + original->text().c_str() + original->text().length()); + bool show_tips = + (tips_level_ == kTipsChar && length == 1) || tips_level_ == kTipsAll; if (show_in_comment_) { text = original->text(); if (show_tips) { @@ -221,13 +222,8 @@ void Simplifier::PushBack(const an& original, } } } - result->push_back( - New( - original, - "simplified", - text, - tips, - inherit_comment_)); + result->push_back(New(original, "simplified", text, tips, + inherit_comment_)); } bool Simplifier::Convert(const an& original, @@ -242,7 +238,7 @@ bool Simplifier::Convert(const an& original, if (success) { PushBack(original, result, simplified); } - } else { //!random_ + } else { //! random_ vector forms; success = opencc_->ConvertWord(original->text(), &forms); if (success) { diff --git a/src/rime/gear/simplifier.h b/src/rime/gear/simplifier.h index 5de255e29..703f18e60 100644 --- a/src/rime/gear/simplifier.h +++ b/src/rime/gear/simplifier.h @@ -22,13 +22,9 @@ class Simplifier : public Filter, TagMatching { virtual an Apply(an translation, CandidateList* candidates); + virtual bool AppliesToSegment(Segment* segment) { return TagsMatch(segment); } - virtual bool AppliesToSegment(Segment* segment) { - return TagsMatch(segment); - } - - bool Convert(const an& original, - CandidateQueue* result); + bool Convert(const an& original, CandidateQueue* result); protected: enum TipsLevel { kTipsNone, kTipsChar, kTipsAll }; @@ -41,7 +37,7 @@ class Simplifier : public Filter, TagMatching { bool initialized_ = false; the opencc_; // settings - TipsLevel tips_level_ = kTipsNone; + TipsLevel tips_level_ = kTipsNone; string option_name_; string opencc_config_; set excluded_types_; diff --git a/src/rime/gear/single_char_filter.cc b/src/rime/gear/single_char_filter.cc index 3f7e81c89..f7164aff4 100644 --- a/src/rime/gear/single_char_filter.cc +++ b/src/rime/gear/single_char_filter.cc @@ -13,8 +13,7 @@ namespace rime { static inline size_t unistrlen(const string& text) { - return utf8::unchecked::distance( - text.c_str(), text.c_str() + text.length()); + return utf8::unchecked::distance(text.c_str(), text.c_str() + text.length()); } class SingleCharFirstTranslation : public PrefetchTranslation { @@ -40,13 +39,13 @@ bool SingleCharFirstTranslation::Rearrange() { while (!translation_->exhausted()) { auto cand = translation_->Peek(); auto phrase = As(Candidate::GetGenuineCandidate(cand)); - if (!phrase || (phrase->type() != "table" && phrase->type() != "user_table")) { + if (!phrase || + (phrase->type() != "table" && phrase->type() != "user_table")) { break; } if (unistrlen(cand->text()) == 1) { top.push_back(cand); - } - else { + } else { bottom.push_back(cand); } translation_->Next(); @@ -56,12 +55,10 @@ bool SingleCharFirstTranslation::Rearrange() { return !cache_.empty(); } -SingleCharFilter::SingleCharFilter(const Ticket& ticket) - : Filter(ticket) { -} +SingleCharFilter::SingleCharFilter(const Ticket& ticket) : Filter(ticket) {} -an SingleCharFilter::Apply( - an translation, CandidateList* candidates) { +an SingleCharFilter::Apply(an translation, + CandidateList* candidates) { return New(translation); } diff --git a/src/rime/gear/single_char_filter.h b/src/rime/gear/single_char_filter.h index 48c168bd1..2e6c04d53 100644 --- a/src/rime/gear/single_char_filter.h +++ b/src/rime/gear/single_char_filter.h @@ -16,7 +16,7 @@ class SingleCharFilter : public Filter { explicit SingleCharFilter(const Ticket& ticket); virtual an Apply(an translation, - CandidateList* candidates); + CandidateList* candidates); }; } // namespace rime diff --git a/src/rime/gear/speller.cc b/src/rime/gear/speller.cc index ff1457f62..8abcb83d3 100644 --- a/src/rime/gear/speller.cc +++ b/src/rime/gear/speller.cc @@ -43,8 +43,7 @@ static bool is_auto_selectable(const an& cand, const string& delimiters) { return // reaches end of input - cand->end() == input.length() && - is_table_entry(cand) && + cand->end() == input.length() && is_table_entry(cand) && // no delimiters input.find_first_of(delimiters, cand->start()) == string::npos; } @@ -63,8 +62,8 @@ static bool expecting_an_initial(Context* ctx, !belongs_to(previous_char, alphabet); } -Speller::Speller(const Ticket& ticket) : Processor(ticket), - alphabet_(kRimeAlphabet) { +Speller::Speller(const Ticket& ticket) + : Processor(ticket), alphabet_(kRimeAlphabet) { if (Config* config = engine_->schema()->config()) { config->GetString("speller/alphabet", &alphabet_); config->GetString("speller/delimiter", &delimiters_); @@ -79,9 +78,12 @@ Speller::Speller(const Ticket& ticket) : Processor(ticket), } string auto_clear; if (config->GetString("speller/auto_clear", &auto_clear)) { - if (auto_clear == "auto") auto_clear_ = kClearAuto; - else if (auto_clear == "manual") auto_clear_ = kClearManual; - else if (auto_clear == "max_length") auto_clear_ = kClearMaxLength; + if (auto_clear == "auto") + auto_clear_ = kClearAuto; + else if (auto_clear == "manual") + auto_clear_ = kClearManual; + else if (auto_clear == "max_length") + auto_clear_ = kClearMaxLength; } } if (initials_.empty()) { @@ -90,8 +92,8 @@ Speller::Speller(const Ticket& ticket) : Processor(ticket), } ProcessResult Speller::ProcessKeyEvent(const KeyEvent& key_event) { - if (key_event.release() || - key_event.ctrl() || key_event.alt() || key_event.super()) + if (key_event.release() || key_event.ctrl() || key_event.alt() || + key_event.super()) return kNoop; int ch = key_event.keycode(); if (ch < 0x20 || ch >= 0x7f) // not a valid key for spelling @@ -102,15 +104,14 @@ ProcessResult Speller::ProcessKeyEvent(const KeyEvent& key_event) { return kNoop; Context* ctx = engine_->context(); bool is_initial = belongs_to(ch, initials_); - if (!is_initial && - expecting_an_initial(ctx, alphabet_, finals_)) { + if (!is_initial && expecting_an_initial(ctx, alphabet_, finals_)) { return kNoop; } // handles input beyond max_code_length when auto_select is false. if (is_initial && AutoSelectAtMaxCodeLength(ctx)) { DLOG(INFO) << "auto-select at max code length."; - } - else if ((auto_clear_ == kClearMaxLength || auto_clear_ == kClearManual) && AutoClear(ctx)) { + } else if ((auto_clear_ == kClearMaxLength || auto_clear_ == kClearManual) && + AutoClear(ctx)) { DLOG(INFO) << "auto-clear at max code when no candidate."; } // make a backup of previous conversion before modifying input @@ -133,8 +134,7 @@ ProcessResult Speller::ProcessKeyEvent(const KeyEvent& key_event) { } if (AutoSelectUniqueCandidate(ctx)) { DLOG(INFO) << "auto-select unique candidate."; - } - else if (auto_clear_ == kClearAuto && AutoClear(ctx)) { + } else if (auto_clear_ == kClearAuto && AutoClear(ctx)) { DLOG(INFO) << "auto-clear when no candidate."; } return kAccepted; @@ -146,8 +146,7 @@ bool Speller::AutoSelectAtMaxCodeLength(Context* ctx) { if (!ctx->HasMenu()) return false; auto cand = ctx->GetSelectedCandidate(); - if (cand && - reached_max_code_length(cand, max_code_length_) && + if (cand && reached_max_code_length(cand, max_code_length_) && is_auto_selectable(cand, ctx->input(), delimiters_)) { ctx->ConfirmCurrentSelection(); return true; @@ -171,21 +170,18 @@ bool Speller::AutoSelectUniqueCandidate(Context* ctx) { matches_input_pattern = max_code_length_ == 0 || // match any length if not set reached_max_code_length(cand, max_code_length_); - } - else { + } else { string code(input.substr(cand->start(), cand->end())); matches_input_pattern = boost::regex_match(code, auto_select_pattern_); } - if (matches_input_pattern && - is_auto_selectable(cand, input, delimiters_)) { + if (matches_input_pattern && is_auto_selectable(cand, input, delimiters_)) { ctx->ConfirmCurrentSelection(); return true; } return false; } -bool Speller::AutoSelectPreviousMatch(Context* ctx, - Segment* previous_segment) { +bool Speller::AutoSelectPreviousMatch(Context* ctx, Segment* previous_segment) { if (!auto_select_) return false; if (max_code_length_ > 0 || !auto_select_pattern_.empty()) @@ -198,8 +194,8 @@ bool Speller::AutoSelectPreviousMatch(Context* ctx, size_t end = previous_segment->end; string input = ctx->input(); string converted = input.substr(0, end); - if (is_auto_selectable(previous_segment->GetSelectedCandidate(), - converted, delimiters_)) { + if (is_auto_selectable(previous_segment->GetSelectedCandidate(), converted, + delimiters_)) { // reuse previous match ctx->composition().pop_back(); ctx->composition().push_back(std::move(*previous_segment)); @@ -212,7 +208,7 @@ bool Speller::AutoSelectPreviousMatch(Context* ctx, } return true; } - return FindEarlierMatch(ctx, start ,end); + return FindEarlierMatch(ctx, start, end); } bool Speller::AutoClear(Context* ctx) { @@ -236,16 +232,15 @@ bool Speller::FindEarlierMatch(Context* ctx, size_t start, size_t end) { if (!ctx->HasMenu()) break; const Segment& segment(ctx->composition().back()); - if (is_auto_selectable(segment.GetSelectedCandidate(), - converted, delimiters_)) { + if (is_auto_selectable(segment.GetSelectedCandidate(), converted, + delimiters_)) { // select previous match if (ctx->get_option("_auto_commit")) { ctx->Commit(); string rest = input.substr(end); ctx->set_input(rest); end = 0; - } - else { + } else { ctx->ConfirmCurrentSelection(); ctx->set_input(input); } diff --git a/src/rime/gear/speller.h b/src/rime/gear/speller.h index d203abc30..c22465e27 100644 --- a/src/rime/gear/speller.h +++ b/src/rime/gear/speller.h @@ -24,7 +24,12 @@ class Speller : public Processor { virtual ProcessResult ProcessKeyEvent(const KeyEvent& key_event); protected: - enum AutoClearMethod { kClearNone, kClearAuto, kClearManual, kClearMaxLength }; + enum AutoClearMethod { + kClearNone, + kClearAuto, + kClearManual, + kClearMaxLength + }; bool AutoSelectAtMaxCodeLength(Context* ctx); bool AutoSelectUniqueCandidate(Context* ctx); diff --git a/src/rime/gear/switch_translator.cc b/src/rime/gear/switch_translator.cc index c29cb2952..ffaa3cfb4 100644 --- a/src/rime/gear/switch_translator.cc +++ b/src/rime/gear/switch_translator.cc @@ -16,7 +16,7 @@ #include static const char* kRightArrow = "\xe2\x86\x92 "; -//static const char* kRadioSelected = " \xe2\x97\x89"; // U+25C9 FISHEYE +// static const char* kRadioSelected = " \xe2\x97\x89"; // U+25C9 FISHEYE static const char* kRadioSelected = " \xe2\x9c\x93"; // U+2713 CHECK MARK namespace rime { @@ -26,24 +26,22 @@ using SwitchOption = Switches::SwitchOption; inline static string get_state_label(const SwitchOption& option, size_t state_index, bool abbreviate = false) { - return string(Switches::GetStateLabel(option.the_switch, - state_index, - abbreviate)); + return string( + Switches::GetStateLabel(option.the_switch, state_index, abbreviate)); } class Switch : public SimpleCandidate, public SwitcherCommand { public: - Switch(const SwitchOption& option, - bool current_state, - bool auto_save) - : SimpleCandidate("switch", 0, 0, - get_state_label(option, current_state), - kRightArrow + - get_state_label(option, 1 - current_state)), + Switch(const SwitchOption& option, bool current_state, bool auto_save) + : SimpleCandidate( + "switch", + 0, + 0, + get_state_label(option, current_state), + kRightArrow + get_state_label(option, 1 - current_state)), SwitcherCommand(option.option_name), target_state_(!current_state), - auto_save_(auto_save) { - } + auto_save_(auto_save) {} void Apply(Switcher* switcher) override; protected: @@ -68,10 +66,8 @@ class RadioOption; class RadioGroup : public std::enable_shared_from_this { public: RadioGroup(Context* context, Switcher* switcher) - : context_(context), switcher_(switcher) { - } - an CreateOption(const SwitchOption& option, - size_t option_index); + : context_(context), switcher_(switcher) {} + an CreateOption(const SwitchOption& option, size_t option_index); void SelectOption(RadioOption* option); RadioOption* GetSelectedOption() const; @@ -88,8 +84,7 @@ class RadioOption : public SimpleCandidate, public SwitcherCommand { const string& option_name) : SimpleCandidate("switch", 0, 0, state_label), SwitcherCommand(option_name), - group_(group) { - } + group_(group) {} void Apply(Switcher* switcher) override; void UpdateState(bool selected); bool selected() const { return selected_; } @@ -109,8 +104,8 @@ void RadioOption::UpdateState(bool selected) { set_comment(selected ? kRadioSelected : ""); } -an -RadioGroup::CreateOption(const SwitchOption& option, size_t option_index) { +an RadioGroup::CreateOption(const SwitchOption& option, + size_t option_index) { auto radio_option = New(shared_from_this(), get_state_label(option, option_index), option.option_name); @@ -148,17 +143,14 @@ RadioOption* RadioGroup::GetSelectedOption() const { class FoldedOptions : public SimpleCandidate, public SwitcherCommand { public: FoldedOptions(Config* config) - : SimpleCandidate("unfold", 0, 0, ""), - SwitcherCommand("_fold_options") { + : SimpleCandidate("unfold", 0, 0, ""), SwitcherCommand("_fold_options") { LoadConfig(config); } void Apply(Switcher* switcher) override; void Append(const SwitchOption& option, size_t state_index); void Finish(); - size_t size() const { - return labels_.size(); - } + size_t size() const { return labels_.size(); } private: void LoadConfig(Config* config); @@ -188,8 +180,7 @@ void FoldedOptions::Apply(Switcher* switcher) { } void FoldedOptions::Append(const SwitchOption& option, size_t state_index) { - labels_.push_back( - get_state_label(option, state_index, abbreviate_options_)); + labels_.push_back(get_state_label(option, state_index, abbreviate_options_)); } void FoldedOptions::Finish() { @@ -198,9 +189,8 @@ void FoldedOptions::Finish() { class SwitchTranslation : public FifoTranslation { public: - SwitchTranslation(Switcher* switcher) { - LoadSwitches(switcher); - } + SwitchTranslation(Switcher* switcher) { LoadSwitches(switcher); } + protected: void LoadSwitches(Switcher* switcher); }; @@ -216,45 +206,42 @@ void SwitchTranslation::LoadSwitches(Switcher* switcher) { vector> groups; Switches switches(config); switches.FindOption( - [this, switcher, context, &groups] - (Switches::SwitchOption option) -> Switches::FindResult { - if (option.type == Switches::kToggleOption) { - bool current_state = context->get_option(option.option_name); - Append( - New(option, - current_state, - switcher->IsAutoSave(option.option_name))); - } else if (option.type == Switches::kRadioGroup) { - an group; - if (option.option_index == 0) { - group = New(context, switcher); - groups.push_back(group); - } else { - group = groups.back(); + [this, switcher, context, + &groups](Switches::SwitchOption option) -> Switches::FindResult { + if (option.type == Switches::kToggleOption) { + bool current_state = context->get_option(option.option_name); + Append(New(option, current_state, + switcher->IsAutoSave(option.option_name))); + } else if (option.type == Switches::kRadioGroup) { + an group; + if (option.option_index == 0) { + group = New(context, switcher); + groups.push_back(group); + } else { + group = groups.back(); + } + Append(group->CreateOption(option, option.option_index)); } - Append( - group->CreateOption(option, option.option_index)); - } - return Switches::kContinue; - }); + return Switches::kContinue; + }); for (auto& group : groups) { group->SelectOption(group->GetSelectedOption()); } if (switcher->context()->get_option("_fold_options")) { auto folded_options = New(switcher->schema()->config()); switches.FindOption( - [context, &folded_options] - (Switches::SwitchOption option) -> Switches::FindResult { - bool current_state = context->get_option(option.option_name); - if (option.type == Switches::kToggleOption) { - folded_options->Append(option, current_state); - } else if (option.type == Switches::kRadioGroup) { - if (current_state) { - folded_options->Append(option, option.option_index); + [context, &folded_options]( + Switches::SwitchOption option) -> Switches::FindResult { + bool current_state = context->get_option(option.option_name); + if (option.type == Switches::kToggleOption) { + folded_options->Append(option, current_state); + } else if (option.type == Switches::kRadioGroup) { + if (current_state) { + folded_options->Append(option, option.option_index); + } } - } - return Switches::kContinue; - }); + return Switches::kContinue; + }); if (folded_options->size() > 1) { folded_options->Finish(); candies_.clear(); @@ -264,12 +251,10 @@ void SwitchTranslation::LoadSwitches(Switcher* switcher) { DLOG(INFO) << "num switches: " << candies_.size(); } -SwitchTranslator::SwitchTranslator(const Ticket& ticket) - : Translator(ticket) { -} +SwitchTranslator::SwitchTranslator(const Ticket& ticket) : Translator(ticket) {} an SwitchTranslator::Query(const string& input, - const Segment& segment) { + const Segment& segment) { auto switcher = dynamic_cast(engine_); if (!switcher) { return nullptr; diff --git a/src/rime/gear/table_translator.cc b/src/rime/gear/table_translator.cc index 97cfc96e5..a43a77f93 100644 --- a/src/rime/gear/table_translator.cc +++ b/src/rime/gear/table_translator.cc @@ -38,9 +38,14 @@ TableTranslation::TableTranslation(TranslatorOptions* options, const string& preedit, DictEntryIterator&& iter, UserDictEntryIterator&& uter) - : options_(options), language_(language), - input_(input), start_(start), end_(end), preedit_(preedit), - iter_(std::move(iter)), uter_(std::move(uter)) { + : options_(options), + language_(language), + input_(input), + start_(start), + end_(end), + preedit_(preedit), + iter_(std::move(iter)), + uter_(std::move(uter)) { if (options_) options_->preedit_formatter().Apply(&preedit_); CheckEmpty(); @@ -53,8 +58,7 @@ bool TableTranslation::Next() { uter_.Next(); if (uter_.exhausted()) FetchMoreUserPhrases(); - } - else { + } else { iter_.Next(); if (iter_.exhausted()) FetchMoreTableEntries(); @@ -76,15 +80,15 @@ an TableTranslation::Peek() { options_->comment_formatter().Apply(&comment); } bool incomplete = e->remaining_code_length != 0; - auto type = incomplete ? "completion" : is_user_phrase ? "user_table" : "table"; + auto type = incomplete ? "completion" + : is_user_phrase ? "user_table" + : "table"; auto phrase = New(language_, type, start_, end_, e); if (phrase) { phrase->set_comment(comment); phrase->set_preedit(preedit_); - phrase->set_quality(std::exp(e->weight) + - options_->initial_quality() + - (incomplete ? -1 : 0) + - (is_user_phrase ? 0.5 : 0)); + phrase->set_quality(std::exp(e->weight) + options_->initial_quality() + + (incomplete ? -1 : 0) + (is_user_phrase ? 0.5 : 0)); } return phrase; } @@ -117,7 +121,8 @@ class LazyTableTranslation : public TableTranslation { LazyTableTranslation(TableTranslator* translator, const string& input, - size_t start, size_t end, + size_t start, + size_t end, const string& preedit, bool enable_user_dict); bool FetchUserPhrases(TableTranslator* translator); @@ -134,11 +139,16 @@ class LazyTableTranslation : public TableTranslation { LazyTableTranslation::LazyTableTranslation(TableTranslator* translator, const string& input, - size_t start, size_t end, + size_t start, + size_t end, const string& preedit, bool enable_user_dict) - : TableTranslation(translator, translator->language(), - input, start, end, preedit), + : TableTranslation(translator, + translator->language(), + input, + start, + end, + preedit), dict_(translator->dict()), user_dict_(enable_user_dict ? translator->user_dict() : NULL), limit_(kInitialSearchLimit), @@ -163,13 +173,12 @@ bool LazyTableTranslation::FetchUserPhrases(TableTranslator* translator) { bool LazyTableTranslation::FetchMoreUserPhrases() { if (!user_dict_ || user_dict_limit_ == 0) return false; - size_t count = user_dict_->LookupWords(&uter_, input_, true, - user_dict_limit_, &user_dict_key_); + size_t count = user_dict_->LookupWords(&uter_, input_, true, user_dict_limit_, + &user_dict_key_); if (count < user_dict_limit_) { DLOG(INFO) << "all user dict entries obtained."; user_dict_limit_ = 0; // no more try - } - else { + } else { user_dict_limit_ *= kExpandingFactor; } return !uter_.exhausted(); @@ -185,8 +194,7 @@ bool LazyTableTranslation::FetchMoreTableEntries() { if (dict_->LookupWords(&more, input_, true, limit_) < limit_) { DLOG(INFO) << "all table entries obtained."; limit_ = 0; // no more try - } - else { + } else { limit_ *= kExpandingFactor; } if (more.entry_count() > previous_entry_count) { @@ -199,26 +207,20 @@ bool LazyTableTranslation::FetchMoreTableEntries() { // TableTranslator TableTranslator::TableTranslator(const Ticket& ticket) - : Translator(ticket), - Memory(ticket), - TranslatorOptions(ticket) { + : Translator(ticket), Memory(ticket), TranslatorOptions(ticket) { if (!engine_) return; if (Config* config = engine_->schema()->config()) { config->GetBool(name_space_ + "/enable_charset_filter", &enable_charset_filter_); - config->GetBool(name_space_ + "/enable_sentence", - &enable_sentence_); + config->GetBool(name_space_ + "/enable_sentence", &enable_sentence_); config->GetBool(name_space_ + "/sentence_over_completion", &sentence_over_completion_); - config->GetBool(name_space_ + "/enable_encoder", - &enable_encoder_); + config->GetBool(name_space_ + "/enable_encoder", &enable_encoder_); config->GetBool(name_space_ + "/encode_commit_history", &encode_commit_history_); - config->GetInt(name_space_ + "/max_phrase_length", - &max_phrase_length_); - config->GetInt(name_space_ + "/max_homographs", - &max_homographs_); + config->GetInt(name_space_ + "/max_phrase_length", &max_phrase_length_); + config->GetInt(name_space_ + "/max_homographs", &max_homographs_); if (enable_sentence_ || sentence_over_completion_ || contextual_suggestions_) { poet_.reset(new Poet(language(), config, Poet::LeftAssociateCompare)); @@ -241,13 +243,13 @@ an TableTranslator::Query(const string& input, const Segment& segment) { if (!segment.HasTag(tag_)) return nullptr; - DLOG(INFO) << "input = '" << input - << "', [" << segment.start << ", " << segment.end << ")"; + DLOG(INFO) << "input = '" << input << "', [" << segment.start << ", " + << segment.end << ")"; FinishSession(); - bool enable_user_dict = user_dict_ && user_dict_->loaded() && - !IsUserDictDisabledFor(input); + bool enable_user_dict = + user_dict_ && user_dict_->loaded() && !IsUserDictDisabledFor(input); const string& preedit(input); string code = input; @@ -255,15 +257,10 @@ an TableTranslator::Query(const string& input, an translation; if (enable_completion_) { - translation = Cached( - this, - code, - segment.start, - segment.start + input.length(), - preedit, - enable_user_dict); - } - else { + translation = Cached(this, code, segment.start, + segment.start + input.length(), + preedit, enable_user_dict); + } else { DictEntryIterator iter; if (dict_ && dict_->loaded()) { dict_->LookupWords(&iter, code, false); @@ -277,17 +274,12 @@ an TableTranslator::Query(const string& input, } if (!iter.exhausted() || !uter.exhausted()) translation = Cached( - this, - language(), - code, - segment.start, - segment.start + input.length(), - preedit, - std::move(iter), - std::move(uter)); + this, language(), code, segment.start, segment.start + input.length(), + preedit, std::move(iter), std::move(uter)); } if (translation) { - bool filter_by_charset = enable_charset_filter_ && + bool filter_by_charset = + enable_charset_filter_ && !engine_->context()->get_option("extended_charset"); if (filter_by_charset) { translation = New(translation); @@ -298,10 +290,8 @@ an TableTranslator::Query(const string& input, } if (enable_sentence_ && !translation) { translation = MakeSentence(input, segment.start, - /* include_prefix_phrases = */true); - } - else if (sentence_over_completion_ && - starts_with_completion(translation)) { + /* include_prefix_phrases = */ true); + } else if (sentence_over_completion_ && starts_with_completion(translation)) { if (auto sentence = MakeSentence(input, segment.start)) { translation = sentence + translation; } @@ -324,8 +314,7 @@ bool TableTranslator::Memorize(const CommitEntry& commit_entry) { DictEntry blessed(*e); UnityTableEncoder::RemovePrefix(&blessed.custom_code); user_dict_->UpdateEntry(blessed, 1); - } - else { + } else { user_dict_->UpdateEntry(*e, 1); } } @@ -339,14 +328,12 @@ bool TableTranslator::Memorize(const CommitEntry& commit_entry) { DLOG(INFO) << "history: " << history.repr(); auto it = history.rbegin(); if (it->type == "punct") { // ending with punctuation - ++it; + ++it; } string phrase; for (; it != history.rend(); ++it) { - if (it->type != "table" && - it->type != "user_table" && - it->type != "sentence" && - it->type != "uniquified") + if (it->type != "table" && it->type != "user_table" && + it->type != "sentence" && it->type != "uniquified") break; if (phrase.empty()) { phrase = it->text; // last word @@ -367,9 +354,9 @@ bool TableTranslator::Memorize(const CommitEntry& commit_entry) { } string TableTranslator::GetPrecedingText(size_t start) const { - return !contextual_suggestions_ ? string() : - start > 0 ? engine_->context()->composition().GetTextBefore(start) : - engine_->context()->commit_history().latest_text(); + return !contextual_suggestions_ ? string() + : start > 0 ? engine_->context()->composition().GetTextBefore(start) + : engine_->context()->commit_history().latest_text(); } // SentenceSyllabifier @@ -444,8 +431,7 @@ bool SentenceTranslation::Next() { if (!r->second.Next()) { user_phrase_collector_.erase(r->first); } - } - else { + } else { auto r = collector_.rbegin(); if (!r->second.Next()) { collector_.erase(r->first); @@ -467,18 +453,14 @@ an SentenceTranslation::Peek() { auto r = user_phrase_collector_.rbegin(); code_length = r->first; entry = r->second.Peek(); - } - else { + } else { auto r = collector_.rbegin(); code_length = r->first; entry = r->second.Peek(); } - auto result = New( - translator_ ? translator_->language() : NULL, - is_user_phrase ? "user_table" : "table", - start_, - start_ + code_length, - entry); + auto result = New(translator_ ? translator_->language() : NULL, + is_user_phrase ? "user_table" : "table", start_, + start_ + code_length, entry); if (translator_) { string preedit = input_.substr(0, code_length); translator_->preedit_formatter().Apply(&preedit); @@ -512,8 +494,7 @@ void SentenceTranslation::PrepareSentence() { } bool SentenceTranslation::CheckEmpty() { - set_exhausted(!sentence_ && - collector_.empty() && + set_exhausted(!sentence_ && collector_.empty() && user_phrase_collector_.empty()); return exhausted(); } @@ -536,10 +517,9 @@ bool SentenceTranslation::PreferUserPhrase() const { } inline static size_t consume_trailing_delimiters(size_t pos, - const string& input, - const string& delimiters) { - while (pos < input.length() && - delimiters.find(input[pos]) != string::npos) { + const string& input, + const string& delimiters) { + while (pos < input.length() && delimiters.find(input[pos]) != string::npos) { ++pos; } return pos; @@ -558,11 +538,11 @@ inline static void collect_entries(DictEntryList& entries, } } -an -TableTranslator::MakeSentence(const string& input, size_t start, - bool include_prefix_phrases) { +an TableTranslator::MakeSentence(const string& input, + size_t start, + bool include_prefix_phrases) { bool filter_by_charset = enable_charset_filter_ && - !engine_->context()->get_option("extended_charset"); + !engine_->context()->get_option("extended_charset"); DictEntryCollector collector; UserDictEntryCollector user_phrase_collector; WordGraph graph; @@ -681,23 +661,18 @@ TableTranslator::MakeSentence(const string& input, size_t start, // also provide words for manual composition // iter must not be consumed collector[consumed_length] = std::move(iter); - DLOG(INFO) << "table[" << consumed_length << "]: " - << collector[consumed_length].entry_count(); + DLOG(INFO) << "table[" << consumed_length + << "]: " << collector[consumed_length].entry_count(); } } } } } - if (auto sentence = poet_->MakeSentence(graph, - input.length(), - GetPrecedingText(start))) { + if (auto sentence = + poet_->MakeSentence(graph, input.length(), GetPrecedingText(start))) { auto result = Cached( - this, - std::move(sentence), - std::move(collector), - std::move(user_phrase_collector), - input, - start); + this, std::move(sentence), std::move(collector), + std::move(user_phrase_collector), input, start); if (result && filter_by_charset) { return New(result); } diff --git a/src/rime/gear/table_translator.h b/src/rime/gear/table_translator.h index ae1d46424..7057ed4bd 100644 --- a/src/rime/gear/table_translator.h +++ b/src/rime/gear/table_translator.h @@ -28,8 +28,7 @@ class TableTranslator : public Translator, public: TableTranslator(const Ticket& ticket); - virtual an Query(const string& input, - const Segment& segment); + virtual an Query(const string& input, const Segment& segment); virtual bool Memorize(const CommitEntry& commit_entry); an MakeSentence(const string& input, @@ -52,7 +51,6 @@ class TableTranslator : public Translator, class TableTranslation : public Translation { public: - TableTranslation(TranslatorOptions* options, const Language* language, const string& input, diff --git a/src/rime/gear/translator_commons.cc b/src/rime/gear/translator_commons.cc index ba3635c34..081a52292 100644 --- a/src/rime/gear/translator_commons.cc +++ b/src/rime/gear/translator_commons.cc @@ -75,9 +75,12 @@ size_t Spans::NextStop(size_t caret_pos) const { size_t Spans::Count(size_t start_pos, size_t end_pos) const { size_t count = 0; for (auto v : vertices_) { - if (v <= start_pos) continue; - else if (v > end_pos) break; - else ++count; + if (v <= start_pos) + continue; + else if (v > end_pos) + break; + else + ++count; } return count; } @@ -93,14 +96,13 @@ void Sentence::Extend(const DictEntry& another, double new_weight) { entry_->weight = new_weight; entry_->text.append(another.text); - entry_->code.insert(entry_->code.end(), - another.code.begin(), + entry_->code.insert(entry_->code.end(), another.code.begin(), another.code.end()); components_.push_back(another); word_lengths_.push_back(end_pos - end()); set_end(end_pos); - DLOG(INFO) << "extend sentence " << end_pos << ") " - << text() << " weight: " << weight(); + DLOG(INFO) << "extend sentence " << end_pos << ") " << text() + << " weight: " << weight(); } void Sentence::Offset(size_t offset) { @@ -113,7 +115,7 @@ void Sentence::Offset(size_t offset) { TranslatorOptions::TranslatorOptions(const Ticket& ticket) { if (!ticket.schema) return; - if (Config *config = ticket.schema->config()) { + if (Config* config = ticket.schema->config()) { config->GetString(ticket.name_space + "/delimiter", &delimiters_) || config->GetString("speller/delimiter", &delimiters_); config->GetString(ticket.name_space + "/tag", &tag_); @@ -121,8 +123,7 @@ TranslatorOptions::TranslatorOptions(const Ticket& ticket) { &contextual_suggestions_); config->GetBool(ticket.name_space + "/enable_completion", &enable_completion_); - config->GetBool(ticket.name_space + "/strict_spelling", - &strict_spelling_); + config->GetBool(ticket.name_space + "/strict_spelling", &strict_spelling_); config->GetDouble(ticket.name_space + "/initial_quality", &initial_quality_); preedit_formatter_.Load( @@ -130,8 +131,7 @@ TranslatorOptions::TranslatorOptions(const Ticket& ticket) { comment_formatter_.Load( config->GetList(ticket.name_space + "/comment_format")); user_dict_disabling_patterns_.Load( - config->GetList( - ticket.name_space + "/disable_user_dict_for_patterns")); + config->GetList(ticket.name_space + "/disable_user_dict_for_patterns")); } if (delimiters_.empty()) { delimiters_ = " "; diff --git a/src/rime/gear/translator_commons.h b/src/rime/gear/translator_commons.h index de614fdf2..a004d9f8e 100644 --- a/src/rime/gear/translator_commons.h +++ b/src/rime/gear/translator_commons.h @@ -37,19 +37,11 @@ class Spans { size_t PreviousStop(size_t caret_pos) const; size_t NextStop(size_t caret_pos) const; size_t Count(size_t start_pos, size_t end_pos) const; - size_t Count() const { - return vertices_.empty() ? 0 : vertices_.size() - 1; - } - size_t start() const { - return vertices_.empty() ? 0 : vertices_.front(); - } - size_t end() const { - return vertices_.empty() ? 0 : vertices_.back(); - } + size_t Count() const { return vertices_.empty() ? 0 : vertices_.size() - 1; } + size_t start() const { return vertices_.empty() ? 0 : vertices_.front(); } + size_t end() const { return vertices_.empty() ? 0 : vertices_.back(); } bool HasVertex(size_t vertex) const; - void set_vertices(vector&& vertices) { - vertices_ = vertices; - } + void set_vertices(vector&& vertices) { vertices_ = vertices; } private: vector vertices_; @@ -75,19 +67,12 @@ class Phrase : public Candidate { size_t start, size_t end, const an& entry) - : Candidate(type, start, end), - language_(language), - entry_(entry) { - } + : Candidate(type, start, end), language_(language), entry_(entry) {} const string& text() const { return entry_->text; } string comment() const { return entry_->comment; } string preedit() const { return entry_->preedit; } - void set_comment(const string& comment) { - entry_->comment = comment; - } - void set_preedit(const string& preedit) { - entry_->preedit = preedit; - } + void set_comment(const string& comment) { entry_->comment = comment; } + void set_preedit(const string& preedit) { entry_->preedit = preedit; } void set_syllabifier(an syllabifier) { syllabifier_ = syllabifier; } @@ -97,8 +82,7 @@ class Phrase : public Candidate { const DictEntry& entry() const { return *entry_; } const Language* language() const { return language_; } Spans spans() { - return syllabifier_ ? syllabifier_->Syllabify(this) - : Spans(); + return syllabifier_ ? syllabifier_->Syllabify(this) : Spans(); } protected: @@ -122,20 +106,12 @@ class Sentence : public Phrase { void Extend(const DictEntry& another, size_t end_pos, double new_weight); void Offset(size_t offset); - bool empty() const { - return components_.empty(); - } + bool empty() const { return components_.empty(); } - size_t size() const { - return components_.size(); - } + size_t size() const { return components_.size(); } - const vector& components() const { - return components_; - } - const vector& word_lengths() const { - return word_lengths_; - } + const vector& components() const { return components_; } + const vector& word_lengths() const { return word_lengths_; } protected: vector components_; diff --git a/src/rime/gear/uniquifier.cc b/src/rime/gear/uniquifier.cc index daceca305..067e91251 100644 --- a/src/rime/gear/uniquifier.cc +++ b/src/rime/gear/uniquifier.cc @@ -13,8 +13,7 @@ namespace rime { class UniquifiedTranslation : public CacheTranslation { public: - UniquifiedTranslation(an translation, - CandidateList* candidates) + UniquifiedTranslation(an translation, CandidateList* candidates) : CacheTranslation(translation), candidates_(candidates) { Uniquify(); } @@ -45,8 +44,8 @@ static CandidateList::iterator find_text_match(const an& target, bool UniquifiedTranslation::Uniquify() { while (!exhausted()) { auto next = Peek(); - CandidateList::iterator previous = find_text_match( - next, candidates_->begin(), candidates_->end()); + CandidateList::iterator previous = + find_text_match(next, candidates_->begin(), candidates_->end()); if (previous == candidates_->end()) { // Encountered a unique candidate. return true; @@ -64,11 +63,10 @@ bool UniquifiedTranslation::Uniquify() { // Uniquifier -Uniquifier::Uniquifier(const Ticket& ticket) : Filter(ticket) { -} +Uniquifier::Uniquifier(const Ticket& ticket) : Filter(ticket) {} an Uniquifier::Apply(an translation, - CandidateList* candidates) { + CandidateList* candidates) { return New(translation, candidates); } diff --git a/src/rime/gear/uniquifier.h b/src/rime/gear/uniquifier.h index f8842e6d2..ecd7adae1 100644 --- a/src/rime/gear/uniquifier.h +++ b/src/rime/gear/uniquifier.h @@ -16,8 +16,7 @@ class Uniquifier : public Filter { explicit Uniquifier(const Ticket& ticket); virtual an Apply(an translation, - CandidateList* candidates); - + CandidateList* candidates); }; } // namespace rime diff --git a/src/rime/gear/unity_table_encoder.cc b/src/rime/gear/unity_table_encoder.cc index 2ac9514ab..79852f7e3 100644 --- a/src/rime/gear/unity_table_encoder.cc +++ b/src/rime/gear/unity_table_encoder.cc @@ -12,15 +12,16 @@ namespace rime { -static const char* kEncodedPrefix = "\x7f""enc\x1f"; +static const char* kEncodedPrefix = + "\x7f" + "enc\x1f"; UnityTableEncoder::UnityTableEncoder(UserDictionary* user_dict) : TableEncoder(NULL), user_dict_(user_dict) { set_collector(this); } -UnityTableEncoder::~UnityTableEncoder() { -} +UnityTableEncoder::~UnityTableEncoder() {} bool UnityTableEncoder::Load(const Ticket& ticket) { auto c = ReverseLookupDictionary::Require("reverse_lookup_dictionary"); @@ -74,9 +75,8 @@ size_t UnityTableEncoder::LookupPhrases(UserDictEntryIterator* result, string* resume_key) { if (!user_dict_) return 0; - return user_dict_->LookupWords(result, - kEncodedPrefix + input, - predictive, limit, resume_key); + return user_dict_->LookupWords(result, kEncodedPrefix + input, predictive, + limit, resume_key); } bool UnityTableEncoder::HasPrefix(const string& key) { diff --git a/src/rime/gear/unity_table_encoder.h b/src/rime/gear/unity_table_encoder.h index 464b3345d..4f1d04461 100644 --- a/src/rime/gear/unity_table_encoder.h +++ b/src/rime/gear/unity_table_encoder.h @@ -26,8 +26,7 @@ class UnityTableEncoder : public TableEncoder, public PhraseCollector { void CreateEntry(const string& word, const string& code_str, const string& weight_str); - bool TranslateWord(const string& word, - vector* code); + bool TranslateWord(const string& word, vector* code); size_t LookupPhrases(UserDictEntryIterator* result, const string& input, diff --git a/src/rime/key_event.cc b/src/rime/key_event.cc index ce7089a02..ae1ecea70 100644 --- a/src/rime/key_event.cc +++ b/src/rime/key_event.cc @@ -39,11 +39,9 @@ string KeyEvent::repr() const { string value; if (keycode_ <= 0xffff) { value = boost::str(boost::format("0x%4x") % keycode_); - } - else if (keycode_ <= 0xffffff) { + } else if (keycode_ <= 0xffffff) { value = boost::str(boost::format("0x%6x") % keycode_); - } - else { + } else { return "(unknown)"; // invalid keycode } return modifiers.str() + value; @@ -56,8 +54,7 @@ bool KeyEvent::Parse(const string& repr) { } if (repr.size() == 1) { keycode_ = static_cast(repr[0]); - } - else { + } else { size_t start = 0; size_t found = 0; string token; @@ -67,8 +64,7 @@ bool KeyEvent::Parse(const string& repr) { mask = RimeGetModifierByName(token.c_str()); if (mask) { modifier_ |= mask; - } - else { + } else { LOG(ERROR) << "parse error: unrecognized modifier '" << token << "'"; return false; } @@ -91,9 +87,8 @@ KeySequence::KeySequence(const string& repr) { static bool is_unescaped_character(const KeyEvent& key_event) { int ch = key_event.keycode(); - return key_event.modifier() == 0 && - ch >= 0x20 && ch <= 0x7e && - ch != '{' && ch != '}'; + return key_event.modifier() == 0 && ch >= 0x20 && ch <= 0x7e && ch != '{' && + ch != '}'; } string KeySequence::repr() const { @@ -103,11 +98,9 @@ string KeySequence::repr() const { k = it->repr(); if (k.size() == 1) { result << k; - } - else if (is_unescaped_character(*it)) { + } else if (is_unescaped_character(*it)) { result << char(it->keycode()); - } - else { + } else { result << '{' << k << '}'; } } @@ -130,8 +123,7 @@ bool KeySequence::Parse(const string& repr) { } len = j - start; i = j; - } - else { + } else { start = i; len = 1; } diff --git a/src/rime/key_event.h b/src/rime/key_event.h index 8910fae25..22e48ae01 100644 --- a/src/rime/key_event.h +++ b/src/rime/key_event.h @@ -40,11 +40,11 @@ class KeyEvent { // 解析文字表示的按鍵 RIME_API bool Parse(const string& repr); - bool operator== (const KeyEvent& other) const { + bool operator==(const KeyEvent& other) const { return keycode_ == other.keycode_ && modifier_ == other.modifier_; } - bool operator< (const KeyEvent& other) const { + bool operator<(const KeyEvent& other) const { if (keycode_ != other.keycode_) return keycode_ < other.keycode_; return modifier_ < other.modifier_; @@ -70,12 +70,12 @@ class KeySequence : public vector { RIME_API bool Parse(const string& repr); }; -inline std::ostream& operator<< (std::ostream& out, const KeyEvent& key_event) { +inline std::ostream& operator<<(std::ostream& out, const KeyEvent& key_event) { out << key_event.repr(); return out; } -inline std::ostream& operator<< (std::ostream& out, const KeySequence& key_seq) { +inline std::ostream& operator<<(std::ostream& out, const KeySequence& key_seq) { out << key_seq.repr(); return out; } diff --git a/src/rime/key_table.cc b/src/rime/key_table.cc index 1c7d87133..a8a8617a7 100644 --- a/src/rime/key_table.cc +++ b/src/rime/key_table.cc @@ -4,1338 +4,1338 @@ #include #include -static const char *modifier_name[] = { - "Shift", // 0 - "Lock", // 1 - "Control", // 2 - "Alt", // 3 - "Mod2", // 4 - "Mod3", // 5 - "Mod4", // 6 - "Mod5", // 7 - "Button1", // 8 - "Button2", // 9 - "Button3", // 10 - "Button4", // 11 - "Button5", // 12 - NULL, NULL, NULL, NULL, NULL, // 13 - 17 - NULL, NULL, NULL, NULL, NULL, // 18 - 22 - NULL, NULL, NULL, // 23 - 25 - "Super", // 26 - "Hyper", // 27 - "Meta", // 28 - NULL, // 29 - "Release", // 30 - NULL, // 31 +static const char* modifier_name[] = { + "Shift", // 0 + "Lock", // 1 + "Control", // 2 + "Alt", // 3 + "Mod2", // 4 + "Mod3", // 5 + "Mod4", // 6 + "Mod5", // 7 + "Button1", // 8 + "Button2", // 9 + "Button3", // 10 + "Button4", // 11 + "Button5", // 12 + NULL, NULL, NULL, NULL, NULL, // 13 - 17 + NULL, NULL, NULL, NULL, NULL, // 18 - 22 + NULL, NULL, NULL, // 23 - 25 + "Super", // 26 + "Hyper", // 27 + "Meta", // 28 + NULL, // 29 + "Release", // 30 + NULL, // 31 }; static const char key_names[] = - "space\0" - "exclam\0" - "quotedbl\0" - "numbersign\0" - "dollar\0" - "percent\0" - "ampersand\0" - "apostrophe\0" - "quoteright\0" - "parenleft\0" - "parenright\0" - "asterisk\0" - "plus\0" - "comma\0" - "minus\0" - "period\0" - "slash\0" - "0\0" - "1\0" - "2\0" - "3\0" - "4\0" - "5\0" - "6\0" - "7\0" - "8\0" - "9\0" - "colon\0" - "semicolon\0" - "less\0" - "equal\0" - "greater\0" - "question\0" - "at\0" - "A\0" - "B\0" - "C\0" - "D\0" - "E\0" - "F\0" - "G\0" - "H\0" - "I\0" - "J\0" - "K\0" - "L\0" - "M\0" - "N\0" - "O\0" - "P\0" - "Q\0" - "R\0" - "S\0" - "T\0" - "U\0" - "V\0" - "W\0" - "X\0" - "Y\0" - "Z\0" - "bracketleft\0" - "backslash\0" - "bracketright\0" - "asciicircum\0" - "underscore\0" - "grave\0" - "quoteleft\0" - "a\0" - "b\0" - "c\0" - "d\0" - "e\0" - "f\0" - "g\0" - "h\0" - "i\0" - "j\0" - "k\0" - "l\0" - "m\0" - "n\0" - "o\0" - "p\0" - "q\0" - "r\0" - "s\0" - "t\0" - "u\0" - "v\0" - "w\0" - "x\0" - "y\0" - "z\0" - "braceleft\0" - "bar\0" - "braceright\0" - "asciitilde\0" - "nobreakspace\0" - "exclamdown\0" - "cent\0" - "sterling\0" - "currency\0" - "yen\0" - "brokenbar\0" - "section\0" - "diaeresis\0" - "copyright\0" - "ordfeminine\0" - "guillemotleft\0" - "notsign\0" - "hyphen\0" - "registered\0" - "macron\0" - "degree\0" - "plusminus\0" - "twosuperior\0" - "threesuperior\0" - "acute\0" - "mu\0" - "paragraph\0" - "periodcentered\0" - "cedilla\0" - "onesuperior\0" - "masculine\0" - "guillemotright\0" - "onequarter\0" - "onehalf\0" - "threequarters\0" - "questiondown\0" - "Agrave\0" - "Aacute\0" - "Acircumflex\0" - "Atilde\0" - "Adiaeresis\0" - "Aring\0" - "AE\0" - "Ccedilla\0" - "Egrave\0" - "Eacute\0" - "Ecircumflex\0" - "Ediaeresis\0" - "Igrave\0" - "Iacute\0" - "Icircumflex\0" - "Idiaeresis\0" - "ETH\0" - "Eth\0" - "Ntilde\0" - "Ograve\0" - "Oacute\0" - "Ocircumflex\0" - "Otilde\0" - "Odiaeresis\0" - "multiply\0" - "Ooblique\0" - "Ugrave\0" - "Uacute\0" - "Ucircumflex\0" - "Udiaeresis\0" - "Yacute\0" - "THORN\0" - "Thorn\0" - "ssharp\0" - "agrave\0" - "aacute\0" - "acircumflex\0" - "atilde\0" - "adiaeresis\0" - "aring\0" - "ae\0" - "ccedilla\0" - "egrave\0" - "eacute\0" - "ecircumflex\0" - "ediaeresis\0" - "igrave\0" - "iacute\0" - "icircumflex\0" - "idiaeresis\0" - "eth\0" - "ntilde\0" - "ograve\0" - "oacute\0" - "ocircumflex\0" - "otilde\0" - "odiaeresis\0" - "division\0" - "oslash\0" - "ugrave\0" - "uacute\0" - "ucircumflex\0" - "udiaeresis\0" - "yacute\0" - "thorn\0" - "ydiaeresis\0" - "Aogonek\0" - "breve\0" - "Lstroke\0" - "Lcaron\0" - "Sacute\0" - "Scaron\0" - "Scedilla\0" - "Tcaron\0" - "Zacute\0" - "Zcaron\0" - "Zabovedot\0" - "aogonek\0" - "ogonek\0" - "lstroke\0" - "lcaron\0" - "sacute\0" - "caron\0" - "scaron\0" - "scedilla\0" - "tcaron\0" - "zacute\0" - "doubleacute\0" - "zcaron\0" - "zabovedot\0" - "Racute\0" - "Abreve\0" - "Lacute\0" - "Cacute\0" - "Ccaron\0" - "Eogonek\0" - "Ecaron\0" - "Dcaron\0" - "Dstroke\0" - "Nacute\0" - "Ncaron\0" - "Odoubleacute\0" - "Rcaron\0" - "Uring\0" - "Udoubleacute\0" - "Tcedilla\0" - "racute\0" - "abreve\0" - "lacute\0" - "cacute\0" - "ccaron\0" - "eogonek\0" - "ecaron\0" - "dcaron\0" - "dstroke\0" - "nacute\0" - "ncaron\0" - "odoubleacute\0" - "rcaron\0" - "uring\0" - "udoubleacute\0" - "tcedilla\0" - "abovedot\0" - "Hstroke\0" - "Hcircumflex\0" - "Iabovedot\0" - "Gbreve\0" - "Jcircumflex\0" - "hstroke\0" - "hcircumflex\0" - "idotless\0" - "gbreve\0" - "jcircumflex\0" - "Cabovedot\0" - "Ccircumflex\0" - "Gabovedot\0" - "Gcircumflex\0" - "Ubreve\0" - "Scircumflex\0" - "cabovedot\0" - "ccircumflex\0" - "gabovedot\0" - "gcircumflex\0" - "ubreve\0" - "scircumflex\0" - "kappa\0" - "kra\0" - "Rcedilla\0" - "Itilde\0" - "Lcedilla\0" - "Emacron\0" - "Gcedilla\0" - "Tslash\0" - "rcedilla\0" - "itilde\0" - "lcedilla\0" - "emacron\0" - "gcedilla\0" - "tslash\0" - "ENG\0" - "eng\0" - "Amacron\0" - "Iogonek\0" - "Eabovedot\0" - "Imacron\0" - "Ncedilla\0" - "Omacron\0" - "Kcedilla\0" - "Uogonek\0" - "Utilde\0" - "Umacron\0" - "amacron\0" - "iogonek\0" - "eabovedot\0" - "imacron\0" - "ncedilla\0" - "omacron\0" - "kcedilla\0" - "uogonek\0" - "utilde\0" - "umacron\0" - "overline\0" - "kana_fullstop\0" - "kana_openingbracket\0" - "kana_closingbracket\0" - "kana_comma\0" - "kana_conjunctive\0" - "kana_middledot\0" - "kana_WO\0" - "kana_a\0" - "kana_i\0" - "kana_u\0" - "kana_e\0" - "kana_o\0" - "kana_ya\0" - "kana_yu\0" - "kana_yo\0" - "kana_tsu\0" - "kana_tu\0" - "prolongedsound\0" - "kana_A\0" - "kana_I\0" - "kana_U\0" - "kana_E\0" - "kana_O\0" - "kana_KA\0" - "kana_KI\0" - "kana_KU\0" - "kana_KE\0" - "kana_KO\0" - "kana_SA\0" - "kana_SHI\0" - "kana_SU\0" - "kana_SE\0" - "kana_SO\0" - "kana_TA\0" - "kana_CHI\0" - "kana_TI\0" - "kana_TSU\0" - "kana_TU\0" - "kana_TE\0" - "kana_TO\0" - "kana_NA\0" - "kana_NI\0" - "kana_NU\0" - "kana_NE\0" - "kana_NO\0" - "kana_HA\0" - "kana_HI\0" - "kana_FU\0" - "kana_HU\0" - "kana_HE\0" - "kana_HO\0" - "kana_MA\0" - "kana_MI\0" - "kana_MU\0" - "kana_ME\0" - "kana_MO\0" - "kana_YA\0" - "kana_YU\0" - "kana_YO\0" - "kana_RA\0" - "kana_RI\0" - "kana_RU\0" - "kana_RE\0" - "kana_RO\0" - "kana_WA\0" - "kana_N\0" - "voicedsound\0" - "semivoicedsound\0" - "Arabic_comma\0" - "Arabic_semicolon\0" - "Arabic_question_mark\0" - "Arabic_hamza\0" - "Arabic_maddaonalef\0" - "Arabic_hamzaonalef\0" - "Arabic_hamzaonwaw\0" - "Arabic_hamzaunderalef\0" - "Arabic_hamzaonyeh\0" - "Arabic_alef\0" - "Arabic_beh\0" - "Arabic_tehmarbuta\0" - "Arabic_teh\0" - "Arabic_theh\0" - "Arabic_jeem\0" - "Arabic_hah\0" - "Arabic_khah\0" - "Arabic_dal\0" - "Arabic_thal\0" - "Arabic_ra\0" - "Arabic_zain\0" - "Arabic_seen\0" - "Arabic_sheen\0" - "Arabic_sad\0" - "Arabic_dad\0" - "Arabic_tah\0" - "Arabic_zah\0" - "Arabic_ain\0" - "Arabic_ghain\0" - "Arabic_tatweel\0" - "Arabic_feh\0" - "Arabic_qaf\0" - "Arabic_kaf\0" - "Arabic_lam\0" - "Arabic_meem\0" - "Arabic_noon\0" - "Arabic_ha\0" - "Arabic_heh\0" - "Arabic_waw\0" - "Arabic_alefmaksura\0" - "Arabic_yeh\0" - "Arabic_fathatan\0" - "Arabic_dammatan\0" - "Arabic_kasratan\0" - "Arabic_fatha\0" - "Arabic_damma\0" - "Arabic_kasra\0" - "Arabic_shadda\0" - "Arabic_sukun\0" - "Serbian_dje\0" - "Macedonia_gje\0" - "Cyrillic_io\0" - "Ukrainian_ie\0" - "Ukranian_je\0" - "Macedonia_dse\0" - "Ukrainian_i\0" - "Ukranian_i\0" - "Ukrainian_yi\0" - "Ukranian_yi\0" - "Cyrillic_je\0" - "Serbian_je\0" - "Cyrillic_lje\0" - "Serbian_lje\0" - "Cyrillic_nje\0" - "Serbian_nje\0" - "Serbian_tshe\0" - "Macedonia_kje\0" - "Byelorussian_shortu\0" - "Cyrillic_dzhe\0" - "Serbian_dze\0" - "numerosign\0" - "Serbian_DJE\0" - "Macedonia_GJE\0" - "Cyrillic_IO\0" - "Ukrainian_IE\0" - "Ukranian_JE\0" - "Macedonia_DSE\0" - "Ukrainian_I\0" - "Ukranian_I\0" - "Ukrainian_YI\0" - "Ukranian_YI\0" - "Cyrillic_JE\0" - "Serbian_JE\0" - "Cyrillic_LJE\0" - "Serbian_LJE\0" - "Cyrillic_NJE\0" - "Serbian_NJE\0" - "Serbian_TSHE\0" - "Macedonia_KJE\0" - "Byelorussian_SHORTU\0" - "Cyrillic_DZHE\0" - "Serbian_DZE\0" - "Cyrillic_yu\0" - "Cyrillic_a\0" - "Cyrillic_be\0" - "Cyrillic_tse\0" - "Cyrillic_de\0" - "Cyrillic_ie\0" - "Cyrillic_ef\0" - "Cyrillic_ghe\0" - "Cyrillic_ha\0" - "Cyrillic_i\0" - "Cyrillic_shorti\0" - "Cyrillic_ka\0" - "Cyrillic_el\0" - "Cyrillic_em\0" - "Cyrillic_en\0" - "Cyrillic_o\0" - "Cyrillic_pe\0" - "Cyrillic_ya\0" - "Cyrillic_er\0" - "Cyrillic_es\0" - "Cyrillic_te\0" - "Cyrillic_u\0" - "Cyrillic_zhe\0" - "Cyrillic_ve\0" - "Cyrillic_softsign\0" - "Cyrillic_yeru\0" - "Cyrillic_ze\0" - "Cyrillic_sha\0" - "Cyrillic_e\0" - "Cyrillic_shcha\0" - "Cyrillic_che\0" - "Cyrillic_hardsign\0" - "Cyrillic_YU\0" - "Cyrillic_A\0" - "Cyrillic_BE\0" - "Cyrillic_TSE\0" - "Cyrillic_DE\0" - "Cyrillic_IE\0" - "Cyrillic_EF\0" - "Cyrillic_GHE\0" - "Cyrillic_HA\0" - "Cyrillic_I\0" - "Cyrillic_SHORTI\0" - "Cyrillic_KA\0" - "Cyrillic_EL\0" - "Cyrillic_EM\0" - "Cyrillic_EN\0" - "Cyrillic_O\0" - "Cyrillic_PE\0" - "Cyrillic_YA\0" - "Cyrillic_ER\0" - "Cyrillic_ES\0" - "Cyrillic_TE\0" - "Cyrillic_U\0" - "Cyrillic_ZHE\0" - "Cyrillic_VE\0" - "Cyrillic_SOFTSIGN\0" - "Cyrillic_YERU\0" - "Cyrillic_ZE\0" - "Cyrillic_SHA\0" - "Cyrillic_E\0" - "Cyrillic_SHCHA\0" - "Cyrillic_CHE\0" - "Cyrillic_HARDSIGN\0" - "Greek_ALPHAaccent\0" - "Greek_EPSILONaccent\0" - "Greek_ETAaccent\0" - "Greek_IOTAaccent\0" - "Greek_IOTAdieresis\0" - "Greek_IOTAdiaeresis\0" - "Greek_OMICRONaccent\0" - "Greek_UPSILONaccent\0" - "Greek_UPSILONdieresis\0" - "Greek_OMEGAaccent\0" - "Greek_accentdieresis\0" - "Greek_horizbar\0" - "Greek_alphaaccent\0" - "Greek_epsilonaccent\0" - "Greek_etaaccent\0" - "Greek_iotaaccent\0" - "Greek_iotadieresis\0" - "Greek_iotaaccentdieresis\0" - "Greek_omicronaccent\0" - "Greek_upsilonaccent\0" - "Greek_upsilondieresis\0" - "Greek_upsilonaccentdieresis\0" - "Greek_omegaaccent\0" - "Greek_ALPHA\0" - "Greek_BETA\0" - "Greek_GAMMA\0" - "Greek_DELTA\0" - "Greek_EPSILON\0" - "Greek_ZETA\0" - "Greek_ETA\0" - "Greek_THETA\0" - "Greek_IOTA\0" - "Greek_KAPPA\0" - "Greek_LAMBDA\0" - "Greek_LAMDA\0" - "Greek_MU\0" - "Greek_NU\0" - "Greek_XI\0" - "Greek_OMICRON\0" - "Greek_PI\0" - "Greek_RHO\0" - "Greek_SIGMA\0" - "Greek_TAU\0" - "Greek_UPSILON\0" - "Greek_PHI\0" - "Greek_CHI\0" - "Greek_PSI\0" - "Greek_OMEGA\0" - "Greek_alpha\0" - "Greek_beta\0" - "Greek_gamma\0" - "Greek_delta\0" - "Greek_epsilon\0" - "Greek_zeta\0" - "Greek_eta\0" - "Greek_theta\0" - "Greek_iota\0" - "Greek_kappa\0" - "Greek_lambda\0" - "Greek_lamda\0" - "Greek_mu\0" - "Greek_nu\0" - "Greek_xi\0" - "Greek_omicron\0" - "Greek_pi\0" - "Greek_rho\0" - "Greek_sigma\0" - "Greek_finalsmallsigma\0" - "Greek_tau\0" - "Greek_upsilon\0" - "Greek_phi\0" - "Greek_chi\0" - "Greek_psi\0" - "Greek_omega\0" - "leftradical\0" - "topleftradical\0" - "horizconnector\0" - "topintegral\0" - "botintegral\0" - "vertconnector\0" - "topleftsqbracket\0" - "botleftsqbracket\0" - "toprightsqbracket\0" - "botrightsqbracket\0" - "topleftparens\0" - "botleftparens\0" - "toprightparens\0" - "botrightparens\0" - "leftmiddlecurlybrace\0" - "rightmiddlecurlybrace\0" - "topleftsummation\0" - "botleftsummation\0" - "topvertsummationconnector\0" - "botvertsummationconnector\0" - "toprightsummation\0" - "botrightsummation\0" - "rightmiddlesummation\0" - "lessthanequal\0" - "notequal\0" - "greaterthanequal\0" - "integral\0" - "therefore\0" - "variation\0" - "infinity\0" - "nabla\0" - "approximate\0" - "similarequal\0" - "ifonlyif\0" - "implies\0" - "identical\0" - "radical\0" - "includedin\0" - "includes\0" - "intersection\0" - "union\0" - "logicaland\0" - "logicalor\0" - "partialderivative\0" - "function\0" - "leftarrow\0" - "uparrow\0" - "rightarrow\0" - "downarrow\0" - "blank\0" - "soliddiamond\0" - "checkerboard\0" - "ht\0" - "ff\0" - "cr\0" - "lf\0" - "nl\0" - "vt\0" - "lowrightcorner\0" - "uprightcorner\0" - "upleftcorner\0" - "lowleftcorner\0" - "crossinglines\0" - "horizlinescan1\0" - "horizlinescan3\0" - "horizlinescan5\0" - "horizlinescan7\0" - "horizlinescan9\0" - "leftt\0" - "rightt\0" - "bott\0" - "topt\0" - "vertbar\0" - "emspace\0" - "enspace\0" - "em3space\0" - "em4space\0" - "digitspace\0" - "punctspace\0" - "thinspace\0" - "hairspace\0" - "emdash\0" - "endash\0" - "signifblank\0" - "ellipsis\0" - "doubbaselinedot\0" - "onethird\0" - "twothirds\0" - "onefifth\0" - "twofifths\0" - "threefifths\0" - "fourfifths\0" - "onesixth\0" - "fivesixths\0" - "careof\0" - "figdash\0" - "leftanglebracket\0" - "decimalpoint\0" - "rightanglebracket\0" - "marker\0" - "oneeighth\0" - "threeeighths\0" - "fiveeighths\0" - "seveneighths\0" - "trademark\0" - "signaturemark\0" - "trademarkincircle\0" - "leftopentriangle\0" - "rightopentriangle\0" - "emopencircle\0" - "emopenrectangle\0" - "leftsinglequotemark\0" - "rightsinglequotemark\0" - "leftdoublequotemark\0" - "rightdoublequotemark\0" - "prescription\0" - "minutes\0" - "seconds\0" - "latincross\0" - "hexagram\0" - "filledrectbullet\0" - "filledlefttribullet\0" - "filledrighttribullet\0" - "emfilledcircle\0" - "emfilledrect\0" - "enopencircbullet\0" - "enopensquarebullet\0" - "openrectbullet\0" - "opentribulletup\0" - "opentribulletdown\0" - "openstar\0" - "enfilledcircbullet\0" - "enfilledsqbullet\0" - "filledtribulletup\0" - "filledtribulletdown\0" - "leftpointer\0" - "rightpointer\0" - "club\0" - "diamond\0" - "heart\0" - "maltesecross\0" - "dagger\0" - "doubledagger\0" - "checkmark\0" - "ballotcross\0" - "musicalsharp\0" - "musicalflat\0" - "malesymbol\0" - "femalesymbol\0" - "telephone\0" - "telephonerecorder\0" - "phonographcopyright\0" - "caret\0" - "singlelowquotemark\0" - "doublelowquotemark\0" - "cursor\0" - "leftcaret\0" - "rightcaret\0" - "downcaret\0" - "upcaret\0" - "overbar\0" - "downtack\0" - "upshoe\0" - "downstile\0" - "underbar\0" - "jot\0" - "quad\0" - "uptack\0" - "circle\0" - "upstile\0" - "downshoe\0" - "rightshoe\0" - "leftshoe\0" - "lefttack\0" - "righttack\0" - "hebrew_doublelowline\0" - "hebrew_aleph\0" - "hebrew_bet\0" - "hebrew_beth\0" - "hebrew_gimel\0" - "hebrew_gimmel\0" - "hebrew_dalet\0" - "hebrew_daleth\0" - "hebrew_he\0" - "hebrew_waw\0" - "hebrew_zain\0" - "hebrew_zayin\0" - "hebrew_chet\0" - "hebrew_het\0" - "hebrew_tet\0" - "hebrew_teth\0" - "hebrew_yod\0" - "hebrew_finalkaph\0" - "hebrew_kaph\0" - "hebrew_lamed\0" - "hebrew_finalmem\0" - "hebrew_mem\0" - "hebrew_finalnun\0" - "hebrew_nun\0" - "hebrew_samech\0" - "hebrew_samekh\0" - "hebrew_ayin\0" - "hebrew_finalpe\0" - "hebrew_pe\0" - "hebrew_finalzade\0" - "hebrew_finalzadi\0" - "hebrew_zade\0" - "hebrew_zadi\0" - "hebrew_kuf\0" - "hebrew_qoph\0" - "hebrew_resh\0" - "hebrew_shin\0" - "hebrew_taf\0" - "hebrew_taw\0" - "Thai_kokai\0" - "Thai_khokhai\0" - "Thai_khokhuat\0" - "Thai_khokhwai\0" - "Thai_khokhon\0" - "Thai_khorakhang\0" - "Thai_ngongu\0" - "Thai_chochan\0" - "Thai_choching\0" - "Thai_chochang\0" - "Thai_soso\0" - "Thai_chochoe\0" - "Thai_yoying\0" - "Thai_dochada\0" - "Thai_topatak\0" - "Thai_thothan\0" - "Thai_thonangmontho\0" - "Thai_thophuthao\0" - "Thai_nonen\0" - "Thai_dodek\0" - "Thai_totao\0" - "Thai_thothung\0" - "Thai_thothahan\0" - "Thai_thothong\0" - "Thai_nonu\0" - "Thai_bobaimai\0" - "Thai_popla\0" - "Thai_phophung\0" - "Thai_fofa\0" - "Thai_phophan\0" - "Thai_fofan\0" - "Thai_phosamphao\0" - "Thai_moma\0" - "Thai_yoyak\0" - "Thai_rorua\0" - "Thai_ru\0" - "Thai_loling\0" - "Thai_lu\0" - "Thai_wowaen\0" - "Thai_sosala\0" - "Thai_sorusi\0" - "Thai_sosua\0" - "Thai_hohip\0" - "Thai_lochula\0" - "Thai_oang\0" - "Thai_honokhuk\0" - "Thai_paiyannoi\0" - "Thai_saraa\0" - "Thai_maihanakat\0" - "Thai_saraaa\0" - "Thai_saraam\0" - "Thai_sarai\0" - "Thai_saraii\0" - "Thai_saraue\0" - "Thai_sarauee\0" - "Thai_sarau\0" - "Thai_sarauu\0" - "Thai_phinthu\0" - "Thai_maihanakat_maitho\0" - "Thai_baht\0" - "Thai_sarae\0" - "Thai_saraae\0" - "Thai_sarao\0" - "Thai_saraaimaimuan\0" - "Thai_saraaimaimalai\0" - "Thai_lakkhangyao\0" - "Thai_maiyamok\0" - "Thai_maitaikhu\0" - "Thai_maiek\0" - "Thai_maitho\0" - "Thai_maitri\0" - "Thai_maichattawa\0" - "Thai_thanthakhat\0" - "Thai_nikhahit\0" - "Thai_leksun\0" - "Thai_leknung\0" - "Thai_leksong\0" - "Thai_leksam\0" - "Thai_leksi\0" - "Thai_lekha\0" - "Thai_lekhok\0" - "Thai_lekchet\0" - "Thai_lekpaet\0" - "Thai_lekkao\0" - "Hangul_Kiyeog\0" - "Hangul_SsangKiyeog\0" - "Hangul_KiyeogSios\0" - "Hangul_Nieun\0" - "Hangul_NieunJieuj\0" - "Hangul_NieunHieuh\0" - "Hangul_Dikeud\0" - "Hangul_SsangDikeud\0" - "Hangul_Rieul\0" - "Hangul_RieulKiyeog\0" - "Hangul_RieulMieum\0" - "Hangul_RieulPieub\0" - "Hangul_RieulSios\0" - "Hangul_RieulTieut\0" - "Hangul_RieulPhieuf\0" - "Hangul_RieulHieuh\0" - "Hangul_Mieum\0" - "Hangul_Pieub\0" - "Hangul_SsangPieub\0" - "Hangul_PieubSios\0" - "Hangul_Sios\0" - "Hangul_SsangSios\0" - "Hangul_Ieung\0" - "Hangul_Jieuj\0" - "Hangul_SsangJieuj\0" - "Hangul_Cieuc\0" - "Hangul_Khieuq\0" - "Hangul_Tieut\0" - "Hangul_Phieuf\0" - "Hangul_Hieuh\0" - "Hangul_A\0" - "Hangul_AE\0" - "Hangul_YA\0" - "Hangul_YAE\0" - "Hangul_EO\0" - "Hangul_E\0" - "Hangul_YEO\0" - "Hangul_YE\0" - "Hangul_O\0" - "Hangul_WA\0" - "Hangul_WAE\0" - "Hangul_OE\0" - "Hangul_YO\0" - "Hangul_U\0" - "Hangul_WEO\0" - "Hangul_WE\0" - "Hangul_WI\0" - "Hangul_YU\0" - "Hangul_EU\0" - "Hangul_YI\0" - "Hangul_I\0" - "Hangul_J_Kiyeog\0" - "Hangul_J_SsangKiyeog\0" - "Hangul_J_KiyeogSios\0" - "Hangul_J_Nieun\0" - "Hangul_J_NieunJieuj\0" - "Hangul_J_NieunHieuh\0" - "Hangul_J_Dikeud\0" - "Hangul_J_Rieul\0" - "Hangul_J_RieulKiyeog\0" - "Hangul_J_RieulMieum\0" - "Hangul_J_RieulPieub\0" - "Hangul_J_RieulSios\0" - "Hangul_J_RieulTieut\0" - "Hangul_J_RieulPhieuf\0" - "Hangul_J_RieulHieuh\0" - "Hangul_J_Mieum\0" - "Hangul_J_Pieub\0" - "Hangul_J_PieubSios\0" - "Hangul_J_Sios\0" - "Hangul_J_SsangSios\0" - "Hangul_J_Ieung\0" - "Hangul_J_Jieuj\0" - "Hangul_J_Cieuc\0" - "Hangul_J_Khieuq\0" - "Hangul_J_Tieut\0" - "Hangul_J_Phieuf\0" - "Hangul_J_Hieuh\0" - "Hangul_RieulYeorinHieuh\0" - "Hangul_SunkyeongeumMieum\0" - "Hangul_SunkyeongeumPieub\0" - "Hangul_PanSios\0" - "Hangul_KkogjiDalrinIeung\0" - "Hangul_SunkyeongeumPhieuf\0" - "Hangul_YeorinHieuh\0" - "Hangul_AraeA\0" - "Hangul_AraeAE\0" - "Hangul_J_PanSios\0" - "Hangul_J_KkogjiDalrinIeung\0" - "Hangul_J_YeorinHieuh\0" - "Korean_Won\0" - "OE\0" - "oe\0" - "Ydiaeresis\0" - "EcuSign\0" - "ColonSign\0" - "CruzeiroSign\0" - "FFrancSign\0" - "LiraSign\0" - "MillSign\0" - "NairaSign\0" - "PesetaSign\0" - "RupeeSign\0" - "WonSign\0" - "NewSheqelSign\0" - "DongSign\0" - "EuroSign\0" - "3270_Duplicate\0" - "3270_FieldMark\0" - "3270_Right2\0" - "3270_Left2\0" - "3270_BackTab\0" - "3270_EraseEOF\0" - "3270_EraseInput\0" - "3270_Reset\0" - "3270_Quit\0" - "3270_PA1\0" - "3270_PA2\0" - "3270_PA3\0" - "3270_Test\0" - "3270_Attn\0" - "3270_CursorBlink\0" - "3270_AltCursor\0" - "3270_KeyClick\0" - "3270_Jump\0" - "3270_Ident\0" - "3270_Rule\0" - "3270_Copy\0" - "3270_Play\0" - "3270_Setup\0" - "3270_Record\0" - "3270_ChangeScreen\0" - "3270_DeleteWord\0" - "3270_ExSelect\0" - "3270_CursorSelect\0" - "3270_PrintScreen\0" - "3270_Enter\0" - "ISO_Lock\0" - "ISO_Level2_Latch\0" - "ISO_Level3_Shift\0" - "ISO_Level3_Latch\0" - "ISO_Level3_Lock\0" - "ISO_Group_Latch\0" - "ISO_Group_Lock\0" - "ISO_Next_Group\0" - "ISO_Next_Group_Lock\0" - "ISO_Prev_Group\0" - "ISO_Prev_Group_Lock\0" - "ISO_First_Group\0" - "ISO_First_Group_Lock\0" - "ISO_Last_Group\0" - "ISO_Last_Group_Lock\0" - "ISO_Left_Tab\0" - "ISO_Move_Line_Up\0" - "ISO_Move_Line_Down\0" - "ISO_Partial_Line_Up\0" - "ISO_Partial_Line_Down\0" - "ISO_Partial_Space_Left\0" - "ISO_Partial_Space_Right\0" - "ISO_Set_Margin_Left\0" - "ISO_Set_Margin_Right\0" - "ISO_Release_Margin_Left\0" - "ISO_Release_Margin_Right\0" - "ISO_Release_Both_Margins\0" - "ISO_Fast_Cursor_Left\0" - "ISO_Fast_Cursor_Right\0" - "ISO_Fast_Cursor_Up\0" - "ISO_Fast_Cursor_Down\0" - "ISO_Continuous_Underline\0" - "ISO_Discontinuous_Underline\0" - "ISO_Emphasize\0" - "ISO_Center_Object\0" - "ISO_Enter\0" - "dead_grave\0" - "dead_acute\0" - "dead_circumflex\0" - "dead_tilde\0" - "dead_macron\0" - "dead_breve\0" - "dead_abovedot\0" - "dead_diaeresis\0" - "dead_abovering\0" - "dead_doubleacute\0" - "dead_caron\0" - "dead_cedilla\0" - "dead_ogonek\0" - "dead_iota\0" - "dead_voiced_sound\0" - "dead_semivoiced_sound\0" - "dead_belowdot\0" - "dead_hook\0" - "dead_horn\0" - "AccessX_Enable\0" - "AccessX_Feedback_Enable\0" - "RepeatKeys_Enable\0" - "SlowKeys_Enable\0" - "BounceKeys_Enable\0" - "StickyKeys_Enable\0" - "MouseKeys_Enable\0" - "MouseKeys_Accel_Enable\0" - "Overlay1_Enable\0" - "Overlay2_Enable\0" - "AudibleBell_Enable\0" - "First_Virtual_Screen\0" - "Prev_Virtual_Screen\0" - "Next_Virtual_Screen\0" - "Last_Virtual_Screen\0" - "Terminate_Server\0" - "Pointer_Left\0" - "Pointer_Right\0" - "Pointer_Up\0" - "Pointer_Down\0" - "Pointer_UpLeft\0" - "Pointer_UpRight\0" - "Pointer_DownLeft\0" - "Pointer_DownRight\0" - "Pointer_Button_Dflt\0" - "Pointer_Button1\0" - "Pointer_Button2\0" - "Pointer_Button3\0" - "Pointer_Button4\0" - "Pointer_Button5\0" - "Pointer_DblClick_Dflt\0" - "Pointer_DblClick1\0" - "Pointer_DblClick2\0" - "Pointer_DblClick3\0" - "Pointer_DblClick4\0" - "Pointer_DblClick5\0" - "Pointer_Drag_Dflt\0" - "Pointer_Drag1\0" - "Pointer_Drag2\0" - "Pointer_Drag3\0" - "Pointer_Drag4\0" - "Pointer_EnableKeys\0" - "Pointer_Accelerate\0" - "Pointer_DfltBtnNext\0" - "Pointer_DfltBtnPrev\0" - "Pointer_Drag5\0" - "BackSpace\0" - "Tab\0" - "Linefeed\0" - "Clear\0" - "Return\0" - "Pause\0" - "Scroll_Lock\0" - "Sys_Req\0" - "Escape\0" - "Multi_key\0" - "Kanji\0" - "Muhenkan\0" - "Henkan\0" - "Henkan_Mode\0" - "Romaji\0" - "Hiragana\0" - "Katakana\0" - "Hiragana_Katakana\0" - "Zenkaku\0" - "Hankaku\0" - "Zenkaku_Hankaku\0" - "Touroku\0" - "Massyo\0" - "Kana_Lock\0" - "Kana_Shift\0" - "Eisu_Shift\0" - "Eisu_toggle\0" - "Hangul\0" - "Hangul_Start\0" - "Hangul_End\0" - "Hangul_Hanja\0" - "Hangul_Jamo\0" - "Hangul_Romaja\0" - "Codeinput\0" - "Hangul_Jeonja\0" - "Hangul_Banja\0" - "Hangul_PreHanja\0" - "Hangul_PostHanja\0" - "SingleCandidate\0" - "MultipleCandidate\0" - "PreviousCandidate\0" - "Hangul_Special\0" - "Home\0" - "Left\0" - "Up\0" - "Right\0" - "Down\0" - "Page_Up\0" - "Prior\0" - "Page_Down\0" - "Next\0" - "End\0" - "Begin\0" - "Select\0" - "Print\0" - "Execute\0" - "Insert\0" - "Undo\0" - "Redo\0" - "Menu\0" - "Find\0" - "Cancel\0" - "Help\0" - "Break\0" - "Arabic_switch\0" - "Greek_switch\0" - "Hangul_switch\0" - "Hebrew_switch\0" - "ISO_Group_Shift\0" - "Mode_switch\0" - "kana_switch\0" - "script_switch\0" - "Num_Lock\0" - "KP_Space\0" - "KP_Tab\0" - "KP_Enter\0" - "KP_F1\0" - "KP_F2\0" - "KP_F3\0" - "KP_F4\0" - "KP_Home\0" - "KP_Left\0" - "KP_Up\0" - "KP_Right\0" - "KP_Down\0" - "KP_Page_Up\0" - "KP_Prior\0" - "KP_Page_Down\0" - "KP_Next\0" - "KP_End\0" - "KP_Begin\0" - "KP_Insert\0" - "KP_Delete\0" - "KP_Multiply\0" - "KP_Add\0" - "KP_Separator\0" - "KP_Subtract\0" - "KP_Decimal\0" - "KP_Divide\0" - "KP_0\0" - "KP_1\0" - "KP_2\0" - "KP_3\0" - "KP_4\0" - "KP_5\0" - "KP_6\0" - "KP_7\0" - "KP_8\0" - "KP_9\0" - "KP_Equal\0" - "F1\0" - "F2\0" - "F3\0" - "F4\0" - "F5\0" - "F6\0" - "F7\0" - "F8\0" - "F9\0" - "F10\0" - "F11\0" - "F12\0" - "F13\0" - "F14\0" - "F15\0" - "F16\0" - "F17\0" - "F18\0" - "F19\0" - "F20\0" - "F21\0" - "F22\0" - "F23\0" - "F24\0" - "F25\0" - "F26\0" - "F27\0" - "F28\0" - "F29\0" - "F30\0" - "F31\0" - "F32\0" - "F33\0" - "F34\0" - "F35\0" - "Shift_L\0" - "Shift_R\0" - "Control_L\0" - "Control_R\0" - "Caps_Lock\0" - "Shift_Lock\0" - "Meta_L\0" - "Meta_R\0" - "Alt_L\0" - "Alt_R\0" - "Super_L\0" - "Super_R\0" - "Hyper_L\0" - "Hyper_R\0" - "Delete\0" - "VoidSymbol\0"; + "space\0" + "exclam\0" + "quotedbl\0" + "numbersign\0" + "dollar\0" + "percent\0" + "ampersand\0" + "apostrophe\0" + "quoteright\0" + "parenleft\0" + "parenright\0" + "asterisk\0" + "plus\0" + "comma\0" + "minus\0" + "period\0" + "slash\0" + "0\0" + "1\0" + "2\0" + "3\0" + "4\0" + "5\0" + "6\0" + "7\0" + "8\0" + "9\0" + "colon\0" + "semicolon\0" + "less\0" + "equal\0" + "greater\0" + "question\0" + "at\0" + "A\0" + "B\0" + "C\0" + "D\0" + "E\0" + "F\0" + "G\0" + "H\0" + "I\0" + "J\0" + "K\0" + "L\0" + "M\0" + "N\0" + "O\0" + "P\0" + "Q\0" + "R\0" + "S\0" + "T\0" + "U\0" + "V\0" + "W\0" + "X\0" + "Y\0" + "Z\0" + "bracketleft\0" + "backslash\0" + "bracketright\0" + "asciicircum\0" + "underscore\0" + "grave\0" + "quoteleft\0" + "a\0" + "b\0" + "c\0" + "d\0" + "e\0" + "f\0" + "g\0" + "h\0" + "i\0" + "j\0" + "k\0" + "l\0" + "m\0" + "n\0" + "o\0" + "p\0" + "q\0" + "r\0" + "s\0" + "t\0" + "u\0" + "v\0" + "w\0" + "x\0" + "y\0" + "z\0" + "braceleft\0" + "bar\0" + "braceright\0" + "asciitilde\0" + "nobreakspace\0" + "exclamdown\0" + "cent\0" + "sterling\0" + "currency\0" + "yen\0" + "brokenbar\0" + "section\0" + "diaeresis\0" + "copyright\0" + "ordfeminine\0" + "guillemotleft\0" + "notsign\0" + "hyphen\0" + "registered\0" + "macron\0" + "degree\0" + "plusminus\0" + "twosuperior\0" + "threesuperior\0" + "acute\0" + "mu\0" + "paragraph\0" + "periodcentered\0" + "cedilla\0" + "onesuperior\0" + "masculine\0" + "guillemotright\0" + "onequarter\0" + "onehalf\0" + "threequarters\0" + "questiondown\0" + "Agrave\0" + "Aacute\0" + "Acircumflex\0" + "Atilde\0" + "Adiaeresis\0" + "Aring\0" + "AE\0" + "Ccedilla\0" + "Egrave\0" + "Eacute\0" + "Ecircumflex\0" + "Ediaeresis\0" + "Igrave\0" + "Iacute\0" + "Icircumflex\0" + "Idiaeresis\0" + "ETH\0" + "Eth\0" + "Ntilde\0" + "Ograve\0" + "Oacute\0" + "Ocircumflex\0" + "Otilde\0" + "Odiaeresis\0" + "multiply\0" + "Ooblique\0" + "Ugrave\0" + "Uacute\0" + "Ucircumflex\0" + "Udiaeresis\0" + "Yacute\0" + "THORN\0" + "Thorn\0" + "ssharp\0" + "agrave\0" + "aacute\0" + "acircumflex\0" + "atilde\0" + "adiaeresis\0" + "aring\0" + "ae\0" + "ccedilla\0" + "egrave\0" + "eacute\0" + "ecircumflex\0" + "ediaeresis\0" + "igrave\0" + "iacute\0" + "icircumflex\0" + "idiaeresis\0" + "eth\0" + "ntilde\0" + "ograve\0" + "oacute\0" + "ocircumflex\0" + "otilde\0" + "odiaeresis\0" + "division\0" + "oslash\0" + "ugrave\0" + "uacute\0" + "ucircumflex\0" + "udiaeresis\0" + "yacute\0" + "thorn\0" + "ydiaeresis\0" + "Aogonek\0" + "breve\0" + "Lstroke\0" + "Lcaron\0" + "Sacute\0" + "Scaron\0" + "Scedilla\0" + "Tcaron\0" + "Zacute\0" + "Zcaron\0" + "Zabovedot\0" + "aogonek\0" + "ogonek\0" + "lstroke\0" + "lcaron\0" + "sacute\0" + "caron\0" + "scaron\0" + "scedilla\0" + "tcaron\0" + "zacute\0" + "doubleacute\0" + "zcaron\0" + "zabovedot\0" + "Racute\0" + "Abreve\0" + "Lacute\0" + "Cacute\0" + "Ccaron\0" + "Eogonek\0" + "Ecaron\0" + "Dcaron\0" + "Dstroke\0" + "Nacute\0" + "Ncaron\0" + "Odoubleacute\0" + "Rcaron\0" + "Uring\0" + "Udoubleacute\0" + "Tcedilla\0" + "racute\0" + "abreve\0" + "lacute\0" + "cacute\0" + "ccaron\0" + "eogonek\0" + "ecaron\0" + "dcaron\0" + "dstroke\0" + "nacute\0" + "ncaron\0" + "odoubleacute\0" + "rcaron\0" + "uring\0" + "udoubleacute\0" + "tcedilla\0" + "abovedot\0" + "Hstroke\0" + "Hcircumflex\0" + "Iabovedot\0" + "Gbreve\0" + "Jcircumflex\0" + "hstroke\0" + "hcircumflex\0" + "idotless\0" + "gbreve\0" + "jcircumflex\0" + "Cabovedot\0" + "Ccircumflex\0" + "Gabovedot\0" + "Gcircumflex\0" + "Ubreve\0" + "Scircumflex\0" + "cabovedot\0" + "ccircumflex\0" + "gabovedot\0" + "gcircumflex\0" + "ubreve\0" + "scircumflex\0" + "kappa\0" + "kra\0" + "Rcedilla\0" + "Itilde\0" + "Lcedilla\0" + "Emacron\0" + "Gcedilla\0" + "Tslash\0" + "rcedilla\0" + "itilde\0" + "lcedilla\0" + "emacron\0" + "gcedilla\0" + "tslash\0" + "ENG\0" + "eng\0" + "Amacron\0" + "Iogonek\0" + "Eabovedot\0" + "Imacron\0" + "Ncedilla\0" + "Omacron\0" + "Kcedilla\0" + "Uogonek\0" + "Utilde\0" + "Umacron\0" + "amacron\0" + "iogonek\0" + "eabovedot\0" + "imacron\0" + "ncedilla\0" + "omacron\0" + "kcedilla\0" + "uogonek\0" + "utilde\0" + "umacron\0" + "overline\0" + "kana_fullstop\0" + "kana_openingbracket\0" + "kana_closingbracket\0" + "kana_comma\0" + "kana_conjunctive\0" + "kana_middledot\0" + "kana_WO\0" + "kana_a\0" + "kana_i\0" + "kana_u\0" + "kana_e\0" + "kana_o\0" + "kana_ya\0" + "kana_yu\0" + "kana_yo\0" + "kana_tsu\0" + "kana_tu\0" + "prolongedsound\0" + "kana_A\0" + "kana_I\0" + "kana_U\0" + "kana_E\0" + "kana_O\0" + "kana_KA\0" + "kana_KI\0" + "kana_KU\0" + "kana_KE\0" + "kana_KO\0" + "kana_SA\0" + "kana_SHI\0" + "kana_SU\0" + "kana_SE\0" + "kana_SO\0" + "kana_TA\0" + "kana_CHI\0" + "kana_TI\0" + "kana_TSU\0" + "kana_TU\0" + "kana_TE\0" + "kana_TO\0" + "kana_NA\0" + "kana_NI\0" + "kana_NU\0" + "kana_NE\0" + "kana_NO\0" + "kana_HA\0" + "kana_HI\0" + "kana_FU\0" + "kana_HU\0" + "kana_HE\0" + "kana_HO\0" + "kana_MA\0" + "kana_MI\0" + "kana_MU\0" + "kana_ME\0" + "kana_MO\0" + "kana_YA\0" + "kana_YU\0" + "kana_YO\0" + "kana_RA\0" + "kana_RI\0" + "kana_RU\0" + "kana_RE\0" + "kana_RO\0" + "kana_WA\0" + "kana_N\0" + "voicedsound\0" + "semivoicedsound\0" + "Arabic_comma\0" + "Arabic_semicolon\0" + "Arabic_question_mark\0" + "Arabic_hamza\0" + "Arabic_maddaonalef\0" + "Arabic_hamzaonalef\0" + "Arabic_hamzaonwaw\0" + "Arabic_hamzaunderalef\0" + "Arabic_hamzaonyeh\0" + "Arabic_alef\0" + "Arabic_beh\0" + "Arabic_tehmarbuta\0" + "Arabic_teh\0" + "Arabic_theh\0" + "Arabic_jeem\0" + "Arabic_hah\0" + "Arabic_khah\0" + "Arabic_dal\0" + "Arabic_thal\0" + "Arabic_ra\0" + "Arabic_zain\0" + "Arabic_seen\0" + "Arabic_sheen\0" + "Arabic_sad\0" + "Arabic_dad\0" + "Arabic_tah\0" + "Arabic_zah\0" + "Arabic_ain\0" + "Arabic_ghain\0" + "Arabic_tatweel\0" + "Arabic_feh\0" + "Arabic_qaf\0" + "Arabic_kaf\0" + "Arabic_lam\0" + "Arabic_meem\0" + "Arabic_noon\0" + "Arabic_ha\0" + "Arabic_heh\0" + "Arabic_waw\0" + "Arabic_alefmaksura\0" + "Arabic_yeh\0" + "Arabic_fathatan\0" + "Arabic_dammatan\0" + "Arabic_kasratan\0" + "Arabic_fatha\0" + "Arabic_damma\0" + "Arabic_kasra\0" + "Arabic_shadda\0" + "Arabic_sukun\0" + "Serbian_dje\0" + "Macedonia_gje\0" + "Cyrillic_io\0" + "Ukrainian_ie\0" + "Ukranian_je\0" + "Macedonia_dse\0" + "Ukrainian_i\0" + "Ukranian_i\0" + "Ukrainian_yi\0" + "Ukranian_yi\0" + "Cyrillic_je\0" + "Serbian_je\0" + "Cyrillic_lje\0" + "Serbian_lje\0" + "Cyrillic_nje\0" + "Serbian_nje\0" + "Serbian_tshe\0" + "Macedonia_kje\0" + "Byelorussian_shortu\0" + "Cyrillic_dzhe\0" + "Serbian_dze\0" + "numerosign\0" + "Serbian_DJE\0" + "Macedonia_GJE\0" + "Cyrillic_IO\0" + "Ukrainian_IE\0" + "Ukranian_JE\0" + "Macedonia_DSE\0" + "Ukrainian_I\0" + "Ukranian_I\0" + "Ukrainian_YI\0" + "Ukranian_YI\0" + "Cyrillic_JE\0" + "Serbian_JE\0" + "Cyrillic_LJE\0" + "Serbian_LJE\0" + "Cyrillic_NJE\0" + "Serbian_NJE\0" + "Serbian_TSHE\0" + "Macedonia_KJE\0" + "Byelorussian_SHORTU\0" + "Cyrillic_DZHE\0" + "Serbian_DZE\0" + "Cyrillic_yu\0" + "Cyrillic_a\0" + "Cyrillic_be\0" + "Cyrillic_tse\0" + "Cyrillic_de\0" + "Cyrillic_ie\0" + "Cyrillic_ef\0" + "Cyrillic_ghe\0" + "Cyrillic_ha\0" + "Cyrillic_i\0" + "Cyrillic_shorti\0" + "Cyrillic_ka\0" + "Cyrillic_el\0" + "Cyrillic_em\0" + "Cyrillic_en\0" + "Cyrillic_o\0" + "Cyrillic_pe\0" + "Cyrillic_ya\0" + "Cyrillic_er\0" + "Cyrillic_es\0" + "Cyrillic_te\0" + "Cyrillic_u\0" + "Cyrillic_zhe\0" + "Cyrillic_ve\0" + "Cyrillic_softsign\0" + "Cyrillic_yeru\0" + "Cyrillic_ze\0" + "Cyrillic_sha\0" + "Cyrillic_e\0" + "Cyrillic_shcha\0" + "Cyrillic_che\0" + "Cyrillic_hardsign\0" + "Cyrillic_YU\0" + "Cyrillic_A\0" + "Cyrillic_BE\0" + "Cyrillic_TSE\0" + "Cyrillic_DE\0" + "Cyrillic_IE\0" + "Cyrillic_EF\0" + "Cyrillic_GHE\0" + "Cyrillic_HA\0" + "Cyrillic_I\0" + "Cyrillic_SHORTI\0" + "Cyrillic_KA\0" + "Cyrillic_EL\0" + "Cyrillic_EM\0" + "Cyrillic_EN\0" + "Cyrillic_O\0" + "Cyrillic_PE\0" + "Cyrillic_YA\0" + "Cyrillic_ER\0" + "Cyrillic_ES\0" + "Cyrillic_TE\0" + "Cyrillic_U\0" + "Cyrillic_ZHE\0" + "Cyrillic_VE\0" + "Cyrillic_SOFTSIGN\0" + "Cyrillic_YERU\0" + "Cyrillic_ZE\0" + "Cyrillic_SHA\0" + "Cyrillic_E\0" + "Cyrillic_SHCHA\0" + "Cyrillic_CHE\0" + "Cyrillic_HARDSIGN\0" + "Greek_ALPHAaccent\0" + "Greek_EPSILONaccent\0" + "Greek_ETAaccent\0" + "Greek_IOTAaccent\0" + "Greek_IOTAdieresis\0" + "Greek_IOTAdiaeresis\0" + "Greek_OMICRONaccent\0" + "Greek_UPSILONaccent\0" + "Greek_UPSILONdieresis\0" + "Greek_OMEGAaccent\0" + "Greek_accentdieresis\0" + "Greek_horizbar\0" + "Greek_alphaaccent\0" + "Greek_epsilonaccent\0" + "Greek_etaaccent\0" + "Greek_iotaaccent\0" + "Greek_iotadieresis\0" + "Greek_iotaaccentdieresis\0" + "Greek_omicronaccent\0" + "Greek_upsilonaccent\0" + "Greek_upsilondieresis\0" + "Greek_upsilonaccentdieresis\0" + "Greek_omegaaccent\0" + "Greek_ALPHA\0" + "Greek_BETA\0" + "Greek_GAMMA\0" + "Greek_DELTA\0" + "Greek_EPSILON\0" + "Greek_ZETA\0" + "Greek_ETA\0" + "Greek_THETA\0" + "Greek_IOTA\0" + "Greek_KAPPA\0" + "Greek_LAMBDA\0" + "Greek_LAMDA\0" + "Greek_MU\0" + "Greek_NU\0" + "Greek_XI\0" + "Greek_OMICRON\0" + "Greek_PI\0" + "Greek_RHO\0" + "Greek_SIGMA\0" + "Greek_TAU\0" + "Greek_UPSILON\0" + "Greek_PHI\0" + "Greek_CHI\0" + "Greek_PSI\0" + "Greek_OMEGA\0" + "Greek_alpha\0" + "Greek_beta\0" + "Greek_gamma\0" + "Greek_delta\0" + "Greek_epsilon\0" + "Greek_zeta\0" + "Greek_eta\0" + "Greek_theta\0" + "Greek_iota\0" + "Greek_kappa\0" + "Greek_lambda\0" + "Greek_lamda\0" + "Greek_mu\0" + "Greek_nu\0" + "Greek_xi\0" + "Greek_omicron\0" + "Greek_pi\0" + "Greek_rho\0" + "Greek_sigma\0" + "Greek_finalsmallsigma\0" + "Greek_tau\0" + "Greek_upsilon\0" + "Greek_phi\0" + "Greek_chi\0" + "Greek_psi\0" + "Greek_omega\0" + "leftradical\0" + "topleftradical\0" + "horizconnector\0" + "topintegral\0" + "botintegral\0" + "vertconnector\0" + "topleftsqbracket\0" + "botleftsqbracket\0" + "toprightsqbracket\0" + "botrightsqbracket\0" + "topleftparens\0" + "botleftparens\0" + "toprightparens\0" + "botrightparens\0" + "leftmiddlecurlybrace\0" + "rightmiddlecurlybrace\0" + "topleftsummation\0" + "botleftsummation\0" + "topvertsummationconnector\0" + "botvertsummationconnector\0" + "toprightsummation\0" + "botrightsummation\0" + "rightmiddlesummation\0" + "lessthanequal\0" + "notequal\0" + "greaterthanequal\0" + "integral\0" + "therefore\0" + "variation\0" + "infinity\0" + "nabla\0" + "approximate\0" + "similarequal\0" + "ifonlyif\0" + "implies\0" + "identical\0" + "radical\0" + "includedin\0" + "includes\0" + "intersection\0" + "union\0" + "logicaland\0" + "logicalor\0" + "partialderivative\0" + "function\0" + "leftarrow\0" + "uparrow\0" + "rightarrow\0" + "downarrow\0" + "blank\0" + "soliddiamond\0" + "checkerboard\0" + "ht\0" + "ff\0" + "cr\0" + "lf\0" + "nl\0" + "vt\0" + "lowrightcorner\0" + "uprightcorner\0" + "upleftcorner\0" + "lowleftcorner\0" + "crossinglines\0" + "horizlinescan1\0" + "horizlinescan3\0" + "horizlinescan5\0" + "horizlinescan7\0" + "horizlinescan9\0" + "leftt\0" + "rightt\0" + "bott\0" + "topt\0" + "vertbar\0" + "emspace\0" + "enspace\0" + "em3space\0" + "em4space\0" + "digitspace\0" + "punctspace\0" + "thinspace\0" + "hairspace\0" + "emdash\0" + "endash\0" + "signifblank\0" + "ellipsis\0" + "doubbaselinedot\0" + "onethird\0" + "twothirds\0" + "onefifth\0" + "twofifths\0" + "threefifths\0" + "fourfifths\0" + "onesixth\0" + "fivesixths\0" + "careof\0" + "figdash\0" + "leftanglebracket\0" + "decimalpoint\0" + "rightanglebracket\0" + "marker\0" + "oneeighth\0" + "threeeighths\0" + "fiveeighths\0" + "seveneighths\0" + "trademark\0" + "signaturemark\0" + "trademarkincircle\0" + "leftopentriangle\0" + "rightopentriangle\0" + "emopencircle\0" + "emopenrectangle\0" + "leftsinglequotemark\0" + "rightsinglequotemark\0" + "leftdoublequotemark\0" + "rightdoublequotemark\0" + "prescription\0" + "minutes\0" + "seconds\0" + "latincross\0" + "hexagram\0" + "filledrectbullet\0" + "filledlefttribullet\0" + "filledrighttribullet\0" + "emfilledcircle\0" + "emfilledrect\0" + "enopencircbullet\0" + "enopensquarebullet\0" + "openrectbullet\0" + "opentribulletup\0" + "opentribulletdown\0" + "openstar\0" + "enfilledcircbullet\0" + "enfilledsqbullet\0" + "filledtribulletup\0" + "filledtribulletdown\0" + "leftpointer\0" + "rightpointer\0" + "club\0" + "diamond\0" + "heart\0" + "maltesecross\0" + "dagger\0" + "doubledagger\0" + "checkmark\0" + "ballotcross\0" + "musicalsharp\0" + "musicalflat\0" + "malesymbol\0" + "femalesymbol\0" + "telephone\0" + "telephonerecorder\0" + "phonographcopyright\0" + "caret\0" + "singlelowquotemark\0" + "doublelowquotemark\0" + "cursor\0" + "leftcaret\0" + "rightcaret\0" + "downcaret\0" + "upcaret\0" + "overbar\0" + "downtack\0" + "upshoe\0" + "downstile\0" + "underbar\0" + "jot\0" + "quad\0" + "uptack\0" + "circle\0" + "upstile\0" + "downshoe\0" + "rightshoe\0" + "leftshoe\0" + "lefttack\0" + "righttack\0" + "hebrew_doublelowline\0" + "hebrew_aleph\0" + "hebrew_bet\0" + "hebrew_beth\0" + "hebrew_gimel\0" + "hebrew_gimmel\0" + "hebrew_dalet\0" + "hebrew_daleth\0" + "hebrew_he\0" + "hebrew_waw\0" + "hebrew_zain\0" + "hebrew_zayin\0" + "hebrew_chet\0" + "hebrew_het\0" + "hebrew_tet\0" + "hebrew_teth\0" + "hebrew_yod\0" + "hebrew_finalkaph\0" + "hebrew_kaph\0" + "hebrew_lamed\0" + "hebrew_finalmem\0" + "hebrew_mem\0" + "hebrew_finalnun\0" + "hebrew_nun\0" + "hebrew_samech\0" + "hebrew_samekh\0" + "hebrew_ayin\0" + "hebrew_finalpe\0" + "hebrew_pe\0" + "hebrew_finalzade\0" + "hebrew_finalzadi\0" + "hebrew_zade\0" + "hebrew_zadi\0" + "hebrew_kuf\0" + "hebrew_qoph\0" + "hebrew_resh\0" + "hebrew_shin\0" + "hebrew_taf\0" + "hebrew_taw\0" + "Thai_kokai\0" + "Thai_khokhai\0" + "Thai_khokhuat\0" + "Thai_khokhwai\0" + "Thai_khokhon\0" + "Thai_khorakhang\0" + "Thai_ngongu\0" + "Thai_chochan\0" + "Thai_choching\0" + "Thai_chochang\0" + "Thai_soso\0" + "Thai_chochoe\0" + "Thai_yoying\0" + "Thai_dochada\0" + "Thai_topatak\0" + "Thai_thothan\0" + "Thai_thonangmontho\0" + "Thai_thophuthao\0" + "Thai_nonen\0" + "Thai_dodek\0" + "Thai_totao\0" + "Thai_thothung\0" + "Thai_thothahan\0" + "Thai_thothong\0" + "Thai_nonu\0" + "Thai_bobaimai\0" + "Thai_popla\0" + "Thai_phophung\0" + "Thai_fofa\0" + "Thai_phophan\0" + "Thai_fofan\0" + "Thai_phosamphao\0" + "Thai_moma\0" + "Thai_yoyak\0" + "Thai_rorua\0" + "Thai_ru\0" + "Thai_loling\0" + "Thai_lu\0" + "Thai_wowaen\0" + "Thai_sosala\0" + "Thai_sorusi\0" + "Thai_sosua\0" + "Thai_hohip\0" + "Thai_lochula\0" + "Thai_oang\0" + "Thai_honokhuk\0" + "Thai_paiyannoi\0" + "Thai_saraa\0" + "Thai_maihanakat\0" + "Thai_saraaa\0" + "Thai_saraam\0" + "Thai_sarai\0" + "Thai_saraii\0" + "Thai_saraue\0" + "Thai_sarauee\0" + "Thai_sarau\0" + "Thai_sarauu\0" + "Thai_phinthu\0" + "Thai_maihanakat_maitho\0" + "Thai_baht\0" + "Thai_sarae\0" + "Thai_saraae\0" + "Thai_sarao\0" + "Thai_saraaimaimuan\0" + "Thai_saraaimaimalai\0" + "Thai_lakkhangyao\0" + "Thai_maiyamok\0" + "Thai_maitaikhu\0" + "Thai_maiek\0" + "Thai_maitho\0" + "Thai_maitri\0" + "Thai_maichattawa\0" + "Thai_thanthakhat\0" + "Thai_nikhahit\0" + "Thai_leksun\0" + "Thai_leknung\0" + "Thai_leksong\0" + "Thai_leksam\0" + "Thai_leksi\0" + "Thai_lekha\0" + "Thai_lekhok\0" + "Thai_lekchet\0" + "Thai_lekpaet\0" + "Thai_lekkao\0" + "Hangul_Kiyeog\0" + "Hangul_SsangKiyeog\0" + "Hangul_KiyeogSios\0" + "Hangul_Nieun\0" + "Hangul_NieunJieuj\0" + "Hangul_NieunHieuh\0" + "Hangul_Dikeud\0" + "Hangul_SsangDikeud\0" + "Hangul_Rieul\0" + "Hangul_RieulKiyeog\0" + "Hangul_RieulMieum\0" + "Hangul_RieulPieub\0" + "Hangul_RieulSios\0" + "Hangul_RieulTieut\0" + "Hangul_RieulPhieuf\0" + "Hangul_RieulHieuh\0" + "Hangul_Mieum\0" + "Hangul_Pieub\0" + "Hangul_SsangPieub\0" + "Hangul_PieubSios\0" + "Hangul_Sios\0" + "Hangul_SsangSios\0" + "Hangul_Ieung\0" + "Hangul_Jieuj\0" + "Hangul_SsangJieuj\0" + "Hangul_Cieuc\0" + "Hangul_Khieuq\0" + "Hangul_Tieut\0" + "Hangul_Phieuf\0" + "Hangul_Hieuh\0" + "Hangul_A\0" + "Hangul_AE\0" + "Hangul_YA\0" + "Hangul_YAE\0" + "Hangul_EO\0" + "Hangul_E\0" + "Hangul_YEO\0" + "Hangul_YE\0" + "Hangul_O\0" + "Hangul_WA\0" + "Hangul_WAE\0" + "Hangul_OE\0" + "Hangul_YO\0" + "Hangul_U\0" + "Hangul_WEO\0" + "Hangul_WE\0" + "Hangul_WI\0" + "Hangul_YU\0" + "Hangul_EU\0" + "Hangul_YI\0" + "Hangul_I\0" + "Hangul_J_Kiyeog\0" + "Hangul_J_SsangKiyeog\0" + "Hangul_J_KiyeogSios\0" + "Hangul_J_Nieun\0" + "Hangul_J_NieunJieuj\0" + "Hangul_J_NieunHieuh\0" + "Hangul_J_Dikeud\0" + "Hangul_J_Rieul\0" + "Hangul_J_RieulKiyeog\0" + "Hangul_J_RieulMieum\0" + "Hangul_J_RieulPieub\0" + "Hangul_J_RieulSios\0" + "Hangul_J_RieulTieut\0" + "Hangul_J_RieulPhieuf\0" + "Hangul_J_RieulHieuh\0" + "Hangul_J_Mieum\0" + "Hangul_J_Pieub\0" + "Hangul_J_PieubSios\0" + "Hangul_J_Sios\0" + "Hangul_J_SsangSios\0" + "Hangul_J_Ieung\0" + "Hangul_J_Jieuj\0" + "Hangul_J_Cieuc\0" + "Hangul_J_Khieuq\0" + "Hangul_J_Tieut\0" + "Hangul_J_Phieuf\0" + "Hangul_J_Hieuh\0" + "Hangul_RieulYeorinHieuh\0" + "Hangul_SunkyeongeumMieum\0" + "Hangul_SunkyeongeumPieub\0" + "Hangul_PanSios\0" + "Hangul_KkogjiDalrinIeung\0" + "Hangul_SunkyeongeumPhieuf\0" + "Hangul_YeorinHieuh\0" + "Hangul_AraeA\0" + "Hangul_AraeAE\0" + "Hangul_J_PanSios\0" + "Hangul_J_KkogjiDalrinIeung\0" + "Hangul_J_YeorinHieuh\0" + "Korean_Won\0" + "OE\0" + "oe\0" + "Ydiaeresis\0" + "EcuSign\0" + "ColonSign\0" + "CruzeiroSign\0" + "FFrancSign\0" + "LiraSign\0" + "MillSign\0" + "NairaSign\0" + "PesetaSign\0" + "RupeeSign\0" + "WonSign\0" + "NewSheqelSign\0" + "DongSign\0" + "EuroSign\0" + "3270_Duplicate\0" + "3270_FieldMark\0" + "3270_Right2\0" + "3270_Left2\0" + "3270_BackTab\0" + "3270_EraseEOF\0" + "3270_EraseInput\0" + "3270_Reset\0" + "3270_Quit\0" + "3270_PA1\0" + "3270_PA2\0" + "3270_PA3\0" + "3270_Test\0" + "3270_Attn\0" + "3270_CursorBlink\0" + "3270_AltCursor\0" + "3270_KeyClick\0" + "3270_Jump\0" + "3270_Ident\0" + "3270_Rule\0" + "3270_Copy\0" + "3270_Play\0" + "3270_Setup\0" + "3270_Record\0" + "3270_ChangeScreen\0" + "3270_DeleteWord\0" + "3270_ExSelect\0" + "3270_CursorSelect\0" + "3270_PrintScreen\0" + "3270_Enter\0" + "ISO_Lock\0" + "ISO_Level2_Latch\0" + "ISO_Level3_Shift\0" + "ISO_Level3_Latch\0" + "ISO_Level3_Lock\0" + "ISO_Group_Latch\0" + "ISO_Group_Lock\0" + "ISO_Next_Group\0" + "ISO_Next_Group_Lock\0" + "ISO_Prev_Group\0" + "ISO_Prev_Group_Lock\0" + "ISO_First_Group\0" + "ISO_First_Group_Lock\0" + "ISO_Last_Group\0" + "ISO_Last_Group_Lock\0" + "ISO_Left_Tab\0" + "ISO_Move_Line_Up\0" + "ISO_Move_Line_Down\0" + "ISO_Partial_Line_Up\0" + "ISO_Partial_Line_Down\0" + "ISO_Partial_Space_Left\0" + "ISO_Partial_Space_Right\0" + "ISO_Set_Margin_Left\0" + "ISO_Set_Margin_Right\0" + "ISO_Release_Margin_Left\0" + "ISO_Release_Margin_Right\0" + "ISO_Release_Both_Margins\0" + "ISO_Fast_Cursor_Left\0" + "ISO_Fast_Cursor_Right\0" + "ISO_Fast_Cursor_Up\0" + "ISO_Fast_Cursor_Down\0" + "ISO_Continuous_Underline\0" + "ISO_Discontinuous_Underline\0" + "ISO_Emphasize\0" + "ISO_Center_Object\0" + "ISO_Enter\0" + "dead_grave\0" + "dead_acute\0" + "dead_circumflex\0" + "dead_tilde\0" + "dead_macron\0" + "dead_breve\0" + "dead_abovedot\0" + "dead_diaeresis\0" + "dead_abovering\0" + "dead_doubleacute\0" + "dead_caron\0" + "dead_cedilla\0" + "dead_ogonek\0" + "dead_iota\0" + "dead_voiced_sound\0" + "dead_semivoiced_sound\0" + "dead_belowdot\0" + "dead_hook\0" + "dead_horn\0" + "AccessX_Enable\0" + "AccessX_Feedback_Enable\0" + "RepeatKeys_Enable\0" + "SlowKeys_Enable\0" + "BounceKeys_Enable\0" + "StickyKeys_Enable\0" + "MouseKeys_Enable\0" + "MouseKeys_Accel_Enable\0" + "Overlay1_Enable\0" + "Overlay2_Enable\0" + "AudibleBell_Enable\0" + "First_Virtual_Screen\0" + "Prev_Virtual_Screen\0" + "Next_Virtual_Screen\0" + "Last_Virtual_Screen\0" + "Terminate_Server\0" + "Pointer_Left\0" + "Pointer_Right\0" + "Pointer_Up\0" + "Pointer_Down\0" + "Pointer_UpLeft\0" + "Pointer_UpRight\0" + "Pointer_DownLeft\0" + "Pointer_DownRight\0" + "Pointer_Button_Dflt\0" + "Pointer_Button1\0" + "Pointer_Button2\0" + "Pointer_Button3\0" + "Pointer_Button4\0" + "Pointer_Button5\0" + "Pointer_DblClick_Dflt\0" + "Pointer_DblClick1\0" + "Pointer_DblClick2\0" + "Pointer_DblClick3\0" + "Pointer_DblClick4\0" + "Pointer_DblClick5\0" + "Pointer_Drag_Dflt\0" + "Pointer_Drag1\0" + "Pointer_Drag2\0" + "Pointer_Drag3\0" + "Pointer_Drag4\0" + "Pointer_EnableKeys\0" + "Pointer_Accelerate\0" + "Pointer_DfltBtnNext\0" + "Pointer_DfltBtnPrev\0" + "Pointer_Drag5\0" + "BackSpace\0" + "Tab\0" + "Linefeed\0" + "Clear\0" + "Return\0" + "Pause\0" + "Scroll_Lock\0" + "Sys_Req\0" + "Escape\0" + "Multi_key\0" + "Kanji\0" + "Muhenkan\0" + "Henkan\0" + "Henkan_Mode\0" + "Romaji\0" + "Hiragana\0" + "Katakana\0" + "Hiragana_Katakana\0" + "Zenkaku\0" + "Hankaku\0" + "Zenkaku_Hankaku\0" + "Touroku\0" + "Massyo\0" + "Kana_Lock\0" + "Kana_Shift\0" + "Eisu_Shift\0" + "Eisu_toggle\0" + "Hangul\0" + "Hangul_Start\0" + "Hangul_End\0" + "Hangul_Hanja\0" + "Hangul_Jamo\0" + "Hangul_Romaja\0" + "Codeinput\0" + "Hangul_Jeonja\0" + "Hangul_Banja\0" + "Hangul_PreHanja\0" + "Hangul_PostHanja\0" + "SingleCandidate\0" + "MultipleCandidate\0" + "PreviousCandidate\0" + "Hangul_Special\0" + "Home\0" + "Left\0" + "Up\0" + "Right\0" + "Down\0" + "Page_Up\0" + "Prior\0" + "Page_Down\0" + "Next\0" + "End\0" + "Begin\0" + "Select\0" + "Print\0" + "Execute\0" + "Insert\0" + "Undo\0" + "Redo\0" + "Menu\0" + "Find\0" + "Cancel\0" + "Help\0" + "Break\0" + "Arabic_switch\0" + "Greek_switch\0" + "Hangul_switch\0" + "Hebrew_switch\0" + "ISO_Group_Shift\0" + "Mode_switch\0" + "kana_switch\0" + "script_switch\0" + "Num_Lock\0" + "KP_Space\0" + "KP_Tab\0" + "KP_Enter\0" + "KP_F1\0" + "KP_F2\0" + "KP_F3\0" + "KP_F4\0" + "KP_Home\0" + "KP_Left\0" + "KP_Up\0" + "KP_Right\0" + "KP_Down\0" + "KP_Page_Up\0" + "KP_Prior\0" + "KP_Page_Down\0" + "KP_Next\0" + "KP_End\0" + "KP_Begin\0" + "KP_Insert\0" + "KP_Delete\0" + "KP_Multiply\0" + "KP_Add\0" + "KP_Separator\0" + "KP_Subtract\0" + "KP_Decimal\0" + "KP_Divide\0" + "KP_0\0" + "KP_1\0" + "KP_2\0" + "KP_3\0" + "KP_4\0" + "KP_5\0" + "KP_6\0" + "KP_7\0" + "KP_8\0" + "KP_9\0" + "KP_Equal\0" + "F1\0" + "F2\0" + "F3\0" + "F4\0" + "F5\0" + "F6\0" + "F7\0" + "F8\0" + "F9\0" + "F10\0" + "F11\0" + "F12\0" + "F13\0" + "F14\0" + "F15\0" + "F16\0" + "F17\0" + "F18\0" + "F19\0" + "F20\0" + "F21\0" + "F22\0" + "F23\0" + "F24\0" + "F25\0" + "F26\0" + "F27\0" + "F28\0" + "F29\0" + "F30\0" + "F31\0" + "F32\0" + "F33\0" + "F34\0" + "F35\0" + "Shift_L\0" + "Shift_R\0" + "Control_L\0" + "Control_R\0" + "Caps_Lock\0" + "Shift_Lock\0" + "Meta_L\0" + "Meta_R\0" + "Alt_L\0" + "Alt_R\0" + "Super_L\0" + "Super_R\0" + "Hyper_L\0" + "Hyper_R\0" + "Delete\0" + "VoidSymbol\0"; typedef struct { int keyval; @@ -1343,2624 +1343,664 @@ typedef struct { } key_entry; static const key_entry keys_by_keyval[] = { - { 0x000020, 0 }, - { 0x000021, 6 }, - { 0x000022, 13 }, - { 0x000023, 22 }, - { 0x000024, 33 }, - { 0x000025, 40 }, - { 0x000026, 48 }, - { 0x000027, 58 }, - { 0x000027, 69 }, - { 0x000028, 80 }, - { 0x000029, 90 }, - { 0x00002a, 101 }, - { 0x00002b, 110 }, - { 0x00002c, 115 }, - { 0x00002d, 121 }, - { 0x00002e, 127 }, - { 0x00002f, 134 }, - { 0x000030, 140 }, - { 0x000031, 142 }, - { 0x000032, 144 }, - { 0x000033, 146 }, - { 0x000034, 148 }, - { 0x000035, 150 }, - { 0x000036, 152 }, - { 0x000037, 154 }, - { 0x000038, 156 }, - { 0x000039, 158 }, - { 0x00003a, 160 }, - { 0x00003b, 166 }, - { 0x00003c, 176 }, - { 0x00003d, 181 }, - { 0x00003e, 187 }, - { 0x00003f, 195 }, - { 0x000040, 204 }, - { 0x000041, 207 }, - { 0x000042, 209 }, - { 0x000043, 211 }, - { 0x000044, 213 }, - { 0x000045, 215 }, - { 0x000046, 217 }, - { 0x000047, 219 }, - { 0x000048, 221 }, - { 0x000049, 223 }, - { 0x00004a, 225 }, - { 0x00004b, 227 }, - { 0x00004c, 229 }, - { 0x00004d, 231 }, - { 0x00004e, 233 }, - { 0x00004f, 235 }, - { 0x000050, 237 }, - { 0x000051, 239 }, - { 0x000052, 241 }, - { 0x000053, 243 }, - { 0x000054, 245 }, - { 0x000055, 247 }, - { 0x000056, 249 }, - { 0x000057, 251 }, - { 0x000058, 253 }, - { 0x000059, 255 }, - { 0x00005a, 257 }, - { 0x00005b, 259 }, - { 0x00005c, 271 }, - { 0x00005d, 281 }, - { 0x00005e, 294 }, - { 0x00005f, 306 }, - { 0x000060, 317 }, - { 0x000060, 323 }, - { 0x000061, 333 }, - { 0x000062, 335 }, - { 0x000063, 337 }, - { 0x000064, 339 }, - { 0x000065, 341 }, - { 0x000066, 343 }, - { 0x000067, 345 }, - { 0x000068, 347 }, - { 0x000069, 349 }, - { 0x00006a, 351 }, - { 0x00006b, 353 }, - { 0x00006c, 355 }, - { 0x00006d, 357 }, - { 0x00006e, 359 }, - { 0x00006f, 361 }, - { 0x000070, 363 }, - { 0x000071, 365 }, - { 0x000072, 367 }, - { 0x000073, 369 }, - { 0x000074, 371 }, - { 0x000075, 373 }, - { 0x000076, 375 }, - { 0x000077, 377 }, - { 0x000078, 379 }, - { 0x000079, 381 }, - { 0x00007a, 383 }, - { 0x00007b, 385 }, - { 0x00007c, 395 }, - { 0x00007d, 399 }, - { 0x00007e, 410 }, - { 0x0000a0, 421 }, - { 0x0000a1, 434 }, - { 0x0000a2, 445 }, - { 0x0000a3, 450 }, - { 0x0000a4, 459 }, - { 0x0000a5, 468 }, - { 0x0000a6, 472 }, - { 0x0000a7, 482 }, - { 0x0000a8, 490 }, - { 0x0000a9, 500 }, - { 0x0000aa, 510 }, - { 0x0000ab, 522 }, - { 0x0000ac, 536 }, - { 0x0000ad, 544 }, - { 0x0000ae, 551 }, - { 0x0000af, 562 }, - { 0x0000b0, 569 }, - { 0x0000b1, 576 }, - { 0x0000b2, 586 }, - { 0x0000b3, 598 }, - { 0x0000b4, 612 }, - { 0x0000b5, 618 }, - { 0x0000b6, 621 }, - { 0x0000b7, 631 }, - { 0x0000b8, 646 }, - { 0x0000b9, 654 }, - { 0x0000ba, 666 }, - { 0x0000bb, 676 }, - { 0x0000bc, 691 }, - { 0x0000bd, 702 }, - { 0x0000be, 710 }, - { 0x0000bf, 724 }, - { 0x0000c0, 737 }, - { 0x0000c1, 744 }, - { 0x0000c2, 751 }, - { 0x0000c3, 763 }, - { 0x0000c4, 770 }, - { 0x0000c5, 781 }, - { 0x0000c6, 787 }, - { 0x0000c7, 790 }, - { 0x0000c8, 799 }, - { 0x0000c9, 806 }, - { 0x0000ca, 813 }, - { 0x0000cb, 825 }, - { 0x0000cc, 836 }, - { 0x0000cd, 843 }, - { 0x0000ce, 850 }, - { 0x0000cf, 862 }, - { 0x0000d0, 873 }, - { 0x0000d0, 877 }, - { 0x0000d1, 881 }, - { 0x0000d2, 888 }, - { 0x0000d3, 895 }, - { 0x0000d4, 902 }, - { 0x0000d5, 914 }, - { 0x0000d6, 921 }, - { 0x0000d7, 932 }, - { 0x0000d8, 941 }, - { 0x0000d9, 950 }, - { 0x0000da, 957 }, - { 0x0000db, 964 }, - { 0x0000dc, 976 }, - { 0x0000dd, 987 }, - { 0x0000de, 994 }, - { 0x0000de, 1000 }, - { 0x0000df, 1006 }, - { 0x0000e0, 1013 }, - { 0x0000e1, 1020 }, - { 0x0000e2, 1027 }, - { 0x0000e3, 1039 }, - { 0x0000e4, 1046 }, - { 0x0000e5, 1057 }, - { 0x0000e6, 1063 }, - { 0x0000e7, 1066 }, - { 0x0000e8, 1075 }, - { 0x0000e9, 1082 }, - { 0x0000ea, 1089 }, - { 0x0000eb, 1101 }, - { 0x0000ec, 1112 }, - { 0x0000ed, 1119 }, - { 0x0000ee, 1126 }, - { 0x0000ef, 1138 }, - { 0x0000f0, 1149 }, - { 0x0000f1, 1153 }, - { 0x0000f2, 1160 }, - { 0x0000f3, 1167 }, - { 0x0000f4, 1174 }, - { 0x0000f5, 1186 }, - { 0x0000f6, 1193 }, - { 0x0000f7, 1204 }, - { 0x0000f8, 1213 }, - { 0x0000f9, 1220 }, - { 0x0000fa, 1227 }, - { 0x0000fb, 1234 }, - { 0x0000fc, 1246 }, - { 0x0000fd, 1257 }, - { 0x0000fe, 1264 }, - { 0x0000ff, 1270 }, - { 0x0001a1, 1281 }, - { 0x0001a2, 1289 }, - { 0x0001a3, 1295 }, - { 0x0001a5, 1303 }, - { 0x0001a6, 1310 }, - { 0x0001a9, 1317 }, - { 0x0001aa, 1324 }, - { 0x0001ab, 1333 }, - { 0x0001ac, 1340 }, - { 0x0001ae, 1347 }, - { 0x0001af, 1354 }, - { 0x0001b1, 1364 }, - { 0x0001b2, 1372 }, - { 0x0001b3, 1379 }, - { 0x0001b5, 1387 }, - { 0x0001b6, 1394 }, - { 0x0001b7, 1401 }, - { 0x0001b9, 1407 }, - { 0x0001ba, 1414 }, - { 0x0001bb, 1423 }, - { 0x0001bc, 1430 }, - { 0x0001bd, 1437 }, - { 0x0001be, 1449 }, - { 0x0001bf, 1456 }, - { 0x0001c0, 1466 }, - { 0x0001c3, 1473 }, - { 0x0001c5, 1480 }, - { 0x0001c6, 1487 }, - { 0x0001c8, 1494 }, - { 0x0001ca, 1501 }, - { 0x0001cc, 1509 }, - { 0x0001cf, 1516 }, - { 0x0001d0, 1523 }, - { 0x0001d1, 1531 }, - { 0x0001d2, 1538 }, - { 0x0001d5, 1545 }, - { 0x0001d8, 1558 }, - { 0x0001d9, 1565 }, - { 0x0001db, 1571 }, - { 0x0001de, 1584 }, - { 0x0001e0, 1593 }, - { 0x0001e3, 1600 }, - { 0x0001e5, 1607 }, - { 0x0001e6, 1614 }, - { 0x0001e8, 1621 }, - { 0x0001ea, 1628 }, - { 0x0001ec, 1636 }, - { 0x0001ef, 1643 }, - { 0x0001f0, 1650 }, - { 0x0001f1, 1658 }, - { 0x0001f2, 1665 }, - { 0x0001f5, 1672 }, - { 0x0001f8, 1685 }, - { 0x0001f9, 1692 }, - { 0x0001fb, 1698 }, - { 0x0001fe, 1711 }, - { 0x0001ff, 1720 }, - { 0x0002a1, 1729 }, - { 0x0002a6, 1737 }, - { 0x0002a9, 1749 }, - { 0x0002ab, 1759 }, - { 0x0002ac, 1766 }, - { 0x0002b1, 1778 }, - { 0x0002b6, 1786 }, - { 0x0002b9, 1798 }, - { 0x0002bb, 1807 }, - { 0x0002bc, 1814 }, - { 0x0002c5, 1826 }, - { 0x0002c6, 1836 }, - { 0x0002d5, 1848 }, - { 0x0002d8, 1858 }, - { 0x0002dd, 1870 }, - { 0x0002de, 1877 }, - { 0x0002e5, 1889 }, - { 0x0002e6, 1899 }, - { 0x0002f5, 1911 }, - { 0x0002f8, 1921 }, - { 0x0002fd, 1933 }, - { 0x0002fe, 1940 }, - { 0x0003a2, 1952 }, - { 0x0003a2, 1958 }, - { 0x0003a3, 1962 }, - { 0x0003a5, 1971 }, - { 0x0003a6, 1978 }, - { 0x0003aa, 1987 }, - { 0x0003ab, 1995 }, - { 0x0003ac, 2004 }, - { 0x0003b3, 2011 }, - { 0x0003b5, 2020 }, - { 0x0003b6, 2027 }, - { 0x0003ba, 2036 }, - { 0x0003bb, 2044 }, - { 0x0003bc, 2053 }, - { 0x0003bd, 2060 }, - { 0x0003bf, 2064 }, - { 0x0003c0, 2068 }, - { 0x0003c7, 2076 }, - { 0x0003cc, 2084 }, - { 0x0003cf, 2094 }, - { 0x0003d1, 2102 }, - { 0x0003d2, 2111 }, - { 0x0003d3, 2119 }, - { 0x0003d9, 2128 }, - { 0x0003dd, 2136 }, - { 0x0003de, 2143 }, - { 0x0003e0, 2151 }, - { 0x0003e7, 2159 }, - { 0x0003ec, 2167 }, - { 0x0003ef, 2177 }, - { 0x0003f1, 2185 }, - { 0x0003f2, 2194 }, - { 0x0003f3, 2202 }, - { 0x0003f9, 2211 }, - { 0x0003fd, 2219 }, - { 0x0003fe, 2226 }, - { 0x00047e, 2234 }, - { 0x0004a1, 2243 }, - { 0x0004a2, 2257 }, - { 0x0004a3, 2277 }, - { 0x0004a4, 2297 }, - { 0x0004a5, 2308 }, - { 0x0004a5, 2325 }, - { 0x0004a6, 2340 }, - { 0x0004a7, 2348 }, - { 0x0004a8, 2355 }, - { 0x0004a9, 2362 }, - { 0x0004aa, 2369 }, - { 0x0004ab, 2376 }, - { 0x0004ac, 2383 }, - { 0x0004ad, 2391 }, - { 0x0004ae, 2399 }, - { 0x0004af, 2407 }, - { 0x0004af, 2416 }, - { 0x0004b0, 2424 }, - { 0x0004b1, 2439 }, - { 0x0004b2, 2446 }, - { 0x0004b3, 2453 }, - { 0x0004b4, 2460 }, - { 0x0004b5, 2467 }, - { 0x0004b6, 2474 }, - { 0x0004b7, 2482 }, - { 0x0004b8, 2490 }, - { 0x0004b9, 2498 }, - { 0x0004ba, 2506 }, - { 0x0004bb, 2514 }, - { 0x0004bc, 2522 }, - { 0x0004bd, 2531 }, - { 0x0004be, 2539 }, - { 0x0004bf, 2547 }, - { 0x0004c0, 2555 }, - { 0x0004c1, 2563 }, - { 0x0004c1, 2572 }, - { 0x0004c2, 2580 }, - { 0x0004c2, 2589 }, - { 0x0004c3, 2597 }, - { 0x0004c4, 2605 }, - { 0x0004c5, 2613 }, - { 0x0004c6, 2621 }, - { 0x0004c7, 2629 }, - { 0x0004c8, 2637 }, - { 0x0004c9, 2645 }, - { 0x0004ca, 2653 }, - { 0x0004cb, 2661 }, - { 0x0004cc, 2669 }, - { 0x0004cc, 2677 }, - { 0x0004cd, 2685 }, - { 0x0004ce, 2693 }, - { 0x0004cf, 2701 }, - { 0x0004d0, 2709 }, - { 0x0004d1, 2717 }, - { 0x0004d2, 2725 }, - { 0x0004d3, 2733 }, - { 0x0004d4, 2741 }, - { 0x0004d5, 2749 }, - { 0x0004d6, 2757 }, - { 0x0004d7, 2765 }, - { 0x0004d8, 2773 }, - { 0x0004d9, 2781 }, - { 0x0004da, 2789 }, - { 0x0004db, 2797 }, - { 0x0004dc, 2805 }, - { 0x0004dd, 2813 }, - { 0x0004de, 2820 }, - { 0x0004df, 2832 }, - { 0x0005ac, 2848 }, - { 0x0005bb, 2861 }, - { 0x0005bf, 2878 }, - { 0x0005c1, 2899 }, - { 0x0005c2, 2912 }, - { 0x0005c3, 2931 }, - { 0x0005c4, 2950 }, - { 0x0005c5, 2968 }, - { 0x0005c6, 2990 }, - { 0x0005c7, 3008 }, - { 0x0005c8, 3020 }, - { 0x0005c9, 3031 }, - { 0x0005ca, 3049 }, - { 0x0005cb, 3060 }, - { 0x0005cc, 3072 }, - { 0x0005cd, 3084 }, - { 0x0005ce, 3095 }, - { 0x0005cf, 3107 }, - { 0x0005d0, 3118 }, - { 0x0005d1, 3130 }, - { 0x0005d2, 3140 }, - { 0x0005d3, 3152 }, - { 0x0005d4, 3164 }, - { 0x0005d5, 3177 }, - { 0x0005d6, 3188 }, - { 0x0005d7, 3199 }, - { 0x0005d8, 3210 }, - { 0x0005d9, 3221 }, - { 0x0005da, 3232 }, - { 0x0005e0, 3245 }, - { 0x0005e1, 3260 }, - { 0x0005e2, 3271 }, - { 0x0005e3, 3282 }, - { 0x0005e4, 3293 }, - { 0x0005e5, 3304 }, - { 0x0005e6, 3316 }, - { 0x0005e7, 3328 }, - { 0x0005e7, 3338 }, - { 0x0005e8, 3349 }, - { 0x0005e9, 3360 }, - { 0x0005ea, 3379 }, - { 0x0005eb, 3390 }, - { 0x0005ec, 3406 }, - { 0x0005ed, 3422 }, - { 0x0005ee, 3438 }, - { 0x0005ef, 3451 }, - { 0x0005f0, 3464 }, - { 0x0005f1, 3477 }, - { 0x0005f2, 3491 }, - { 0x0006a1, 3504 }, - { 0x0006a2, 3516 }, - { 0x0006a3, 3530 }, - { 0x0006a4, 3542 }, - { 0x0006a4, 3555 }, - { 0x0006a5, 3567 }, - { 0x0006a6, 3581 }, - { 0x0006a6, 3593 }, - { 0x0006a7, 3604 }, - { 0x0006a7, 3617 }, - { 0x0006a8, 3629 }, - { 0x0006a8, 3641 }, - { 0x0006a9, 3652 }, - { 0x0006a9, 3665 }, - { 0x0006aa, 3677 }, - { 0x0006aa, 3690 }, - { 0x0006ab, 3702 }, - { 0x0006ac, 3715 }, - { 0x0006ae, 3729 }, - { 0x0006af, 3749 }, - { 0x0006af, 3763 }, - { 0x0006b0, 3775 }, - { 0x0006b1, 3786 }, - { 0x0006b2, 3798 }, - { 0x0006b3, 3812 }, - { 0x0006b4, 3824 }, - { 0x0006b4, 3837 }, - { 0x0006b5, 3849 }, - { 0x0006b6, 3863 }, - { 0x0006b6, 3875 }, - { 0x0006b7, 3886 }, - { 0x0006b7, 3899 }, - { 0x0006b8, 3911 }, - { 0x0006b8, 3923 }, - { 0x0006b9, 3934 }, - { 0x0006b9, 3947 }, - { 0x0006ba, 3959 }, - { 0x0006ba, 3972 }, - { 0x0006bb, 3984 }, - { 0x0006bc, 3997 }, - { 0x0006be, 4011 }, - { 0x0006bf, 4031 }, - { 0x0006bf, 4045 }, - { 0x0006c0, 4057 }, - { 0x0006c1, 4069 }, - { 0x0006c2, 4080 }, - { 0x0006c3, 4092 }, - { 0x0006c4, 4105 }, - { 0x0006c5, 4117 }, - { 0x0006c6, 4129 }, - { 0x0006c7, 4141 }, - { 0x0006c8, 4154 }, - { 0x0006c9, 4166 }, - { 0x0006ca, 4177 }, - { 0x0006cb, 4193 }, - { 0x0006cc, 4205 }, - { 0x0006cd, 4217 }, - { 0x0006ce, 4229 }, - { 0x0006cf, 4241 }, - { 0x0006d0, 4252 }, - { 0x0006d1, 4264 }, - { 0x0006d2, 4276 }, - { 0x0006d3, 4288 }, - { 0x0006d4, 4300 }, - { 0x0006d5, 4312 }, - { 0x0006d6, 4323 }, - { 0x0006d7, 4336 }, - { 0x0006d8, 4348 }, - { 0x0006d9, 4366 }, - { 0x0006da, 4380 }, - { 0x0006db, 4392 }, - { 0x0006dc, 4405 }, - { 0x0006dd, 4416 }, - { 0x0006de, 4431 }, - { 0x0006df, 4444 }, - { 0x0006e0, 4462 }, - { 0x0006e1, 4474 }, - { 0x0006e2, 4485 }, - { 0x0006e3, 4497 }, - { 0x0006e4, 4510 }, - { 0x0006e5, 4522 }, - { 0x0006e6, 4534 }, - { 0x0006e7, 4546 }, - { 0x0006e8, 4559 }, - { 0x0006e9, 4571 }, - { 0x0006ea, 4582 }, - { 0x0006eb, 4598 }, - { 0x0006ec, 4610 }, - { 0x0006ed, 4622 }, - { 0x0006ee, 4634 }, - { 0x0006ef, 4646 }, - { 0x0006f0, 4657 }, - { 0x0006f1, 4669 }, - { 0x0006f2, 4681 }, - { 0x0006f3, 4693 }, - { 0x0006f4, 4705 }, - { 0x0006f5, 4717 }, - { 0x0006f6, 4728 }, - { 0x0006f7, 4741 }, - { 0x0006f8, 4753 }, - { 0x0006f9, 4771 }, - { 0x0006fa, 4785 }, - { 0x0006fb, 4797 }, - { 0x0006fc, 4810 }, - { 0x0006fd, 4821 }, - { 0x0006fe, 4836 }, - { 0x0006ff, 4849 }, - { 0x0007a1, 4867 }, - { 0x0007a2, 4885 }, - { 0x0007a3, 4905 }, - { 0x0007a4, 4921 }, - { 0x0007a5, 4938 }, - { 0x0007a5, 4957 }, - { 0x0007a7, 4977 }, - { 0x0007a8, 4997 }, - { 0x0007a9, 5017 }, - { 0x0007ab, 5039 }, - { 0x0007ae, 5057 }, - { 0x0007af, 5078 }, - { 0x0007b1, 5093 }, - { 0x0007b2, 5111 }, - { 0x0007b3, 5131 }, - { 0x0007b4, 5147 }, - { 0x0007b5, 5164 }, - { 0x0007b6, 5183 }, - { 0x0007b7, 5208 }, - { 0x0007b8, 5228 }, - { 0x0007b9, 5248 }, - { 0x0007ba, 5270 }, - { 0x0007bb, 5298 }, - { 0x0007c1, 5316 }, - { 0x0007c2, 5328 }, - { 0x0007c3, 5339 }, - { 0x0007c4, 5351 }, - { 0x0007c5, 5363 }, - { 0x0007c6, 5377 }, - { 0x0007c7, 5388 }, - { 0x0007c8, 5398 }, - { 0x0007c9, 5410 }, - { 0x0007ca, 5421 }, - { 0x0007cb, 5433 }, - { 0x0007cb, 5446 }, - { 0x0007cc, 5458 }, - { 0x0007cd, 5467 }, - { 0x0007ce, 5476 }, - { 0x0007cf, 5485 }, - { 0x0007d0, 5499 }, - { 0x0007d1, 5508 }, - { 0x0007d2, 5518 }, - { 0x0007d4, 5530 }, - { 0x0007d5, 5540 }, - { 0x0007d6, 5554 }, - { 0x0007d7, 5564 }, - { 0x0007d8, 5574 }, - { 0x0007d9, 5584 }, - { 0x0007e1, 5596 }, - { 0x0007e2, 5608 }, - { 0x0007e3, 5619 }, - { 0x0007e4, 5631 }, - { 0x0007e5, 5643 }, - { 0x0007e6, 5657 }, - { 0x0007e7, 5668 }, - { 0x0007e8, 5678 }, - { 0x0007e9, 5690 }, - { 0x0007ea, 5701 }, - { 0x0007eb, 5713 }, - { 0x0007eb, 5726 }, - { 0x0007ec, 5738 }, - { 0x0007ed, 5747 }, - { 0x0007ee, 5756 }, - { 0x0007ef, 5765 }, - { 0x0007f0, 5779 }, - { 0x0007f1, 5788 }, - { 0x0007f2, 5798 }, - { 0x0007f3, 5810 }, - { 0x0007f4, 5832 }, - { 0x0007f5, 5842 }, - { 0x0007f6, 5856 }, - { 0x0007f7, 5866 }, - { 0x0007f8, 5876 }, - { 0x0007f9, 5886 }, - { 0x0008a1, 5898 }, - { 0x0008a2, 5910 }, - { 0x0008a3, 5925 }, - { 0x0008a4, 5940 }, - { 0x0008a5, 5952 }, - { 0x0008a6, 5964 }, - { 0x0008a7, 5978 }, - { 0x0008a8, 5995 }, - { 0x0008a9, 6012 }, - { 0x0008aa, 6030 }, - { 0x0008ab, 6048 }, - { 0x0008ac, 6062 }, - { 0x0008ad, 6076 }, - { 0x0008ae, 6091 }, - { 0x0008af, 6106 }, - { 0x0008b0, 6127 }, - { 0x0008b1, 6149 }, - { 0x0008b2, 6166 }, - { 0x0008b3, 6183 }, - { 0x0008b4, 6209 }, - { 0x0008b5, 6235 }, - { 0x0008b6, 6253 }, - { 0x0008b7, 6271 }, - { 0x0008bc, 6292 }, - { 0x0008bd, 6306 }, - { 0x0008be, 6315 }, - { 0x0008bf, 6332 }, - { 0x0008c0, 6341 }, - { 0x0008c1, 6351 }, - { 0x0008c2, 6361 }, - { 0x0008c5, 6370 }, - { 0x0008c8, 6376 }, - { 0x0008c9, 6388 }, - { 0x0008cd, 6401 }, - { 0x0008ce, 6410 }, - { 0x0008cf, 6418 }, - { 0x0008d6, 6428 }, - { 0x0008da, 6436 }, - { 0x0008db, 6447 }, - { 0x0008dc, 6456 }, - { 0x0008dd, 6469 }, - { 0x0008de, 6475 }, - { 0x0008df, 6486 }, - { 0x0008ef, 6496 }, - { 0x0008f6, 6514 }, - { 0x0008fb, 6523 }, - { 0x0008fc, 6533 }, - { 0x0008fd, 6541 }, - { 0x0008fe, 6552 }, - { 0x0009df, 6562 }, - { 0x0009e0, 6568 }, - { 0x0009e1, 6581 }, - { 0x0009e2, 6594 }, - { 0x0009e3, 6597 }, - { 0x0009e4, 6600 }, - { 0x0009e5, 6603 }, - { 0x0009e8, 6606 }, - { 0x0009e9, 6609 }, - { 0x0009ea, 6612 }, - { 0x0009eb, 6627 }, - { 0x0009ec, 6641 }, - { 0x0009ed, 6654 }, - { 0x0009ee, 6668 }, - { 0x0009ef, 6682 }, - { 0x0009f0, 6697 }, - { 0x0009f1, 6712 }, - { 0x0009f2, 6727 }, - { 0x0009f3, 6742 }, - { 0x0009f4, 6757 }, - { 0x0009f5, 6763 }, - { 0x0009f6, 6770 }, - { 0x0009f7, 6775 }, - { 0x0009f8, 6780 }, - { 0x000aa1, 6788 }, - { 0x000aa2, 6796 }, - { 0x000aa3, 6804 }, - { 0x000aa4, 6813 }, - { 0x000aa5, 6822 }, - { 0x000aa6, 6833 }, - { 0x000aa7, 6844 }, - { 0x000aa8, 6854 }, - { 0x000aa9, 6864 }, - { 0x000aaa, 6871 }, - { 0x000aac, 6878 }, - { 0x000aae, 6890 }, - { 0x000aaf, 6899 }, - { 0x000ab0, 6915 }, - { 0x000ab1, 6924 }, - { 0x000ab2, 6934 }, - { 0x000ab3, 6943 }, - { 0x000ab4, 6953 }, - { 0x000ab5, 6965 }, - { 0x000ab6, 6976 }, - { 0x000ab7, 6985 }, - { 0x000ab8, 6996 }, - { 0x000abb, 7003 }, - { 0x000abc, 7011 }, - { 0x000abd, 7028 }, - { 0x000abe, 7041 }, - { 0x000abf, 7059 }, - { 0x000ac3, 7066 }, - { 0x000ac4, 7076 }, - { 0x000ac5, 7089 }, - { 0x000ac6, 7101 }, - { 0x000ac9, 7114 }, - { 0x000aca, 7124 }, - { 0x000acb, 7138 }, - { 0x000acc, 7156 }, - { 0x000acd, 7173 }, - { 0x000ace, 7191 }, - { 0x000acf, 7204 }, - { 0x000ad0, 7220 }, - { 0x000ad1, 7240 }, - { 0x000ad2, 7261 }, - { 0x000ad3, 7281 }, - { 0x000ad4, 7302 }, - { 0x000ad6, 7315 }, - { 0x000ad7, 7323 }, - { 0x000ad9, 7331 }, - { 0x000ada, 7342 }, - { 0x000adb, 7351 }, - { 0x000adc, 7368 }, - { 0x000add, 7388 }, - { 0x000ade, 7409 }, - { 0x000adf, 7424 }, - { 0x000ae0, 7437 }, - { 0x000ae1, 7454 }, - { 0x000ae2, 7473 }, - { 0x000ae3, 7488 }, - { 0x000ae4, 7504 }, - { 0x000ae5, 7522 }, - { 0x000ae6, 7531 }, - { 0x000ae7, 7550 }, - { 0x000ae8, 7567 }, - { 0x000ae9, 7585 }, - { 0x000aea, 7605 }, - { 0x000aeb, 7617 }, - { 0x000aec, 7630 }, - { 0x000aed, 7635 }, - { 0x000aee, 7643 }, - { 0x000af0, 7649 }, - { 0x000af1, 7662 }, - { 0x000af2, 7669 }, - { 0x000af3, 7682 }, - { 0x000af4, 7692 }, - { 0x000af5, 7704 }, - { 0x000af6, 7717 }, - { 0x000af7, 7729 }, - { 0x000af8, 7740 }, - { 0x000af9, 7753 }, - { 0x000afa, 7763 }, - { 0x000afb, 7781 }, - { 0x000afc, 7801 }, - { 0x000afd, 7807 }, - { 0x000afe, 7826 }, - { 0x000aff, 7845 }, - { 0x000ba3, 7852 }, - { 0x000ba6, 7862 }, - { 0x000ba8, 7873 }, - { 0x000ba9, 7883 }, - { 0x000bc0, 7891 }, - { 0x000bc2, 7899 }, - { 0x000bc3, 7908 }, - { 0x000bc4, 7915 }, - { 0x000bc6, 7925 }, - { 0x000bca, 7934 }, - { 0x000bcc, 7938 }, - { 0x000bce, 7943 }, - { 0x000bcf, 7950 }, - { 0x000bd3, 7957 }, - { 0x000bd6, 7965 }, - { 0x000bd8, 7974 }, - { 0x000bda, 7984 }, - { 0x000bdc, 7993 }, - { 0x000bfc, 8002 }, - { 0x000cdf, 8012 }, - { 0x000ce0, 8033 }, - { 0x000ce1, 8046 }, - { 0x000ce1, 8057 }, - { 0x000ce2, 8069 }, - { 0x000ce2, 8082 }, - { 0x000ce3, 8096 }, - { 0x000ce3, 8109 }, - { 0x000ce4, 8123 }, - { 0x000ce5, 8133 }, - { 0x000ce6, 8144 }, - { 0x000ce6, 8156 }, - { 0x000ce7, 8169 }, - { 0x000ce7, 8181 }, - { 0x000ce8, 8192 }, - { 0x000ce8, 8203 }, - { 0x000ce9, 8215 }, - { 0x000cea, 8226 }, - { 0x000ceb, 8243 }, - { 0x000cec, 8255 }, - { 0x000ced, 8268 }, - { 0x000cee, 8284 }, - { 0x000cef, 8295 }, - { 0x000cf0, 8311 }, - { 0x000cf1, 8322 }, - { 0x000cf1, 8336 }, - { 0x000cf2, 8350 }, - { 0x000cf3, 8362 }, - { 0x000cf4, 8377 }, - { 0x000cf5, 8387 }, - { 0x000cf5, 8404 }, - { 0x000cf6, 8421 }, - { 0x000cf6, 8433 }, - { 0x000cf7, 8445 }, - { 0x000cf7, 8456 }, - { 0x000cf8, 8468 }, - { 0x000cf9, 8480 }, - { 0x000cfa, 8492 }, - { 0x000cfa, 8503 }, - { 0x000da1, 8514 }, - { 0x000da2, 8525 }, - { 0x000da3, 8538 }, - { 0x000da4, 8552 }, - { 0x000da5, 8566 }, - { 0x000da6, 8579 }, - { 0x000da7, 8595 }, - { 0x000da8, 8607 }, - { 0x000da9, 8620 }, - { 0x000daa, 8634 }, - { 0x000dab, 8648 }, - { 0x000dac, 8658 }, - { 0x000dad, 8671 }, - { 0x000dae, 8683 }, - { 0x000daf, 8696 }, - { 0x000db0, 8709 }, - { 0x000db1, 8722 }, - { 0x000db2, 8741 }, - { 0x000db3, 8757 }, - { 0x000db4, 8768 }, - { 0x000db5, 8779 }, - { 0x000db6, 8790 }, - { 0x000db7, 8804 }, - { 0x000db8, 8819 }, - { 0x000db9, 8833 }, - { 0x000dba, 8843 }, - { 0x000dbb, 8857 }, - { 0x000dbc, 8868 }, - { 0x000dbd, 8882 }, - { 0x000dbe, 8892 }, - { 0x000dbf, 8905 }, - { 0x000dc0, 8916 }, - { 0x000dc1, 8932 }, - { 0x000dc2, 8942 }, - { 0x000dc3, 8953 }, - { 0x000dc4, 8964 }, - { 0x000dc5, 8972 }, - { 0x000dc6, 8984 }, - { 0x000dc7, 8992 }, - { 0x000dc8, 9004 }, - { 0x000dc9, 9016 }, - { 0x000dca, 9028 }, - { 0x000dcb, 9039 }, - { 0x000dcc, 9050 }, - { 0x000dcd, 9063 }, - { 0x000dce, 9073 }, - { 0x000dcf, 9087 }, - { 0x000dd0, 9102 }, - { 0x000dd1, 9113 }, - { 0x000dd2, 9129 }, - { 0x000dd3, 9141 }, - { 0x000dd4, 9153 }, - { 0x000dd5, 9164 }, - { 0x000dd6, 9176 }, - { 0x000dd7, 9188 }, - { 0x000dd8, 9201 }, - { 0x000dd9, 9212 }, - { 0x000dda, 9224 }, - { 0x000dde, 9237 }, - { 0x000ddf, 9260 }, - { 0x000de0, 9270 }, - { 0x000de1, 9281 }, - { 0x000de2, 9293 }, - { 0x000de3, 9304 }, - { 0x000de4, 9323 }, - { 0x000de5, 9343 }, - { 0x000de6, 9360 }, - { 0x000de7, 9374 }, - { 0x000de8, 9389 }, - { 0x000de9, 9400 }, - { 0x000dea, 9412 }, - { 0x000deb, 9424 }, - { 0x000dec, 9441 }, - { 0x000ded, 9458 }, - { 0x000df0, 9472 }, - { 0x000df1, 9484 }, - { 0x000df2, 9497 }, - { 0x000df3, 9510 }, - { 0x000df4, 9522 }, - { 0x000df5, 9533 }, - { 0x000df6, 9544 }, - { 0x000df7, 9556 }, - { 0x000df8, 9569 }, - { 0x000df9, 9582 }, - { 0x000ea1, 9594 }, - { 0x000ea2, 9608 }, - { 0x000ea3, 9627 }, - { 0x000ea4, 9645 }, - { 0x000ea5, 9658 }, - { 0x000ea6, 9676 }, - { 0x000ea7, 9694 }, - { 0x000ea8, 9708 }, - { 0x000ea9, 9727 }, - { 0x000eaa, 9740 }, - { 0x000eab, 9759 }, - { 0x000eac, 9777 }, - { 0x000ead, 9795 }, - { 0x000eae, 9812 }, - { 0x000eaf, 9830 }, - { 0x000eb0, 9849 }, - { 0x000eb1, 9867 }, - { 0x000eb2, 9880 }, - { 0x000eb3, 9893 }, - { 0x000eb4, 9911 }, - { 0x000eb5, 9928 }, - { 0x000eb6, 9940 }, - { 0x000eb7, 9957 }, - { 0x000eb8, 9970 }, - { 0x000eb9, 9983 }, - { 0x000eba, 10001 }, - { 0x000ebb, 10014 }, - { 0x000ebc, 10028 }, - { 0x000ebd, 10041 }, - { 0x000ebe, 10055 }, - { 0x000ebf, 10068 }, - { 0x000ec0, 10077 }, - { 0x000ec1, 10087 }, - { 0x000ec2, 10097 }, - { 0x000ec3, 10108 }, - { 0x000ec4, 10118 }, - { 0x000ec5, 10127 }, - { 0x000ec6, 10138 }, - { 0x000ec7, 10148 }, - { 0x000ec8, 10157 }, - { 0x000ec9, 10167 }, - { 0x000eca, 10178 }, - { 0x000ecb, 10188 }, - { 0x000ecc, 10198 }, - { 0x000ecd, 10207 }, - { 0x000ece, 10218 }, - { 0x000ecf, 10228 }, - { 0x000ed0, 10238 }, - { 0x000ed1, 10248 }, - { 0x000ed2, 10258 }, - { 0x000ed3, 10268 }, - { 0x000ed4, 10277 }, - { 0x000ed5, 10293 }, - { 0x000ed6, 10314 }, - { 0x000ed7, 10334 }, - { 0x000ed8, 10349 }, - { 0x000ed9, 10369 }, - { 0x000eda, 10389 }, - { 0x000edb, 10405 }, - { 0x000edc, 10420 }, - { 0x000edd, 10441 }, - { 0x000ede, 10461 }, - { 0x000edf, 10481 }, - { 0x000ee0, 10500 }, - { 0x000ee1, 10520 }, - { 0x000ee2, 10541 }, - { 0x000ee3, 10561 }, - { 0x000ee4, 10576 }, - { 0x000ee5, 10591 }, - { 0x000ee6, 10610 }, - { 0x000ee7, 10624 }, - { 0x000ee8, 10643 }, - { 0x000ee9, 10658 }, - { 0x000eea, 10673 }, - { 0x000eeb, 10688 }, - { 0x000eec, 10704 }, - { 0x000eed, 10719 }, - { 0x000eee, 10735 }, - { 0x000eef, 10750 }, - { 0x000ef0, 10774 }, - { 0x000ef1, 10799 }, - { 0x000ef2, 10824 }, - { 0x000ef3, 10839 }, - { 0x000ef4, 10864 }, - { 0x000ef5, 10890 }, - { 0x000ef6, 10909 }, - { 0x000ef7, 10922 }, - { 0x000ef8, 10936 }, - { 0x000ef9, 10953 }, - { 0x000efa, 10980 }, - { 0x000eff, 11001 }, - { 0x0013bc, 11012 }, - { 0x0013bd, 11015 }, - { 0x0013be, 11018 }, - { 0x0020a0, 11029 }, - { 0x0020a1, 11037 }, - { 0x0020a2, 11047 }, - { 0x0020a3, 11060 }, - { 0x0020a4, 11071 }, - { 0x0020a5, 11080 }, - { 0x0020a6, 11089 }, - { 0x0020a7, 11099 }, - { 0x0020a8, 11110 }, - { 0x0020a9, 11120 }, - { 0x0020aa, 11128 }, - { 0x0020ab, 11142 }, - { 0x0020ac, 11151 }, - { 0x00fd01, 11160 }, - { 0x00fd02, 11175 }, - { 0x00fd03, 11190 }, - { 0x00fd04, 11202 }, - { 0x00fd05, 11213 }, - { 0x00fd06, 11226 }, - { 0x00fd07, 11240 }, - { 0x00fd08, 11256 }, - { 0x00fd09, 11267 }, - { 0x00fd0a, 11277 }, - { 0x00fd0b, 11286 }, - { 0x00fd0c, 11295 }, - { 0x00fd0d, 11304 }, - { 0x00fd0e, 11314 }, - { 0x00fd0f, 11324 }, - { 0x00fd10, 11341 }, - { 0x00fd11, 11356 }, - { 0x00fd12, 11370 }, - { 0x00fd13, 11380 }, - { 0x00fd14, 11391 }, - { 0x00fd15, 11401 }, - { 0x00fd16, 11411 }, - { 0x00fd17, 11421 }, - { 0x00fd18, 11432 }, - { 0x00fd19, 11444 }, - { 0x00fd1a, 11462 }, - { 0x00fd1b, 11478 }, - { 0x00fd1c, 11492 }, - { 0x00fd1d, 11510 }, - { 0x00fd1e, 11527 }, - { 0x00fe01, 11538 }, - { 0x00fe02, 11547 }, - { 0x00fe03, 11564 }, - { 0x00fe04, 11581 }, - { 0x00fe05, 11598 }, - { 0x00fe06, 11614 }, - { 0x00fe07, 11630 }, - { 0x00fe08, 11645 }, - { 0x00fe09, 11660 }, - { 0x00fe0a, 11680 }, - { 0x00fe0b, 11695 }, - { 0x00fe0c, 11715 }, - { 0x00fe0d, 11731 }, - { 0x00fe0e, 11752 }, - { 0x00fe0f, 11767 }, - { 0x00fe20, 11787 }, - { 0x00fe21, 11800 }, - { 0x00fe22, 11817 }, - { 0x00fe23, 11836 }, - { 0x00fe24, 11856 }, - { 0x00fe25, 11878 }, - { 0x00fe26, 11901 }, - { 0x00fe27, 11925 }, - { 0x00fe28, 11945 }, - { 0x00fe29, 11966 }, - { 0x00fe2a, 11990 }, - { 0x00fe2b, 12015 }, - { 0x00fe2c, 12040 }, - { 0x00fe2d, 12061 }, - { 0x00fe2e, 12083 }, - { 0x00fe2f, 12102 }, - { 0x00fe30, 12123 }, - { 0x00fe31, 12148 }, - { 0x00fe32, 12176 }, - { 0x00fe33, 12190 }, - { 0x00fe34, 12208 }, - { 0x00fe50, 12218 }, - { 0x00fe51, 12229 }, - { 0x00fe52, 12240 }, - { 0x00fe53, 12256 }, - { 0x00fe54, 12267 }, - { 0x00fe55, 12279 }, - { 0x00fe56, 12290 }, - { 0x00fe57, 12304 }, - { 0x00fe58, 12319 }, - { 0x00fe59, 12334 }, - { 0x00fe5a, 12351 }, - { 0x00fe5b, 12362 }, - { 0x00fe5c, 12375 }, - { 0x00fe5d, 12387 }, - { 0x00fe5e, 12397 }, - { 0x00fe5f, 12415 }, - { 0x00fe60, 12437 }, - { 0x00fe61, 12451 }, - { 0x00fe62, 12461 }, - { 0x00fe70, 12471 }, - { 0x00fe71, 12486 }, - { 0x00fe72, 12510 }, - { 0x00fe73, 12528 }, - { 0x00fe74, 12544 }, - { 0x00fe75, 12562 }, - { 0x00fe76, 12580 }, - { 0x00fe77, 12597 }, - { 0x00fe78, 12620 }, - { 0x00fe79, 12636 }, - { 0x00fe7a, 12652 }, - { 0x00fed0, 12671 }, - { 0x00fed1, 12692 }, - { 0x00fed2, 12712 }, - { 0x00fed4, 12732 }, - { 0x00fed5, 12752 }, - { 0x00fee0, 12769 }, - { 0x00fee1, 12782 }, - { 0x00fee2, 12796 }, - { 0x00fee3, 12807 }, - { 0x00fee4, 12820 }, - { 0x00fee5, 12835 }, - { 0x00fee6, 12851 }, - { 0x00fee7, 12868 }, - { 0x00fee8, 12886 }, - { 0x00fee9, 12906 }, - { 0x00feea, 12922 }, - { 0x00feeb, 12938 }, - { 0x00feec, 12954 }, - { 0x00feed, 12970 }, - { 0x00feee, 12986 }, - { 0x00feef, 13008 }, - { 0x00fef0, 13026 }, - { 0x00fef1, 13044 }, - { 0x00fef2, 13062 }, - { 0x00fef3, 13080 }, - { 0x00fef4, 13098 }, - { 0x00fef5, 13116 }, - { 0x00fef6, 13130 }, - { 0x00fef7, 13144 }, - { 0x00fef8, 13158 }, - { 0x00fef9, 13172 }, - { 0x00fefa, 13191 }, - { 0x00fefb, 13210 }, - { 0x00fefc, 13230 }, - { 0x00fefd, 13250 }, - { 0x00ff08, 13264 }, - { 0x00ff09, 13274 }, - { 0x00ff0a, 13278 }, - { 0x00ff0b, 13287 }, - { 0x00ff0d, 13293 }, - { 0x00ff13, 13300 }, - { 0x00ff14, 13306 }, - { 0x00ff15, 13318 }, - { 0x00ff1b, 13326 }, - { 0x00ff20, 13333 }, - { 0x00ff21, 13343 }, - { 0x00ff22, 13349 }, - { 0x00ff23, 13358 }, - { 0x00ff23, 13365 }, - { 0x00ff24, 13377 }, - { 0x00ff25, 13384 }, - { 0x00ff26, 13393 }, - { 0x00ff27, 13402 }, - { 0x00ff28, 13420 }, - { 0x00ff29, 13428 }, - { 0x00ff2a, 13436 }, - { 0x00ff2b, 13452 }, - { 0x00ff2c, 13460 }, - { 0x00ff2d, 13467 }, - { 0x00ff2e, 13477 }, - { 0x00ff2f, 13488 }, - { 0x00ff30, 13499 }, - { 0x00ff31, 13511 }, - { 0x00ff32, 13518 }, - { 0x00ff33, 13531 }, - { 0x00ff34, 13542 }, - { 0x00ff35, 13555 }, - { 0x00ff36, 13567 }, - { 0x00ff37, 13581 }, - { 0x00ff38, 13591 }, - { 0x00ff39, 13605 }, - { 0x00ff3a, 13618 }, - { 0x00ff3b, 13634 }, - { 0x00ff3c, 13651 }, - { 0x00ff3d, 13667 }, - { 0x00ff3e, 13685 }, - { 0x00ff3f, 13703 }, - { 0x00ff50, 13718 }, - { 0x00ff51, 13723 }, - { 0x00ff52, 13728 }, - { 0x00ff53, 13731 }, - { 0x00ff54, 13737 }, - { 0x00ff55, 13742 }, - { 0x00ff55, 13750 }, - { 0x00ff56, 13756 }, - { 0x00ff56, 13766 }, - { 0x00ff57, 13771 }, - { 0x00ff58, 13775 }, - { 0x00ff60, 13781 }, - { 0x00ff61, 13788 }, - { 0x00ff62, 13794 }, - { 0x00ff63, 13802 }, - { 0x00ff65, 13809 }, - { 0x00ff66, 13814 }, - { 0x00ff67, 13819 }, - { 0x00ff68, 13824 }, - { 0x00ff69, 13829 }, - { 0x00ff6a, 13836 }, - { 0x00ff6b, 13841 }, - { 0x00ff7e, 13847 }, - { 0x00ff7e, 13861 }, - { 0x00ff7e, 13874 }, - { 0x00ff7e, 13888 }, - { 0x00ff7e, 13902 }, - { 0x00ff7e, 13918 }, - { 0x00ff7e, 13930 }, - { 0x00ff7e, 13942 }, - { 0x00ff7f, 13956 }, - { 0x00ff80, 13965 }, - { 0x00ff89, 13974 }, - { 0x00ff8d, 13981 }, - { 0x00ff91, 13990 }, - { 0x00ff92, 13996 }, - { 0x00ff93, 14002 }, - { 0x00ff94, 14008 }, - { 0x00ff95, 14014 }, - { 0x00ff96, 14022 }, - { 0x00ff97, 14030 }, - { 0x00ff98, 14036 }, - { 0x00ff99, 14045 }, - { 0x00ff9a, 14053 }, - { 0x00ff9a, 14064 }, - { 0x00ff9b, 14073 }, - { 0x00ff9b, 14086 }, - { 0x00ff9c, 14094 }, - { 0x00ff9d, 14101 }, - { 0x00ff9e, 14110 }, - { 0x00ff9f, 14120 }, - { 0x00ffaa, 14130 }, - { 0x00ffab, 14142 }, - { 0x00ffac, 14149 }, - { 0x00ffad, 14162 }, - { 0x00ffae, 14174 }, - { 0x00ffaf, 14185 }, - { 0x00ffb0, 14195 }, - { 0x00ffb1, 14200 }, - { 0x00ffb2, 14205 }, - { 0x00ffb3, 14210 }, - { 0x00ffb4, 14215 }, - { 0x00ffb5, 14220 }, - { 0x00ffb6, 14225 }, - { 0x00ffb7, 14230 }, - { 0x00ffb8, 14235 }, - { 0x00ffb9, 14240 }, - { 0x00ffbd, 14245 }, - { 0x00ffbe, 14254 }, - { 0x00ffbf, 14257 }, - { 0x00ffc0, 14260 }, - { 0x00ffc1, 14263 }, - { 0x00ffc2, 14266 }, - { 0x00ffc3, 14269 }, - { 0x00ffc4, 14272 }, - { 0x00ffc5, 14275 }, - { 0x00ffc6, 14278 }, - { 0x00ffc7, 14281 }, - { 0x00ffc8, 14285 }, - { 0x00ffc9, 14289 }, - { 0x00ffca, 14293 }, - { 0x00ffcb, 14297 }, - { 0x00ffcc, 14301 }, - { 0x00ffcd, 14305 }, - { 0x00ffce, 14309 }, - { 0x00ffcf, 14313 }, - { 0x00ffd0, 14317 }, - { 0x00ffd1, 14321 }, - { 0x00ffd2, 14325 }, - { 0x00ffd3, 14329 }, - { 0x00ffd4, 14333 }, - { 0x00ffd5, 14337 }, - { 0x00ffd6, 14341 }, - { 0x00ffd7, 14345 }, - { 0x00ffd8, 14349 }, - { 0x00ffd9, 14353 }, - { 0x00ffda, 14357 }, - { 0x00ffdb, 14361 }, - { 0x00ffdc, 14365 }, - { 0x00ffdd, 14369 }, - { 0x00ffde, 14373 }, - { 0x00ffdf, 14377 }, - { 0x00ffe0, 14381 }, - { 0x00ffe1, 14385 }, - { 0x00ffe2, 14393 }, - { 0x00ffe3, 14401 }, - { 0x00ffe4, 14411 }, - { 0x00ffe5, 14421 }, - { 0x00ffe6, 14431 }, - { 0x00ffe7, 14442 }, - { 0x00ffe8, 14449 }, - { 0x00ffe9, 14456 }, - { 0x00ffea, 14462 }, - { 0x00ffeb, 14468 }, - { 0x00ffec, 14476 }, - { 0x00ffed, 14484 }, - { 0x00ffee, 14492 }, - { 0x00ffff, 14500 }, - { 0xffffff, 14507 } -}; + {0x000020, 0}, {0x000021, 6}, {0x000022, 13}, {0x000023, 22}, + {0x000024, 33}, {0x000025, 40}, {0x000026, 48}, {0x000027, 58}, + {0x000027, 69}, {0x000028, 80}, {0x000029, 90}, {0x00002a, 101}, + {0x00002b, 110}, {0x00002c, 115}, {0x00002d, 121}, {0x00002e, 127}, + {0x00002f, 134}, {0x000030, 140}, {0x000031, 142}, {0x000032, 144}, + {0x000033, 146}, {0x000034, 148}, {0x000035, 150}, {0x000036, 152}, + {0x000037, 154}, {0x000038, 156}, {0x000039, 158}, {0x00003a, 160}, + {0x00003b, 166}, {0x00003c, 176}, {0x00003d, 181}, {0x00003e, 187}, + {0x00003f, 195}, {0x000040, 204}, {0x000041, 207}, {0x000042, 209}, + {0x000043, 211}, {0x000044, 213}, {0x000045, 215}, {0x000046, 217}, + {0x000047, 219}, {0x000048, 221}, {0x000049, 223}, {0x00004a, 225}, + {0x00004b, 227}, {0x00004c, 229}, {0x00004d, 231}, {0x00004e, 233}, + {0x00004f, 235}, {0x000050, 237}, {0x000051, 239}, {0x000052, 241}, + {0x000053, 243}, {0x000054, 245}, {0x000055, 247}, {0x000056, 249}, + {0x000057, 251}, {0x000058, 253}, {0x000059, 255}, {0x00005a, 257}, + {0x00005b, 259}, {0x00005c, 271}, {0x00005d, 281}, {0x00005e, 294}, + {0x00005f, 306}, {0x000060, 317}, {0x000060, 323}, {0x000061, 333}, + {0x000062, 335}, {0x000063, 337}, {0x000064, 339}, {0x000065, 341}, + {0x000066, 343}, {0x000067, 345}, {0x000068, 347}, {0x000069, 349}, + {0x00006a, 351}, {0x00006b, 353}, {0x00006c, 355}, {0x00006d, 357}, + {0x00006e, 359}, {0x00006f, 361}, {0x000070, 363}, {0x000071, 365}, + {0x000072, 367}, {0x000073, 369}, {0x000074, 371}, {0x000075, 373}, + {0x000076, 375}, {0x000077, 377}, {0x000078, 379}, {0x000079, 381}, + {0x00007a, 383}, {0x00007b, 385}, {0x00007c, 395}, {0x00007d, 399}, + {0x00007e, 410}, {0x0000a0, 421}, {0x0000a1, 434}, {0x0000a2, 445}, + {0x0000a3, 450}, {0x0000a4, 459}, {0x0000a5, 468}, {0x0000a6, 472}, + {0x0000a7, 482}, {0x0000a8, 490}, {0x0000a9, 500}, {0x0000aa, 510}, + {0x0000ab, 522}, {0x0000ac, 536}, {0x0000ad, 544}, {0x0000ae, 551}, + {0x0000af, 562}, {0x0000b0, 569}, {0x0000b1, 576}, {0x0000b2, 586}, + {0x0000b3, 598}, {0x0000b4, 612}, {0x0000b5, 618}, {0x0000b6, 621}, + {0x0000b7, 631}, {0x0000b8, 646}, {0x0000b9, 654}, {0x0000ba, 666}, + {0x0000bb, 676}, {0x0000bc, 691}, {0x0000bd, 702}, {0x0000be, 710}, + {0x0000bf, 724}, {0x0000c0, 737}, {0x0000c1, 744}, {0x0000c2, 751}, + {0x0000c3, 763}, {0x0000c4, 770}, {0x0000c5, 781}, {0x0000c6, 787}, + {0x0000c7, 790}, {0x0000c8, 799}, {0x0000c9, 806}, {0x0000ca, 813}, + {0x0000cb, 825}, {0x0000cc, 836}, {0x0000cd, 843}, {0x0000ce, 850}, + {0x0000cf, 862}, {0x0000d0, 873}, {0x0000d0, 877}, {0x0000d1, 881}, + {0x0000d2, 888}, {0x0000d3, 895}, {0x0000d4, 902}, {0x0000d5, 914}, + {0x0000d6, 921}, {0x0000d7, 932}, {0x0000d8, 941}, {0x0000d9, 950}, + {0x0000da, 957}, {0x0000db, 964}, {0x0000dc, 976}, {0x0000dd, 987}, + {0x0000de, 994}, {0x0000de, 1000}, {0x0000df, 1006}, {0x0000e0, 1013}, + {0x0000e1, 1020}, {0x0000e2, 1027}, {0x0000e3, 1039}, {0x0000e4, 1046}, + {0x0000e5, 1057}, {0x0000e6, 1063}, {0x0000e7, 1066}, {0x0000e8, 1075}, + {0x0000e9, 1082}, {0x0000ea, 1089}, {0x0000eb, 1101}, {0x0000ec, 1112}, + {0x0000ed, 1119}, {0x0000ee, 1126}, {0x0000ef, 1138}, {0x0000f0, 1149}, + {0x0000f1, 1153}, {0x0000f2, 1160}, {0x0000f3, 1167}, {0x0000f4, 1174}, + {0x0000f5, 1186}, {0x0000f6, 1193}, {0x0000f7, 1204}, {0x0000f8, 1213}, + {0x0000f9, 1220}, {0x0000fa, 1227}, {0x0000fb, 1234}, {0x0000fc, 1246}, + {0x0000fd, 1257}, {0x0000fe, 1264}, {0x0000ff, 1270}, {0x0001a1, 1281}, + {0x0001a2, 1289}, {0x0001a3, 1295}, {0x0001a5, 1303}, {0x0001a6, 1310}, + {0x0001a9, 1317}, {0x0001aa, 1324}, {0x0001ab, 1333}, {0x0001ac, 1340}, + {0x0001ae, 1347}, {0x0001af, 1354}, {0x0001b1, 1364}, {0x0001b2, 1372}, + {0x0001b3, 1379}, {0x0001b5, 1387}, {0x0001b6, 1394}, {0x0001b7, 1401}, + {0x0001b9, 1407}, {0x0001ba, 1414}, {0x0001bb, 1423}, {0x0001bc, 1430}, + {0x0001bd, 1437}, {0x0001be, 1449}, {0x0001bf, 1456}, {0x0001c0, 1466}, + {0x0001c3, 1473}, {0x0001c5, 1480}, {0x0001c6, 1487}, {0x0001c8, 1494}, + {0x0001ca, 1501}, {0x0001cc, 1509}, {0x0001cf, 1516}, {0x0001d0, 1523}, + {0x0001d1, 1531}, {0x0001d2, 1538}, {0x0001d5, 1545}, {0x0001d8, 1558}, + {0x0001d9, 1565}, {0x0001db, 1571}, {0x0001de, 1584}, {0x0001e0, 1593}, + {0x0001e3, 1600}, {0x0001e5, 1607}, {0x0001e6, 1614}, {0x0001e8, 1621}, + {0x0001ea, 1628}, {0x0001ec, 1636}, {0x0001ef, 1643}, {0x0001f0, 1650}, + {0x0001f1, 1658}, {0x0001f2, 1665}, {0x0001f5, 1672}, {0x0001f8, 1685}, + {0x0001f9, 1692}, {0x0001fb, 1698}, {0x0001fe, 1711}, {0x0001ff, 1720}, + {0x0002a1, 1729}, {0x0002a6, 1737}, {0x0002a9, 1749}, {0x0002ab, 1759}, + {0x0002ac, 1766}, {0x0002b1, 1778}, {0x0002b6, 1786}, {0x0002b9, 1798}, + {0x0002bb, 1807}, {0x0002bc, 1814}, {0x0002c5, 1826}, {0x0002c6, 1836}, + {0x0002d5, 1848}, {0x0002d8, 1858}, {0x0002dd, 1870}, {0x0002de, 1877}, + {0x0002e5, 1889}, {0x0002e6, 1899}, {0x0002f5, 1911}, {0x0002f8, 1921}, + {0x0002fd, 1933}, {0x0002fe, 1940}, {0x0003a2, 1952}, {0x0003a2, 1958}, + {0x0003a3, 1962}, {0x0003a5, 1971}, {0x0003a6, 1978}, {0x0003aa, 1987}, + {0x0003ab, 1995}, {0x0003ac, 2004}, {0x0003b3, 2011}, {0x0003b5, 2020}, + {0x0003b6, 2027}, {0x0003ba, 2036}, {0x0003bb, 2044}, {0x0003bc, 2053}, + {0x0003bd, 2060}, {0x0003bf, 2064}, {0x0003c0, 2068}, {0x0003c7, 2076}, + {0x0003cc, 2084}, {0x0003cf, 2094}, {0x0003d1, 2102}, {0x0003d2, 2111}, + {0x0003d3, 2119}, {0x0003d9, 2128}, {0x0003dd, 2136}, {0x0003de, 2143}, + {0x0003e0, 2151}, {0x0003e7, 2159}, {0x0003ec, 2167}, {0x0003ef, 2177}, + {0x0003f1, 2185}, {0x0003f2, 2194}, {0x0003f3, 2202}, {0x0003f9, 2211}, + {0x0003fd, 2219}, {0x0003fe, 2226}, {0x00047e, 2234}, {0x0004a1, 2243}, + {0x0004a2, 2257}, {0x0004a3, 2277}, {0x0004a4, 2297}, {0x0004a5, 2308}, + {0x0004a5, 2325}, {0x0004a6, 2340}, {0x0004a7, 2348}, {0x0004a8, 2355}, + {0x0004a9, 2362}, {0x0004aa, 2369}, {0x0004ab, 2376}, {0x0004ac, 2383}, + {0x0004ad, 2391}, {0x0004ae, 2399}, {0x0004af, 2407}, {0x0004af, 2416}, + {0x0004b0, 2424}, {0x0004b1, 2439}, {0x0004b2, 2446}, {0x0004b3, 2453}, + {0x0004b4, 2460}, {0x0004b5, 2467}, {0x0004b6, 2474}, {0x0004b7, 2482}, + {0x0004b8, 2490}, {0x0004b9, 2498}, {0x0004ba, 2506}, {0x0004bb, 2514}, + {0x0004bc, 2522}, {0x0004bd, 2531}, {0x0004be, 2539}, {0x0004bf, 2547}, + {0x0004c0, 2555}, {0x0004c1, 2563}, {0x0004c1, 2572}, {0x0004c2, 2580}, + {0x0004c2, 2589}, {0x0004c3, 2597}, {0x0004c4, 2605}, {0x0004c5, 2613}, + {0x0004c6, 2621}, {0x0004c7, 2629}, {0x0004c8, 2637}, {0x0004c9, 2645}, + {0x0004ca, 2653}, {0x0004cb, 2661}, {0x0004cc, 2669}, {0x0004cc, 2677}, + {0x0004cd, 2685}, {0x0004ce, 2693}, {0x0004cf, 2701}, {0x0004d0, 2709}, + {0x0004d1, 2717}, {0x0004d2, 2725}, {0x0004d3, 2733}, {0x0004d4, 2741}, + {0x0004d5, 2749}, {0x0004d6, 2757}, {0x0004d7, 2765}, {0x0004d8, 2773}, + {0x0004d9, 2781}, {0x0004da, 2789}, {0x0004db, 2797}, {0x0004dc, 2805}, + {0x0004dd, 2813}, {0x0004de, 2820}, {0x0004df, 2832}, {0x0005ac, 2848}, + {0x0005bb, 2861}, {0x0005bf, 2878}, {0x0005c1, 2899}, {0x0005c2, 2912}, + {0x0005c3, 2931}, {0x0005c4, 2950}, {0x0005c5, 2968}, {0x0005c6, 2990}, + {0x0005c7, 3008}, {0x0005c8, 3020}, {0x0005c9, 3031}, {0x0005ca, 3049}, + {0x0005cb, 3060}, {0x0005cc, 3072}, {0x0005cd, 3084}, {0x0005ce, 3095}, + {0x0005cf, 3107}, {0x0005d0, 3118}, {0x0005d1, 3130}, {0x0005d2, 3140}, + {0x0005d3, 3152}, {0x0005d4, 3164}, {0x0005d5, 3177}, {0x0005d6, 3188}, + {0x0005d7, 3199}, {0x0005d8, 3210}, {0x0005d9, 3221}, {0x0005da, 3232}, + {0x0005e0, 3245}, {0x0005e1, 3260}, {0x0005e2, 3271}, {0x0005e3, 3282}, + {0x0005e4, 3293}, {0x0005e5, 3304}, {0x0005e6, 3316}, {0x0005e7, 3328}, + {0x0005e7, 3338}, {0x0005e8, 3349}, {0x0005e9, 3360}, {0x0005ea, 3379}, + {0x0005eb, 3390}, {0x0005ec, 3406}, {0x0005ed, 3422}, {0x0005ee, 3438}, + {0x0005ef, 3451}, {0x0005f0, 3464}, {0x0005f1, 3477}, {0x0005f2, 3491}, + {0x0006a1, 3504}, {0x0006a2, 3516}, {0x0006a3, 3530}, {0x0006a4, 3542}, + {0x0006a4, 3555}, {0x0006a5, 3567}, {0x0006a6, 3581}, {0x0006a6, 3593}, + {0x0006a7, 3604}, {0x0006a7, 3617}, {0x0006a8, 3629}, {0x0006a8, 3641}, + {0x0006a9, 3652}, {0x0006a9, 3665}, {0x0006aa, 3677}, {0x0006aa, 3690}, + {0x0006ab, 3702}, {0x0006ac, 3715}, {0x0006ae, 3729}, {0x0006af, 3749}, + {0x0006af, 3763}, {0x0006b0, 3775}, {0x0006b1, 3786}, {0x0006b2, 3798}, + {0x0006b3, 3812}, {0x0006b4, 3824}, {0x0006b4, 3837}, {0x0006b5, 3849}, + {0x0006b6, 3863}, {0x0006b6, 3875}, {0x0006b7, 3886}, {0x0006b7, 3899}, + {0x0006b8, 3911}, {0x0006b8, 3923}, {0x0006b9, 3934}, {0x0006b9, 3947}, + {0x0006ba, 3959}, {0x0006ba, 3972}, {0x0006bb, 3984}, {0x0006bc, 3997}, + {0x0006be, 4011}, {0x0006bf, 4031}, {0x0006bf, 4045}, {0x0006c0, 4057}, + {0x0006c1, 4069}, {0x0006c2, 4080}, {0x0006c3, 4092}, {0x0006c4, 4105}, + {0x0006c5, 4117}, {0x0006c6, 4129}, {0x0006c7, 4141}, {0x0006c8, 4154}, + {0x0006c9, 4166}, {0x0006ca, 4177}, {0x0006cb, 4193}, {0x0006cc, 4205}, + {0x0006cd, 4217}, {0x0006ce, 4229}, {0x0006cf, 4241}, {0x0006d0, 4252}, + {0x0006d1, 4264}, {0x0006d2, 4276}, {0x0006d3, 4288}, {0x0006d4, 4300}, + {0x0006d5, 4312}, {0x0006d6, 4323}, {0x0006d7, 4336}, {0x0006d8, 4348}, + {0x0006d9, 4366}, {0x0006da, 4380}, {0x0006db, 4392}, {0x0006dc, 4405}, + {0x0006dd, 4416}, {0x0006de, 4431}, {0x0006df, 4444}, {0x0006e0, 4462}, + {0x0006e1, 4474}, {0x0006e2, 4485}, {0x0006e3, 4497}, {0x0006e4, 4510}, + {0x0006e5, 4522}, {0x0006e6, 4534}, {0x0006e7, 4546}, {0x0006e8, 4559}, + {0x0006e9, 4571}, {0x0006ea, 4582}, {0x0006eb, 4598}, {0x0006ec, 4610}, + {0x0006ed, 4622}, {0x0006ee, 4634}, {0x0006ef, 4646}, {0x0006f0, 4657}, + {0x0006f1, 4669}, {0x0006f2, 4681}, {0x0006f3, 4693}, {0x0006f4, 4705}, + {0x0006f5, 4717}, {0x0006f6, 4728}, {0x0006f7, 4741}, {0x0006f8, 4753}, + {0x0006f9, 4771}, {0x0006fa, 4785}, {0x0006fb, 4797}, {0x0006fc, 4810}, + {0x0006fd, 4821}, {0x0006fe, 4836}, {0x0006ff, 4849}, {0x0007a1, 4867}, + {0x0007a2, 4885}, {0x0007a3, 4905}, {0x0007a4, 4921}, {0x0007a5, 4938}, + {0x0007a5, 4957}, {0x0007a7, 4977}, {0x0007a8, 4997}, {0x0007a9, 5017}, + {0x0007ab, 5039}, {0x0007ae, 5057}, {0x0007af, 5078}, {0x0007b1, 5093}, + {0x0007b2, 5111}, {0x0007b3, 5131}, {0x0007b4, 5147}, {0x0007b5, 5164}, + {0x0007b6, 5183}, {0x0007b7, 5208}, {0x0007b8, 5228}, {0x0007b9, 5248}, + {0x0007ba, 5270}, {0x0007bb, 5298}, {0x0007c1, 5316}, {0x0007c2, 5328}, + {0x0007c3, 5339}, {0x0007c4, 5351}, {0x0007c5, 5363}, {0x0007c6, 5377}, + {0x0007c7, 5388}, {0x0007c8, 5398}, {0x0007c9, 5410}, {0x0007ca, 5421}, + {0x0007cb, 5433}, {0x0007cb, 5446}, {0x0007cc, 5458}, {0x0007cd, 5467}, + {0x0007ce, 5476}, {0x0007cf, 5485}, {0x0007d0, 5499}, {0x0007d1, 5508}, + {0x0007d2, 5518}, {0x0007d4, 5530}, {0x0007d5, 5540}, {0x0007d6, 5554}, + {0x0007d7, 5564}, {0x0007d8, 5574}, {0x0007d9, 5584}, {0x0007e1, 5596}, + {0x0007e2, 5608}, {0x0007e3, 5619}, {0x0007e4, 5631}, {0x0007e5, 5643}, + {0x0007e6, 5657}, {0x0007e7, 5668}, {0x0007e8, 5678}, {0x0007e9, 5690}, + {0x0007ea, 5701}, {0x0007eb, 5713}, {0x0007eb, 5726}, {0x0007ec, 5738}, + {0x0007ed, 5747}, {0x0007ee, 5756}, {0x0007ef, 5765}, {0x0007f0, 5779}, + {0x0007f1, 5788}, {0x0007f2, 5798}, {0x0007f3, 5810}, {0x0007f4, 5832}, + {0x0007f5, 5842}, {0x0007f6, 5856}, {0x0007f7, 5866}, {0x0007f8, 5876}, + {0x0007f9, 5886}, {0x0008a1, 5898}, {0x0008a2, 5910}, {0x0008a3, 5925}, + {0x0008a4, 5940}, {0x0008a5, 5952}, {0x0008a6, 5964}, {0x0008a7, 5978}, + {0x0008a8, 5995}, {0x0008a9, 6012}, {0x0008aa, 6030}, {0x0008ab, 6048}, + {0x0008ac, 6062}, {0x0008ad, 6076}, {0x0008ae, 6091}, {0x0008af, 6106}, + {0x0008b0, 6127}, {0x0008b1, 6149}, {0x0008b2, 6166}, {0x0008b3, 6183}, + {0x0008b4, 6209}, {0x0008b5, 6235}, {0x0008b6, 6253}, {0x0008b7, 6271}, + {0x0008bc, 6292}, {0x0008bd, 6306}, {0x0008be, 6315}, {0x0008bf, 6332}, + {0x0008c0, 6341}, {0x0008c1, 6351}, {0x0008c2, 6361}, {0x0008c5, 6370}, + {0x0008c8, 6376}, {0x0008c9, 6388}, {0x0008cd, 6401}, {0x0008ce, 6410}, + {0x0008cf, 6418}, {0x0008d6, 6428}, {0x0008da, 6436}, {0x0008db, 6447}, + {0x0008dc, 6456}, {0x0008dd, 6469}, {0x0008de, 6475}, {0x0008df, 6486}, + {0x0008ef, 6496}, {0x0008f6, 6514}, {0x0008fb, 6523}, {0x0008fc, 6533}, + {0x0008fd, 6541}, {0x0008fe, 6552}, {0x0009df, 6562}, {0x0009e0, 6568}, + {0x0009e1, 6581}, {0x0009e2, 6594}, {0x0009e3, 6597}, {0x0009e4, 6600}, + {0x0009e5, 6603}, {0x0009e8, 6606}, {0x0009e9, 6609}, {0x0009ea, 6612}, + {0x0009eb, 6627}, {0x0009ec, 6641}, {0x0009ed, 6654}, {0x0009ee, 6668}, + {0x0009ef, 6682}, {0x0009f0, 6697}, {0x0009f1, 6712}, {0x0009f2, 6727}, + {0x0009f3, 6742}, {0x0009f4, 6757}, {0x0009f5, 6763}, {0x0009f6, 6770}, + {0x0009f7, 6775}, {0x0009f8, 6780}, {0x000aa1, 6788}, {0x000aa2, 6796}, + {0x000aa3, 6804}, {0x000aa4, 6813}, {0x000aa5, 6822}, {0x000aa6, 6833}, + {0x000aa7, 6844}, {0x000aa8, 6854}, {0x000aa9, 6864}, {0x000aaa, 6871}, + {0x000aac, 6878}, {0x000aae, 6890}, {0x000aaf, 6899}, {0x000ab0, 6915}, + {0x000ab1, 6924}, {0x000ab2, 6934}, {0x000ab3, 6943}, {0x000ab4, 6953}, + {0x000ab5, 6965}, {0x000ab6, 6976}, {0x000ab7, 6985}, {0x000ab8, 6996}, + {0x000abb, 7003}, {0x000abc, 7011}, {0x000abd, 7028}, {0x000abe, 7041}, + {0x000abf, 7059}, {0x000ac3, 7066}, {0x000ac4, 7076}, {0x000ac5, 7089}, + {0x000ac6, 7101}, {0x000ac9, 7114}, {0x000aca, 7124}, {0x000acb, 7138}, + {0x000acc, 7156}, {0x000acd, 7173}, {0x000ace, 7191}, {0x000acf, 7204}, + {0x000ad0, 7220}, {0x000ad1, 7240}, {0x000ad2, 7261}, {0x000ad3, 7281}, + {0x000ad4, 7302}, {0x000ad6, 7315}, {0x000ad7, 7323}, {0x000ad9, 7331}, + {0x000ada, 7342}, {0x000adb, 7351}, {0x000adc, 7368}, {0x000add, 7388}, + {0x000ade, 7409}, {0x000adf, 7424}, {0x000ae0, 7437}, {0x000ae1, 7454}, + {0x000ae2, 7473}, {0x000ae3, 7488}, {0x000ae4, 7504}, {0x000ae5, 7522}, + {0x000ae6, 7531}, {0x000ae7, 7550}, {0x000ae8, 7567}, {0x000ae9, 7585}, + {0x000aea, 7605}, {0x000aeb, 7617}, {0x000aec, 7630}, {0x000aed, 7635}, + {0x000aee, 7643}, {0x000af0, 7649}, {0x000af1, 7662}, {0x000af2, 7669}, + {0x000af3, 7682}, {0x000af4, 7692}, {0x000af5, 7704}, {0x000af6, 7717}, + {0x000af7, 7729}, {0x000af8, 7740}, {0x000af9, 7753}, {0x000afa, 7763}, + {0x000afb, 7781}, {0x000afc, 7801}, {0x000afd, 7807}, {0x000afe, 7826}, + {0x000aff, 7845}, {0x000ba3, 7852}, {0x000ba6, 7862}, {0x000ba8, 7873}, + {0x000ba9, 7883}, {0x000bc0, 7891}, {0x000bc2, 7899}, {0x000bc3, 7908}, + {0x000bc4, 7915}, {0x000bc6, 7925}, {0x000bca, 7934}, {0x000bcc, 7938}, + {0x000bce, 7943}, {0x000bcf, 7950}, {0x000bd3, 7957}, {0x000bd6, 7965}, + {0x000bd8, 7974}, {0x000bda, 7984}, {0x000bdc, 7993}, {0x000bfc, 8002}, + {0x000cdf, 8012}, {0x000ce0, 8033}, {0x000ce1, 8046}, {0x000ce1, 8057}, + {0x000ce2, 8069}, {0x000ce2, 8082}, {0x000ce3, 8096}, {0x000ce3, 8109}, + {0x000ce4, 8123}, {0x000ce5, 8133}, {0x000ce6, 8144}, {0x000ce6, 8156}, + {0x000ce7, 8169}, {0x000ce7, 8181}, {0x000ce8, 8192}, {0x000ce8, 8203}, + {0x000ce9, 8215}, {0x000cea, 8226}, {0x000ceb, 8243}, {0x000cec, 8255}, + {0x000ced, 8268}, {0x000cee, 8284}, {0x000cef, 8295}, {0x000cf0, 8311}, + {0x000cf1, 8322}, {0x000cf1, 8336}, {0x000cf2, 8350}, {0x000cf3, 8362}, + {0x000cf4, 8377}, {0x000cf5, 8387}, {0x000cf5, 8404}, {0x000cf6, 8421}, + {0x000cf6, 8433}, {0x000cf7, 8445}, {0x000cf7, 8456}, {0x000cf8, 8468}, + {0x000cf9, 8480}, {0x000cfa, 8492}, {0x000cfa, 8503}, {0x000da1, 8514}, + {0x000da2, 8525}, {0x000da3, 8538}, {0x000da4, 8552}, {0x000da5, 8566}, + {0x000da6, 8579}, {0x000da7, 8595}, {0x000da8, 8607}, {0x000da9, 8620}, + {0x000daa, 8634}, {0x000dab, 8648}, {0x000dac, 8658}, {0x000dad, 8671}, + {0x000dae, 8683}, {0x000daf, 8696}, {0x000db0, 8709}, {0x000db1, 8722}, + {0x000db2, 8741}, {0x000db3, 8757}, {0x000db4, 8768}, {0x000db5, 8779}, + {0x000db6, 8790}, {0x000db7, 8804}, {0x000db8, 8819}, {0x000db9, 8833}, + {0x000dba, 8843}, {0x000dbb, 8857}, {0x000dbc, 8868}, {0x000dbd, 8882}, + {0x000dbe, 8892}, {0x000dbf, 8905}, {0x000dc0, 8916}, {0x000dc1, 8932}, + {0x000dc2, 8942}, {0x000dc3, 8953}, {0x000dc4, 8964}, {0x000dc5, 8972}, + {0x000dc6, 8984}, {0x000dc7, 8992}, {0x000dc8, 9004}, {0x000dc9, 9016}, + {0x000dca, 9028}, {0x000dcb, 9039}, {0x000dcc, 9050}, {0x000dcd, 9063}, + {0x000dce, 9073}, {0x000dcf, 9087}, {0x000dd0, 9102}, {0x000dd1, 9113}, + {0x000dd2, 9129}, {0x000dd3, 9141}, {0x000dd4, 9153}, {0x000dd5, 9164}, + {0x000dd6, 9176}, {0x000dd7, 9188}, {0x000dd8, 9201}, {0x000dd9, 9212}, + {0x000dda, 9224}, {0x000dde, 9237}, {0x000ddf, 9260}, {0x000de0, 9270}, + {0x000de1, 9281}, {0x000de2, 9293}, {0x000de3, 9304}, {0x000de4, 9323}, + {0x000de5, 9343}, {0x000de6, 9360}, {0x000de7, 9374}, {0x000de8, 9389}, + {0x000de9, 9400}, {0x000dea, 9412}, {0x000deb, 9424}, {0x000dec, 9441}, + {0x000ded, 9458}, {0x000df0, 9472}, {0x000df1, 9484}, {0x000df2, 9497}, + {0x000df3, 9510}, {0x000df4, 9522}, {0x000df5, 9533}, {0x000df6, 9544}, + {0x000df7, 9556}, {0x000df8, 9569}, {0x000df9, 9582}, {0x000ea1, 9594}, + {0x000ea2, 9608}, {0x000ea3, 9627}, {0x000ea4, 9645}, {0x000ea5, 9658}, + {0x000ea6, 9676}, {0x000ea7, 9694}, {0x000ea8, 9708}, {0x000ea9, 9727}, + {0x000eaa, 9740}, {0x000eab, 9759}, {0x000eac, 9777}, {0x000ead, 9795}, + {0x000eae, 9812}, {0x000eaf, 9830}, {0x000eb0, 9849}, {0x000eb1, 9867}, + {0x000eb2, 9880}, {0x000eb3, 9893}, {0x000eb4, 9911}, {0x000eb5, 9928}, + {0x000eb6, 9940}, {0x000eb7, 9957}, {0x000eb8, 9970}, {0x000eb9, 9983}, + {0x000eba, 10001}, {0x000ebb, 10014}, {0x000ebc, 10028}, {0x000ebd, 10041}, + {0x000ebe, 10055}, {0x000ebf, 10068}, {0x000ec0, 10077}, {0x000ec1, 10087}, + {0x000ec2, 10097}, {0x000ec3, 10108}, {0x000ec4, 10118}, {0x000ec5, 10127}, + {0x000ec6, 10138}, {0x000ec7, 10148}, {0x000ec8, 10157}, {0x000ec9, 10167}, + {0x000eca, 10178}, {0x000ecb, 10188}, {0x000ecc, 10198}, {0x000ecd, 10207}, + {0x000ece, 10218}, {0x000ecf, 10228}, {0x000ed0, 10238}, {0x000ed1, 10248}, + {0x000ed2, 10258}, {0x000ed3, 10268}, {0x000ed4, 10277}, {0x000ed5, 10293}, + {0x000ed6, 10314}, {0x000ed7, 10334}, {0x000ed8, 10349}, {0x000ed9, 10369}, + {0x000eda, 10389}, {0x000edb, 10405}, {0x000edc, 10420}, {0x000edd, 10441}, + {0x000ede, 10461}, {0x000edf, 10481}, {0x000ee0, 10500}, {0x000ee1, 10520}, + {0x000ee2, 10541}, {0x000ee3, 10561}, {0x000ee4, 10576}, {0x000ee5, 10591}, + {0x000ee6, 10610}, {0x000ee7, 10624}, {0x000ee8, 10643}, {0x000ee9, 10658}, + {0x000eea, 10673}, {0x000eeb, 10688}, {0x000eec, 10704}, {0x000eed, 10719}, + {0x000eee, 10735}, {0x000eef, 10750}, {0x000ef0, 10774}, {0x000ef1, 10799}, + {0x000ef2, 10824}, {0x000ef3, 10839}, {0x000ef4, 10864}, {0x000ef5, 10890}, + {0x000ef6, 10909}, {0x000ef7, 10922}, {0x000ef8, 10936}, {0x000ef9, 10953}, + {0x000efa, 10980}, {0x000eff, 11001}, {0x0013bc, 11012}, {0x0013bd, 11015}, + {0x0013be, 11018}, {0x0020a0, 11029}, {0x0020a1, 11037}, {0x0020a2, 11047}, + {0x0020a3, 11060}, {0x0020a4, 11071}, {0x0020a5, 11080}, {0x0020a6, 11089}, + {0x0020a7, 11099}, {0x0020a8, 11110}, {0x0020a9, 11120}, {0x0020aa, 11128}, + {0x0020ab, 11142}, {0x0020ac, 11151}, {0x00fd01, 11160}, {0x00fd02, 11175}, + {0x00fd03, 11190}, {0x00fd04, 11202}, {0x00fd05, 11213}, {0x00fd06, 11226}, + {0x00fd07, 11240}, {0x00fd08, 11256}, {0x00fd09, 11267}, {0x00fd0a, 11277}, + {0x00fd0b, 11286}, {0x00fd0c, 11295}, {0x00fd0d, 11304}, {0x00fd0e, 11314}, + {0x00fd0f, 11324}, {0x00fd10, 11341}, {0x00fd11, 11356}, {0x00fd12, 11370}, + {0x00fd13, 11380}, {0x00fd14, 11391}, {0x00fd15, 11401}, {0x00fd16, 11411}, + {0x00fd17, 11421}, {0x00fd18, 11432}, {0x00fd19, 11444}, {0x00fd1a, 11462}, + {0x00fd1b, 11478}, {0x00fd1c, 11492}, {0x00fd1d, 11510}, {0x00fd1e, 11527}, + {0x00fe01, 11538}, {0x00fe02, 11547}, {0x00fe03, 11564}, {0x00fe04, 11581}, + {0x00fe05, 11598}, {0x00fe06, 11614}, {0x00fe07, 11630}, {0x00fe08, 11645}, + {0x00fe09, 11660}, {0x00fe0a, 11680}, {0x00fe0b, 11695}, {0x00fe0c, 11715}, + {0x00fe0d, 11731}, {0x00fe0e, 11752}, {0x00fe0f, 11767}, {0x00fe20, 11787}, + {0x00fe21, 11800}, {0x00fe22, 11817}, {0x00fe23, 11836}, {0x00fe24, 11856}, + {0x00fe25, 11878}, {0x00fe26, 11901}, {0x00fe27, 11925}, {0x00fe28, 11945}, + {0x00fe29, 11966}, {0x00fe2a, 11990}, {0x00fe2b, 12015}, {0x00fe2c, 12040}, + {0x00fe2d, 12061}, {0x00fe2e, 12083}, {0x00fe2f, 12102}, {0x00fe30, 12123}, + {0x00fe31, 12148}, {0x00fe32, 12176}, {0x00fe33, 12190}, {0x00fe34, 12208}, + {0x00fe50, 12218}, {0x00fe51, 12229}, {0x00fe52, 12240}, {0x00fe53, 12256}, + {0x00fe54, 12267}, {0x00fe55, 12279}, {0x00fe56, 12290}, {0x00fe57, 12304}, + {0x00fe58, 12319}, {0x00fe59, 12334}, {0x00fe5a, 12351}, {0x00fe5b, 12362}, + {0x00fe5c, 12375}, {0x00fe5d, 12387}, {0x00fe5e, 12397}, {0x00fe5f, 12415}, + {0x00fe60, 12437}, {0x00fe61, 12451}, {0x00fe62, 12461}, {0x00fe70, 12471}, + {0x00fe71, 12486}, {0x00fe72, 12510}, {0x00fe73, 12528}, {0x00fe74, 12544}, + {0x00fe75, 12562}, {0x00fe76, 12580}, {0x00fe77, 12597}, {0x00fe78, 12620}, + {0x00fe79, 12636}, {0x00fe7a, 12652}, {0x00fed0, 12671}, {0x00fed1, 12692}, + {0x00fed2, 12712}, {0x00fed4, 12732}, {0x00fed5, 12752}, {0x00fee0, 12769}, + {0x00fee1, 12782}, {0x00fee2, 12796}, {0x00fee3, 12807}, {0x00fee4, 12820}, + {0x00fee5, 12835}, {0x00fee6, 12851}, {0x00fee7, 12868}, {0x00fee8, 12886}, + {0x00fee9, 12906}, {0x00feea, 12922}, {0x00feeb, 12938}, {0x00feec, 12954}, + {0x00feed, 12970}, {0x00feee, 12986}, {0x00feef, 13008}, {0x00fef0, 13026}, + {0x00fef1, 13044}, {0x00fef2, 13062}, {0x00fef3, 13080}, {0x00fef4, 13098}, + {0x00fef5, 13116}, {0x00fef6, 13130}, {0x00fef7, 13144}, {0x00fef8, 13158}, + {0x00fef9, 13172}, {0x00fefa, 13191}, {0x00fefb, 13210}, {0x00fefc, 13230}, + {0x00fefd, 13250}, {0x00ff08, 13264}, {0x00ff09, 13274}, {0x00ff0a, 13278}, + {0x00ff0b, 13287}, {0x00ff0d, 13293}, {0x00ff13, 13300}, {0x00ff14, 13306}, + {0x00ff15, 13318}, {0x00ff1b, 13326}, {0x00ff20, 13333}, {0x00ff21, 13343}, + {0x00ff22, 13349}, {0x00ff23, 13358}, {0x00ff23, 13365}, {0x00ff24, 13377}, + {0x00ff25, 13384}, {0x00ff26, 13393}, {0x00ff27, 13402}, {0x00ff28, 13420}, + {0x00ff29, 13428}, {0x00ff2a, 13436}, {0x00ff2b, 13452}, {0x00ff2c, 13460}, + {0x00ff2d, 13467}, {0x00ff2e, 13477}, {0x00ff2f, 13488}, {0x00ff30, 13499}, + {0x00ff31, 13511}, {0x00ff32, 13518}, {0x00ff33, 13531}, {0x00ff34, 13542}, + {0x00ff35, 13555}, {0x00ff36, 13567}, {0x00ff37, 13581}, {0x00ff38, 13591}, + {0x00ff39, 13605}, {0x00ff3a, 13618}, {0x00ff3b, 13634}, {0x00ff3c, 13651}, + {0x00ff3d, 13667}, {0x00ff3e, 13685}, {0x00ff3f, 13703}, {0x00ff50, 13718}, + {0x00ff51, 13723}, {0x00ff52, 13728}, {0x00ff53, 13731}, {0x00ff54, 13737}, + {0x00ff55, 13742}, {0x00ff55, 13750}, {0x00ff56, 13756}, {0x00ff56, 13766}, + {0x00ff57, 13771}, {0x00ff58, 13775}, {0x00ff60, 13781}, {0x00ff61, 13788}, + {0x00ff62, 13794}, {0x00ff63, 13802}, {0x00ff65, 13809}, {0x00ff66, 13814}, + {0x00ff67, 13819}, {0x00ff68, 13824}, {0x00ff69, 13829}, {0x00ff6a, 13836}, + {0x00ff6b, 13841}, {0x00ff7e, 13847}, {0x00ff7e, 13861}, {0x00ff7e, 13874}, + {0x00ff7e, 13888}, {0x00ff7e, 13902}, {0x00ff7e, 13918}, {0x00ff7e, 13930}, + {0x00ff7e, 13942}, {0x00ff7f, 13956}, {0x00ff80, 13965}, {0x00ff89, 13974}, + {0x00ff8d, 13981}, {0x00ff91, 13990}, {0x00ff92, 13996}, {0x00ff93, 14002}, + {0x00ff94, 14008}, {0x00ff95, 14014}, {0x00ff96, 14022}, {0x00ff97, 14030}, + {0x00ff98, 14036}, {0x00ff99, 14045}, {0x00ff9a, 14053}, {0x00ff9a, 14064}, + {0x00ff9b, 14073}, {0x00ff9b, 14086}, {0x00ff9c, 14094}, {0x00ff9d, 14101}, + {0x00ff9e, 14110}, {0x00ff9f, 14120}, {0x00ffaa, 14130}, {0x00ffab, 14142}, + {0x00ffac, 14149}, {0x00ffad, 14162}, {0x00ffae, 14174}, {0x00ffaf, 14185}, + {0x00ffb0, 14195}, {0x00ffb1, 14200}, {0x00ffb2, 14205}, {0x00ffb3, 14210}, + {0x00ffb4, 14215}, {0x00ffb5, 14220}, {0x00ffb6, 14225}, {0x00ffb7, 14230}, + {0x00ffb8, 14235}, {0x00ffb9, 14240}, {0x00ffbd, 14245}, {0x00ffbe, 14254}, + {0x00ffbf, 14257}, {0x00ffc0, 14260}, {0x00ffc1, 14263}, {0x00ffc2, 14266}, + {0x00ffc3, 14269}, {0x00ffc4, 14272}, {0x00ffc5, 14275}, {0x00ffc6, 14278}, + {0x00ffc7, 14281}, {0x00ffc8, 14285}, {0x00ffc9, 14289}, {0x00ffca, 14293}, + {0x00ffcb, 14297}, {0x00ffcc, 14301}, {0x00ffcd, 14305}, {0x00ffce, 14309}, + {0x00ffcf, 14313}, {0x00ffd0, 14317}, {0x00ffd1, 14321}, {0x00ffd2, 14325}, + {0x00ffd3, 14329}, {0x00ffd4, 14333}, {0x00ffd5, 14337}, {0x00ffd6, 14341}, + {0x00ffd7, 14345}, {0x00ffd8, 14349}, {0x00ffd9, 14353}, {0x00ffda, 14357}, + {0x00ffdb, 14361}, {0x00ffdc, 14365}, {0x00ffdd, 14369}, {0x00ffde, 14373}, + {0x00ffdf, 14377}, {0x00ffe0, 14381}, {0x00ffe1, 14385}, {0x00ffe2, 14393}, + {0x00ffe3, 14401}, {0x00ffe4, 14411}, {0x00ffe5, 14421}, {0x00ffe6, 14431}, + {0x00ffe7, 14442}, {0x00ffe8, 14449}, {0x00ffe9, 14456}, {0x00ffea, 14462}, + {0x00ffeb, 14468}, {0x00ffec, 14476}, {0x00ffed, 14484}, {0x00ffee, 14492}, + {0x00ffff, 14500}, {0xffffff, 14507}}; static const key_entry keys_by_name[] = { - { 0x000030, 140 }, - { 0x000031, 142 }, - { 0x000032, 144 }, - { 0x000033, 146 }, - { 0x00fd10, 11341 }, - { 0x00fd0e, 11314 }, - { 0x00fd05, 11213 }, - { 0x00fd19, 11444 }, - { 0x00fd15, 11401 }, - { 0x00fd0f, 11324 }, - { 0x00fd1c, 11492 }, - { 0x00fd1a, 11462 }, - { 0x00fd01, 11160 }, - { 0x00fd1e, 11527 }, - { 0x00fd06, 11226 }, - { 0x00fd07, 11240 }, - { 0x00fd1b, 11478 }, - { 0x00fd02, 11175 }, - { 0x00fd13, 11380 }, - { 0x00fd12, 11370 }, - { 0x00fd11, 11356 }, - { 0x00fd04, 11202 }, - { 0x00fd0a, 11277 }, - { 0x00fd0b, 11286 }, - { 0x00fd0c, 11295 }, - { 0x00fd16, 11411 }, - { 0x00fd1d, 11510 }, - { 0x00fd09, 11267 }, - { 0x00fd18, 11432 }, - { 0x00fd08, 11256 }, - { 0x00fd03, 11190 }, - { 0x00fd14, 11391 }, - { 0x00fd17, 11421 }, - { 0x00fd0d, 11304 }, - { 0x000034, 148 }, - { 0x000035, 150 }, - { 0x000036, 152 }, - { 0x000037, 154 }, - { 0x000038, 156 }, - { 0x000039, 158 }, - { 0x000041, 207 }, - { 0x0000c6, 787 }, - { 0x0000c1, 744 }, - { 0x0001c3, 1473 }, - { 0x00fe70, 12471 }, - { 0x00fe71, 12486 }, - { 0x0000c2, 751 }, - { 0x0000c4, 770 }, - { 0x0000c0, 737 }, - { 0x00ffe9, 14456 }, - { 0x00ffea, 14462 }, - { 0x0003c0, 2068 }, - { 0x0001a1, 1281 }, - { 0x0005d9, 3221 }, - { 0x0005c7, 3008 }, - { 0x0005e9, 3360 }, - { 0x0005c8, 3020 }, - { 0x0005ac, 2848 }, - { 0x0005d6, 3188 }, - { 0x0005cf, 3107 }, - { 0x0005ef, 3451 }, - { 0x0005ec, 3406 }, - { 0x0005ee, 3438 }, - { 0x0005eb, 3390 }, - { 0x0005e1, 3260 }, - { 0x0005da, 3232 }, - { 0x0005e7, 3328 }, - { 0x0005cd, 3084 }, - { 0x0005c1, 2899 }, - { 0x0005c3, 2931 }, - { 0x0005c4, 2950 }, - { 0x0005c6, 2990 }, - { 0x0005c5, 2968 }, - { 0x0005e7, 3338 }, - { 0x0005cc, 3072 }, - { 0x0005e3, 3282 }, - { 0x0005f0, 3464 }, - { 0x0005ed, 3422 }, - { 0x0005ce, 3095 }, - { 0x0005e4, 3293 }, - { 0x0005c2, 2912 }, - { 0x0005e5, 3304 }, - { 0x0005e6, 3316 }, - { 0x0005e2, 3271 }, - { 0x0005bf, 2878 }, - { 0x0005d1, 3130 }, - { 0x0005d5, 3177 }, - { 0x0005d3, 3152 }, - { 0x0005bb, 2861 }, - { 0x0005f1, 3477 }, - { 0x0005d4, 3164 }, - { 0x0005f2, 3491 }, - { 0x00ff7e, 13847 }, - { 0x0005d7, 3199 }, - { 0x0005e0, 3245 }, - { 0x0005ca, 3049 }, - { 0x0005c9, 3031 }, - { 0x0005d0, 3118 }, - { 0x0005cb, 3060 }, - { 0x0005e8, 3349 }, - { 0x0005ea, 3379 }, - { 0x0005d8, 3210 }, - { 0x0005d2, 3140 }, - { 0x0000c5, 781 }, - { 0x0000c3, 763 }, - { 0x00fe7a, 12652 }, - { 0x000042, 209 }, - { 0x00ff08, 13264 }, - { 0x00ff58, 13775 }, - { 0x00fe74, 12544 }, - { 0x00ff6b, 13841 }, - { 0x0006be, 4011 }, - { 0x0006ae, 3729 }, - { 0x000043, 211 }, - { 0x0002c5, 1826 }, - { 0x0001c6, 1487 }, - { 0x00ff69, 13829 }, - { 0x00ffe5, 14421 }, - { 0x0001c8, 1494 }, - { 0x0000c7, 790 }, - { 0x0002c6, 1836 }, - { 0x00ff0b, 13287 }, - { 0x00ff37, 13581 }, - { 0x0020a1, 11037 }, - { 0x00ffe3, 14401 }, - { 0x00ffe4, 14411 }, - { 0x0020a2, 11047 }, - { 0x0006e1, 4474 }, - { 0x0006e2, 4485 }, - { 0x0006fe, 4836 }, - { 0x0006e4, 4510 }, - { 0x0006bf, 4031 }, - { 0x0006fc, 4810 }, - { 0x0006e6, 4534 }, - { 0x0006ec, 4610 }, - { 0x0006ed, 4622 }, - { 0x0006ee, 4634 }, - { 0x0006f2, 4681 }, - { 0x0006f3, 4693 }, - { 0x0006e7, 4546 }, - { 0x0006e8, 4559 }, - { 0x0006ff, 4849 }, - { 0x0006e9, 4571 }, - { 0x0006e5, 4522 }, - { 0x0006b3, 3812 }, - { 0x0006b8, 3911 }, - { 0x0006eb, 4598 }, - { 0x0006b9, 3934 }, - { 0x0006ba, 3959 }, - { 0x0006ef, 4646 }, - { 0x0006f0, 4657 }, - { 0x0006fb, 4797 }, - { 0x0006fd, 4821 }, - { 0x0006ea, 4582 }, - { 0x0006f8, 4753 }, - { 0x0006f4, 4705 }, - { 0x0006e3, 4497 }, - { 0x0006f5, 4717 }, - { 0x0006f7, 4741 }, - { 0x0006f1, 4669 }, - { 0x0006f9, 4771 }, - { 0x0006e0, 4462 }, - { 0x0006fa, 4785 }, - { 0x0006f6, 4728 }, - { 0x0006c1, 4069 }, - { 0x0006c2, 4080 }, - { 0x0006de, 4431 }, - { 0x0006c4, 4105 }, - { 0x0006af, 3749 }, - { 0x0006dc, 4405 }, - { 0x0006c6, 4129 }, - { 0x0006cc, 4205 }, - { 0x0006cd, 4217 }, - { 0x0006ce, 4229 }, - { 0x0006d2, 4276 }, - { 0x0006d3, 4288 }, - { 0x0006c7, 4141 }, - { 0x0006c8, 4154 }, - { 0x0006df, 4444 }, - { 0x0006c9, 4166 }, - { 0x0006c5, 4117 }, - { 0x0006a3, 3530 }, - { 0x0006a8, 3629 }, - { 0x0006cb, 4193 }, - { 0x0006a9, 3652 }, - { 0x0006aa, 3677 }, - { 0x0006cf, 4241 }, - { 0x0006d0, 4252 }, - { 0x0006db, 4392 }, - { 0x0006dd, 4416 }, - { 0x0006ca, 4177 }, - { 0x0006d8, 4348 }, - { 0x0006d4, 4300 }, - { 0x0006c3, 4092 }, - { 0x0006d5, 4312 }, - { 0x0006d7, 4336 }, - { 0x0006d1, 4264 }, - { 0x0006d9, 4366 }, - { 0x0006c0, 4057 }, - { 0x0006da, 4380 }, - { 0x0006d6, 4323 }, - { 0x000044, 213 }, - { 0x0001cf, 1516 }, - { 0x00ffff, 14500 }, - { 0x0020ab, 11142 }, - { 0x00ff54, 13737 }, - { 0x0001d0, 1523 }, - { 0x000045, 215 }, - { 0x0003bd, 2060 }, - { 0x0000d0, 873 }, - { 0x0003cc, 2084 }, - { 0x0000c9, 806 }, - { 0x0001cc, 1509 }, - { 0x0000ca, 813 }, - { 0x0020a0, 11029 }, - { 0x0000cb, 825 }, - { 0x0000c8, 799 }, - { 0x00ff2f, 13488 }, - { 0x00ff30, 13499 }, - { 0x0003aa, 1987 }, - { 0x00ff57, 13771 }, - { 0x0001ca, 1501 }, - { 0x00ff1b, 13326 }, - { 0x0000d0, 877 }, - { 0x0020ac, 11151 }, - { 0x00ff62, 13794 }, - { 0x000046, 217 }, - { 0x00ffbe, 14254 }, - { 0x00ffc7, 14281 }, - { 0x00ffc8, 14285 }, - { 0x00ffc9, 14289 }, - { 0x00ffca, 14293 }, - { 0x00ffcb, 14297 }, - { 0x00ffcc, 14301 }, - { 0x00ffcd, 14305 }, - { 0x00ffce, 14309 }, - { 0x00ffcf, 14313 }, - { 0x00ffd0, 14317 }, - { 0x00ffbf, 14257 }, - { 0x00ffd1, 14321 }, - { 0x00ffd2, 14325 }, - { 0x00ffd3, 14329 }, - { 0x00ffd4, 14333 }, - { 0x00ffd5, 14337 }, - { 0x00ffd6, 14341 }, - { 0x00ffd7, 14345 }, - { 0x00ffd8, 14349 }, - { 0x00ffd9, 14353 }, - { 0x00ffda, 14357 }, - { 0x00ffc0, 14260 }, - { 0x00ffdb, 14361 }, - { 0x00ffdc, 14365 }, - { 0x00ffdd, 14369 }, - { 0x00ffde, 14373 }, - { 0x00ffdf, 14377 }, - { 0x00ffe0, 14381 }, - { 0x00ffc1, 14263 }, - { 0x00ffc2, 14266 }, - { 0x00ffc3, 14269 }, - { 0x00ffc4, 14272 }, - { 0x00ffc5, 14275 }, - { 0x00ffc6, 14278 }, - { 0x0020a3, 11060 }, - { 0x00ff68, 13824 }, - { 0x00fed0, 12671 }, - { 0x000047, 219 }, - { 0x0002d5, 1848 }, - { 0x0002ab, 1759 }, - { 0x0003ab, 1995 }, - { 0x0002d8, 1858 }, - { 0x0007c1, 5316 }, - { 0x0007a1, 4867 }, - { 0x0007c2, 5328 }, - { 0x0007d7, 5564 }, - { 0x0007c4, 5351 }, - { 0x0007c5, 5363 }, - { 0x0007a2, 4885 }, - { 0x0007c7, 5388 }, - { 0x0007a3, 4905 }, - { 0x0007c3, 5339 }, - { 0x0007c9, 5410 }, - { 0x0007a4, 4921 }, - { 0x0007a5, 4957 }, - { 0x0007a5, 4938 }, - { 0x0007ca, 5421 }, - { 0x0007cb, 5433 }, - { 0x0007cb, 5446 }, - { 0x0007cc, 5458 }, - { 0x0007cd, 5467 }, - { 0x0007d9, 5584 }, - { 0x0007ab, 5039 }, - { 0x0007cf, 5485 }, - { 0x0007a7, 4977 }, - { 0x0007d6, 5554 }, - { 0x0007d0, 5499 }, - { 0x0007d8, 5574 }, - { 0x0007d1, 5508 }, - { 0x0007d2, 5518 }, - { 0x0007d4, 5530 }, - { 0x0007c8, 5398 }, - { 0x0007d5, 5540 }, - { 0x0007a8, 4997 }, - { 0x0007a9, 5017 }, - { 0x0007ce, 5476 }, - { 0x0007c6, 5377 }, - { 0x0007ae, 5057 }, - { 0x0007e1, 5596 }, - { 0x0007b1, 5093 }, - { 0x0007e2, 5608 }, - { 0x0007f7, 5866 }, - { 0x0007e4, 5631 }, - { 0x0007e5, 5643 }, - { 0x0007b2, 5111 }, - { 0x0007e7, 5668 }, - { 0x0007b3, 5131 }, - { 0x0007f3, 5810 }, - { 0x0007e3, 5619 }, - { 0x0007af, 5078 }, - { 0x0007e9, 5690 }, - { 0x0007b4, 5147 }, - { 0x0007b6, 5183 }, - { 0x0007b5, 5164 }, - { 0x0007ea, 5701 }, - { 0x0007eb, 5713 }, - { 0x0007eb, 5726 }, - { 0x0007ec, 5738 }, - { 0x0007ed, 5747 }, - { 0x0007f9, 5886 }, - { 0x0007bb, 5298 }, - { 0x0007ef, 5765 }, - { 0x0007b7, 5208 }, - { 0x0007f6, 5856 }, - { 0x0007f0, 5779 }, - { 0x0007f8, 5876 }, - { 0x0007f1, 5788 }, - { 0x0007f2, 5798 }, - { 0x00ff7e, 13861 }, - { 0x0007f4, 5832 }, - { 0x0007e8, 5678 }, - { 0x0007f5, 5842 }, - { 0x0007b8, 5228 }, - { 0x0007ba, 5270 }, - { 0x0007b9, 5248 }, - { 0x0007ee, 5756 }, - { 0x0007e6, 5657 }, - { 0x000048, 221 }, - { 0x00ff31, 13511 }, - { 0x000ebf, 10068 }, - { 0x000ec0, 10077 }, - { 0x000ef6, 10909 }, - { 0x000ef7, 10922 }, - { 0x00ff39, 13605 }, - { 0x000eba, 10001 }, - { 0x000ea7, 9694 }, - { 0x000ec4, 10118 }, - { 0x000ec3, 10108 }, - { 0x000ed1, 10248 }, - { 0x00ff33, 13531 }, - { 0x00ff34, 13542 }, - { 0x000ebe, 10055 }, - { 0x000ed3, 10268 }, - { 0x000eb7, 9957 }, - { 0x000eea, 10673 }, - { 0x000eda, 10389 }, - { 0x000eee, 10735 }, - { 0x000ee8, 10643 }, - { 0x000ee9, 10658 }, - { 0x000eeb, 10688 }, - { 0x000ed4, 10277 }, - { 0x000ed6, 10314 }, - { 0x000ef9, 10953 }, - { 0x000ee3, 10561 }, - { 0x000ed7, 10334 }, - { 0x000ed9, 10369 }, - { 0x000ed8, 10349 }, - { 0x000ef8, 10936 }, - { 0x000eed, 10719 }, - { 0x000ee4, 10576 }, - { 0x000ee5, 10591 }, - { 0x000edb, 10405 }, - { 0x000ee2, 10541 }, - { 0x000edc, 10420 }, - { 0x000edd, 10441 }, - { 0x000ee1, 10520 }, - { 0x000ede, 10461 }, - { 0x000edf, 10481 }, - { 0x000ee0, 10500 }, - { 0x000ee6, 10610 }, - { 0x000ed5, 10293 }, - { 0x000ee7, 10624 }, - { 0x000eec, 10704 }, - { 0x000efa, 10980 }, - { 0x00ff35, 13555 }, - { 0x00ff38, 13591 }, - { 0x000eb8, 9970 }, - { 0x000ebb, 10014 }, - { 0x000ea1, 9594 }, - { 0x000ea3, 9627 }, - { 0x000ef3, 10839 }, - { 0x000eb1, 9867 }, - { 0x000ea4, 9645 }, - { 0x000ea6, 9676 }, - { 0x000ea5, 9658 }, - { 0x000ec7, 10148 }, - { 0x000eca, 10178 }, - { 0x000ef2, 10824 }, - { 0x000ebd, 10041 }, - { 0x000eb2, 9880 }, - { 0x000eb4, 9911 }, - { 0x00ff3b, 13634 }, - { 0x00ff3a, 13618 }, - { 0x000ea9, 9727 }, - { 0x000eb0, 9849 }, - { 0x000eaa, 9740 }, - { 0x000eab, 9759 }, - { 0x000eaf, 9830 }, - { 0x000eac, 9777 }, - { 0x000ead, 9795 }, - { 0x000eae, 9812 }, - { 0x000eef, 10750 }, - { 0x00ff36, 13567 }, - { 0x000eb5, 9928 }, - { 0x00ff3f, 13703 }, - { 0x000ea8, 9708 }, - { 0x000eb9, 9983 }, - { 0x000ea2, 9608 }, - { 0x000eb3, 9893 }, - { 0x000eb6, 9940 }, - { 0x00ff32, 13518 }, - { 0x000ef0, 10774 }, - { 0x000ef4, 10864 }, - { 0x000ef1, 10799 }, - { 0x000ebc, 10028 }, - { 0x000ecc, 10198 }, - { 0x000ec8, 10157 }, - { 0x000ec9, 10167 }, - { 0x000ece, 10218 }, - { 0x000ecd, 10207 }, - { 0x000ecf, 10228 }, - { 0x000ec1, 10087 }, - { 0x000ec2, 10097 }, - { 0x000ec6, 10138 }, - { 0x000ec5, 10127 }, - { 0x000ed2, 10258 }, - { 0x000ecb, 10188 }, - { 0x000ed0, 10238 }, - { 0x000ef5, 10890 }, - { 0x00ff7e, 13874 }, - { 0x00ff29, 13428 }, - { 0x0002a6, 1737 }, - { 0x00ff7e, 13888 }, - { 0x00ff6a, 13836 }, - { 0x00ff23, 13358 }, - { 0x00ff23, 13365 }, - { 0x00ff25, 13384 }, - { 0x00ff27, 13402 }, - { 0x00ff50, 13718 }, - { 0x0002a1, 1729 }, - { 0x00ffed, 14484 }, - { 0x00ffee, 14492 }, - { 0x000049, 223 }, - { 0x00fe33, 12190 }, - { 0x00fe30, 12123 }, - { 0x00fe31, 12148 }, - { 0x00fe32, 12176 }, - { 0x00fe34, 12208 }, - { 0x00fe2f, 12102 }, - { 0x00fe2c, 12040 }, - { 0x00fe2d, 12061 }, - { 0x00fe2e, 12083 }, - { 0x00fe0c, 11715 }, - { 0x00fe0d, 11731 }, - { 0x00fe06, 11614 }, - { 0x00fe07, 11630 }, - { 0x00ff7e, 13902 }, - { 0x00fe0e, 11752 }, - { 0x00fe0f, 11767 }, - { 0x00fe20, 11787 }, - { 0x00fe02, 11547 }, - { 0x00fe04, 11581 }, - { 0x00fe05, 11598 }, - { 0x00fe03, 11564 }, - { 0x00fe01, 11538 }, - { 0x00fe22, 11817 }, - { 0x00fe21, 11800 }, - { 0x00fe08, 11645 }, - { 0x00fe09, 11660 }, - { 0x00fe24, 11856 }, - { 0x00fe23, 11836 }, - { 0x00fe25, 11878 }, - { 0x00fe26, 11901 }, - { 0x00fe0a, 11680 }, - { 0x00fe0b, 11695 }, - { 0x00fe2b, 12015 }, - { 0x00fe29, 11966 }, - { 0x00fe2a, 11990 }, - { 0x00fe27, 11925 }, - { 0x00fe28, 11945 }, - { 0x0002a9, 1749 }, - { 0x0000cd, 843 }, - { 0x0000ce, 850 }, - { 0x0000cf, 862 }, - { 0x0000cc, 836 }, - { 0x0003cf, 2094 }, - { 0x00ff63, 13802 }, - { 0x0003c7, 2076 }, - { 0x0003a5, 1971 }, - { 0x00004a, 225 }, - { 0x0002ac, 1766 }, - { 0x00004b, 227 }, - { 0x00ffb0, 14195 }, - { 0x00ffb1, 14200 }, - { 0x00ffb2, 14205 }, - { 0x00ffb3, 14210 }, - { 0x00ffb4, 14215 }, - { 0x00ffb5, 14220 }, - { 0x00ffb6, 14225 }, - { 0x00ffb7, 14230 }, - { 0x00ffb8, 14235 }, - { 0x00ffb9, 14240 }, - { 0x00ffab, 14142 }, - { 0x00ff9d, 14101 }, - { 0x00ffae, 14174 }, - { 0x00ff9f, 14120 }, - { 0x00ffaf, 14185 }, - { 0x00ff99, 14045 }, - { 0x00ff9c, 14094 }, - { 0x00ff8d, 13981 }, - { 0x00ffbd, 14245 }, - { 0x00ff91, 13990 }, - { 0x00ff92, 13996 }, - { 0x00ff93, 14002 }, - { 0x00ff94, 14008 }, - { 0x00ff95, 14014 }, - { 0x00ff9e, 14110 }, - { 0x00ff96, 14022 }, - { 0x00ffaa, 14130 }, - { 0x00ff9b, 14086 }, - { 0x00ff9b, 14073 }, - { 0x00ff9a, 14053 }, - { 0x00ff9a, 14064 }, - { 0x00ff98, 14036 }, - { 0x00ffac, 14149 }, - { 0x00ff80, 13965 }, - { 0x00ffad, 14162 }, - { 0x00ff89, 13974 }, - { 0x00ff97, 14030 }, - { 0x00ff2d, 13467 }, - { 0x00ff2e, 13477 }, - { 0x00ff21, 13343 }, - { 0x00ff26, 13393 }, - { 0x0003d3, 2119 }, - { 0x000eff, 11001 }, - { 0x00004c, 229 }, - { 0x0001c5, 1480 }, - { 0x00fed4, 12732 }, - { 0x0001a5, 1303 }, - { 0x0003a6, 1978 }, - { 0x00ff51, 13723 }, - { 0x00ff0a, 13278 }, - { 0x0020a4, 11071 }, - { 0x0001a3, 1295 }, - { 0x00004d, 231 }, - { 0x0006b5, 3849 }, - { 0x0006b2, 3798 }, - { 0x0006bc, 3997 }, - { 0x0006a5, 3567 }, - { 0x0006a2, 3516 }, - { 0x0006ac, 3715 }, - { 0x00ff2c, 13460 }, - { 0x00ff67, 13819 }, - { 0x00ffe7, 14442 }, - { 0x00ffe8, 14449 }, - { 0x0020a5, 11080 }, - { 0x00ff7e, 13918 }, - { 0x00fe77, 12597 }, - { 0x00fe76, 12580 }, - { 0x00ff22, 13349 }, - { 0x00ff20, 13333 }, - { 0x00ff3d, 13667 }, - { 0x00004e, 233 }, - { 0x0001d1, 1531 }, - { 0x0020a6, 11089 }, - { 0x0001d2, 1538 }, - { 0x0003d1, 2102 }, - { 0x0020aa, 11128 }, - { 0x00ff56, 13766 }, - { 0x00fed2, 12712 }, - { 0x0000d1, 881 }, - { 0x00ff7f, 13956 }, - { 0x00004f, 235 }, - { 0x0013bc, 11012 }, - { 0x0000d3, 895 }, - { 0x0000d4, 902 }, - { 0x0000d6, 921 }, - { 0x0001d5, 1545 }, - { 0x0000d2, 888 }, - { 0x0003d2, 2111 }, - { 0x0000d8, 941 }, - { 0x0000d5, 914 }, - { 0x00fe78, 12620 }, - { 0x00fe79, 12636 }, - { 0x000050, 237 }, - { 0x00ff56, 13756 }, - { 0x00ff55, 13742 }, - { 0x00ff13, 13300 }, - { 0x0020a7, 11099 }, - { 0x00fefa, 13191 }, - { 0x00fee9, 12906 }, - { 0x00feea, 12922 }, - { 0x00feeb, 12938 }, - { 0x00feec, 12954 }, - { 0x00feed, 12970 }, - { 0x00fee8, 12886 }, - { 0x00feef, 13008 }, - { 0x00fef0, 13026 }, - { 0x00fef1, 13044 }, - { 0x00fef2, 13062 }, - { 0x00fef3, 13080 }, - { 0x00feee, 12986 }, - { 0x00fefb, 13210 }, - { 0x00fefc, 13230 }, - { 0x00fee3, 12807 }, - { 0x00fee6, 12851 }, - { 0x00fee7, 12868 }, - { 0x00fef5, 13116 }, - { 0x00fef6, 13130 }, - { 0x00fef7, 13144 }, - { 0x00fef8, 13158 }, - { 0x00fefd, 13250 }, - { 0x00fef4, 13098 }, - { 0x00fef9, 13172 }, - { 0x00fee0, 12769 }, - { 0x00fee1, 12782 }, - { 0x00fee2, 12796 }, - { 0x00fee4, 12820 }, - { 0x00fee5, 12835 }, - { 0x00fed1, 12692 }, - { 0x00ff3e, 13685 }, - { 0x00ff61, 13788 }, - { 0x00ff55, 13750 }, - { 0x000051, 239 }, - { 0x000052, 241 }, - { 0x0001c0, 1466 }, - { 0x0001d8, 1558 }, - { 0x0003a3, 1962 }, - { 0x00ff66, 13814 }, - { 0x00fe72, 12510 }, - { 0x00ff0d, 13293 }, - { 0x00ff53, 13731 }, - { 0x00ff24, 13377 }, - { 0x0020a8, 11110 }, - { 0x000053, 243 }, - { 0x0001a6, 1310 }, - { 0x0001a9, 1317 }, - { 0x0001aa, 1324 }, - { 0x0002de, 1877 }, - { 0x00ff14, 13306 }, - { 0x00ff60, 13781 }, - { 0x0006b1, 3786 }, - { 0x0006bf, 4045 }, - { 0x0006b8, 3923 }, - { 0x0006b9, 3947 }, - { 0x0006ba, 3972 }, - { 0x0006bb, 3984 }, - { 0x0006a1, 3504 }, - { 0x0006af, 3763 }, - { 0x0006a8, 3641 }, - { 0x0006a9, 3665 }, - { 0x0006aa, 3690 }, - { 0x0006ab, 3702 }, - { 0x00ffe1, 14385 }, - { 0x00ffe6, 14431 }, - { 0x00ffe2, 14393 }, - { 0x00ff3c, 13651 }, - { 0x00fe73, 12528 }, - { 0x00fe75, 12562 }, - { 0x00ffeb, 14468 }, - { 0x00ffec, 14476 }, - { 0x00ff15, 13318 }, - { 0x000054, 245 }, - { 0x0000de, 994 }, - { 0x00ff09, 13274 }, - { 0x0001ab, 1333 }, - { 0x0001de, 1584 }, - { 0x00fed5, 12752 }, - { 0x000ddf, 9260 }, - { 0x000dba, 8843 }, - { 0x000da8, 8607 }, - { 0x000daa, 8634 }, - { 0x000da9, 8620 }, - { 0x000dac, 8658 }, - { 0x000dae, 8683 }, - { 0x000db4, 8768 }, - { 0x000dbd, 8882 }, - { 0x000dbf, 8905 }, - { 0x000dcb, 9039 }, - { 0x000dce, 9073 }, - { 0x000da2, 8525 }, - { 0x000da5, 8566 }, - { 0x000da3, 8538 }, - { 0x000da4, 8552 }, - { 0x000da6, 8579 }, - { 0x000da1, 8514 }, - { 0x000de5, 9343 }, - { 0x000df7, 9556 }, - { 0x000df5, 9533 }, - { 0x000df6, 9544 }, - { 0x000df9, 9582 }, - { 0x000df1, 9484 }, - { 0x000df8, 9569 }, - { 0x000df3, 9510 }, - { 0x000df4, 9522 }, - { 0x000df2, 9497 }, - { 0x000df0, 9472 }, - { 0x000dcc, 9050 }, - { 0x000dc5, 8972 }, - { 0x000dc6, 8984 }, - { 0x000deb, 9424 }, - { 0x000de8, 9389 }, - { 0x000dd1, 9113 }, - { 0x000dde, 9237 }, - { 0x000de7, 9374 }, - { 0x000de9, 9400 }, - { 0x000dea, 9412 }, - { 0x000de6, 9360 }, - { 0x000dc1, 8932 }, - { 0x000da7, 8595 }, - { 0x000ded, 9458 }, - { 0x000db3, 8757 }, - { 0x000db9, 8833 }, - { 0x000dcd, 9063 }, - { 0x000dcf, 9087 }, - { 0x000dda, 9224 }, - { 0x000dbe, 8892 }, - { 0x000dbc, 8868 }, - { 0x000dc0, 8916 }, - { 0x000dbb, 8857 }, - { 0x000dc3, 8953 }, - { 0x000dc4, 8964 }, - { 0x000dd0, 9102 }, - { 0x000dd2, 9129 }, - { 0x000de1, 9281 }, - { 0x000de4, 9323 }, - { 0x000de3, 9304 }, - { 0x000dd3, 9141 }, - { 0x000de0, 9270 }, - { 0x000dd4, 9153 }, - { 0x000dd5, 9164 }, - { 0x000de2, 9293 }, - { 0x000dd8, 9201 }, - { 0x000dd6, 9176 }, - { 0x000dd7, 9188 }, - { 0x000dd9, 9212 }, - { 0x000dc9, 9016 }, - { 0x000dc8, 9004 }, - { 0x000dab, 8648 }, - { 0x000dca, 9028 }, - { 0x000dec, 9441 }, - { 0x000db1, 8722 }, - { 0x000db2, 8741 }, - { 0x000db7, 8804 }, - { 0x000db0, 8709 }, - { 0x000db8, 8819 }, - { 0x000db6, 8790 }, - { 0x000daf, 8696 }, - { 0x000db5, 8779 }, - { 0x000dc7, 8992 }, - { 0x000dc2, 8942 }, - { 0x000dad, 8671 }, - { 0x0000de, 1000 }, - { 0x00ff2b, 13452 }, - { 0x0003ac, 2004 }, - { 0x000055, 247 }, - { 0x0000da, 957 }, - { 0x0002dd, 1870 }, - { 0x0000db, 964 }, - { 0x0000dc, 976 }, - { 0x0001db, 1571 }, - { 0x0000d9, 950 }, - { 0x0006b6, 3863 }, - { 0x0006b4, 3824 }, - { 0x0006b7, 3886 }, - { 0x0006a6, 3581 }, - { 0x0006a4, 3542 }, - { 0x0006a7, 3604 }, - { 0x0006b6, 3875 }, - { 0x0006b4, 3837 }, - { 0x0006b7, 3899 }, - { 0x0006a6, 3593 }, - { 0x0006a4, 3555 }, - { 0x0006a7, 3617 }, - { 0x0003de, 2143 }, - { 0x00ff65, 13809 }, - { 0x0003d9, 2128 }, - { 0x00ff52, 13728 }, - { 0x0001d9, 1565 }, - { 0x0003dd, 2136 }, - { 0x000056, 249 }, - { 0xffffff, 14507 }, - { 0x000057, 251 }, - { 0x0020a9, 11120 }, - { 0x000058, 253 }, - { 0x000059, 255 }, - { 0x0000dd, 987 }, - { 0x0013be, 11018 }, - { 0x00005a, 257 }, - { 0x0001af, 1354 }, - { 0x0001ac, 1340 }, - { 0x0001ae, 1347 }, - { 0x00ff28, 13420 }, - { 0x00ff2a, 13436 }, - { 0x000061, 333 }, - { 0x0000e1, 1020 }, - { 0x0001ff, 1720 }, - { 0x0001e3, 1600 }, - { 0x0000e2, 1027 }, - { 0x0000b4, 612 }, - { 0x0000e4, 1046 }, - { 0x0000e6, 1063 }, - { 0x0000e0, 1013 }, - { 0x0003e0, 2151 }, - { 0x000026, 48 }, - { 0x0001b1, 1364 }, - { 0x000027, 58 }, - { 0x0008c8, 6376 }, - { 0x0000e5, 1057 }, - { 0x00005e, 294 }, - { 0x00007e, 410 }, - { 0x00002a, 101 }, - { 0x000040, 204 }, - { 0x0000e3, 1039 }, - { 0x000062, 335 }, - { 0x00005c, 271 }, - { 0x000af4, 7692 }, - { 0x00007c, 395 }, - { 0x0009df, 6562 }, - { 0x0008a5, 5952 }, - { 0x0008ac, 6062 }, - { 0x0008a8, 5995 }, - { 0x0008b2, 6166 }, - { 0x0008ae, 6091 }, - { 0x0008aa, 6030 }, - { 0x0008b6, 6253 }, - { 0x0009f6, 6770 }, - { 0x0008b4, 6209 }, - { 0x00007b, 385 }, - { 0x00007d, 399 }, - { 0x00005b, 259 }, - { 0x00005d, 281 }, - { 0x0001a2, 1289 }, - { 0x0000a6, 472 }, - { 0x000063, 337 }, - { 0x0002e5, 1889 }, - { 0x0001e6, 1614 }, - { 0x000ab8, 6996 }, - { 0x000afc, 7801 }, - { 0x0001b7, 1401 }, - { 0x0001e8, 1621 }, - { 0x0000e7, 1066 }, - { 0x0002e6, 1899 }, - { 0x0000b8, 646 }, - { 0x0000a2, 445 }, - { 0x0009e1, 6581 }, - { 0x000af3, 7682 }, - { 0x000bcf, 7950 }, - { 0x000aec, 7630 }, - { 0x00003a, 160 }, - { 0x00002c, 115 }, - { 0x0000a9, 500 }, - { 0x0009e4, 6600 }, - { 0x0009ee, 6668 }, - { 0x0000a4, 459 }, - { 0x000aff, 7845 }, - { 0x000064, 339 }, - { 0x000af1, 7662 }, - { 0x0001ef, 1643 }, - { 0x00fe56, 12290 }, - { 0x00fe58, 12319 }, - { 0x00fe51, 12229 }, - { 0x00fe60, 12437 }, - { 0x00fe55, 12279 }, - { 0x00fe5a, 12351 }, - { 0x00fe5b, 12362 }, - { 0x00fe52, 12240 }, - { 0x00fe57, 12304 }, - { 0x00fe59, 12334 }, - { 0x00fe50, 12218 }, - { 0x00fe61, 12451 }, - { 0x00fe62, 12461 }, - { 0x00fe5d, 12387 }, - { 0x00fe54, 12267 }, - { 0x00fe5c, 12375 }, - { 0x00fe5f, 12415 }, - { 0x00fe53, 12256 }, - { 0x00fe5e, 12397 }, - { 0x000abd, 7028 }, - { 0x0000b0, 569 }, - { 0x0000a8, 490 }, - { 0x000aed, 7635 }, - { 0x000aa5, 6822 }, - { 0x0000f7, 1204 }, - { 0x000024, 33 }, - { 0x000aaf, 6899 }, - { 0x0001bd, 1437 }, - { 0x000af2, 7669 }, - { 0x000afe, 7826 }, - { 0x0008fe, 6552 }, - { 0x000ba8, 7873 }, - { 0x000bd6, 7965 }, - { 0x000bc4, 7915 }, - { 0x000bc2, 7899 }, - { 0x0001f0, 1650 }, - { 0x000065, 341 }, - { 0x0003ec, 2167 }, - { 0x0000e9, 1082 }, - { 0x0001ec, 1636 }, - { 0x0000ea, 1089 }, - { 0x0000eb, 1101 }, - { 0x0000e8, 1075 }, - { 0x000aae, 6890 }, - { 0x000aa3, 6804 }, - { 0x000aa4, 6813 }, - { 0x0003ba, 2036 }, - { 0x000aa9, 6864 }, - { 0x000ade, 7409 }, - { 0x000adf, 7424 }, - { 0x000ace, 7191 }, - { 0x000acf, 7204 }, - { 0x000aa1, 6788 }, - { 0x000aaa, 6871 }, - { 0x000ae6, 7531 }, - { 0x000ae7, 7550 }, - { 0x0003bf, 2064 }, - { 0x000ae0, 7437 }, - { 0x000ae1, 7454 }, - { 0x000aa2, 6796 }, - { 0x0001ea, 1628 }, - { 0x00003d, 181 }, - { 0x0000f0, 1149 }, - { 0x000021, 6 }, - { 0x0000a1, 434 }, - { 0x000066, 343 }, - { 0x000af8, 7740 }, - { 0x0009e3, 6597 }, - { 0x000abb, 7003 }, - { 0x000adc, 7368 }, - { 0x000adb, 7351 }, - { 0x000add, 7388 }, - { 0x000ae9, 7585 }, - { 0x000ae8, 7567 }, - { 0x000ac5, 7089 }, - { 0x000ab7, 6985 }, - { 0x000ab5, 6965 }, - { 0x0008f6, 6514 }, - { 0x000067, 345 }, - { 0x0002f5, 1911 }, - { 0x0002bb, 1807 }, - { 0x0003bb, 2044 }, - { 0x0002f8, 1921 }, - { 0x000060, 317 }, - { 0x00003e, 187 }, - { 0x0008be, 6315 }, - { 0x0000ab, 522 }, - { 0x0000bb, 676 }, - { 0x000068, 347 }, - { 0x000aa8, 6854 }, - { 0x0002b6, 1786 }, - { 0x000aee, 7643 }, - { 0x000ce0, 8033 }, - { 0x000cf2, 8350 }, - { 0x000ce1, 8046 }, - { 0x000ce1, 8057 }, - { 0x000ce7, 8169 }, - { 0x000ce3, 8096 }, - { 0x000ce3, 8109 }, - { 0x000cdf, 8012 }, - { 0x000cea, 8226 }, - { 0x000ced, 8268 }, - { 0x000cef, 8295 }, - { 0x000cf3, 8362 }, - { 0x000cf5, 8387 }, - { 0x000cf5, 8404 }, - { 0x000ce2, 8069 }, - { 0x000ce2, 8082 }, - { 0x000ce4, 8123 }, - { 0x000ce7, 8181 }, - { 0x000ceb, 8243 }, - { 0x000cf7, 8445 }, - { 0x000cec, 8255 }, - { 0x000cee, 8284 }, - { 0x000cf0, 8311 }, - { 0x000cf4, 8377 }, - { 0x000cf7, 8456 }, - { 0x000cf8, 8468 }, - { 0x000cf1, 8322 }, - { 0x000cf1, 8336 }, - { 0x000cf9, 8480 }, - { 0x000cfa, 8492 }, - { 0x000cfa, 8503 }, - { 0x000ce8, 8192 }, - { 0x000ce8, 8203 }, - { 0x000ce5, 8133 }, - { 0x000ce9, 8215 }, - { 0x000cf6, 8421 }, - { 0x000cf6, 8433 }, - { 0x000ce6, 8144 }, - { 0x000ce6, 8156 }, - { 0x000ada, 7342 }, - { 0x0008a3, 5925 }, - { 0x0009ef, 6682 }, - { 0x0009f0, 6697 }, - { 0x0009f1, 6712 }, - { 0x0009f2, 6727 }, - { 0x0009f3, 6742 }, - { 0x0002b1, 1778 }, - { 0x0009e2, 6594 }, - { 0x0000ad, 544 }, - { 0x000069, 349 }, - { 0x0000ed, 1119 }, - { 0x0000ee, 1126 }, - { 0x0008cf, 6418 }, - { 0x0000ef, 1138 }, - { 0x0002b9, 1798 }, - { 0x0008cd, 6401 }, - { 0x0000ec, 1112 }, - { 0x0003ef, 2177 }, - { 0x0008ce, 6410 }, - { 0x0008da, 6436 }, - { 0x0008db, 6447 }, - { 0x0008c2, 6361 }, - { 0x0008bf, 6332 }, - { 0x0008dc, 6456 }, - { 0x0003e7, 2159 }, - { 0x0003b5, 2020 }, - { 0x00006a, 351 }, - { 0x0002bc, 1814 }, - { 0x000bca, 7934 }, - { 0x00006b, 353 }, - { 0x0004b1, 2439 }, - { 0x0004c1, 2563 }, - { 0x0004b4, 2460 }, - { 0x0004cc, 2669 }, - { 0x0004ca, 2653 }, - { 0x0004cd, 2685 }, - { 0x0004cb, 2661 }, - { 0x0004ce, 2693 }, - { 0x0004cc, 2677 }, - { 0x0004b2, 2446 }, - { 0x0004b6, 2474 }, - { 0x0004b9, 2498 }, - { 0x0004b7, 2482 }, - { 0x0004ba, 2506 }, - { 0x0004b8, 2490 }, - { 0x0004cf, 2701 }, - { 0x0004d2, 2725 }, - { 0x0004d0, 2709 }, - { 0x0004d3, 2733 }, - { 0x0004d1, 2717 }, - { 0x0004dd, 2813 }, - { 0x0004c5, 2613 }, - { 0x0004c8, 2637 }, - { 0x0004c6, 2621 }, - { 0x0004c9, 2645 }, - { 0x0004c7, 2629 }, - { 0x0004b5, 2467 }, - { 0x0004d7, 2765 }, - { 0x0004da, 2789 }, - { 0x0004d8, 2773 }, - { 0x0004db, 2797 }, - { 0x0004d9, 2781 }, - { 0x0004bb, 2514 }, - { 0x0004be, 2539 }, - { 0x0004bc, 2522 }, - { 0x0004bf, 2547 }, - { 0x0004bd, 2531 }, - { 0x0004c0, 2555 }, - { 0x0004c3, 2597 }, - { 0x0004c1, 2572 }, - { 0x0004c4, 2605 }, - { 0x0004c2, 2580 }, - { 0x0004c2, 2589 }, - { 0x0004b3, 2453 }, - { 0x0004dc, 2805 }, - { 0x0004a6, 2340 }, - { 0x0004d4, 2741 }, - { 0x0004d6, 2757 }, - { 0x0004d5, 2749 }, - { 0x0004a7, 2348 }, - { 0x0004a3, 2277 }, - { 0x0004a4, 2297 }, - { 0x0004a5, 2308 }, - { 0x0004aa, 2369 }, - { 0x0004a1, 2243 }, - { 0x0004a8, 2355 }, - { 0x0004a5, 2325 }, - { 0x0004ab, 2376 }, - { 0x0004a2, 2257 }, - { 0x00ff7e, 13930 }, - { 0x0004af, 2407 }, - { 0x0004af, 2416 }, - { 0x0004a9, 2362 }, - { 0x0004ac, 2383 }, - { 0x0004ae, 2399 }, - { 0x0004ad, 2391 }, - { 0x0003a2, 1952 }, - { 0x0003f3, 2202 }, - { 0x0003a2, 1958 }, - { 0x00006c, 355 }, - { 0x0001e5, 1607 }, - { 0x000ad9, 7331 }, - { 0x0001b5, 1387 }, - { 0x0003b6, 2027 }, - { 0x000abc, 7011 }, - { 0x0008fb, 6523 }, - { 0x000ba3, 7852 }, - { 0x000ad2, 7261 }, - { 0x0008af, 6106 }, - { 0x000acc, 7156 }, - { 0x000aea, 7605 }, - { 0x0008a1, 5898 }, - { 0x000bda, 7984 }, - { 0x000ad0, 7220 }, - { 0x0009f4, 6757 }, - { 0x000bdc, 7993 }, - { 0x00003c, 176 }, - { 0x0008bc, 6292 }, - { 0x0009e5, 6603 }, - { 0x0008de, 6475 }, - { 0x0008df, 6486 }, - { 0x0009ed, 6654 }, - { 0x0009ea, 6612 }, - { 0x0001b3, 1379 }, - { 0x00006d, 357 }, - { 0x0000af, 562 }, - { 0x000af7, 7729 }, - { 0x000af0, 7649 }, - { 0x000abf, 7059 }, - { 0x0000ba, 666 }, - { 0x00002d, 121 }, - { 0x000ad6, 7315 }, - { 0x0000b5, 618 }, - { 0x0000d7, 932 }, - { 0x000af6, 7717 }, - { 0x000af5, 7704 }, - { 0x00006e, 359 }, - { 0x0008c5, 6370 }, - { 0x0001f1, 1658 }, - { 0x0001f2, 1665 }, - { 0x0003f1, 2185 }, - { 0x0009e8, 6606 }, - { 0x0000a0, 421 }, - { 0x0008bd, 6306 }, - { 0x0000ac, 536 }, - { 0x0000f1, 1153 }, - { 0x000023, 22 }, - { 0x0006b0, 3775 }, - { 0x00006f, 361 }, - { 0x0000f3, 1167 }, - { 0x0000f4, 1174 }, - { 0x0000f6, 1193 }, - { 0x0001f5, 1672 }, - { 0x0013bd, 11015 }, - { 0x0001b2, 1372 }, - { 0x0000f2, 1160 }, - { 0x0003f2, 2194 }, - { 0x000ac3, 7066 }, - { 0x000ab2, 6934 }, - { 0x0000bd, 702 }, - { 0x0000bc, 691 }, - { 0x000ab6, 6976 }, - { 0x0000b9, 654 }, - { 0x000ab0, 6915 }, - { 0x000ae2, 7473 }, - { 0x000ae5, 7522 }, - { 0x000ae4, 7504 }, - { 0x000ae3, 7488 }, - { 0x0000aa, 510 }, - { 0x0000f8, 1213 }, - { 0x0000f5, 1186 }, - { 0x000bc0, 7891 }, - { 0x00047e, 2234 }, - { 0x000070, 363 }, - { 0x0000b6, 621 }, - { 0x000028, 80 }, - { 0x000029, 90 }, - { 0x0008ef, 6496 }, - { 0x000025, 40 }, - { 0x00002e, 127 }, - { 0x0000b7, 631 }, - { 0x000afb, 7781 }, - { 0x00002b, 110 }, - { 0x0000b1, 576 }, - { 0x000ad4, 7302 }, - { 0x0004b0, 2424 }, - { 0x000aa6, 6833 }, - { 0x000071, 365 }, - { 0x000bcc, 7938 }, - { 0x00003f, 195 }, - { 0x0000bf, 724 }, - { 0x000022, 13 }, - { 0x000060, 323 }, - { 0x000027, 69 }, - { 0x000072, 367 }, - { 0x0001e0, 1593 }, - { 0x0008d6, 6428 }, - { 0x0001f8, 1685 }, - { 0x0003b3, 2011 }, - { 0x0000ae, 551 }, - { 0x000abe, 7041 }, - { 0x0008fd, 6541 }, - { 0x000ba6, 7862 }, - { 0x000ad3, 7281 }, - { 0x0008b0, 6127 }, - { 0x0008b7, 6271 }, - { 0x000acd, 7173 }, - { 0x000aeb, 7617 }, - { 0x000bd8, 7974 }, - { 0x000ad1, 7240 }, - { 0x0009f5, 6763 }, - { 0x000bfc, 8002 }, - { 0x000073, 369 }, - { 0x0001b6, 1394 }, - { 0x0001b9, 1407 }, - { 0x0001ba, 1414 }, - { 0x0002fe, 1940 }, - { 0x00ff7e, 13942 }, - { 0x000ad7, 7323 }, - { 0x0000a7, 482 }, - { 0x00003b, 166 }, - { 0x0004df, 2832 }, - { 0x000ac6, 7101 }, - { 0x000aca, 7124 }, - { 0x000aac, 6878 }, - { 0x0008c9, 6388 }, - { 0x000afd, 7807 }, - { 0x00002f, 134 }, - { 0x0009e0, 6568 }, - { 0x000020, 0 }, - { 0x0000df, 1006 }, - { 0x0000a3, 450 }, - { 0x000074, 371 }, - { 0x0001bb, 1423 }, - { 0x0001fe, 1711 }, - { 0x000af9, 7753 }, - { 0x000afa, 7763 }, - { 0x0008c0, 6341 }, - { 0x000aa7, 6844 }, - { 0x0000fe, 1264 }, - { 0x000ac4, 7076 }, - { 0x000ab4, 6953 }, - { 0x0000be, 710 }, - { 0x0000b3, 598 }, - { 0x0008a4, 5940 }, - { 0x0008ab, 6048 }, - { 0x0008a2, 5910 }, - { 0x0008a7, 5978 }, - { 0x0008b1, 6149 }, - { 0x0008ad, 6076 }, - { 0x0008a9, 6012 }, - { 0x0008b5, 6235 }, - { 0x0009f7, 6775 }, - { 0x0008b3, 6183 }, - { 0x000ac9, 7114 }, - { 0x000acb, 7138 }, - { 0x0003bc, 2053 }, - { 0x000ab3, 6943 }, - { 0x0000b2, 586 }, - { 0x000ab1, 6924 }, - { 0x000075, 373 }, - { 0x0000fa, 1227 }, - { 0x0002fd, 1933 }, - { 0x0000fb, 1234 }, - { 0x0000fc, 1246 }, - { 0x0001fb, 1698 }, - { 0x0000f9, 1220 }, - { 0x0003fe, 2226 }, - { 0x000bc6, 7925 }, - { 0x00005f, 306 }, - { 0x0008dd, 6469 }, - { 0x0003f9, 2211 }, - { 0x0008fc, 6533 }, - { 0x000ba9, 7883 }, - { 0x0009ec, 6641 }, - { 0x0009eb, 6627 }, - { 0x000bc3, 7908 }, - { 0x000bd3, 7957 }, - { 0x000bce, 7943 }, - { 0x0001f9, 1692 }, - { 0x0003fd, 2219 }, - { 0x000076, 375 }, - { 0x0008c1, 6351 }, - { 0x0009f8, 6780 }, - { 0x0008a6, 5964 }, - { 0x0004de, 2820 }, - { 0x0009e9, 6609 }, - { 0x000077, 377 }, - { 0x000078, 379 }, - { 0x000079, 381 }, - { 0x0000fd, 1257 }, - { 0x0000ff, 1270 }, - { 0x0000a5, 468 }, - { 0x00007a, 383 }, - { 0x0001bf, 1456 }, - { 0x0001bc, 1430 }, - { 0x0001be, 1449 } -}; + {0x000030, 140}, {0x000031, 142}, {0x000032, 144}, {0x000033, 146}, + {0x00fd10, 11341}, {0x00fd0e, 11314}, {0x00fd05, 11213}, {0x00fd19, 11444}, + {0x00fd15, 11401}, {0x00fd0f, 11324}, {0x00fd1c, 11492}, {0x00fd1a, 11462}, + {0x00fd01, 11160}, {0x00fd1e, 11527}, {0x00fd06, 11226}, {0x00fd07, 11240}, + {0x00fd1b, 11478}, {0x00fd02, 11175}, {0x00fd13, 11380}, {0x00fd12, 11370}, + {0x00fd11, 11356}, {0x00fd04, 11202}, {0x00fd0a, 11277}, {0x00fd0b, 11286}, + {0x00fd0c, 11295}, {0x00fd16, 11411}, {0x00fd1d, 11510}, {0x00fd09, 11267}, + {0x00fd18, 11432}, {0x00fd08, 11256}, {0x00fd03, 11190}, {0x00fd14, 11391}, + {0x00fd17, 11421}, {0x00fd0d, 11304}, {0x000034, 148}, {0x000035, 150}, + {0x000036, 152}, {0x000037, 154}, {0x000038, 156}, {0x000039, 158}, + {0x000041, 207}, {0x0000c6, 787}, {0x0000c1, 744}, {0x0001c3, 1473}, + {0x00fe70, 12471}, {0x00fe71, 12486}, {0x0000c2, 751}, {0x0000c4, 770}, + {0x0000c0, 737}, {0x00ffe9, 14456}, {0x00ffea, 14462}, {0x0003c0, 2068}, + {0x0001a1, 1281}, {0x0005d9, 3221}, {0x0005c7, 3008}, {0x0005e9, 3360}, + {0x0005c8, 3020}, {0x0005ac, 2848}, {0x0005d6, 3188}, {0x0005cf, 3107}, + {0x0005ef, 3451}, {0x0005ec, 3406}, {0x0005ee, 3438}, {0x0005eb, 3390}, + {0x0005e1, 3260}, {0x0005da, 3232}, {0x0005e7, 3328}, {0x0005cd, 3084}, + {0x0005c1, 2899}, {0x0005c3, 2931}, {0x0005c4, 2950}, {0x0005c6, 2990}, + {0x0005c5, 2968}, {0x0005e7, 3338}, {0x0005cc, 3072}, {0x0005e3, 3282}, + {0x0005f0, 3464}, {0x0005ed, 3422}, {0x0005ce, 3095}, {0x0005e4, 3293}, + {0x0005c2, 2912}, {0x0005e5, 3304}, {0x0005e6, 3316}, {0x0005e2, 3271}, + {0x0005bf, 2878}, {0x0005d1, 3130}, {0x0005d5, 3177}, {0x0005d3, 3152}, + {0x0005bb, 2861}, {0x0005f1, 3477}, {0x0005d4, 3164}, {0x0005f2, 3491}, + {0x00ff7e, 13847}, {0x0005d7, 3199}, {0x0005e0, 3245}, {0x0005ca, 3049}, + {0x0005c9, 3031}, {0x0005d0, 3118}, {0x0005cb, 3060}, {0x0005e8, 3349}, + {0x0005ea, 3379}, {0x0005d8, 3210}, {0x0005d2, 3140}, {0x0000c5, 781}, + {0x0000c3, 763}, {0x00fe7a, 12652}, {0x000042, 209}, {0x00ff08, 13264}, + {0x00ff58, 13775}, {0x00fe74, 12544}, {0x00ff6b, 13841}, {0x0006be, 4011}, + {0x0006ae, 3729}, {0x000043, 211}, {0x0002c5, 1826}, {0x0001c6, 1487}, + {0x00ff69, 13829}, {0x00ffe5, 14421}, {0x0001c8, 1494}, {0x0000c7, 790}, + {0x0002c6, 1836}, {0x00ff0b, 13287}, {0x00ff37, 13581}, {0x0020a1, 11037}, + {0x00ffe3, 14401}, {0x00ffe4, 14411}, {0x0020a2, 11047}, {0x0006e1, 4474}, + {0x0006e2, 4485}, {0x0006fe, 4836}, {0x0006e4, 4510}, {0x0006bf, 4031}, + {0x0006fc, 4810}, {0x0006e6, 4534}, {0x0006ec, 4610}, {0x0006ed, 4622}, + {0x0006ee, 4634}, {0x0006f2, 4681}, {0x0006f3, 4693}, {0x0006e7, 4546}, + {0x0006e8, 4559}, {0x0006ff, 4849}, {0x0006e9, 4571}, {0x0006e5, 4522}, + {0x0006b3, 3812}, {0x0006b8, 3911}, {0x0006eb, 4598}, {0x0006b9, 3934}, + {0x0006ba, 3959}, {0x0006ef, 4646}, {0x0006f0, 4657}, {0x0006fb, 4797}, + {0x0006fd, 4821}, {0x0006ea, 4582}, {0x0006f8, 4753}, {0x0006f4, 4705}, + {0x0006e3, 4497}, {0x0006f5, 4717}, {0x0006f7, 4741}, {0x0006f1, 4669}, + {0x0006f9, 4771}, {0x0006e0, 4462}, {0x0006fa, 4785}, {0x0006f6, 4728}, + {0x0006c1, 4069}, {0x0006c2, 4080}, {0x0006de, 4431}, {0x0006c4, 4105}, + {0x0006af, 3749}, {0x0006dc, 4405}, {0x0006c6, 4129}, {0x0006cc, 4205}, + {0x0006cd, 4217}, {0x0006ce, 4229}, {0x0006d2, 4276}, {0x0006d3, 4288}, + {0x0006c7, 4141}, {0x0006c8, 4154}, {0x0006df, 4444}, {0x0006c9, 4166}, + {0x0006c5, 4117}, {0x0006a3, 3530}, {0x0006a8, 3629}, {0x0006cb, 4193}, + {0x0006a9, 3652}, {0x0006aa, 3677}, {0x0006cf, 4241}, {0x0006d0, 4252}, + {0x0006db, 4392}, {0x0006dd, 4416}, {0x0006ca, 4177}, {0x0006d8, 4348}, + {0x0006d4, 4300}, {0x0006c3, 4092}, {0x0006d5, 4312}, {0x0006d7, 4336}, + {0x0006d1, 4264}, {0x0006d9, 4366}, {0x0006c0, 4057}, {0x0006da, 4380}, + {0x0006d6, 4323}, {0x000044, 213}, {0x0001cf, 1516}, {0x00ffff, 14500}, + {0x0020ab, 11142}, {0x00ff54, 13737}, {0x0001d0, 1523}, {0x000045, 215}, + {0x0003bd, 2060}, {0x0000d0, 873}, {0x0003cc, 2084}, {0x0000c9, 806}, + {0x0001cc, 1509}, {0x0000ca, 813}, {0x0020a0, 11029}, {0x0000cb, 825}, + {0x0000c8, 799}, {0x00ff2f, 13488}, {0x00ff30, 13499}, {0x0003aa, 1987}, + {0x00ff57, 13771}, {0x0001ca, 1501}, {0x00ff1b, 13326}, {0x0000d0, 877}, + {0x0020ac, 11151}, {0x00ff62, 13794}, {0x000046, 217}, {0x00ffbe, 14254}, + {0x00ffc7, 14281}, {0x00ffc8, 14285}, {0x00ffc9, 14289}, {0x00ffca, 14293}, + {0x00ffcb, 14297}, {0x00ffcc, 14301}, {0x00ffcd, 14305}, {0x00ffce, 14309}, + {0x00ffcf, 14313}, {0x00ffd0, 14317}, {0x00ffbf, 14257}, {0x00ffd1, 14321}, + {0x00ffd2, 14325}, {0x00ffd3, 14329}, {0x00ffd4, 14333}, {0x00ffd5, 14337}, + {0x00ffd6, 14341}, {0x00ffd7, 14345}, {0x00ffd8, 14349}, {0x00ffd9, 14353}, + {0x00ffda, 14357}, {0x00ffc0, 14260}, {0x00ffdb, 14361}, {0x00ffdc, 14365}, + {0x00ffdd, 14369}, {0x00ffde, 14373}, {0x00ffdf, 14377}, {0x00ffe0, 14381}, + {0x00ffc1, 14263}, {0x00ffc2, 14266}, {0x00ffc3, 14269}, {0x00ffc4, 14272}, + {0x00ffc5, 14275}, {0x00ffc6, 14278}, {0x0020a3, 11060}, {0x00ff68, 13824}, + {0x00fed0, 12671}, {0x000047, 219}, {0x0002d5, 1848}, {0x0002ab, 1759}, + {0x0003ab, 1995}, {0x0002d8, 1858}, {0x0007c1, 5316}, {0x0007a1, 4867}, + {0x0007c2, 5328}, {0x0007d7, 5564}, {0x0007c4, 5351}, {0x0007c5, 5363}, + {0x0007a2, 4885}, {0x0007c7, 5388}, {0x0007a3, 4905}, {0x0007c3, 5339}, + {0x0007c9, 5410}, {0x0007a4, 4921}, {0x0007a5, 4957}, {0x0007a5, 4938}, + {0x0007ca, 5421}, {0x0007cb, 5433}, {0x0007cb, 5446}, {0x0007cc, 5458}, + {0x0007cd, 5467}, {0x0007d9, 5584}, {0x0007ab, 5039}, {0x0007cf, 5485}, + {0x0007a7, 4977}, {0x0007d6, 5554}, {0x0007d0, 5499}, {0x0007d8, 5574}, + {0x0007d1, 5508}, {0x0007d2, 5518}, {0x0007d4, 5530}, {0x0007c8, 5398}, + {0x0007d5, 5540}, {0x0007a8, 4997}, {0x0007a9, 5017}, {0x0007ce, 5476}, + {0x0007c6, 5377}, {0x0007ae, 5057}, {0x0007e1, 5596}, {0x0007b1, 5093}, + {0x0007e2, 5608}, {0x0007f7, 5866}, {0x0007e4, 5631}, {0x0007e5, 5643}, + {0x0007b2, 5111}, {0x0007e7, 5668}, {0x0007b3, 5131}, {0x0007f3, 5810}, + {0x0007e3, 5619}, {0x0007af, 5078}, {0x0007e9, 5690}, {0x0007b4, 5147}, + {0x0007b6, 5183}, {0x0007b5, 5164}, {0x0007ea, 5701}, {0x0007eb, 5713}, + {0x0007eb, 5726}, {0x0007ec, 5738}, {0x0007ed, 5747}, {0x0007f9, 5886}, + {0x0007bb, 5298}, {0x0007ef, 5765}, {0x0007b7, 5208}, {0x0007f6, 5856}, + {0x0007f0, 5779}, {0x0007f8, 5876}, {0x0007f1, 5788}, {0x0007f2, 5798}, + {0x00ff7e, 13861}, {0x0007f4, 5832}, {0x0007e8, 5678}, {0x0007f5, 5842}, + {0x0007b8, 5228}, {0x0007ba, 5270}, {0x0007b9, 5248}, {0x0007ee, 5756}, + {0x0007e6, 5657}, {0x000048, 221}, {0x00ff31, 13511}, {0x000ebf, 10068}, + {0x000ec0, 10077}, {0x000ef6, 10909}, {0x000ef7, 10922}, {0x00ff39, 13605}, + {0x000eba, 10001}, {0x000ea7, 9694}, {0x000ec4, 10118}, {0x000ec3, 10108}, + {0x000ed1, 10248}, {0x00ff33, 13531}, {0x00ff34, 13542}, {0x000ebe, 10055}, + {0x000ed3, 10268}, {0x000eb7, 9957}, {0x000eea, 10673}, {0x000eda, 10389}, + {0x000eee, 10735}, {0x000ee8, 10643}, {0x000ee9, 10658}, {0x000eeb, 10688}, + {0x000ed4, 10277}, {0x000ed6, 10314}, {0x000ef9, 10953}, {0x000ee3, 10561}, + {0x000ed7, 10334}, {0x000ed9, 10369}, {0x000ed8, 10349}, {0x000ef8, 10936}, + {0x000eed, 10719}, {0x000ee4, 10576}, {0x000ee5, 10591}, {0x000edb, 10405}, + {0x000ee2, 10541}, {0x000edc, 10420}, {0x000edd, 10441}, {0x000ee1, 10520}, + {0x000ede, 10461}, {0x000edf, 10481}, {0x000ee0, 10500}, {0x000ee6, 10610}, + {0x000ed5, 10293}, {0x000ee7, 10624}, {0x000eec, 10704}, {0x000efa, 10980}, + {0x00ff35, 13555}, {0x00ff38, 13591}, {0x000eb8, 9970}, {0x000ebb, 10014}, + {0x000ea1, 9594}, {0x000ea3, 9627}, {0x000ef3, 10839}, {0x000eb1, 9867}, + {0x000ea4, 9645}, {0x000ea6, 9676}, {0x000ea5, 9658}, {0x000ec7, 10148}, + {0x000eca, 10178}, {0x000ef2, 10824}, {0x000ebd, 10041}, {0x000eb2, 9880}, + {0x000eb4, 9911}, {0x00ff3b, 13634}, {0x00ff3a, 13618}, {0x000ea9, 9727}, + {0x000eb0, 9849}, {0x000eaa, 9740}, {0x000eab, 9759}, {0x000eaf, 9830}, + {0x000eac, 9777}, {0x000ead, 9795}, {0x000eae, 9812}, {0x000eef, 10750}, + {0x00ff36, 13567}, {0x000eb5, 9928}, {0x00ff3f, 13703}, {0x000ea8, 9708}, + {0x000eb9, 9983}, {0x000ea2, 9608}, {0x000eb3, 9893}, {0x000eb6, 9940}, + {0x00ff32, 13518}, {0x000ef0, 10774}, {0x000ef4, 10864}, {0x000ef1, 10799}, + {0x000ebc, 10028}, {0x000ecc, 10198}, {0x000ec8, 10157}, {0x000ec9, 10167}, + {0x000ece, 10218}, {0x000ecd, 10207}, {0x000ecf, 10228}, {0x000ec1, 10087}, + {0x000ec2, 10097}, {0x000ec6, 10138}, {0x000ec5, 10127}, {0x000ed2, 10258}, + {0x000ecb, 10188}, {0x000ed0, 10238}, {0x000ef5, 10890}, {0x00ff7e, 13874}, + {0x00ff29, 13428}, {0x0002a6, 1737}, {0x00ff7e, 13888}, {0x00ff6a, 13836}, + {0x00ff23, 13358}, {0x00ff23, 13365}, {0x00ff25, 13384}, {0x00ff27, 13402}, + {0x00ff50, 13718}, {0x0002a1, 1729}, {0x00ffed, 14484}, {0x00ffee, 14492}, + {0x000049, 223}, {0x00fe33, 12190}, {0x00fe30, 12123}, {0x00fe31, 12148}, + {0x00fe32, 12176}, {0x00fe34, 12208}, {0x00fe2f, 12102}, {0x00fe2c, 12040}, + {0x00fe2d, 12061}, {0x00fe2e, 12083}, {0x00fe0c, 11715}, {0x00fe0d, 11731}, + {0x00fe06, 11614}, {0x00fe07, 11630}, {0x00ff7e, 13902}, {0x00fe0e, 11752}, + {0x00fe0f, 11767}, {0x00fe20, 11787}, {0x00fe02, 11547}, {0x00fe04, 11581}, + {0x00fe05, 11598}, {0x00fe03, 11564}, {0x00fe01, 11538}, {0x00fe22, 11817}, + {0x00fe21, 11800}, {0x00fe08, 11645}, {0x00fe09, 11660}, {0x00fe24, 11856}, + {0x00fe23, 11836}, {0x00fe25, 11878}, {0x00fe26, 11901}, {0x00fe0a, 11680}, + {0x00fe0b, 11695}, {0x00fe2b, 12015}, {0x00fe29, 11966}, {0x00fe2a, 11990}, + {0x00fe27, 11925}, {0x00fe28, 11945}, {0x0002a9, 1749}, {0x0000cd, 843}, + {0x0000ce, 850}, {0x0000cf, 862}, {0x0000cc, 836}, {0x0003cf, 2094}, + {0x00ff63, 13802}, {0x0003c7, 2076}, {0x0003a5, 1971}, {0x00004a, 225}, + {0x0002ac, 1766}, {0x00004b, 227}, {0x00ffb0, 14195}, {0x00ffb1, 14200}, + {0x00ffb2, 14205}, {0x00ffb3, 14210}, {0x00ffb4, 14215}, {0x00ffb5, 14220}, + {0x00ffb6, 14225}, {0x00ffb7, 14230}, {0x00ffb8, 14235}, {0x00ffb9, 14240}, + {0x00ffab, 14142}, {0x00ff9d, 14101}, {0x00ffae, 14174}, {0x00ff9f, 14120}, + {0x00ffaf, 14185}, {0x00ff99, 14045}, {0x00ff9c, 14094}, {0x00ff8d, 13981}, + {0x00ffbd, 14245}, {0x00ff91, 13990}, {0x00ff92, 13996}, {0x00ff93, 14002}, + {0x00ff94, 14008}, {0x00ff95, 14014}, {0x00ff9e, 14110}, {0x00ff96, 14022}, + {0x00ffaa, 14130}, {0x00ff9b, 14086}, {0x00ff9b, 14073}, {0x00ff9a, 14053}, + {0x00ff9a, 14064}, {0x00ff98, 14036}, {0x00ffac, 14149}, {0x00ff80, 13965}, + {0x00ffad, 14162}, {0x00ff89, 13974}, {0x00ff97, 14030}, {0x00ff2d, 13467}, + {0x00ff2e, 13477}, {0x00ff21, 13343}, {0x00ff26, 13393}, {0x0003d3, 2119}, + {0x000eff, 11001}, {0x00004c, 229}, {0x0001c5, 1480}, {0x00fed4, 12732}, + {0x0001a5, 1303}, {0x0003a6, 1978}, {0x00ff51, 13723}, {0x00ff0a, 13278}, + {0x0020a4, 11071}, {0x0001a3, 1295}, {0x00004d, 231}, {0x0006b5, 3849}, + {0x0006b2, 3798}, {0x0006bc, 3997}, {0x0006a5, 3567}, {0x0006a2, 3516}, + {0x0006ac, 3715}, {0x00ff2c, 13460}, {0x00ff67, 13819}, {0x00ffe7, 14442}, + {0x00ffe8, 14449}, {0x0020a5, 11080}, {0x00ff7e, 13918}, {0x00fe77, 12597}, + {0x00fe76, 12580}, {0x00ff22, 13349}, {0x00ff20, 13333}, {0x00ff3d, 13667}, + {0x00004e, 233}, {0x0001d1, 1531}, {0x0020a6, 11089}, {0x0001d2, 1538}, + {0x0003d1, 2102}, {0x0020aa, 11128}, {0x00ff56, 13766}, {0x00fed2, 12712}, + {0x0000d1, 881}, {0x00ff7f, 13956}, {0x00004f, 235}, {0x0013bc, 11012}, + {0x0000d3, 895}, {0x0000d4, 902}, {0x0000d6, 921}, {0x0001d5, 1545}, + {0x0000d2, 888}, {0x0003d2, 2111}, {0x0000d8, 941}, {0x0000d5, 914}, + {0x00fe78, 12620}, {0x00fe79, 12636}, {0x000050, 237}, {0x00ff56, 13756}, + {0x00ff55, 13742}, {0x00ff13, 13300}, {0x0020a7, 11099}, {0x00fefa, 13191}, + {0x00fee9, 12906}, {0x00feea, 12922}, {0x00feeb, 12938}, {0x00feec, 12954}, + {0x00feed, 12970}, {0x00fee8, 12886}, {0x00feef, 13008}, {0x00fef0, 13026}, + {0x00fef1, 13044}, {0x00fef2, 13062}, {0x00fef3, 13080}, {0x00feee, 12986}, + {0x00fefb, 13210}, {0x00fefc, 13230}, {0x00fee3, 12807}, {0x00fee6, 12851}, + {0x00fee7, 12868}, {0x00fef5, 13116}, {0x00fef6, 13130}, {0x00fef7, 13144}, + {0x00fef8, 13158}, {0x00fefd, 13250}, {0x00fef4, 13098}, {0x00fef9, 13172}, + {0x00fee0, 12769}, {0x00fee1, 12782}, {0x00fee2, 12796}, {0x00fee4, 12820}, + {0x00fee5, 12835}, {0x00fed1, 12692}, {0x00ff3e, 13685}, {0x00ff61, 13788}, + {0x00ff55, 13750}, {0x000051, 239}, {0x000052, 241}, {0x0001c0, 1466}, + {0x0001d8, 1558}, {0x0003a3, 1962}, {0x00ff66, 13814}, {0x00fe72, 12510}, + {0x00ff0d, 13293}, {0x00ff53, 13731}, {0x00ff24, 13377}, {0x0020a8, 11110}, + {0x000053, 243}, {0x0001a6, 1310}, {0x0001a9, 1317}, {0x0001aa, 1324}, + {0x0002de, 1877}, {0x00ff14, 13306}, {0x00ff60, 13781}, {0x0006b1, 3786}, + {0x0006bf, 4045}, {0x0006b8, 3923}, {0x0006b9, 3947}, {0x0006ba, 3972}, + {0x0006bb, 3984}, {0x0006a1, 3504}, {0x0006af, 3763}, {0x0006a8, 3641}, + {0x0006a9, 3665}, {0x0006aa, 3690}, {0x0006ab, 3702}, {0x00ffe1, 14385}, + {0x00ffe6, 14431}, {0x00ffe2, 14393}, {0x00ff3c, 13651}, {0x00fe73, 12528}, + {0x00fe75, 12562}, {0x00ffeb, 14468}, {0x00ffec, 14476}, {0x00ff15, 13318}, + {0x000054, 245}, {0x0000de, 994}, {0x00ff09, 13274}, {0x0001ab, 1333}, + {0x0001de, 1584}, {0x00fed5, 12752}, {0x000ddf, 9260}, {0x000dba, 8843}, + {0x000da8, 8607}, {0x000daa, 8634}, {0x000da9, 8620}, {0x000dac, 8658}, + {0x000dae, 8683}, {0x000db4, 8768}, {0x000dbd, 8882}, {0x000dbf, 8905}, + {0x000dcb, 9039}, {0x000dce, 9073}, {0x000da2, 8525}, {0x000da5, 8566}, + {0x000da3, 8538}, {0x000da4, 8552}, {0x000da6, 8579}, {0x000da1, 8514}, + {0x000de5, 9343}, {0x000df7, 9556}, {0x000df5, 9533}, {0x000df6, 9544}, + {0x000df9, 9582}, {0x000df1, 9484}, {0x000df8, 9569}, {0x000df3, 9510}, + {0x000df4, 9522}, {0x000df2, 9497}, {0x000df0, 9472}, {0x000dcc, 9050}, + {0x000dc5, 8972}, {0x000dc6, 8984}, {0x000deb, 9424}, {0x000de8, 9389}, + {0x000dd1, 9113}, {0x000dde, 9237}, {0x000de7, 9374}, {0x000de9, 9400}, + {0x000dea, 9412}, {0x000de6, 9360}, {0x000dc1, 8932}, {0x000da7, 8595}, + {0x000ded, 9458}, {0x000db3, 8757}, {0x000db9, 8833}, {0x000dcd, 9063}, + {0x000dcf, 9087}, {0x000dda, 9224}, {0x000dbe, 8892}, {0x000dbc, 8868}, + {0x000dc0, 8916}, {0x000dbb, 8857}, {0x000dc3, 8953}, {0x000dc4, 8964}, + {0x000dd0, 9102}, {0x000dd2, 9129}, {0x000de1, 9281}, {0x000de4, 9323}, + {0x000de3, 9304}, {0x000dd3, 9141}, {0x000de0, 9270}, {0x000dd4, 9153}, + {0x000dd5, 9164}, {0x000de2, 9293}, {0x000dd8, 9201}, {0x000dd6, 9176}, + {0x000dd7, 9188}, {0x000dd9, 9212}, {0x000dc9, 9016}, {0x000dc8, 9004}, + {0x000dab, 8648}, {0x000dca, 9028}, {0x000dec, 9441}, {0x000db1, 8722}, + {0x000db2, 8741}, {0x000db7, 8804}, {0x000db0, 8709}, {0x000db8, 8819}, + {0x000db6, 8790}, {0x000daf, 8696}, {0x000db5, 8779}, {0x000dc7, 8992}, + {0x000dc2, 8942}, {0x000dad, 8671}, {0x0000de, 1000}, {0x00ff2b, 13452}, + {0x0003ac, 2004}, {0x000055, 247}, {0x0000da, 957}, {0x0002dd, 1870}, + {0x0000db, 964}, {0x0000dc, 976}, {0x0001db, 1571}, {0x0000d9, 950}, + {0x0006b6, 3863}, {0x0006b4, 3824}, {0x0006b7, 3886}, {0x0006a6, 3581}, + {0x0006a4, 3542}, {0x0006a7, 3604}, {0x0006b6, 3875}, {0x0006b4, 3837}, + {0x0006b7, 3899}, {0x0006a6, 3593}, {0x0006a4, 3555}, {0x0006a7, 3617}, + {0x0003de, 2143}, {0x00ff65, 13809}, {0x0003d9, 2128}, {0x00ff52, 13728}, + {0x0001d9, 1565}, {0x0003dd, 2136}, {0x000056, 249}, {0xffffff, 14507}, + {0x000057, 251}, {0x0020a9, 11120}, {0x000058, 253}, {0x000059, 255}, + {0x0000dd, 987}, {0x0013be, 11018}, {0x00005a, 257}, {0x0001af, 1354}, + {0x0001ac, 1340}, {0x0001ae, 1347}, {0x00ff28, 13420}, {0x00ff2a, 13436}, + {0x000061, 333}, {0x0000e1, 1020}, {0x0001ff, 1720}, {0x0001e3, 1600}, + {0x0000e2, 1027}, {0x0000b4, 612}, {0x0000e4, 1046}, {0x0000e6, 1063}, + {0x0000e0, 1013}, {0x0003e0, 2151}, {0x000026, 48}, {0x0001b1, 1364}, + {0x000027, 58}, {0x0008c8, 6376}, {0x0000e5, 1057}, {0x00005e, 294}, + {0x00007e, 410}, {0x00002a, 101}, {0x000040, 204}, {0x0000e3, 1039}, + {0x000062, 335}, {0x00005c, 271}, {0x000af4, 7692}, {0x00007c, 395}, + {0x0009df, 6562}, {0x0008a5, 5952}, {0x0008ac, 6062}, {0x0008a8, 5995}, + {0x0008b2, 6166}, {0x0008ae, 6091}, {0x0008aa, 6030}, {0x0008b6, 6253}, + {0x0009f6, 6770}, {0x0008b4, 6209}, {0x00007b, 385}, {0x00007d, 399}, + {0x00005b, 259}, {0x00005d, 281}, {0x0001a2, 1289}, {0x0000a6, 472}, + {0x000063, 337}, {0x0002e5, 1889}, {0x0001e6, 1614}, {0x000ab8, 6996}, + {0x000afc, 7801}, {0x0001b7, 1401}, {0x0001e8, 1621}, {0x0000e7, 1066}, + {0x0002e6, 1899}, {0x0000b8, 646}, {0x0000a2, 445}, {0x0009e1, 6581}, + {0x000af3, 7682}, {0x000bcf, 7950}, {0x000aec, 7630}, {0x00003a, 160}, + {0x00002c, 115}, {0x0000a9, 500}, {0x0009e4, 6600}, {0x0009ee, 6668}, + {0x0000a4, 459}, {0x000aff, 7845}, {0x000064, 339}, {0x000af1, 7662}, + {0x0001ef, 1643}, {0x00fe56, 12290}, {0x00fe58, 12319}, {0x00fe51, 12229}, + {0x00fe60, 12437}, {0x00fe55, 12279}, {0x00fe5a, 12351}, {0x00fe5b, 12362}, + {0x00fe52, 12240}, {0x00fe57, 12304}, {0x00fe59, 12334}, {0x00fe50, 12218}, + {0x00fe61, 12451}, {0x00fe62, 12461}, {0x00fe5d, 12387}, {0x00fe54, 12267}, + {0x00fe5c, 12375}, {0x00fe5f, 12415}, {0x00fe53, 12256}, {0x00fe5e, 12397}, + {0x000abd, 7028}, {0x0000b0, 569}, {0x0000a8, 490}, {0x000aed, 7635}, + {0x000aa5, 6822}, {0x0000f7, 1204}, {0x000024, 33}, {0x000aaf, 6899}, + {0x0001bd, 1437}, {0x000af2, 7669}, {0x000afe, 7826}, {0x0008fe, 6552}, + {0x000ba8, 7873}, {0x000bd6, 7965}, {0x000bc4, 7915}, {0x000bc2, 7899}, + {0x0001f0, 1650}, {0x000065, 341}, {0x0003ec, 2167}, {0x0000e9, 1082}, + {0x0001ec, 1636}, {0x0000ea, 1089}, {0x0000eb, 1101}, {0x0000e8, 1075}, + {0x000aae, 6890}, {0x000aa3, 6804}, {0x000aa4, 6813}, {0x0003ba, 2036}, + {0x000aa9, 6864}, {0x000ade, 7409}, {0x000adf, 7424}, {0x000ace, 7191}, + {0x000acf, 7204}, {0x000aa1, 6788}, {0x000aaa, 6871}, {0x000ae6, 7531}, + {0x000ae7, 7550}, {0x0003bf, 2064}, {0x000ae0, 7437}, {0x000ae1, 7454}, + {0x000aa2, 6796}, {0x0001ea, 1628}, {0x00003d, 181}, {0x0000f0, 1149}, + {0x000021, 6}, {0x0000a1, 434}, {0x000066, 343}, {0x000af8, 7740}, + {0x0009e3, 6597}, {0x000abb, 7003}, {0x000adc, 7368}, {0x000adb, 7351}, + {0x000add, 7388}, {0x000ae9, 7585}, {0x000ae8, 7567}, {0x000ac5, 7089}, + {0x000ab7, 6985}, {0x000ab5, 6965}, {0x0008f6, 6514}, {0x000067, 345}, + {0x0002f5, 1911}, {0x0002bb, 1807}, {0x0003bb, 2044}, {0x0002f8, 1921}, + {0x000060, 317}, {0x00003e, 187}, {0x0008be, 6315}, {0x0000ab, 522}, + {0x0000bb, 676}, {0x000068, 347}, {0x000aa8, 6854}, {0x0002b6, 1786}, + {0x000aee, 7643}, {0x000ce0, 8033}, {0x000cf2, 8350}, {0x000ce1, 8046}, + {0x000ce1, 8057}, {0x000ce7, 8169}, {0x000ce3, 8096}, {0x000ce3, 8109}, + {0x000cdf, 8012}, {0x000cea, 8226}, {0x000ced, 8268}, {0x000cef, 8295}, + {0x000cf3, 8362}, {0x000cf5, 8387}, {0x000cf5, 8404}, {0x000ce2, 8069}, + {0x000ce2, 8082}, {0x000ce4, 8123}, {0x000ce7, 8181}, {0x000ceb, 8243}, + {0x000cf7, 8445}, {0x000cec, 8255}, {0x000cee, 8284}, {0x000cf0, 8311}, + {0x000cf4, 8377}, {0x000cf7, 8456}, {0x000cf8, 8468}, {0x000cf1, 8322}, + {0x000cf1, 8336}, {0x000cf9, 8480}, {0x000cfa, 8492}, {0x000cfa, 8503}, + {0x000ce8, 8192}, {0x000ce8, 8203}, {0x000ce5, 8133}, {0x000ce9, 8215}, + {0x000cf6, 8421}, {0x000cf6, 8433}, {0x000ce6, 8144}, {0x000ce6, 8156}, + {0x000ada, 7342}, {0x0008a3, 5925}, {0x0009ef, 6682}, {0x0009f0, 6697}, + {0x0009f1, 6712}, {0x0009f2, 6727}, {0x0009f3, 6742}, {0x0002b1, 1778}, + {0x0009e2, 6594}, {0x0000ad, 544}, {0x000069, 349}, {0x0000ed, 1119}, + {0x0000ee, 1126}, {0x0008cf, 6418}, {0x0000ef, 1138}, {0x0002b9, 1798}, + {0x0008cd, 6401}, {0x0000ec, 1112}, {0x0003ef, 2177}, {0x0008ce, 6410}, + {0x0008da, 6436}, {0x0008db, 6447}, {0x0008c2, 6361}, {0x0008bf, 6332}, + {0x0008dc, 6456}, {0x0003e7, 2159}, {0x0003b5, 2020}, {0x00006a, 351}, + {0x0002bc, 1814}, {0x000bca, 7934}, {0x00006b, 353}, {0x0004b1, 2439}, + {0x0004c1, 2563}, {0x0004b4, 2460}, {0x0004cc, 2669}, {0x0004ca, 2653}, + {0x0004cd, 2685}, {0x0004cb, 2661}, {0x0004ce, 2693}, {0x0004cc, 2677}, + {0x0004b2, 2446}, {0x0004b6, 2474}, {0x0004b9, 2498}, {0x0004b7, 2482}, + {0x0004ba, 2506}, {0x0004b8, 2490}, {0x0004cf, 2701}, {0x0004d2, 2725}, + {0x0004d0, 2709}, {0x0004d3, 2733}, {0x0004d1, 2717}, {0x0004dd, 2813}, + {0x0004c5, 2613}, {0x0004c8, 2637}, {0x0004c6, 2621}, {0x0004c9, 2645}, + {0x0004c7, 2629}, {0x0004b5, 2467}, {0x0004d7, 2765}, {0x0004da, 2789}, + {0x0004d8, 2773}, {0x0004db, 2797}, {0x0004d9, 2781}, {0x0004bb, 2514}, + {0x0004be, 2539}, {0x0004bc, 2522}, {0x0004bf, 2547}, {0x0004bd, 2531}, + {0x0004c0, 2555}, {0x0004c3, 2597}, {0x0004c1, 2572}, {0x0004c4, 2605}, + {0x0004c2, 2580}, {0x0004c2, 2589}, {0x0004b3, 2453}, {0x0004dc, 2805}, + {0x0004a6, 2340}, {0x0004d4, 2741}, {0x0004d6, 2757}, {0x0004d5, 2749}, + {0x0004a7, 2348}, {0x0004a3, 2277}, {0x0004a4, 2297}, {0x0004a5, 2308}, + {0x0004aa, 2369}, {0x0004a1, 2243}, {0x0004a8, 2355}, {0x0004a5, 2325}, + {0x0004ab, 2376}, {0x0004a2, 2257}, {0x00ff7e, 13930}, {0x0004af, 2407}, + {0x0004af, 2416}, {0x0004a9, 2362}, {0x0004ac, 2383}, {0x0004ae, 2399}, + {0x0004ad, 2391}, {0x0003a2, 1952}, {0x0003f3, 2202}, {0x0003a2, 1958}, + {0x00006c, 355}, {0x0001e5, 1607}, {0x000ad9, 7331}, {0x0001b5, 1387}, + {0x0003b6, 2027}, {0x000abc, 7011}, {0x0008fb, 6523}, {0x000ba3, 7852}, + {0x000ad2, 7261}, {0x0008af, 6106}, {0x000acc, 7156}, {0x000aea, 7605}, + {0x0008a1, 5898}, {0x000bda, 7984}, {0x000ad0, 7220}, {0x0009f4, 6757}, + {0x000bdc, 7993}, {0x00003c, 176}, {0x0008bc, 6292}, {0x0009e5, 6603}, + {0x0008de, 6475}, {0x0008df, 6486}, {0x0009ed, 6654}, {0x0009ea, 6612}, + {0x0001b3, 1379}, {0x00006d, 357}, {0x0000af, 562}, {0x000af7, 7729}, + {0x000af0, 7649}, {0x000abf, 7059}, {0x0000ba, 666}, {0x00002d, 121}, + {0x000ad6, 7315}, {0x0000b5, 618}, {0x0000d7, 932}, {0x000af6, 7717}, + {0x000af5, 7704}, {0x00006e, 359}, {0x0008c5, 6370}, {0x0001f1, 1658}, + {0x0001f2, 1665}, {0x0003f1, 2185}, {0x0009e8, 6606}, {0x0000a0, 421}, + {0x0008bd, 6306}, {0x0000ac, 536}, {0x0000f1, 1153}, {0x000023, 22}, + {0x0006b0, 3775}, {0x00006f, 361}, {0x0000f3, 1167}, {0x0000f4, 1174}, + {0x0000f6, 1193}, {0x0001f5, 1672}, {0x0013bd, 11015}, {0x0001b2, 1372}, + {0x0000f2, 1160}, {0x0003f2, 2194}, {0x000ac3, 7066}, {0x000ab2, 6934}, + {0x0000bd, 702}, {0x0000bc, 691}, {0x000ab6, 6976}, {0x0000b9, 654}, + {0x000ab0, 6915}, {0x000ae2, 7473}, {0x000ae5, 7522}, {0x000ae4, 7504}, + {0x000ae3, 7488}, {0x0000aa, 510}, {0x0000f8, 1213}, {0x0000f5, 1186}, + {0x000bc0, 7891}, {0x00047e, 2234}, {0x000070, 363}, {0x0000b6, 621}, + {0x000028, 80}, {0x000029, 90}, {0x0008ef, 6496}, {0x000025, 40}, + {0x00002e, 127}, {0x0000b7, 631}, {0x000afb, 7781}, {0x00002b, 110}, + {0x0000b1, 576}, {0x000ad4, 7302}, {0x0004b0, 2424}, {0x000aa6, 6833}, + {0x000071, 365}, {0x000bcc, 7938}, {0x00003f, 195}, {0x0000bf, 724}, + {0x000022, 13}, {0x000060, 323}, {0x000027, 69}, {0x000072, 367}, + {0x0001e0, 1593}, {0x0008d6, 6428}, {0x0001f8, 1685}, {0x0003b3, 2011}, + {0x0000ae, 551}, {0x000abe, 7041}, {0x0008fd, 6541}, {0x000ba6, 7862}, + {0x000ad3, 7281}, {0x0008b0, 6127}, {0x0008b7, 6271}, {0x000acd, 7173}, + {0x000aeb, 7617}, {0x000bd8, 7974}, {0x000ad1, 7240}, {0x0009f5, 6763}, + {0x000bfc, 8002}, {0x000073, 369}, {0x0001b6, 1394}, {0x0001b9, 1407}, + {0x0001ba, 1414}, {0x0002fe, 1940}, {0x00ff7e, 13942}, {0x000ad7, 7323}, + {0x0000a7, 482}, {0x00003b, 166}, {0x0004df, 2832}, {0x000ac6, 7101}, + {0x000aca, 7124}, {0x000aac, 6878}, {0x0008c9, 6388}, {0x000afd, 7807}, + {0x00002f, 134}, {0x0009e0, 6568}, {0x000020, 0}, {0x0000df, 1006}, + {0x0000a3, 450}, {0x000074, 371}, {0x0001bb, 1423}, {0x0001fe, 1711}, + {0x000af9, 7753}, {0x000afa, 7763}, {0x0008c0, 6341}, {0x000aa7, 6844}, + {0x0000fe, 1264}, {0x000ac4, 7076}, {0x000ab4, 6953}, {0x0000be, 710}, + {0x0000b3, 598}, {0x0008a4, 5940}, {0x0008ab, 6048}, {0x0008a2, 5910}, + {0x0008a7, 5978}, {0x0008b1, 6149}, {0x0008ad, 6076}, {0x0008a9, 6012}, + {0x0008b5, 6235}, {0x0009f7, 6775}, {0x0008b3, 6183}, {0x000ac9, 7114}, + {0x000acb, 7138}, {0x0003bc, 2053}, {0x000ab3, 6943}, {0x0000b2, 586}, + {0x000ab1, 6924}, {0x000075, 373}, {0x0000fa, 1227}, {0x0002fd, 1933}, + {0x0000fb, 1234}, {0x0000fc, 1246}, {0x0001fb, 1698}, {0x0000f9, 1220}, + {0x0003fe, 2226}, {0x000bc6, 7925}, {0x00005f, 306}, {0x0008dd, 6469}, + {0x0003f9, 2211}, {0x0008fc, 6533}, {0x000ba9, 7883}, {0x0009ec, 6641}, + {0x0009eb, 6627}, {0x000bc3, 7908}, {0x000bd3, 7957}, {0x000bce, 7943}, + {0x0001f9, 1692}, {0x0003fd, 2219}, {0x000076, 375}, {0x0008c1, 6351}, + {0x0009f8, 6780}, {0x0008a6, 5964}, {0x0004de, 2820}, {0x0009e9, 6609}, + {0x000077, 377}, {0x000078, 379}, {0x000079, 381}, {0x0000fd, 1257}, + {0x0000ff, 1270}, {0x0000a5, 468}, {0x00007a, 383}, {0x0001bf, 1456}, + {0x0001bc, 1430}, {0x0001be, 1449}}; -RIME_API int RimeGetModifierByName(const char *name) { +RIME_API int RimeGetModifierByName(const char* name) { const int n = sizeof(modifier_name) / sizeof(const char*); if (!name) return 0; @@ -3983,8 +2023,8 @@ RIME_API const char* RimeGetModifierName(int modifier) { return NULL; } -RIME_API int RimeGetKeycodeByName(const char *name) { - for (const key_entry *p = keys_by_keyval; p->keyval != XK_VoidSymbol; ++p) { +RIME_API int RimeGetKeycodeByName(const char* name) { + for (const key_entry* p = keys_by_keyval; p->keyval != XK_VoidSymbol; ++p) { if (!strcmp(name, key_names + p->offset)) { return p->keyval; } diff --git a/src/rime/key_table.h b/src/rime/key_table.h index a5b8fd6d3..bf5664f77 100644 --- a/src/rime/key_table.h +++ b/src/rime/key_table.h @@ -12,35 +12,35 @@ #include typedef enum { - kShiftMask = 1 << 0, - kLockMask = 1 << 1, - kControlMask = 1 << 2, - kMod1Mask = 1 << 3, - kAltMask = kMod1Mask, - kMod2Mask = 1 << 4, - kMod3Mask = 1 << 5, - kMod4Mask = 1 << 6, - kMod5Mask = 1 << 7, - kButton1Mask = 1 << 8, - kButton2Mask = 1 << 9, - kButton3Mask = 1 << 10, - kButton4Mask = 1 << 11, - kButton5Mask = 1 << 12, + kShiftMask = 1 << 0, + kLockMask = 1 << 1, + kControlMask = 1 << 2, + kMod1Mask = 1 << 3, + kAltMask = kMod1Mask, + kMod2Mask = 1 << 4, + kMod3Mask = 1 << 5, + kMod4Mask = 1 << 6, + kMod5Mask = 1 << 7, + kButton1Mask = 1 << 8, + kButton2Mask = 1 << 9, + kButton3Mask = 1 << 10, + kButton4Mask = 1 << 11, + kButton5Mask = 1 << 12, /* The next few modifiers are used by XKB, so we skip to the end. * Bits 15 - 23 are currently unused. Bit 29 is used internally. */ /* ibus :) mask */ - kHandledMask = 1 << 24, - kForwardMask = 1 << 25, - kIgnoredMask = kForwardMask, + kHandledMask = 1 << 24, + kForwardMask = 1 << 25, + kIgnoredMask = kForwardMask, - kSuperMask = 1 << 26, - kHyperMask = 1 << 27, - kMetaMask = 1 << 28, + kSuperMask = 1 << 26, + kHyperMask = 1 << 27, + kMetaMask = 1 << 28, - kReleaseMask = 1 << 30, + kReleaseMask = 1 << 30, kModifierMask = 0x5f001fff } RimeModifier; diff --git a/src/rime/language.h b/src/rime/language.h index dbc8c0a2b..cb4e0e12b 100644 --- a/src/rime/language.h +++ b/src/rime/language.h @@ -16,14 +16,12 @@ class Language { Language(const string& name) : name_(name) {} string name() const { return name_; } - bool operator== (const Language& other) const { - return name_ == other.name_; - } + bool operator==(const Language& other) const { return name_ == other.name_; } template static bool intelligible(const T& t, const U& u) { return t && t->language() && u && u->language() && - *t->language() == *u->language(); + *t->language() == *u->language(); } static string get_language_component(const string& name); diff --git a/src/rime/lever/custom_settings.cc b/src/rime/lever/custom_settings.cc index 196a7bc5d..3d41c7936 100644 --- a/src/rime/lever/custom_settings.cc +++ b/src/rime/lever/custom_settings.cc @@ -16,8 +16,9 @@ namespace fs = boost::filesystem; namespace rime { static string remove_suffix(const string& input, const string& suffix) { - return boost::ends_with(input, suffix) ? - input.substr(0, input.length() - suffix.length()) : input; + return boost::ends_with(input, suffix) + ? input.substr(0, input.length() - suffix.length()) + : input; } static string custom_config_file(const string& config_id) { @@ -27,15 +28,14 @@ static string custom_config_file(const string& config_id) { CustomSettings::CustomSettings(Deployer* deployer, const string& config_id, const string& generator_id) - : deployer_(deployer), - config_id_(config_id), - generator_id_(generator_id) { -} + : deployer_(deployer), config_id_(config_id), generator_id_(generator_id) {} bool CustomSettings::Load() { - fs::path config_path = fs::path(deployer_->staging_dir) / (config_id_ + ".yaml"); + fs::path config_path = + fs::path(deployer_->staging_dir) / (config_id_ + ".yaml"); if (!config_.LoadFromFile(config_path.string())) { - config_path = fs::path(deployer_->prebuilt_data_dir) / (config_id_ + ".yaml"); + config_path = + fs::path(deployer_->prebuilt_data_dir) / (config_id_ + ".yaml"); if (!config_.LoadFromFile(config_path.string())) { LOG(WARNING) << "cannot find '" << config_id_ << ".yaml'."; } @@ -73,8 +73,7 @@ an CustomSettings::GetMap(const string& key) { return config_.GetMap(key); } -bool CustomSettings::Customize(const string& key, - const an& item) { +bool CustomSettings::Customize(const string& key, const an& item) { auto patch = custom_config_.GetMap("patch"); if (!patch) { patch = New(); diff --git a/src/rime/lever/customizer.cc b/src/rime/lever/customizer.cc index 349cabb8b..e5021e84f 100644 --- a/src/rime/lever/customizer.cc +++ b/src/rime/lever/customizer.cc @@ -42,20 +42,17 @@ bool Customizer::UpdateConfigFile() { dest_config.GetString(version_key_, &dest_version); dest_config.GetString("customization", &applied_customization); } - if (fs::exists(source_path_) && - fs::exists(dest_path_) && + if (fs::exists(source_path_) && fs::exists(dest_path_) && fs::equivalent(source_path_, dest_path_)) { missing_original_copy = true; source_version = dest_version; - } - else { + } else { Config source_config; if (source_config.LoadFromFile(source_path_.string())) { source_config.GetString(version_key_, &source_version); - } - else { - LOG(ERROR) << "Error loading config from '" - << source_path_.string() << "'."; + } else { + LOG(ERROR) << "Error loading config from '" << source_path_.string() + << "'."; return false; } if (CompareVersionString(source_version, dest_version) > 0) { @@ -63,12 +60,11 @@ bool Customizer::UpdateConfigFile() { redistribute = true; } } - + fs::path custom_path(dest_path_); if (custom_path.extension() != ".yaml") { custom_path.clear(); - } - else { + } else { custom_path.replace_extension(); if (custom_path.extension() == ".schema") { custom_path.replace_extension(); @@ -77,8 +73,7 @@ bool Customizer::UpdateConfigFile() { } string customization; if (!custom_path.empty() && fs::exists(custom_path)) { - customization = boost::lexical_cast( - Checksum(custom_path.string())); + customization = boost::lexical_cast(Checksum(custom_path.string())); } if (applied_customization != customization) { need_update = true; @@ -95,17 +90,16 @@ bool Customizer::UpdateConfigFile() { try { fs::copy_file(source_path_, dest_path_, fs::copy_option::overwrite_if_exists); - } - catch (...) { - LOG(ERROR) << "Error copying config file '" - << source_path_.string() << "' to user directory."; + } catch (...) { + LOG(ERROR) << "Error copying config file '" << source_path_.string() + << "' to user directory."; return false; } } if (!customization.empty()) { if (missing_original_copy) { LOG(WARNING) << "patching user config without a shared original copy " - "is discouraged."; + "is discouraged."; } LOG(INFO) << "applying customization file: " << custom_path.string(); if (!dest_config.LoadFromFile(dest_path_.string())) { @@ -125,8 +119,7 @@ bool Customizer::UpdateConfigFile() { return false; } } - } - else { + } else { LOG(WARNING) << "'patch' not found in customization file."; } // update config version diff --git a/src/rime/lever/deployment_tasks.cc b/src/rime/lever/deployment_tasks.cc index e40bc6df6..d8eb2f291 100644 --- a/src/rime/lever/deployment_tasks.cc +++ b/src/rime/lever/deployment_tasks.cc @@ -37,8 +37,7 @@ namespace rime { DetectModifications::DetectModifications(TaskInitializer arg) { try { data_dirs_ = boost::any_cast>(arg); - } - catch (const boost::bad_any_cast&) { + } catch (const boost::bad_any_cast&) { LOG(ERROR) << "DetectModifications: invalid arguments."; } } @@ -61,7 +60,7 @@ bool DetectModifications::Run(Deployer* deployer) { } } } - } catch(const fs::filesystem_error& ex) { + } catch (const fs::filesystem_error& ex) { LOG(ERROR) << "Error reading file information: " << ex.what(); return true; } @@ -138,8 +137,7 @@ bool InstallationUpdate::Run(Deployer* deployer) { deployer->user_id = installation_id; config.SetString("installation_id", installation_id); config.SetString("install_time", time_str); - } - else { + } else { config.SetString("update_time", time_str); } if (!deployer->distribution_name.empty()) { @@ -149,12 +147,10 @@ bool InstallationUpdate::Run(Deployer* deployer) { if (!deployer->distribution_code_name.empty()) { config.SetString("distribution_code_name", deployer->distribution_code_name); - LOG(INFO) << "distribution code name: " - << deployer->distribution_code_name; + LOG(INFO) << "distribution code name: " << deployer->distribution_code_name; } if (!deployer->distribution_version.empty()) { - config.SetString("distribution_version", - deployer->distribution_version); + config.SetString("distribution_version", deployer->distribution_version); LOG(INFO) << "distribution version: " << deployer->distribution_version; } config.SetString("rime_version", RIME_VERSION); @@ -169,8 +165,8 @@ bool WorkspaceUpdate::Run(Deployer* deployer) { t.reset(new ConfigFileUpdate("default.yaml", "config_version")); t->Run(deployer); // Deprecated: symbols.yaml is only used as source file - //t.reset(new ConfigFileUpdate("symbols.yaml", "config_version")); - //t->Run(deployer); + // t.reset(new ConfigFileUpdate("symbols.yaml", "config_version")); + // t->Run(deployer); t.reset(new SymlinkingPrebuiltDictionaries); t->Run(deployer); } @@ -190,9 +186,8 @@ bool WorkspaceUpdate::Run(Deployer* deployer) { int success = 0; int failure = 0; map schemas; - the resolver( - Service::instance().CreateResourceResolver( - {"schema_source_file", "", ".schema.yaml"})); + the resolver(Service::instance().CreateResourceResolver( + {"schema_source_file", "", ".schema.yaml"})); auto build_schema = [&](const string& schema_id, bool as_dependency = false) { if (schemas.find(schema_id) != schemas.end()) // already built return; @@ -201,13 +196,13 @@ bool WorkspaceUpdate::Run(Deployer* deployer) { if (schemas.find(schema_id) == schemas.end()) { schema_path = resolver->ResolvePath(schema_id).string(); schemas[schema_id] = schema_path; - } - else { + } else { schema_path = schemas[schema_id]; } if (schema_path.empty() || !fs::exists(schema_path)) { if (as_dependency) { - LOG(WARNING) << "missing input schema; skipped unsatisfied dependency: " << schema_id; + LOG(WARNING) << "missing input schema; skipped unsatisfied dependency: " + << schema_id; } else { LOG(ERROR) << "missing input schema: " << schema_id; ++failure; @@ -244,8 +239,8 @@ bool WorkspaceUpdate::Run(Deployer* deployer) { } } } - LOG(INFO) << "finished updating schemas: " - << success << " success, " << failure << " failure."; + LOG(INFO) << "finished updating schemas: " << success << " success, " + << failure << " failure."; the user_config(Config::Require("user_config")->Create("user")); // TODO: store as 64-bit number to avoid the year 2038 problem @@ -257,8 +252,7 @@ bool WorkspaceUpdate::Run(Deployer* deployer) { SchemaUpdate::SchemaUpdate(TaskInitializer arg) : verbose_(false) { try { schema_file_ = boost::any_cast(arg); - } - catch (const boost::bad_any_cast&) { + } catch (const boost::bad_any_cast&) { LOG(ERROR) << "SchemaUpdate: invalid arguments."; } } @@ -275,20 +269,19 @@ static bool MaybeCreateDirectory(fs::path dir) { } static bool RemoveVersionSuffix(string* version, const string& suffix) { - size_t suffix_pos = version->find(suffix); - if (suffix_pos != string::npos) { - version->erase(suffix_pos); - return true; - } - return false; + size_t suffix_pos = version->find(suffix); + if (suffix_pos != string::npos) { + version->erase(suffix_pos); + return true; + } + return false; } static bool TrashDeprecatedUserCopy(const fs::path& shared_copy, const fs::path& user_copy, const string& version_key, const fs::path& trash) { - if (!fs::exists(shared_copy) || - !fs::exists(user_copy) || + if (!fs::exists(shared_copy) || !fs::exists(user_copy) || fs::equivalent(shared_copy, user_copy)) { return false; } @@ -328,15 +321,14 @@ static bool TrashDeprecatedUserCopy(const fs::path& shared_copy, bool SchemaUpdate::Run(Deployer* deployer) { fs::path source_path(schema_file_); if (!fs::exists(source_path)) { - LOG(ERROR) << "Error updating schema: nonexistent file '" - << schema_file_ << "'."; + LOG(ERROR) << "Error updating schema: nonexistent file '" << schema_file_ + << "'."; return false; } string schema_id; the config(new Config); if (!config->LoadFromFile(schema_file_) || - !config->GetString("schema/schema_id", &schema_id) || - schema_id.empty()) { + !config->GetString("schema/schema_id", &schema_id) || schema_id.empty()) { LOG(ERROR) << "invalid schema definition in '" << schema_file_ << "'."; return false; } @@ -371,9 +363,8 @@ bool SchemaUpdate::Run(Deployer* deployer) { dict_compiler.set_options(DictCompiler::kRebuild | DictCompiler::kDump); } the resolver( - Service::instance().CreateDeployedResourceResolver({ - "compiled_schema", "", ".schema.yaml" - })); + Service::instance().CreateDeployedResourceResolver( + {"compiled_schema", "", ".schema.yaml"})); auto compiled_schema = resolver->ResolvePath(schema_id).string(); if (!dict_compiler.Compile(compiled_schema)) { LOG(ERROR) << "dictionary '" << dict_name << "' failed to compile."; @@ -388,8 +379,7 @@ ConfigFileUpdate::ConfigFileUpdate(TaskInitializer arg) { auto p = boost::any_cast>(arg); file_name_ = p.first; version_key_ = p.second; - } - catch (const boost::bad_any_cast&) { + } catch (const boost::bad_any_cast&) { LOG(ERROR) << "ConfigFileUpdate: invalid arguments."; } } @@ -405,9 +395,8 @@ static bool ConfigNeedsUpdate(Config* config) { LOG(INFO) << "missing timestamps"; return true; } - the resolver( - Service::instance().CreateResourceResolver( - {"config_source_file", "", ".yaml"})); + the resolver(Service::instance().CreateResourceResolver( + {"config_source_file", "", ".yaml"})); for (auto entry : *timestamps.AsMap()) { auto value = As(entry.second); int recorded_time = 0; @@ -423,7 +412,7 @@ static bool ConfigNeedsUpdate(Config* config) { } continue; } - if (recorded_time != (int) fs::last_write_time(source_file)) { + if (recorded_time != (int)fs::last_write_time(source_file)) { LOG(INFO) << "source file " << (recorded_time ? "changed: " : "added: ") << source_file.string(); return true; @@ -439,12 +428,10 @@ bool ConfigFileUpdate::Run(Deployer* deployer) { fs::path source_config_path(shared_data_path / file_name_); fs::path dest_config_path(user_data_path / file_name_); fs::path trash = user_data_path / "trash"; - if (TrashDeprecatedUserCopy(source_config_path, - dest_config_path, - version_key_, - trash)) { - LOG(INFO) << "deprecated user copy of '" << file_name_ - << "' is moved to " << trash; + if (TrashDeprecatedUserCopy(source_config_path, dest_config_path, + version_key_, trash)) { + LOG(INFO) << "deprecated user copy of '" << file_name_ << "' is moved to " + << trash; } // build the config file if needs update the config(Config::Require("config")->Create(file_name_)); @@ -463,8 +450,8 @@ bool PrebuildAllSchemas::Run(Deployer* deployer) { if (!fs::exists(shared_data_path) || !fs::is_directory(shared_data_path)) return false; bool success = true; - for (fs::directory_iterator iter(shared_data_path), end; - iter != end; ++iter) { + for (fs::directory_iterator iter(shared_data_path), end; iter != end; + ++iter) { fs::path entry(iter->path()); if (boost::ends_with(entry.string(), ".schema.yaml")) { the t(new SchemaUpdate(entry.string())); @@ -484,8 +471,7 @@ bool SymlinkingPrebuiltDictionaries::Run(Deployer* deployer) { return false; bool success = false; // remove symlinks to shared data files created by previous version - for (fs::directory_iterator test(user_data_path), end; - test != end; ++test) { + for (fs::directory_iterator test(user_data_path), end; test != end; ++test) { fs::path entry(test->path()); if (fs::is_symlink(entry)) { try { @@ -494,15 +480,13 @@ bool SymlinkingPrebuiltDictionaries::Run(Deployer* deployer) { auto target_path = fs::canonical(entry, ec); bool bad_link = bool(ec); bool linked_to_shared_data = - !bad_link && - target_path.has_parent_path() && + !bad_link && target_path.has_parent_path() && fs::equivalent(shared_data_path, target_path.parent_path()); if (bad_link || linked_to_shared_data) { LOG(INFO) << "removing symlink: " << entry.filename().string(); fs::remove(entry); } - } - catch (const fs::filesystem_error& ex) { + } catch (const fs::filesystem_error& ex) { LOG(ERROR) << entry << ": " << ex.what(); success = false; } @@ -556,8 +540,7 @@ bool BackupConfigFiles::Run(Deployer* deployer) { return false; } int success = 0, failure = 0, latest = 0, skipped = 0; - for (fs::directory_iterator iter(user_data_path), end; - iter != end; ++iter) { + for (fs::directory_iterator iter(user_data_path), end; iter != end; ++iter) { fs::path entry(iter->path()); if (!fs::is_regular_file(entry)) continue; @@ -581,15 +564,13 @@ bool BackupConfigFiles::Run(Deployer* deployer) { if (ec) { LOG(ERROR) << "error backing up file " << backup.string(); ++failure; - } - else { + } else { ++success; } } LOG(INFO) << "backed up " << success << " config files to " - << backup_dir.string() << ", " << failure << " failed, " - << latest << " up-to-date, " - << skipped << " skipped."; + << backup_dir.string() << ", " << failure << " failed, " << latest + << " up-to-date, " << skipped << " skipped."; return !failure; } @@ -600,14 +581,12 @@ bool CleanupTrash::Run(Deployer* deployer) { return false; fs::path trash = user_data_path / "trash"; int success = 0, failure = 0; - for (fs::directory_iterator iter(user_data_path), end; - iter != end; ++iter) { + for (fs::directory_iterator iter(user_data_path), end; iter != end; ++iter) { fs::path entry(iter->path()); if (!fs::is_regular_file(entry)) continue; auto filename = entry.filename().string(); - if (filename == "rime.log" || - boost::ends_with(filename, ".bin") || + if (filename == "rime.log" || boost::ends_with(filename, ".bin") || boost::ends_with(filename, ".reverse.kct") || boost::ends_with(filename, ".userdb.kct.old") || boost::ends_with(filename, ".userdb.kct.snapshot")) { @@ -620,8 +599,7 @@ bool CleanupTrash::Run(Deployer* deployer) { if (ec) { LOG(ERROR) << "error clean up file " << entry.string(); ++failure; - } - else { + } else { ++success; } } @@ -660,16 +638,14 @@ bool CleanOldLogFiles::Run(Deployer* deployer) { fs::path entry(j->path()); string file_name(entry.filename().string()); try { - if (fs::is_regular_file(entry) && - !fs::is_symlink(entry) && + if (fs::is_regular_file(entry) && !fs::is_symlink(entry) && boost::starts_with(file_name, "rime.") && !boost::contains(file_name, today)) { DLOG(INFO) << "removing log file '" << file_name << "'."; fs::remove(entry); ++removed; } - } - catch (const fs::filesystem_error& ex) { + } catch (const fs::filesystem_error& ex) { LOG(ERROR) << ex.what(); success = false; } diff --git a/src/rime/lever/deployment_tasks.h b/src/rime/lever/deployment_tasks.h index 66a9815f0..8fd61f633 100644 --- a/src/rime/lever/deployment_tasks.h +++ b/src/rime/lever/deployment_tasks.h @@ -19,6 +19,7 @@ class DetectModifications : public DeploymentTask { // Unlike other tasks, its return value indicates whether modifications // has been detected and workspace needs update. bool Run(Deployer* deployer); + protected: vector data_dirs_; }; @@ -38,8 +39,8 @@ class WorkspaceUpdate : public DeploymentTask { protected: string GetSchemaPath(Deployer* deployer, - const string& schema_id, - bool prefer_shared_copy); + const string& schema_id, + bool prefer_shared_copy); }; // update a specific schema, build corresponding dictionary @@ -59,8 +60,7 @@ class SchemaUpdate : public DeploymentTask { // update a specific config file class ConfigFileUpdate : public DeploymentTask { public: - ConfigFileUpdate(const string& file_name, - const string& version_key) + ConfigFileUpdate(const string& file_name, const string& version_key) : file_name_(file_name), version_key_(version_key) {} ConfigFileUpdate(TaskInitializer arg); bool Run(Deployer* deployer); diff --git a/src/rime/lever/levers_module.cc b/src/rime/lever/levers_module.cc index cf1571ed5..a111a989d 100644 --- a/src/rime/lever/levers_module.cc +++ b/src/rime/lever/levers_module.cc @@ -19,7 +19,6 @@ using namespace rime; static void rime_levers_initialize() { - LOG(INFO) << "registering components from module 'levers'."; Registry& r = Registry::instance(); @@ -37,17 +36,15 @@ static void rime_levers_initialize() { r.Register("clean_old_log_files", new Component); } -static void rime_levers_finalize() { -} +static void rime_levers_finalize() {} // implementation of levers api -static RimeCustomSettings* -rime_levers_custom_settings_init(const char* config_id, - const char* generator_id) { - return reinterpret_cast( - new CustomSettings(&Service::instance().deployer(), - config_id, generator_id)); +static RimeCustomSettings* rime_levers_custom_settings_init( + const char* config_id, + const char* generator_id) { + return reinterpret_cast(new CustomSettings( + &Service::instance().deployer(), config_id, generator_id)); } static void rime_levers_custom_settings_destroy(RimeCustomSettings* settings) { @@ -63,35 +60,40 @@ static Bool rime_levers_save_settings(RimeCustomSettings* settings) { } static Bool rime_levers_customize_bool(RimeCustomSettings* settings, - const char* key, Bool value) { + const char* key, + Bool value) { an item = New(bool(value)); auto custom_settings = reinterpret_cast(settings); return custom_settings->Customize(key, item); } static Bool rime_levers_customize_int(RimeCustomSettings* settings, - const char* key, int value) { + const char* key, + int value) { an item = New(value); auto custom_settings = reinterpret_cast(settings); return custom_settings->Customize(key, item); } static Bool rime_levers_customize_double(RimeCustomSettings* settings, - const char* key, double value) { + const char* key, + double value) { an item = New(value); auto custom_settings = reinterpret_cast(settings); return custom_settings->Customize(key, item); } static Bool rime_levers_customize_string(RimeCustomSettings* settings, - const char* key, const char* value) { + const char* key, + const char* value) { an item = New(value); auto custom_settings = reinterpret_cast(settings); return custom_settings->Customize(key, item); } static Bool rime_levers_customize_item(RimeCustomSettings* settings, - const char* key, RimeConfig* value) { + const char* key, + RimeConfig* value) { an item; if (value) { if (Config* v = reinterpret_cast(value->ptr)) { @@ -123,9 +125,9 @@ static RimeSwitcherSettings* rime_levers_switcher_settings_init() { new SwitcherSettings(&Service::instance().deployer())); } -static Bool -rime_levers_get_available_schema_list(RimeSwitcherSettings* settings, - RimeSchemaList* list) { +static Bool rime_levers_get_available_schema_list( + RimeSwitcherSettings* settings, + RimeSchemaList* list) { auto ss = reinterpret_cast(settings); list->size = 0; list->list = NULL; @@ -143,9 +145,8 @@ rime_levers_get_available_schema_list(RimeSwitcherSettings* settings, return True; } -static Bool -rime_levers_get_selected_schema_list(RimeSwitcherSettings* settings, - RimeSchemaList* list) { +static Bool rime_levers_get_selected_schema_list(RimeSwitcherSettings* settings, + RimeSchemaList* list) { auto ss = reinterpret_cast(settings); list->size = 0; list->list = NULL; diff --git a/src/rime/lever/switcher_settings.cc b/src/rime/lever/switcher_settings.cc index dfc872fd7..3e7ad38a1 100644 --- a/src/rime/lever/switcher_settings.cc +++ b/src/rime/lever/switcher_settings.cc @@ -16,8 +16,7 @@ namespace fs = boost::filesystem; namespace rime { SwitcherSettings::SwitcherSettings(Deployer* deployer) - : CustomSettings(deployer, "default", "Rime::SwitcherSettings") { -} + : CustomSettings(deployer, "default", "Rime::SwitcherSettings") {} bool SwitcherSettings::Load() { if (!CustomSettings::Load()) @@ -53,8 +52,7 @@ void SwitcherSettings::GetAvailableSchemasFromDirectory(const fs::path& dir) { LOG(INFO) << "directory '" << dir.string() << "' does not exist."; return; } - for (fs::directory_iterator it(dir), end; - it != end; ++it) { + for (fs::directory_iterator it(dir), end; it != end; ++it) { string file_path(it->path().string()); if (boost::ends_with(file_path, ".schema.yaml")) { Config config; diff --git a/src/rime/lever/switcher_settings.h b/src/rime/lever/switcher_settings.h index 4a637d90c..b99fa0c0c 100644 --- a/src/rime/lever/switcher_settings.h +++ b/src/rime/lever/switcher_settings.h @@ -26,12 +26,12 @@ class SwitcherSettings : public CustomSettings { using SchemaList = vector; // a list of schema_ids using Selection = vector; - + explicit SwitcherSettings(Deployer* deployer); bool Load(); bool Select(Selection selection); bool SetHotkeys(const string& hotkeys); - + const SchemaList& available() const { return available_; } const Selection& selection() const { return selection_; } const string& hotkeys() const { return hotkeys_; } diff --git a/src/rime/lever/user_dict_manager.cc b/src/rime/lever/user_dict_manager.cc index c5258266e..c01bf3327 100644 --- a/src/rime/lever/user_dict_manager.cc +++ b/src/rime/lever/user_dict_manager.cc @@ -21,8 +21,7 @@ namespace fs = boost::filesystem; namespace rime { UserDictManager::UserDictManager(Deployer* deployer) - : deployer_(deployer), - user_db_component_(UserDb::Require("userdb")) { + : deployer_(deployer), user_db_component_(UserDb::Require("userdb")) { if (deployer) { path_ = deployer->user_data_dir; } @@ -77,8 +76,7 @@ bool UserDictManager::Restore(const string& snapshot_file) { temp->Remove(); if (!temp->Open()) return false; - BOOST_SCOPE_EXIT( (&temp) ) - { + BOOST_SCOPE_EXIT((&temp)) { temp->Close(); temp->Remove(); } @@ -93,26 +91,24 @@ bool UserDictManager::Restore(const string& snapshot_file) { the dest(user_db_component_->Create(db_name)); if (!dest->Open()) return false; - BOOST_SCOPE_EXIT( (&dest) ) - { + BOOST_SCOPE_EXIT((&dest)) { dest->Close(); - } BOOST_SCOPE_EXIT_END - LOG(INFO) << "merging '" << snapshot_file - << "' from " << UserDbHelper(temp).GetUserId() - << " into userdb '" << db_name << "'..."; + } + BOOST_SCOPE_EXIT_END + LOG(INFO) << "merging '" << snapshot_file << "' from " + << UserDbHelper(temp).GetUserId() << " into userdb '" << db_name + << "'..."; DbSource source(temp.get()); UserDbMerger merger(dest.get()); source >> merger; return true; } -int UserDictManager::Export(const string& dict_name, - const string& text_file) { +int UserDictManager::Export(const string& dict_name, const string& text_file) { the db(user_db_component_->Create(dict_name)); if (!db->OpenReadOnly()) return -1; - BOOST_SCOPE_EXIT( (&db) ) - { + BOOST_SCOPE_EXIT((&db)) { db->Close(); } BOOST_SCOPE_EXIT_END @@ -124,8 +120,7 @@ int UserDictManager::Export(const string& dict_name, int num_entries = 0; try { num_entries = writer << source; - } - catch (std::exception& ex) { + } catch (std::exception& ex) { LOG(ERROR) << ex.what(); return -1; } @@ -133,13 +128,11 @@ int UserDictManager::Export(const string& dict_name, return num_entries; } -int UserDictManager::Import(const string& dict_name, - const string& text_file) { +int UserDictManager::Import(const string& dict_name, const string& text_file) { the db(user_db_component_->Create(dict_name)); if (!db->Open()) return -1; - BOOST_SCOPE_EXIT( (&db) ) - { + BOOST_SCOPE_EXIT((&db)) { db->Close(); } BOOST_SCOPE_EXIT_END @@ -150,8 +143,7 @@ int UserDictManager::Import(const string& dict_name, int num_entries = 0; try { num_entries = reader >> importer; - } - catch (std::exception& ex) { + } catch (std::exception& ex) { LOG(ERROR) << ex.what(); return -1; } @@ -179,10 +171,8 @@ bool UserDictManager::UpgradeUserDict(const string& dict_name) { } string snapshot_file = dict_name + UserDb::snapshot_extension(); fs::path snapshot_path = trash / snapshot_file; - return legacy_db->Backup(snapshot_path.string()) && - legacy_db->Close() && - legacy_db->Remove() && - Restore(snapshot_path.string()); + return legacy_db->Backup(snapshot_path.string()) && legacy_db->Close() && + legacy_db->Remove() && Restore(snapshot_path.string()); } bool UserDictManager::Synchronize(const string& dict_name) { @@ -227,8 +217,8 @@ bool UserDictManager::SynchronizeAll() { ++failure; } if (failure) { - LOG(ERROR) << "failed synchronizing " - << failure << "/" << user_dicts.size() << " user dicts."; + LOG(ERROR) << "failed synchronizing " << failure << "/" << user_dicts.size() + << " user dicts."; } return !failure; } diff --git a/src/rime/menu.cc b/src/rime/menu.cc index 4335efce6..f5cef6852 100644 --- a/src/rime/menu.cc +++ b/src/rime/menu.cc @@ -12,10 +12,7 @@ namespace rime { -Menu::Menu() - : merged_(new MergedTranslation(candidates_)), - result_(merged_) { -} +Menu::Menu() : merged_(new MergedTranslation(candidates_)), result_(merged_) {} void Menu::AddTranslation(an translation) { *merged_ += translation; @@ -55,15 +52,13 @@ Page* Menu::CreatePage(size_t page_size, size_t page_no) { page->page_size = page_size; page->page_no = page_no; page->is_last_page = result_->exhausted() && (end_pos == candidates_.size()); - std::copy(candidates_.begin() + start_pos, - candidates_.begin() + end_pos, + std::copy(candidates_.begin() + start_pos, candidates_.begin() + end_pos, std::back_inserter(page->candidates)); return page; } an Menu::GetCandidateAt(size_t index) { - if (index >= candidates_.size() && - index >= Prepare(index + 1)) { + if (index >= candidates_.size() && index >= Prepare(index + 1)) { return nullptr; } return candidates_[index]; diff --git a/src/rime/messenger.h b/src/rime/messenger.h index fb64a45b5..39b92a74a 100644 --- a/src/rime/messenger.h +++ b/src/rime/messenger.h @@ -13,8 +13,8 @@ namespace rime { class Messenger { public: - using MessageSink = signal; + using MessageSink = + signal; MessageSink& message_sink() { return message_sink_; } diff --git a/src/rime/module.cc b/src/rime/module.cc index e0935d8a3..223d11670 100644 --- a/src/rime/module.cc +++ b/src/rime/module.cc @@ -10,8 +10,7 @@ namespace rime { -void ModuleManager::Register(const string& name, - RimeModule* module) { +void ModuleManager::Register(const string& name, RimeModule* module) { map_[name] = module; } @@ -24,16 +23,14 @@ RimeModule* ModuleManager::Find(const string& name) { } void ModuleManager::LoadModule(RimeModule* module) { - if (!module || - loaded_.find(module) != loaded_.end()) { + if (!module || loaded_.find(module) != loaded_.end()) { return; } DLOG(INFO) << "loading module: " << module; loaded_.insert(module); if (module->initialize != NULL) { module->initialize(); - } - else { + } else { LOG(WARNING) << "missing initialize() function in module: " << module; } } diff --git a/src/rime/no_logging.h b/src/rime/no_logging.h index d4b734847..ddf69fd1f 100644 --- a/src/rime/no_logging.h +++ b/src/rime/no_logging.h @@ -11,19 +11,22 @@ class VoidLogger { VoidLogger& stream() { return *this; } template - VoidLogger& operator<< (const T& x) { return *this; } + VoidLogger& operator<<(const T& x) { + return *this; + } }; // to avoid compiler warnings class Voidify { public: Voidify() {} - void operator& (VoidLogger&) {} + void operator&(VoidLogger&) {} }; } // namespace rime -#define RIME_NO_LOG true ? (void) 0 : rime::Voidify() & rime::VoidLogger().stream() +#define RIME_NO_LOG \ + true ? (void)0 : rime::Voidify() & rime::VoidLogger().stream() #define LOG(severity) RIME_NO_LOG #define VLOG(verboselevel) RIME_NO_LOG @@ -32,7 +35,7 @@ class Voidify { #define LOG_IF_EVERY_N(severity, condition, n) RIME_NO_LOG #define LOG_ASSERT(condition) RIME_NO_LOG -#define RIME_NO_CHECK (void) 0 +#define RIME_NO_CHECK (void)0 #define CHECK(condition) RIME_NO_CHECK #define CHECK_EQ(val1, val2) RIME_NO_CHECK diff --git a/src/rime/processor.h b/src/rime/processor.h index 5029dfe80..9c4a2277f 100644 --- a/src/rime/processor.h +++ b/src/rime/processor.h @@ -32,7 +32,7 @@ class Processor : public Class { } string name_space() const { return name_space_; } - + protected: Engine* engine_; string name_space_; diff --git a/src/rime/registry.cc b/src/rime/registry.cc index 93835f51c..979396c50 100644 --- a/src/rime/registry.cc +++ b/src/rime/registry.cc @@ -10,7 +10,7 @@ namespace rime { -void Registry::Register(const string &name, ComponentBase *component) { +void Registry::Register(const string& name, ComponentBase* component) { LOG(INFO) << "registering component: " << name; if (ComponentBase* existing = Find(name)) { LOG(WARNING) << "replacing previously registered component: " << name; @@ -19,7 +19,7 @@ void Registry::Register(const string &name, ComponentBase *component) { map_[name] = component; } -void Registry::Unregister(const string &name) { +void Registry::Unregister(const string& name) { LOG(INFO) << "unregistering component: " << name; ComponentMap::iterator it = map_.find(name); if (it == map_.end()) @@ -36,7 +36,7 @@ void Registry::Clear() { } } -ComponentBase* Registry::Find(const string &name) { +ComponentBase* Registry::Find(const string& name) { ComponentMap::const_iterator it = map_.find(name); if (it != map_.end()) { return it->second; diff --git a/src/rime/resource.cc b/src/rime/resource.cc index 82eb6c222..765ea4d2e 100644 --- a/src/rime/resource.cc +++ b/src/rime/resource.cc @@ -21,20 +21,21 @@ string ResourceResolver::ToResourceId(const string& file_path) const { string ResourceResolver::ToFilePath(const string& resource_id) const { boost::filesystem::path file_path(resource_id); bool missing_prefix = !file_path.has_parent_path() && - !boost::starts_with(resource_id, type_.prefix); + !boost::starts_with(resource_id, type_.prefix); bool missing_suffix = !boost::ends_with(resource_id, type_.suffix); return (missing_prefix ? type_.prefix : "") + resource_id + - (missing_suffix ? type_.suffix : ""); + (missing_suffix ? type_.suffix : ""); } -boost::filesystem::path ResourceResolver::ResolvePath(const string& resource_id) { +boost::filesystem::path ResourceResolver::ResolvePath( + const string& resource_id) { return boost::filesystem::absolute( boost::filesystem::path(type_.prefix + resource_id + type_.suffix), root_path_); } -boost::filesystem::path -FallbackResourceResolver::ResolvePath(const string& resource_id) { +boost::filesystem::path FallbackResourceResolver::ResolvePath( + const string& resource_id) { auto default_path = ResourceResolver::ResolvePath(resource_id); if (!boost::filesystem::exists(default_path)) { auto fallback_path = boost::filesystem::absolute( diff --git a/src/rime/resource.h b/src/rime/resource.h index 04b56cd77..bc4f042b6 100644 --- a/src/rime/resource.h +++ b/src/rime/resource.h @@ -22,19 +22,17 @@ struct ResourceType { class ResourceResolver { public: - explicit ResourceResolver(const ResourceType type) : type_(type) { - } - virtual ~ResourceResolver() { - } - RIME_API virtual boost::filesystem::path ResolvePath(const string& resource_id); + explicit ResourceResolver(const ResourceType type) : type_(type) {} + virtual ~ResourceResolver() {} + RIME_API virtual boost::filesystem::path ResolvePath( + const string& resource_id); string ToResourceId(const string& file_path) const; string ToFilePath(const string& resource_id) const; void set_root_path(boost::filesystem::path root_path) { root_path_ = root_path; } - boost::filesystem::path root_path() const { - return root_path_; - } + boost::filesystem::path root_path() const { return root_path_; } + protected: const ResourceType type_; boost::filesystem::path root_path_; @@ -44,12 +42,13 @@ class ResourceResolver { class FallbackResourceResolver : public ResourceResolver { public: explicit FallbackResourceResolver(const ResourceType& type) - : ResourceResolver(type) { - } - RIME_API boost::filesystem::path ResolvePath(const string& resource_id) override; + : ResourceResolver(type) {} + RIME_API boost::filesystem::path ResolvePath( + const string& resource_id) override; void set_fallback_root_path(boost::filesystem::path fallback_root_path) { fallback_root_path_ = fallback_root_path; } + private: boost::filesystem::path fallback_root_path_; }; diff --git a/src/rime/schema.cc b/src/rime/schema.cc index 577bb31ff..559cb7a8a 100644 --- a/src/rime/schema.cc +++ b/src/rime/schema.cc @@ -9,17 +9,15 @@ namespace rime { -Schema::Schema() - : schema_id_(".default") { +Schema::Schema() : schema_id_(".default") { config_.reset(Config::Require("config")->Create("default")); FetchUsefulConfigItems(); } -Schema::Schema(const string& schema_id) - : schema_id_(schema_id) { - config_.reset(boost::starts_with(schema_id_, L".") ? - Config::Require("config")->Create(schema_id.substr(1)) : - Config::Require("schema")->Create(schema_id)); +Schema::Schema(const string& schema_id) : schema_id_(schema_id) { + config_.reset(boost::starts_with(schema_id_, L".") + ? Config::Require("config")->Create(schema_id.substr(1)) + : Config::Require("schema")->Create(schema_id)); FetchUsefulConfigItems(); } diff --git a/src/rime/schema.h b/src/rime/schema.h index 7d7ab9956..bb68bcdb9 100644 --- a/src/rime/schema.h +++ b/src/rime/schema.h @@ -45,10 +45,10 @@ class Schema { class SchemaComponent : public Config::Component { public: SchemaComponent(Config::Component* config_component) - : config_component_(config_component) { - } + : config_component_(config_component) {} // NOTE: creates `Config` for the schema Config* Create(const string& schema_id) override; + private: // we do not own the config component, do not try to deallocate it // also be careful that there is no guarantee it will outlive us diff --git a/src/rime/segmentation.cc b/src/rime/segmentation.cc index 1e0bafaa5..b34256d05 100644 --- a/src/rime/segmentation.cc +++ b/src/rime/segmentation.cc @@ -36,8 +36,7 @@ bool Segment::Reopen(size_t caret_pos) { tags.erase(kPartialSelectionTag); } status = kGuess; - } - else { + } else { status = kVoid; } return true; @@ -53,15 +52,13 @@ an Segment::GetSelectedCandidate() const { return GetCandidateAt(selected_index); } -Segmentation::Segmentation() { -} +Segmentation::Segmentation() {} void Segmentation::Reset(const string& new_input) { DLOG(INFO) << "reset to " << size() << " segments."; // mark redo segmentation, while keeping user confirmed segments size_t diff_pos = 0; - while (diff_pos < input_.length() && - diff_pos < new_input.length() && + while (diff_pos < input_.length() && diff_pos < new_input.length() && input_[diff_pos] == new_input[diff_pos]) ++diff_pos; DLOG(INFO) << "diff pos: " << diff_pos; @@ -100,17 +97,14 @@ bool Segmentation::AddSegment(Segment segment) { Segment& last = back(); if (last.end > segment.end) { // rule two: always prefer the longer segment... - } - else if (last.end < segment.end) { + } else if (last.end < segment.end) { // ...and overwrite the shorter one last = segment; - } - else { + } else { // rule three: with segments equal in length, merge their tags set result; - set_union(last.tags.begin(), last.tags.end(), - segment.tags.begin(), segment.tags.end(), - std::inserter(result, result.begin())); + set_union(last.tags.begin(), last.tags.end(), segment.tags.begin(), + segment.tags.end(), std::inserter(result, result.begin())); last.tags.swap(result); } return true; @@ -159,8 +153,7 @@ size_t Segmentation::GetConfirmedPosition() const { return k; } -std::ostream& operator<< (std::ostream& out, - const Segmentation& segmentation) { +std::ostream& operator<<(std::ostream& out, const Segmentation& segmentation) { out << "[" << segmentation.input(); for (const Segment& segment : segmentation) { out << "|" << segment.start << "," << segment.end; diff --git a/src/rime/segmentation.h b/src/rime/segmentation.h index ebc418806..b30e00b44 100644 --- a/src/rime/segmentation.h +++ b/src/rime/segmentation.h @@ -34,8 +34,7 @@ struct Segment { Segment() = default; Segment(int start_pos, int end_pos) - : start(start_pos), end(end_pos), length(end_pos - start_pos) { - } + : start(start_pos), end(end_pos), length(end_pos - start_pos) {} void Clear() { status = kVoid; @@ -48,9 +47,7 @@ struct Segment { void Close(); bool Reopen(size_t caret_pos); - bool HasTag(const string& tag) const { - return tags.find(tag) != tags.end(); - } + bool HasTag(const string& tag) const { return tags.find(tag) != tags.end(); } an GetCandidateAt(size_t index) const; an GetSelectedCandidate() const; @@ -78,8 +75,7 @@ class Segmentation : public vector { string input_; }; -std::ostream& operator<< (std::ostream& out, - const Segmentation& segmentation); +std::ostream& operator<<(std::ostream& out, const Segmentation& segmentation); } // namespace rime diff --git a/src/rime/segmentor.h b/src/rime/segmentor.h index e73a09974..4aa7d3e23 100644 --- a/src/rime/segmentor.h +++ b/src/rime/segmentor.h @@ -22,9 +22,9 @@ class Segmentor : public Class { virtual ~Segmentor() = default; virtual bool Proceed(Segmentation* segmentation) = 0; - + string name_space() const { return name_space_; } - + protected: Engine* engine_; string name_space_; diff --git a/src/rime/service.cc b/src/rime/service.cc index 22eaab72a..616c8765a 100644 --- a/src/rime/service.cc +++ b/src/rime/service.cc @@ -83,26 +83,22 @@ void Service::StopService() { SessionId Service::CreateSession() { SessionId id = kInvalidSessionId; - if (disabled()) return id; + if (disabled()) + return id; try { auto session = New(); session->Activate(); id = reinterpret_cast(session.get()); sessions_[id] = session; - } - catch (const std::exception& ex) { + } catch (const std::exception& ex) { LOG(ERROR) << "Error creating session: " << ex.what(); - } - catch (const string& ex) { + } catch (const string& ex) { LOG(ERROR) << "Error creating session: " << ex; - } - catch (const char* ex) { + } catch (const char* ex) { LOG(ERROR) << "Error creating session: " << ex; - } - catch (int ex) { + } catch (int ex) { LOG(ERROR) << "Error creating session: " << ex; - } - catch (...) { + } catch (...) { LOG(ERROR) << "Error creating session."; } return id; @@ -131,13 +127,12 @@ bool Service::DestroySession(SessionId session_id) { void Service::CleanupStaleSessions() { time_t now = time(NULL); int count = 0; - for (auto it = sessions_.begin(); it != sessions_.end(); ) { + for (auto it = sessions_.begin(); it != sessions_.end();) { if (it->second && it->second->last_active_time() < now - Session::kLifeSpan) { sessions_.erase(it++); ++count; - } - else { + } else { ++it; } } @@ -163,8 +158,7 @@ void Service::Notify(SessionId session_id, const string& message_value) { if (notification_handler_) { std::lock_guard lock(mutex_); - notification_handler_(session_id, - message_type.c_str(), + notification_handler_(session_id, message_type.c_str(), message_value.c_str()); } } diff --git a/src/rime/service.h b/src/rime/service.h index 658f27b25..f8023c4dd 100644 --- a/src/rime/service.h +++ b/src/rime/service.h @@ -19,9 +19,9 @@ using SessionId = uintptr_t; static const SessionId kInvalidSessionId = 0; -using NotificationHandler = function; +using NotificationHandler = function; class Context; class Engine; @@ -76,7 +76,8 @@ class Service { const string& message_value); ResourceResolver* CreateResourceResolver(const ResourceType& type); - ResourceResolver* CreateUserSpecificResourceResolver(const ResourceType& type); + ResourceResolver* CreateUserSpecificResourceResolver( + const ResourceType& type); ResourceResolver* CreateDeployedResourceResolver(const ResourceType& type); ResourceResolver* CreateStagingResourceResolver(const ResourceType& type); diff --git a/src/rime/setup.cc b/src/rime/setup.cc index 37299556f..05730a639 100644 --- a/src/rime/setup.cc +++ b/src/rime/setup.cc @@ -10,7 +10,7 @@ #ifdef RIME_ENABLE_LOGGING #ifdef _WIN32 #define GLOG_NO_ABBREVIATED_SEVERITIES -#endif // _WIN32 +#endif // _WIN32 #include #endif // RIME_ENABLE_LOGGING @@ -44,11 +44,13 @@ RIME_API void LoadModules(const char* module_names[]) { } // assume member is a non-null pointer in struct *p. -#define PROVIDED(p, member) ((p) && RIME_STRUCT_HAS_MEMBER(*(p), (p)->member) && (p)->member) +#define PROVIDED(p, member) \ + ((p) && RIME_STRUCT_HAS_MEMBER(*(p), (p)->member) && (p)->member) -RIME_API void SetupDeployer(RimeTraits *traits) { - if (!traits) return; - Deployer &deployer(Service::instance().deployer()); +RIME_API void SetupDeployer(RimeTraits* traits) { + if (!traits) + return; + Deployer& deployer(Service::instance().deployer()); if (PROVIDED(traits, shared_data_dir)) deployer.shared_data_dir = traits->shared_data_dir; if (PROVIDED(traits, user_data_dir)) @@ -62,21 +64,26 @@ RIME_API void SetupDeployer(RimeTraits *traits) { if (PROVIDED(traits, prebuilt_data_dir)) deployer.prebuilt_data_dir = traits->prebuilt_data_dir; else - deployer.prebuilt_data_dir = (fs::path(deployer.shared_data_dir) / "build").string(); + deployer.prebuilt_data_dir = + (fs::path(deployer.shared_data_dir) / "build").string(); if (PROVIDED(traits, staging_dir)) deployer.staging_dir = traits->staging_dir; else - deployer.staging_dir = (fs::path(deployer.user_data_dir) / "build").string(); + deployer.staging_dir = + (fs::path(deployer.user_data_dir) / "build").string(); } -RIME_API void SetupLogging(const char* app_name, int min_log_level, const char* log_dir) { +RIME_API void SetupLogging(const char* app_name, + int min_log_level, + const char* log_dir) { #ifdef RIME_ENABLE_LOGGING FLAGS_minloglevel = min_log_level; FLAGS_alsologtostderr = true; if (log_dir) { FLAGS_log_dir = log_dir; } - // Do not allow other users to read/write log files created by current process. + // Do not allow other users to read/write log files created by current + // process. FLAGS_logfile_mode = 0600; google::InitGoogleLogging(app_name); #endif // RIME_ENABLE_LOGGING diff --git a/src/rime/setup.h b/src/rime/setup.h index 31a9fffc1..7a5cfe19d 100644 --- a/src/rime/setup.h +++ b/src/rime/setup.h @@ -17,9 +17,11 @@ extern const char* kLegacyModules[]; RIME_API void LoadModules(const char* module_names[]); -RIME_API void SetupDeployer(RimeTraits *traits); +RIME_API void SetupDeployer(RimeTraits* traits); -RIME_API void SetupLogging(const char* app_name, int min_log_level, const char* log_dir); +RIME_API void SetupLogging(const char* app_name, + int min_log_level, + const char* log_dir); RIME_API void SetupLogging(const char* app_name); } // namespace rime diff --git a/src/rime/signature.cc b/src/rime/signature.cc index 2774035c5..65500937d 100644 --- a/src/rime/signature.cc +++ b/src/rime/signature.cc @@ -13,7 +13,8 @@ namespace rime { bool Signature::Sign(Config* config, Deployer* deployer) { - if (!config) return false; + if (!config) + return false; config->SetString(key_ + "/generator", generator_); time_t now = time(NULL); string time_str(ctime(&now)); diff --git a/src/rime/signature.h b/src/rime/signature.h index e11130bdc..15ff7f4fd 100644 --- a/src/rime/signature.h +++ b/src/rime/signature.h @@ -7,7 +7,6 @@ #ifndef RIME_SIGNATURE_H_ #define RIME_SIGNATURE_H_ - namespace rime { class Config; diff --git a/src/rime/switcher.cc b/src/rime/switcher.cc index 15a35b41a..7f6741883 100644 --- a/src/rime/switcher.cc +++ b/src/rime/switcher.cc @@ -24,8 +24,7 @@ Switcher::Switcher(const Ticket& ticket) : Processor(ticket) { context_->set_option("dumb", true); // not going to commit anything // receive context notifications - context_->select_notifier().connect( - [this](Context* ctx) { OnSelect(ctx); }); + context_->select_notifier().connect([this](Context* ctx) { OnSelect(ctx); }); user_config_.reset(Config::Require("user_config")->Create("user")); InitializeComponents(); @@ -55,8 +54,7 @@ ProcessResult Switcher::ProcessKeyEvent(const KeyEvent& key_event) { if (key_event == hotkey) { if (!active_ && engine_) { Activate(); - } - else if (active_) { + } else if (active_) { HighlightNextSchema(); } return kAccepted; @@ -75,8 +73,7 @@ ProcessResult Switcher::ProcessKeyEvent(const KeyEvent& key_event) { int ch = key_event.keycode(); if (ch == XK_space || ch == XK_Return) { context_->ConfirmCurrentSelection(); - } - else if (ch == XK_Escape) { + } else if (ch == XK_Escape) { Deactivate(); } return kAccepted; @@ -97,12 +94,10 @@ void Switcher::HighlightNextSchema() { if (candidate_count <= index) { index = 0; // passed the end; rewind break; - } - else { + } else { option = seg.GetCandidateAt(index); } - } - while (!option || option->type() != "schema"); + } while (!option || option->type() != "schema"); seg.selected_index = index; seg.tags.insert("paging"); return; @@ -135,8 +130,7 @@ static an ParseSchemaListEntry(Config* config, if (!schema_property) return nullptr; if (auto case_conditions = As(entry_map->Get("case"))) { - for (auto iter = case_conditions->begin(); - iter != case_conditions->end(); + for (auto iter = case_conditions->begin(); iter != case_conditions->end(); ++iter) { if (auto condition_variable = As(*iter)) { bool condition_met = false; @@ -151,7 +145,8 @@ static an ParseSchemaListEntry(Config* config, } int Switcher::ForEachSchemaListEntry( - Config* config, function process_entry) { + Config* config, + function process_entry) { auto schema_list = config->GetList("schema_list"); if (!schema_list) return 0; @@ -177,17 +172,15 @@ Schema* Switcher::CreateSchema() { user_config_->GetString("var/previously_selected_schema", &previous); } string recent; - ForEachSchemaListEntry( - config, - [&previous, &recent](const string& schema_id) { - if (previous.empty() || previous == schema_id) { - recent = schema_id; - return /* continue = */false; - } - if (recent.empty()) - recent = schema_id; - return /* continue = */true; - }); + ForEachSchemaListEntry(config, [&previous, &recent](const string& schema_id) { + if (previous.empty() || previous == schema_id) { + recent = schema_id; + return /* continue = */ false; + } + if (recent.empty()) + recent = schema_id; + return /* continue = */ true; + }); if (recent.empty()) return nullptr; else @@ -226,7 +219,7 @@ void Switcher::RefreshMenu() { if (comp.empty()) { // no longer need this to make context_->IsComposing() == true // context_->set_input(" "); - Segment seg(0, 0); // empty range + Segment seg(0, 0); // empty range seg.prompt = caption_; comp.AddSegment(seg); } @@ -288,30 +281,26 @@ void Switcher::InitializeComponents() { if (auto c = Processor::Require("key_binder")) { an p(c->Create(Ticket(this))); processors_.push_back(p); - } - else { + } else { LOG(WARNING) << "key_binder not available."; } if (auto c = Processor::Require("selector")) { an p(c->Create(Ticket(this))); processors_.push_back(p); - } - else { + } else { LOG(WARNING) << "selector not available."; } DLOG(INFO) << "num processors: " << processors_.size(); if (auto c = Translator::Require("schema_list_translator")) { an t(c->Create(Ticket(this))); translators_.push_back(t); - } - else { + } else { LOG(WARNING) << "schema_list_translator not available."; } if (auto c = Translator::Require("switch_translator")) { an t(c->Create(Ticket(this))); translators_.push_back(t); - } - else { + } else { LOG(WARNING) << "switch_translator not available."; } DLOG(INFO) << "num translators: " << translators_.size(); diff --git a/src/rime/switcher.h b/src/rime/switcher.h index e4246843b..dd7e67493 100644 --- a/src/rime/switcher.h +++ b/src/rime/switcher.h @@ -28,7 +28,8 @@ class Switcher : public Processor, public Engine { virtual ProcessResult ProcessKeyEvent(const KeyEvent& key_event); static int ForEachSchemaListEntry( - Config* config, function process_entry); + Config* config, + function process_entry); Schema* CreateSchema(); void SelectNextSchema(); @@ -63,9 +64,7 @@ class Switcher : public Processor, public Engine { class SwitcherCommand { public: - SwitcherCommand(const string& keyword) - : keyword_(keyword) { - } + SwitcherCommand(const string& keyword) : keyword_(keyword) {} virtual void Apply(Switcher* switcher) = 0; const string& keyword() const { return keyword_; } diff --git a/src/rime/switches.cc b/src/rime/switches.cc index d35692c4a..4d7d58977 100644 --- a/src/rime/switches.cc +++ b/src/rime/switches.cc @@ -12,31 +12,23 @@ inline static int reset_value(ConfigItemRef& item) { Switches::SwitchOption Switches::FindOptionFromConfigItem( ConfigItemRef& item, size_t switch_index, - function callback) { + function callback) { auto the_switch = As(*item); auto name = item["name"]; auto options = item["options"]; if (name.IsValue()) { SwitchOption option{ - the_switch, - kToggleOption, - name.ToString(), - reset_value(item), - switch_index, + the_switch, kToggleOption, name.ToString(), + reset_value(item), switch_index, }; if (callback(option) == kFound) return option; } else if (options.IsList()) { - for (size_t option_index = 0; - option_index < options.size(); + for (size_t option_index = 0; option_index < options.size(); ++option_index) { SwitchOption option{ - the_switch, - kRadioGroup, - options[option_index].ToString(), - reset_value(item), - switch_index, - option_index, + the_switch, kRadioGroup, options[option_index].ToString(), + reset_value(item), switch_index, option_index, }; if (callback(option) == kFound) return option; @@ -46,7 +38,7 @@ Switches::SwitchOption Switches::FindOptionFromConfigItem( } Switches::SwitchOption Switches::FindOption( - function callback) { + function callback) { auto switches = (*config_)["switches"]; if (!switches.IsList()) return {}; @@ -75,13 +67,9 @@ Switches::SwitchOption Switches::ByIndex(size_t switch_index) { if (switches.size() <= switch_index) return {}; auto item = switches[switch_index]; - return FindOptionFromConfigItem( - item, - switch_index, - // return the very first found option. - [](SwitchOption option) { - return kFound; - }); + return FindOptionFromConfigItem(item, switch_index, + // return the very first found option. + [](SwitchOption option) { return kFound; }); } Switches::SwitchOption Switches::Cycle(const SwitchOption& current) { @@ -89,12 +77,12 @@ Switches::SwitchOption Switches::Cycle(const SwitchOption& current) { size_t next_option_index = (current.option_index + 1) % options->size(); if (next_option_index != current.option_index) { return { - current.the_switch, - current.type, - options->GetValueAt(next_option_index)->str(), - current.reset_value, - current.switch_index, - next_option_index, + current.the_switch, + current.type, + options->GetValueAt(next_option_index)->str(), + current.reset_value, + current.switch_index, + next_option_index, }; } } @@ -108,12 +96,12 @@ Switches::SwitchOption Switches::Reset(const SwitchOption& current) { default_state == current.option_index) return {}; return { - current.the_switch, - current.type, - options->GetValueAt(default_state)->str(), - current.reset_value, - current.switch_index, - default_state, + current.the_switch, + current.type, + options->GetValueAt(default_state)->str(), + current.reset_value, + current.switch_index, + default_state, }; } return {}; @@ -121,16 +109,14 @@ Switches::SwitchOption Switches::Reset(const SwitchOption& current) { Switches::SwitchOption Switches::FindRadioGroupOption( an the_switch, - function callback) { + function callback) { if (auto options = As(the_switch->Get("options"))) { for (size_t j = 0; j < options->size(); ++j) { SwitchOption option{ - the_switch, - kRadioGroup, - options->GetValueAt(j)->str(), - 0, // unknown - 0, // unknown - j, + the_switch, kRadioGroup, options->GetValueAt(j)->str(), + 0, // unknown + 0, // unknown + j, }; if (callback(option) == kFound) return option; @@ -187,11 +173,9 @@ StringSlice Switches::GetStateLabel(const string& option_name, if (the_option.type == kRadioGroup) { // if the query is a deselected option among the radio group, do not // display its state label; only show the selected option. - return state - ? GetStateLabel(the_option.the_switch, - the_option.option_index, - abbreviated) - : StringSlice{nullptr, 0}; + return state ? GetStateLabel(the_option.the_switch, the_option.option_index, + abbreviated) + : StringSlice{nullptr, 0}; } return {nullptr, 0}; } diff --git a/src/rime/switches.h b/src/rime/switches.h index 792775e40..d03b81bbf 100644 --- a/src/rime/switches.h +++ b/src/rime/switches.h @@ -20,7 +20,7 @@ struct StringSlice { }; class Switches { -public: + public: explicit Switches(Config* config) : config_(config) {} enum SwitchType { @@ -39,9 +39,7 @@ class Switches { // the index of the option in the radio group. size_t option_index = 0; - bool found() const { - return bool(the_switch); - } + bool found() const { return bool(the_switch); } }; enum FindResult { @@ -49,7 +47,7 @@ class Switches { kFound, }; - SwitchOption FindOption(function callback); + SwitchOption FindOption(function callback); SwitchOption OptionByName(const string& option_name); @@ -63,10 +61,11 @@ class Switches { static SwitchOption FindRadioGroupOption( an the_switch, - function callback); + function callback); - static StringSlice GetStateLabel( - an the_switch, size_t state_index, bool abbreviated); + static StringSlice GetStateLabel(an the_switch, + size_t state_index, + bool abbreviated); StringSlice GetStateLabel(const string& option_name, int state, @@ -76,11 +75,11 @@ class Switches { SwitchOption FindOptionFromConfigItem( ConfigItemRef& item, size_t switch_index, - function callback); + function callback); Config* config_; }; } // namespace rime -#endif // RIME_SWITCHES_H_ +#endif // RIME_SWITCHES_H_ diff --git a/src/rime/ticket.cc b/src/rime/ticket.cc index d6d653f14..a42ef9087 100644 --- a/src/rime/ticket.cc +++ b/src/rime/ticket.cc @@ -9,12 +9,9 @@ namespace rime { -Ticket::Ticket(Schema* s, const string& ns) - : schema(s), name_space(ns) { -} +Ticket::Ticket(Schema* s, const string& ns) : schema(s), name_space(ns) {} -Ticket::Ticket(Engine* e, const string& ns, - const string& prescription) +Ticket::Ticket(Engine* e, const string& ns, const string& prescription) : engine(e), schema(e ? e->schema() : NULL), name_space(ns), diff --git a/src/rime/ticket.h b/src/rime/ticket.h index e2d501cbc..e1bb3fdb8 100644 --- a/src/rime/ticket.h +++ b/src/rime/ticket.h @@ -24,7 +24,8 @@ struct Ticket { Ticket(Schema* s, const string& ns); // prescription: in the form of "klass" or "klass@alias" // where alias, if given, will override default name space - RIME_API Ticket(Engine* e, const string& ns = "", + RIME_API Ticket(Engine* e, + const string& ns = "", const string& prescription = ""); }; diff --git a/src/rime/translation.cc b/src/rime/translation.cc index 8e36a5522..4a71066ad 100644 --- a/src/rime/translation.cc +++ b/src/rime/translation.cc @@ -95,7 +95,7 @@ an UnionTranslation::Peek() { return translations_.front()->Peek(); } -UnionTranslation& UnionTranslation::operator+= (an t) { +UnionTranslation& UnionTranslation::operator+=(an t) { if (t && !t->exhausted()) { translations_.push_back(t); set_exhausted(false); @@ -103,7 +103,7 @@ UnionTranslation& UnionTranslation::operator+= (an t) { return *this; } -an operator+ (an x, an y) { +an operator+(an x, an y) { auto z = New(); *z += x; *z += y; @@ -145,8 +145,8 @@ void MergedTranslation::Elect() { size_t k = 0; for (; k < translations_.size(); ++k) { const auto& current = translations_[k]; - const auto& next = k + 1 < translations_.size() ? - translations_[k + 1] : nullptr; + const auto& next = + k + 1 < translations_.size() ? translations_[k + 1] : nullptr; if (current->Compare(next, previous_candidates_) <= 0) { if (current->exhausted()) { translations_.erase(translations_.begin() + k); @@ -160,13 +160,12 @@ void MergedTranslation::Elect() { if (k >= translations_.size()) { DLOG(WARNING) << "failed to elect a winner translation."; set_exhausted(true); - } - else { + } else { set_exhausted(false); } } -MergedTranslation& MergedTranslation::operator+= (an t) { +MergedTranslation& MergedTranslation::operator+=(an t) { if (t && !t->exhausted()) { translations_.push_back(t); Elect(); @@ -204,8 +203,7 @@ an CacheTranslation::Peek() { // DistinctTranslation DistinctTranslation::DistinctTranslation(an translation) - : CacheTranslation(translation) { -} + : CacheTranslation(translation) {} bool DistinctTranslation::Next() { if (exhausted()) @@ -213,9 +211,8 @@ bool DistinctTranslation::Next() { candidate_set_.insert(Peek()->text()); do { CacheTranslation::Next(); - } - while (!exhausted() && - AlreadyHas(Peek()->text())); // skip duplicate candidates + } while (!exhausted() && + AlreadyHas(Peek()->text())); // skip duplicate candidates return true; } @@ -236,8 +233,7 @@ bool PrefetchTranslation::Next() { } if (!cache_.empty()) { cache_.pop_front(); - } - else { + } else { translation_->Next(); } if (cache_.empty() && translation_->exhausted()) { @@ -252,8 +248,7 @@ an PrefetchTranslation::Peek() { } if (!cache_.empty() || Replenish()) { return cache_.front(); - } - else { + } else { return translation_->Peek(); } } diff --git a/src/rime/translation.h b/src/rime/translation.h index 2e848058b..8c690203d 100644 --- a/src/rime/translation.h +++ b/src/rime/translation.h @@ -41,8 +41,7 @@ class Translation { class UniqueTranslation : public Translation { public: - UniqueTranslation(an candidate) - : candidate_(candidate) { + UniqueTranslation(an candidate) : candidate_(candidate) { set_exhausted(!candidate); } @@ -62,9 +61,7 @@ class FifoTranslation : public Translation { void Append(an candy); - size_t size() const { - return candies_.size() - cursor_; - } + size_t size() const { return candies_.size() - cursor_; } protected: CandidateList candies_; @@ -78,13 +75,13 @@ class UnionTranslation : public Translation { bool Next(); an Peek(); - UnionTranslation& operator+= (an t); + UnionTranslation& operator+=(an t); protected: list> translations_; }; -an operator+ (an x, an y); +an operator+(an x, an y); class MergedTranslation : public Translation { public: @@ -93,7 +90,7 @@ class MergedTranslation : public Translation { bool Next(); an Peek(); - MergedTranslation& operator+= (an t); + MergedTranslation& operator+=(an t); size_t size() const { return translations_.size(); } @@ -147,6 +144,6 @@ class PrefetchTranslation : public Translation { CandidateQueue cache_; }; -} // namespace rime +} // namespace rime #endif // RIME_TRANSLATION_H_ diff --git a/src/rime/translator.h b/src/rime/translator.h index 4df38d259..78ba7e22b 100644 --- a/src/rime/translator.h +++ b/src/rime/translator.h @@ -26,8 +26,8 @@ class Translator : public Class { virtual ~Translator() = default; virtual an Query(const string& input, - const Segment& segment) = 0; - + const Segment& segment) = 0; + string name_space() const { return name_space_; } protected: diff --git a/src/rime_api.cc b/src/rime_api.cc index 506396eca..270ab923b 100644 --- a/src/rime_api.cc +++ b/src/rime_api.cc @@ -27,7 +27,8 @@ using namespace rime; using namespace std::placeholders; // assume member is a non-null pointer in struct *p. -#define PROVIDED(p, member) ((p) && RIME_STRUCT_HAS_MEMBER(*(p), (p)->member) && (p)->member) +#define PROVIDED(p, member) \ + ((p) && RIME_STRUCT_HAS_MEMBER(*(p), (p)->member) && (p)->member) RIME_API void RimeSetupLogging(const char* app_name) { SetupLogging(app_name); @@ -49,7 +50,7 @@ static void rime_declare_module_dependencies() { } #endif -RIME_API void RimeSetup(RimeTraits *traits) { +RIME_API void RimeSetup(RimeTraits* traits) { rime_declare_module_dependencies(); SetupDeployer(traits); @@ -68,13 +69,12 @@ RIME_API void RimeSetNotificationHandler(RimeNotificationHandler handler, if (handler) { Service::instance().SetNotificationHandler( std::bind(handler, context_object, _1, _2, _3)); - } - else { + } else { Service::instance().ClearNotificationHandler(); } } -RIME_API void RimeInitialize(RimeTraits *traits) { +RIME_API void RimeInitialize(RimeTraits* traits) { SetupDeployer(traits); LoadModules(PROVIDED(traits, modules) ? traits->modules : kDefaultModules); Service::instance().StartService(); @@ -89,17 +89,17 @@ RIME_API void RimeFinalize() { RIME_API Bool RimeStartMaintenance(Bool full_check) { LoadModules(kDeployerModules); - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); deployer.RunTask("clean_old_log_files"); if (!deployer.RunTask("installation_update")) { return False; } if (!full_check) { TaskInitializer args{ - vector{ - deployer.user_data_dir, - deployer.shared_data_dir, - }, + vector{ + deployer.user_data_dir, + deployer.shared_data_dir, + }, }; if (!deployer.RunTask("detect_modifications", args)) { return False; @@ -118,42 +118,42 @@ RIME_API Bool RimeStartMaintenanceOnWorkspaceChange() { } RIME_API Bool RimeIsMaintenancing() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return Bool(deployer.IsMaintenanceMode()); } RIME_API void RimeJoinMaintenanceThread() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); deployer.JoinMaintenanceThread(); } // deployment -RIME_API void RimeDeployerInitialize(RimeTraits *traits) { +RIME_API void RimeDeployerInitialize(RimeTraits* traits) { SetupDeployer(traits); LoadModules(PROVIDED(traits, modules) ? traits->modules : kDeployerModules); } RIME_API Bool RimePrebuildAllSchemas() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return Bool(deployer.RunTask("prebuild_all_schemas")); } RIME_API Bool RimeDeployWorkspace() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return Bool(deployer.RunTask("installation_update") && deployer.RunTask("workspace_update") && deployer.RunTask("user_dict_upgrade") && deployer.RunTask("cleanup_trash")); } -RIME_API Bool RimeDeploySchema(const char *schema_file) { - Deployer &deployer(Service::instance().deployer()); +RIME_API Bool RimeDeploySchema(const char* schema_file) { + Deployer& deployer(Service::instance().deployer()); return Bool(deployer.RunTask("schema_update", string(schema_file))); } -RIME_API Bool RimeDeployConfigFile(const char *file_name, - const char *version_key) { +RIME_API Bool RimeDeployConfigFile(const char* file_name, + const char* version_key) { Deployer& deployer(Service::instance().deployer()); TaskInitializer args(make_pair(file_name, version_key)); return Bool(deployer.RunTask("config_file_update", args)); @@ -222,8 +222,7 @@ static void rime_candidate_copy(RimeCandidate* dest, const an& src) { if (!comment.empty()) { dest->comment = new char[comment.length() + 1]; std::strcpy(dest->comment, comment.c_str()); - } - else { + } else { dest->comment = nullptr; } dest->reserved = nullptr; @@ -236,7 +235,7 @@ RIME_API Bool RimeGetContext(RimeSessionId session_id, RimeContext* context) { an session(Service::instance().GetSession(session_id)); if (!session) return False; - Context *ctx = session->context(); + Context* ctx = session->context(); if (!ctx) return False; if (ctx->IsComposing()) { @@ -256,9 +255,9 @@ RIME_API Bool RimeGetContext(RimeSessionId session_id, RimeContext* context) { } } if (ctx->HasMenu()) { - Segment &seg(ctx->composition().back()); + Segment& seg(ctx->composition().back()); int page_size = 5; - Schema *schema = session->schema(); + Schema* schema = session->schema(); if (schema) page_size = schema->page_size(); int selected_index = seg.selected_index; @@ -272,7 +271,7 @@ RIME_API Bool RimeGetContext(RimeSessionId session_id, RimeContext* context) { int i = 0; context->menu.num_candidates = page->candidates.size(); context->menu.candidates = new RimeCandidate[page->candidates.size()]; - for (const an &cand : page->candidates) { + for (const an& cand : page->candidates) { RimeCandidate* dest = &context->menu.candidates[i++]; rime_candidate_copy(dest, cand); } @@ -283,7 +282,8 @@ RIME_API Bool RimeGetContext(RimeSessionId session_id, RimeContext* context) { std::strcpy(context->menu.select_keys, select_keys.c_str()); } Config* config = schema->config(); - an select_labels = config->GetList("menu/alternative_select_labels"); + an select_labels = + config->GetList("menu/alternative_select_labels"); if (select_labels && (size_t)page_size <= select_labels->size()) { context->select_labels = new char*[page_size]; for (size_t i = 0; i < (size_t)page_size; ++i) { @@ -309,7 +309,8 @@ RIME_API Bool RimeFreeContext(RimeContext* context) { } delete[] context->menu.candidates; delete[] context->menu.select_keys; - if (RIME_STRUCT_HAS_MEMBER(*context, context->select_labels) && context->select_labels) { + if (RIME_STRUCT_HAS_MEMBER(*context, context->select_labels) && + context->select_labels) { for (int i = 0; i < context->menu.page_size; ++i) { delete[] context->select_labels[i]; } @@ -323,7 +324,7 @@ RIME_API Bool RimeFreeContext(RimeContext* context) { } RIME_API Bool RimeGetCommit(RimeSessionId session_id, RimeCommit* commit) { - if (!commit) + if (!commit) return False; RIME_STRUCT_CLEAR(*commit); an session(Service::instance().GetSession(session_id)); @@ -348,14 +349,14 @@ RIME_API Bool RimeFreeCommit(RimeCommit* commit) { } RIME_API Bool RimeGetStatus(RimeSessionId session_id, RimeStatus* status) { - if (!status || status->data_size <= 0) + if (!status || status->data_size <= 0) return False; RIME_STRUCT_CLEAR(*status); an session(Service::instance().GetSession(session_id)); if (!session) return False; - Schema *schema = session->schema(); - Context *ctx = session->context(); + Schema* schema = session->schema(); + Context* ctx = session->context(); if (!schema || !ctx) return False; status->schema_id = new char[schema->schema_id().length() + 1]; @@ -391,7 +392,7 @@ RIME_API Bool RimeCandidateListFromIndex(RimeSessionId session_id, an session(Service::instance().GetSession(session_id)); if (!session) return False; - Context *ctx = session->context(); + Context* ctx = session->context(); if (!ctx || !ctx->HasMenu()) return False; memset(iterator, 0, sizeof(RimeCandidateListIterator)); @@ -408,7 +409,7 @@ RIME_API Bool RimeCandidateListBegin(RimeSessionId session_id, RIME_API Bool RimeCandidateListNext(RimeCandidateListIterator* iterator) { if (!iterator) return False; - Menu *menu = reinterpret_cast(iterator->ptr); + Menu* menu = reinterpret_cast(iterator->ptr); if (!menu) return False; ++iterator->index; @@ -431,11 +432,13 @@ RIME_API void RimeCandidateListEnd(RimeCandidateListIterator* iterator) { // runtime options -RIME_API void RimeSetOption(RimeSessionId session_id, const char* option, Bool value) { +RIME_API void RimeSetOption(RimeSessionId session_id, + const char* option, + Bool value) { an session(Service::instance().GetSession(session_id)); if (!session) return; - Context *ctx = session->context(); + Context* ctx = session->context(); if (!ctx) return; ctx->set_option(option, !!value); @@ -445,28 +448,32 @@ RIME_API Bool RimeGetOption(RimeSessionId session_id, const char* option) { an session(Service::instance().GetSession(session_id)); if (!session) return False; - Context *ctx = session->context(); + Context* ctx = session->context(); if (!ctx) return False; return Bool(ctx->get_option(option)); } -RIME_API void RimeSetProperty(RimeSessionId session_id, const char* prop, const char* value) { +RIME_API void RimeSetProperty(RimeSessionId session_id, + const char* prop, + const char* value) { an session(Service::instance().GetSession(session_id)); if (!session) return; - Context *ctx = session->context(); + Context* ctx = session->context(); if (!ctx) return; ctx->set_property(prop, value); } -RIME_API Bool RimeGetProperty(RimeSessionId session_id, const char* prop, - char* value, size_t buffer_size) { +RIME_API Bool RimeGetProperty(RimeSessionId session_id, + const char* prop, + char* value, + size_t buffer_size) { an session(Service::instance().GetSession(session_id)); if (!session) return False; - Context *ctx = session->context(); + Context* ctx = session->context(); if (!ctx) return False; string str_value(ctx->get_property(prop)); @@ -477,22 +484,26 @@ RIME_API Bool RimeGetProperty(RimeSessionId session_id, const char* prop, } RIME_API Bool RimeGetSchemaList(RimeSchemaList* output) { - if (!output) return False; + if (!output) + return False; output->size = 0; output->list = NULL; Schema default_schema; Config* config = default_schema.config(); - if (!config) return False; + if (!config) + return False; an schema_list = config->GetList("schema_list"); if (!schema_list || schema_list->size() == 0) return False; output->list = new RimeSchemaListItem[schema_list->size()]; for (size_t i = 0; i < schema_list->size(); ++i) { an item = As(schema_list->GetAt(i)); - if (!item) continue; + if (!item) + continue; an schema_property = item->GetValue("schema"); - if (!schema_property) continue; - const string &schema_id(schema_property->str()); + if (!schema_property) + continue; + const string& schema_id(schema_property->str()); RimeSchemaListItem& x(output->list[output->size]); x.schema_id = new char[schema_id.length() + 1]; strcpy(x.schema_id, schema_id.c_str()); @@ -511,7 +522,8 @@ RIME_API Bool RimeGetSchemaList(RimeSchemaList* output) { } RIME_API void RimeFreeSchemaList(RimeSchemaList* schema_list) { - if (!schema_list) return; + if (!schema_list) + return; if (schema_list->list) { for (size_t i = 0; i < schema_list->size; ++i) { delete[] schema_list->list[i].schema_id; @@ -523,19 +535,26 @@ RIME_API void RimeFreeSchemaList(RimeSchemaList* schema_list) { schema_list->list = NULL; } -RIME_API Bool RimeGetCurrentSchema(RimeSessionId session_id, char* schema_id, size_t buffer_size) { +RIME_API Bool RimeGetCurrentSchema(RimeSessionId session_id, + char* schema_id, + size_t buffer_size) { an session(Service::instance().GetSession(session_id)); - if (!session) return False; + if (!session) + return False; Schema* schema = session->schema(); - if (!schema) return False; + if (!schema) + return False; strncpy(schema_id, schema->schema_id().c_str(), buffer_size); return True; } -RIME_API Bool RimeSelectSchema(RimeSessionId session_id, const char* schema_id) { - if (!schema_id) return False; +RIME_API Bool RimeSelectSchema(RimeSessionId session_id, + const char* schema_id) { + if (!schema_id) + return False; an session(Service::instance().GetSession(session_id)); - if (!session) return False; + if (!session) + return False; session->ApplySchema(new Schema(schema_id)); return True; } @@ -545,20 +564,23 @@ RIME_API Bool RimeSelectSchema(RimeSessionId session_id, const char* schema_id) static Bool open_config_in_component(const char* config_component, const char* config_id, RimeConfig* config) { - if (!config_id || !config) return False; + if (!config_id || !config) + return False; Config::Component* cc = Config::Require(config_component); - if (!cc) return False; + if (!cc) + return False; Config* c = cc->Create(config_id); - if (!c) return False; + if (!c) + return False; config->ptr = (void*)c; return True; } -RIME_API Bool RimeSchemaOpen(const char *schema_id, RimeConfig* config) { +RIME_API Bool RimeSchemaOpen(const char* schema_id, RimeConfig* config) { return open_config_in_component("schema", schema_id, config); } -RIME_API Bool RimeConfigOpen(const char *config_id, RimeConfig* config) { +RIME_API Bool RimeConfigOpen(const char* config_id, RimeConfig* config) { return open_config_in_component("config", config_id, config); } @@ -566,17 +588,21 @@ RIME_API Bool RimeUserConfigOpen(const char* config_id, RimeConfig* config) { return open_config_in_component("user_config", config_id, config); } -RIME_API Bool RimeConfigClose(RimeConfig *config) { - if (!config || !config->ptr) return False; - Config *c = reinterpret_cast(config->ptr); +RIME_API Bool RimeConfigClose(RimeConfig* config) { + if (!config || !config->ptr) + return False; + Config* c = reinterpret_cast(config->ptr); delete c; config->ptr = NULL; return True; } -RIME_API Bool RimeConfigGetBool(RimeConfig *config, const char *key, Bool *value) { - if (!config || !key || !value) return False; - Config *c = reinterpret_cast(config->ptr); +RIME_API Bool RimeConfigGetBool(RimeConfig* config, + const char* key, + Bool* value) { + if (!config || !key || !value) + return False; + Config* c = reinterpret_cast(config->ptr); bool bool_value = false; if (c->GetBool(key, &bool_value)) { *value = Bool(bool_value); @@ -585,23 +611,33 @@ RIME_API Bool RimeConfigGetBool(RimeConfig *config, const char *key, Bool *value return False; } -RIME_API Bool RimeConfigGetInt(RimeConfig *config, const char *key, int *value) { - if (!config || !key || !value) return False; - Config *c = reinterpret_cast(config->ptr); +RIME_API Bool RimeConfigGetInt(RimeConfig* config, + const char* key, + int* value) { + if (!config || !key || !value) + return False; + Config* c = reinterpret_cast(config->ptr); return Bool(c->GetInt(key, value)); } -RIME_API Bool RimeConfigGetDouble(RimeConfig *config, const char *key, double *value) { - if (!config || !key || !value) return False; - Config *c = reinterpret_cast(config->ptr); +RIME_API Bool RimeConfigGetDouble(RimeConfig* config, + const char* key, + double* value) { + if (!config || !key || !value) + return False; + Config* c = reinterpret_cast(config->ptr); return Bool(c->GetDouble(key, value)); } -RIME_API Bool RimeConfigGetString(RimeConfig *config, const char *key, - char *value, size_t buffer_size) { - if (!config || !key || !value) return False; - Config *c = reinterpret_cast(config->ptr); - if (!c) return False; +RIME_API Bool RimeConfigGetString(RimeConfig* config, + const char* key, + char* value, + size_t buffer_size) { + if (!config || !key || !value) + return False; + Config* c = reinterpret_cast(config->ptr); + if (!c) + return False; string str_value; if (c->GetString(key, &str_value)) { std::strncpy(value, str_value.c_str(), buffer_size); @@ -610,20 +646,24 @@ RIME_API Bool RimeConfigGetString(RimeConfig *config, const char *key, return False; } -RIME_API const char* RimeConfigGetCString(RimeConfig *config, const char *key) { - if (!config || !key) return NULL; - Config *c = reinterpret_cast(config->ptr); - if (!c) return NULL; +RIME_API const char* RimeConfigGetCString(RimeConfig* config, const char* key) { + if (!config || !key) + return NULL; + Config* c = reinterpret_cast(config->ptr); + if (!c) + return NULL; if (an v = c->GetValue(key)) { return v->str().c_str(); } return NULL; } -RIME_API Bool RimeConfigUpdateSignature(RimeConfig *config, const char* signer) { - if (!config || !signer) return False; - Config *c = reinterpret_cast(config->ptr); - Deployer &deployer(Service::instance().deployer()); +RIME_API Bool RimeConfigUpdateSignature(RimeConfig* config, + const char* signer) { + if (!config || !signer) + return False; + Config* c = reinterpret_cast(config->ptr); + Deployer& deployer(Service::instance().deployer()); Signature sig(signer); return Bool(sig.Sign(c, &deployer)); } @@ -636,19 +676,18 @@ struct RimeConfigIteratorImpl { string key; string path; RimeConfigIteratorImpl(T& container, const string& root_path) - : iter(container.begin()), - end(container.end()) { + : iter(container.begin()), end(container.end()) { if (root_path.empty() || root_path == "/") { // prefix is empty - } - else { + } else { prefix = root_path + "/"; } } }; RIME_API Bool RimeConfigBeginList(RimeConfigIterator* iterator, - RimeConfig* config, const char* key) { + RimeConfig* config, + const char* key) { if (!iterator || !config || !key) return False; iterator->list = NULL; @@ -656,7 +695,7 @@ RIME_API Bool RimeConfigBeginList(RimeConfigIterator* iterator, iterator->index = -1; iterator->key = NULL; iterator->path = NULL; - Config *c = reinterpret_cast(config->ptr); + Config* c = reinterpret_cast(config->ptr); if (!c) return False; an list = c->GetList(key); @@ -667,7 +706,8 @@ RIME_API Bool RimeConfigBeginList(RimeConfigIterator* iterator, } RIME_API Bool RimeConfigBeginMap(RimeConfigIterator* iterator, - RimeConfig* config, const char* key) { + RimeConfig* config, + const char* key) { if (!iterator || !config || !key) return False; iterator->list = NULL; @@ -675,10 +715,12 @@ RIME_API Bool RimeConfigBeginMap(RimeConfigIterator* iterator, iterator->index = -1; iterator->key = NULL; iterator->path = NULL; - Config *c = reinterpret_cast(config->ptr); - if (!c) return False; + Config* c = reinterpret_cast(config->ptr); + if (!c) + return False; an m = c->GetMap(key); - if (!m) return False; + if (!m) + return False; iterator->map = new RimeConfigIteratorImpl(*m, key); return True; } @@ -689,7 +731,8 @@ RIME_API Bool RimeConfigNext(RimeConfigIterator* iterator) { if (iterator->list) { RimeConfigIteratorImpl* p = reinterpret_cast*>(iterator->list); - if (!p) return False; + if (!p) + return False; if (++iterator->index > 0) ++p->iter; if (p->iter == p->end) @@ -703,7 +746,8 @@ RIME_API Bool RimeConfigNext(RimeConfigIterator* iterator) { if (iterator->map) { RimeConfigIteratorImpl* p = reinterpret_cast*>(iterator->map); - if (!p) return False; + if (!p) + return False; if (++iterator->index > 0) ++p->iter; if (p->iter == p->end) @@ -718,16 +762,18 @@ RIME_API Bool RimeConfigNext(RimeConfigIterator* iterator) { } RIME_API void RimeConfigEnd(RimeConfigIterator* iterator) { - if (!iterator) return; + if (!iterator) + return; if (iterator->list) - delete reinterpret_cast*>(iterator->list); + delete reinterpret_cast*>( + iterator->list); if (iterator->map) delete reinterpret_cast*>(iterator->map); memset(iterator, 0, sizeof(RimeConfigIterator)); } - -RIME_API Bool RimeSimulateKeySequence(RimeSessionId session_id, const char *key_sequence) { +RIME_API Bool RimeSimulateKeySequence(RimeSessionId session_id, + const char* key_sequence) { LOG(INFO) << "simulate key sequence: " << key_sequence; an session(Service::instance().GetSession(session_id)); if (!session) @@ -757,42 +803,42 @@ RIME_API RimeModule* RimeFindModule(const char* module_name) { RIME_API Bool RimeRunTask(const char* task_name) { if (!task_name) return False; - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return Bool(deployer.RunTask(task_name)); } RIME_API const char* RimeGetSharedDataDir() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return deployer.shared_data_dir.c_str(); } RIME_API const char* RimeGetUserDataDir() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return deployer.user_data_dir.c_str(); } RIME_API const char* RimeGetPrebuiltDataDir() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return deployer.prebuilt_data_dir.c_str(); } RIME_API const char* RimeGetStagingDir() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return deployer.staging_dir.c_str(); } RIME_API const char* RimeGetSyncDir() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return deployer.sync_dir.c_str(); } RIME_API const char* RimeGetUserId() { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); return deployer.user_id.c_str(); } RIME_API void RimeGetUserDataSyncDir(char* dir, size_t buffer_size) { - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); strncpy(dir, deployer.user_data_sync_dir().c_str(), buffer_size); } @@ -815,7 +861,9 @@ RIME_API Bool RimeConfigLoadString(RimeConfig* config, const char* yaml) { return Bool(c->LoadFromStream(iss)); } -RIME_API Bool RimeConfigGetItem(RimeConfig* config, const char* key, RimeConfig* value) { +RIME_API Bool RimeConfigGetItem(RimeConfig* config, + const char* key, + RimeConfig* value) { if (!config || !key || !value) return False; Config* c = reinterpret_cast(config->ptr); @@ -829,7 +877,9 @@ RIME_API Bool RimeConfigGetItem(RimeConfig* config, const char* key, RimeConfig* return True; } -RIME_API Bool RimeConfigSetItem(RimeConfig* config, const char* key, RimeConfig* value) { +RIME_API Bool RimeConfigSetItem(RimeConfig* config, + const char* key, + RimeConfig* value) { if (!config || !key) return False; Config* c = reinterpret_cast(config->ptr); @@ -844,7 +894,9 @@ RIME_API Bool RimeConfigSetItem(RimeConfig* config, const char* key, RimeConfig* return Bool(c->SetItem(key, item)); } -RIME_API Bool RimeConfigSetBool(RimeConfig* config, const char* key, Bool value) { +RIME_API Bool RimeConfigSetBool(RimeConfig* config, + const char* key, + Bool value) { if (!config || !key) return False; Config* c = reinterpret_cast(config->ptr); @@ -862,7 +914,9 @@ RIME_API Bool RimeConfigSetInt(RimeConfig* config, const char* key, int value) { return Bool(c->SetInt(key, value)); } -RIME_API Bool RimeConfigSetDouble(RimeConfig* config, const char* key, double value) { +RIME_API Bool RimeConfigSetDouble(RimeConfig* config, + const char* key, + double value) { if (!config || !key) return False; Config* c = reinterpret_cast(config->ptr); @@ -871,7 +925,9 @@ RIME_API Bool RimeConfigSetDouble(RimeConfig* config, const char* key, double va return Bool(c->SetDouble(key, value)); } -RIME_API Bool RimeConfigSetString(RimeConfig* config, const char* key, const char* value) { +RIME_API Bool RimeConfigSetString(RimeConfig* config, + const char* key, + const char* value) { if (!config || !key || !value) return False; Config* c = reinterpret_cast(config->ptr); @@ -923,7 +979,7 @@ const char* RimeGetInput(RimeSessionId session_id) { an session(Service::instance().GetSession(session_id)); if (!session) return NULL; - Context *ctx = session->context(); + Context* ctx = session->context(); if (!ctx) return NULL; return ctx->input().c_str(); @@ -933,49 +989,51 @@ size_t RimeGetCaretPos(RimeSessionId session_id) { an session(Service::instance().GetSession(session_id)); if (!session) return 0; - Context *ctx = session->context(); + Context* ctx = session->context(); if (!ctx) return 0; return ctx->caret_pos(); } -static bool do_with_candidate(RimeSessionId session_id, size_t index, - bool (Context::* verb)(size_t index)) { +static bool do_with_candidate(RimeSessionId session_id, + size_t index, + bool (Context::*verb)(size_t index)) { an session(Service::instance().GetSession(session_id)); if (!session) - return False; - Context *ctx = session->context(); - if (!ctx) - return False; - return (ctx->*verb)(index); + return False; + Context* ctx = session->context(); + if (!ctx) + return False; + return (ctx->*verb)(index); } static bool do_with_candidate_on_current_page( - RimeSessionId session_id, size_t index, - bool (Context::* verb)(size_t index)) { + RimeSessionId session_id, + size_t index, + bool (Context::*verb)(size_t index)) { an session(Service::instance().GetSession(session_id)); if (!session) - return False; - Context *ctx = session->context(); - if (!ctx || !ctx->HasMenu()) - return False; - Schema *schema = session->schema(); - if (!schema) - return False; - size_t page_size = (size_t)schema->page_size(); - if (index >= page_size) - return False; - const auto& seg(ctx->composition().back()); - size_t page_start = seg.selected_index / page_size * page_size; - return (ctx->*verb)(page_start + index); + return False; + Context* ctx = session->context(); + if (!ctx || !ctx->HasMenu()) + return False; + Schema* schema = session->schema(); + if (!schema) + return False; + size_t page_size = (size_t)schema->page_size(); + if (index >= page_size) + return False; + const auto& seg(ctx->composition().back()); + size_t page_start = seg.selected_index / page_size * page_size; + return (ctx->*verb)(page_start + index); } - RIME_API Bool RimeSelectCandidate(RimeSessionId session_id, size_t index) { return do_with_candidate(session_id, index, &Context::Select); } -RIME_API Bool RimeSelectCandidateOnCurrentPage(RimeSessionId session_id, size_t index) { +RIME_API Bool RimeSelectCandidateOnCurrentPage(RimeSessionId session_id, + size_t index) { return do_with_candidate_on_current_page(session_id, index, &Context::Select); } @@ -987,16 +1045,17 @@ RIME_API Bool RimeDeleteCandidate(RimeSessionId session_id, size_t index) { return do_with_candidate(session_id, index, &Context::DeleteCandidate); } -RIME_API Bool RimeDeleteCandidateOnCurrentPage(RimeSessionId session_id, size_t index) { - return do_with_candidate_on_current_page( - session_id, index, &Context::DeleteCandidate); +RIME_API Bool RimeDeleteCandidateOnCurrentPage(RimeSessionId session_id, + size_t index) { + return do_with_candidate_on_current_page(session_id, index, + &Context::DeleteCandidate); } void RimeSetCaretPos(RimeSessionId session_id, size_t caret_pos) { an session(Service::instance().GetSession(session_id)); if (!session) return; - Context *ctx = session->context(); + Context* ctx = session->context(); if (!ctx) return; return ctx->set_caret_pos(caret_pos); @@ -1013,15 +1072,15 @@ RimeStringSlice RimeGetStateLabelAbbreviated(RimeSessionId session_id, if (!config) return {nullptr, 0}; Switches switches(config); - StringSlice label = - switches.GetStateLabel(option_name, state, abbreviated); + StringSlice label = switches.GetStateLabel(option_name, state, abbreviated); return {label.str, label.length}; } const char* RimeGetStateLabel(RimeSessionId session_id, const char* option_name, Bool state) { - return RimeGetStateLabelAbbreviated(session_id, option_name, state, False).str; + return RimeGetStateLabelAbbreviated(session_id, option_name, state, False) + .str; } RIME_API RimeApi* rime_get_api() { @@ -1053,7 +1112,7 @@ RIME_API RimeApi* rime_get_api() { s_api.free_commit = &RimeFreeCommit; s_api.get_context = &RimeGetContext; s_api.free_context = &RimeFreeContext; - s_api.get_status = &RimeGetStatus; + s_api.get_status = &RimeGetStatus; s_api.free_status = &RimeFreeStatus; s_api.set_option = &RimeSetOption; s_api.get_option = &RimeGetOption; diff --git a/src/rime_api.h b/src/rime_api.h index d0bc966a3..6315c670c 100644 --- a/src/rime_api.h +++ b/src/rime_api.h @@ -26,9 +26,9 @@ extern "C" { /* static library */ #define RIME_API #endif -#else /* _WIN32 */ +#else /* _WIN32 */ #define RIME_API -#endif /* _WIN32 */ +#endif /* _WIN32 */ typedef uintptr_t RimeSessionId; @@ -48,12 +48,18 @@ typedef int Bool; #define RIME_MAX_NUM_CANDIDATES 10 // Version control -#define RIME_STRUCT_INIT(Type, var) ((var).data_size = sizeof(Type) - sizeof((var).data_size)) -#define RIME_STRUCT_HAS_MEMBER(var, member) ((int)(sizeof((var).data_size) + (var).data_size) > (char*)&member - (char*)&var) -#define RIME_STRUCT_CLEAR(var) memset((char*)&(var) + sizeof((var).data_size), 0, (var).data_size) +#define RIME_STRUCT_INIT(Type, var) \ + ((var).data_size = sizeof(Type) - sizeof((var).data_size)) +#define RIME_STRUCT_HAS_MEMBER(var, member) \ + ((int)(sizeof((var).data_size) + (var).data_size) > \ + (char*)&member - (char*)&var) +#define RIME_STRUCT_CLEAR(var) \ + memset((char*)&(var) + sizeof((var).data_size), 0, (var).data_size) //! Define a variable of Type -#define RIME_STRUCT(Type, var) Type var = {0}; RIME_STRUCT_INIT(Type, var); +#define RIME_STRUCT(Type, var) \ + Type var = {0}; \ + RIME_STRUCT_INIT(Type, var); //! For passing pointer to capnproto builder as opaque pointer through C API. #define RIME_PROTO_BUILDER void @@ -160,7 +166,7 @@ typedef struct rime_status_t { } RimeStatus; typedef struct rime_candidate_list_iterator_t { - void *ptr; + void* ptr; int index; RimeCandidate candidate; } RimeCandidateListIterator; @@ -203,7 +209,7 @@ typedef struct rime_string_slice_t { /*! * Call this function before accessing any other API. */ -RIME_API void RimeSetup(RimeTraits *traits); +RIME_API void RimeSetup(RimeTraits* traits); /*! * Pass a C-string constant in the format "rime.x" @@ -234,7 +240,7 @@ RIME_API void RimeSetNotificationHandler(RimeNotificationHandler handler, // Entry and exit -RIME_API void RimeInitialize(RimeTraits *traits); +RIME_API void RimeInitialize(RimeTraits* traits); RIME_API void RimeFinalize(void); RIME_API Bool RimeStartMaintenance(Bool full_check); @@ -246,11 +252,12 @@ RIME_API void RimeJoinMaintenanceThread(void); // Deployment -RIME_API void RimeDeployerInitialize(RimeTraits *traits); +RIME_API void RimeDeployerInitialize(RimeTraits* traits); RIME_API Bool RimePrebuildAllSchemas(void); RIME_API Bool RimeDeployWorkspace(void); -RIME_API Bool RimeDeploySchema(const char *schema_file); -RIME_API Bool RimeDeployConfigFile(const char *file_name, const char *version_key); +RIME_API Bool RimeDeploySchema(const char* schema_file); +RIME_API Bool RimeDeployConfigFile(const char* file_name, + const char* version_key); RIME_API Bool RimeSyncUserData(void); @@ -281,28 +288,40 @@ RIME_API Bool RimeGetStatus(RimeSessionId session_id, RimeStatus* status); RIME_API Bool RimeFreeStatus(RimeStatus* status); // Accessing candidate list -RIME_API Bool RimeCandidateListBegin(RimeSessionId session_id, RimeCandidateListIterator* iterator); +RIME_API Bool RimeCandidateListBegin(RimeSessionId session_id, + RimeCandidateListIterator* iterator); RIME_API Bool RimeCandidateListNext(RimeCandidateListIterator* iterator); RIME_API void RimeCandidateListEnd(RimeCandidateListIterator* iterator); RIME_API Bool RimeCandidateListFromIndex(RimeSessionId session_id, RimeCandidateListIterator* iterator, int index); RIME_API Bool RimeSelectCandidate(RimeSessionId session_id, size_t index); -RIME_API Bool RimeSelectCandidateOnCurrentPage(RimeSessionId session_id, size_t index); +RIME_API Bool RimeSelectCandidateOnCurrentPage(RimeSessionId session_id, + size_t index); RIME_API Bool RimeDeleteCandidate(RimeSessionId session_id, size_t index); -RIME_API Bool RimeDeleteCandidateOnCurrentPage(RimeSessionId session_id, size_t index); +RIME_API Bool RimeDeleteCandidateOnCurrentPage(RimeSessionId session_id, + size_t index); // Runtime options -RIME_API void RimeSetOption(RimeSessionId session_id, const char* option, Bool value); +RIME_API void RimeSetOption(RimeSessionId session_id, + const char* option, + Bool value); RIME_API Bool RimeGetOption(RimeSessionId session_id, const char* option); -RIME_API void RimeSetProperty(RimeSessionId session_id, const char* prop, const char* value); -RIME_API Bool RimeGetProperty(RimeSessionId session_id, const char* prop, char* value, size_t buffer_size); +RIME_API void RimeSetProperty(RimeSessionId session_id, + const char* prop, + const char* value); +RIME_API Bool RimeGetProperty(RimeSessionId session_id, + const char* prop, + char* value, + size_t buffer_size); RIME_API Bool RimeGetSchemaList(RimeSchemaList* schema_list); RIME_API void RimeFreeSchemaList(RimeSchemaList* schema_list); -RIME_API Bool RimeGetCurrentSchema(RimeSessionId session_id, char* schema_id, size_t buffer_size); +RIME_API Bool RimeGetCurrentSchema(RimeSessionId session_id, + char* schema_id, + size_t buffer_size); RIME_API Bool RimeSelectSchema(RimeSessionId session_id, const char* schema_id); // Configuration @@ -311,31 +330,52 @@ RIME_API Bool RimeSelectSchema(RimeSessionId session_id, const char* schema_id); RIME_API Bool RimeSchemaOpen(const char* schema_id, RimeConfig* config); // .yaml RIME_API Bool RimeConfigOpen(const char* config_id, RimeConfig* config); -// access config files in user data directory, eg. user.yaml and installation.yaml +// access config files in user data directory, eg. user.yaml and +// installation.yaml RIME_API Bool RimeUserConfigOpen(const char* config_id, RimeConfig* config); RIME_API Bool RimeConfigClose(RimeConfig* config); RIME_API Bool RimeConfigInit(RimeConfig* config); RIME_API Bool RimeConfigLoadString(RimeConfig* config, const char* yaml); // Access config values -RIME_API Bool RimeConfigGetBool(RimeConfig *config, const char *key, Bool *value); -RIME_API Bool RimeConfigGetInt(RimeConfig *config, const char *key, int *value); -RIME_API Bool RimeConfigGetDouble(RimeConfig *config, const char *key, double *value); -RIME_API Bool RimeConfigGetString(RimeConfig *config, const char *key, - char *value, size_t buffer_size); -RIME_API const char* RimeConfigGetCString(RimeConfig *config, const char *key); -RIME_API Bool RimeConfigSetBool(RimeConfig *config, const char *key, Bool value); -RIME_API Bool RimeConfigSetInt(RimeConfig *config, const char *key, int value); -RIME_API Bool RimeConfigSetDouble(RimeConfig *config, const char *key, double value); -RIME_API Bool RimeConfigSetString(RimeConfig *config, const char *key, const char *value); +RIME_API Bool RimeConfigGetBool(RimeConfig* config, + const char* key, + Bool* value); +RIME_API Bool RimeConfigGetInt(RimeConfig* config, const char* key, int* value); +RIME_API Bool RimeConfigGetDouble(RimeConfig* config, + const char* key, + double* value); +RIME_API Bool RimeConfigGetString(RimeConfig* config, + const char* key, + char* value, + size_t buffer_size); +RIME_API const char* RimeConfigGetCString(RimeConfig* config, const char* key); +RIME_API Bool RimeConfigSetBool(RimeConfig* config, + const char* key, + Bool value); +RIME_API Bool RimeConfigSetInt(RimeConfig* config, const char* key, int value); +RIME_API Bool RimeConfigSetDouble(RimeConfig* config, + const char* key, + double value); +RIME_API Bool RimeConfigSetString(RimeConfig* config, + const char* key, + const char* value); // Manipulate complex structures -RIME_API Bool RimeConfigGetItem(RimeConfig* config, const char* key, RimeConfig* value); -RIME_API Bool RimeConfigSetItem(RimeConfig* config, const char* key, RimeConfig* value); +RIME_API Bool RimeConfigGetItem(RimeConfig* config, + const char* key, + RimeConfig* value); +RIME_API Bool RimeConfigSetItem(RimeConfig* config, + const char* key, + RimeConfig* value); RIME_API Bool RimeConfigClear(RimeConfig* config, const char* key); RIME_API Bool RimeConfigCreateList(RimeConfig* config, const char* key); RIME_API Bool RimeConfigCreateMap(RimeConfig* config, const char* key); RIME_API size_t RimeConfigListSize(RimeConfig* config, const char* key); -RIME_API Bool RimeConfigBeginList(RimeConfigIterator* iterator, RimeConfig* config, const char* key); -RIME_API Bool RimeConfigBeginMap(RimeConfigIterator* iterator, RimeConfig* config, const char* key); +RIME_API Bool RimeConfigBeginList(RimeConfigIterator* iterator, + RimeConfig* config, + const char* key); +RIME_API Bool RimeConfigBeginMap(RimeConfigIterator* iterator, + RimeConfig* config, + const char* key); RIME_API Bool RimeConfigNext(RimeConfigIterator* iterator); RIME_API void RimeConfigEnd(RimeConfigIterator* iterator); // Utilities @@ -343,12 +383,14 @@ RIME_API Bool RimeConfigUpdateSignature(RimeConfig* config, const char* signer); // Testing -RIME_API Bool RimeSimulateKeySequence(RimeSessionId session_id, const char *key_sequence); +RIME_API Bool RimeSimulateKeySequence(RimeSessionId session_id, + const char* key_sequence); // Module /*! - * Extend the structure to publish custom data/functions in your specific module + * Extend the structure to publish custom data/functions in your specific + * module */ typedef struct rime_custom_api_t { int data_size; @@ -406,7 +448,7 @@ typedef struct rime_api_t { // entry and exit - void (*initialize)(RimeTraits *traits); + void (*initialize)(RimeTraits* traits); void (*finalize)(void); Bool (*start_maintenance)(Bool full_check); @@ -415,11 +457,11 @@ typedef struct rime_api_t { // deployment - void (*deployer_initialize)(RimeTraits *traits); + void (*deployer_initialize)(RimeTraits* traits); Bool (*prebuild)(void); Bool (*deploy)(void); - Bool (*deploy_schema)(const char *schema_file); - Bool (*deploy_config_file)(const char *file_name, const char *version_key); + Bool (*deploy_schema)(const char* schema_file); + Bool (*deploy_config_file)(const char* file_name, const char* version_key); Bool (*sync_user_data)(void); @@ -452,34 +494,46 @@ typedef struct rime_api_t { void (*set_option)(RimeSessionId session_id, const char* option, Bool value); Bool (*get_option)(RimeSessionId session_id, const char* option); - void (*set_property)(RimeSessionId session_id, const char* prop, const char* value); - Bool (*get_property)(RimeSessionId session_id, const char* prop, char* value, size_t buffer_size); + void (*set_property)(RimeSessionId session_id, + const char* prop, + const char* value); + Bool (*get_property)(RimeSessionId session_id, + const char* prop, + char* value, + size_t buffer_size); Bool (*get_schema_list)(RimeSchemaList* schema_list); void (*free_schema_list)(RimeSchemaList* schema_list); - Bool (*get_current_schema)(RimeSessionId session_id, char* schema_id, size_t buffer_size); + Bool (*get_current_schema)(RimeSessionId session_id, + char* schema_id, + size_t buffer_size); Bool (*select_schema)(RimeSessionId session_id, const char* schema_id); // configuration - Bool (*schema_open)(const char *schema_id, RimeConfig* config); - Bool (*config_open)(const char *config_id, RimeConfig* config); - Bool (*config_close)(RimeConfig *config); - Bool (*config_get_bool)(RimeConfig *config, const char *key, Bool *value); - Bool (*config_get_int)(RimeConfig *config, const char *key, int *value); - Bool (*config_get_double)(RimeConfig *config, const char *key, double *value); - Bool (*config_get_string)(RimeConfig *config, const char *key, - char *value, size_t buffer_size); - const char* (*config_get_cstring)(RimeConfig *config, const char *key); + Bool (*schema_open)(const char* schema_id, RimeConfig* config); + Bool (*config_open)(const char* config_id, RimeConfig* config); + Bool (*config_close)(RimeConfig* config); + Bool (*config_get_bool)(RimeConfig* config, const char* key, Bool* value); + Bool (*config_get_int)(RimeConfig* config, const char* key, int* value); + Bool (*config_get_double)(RimeConfig* config, const char* key, double* value); + Bool (*config_get_string)(RimeConfig* config, + const char* key, + char* value, + size_t buffer_size); + const char* (*config_get_cstring)(RimeConfig* config, const char* key); Bool (*config_update_signature)(RimeConfig* config, const char* signer); - Bool (*config_begin_map)(RimeConfigIterator* iterator, RimeConfig* config, const char* key); + Bool (*config_begin_map)(RimeConfigIterator* iterator, + RimeConfig* config, + const char* key); Bool (*config_next)(RimeConfigIterator* iterator); void (*config_end)(RimeConfigIterator* iterator); // testing - Bool (*simulate_key_sequence)(RimeSessionId session_id, const char *key_sequence); + Bool (*simulate_key_sequence)(RimeSessionId session_id, + const char* key_sequence); // module @@ -502,19 +556,27 @@ typedef struct rime_api_t { Bool (*config_load_string)(RimeConfig* config, const char* yaml); // configuration: setters - Bool (*config_set_bool)(RimeConfig *config, const char *key, Bool value); - Bool (*config_set_int)(RimeConfig *config, const char *key, int value); - Bool (*config_set_double)(RimeConfig *config, const char *key, double value); - Bool (*config_set_string)(RimeConfig *config, const char *key, const char *value); + Bool (*config_set_bool)(RimeConfig* config, const char* key, Bool value); + Bool (*config_set_int)(RimeConfig* config, const char* key, int value); + Bool (*config_set_double)(RimeConfig* config, const char* key, double value); + Bool (*config_set_string)(RimeConfig* config, + const char* key, + const char* value); // configuration: manipulating complex structures - Bool (*config_get_item)(RimeConfig* config, const char* key, RimeConfig* value); - Bool (*config_set_item)(RimeConfig* config, const char* key, RimeConfig* value); + Bool (*config_get_item)(RimeConfig* config, + const char* key, + RimeConfig* value); + Bool (*config_set_item)(RimeConfig* config, + const char* key, + RimeConfig* value); Bool (*config_clear)(RimeConfig* config, const char* key); Bool (*config_create_list)(RimeConfig* config, const char* key); Bool (*config_create_map)(RimeConfig* config, const char* key); size_t (*config_list_size)(RimeConfig* config, const char* key); - Bool (*config_begin_list)(RimeConfigIterator* iterator, RimeConfig* config, const char* key); + Bool (*config_begin_list)(RimeConfigIterator* iterator, + RimeConfig* config, + const char* key); //! get raw input /*! @@ -536,15 +598,18 @@ typedef struct rime_api_t { void (*set_caret_pos)(RimeSessionId session_id, size_t caret_pos); //! select a candidate from current page. - Bool (*select_candidate_on_current_page)(RimeSessionId session_id, size_t index); + Bool (*select_candidate_on_current_page)(RimeSessionId session_id, + size_t index); //! access candidate list. - Bool (*candidate_list_begin)(RimeSessionId session_id, RimeCandidateListIterator* iterator); + Bool (*candidate_list_begin)(RimeSessionId session_id, + RimeCandidateListIterator* iterator); Bool (*candidate_list_next)(RimeCandidateListIterator* iterator); void (*candidate_list_end)(RimeCandidateListIterator* iterator); - //! access config files in user data directory, eg. user.yaml and installation.yaml - Bool (*user_config_open)(const char *config_id, RimeConfig* config); + //! access config files in user data directory, eg. user.yaml and + //! installation.yaml + Bool (*user_config_open)(const char* config_id, RimeConfig* config); Bool (*candidate_list_from_index)(RimeSessionId session_id, RimeCandidateListIterator* iterator, @@ -555,20 +620,27 @@ typedef struct rime_api_t { //! staging directory, stores data files deployed to a Rime client. const char* (*get_staging_dir)(void); - //! Deprecated: for capnproto API, use "proto" module from librime-proto plugin. - void (*commit_proto)(RimeSessionId session_id, RIME_PROTO_BUILDER* commit_builder); - void (*context_proto)(RimeSessionId session_id, RIME_PROTO_BUILDER* context_builder); - void (*status_proto)(RimeSessionId session_id, RIME_PROTO_BUILDER* status_builder); + //! Deprecated: for capnproto API, use "proto" module from librime-proto + //! plugin. + void (*commit_proto)(RimeSessionId session_id, + RIME_PROTO_BUILDER* commit_builder); + void (*context_proto)(RimeSessionId session_id, + RIME_PROTO_BUILDER* context_builder); + void (*status_proto)(RimeSessionId session_id, + RIME_PROTO_BUILDER* status_builder); - const char* (*get_state_label)(RimeSessionId session_id, const char *option_name, Bool state); + const char* (*get_state_label)(RimeSessionId session_id, + const char* option_name, + Bool state); //! delete a candidate at the given index in candidate list. Bool (*delete_candidate)(RimeSessionId session_id, size_t index); //! delete a candidate from current page. - Bool (*delete_candidate_on_current_page)(RimeSessionId session_id, size_t index); + Bool (*delete_candidate_on_current_page)(RimeSessionId session_id, + size_t index); RimeStringSlice (*get_state_label_abbreviated)(RimeSessionId session_id, - const char *option_name, + const char* option_name, Bool state, Bool abbreviated); } RimeApi; @@ -579,20 +651,22 @@ typedef struct rime_api_t { */ RIME_API RimeApi* rime_get_api(void); -//! Clients should test if an api function is available in the current version before calling it. -#define RIME_API_AVAILABLE(api, func) (RIME_STRUCT_HAS_MEMBER(*(api), (api)->func) && (api)->func) +//! Clients should test if an api function is available in the current version +//! before calling it. +#define RIME_API_AVAILABLE(api, func) \ + (RIME_STRUCT_HAS_MEMBER(*(api), (api)->func) && (api)->func) // Initializer for MSVC and GCC. // 2010 Joe Lowe. Released into the public domain. #if defined(__GNUC__) -#define RIME_MODULE_INITIALIZER(f) \ +#define RIME_MODULE_INITIALIZER(f) \ static void f(void) __attribute__((constructor)); \ static void f(void) #elif defined(_MSC_VER) -#pragma section(".CRT$XCU",read) -#define RIME_MODULE_INITIALIZER(f) \ - static void __cdecl f(void); \ - __declspec(allocate(".CRT$XCU")) void (__cdecl*f##_)(void) = f; \ +#pragma section(".CRT$XCU", read) +#define RIME_MODULE_INITIALIZER(f) \ + static void __cdecl f(void); \ + __declspec(allocate(".CRT$XCU")) void(__cdecl * f##_)(void) = f; \ static void __cdecl f(void) #endif @@ -602,58 +676,54 @@ RIME_API RimeApi* rime_get_api(void); * and rime__finalize(). * \sa core_module.cc for an example. */ -#define RIME_REGISTER_MODULE(name) \ -void rime_require_module_##name() {} \ -RIME_MODULE_INITIALIZER(rime_register_module_##name) { \ - static RimeModule module = {0}; \ - if (!module.data_size) { \ - RIME_STRUCT_INIT(RimeModule, module); \ - module.module_name = #name; \ - module.initialize = rime_##name##_initialize; \ - module.finalize = rime_##name##_finalize; \ - } \ - RimeRegisterModule(&module); \ -} +#define RIME_REGISTER_MODULE(name) \ + void rime_require_module_##name() {} \ + RIME_MODULE_INITIALIZER(rime_register_module_##name) { \ + static RimeModule module = {0}; \ + if (!module.data_size) { \ + RIME_STRUCT_INIT(RimeModule, module); \ + module.module_name = #name; \ + module.initialize = rime_##name##_initialize; \ + module.finalize = rime_##name##_finalize; \ + } \ + RimeRegisterModule(&module); \ + } /*! * Customize the module by assigning additional functions, eg. module->get_api. */ -#define RIME_REGISTER_CUSTOM_MODULE(name) \ -void rime_require_module_##name() {} \ -static void rime_customize_module_##name(RimeModule* module); \ -RIME_MODULE_INITIALIZER(rime_register_module_##name) { \ - static RimeModule module = {0}; \ - if (!module.data_size) { \ - RIME_STRUCT_INIT(RimeModule, module); \ - module.module_name = #name; \ - module.initialize = rime_##name##_initialize; \ - module.finalize = rime_##name##_finalize; \ - rime_customize_module_##name(&module); \ - } \ - RimeRegisterModule(&module); \ -} \ -static void rime_customize_module_##name(RimeModule* module) +#define RIME_REGISTER_CUSTOM_MODULE(name) \ + void rime_require_module_##name() {} \ + static void rime_customize_module_##name(RimeModule* module); \ + RIME_MODULE_INITIALIZER(rime_register_module_##name) { \ + static RimeModule module = {0}; \ + if (!module.data_size) { \ + RIME_STRUCT_INIT(RimeModule, module); \ + module.module_name = #name; \ + module.initialize = rime_##name##_initialize; \ + module.finalize = rime_##name##_finalize; \ + rime_customize_module_##name(&module); \ + } \ + RimeRegisterModule(&module); \ + } \ + static void rime_customize_module_##name(RimeModule* module) /*! * Defines a constant for a list of module names. */ -#define RIME_MODULE_LIST(var, ...) \ -const char* var[] = { \ - __VA_ARGS__, NULL \ -} \ +#define RIME_MODULE_LIST(var, ...) const char* var[] = {__VA_ARGS__, NULL} /*! * Register a phony module which, when loaded, will load a list of modules. * \sa setup.cc for an example. */ -#define RIME_REGISTER_MODULE_GROUP(name, ...) \ -static RIME_MODULE_LIST(rime_##name##_module_group, __VA_ARGS__); \ -static void rime_##name##_initialize() { \ - rime::LoadModules(rime_##name##_module_group); \ -} \ -static void rime_##name##_finalize() { \ -} \ -RIME_REGISTER_MODULE(name) +#define RIME_REGISTER_MODULE_GROUP(name, ...) \ + static RIME_MODULE_LIST(rime_##name##_module_group, __VA_ARGS__); \ + static void rime_##name##_initialize() { \ + rime::LoadModules(rime_##name##_module_group); \ + } \ + static void rime_##name##_finalize() {} \ + RIME_REGISTER_MODULE(name) #ifdef __cplusplus } diff --git a/src/rime_levers_api.h b/src/rime_levers_api.h index 5e266f4fd..fbd6332ac 100644 --- a/src/rime_levers_api.h +++ b/src/rime_levers_api.h @@ -13,11 +13,17 @@ extern "C" { #endif -typedef struct { char placeholder; } RimeCustomSettings; +typedef struct { + char placeholder; +} RimeCustomSettings; -typedef struct { char placeholder; } RimeSwitcherSettings; +typedef struct { + char placeholder; +} RimeSwitcherSettings; -typedef struct { char placeholder; } RimeSchemaInfo; +typedef struct { + char placeholder; +} RimeSchemaInfo; typedef struct { void* ptr; @@ -32,10 +38,18 @@ typedef struct rime_levers_api_t { void (*custom_settings_destroy)(RimeCustomSettings* settings); Bool (*load_settings)(RimeCustomSettings* settings); Bool (*save_settings)(RimeCustomSettings* settings); - Bool (*customize_bool)(RimeCustomSettings* settings, const char* key, Bool value); - Bool (*customize_int)(RimeCustomSettings* settings, const char* key, int value); - Bool (*customize_double)(RimeCustomSettings* settings, const char* key, double value); - Bool (*customize_string)(RimeCustomSettings* settings, const char* key, const char* value); + Bool (*customize_bool)(RimeCustomSettings* settings, + const char* key, + Bool value); + Bool (*customize_int)(RimeCustomSettings* settings, + const char* key, + int value); + Bool (*customize_double)(RimeCustomSettings* settings, + const char* key, + double value); + Bool (*customize_string)(RimeCustomSettings* settings, + const char* key, + const char* value); Bool (*is_first_run)(RimeCustomSettings* settings); Bool (*settings_is_modified)(RimeCustomSettings* settings); Bool (*settings_get_config)(RimeCustomSettings* settings, RimeConfig* config); @@ -68,7 +82,8 @@ typedef struct rime_levers_api_t { // patch a list or a map Bool (*customize_item)(RimeCustomSettings* settings, - const char* key, RimeConfig* value); + const char* key, + RimeConfig* value); } RimeLeversApi;