diff options
author | Peng Wu <alexepico@gmail.com> | 2014-04-18 14:48:35 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-04-18 14:48:35 +0800 |
commit | cf8f34957cb56513848ed6f24320c8c3136b6053 (patch) | |
tree | ca7256023a8445793f59110013339504909ceb04 | |
parent | a5a42cca8e034205561338905c573d992b4e0abd (diff) | |
download | ibus-libzhuyin-cf8f34957cb56513848ed6f24320c8c3136b6053.tar.gz ibus-libzhuyin-cf8f34957cb56513848ed6f24320c8c3136b6053.tar.xz ibus-libzhuyin-cf8f34957cb56513848ed6f24320c8c3136b6053.zip |
update BuiltinSymbolSection::fillLookupTableByPage
-rw-r--r-- | src/ZYZBuiltinSymbolSection.cc | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ZYZBuiltinSymbolSection.cc b/src/ZYZBuiltinSymbolSection.cc index 7053e00..5576187 100644 --- a/src/ZYZBuiltinSymbolSection.cc +++ b/src/ZYZBuiltinSymbolSection.cc @@ -56,16 +56,28 @@ BuiltinSymbolSection::initCandidates (const String & lookup) bool BuiltinSymbolSection::fillLookupTableByPage () { - /* clear lookup table. */ LookupTable & lookup_table = getLookupTable (); - lookup_table.clear (); - iterator_t iter = m_candidates.begin (); - for (; iter != m_candidates.end (); ++iter) { - lookup_table.appendCandidate (Text (*iter)); + guint len = m_candidates.size (); + + guint filled_nr = lookup_table.size (); + guint page_size = lookup_table.pageSize (); + + /* fill lookup table by libzhuyin get candidates. */ + guint need_nr = MIN (page_size, len - filled_nr); + g_assert (need_nr >=0); + if (need_nr == 0) + return FALSE; + + for (guint i = filled_nr; i < filled_nr + need_nr; i++) { + if (i >= len) /* no more candidates */ + break; + + Text text (m_candidates[i]); + lookup_table.appendCandidate (text); } - return true; + return TRUE; } int |