Skip to content

Instantly share code, notes, and snippets.

@shellexy
Created September 4, 2011 12:22
Show Gist options
  • Save shellexy/1192786 to your computer and use it in GitHub Desktop.
Save shellexy/1192786 to your computer and use it in GitHub Desktop.
ibus-googlepinyin 输入词的最大长度由 9 改为 16
diff --git a/include/spellingtrie.h b/include/spellingtrie.h
--- a/include/spellingtrie.h
+++ b/include/spellingtrie.h
@@ -30,8 +30,8 @@ struct SpellingNode {
SpellingNode *first_son;
// The spelling id for each node. If you need more bits to store
// spelling id, please adjust this structure.
- uint16 spelling_idx:11;
- uint16 num_of_son:5;
+ uint16 spelling_idx;
+ uint8 num_of_son;
char char_this_node;
unsigned char score;
};
diff --git a/src/matrixsearch.cpp b/src/matrixsearch.cpp
--- a/src/matrixsearch.cpp
+++ b/src/matrixsearch.cpp
@@ -454,7 +454,7 @@ size_t MatrixSearch::search(const char *
// If there are too many spellings, remove the last letter until the spelling
// number is acceptable.
- while (spl_id_num_ > 9) {
+ while (spl_id_num_ > 16) {
py_len--;
reset_search(py_len, false, false, false);
pys_[py_len] = '\0';
diff --git a/wrapper/ibus/engine.py b/wrapper/ibus/engine.py
--- a/wrapper/ibus/engine.py
+++ b/wrapper/ibus/engine.py
@@ -37,6 +37,8 @@ try:
except:
pass
+MAX_SPELLINGS = 16
+
app = 'ibus-googlepinyin'
import os, sys
@@ -243,6 +245,10 @@ class Engine(ibus.EngineBase):
return True
if keyval in xrange(keysyms.a, keysyms.z + 1) or \
(keyval == keysyms.quoteright and self.__prepinyin_string):
+ if self.__lookup_table.get_number_of_candidates() \
+ and len(self.__lookup_table.get_candidate(0).text.decode('utf8'))\
+ > MAX_SPELLINGS - 1:
+ return True
if state & (modifier.CONTROL_MASK | modifier.ALT_MASK) == 0:
self.__prepinyin_string += unichr(keyval)
self.__invalidate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment