From 00533c453e8ab19099ee0e093bdd7e91c94df77f Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 29 Jun 2010 14:34:09 +0800 Subject: [PATCH] fixes compile errors. --- src/ExtEditor.cc | 34 +++++++++++++++++++++++++++++++++- src/ExtEditor.h | 2 ++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/ExtEditor.cc b/src/ExtEditor.cc index ee8d9c9..b9f780b 100644 --- a/src/ExtEditor.cc +++ b/src/ExtEditor.cc @@ -567,8 +567,10 @@ ExtEditor::updateStateFromInput (void) } else if ( isdigit (m_text[1]) ) { m_mode = LABEL_LIST_NUMBERS; + std::string number = m_text.substr(1); //Generate Chinese number. - //fillChineseNumber (). (Label use digit.) + int num = atoi(number.c_str()); + fillChineseNumber (num); } return true; @@ -696,6 +698,36 @@ ExtEditor::fillCommand (std::string command_name, const char * argument) return true; } +bool +ExtEditor::fillChineseNumber(int num) +{ + clearLookupTable(); + + if ( LABEL_LIST_NUMBERS == m_mode) { + for ( int i = 1; i <= 10; ++i ) + m_lookup_table.setLabel ( i - 1, Text (i - 1 + 'a') ); + } + + std::string result = translate_to_simplified(num); + if ( !result.empty() ){ + Text text(result); + m_lookup_table.appendCandidate(text); + } + + result = translate_to_traditional(num); + if ( !result.empty() ){ + Text text(result); + m_lookup_table.appendCandidate(text); + } + + result = translate_to_simplest(num); + if ( !result.empty() ){ + Text text(result); + m_lookup_table.appendCandidate(text); + } + + return TRUE; +} void ExtEditor::clearLookupTable (void) diff --git a/src/ExtEditor.h b/src/ExtEditor.h index 5292c24..87358d1 100644 --- a/src/ExtEditor.h +++ b/src/ExtEditor.h @@ -53,6 +53,8 @@ private: bool fillCommandCandidates (std::string prefix); bool fillCommand (std::string command_name, const char * argument); + bool fillChineseNumber(int num); + /* Auxiliary functions for lookup table */ void clearLookupTable (void); void updateLookupTable (void); -- 2.7.4