fixes compile errors.
authorPeng Wu <alexepico@gmail.com>
Tue, 29 Jun 2010 06:34:09 +0000 (14:34 +0800)
committerPeng Wu <alexepico@gmail.com>
Tue, 29 Jun 2010 06:34:09 +0000 (14:34 +0800)
src/ExtEditor.cc
src/ExtEditor.h

index ee8d9c9..b9f780b 100644 (file)
@@ -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)
index 5292c24..87358d1 100644 (file)
@@ -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);