Blame SOURCES/0002-Add-auto_select-functionality-to-select-the-first-ph.patch

fc8e58
From a55783887e757f02078143c2d12031a33c9e9223 Mon Sep 17 00:00:00 2001
fc8e58
From: bnauwelaerts <bnauwelaerts@cli0189.fednot.be>
fc8e58
Date: Sat, 2 Feb 2013 13:03:48 +0100
fc8e58
Subject: [PATCH 2/5] Add auto_select functionality to select the first phrase
fc8e58
 when typing. Useful for Cyrillic transliteration.
fc8e58
fc8e58
---
fc8e58
 engine/table.py       | 26 +++++++++++++++++++++++---
fc8e58
 engine/tabsqlitedb.py |  1 +
fc8e58
 tables/template.txt   |  3 +++
fc8e58
 3 files changed, 27 insertions(+), 3 deletions(-)
fc8e58
fc8e58
diff --git a/engine/table.py b/engine/table.py
fc8e58
index c106a0a..4a10636 100644
fc8e58
--- a/engine/table.py
fc8e58
+++ b/engine/table.py
fc8e58
@@ -228,6 +228,13 @@ class editor(object):
fc8e58
                 "ChineseMode"))
fc8e58
         if self._chinese_mode == None:
fc8e58
             self._chinese_mode = self.get_chinese_mode()
fc8e58
+        
fc8e58
+        self._auto_select = variant_to_value(self._config.get_value(
fc8e58
+                self._config_section,
fc8e58
+                "AutoSelect"))
fc8e58
+        if self._auto_select == None:
fc8e58
+            self._auto_select = self.db.get_ime_property('auto_select').lower() == u'true'
fc8e58
+        
fc8e58
 
fc8e58
     def init_select_keys(self):
fc8e58
         # __select_keys: lookup table select keys/labels
fc8e58
@@ -728,7 +735,9 @@ class editor(object):
fc8e58
                             if ascii.ispunct (self._chars[0][-1].encode('ascii')) \
fc8e58
                                     or len (self._chars[0][:-1]) \
fc8e58
                                     in self.db.pkeylens \
fc8e58
-                                    or only_one_last:
fc8e58
+                                    or only_one_last \
fc8e58
+                                    or self._auto_select:
fc8e58
+                                    
fc8e58
                                 # because we use [!@#$%] to denote [12345]
fc8e58
                                 # in py_mode, so we need to distinguish them
fc8e58
                                 ## old manner:
fc8e58
@@ -750,7 +759,7 @@ class editor(object):
fc8e58
                                     self._lookup_table.clear()
fc8e58
                                     self._lookup_table.set_cursor_visible(True)
fc8e58
                                     return False
fc8e58
-                            else:    
fc8e58
+                            else:
fc8e58
                                 # this is not a punct or not a valid phrase
fc8e58
                                 # last time
fc8e58
                                 self._chars[1].append( self._chars[0].pop() )
fc8e58
@@ -1142,11 +1151,19 @@ class tabengine (IBus.Engine):
fc8e58
             self._full_width_punct[1] = self.db.get_ime_property('def_full_width_punct').lower() == u'true'
fc8e58
         # some properties we will involved, Property is taken from scim.
fc8e58
         #self._setup_property = Property ("setup", _("Setup"))
fc8e58
+        
fc8e58
         self._auto_commit = variant_to_value(self._config.get_value(
fc8e58
                 self._config_section,
fc8e58
                 "AutoCommit"))
fc8e58
         if self._auto_commit == None:
fc8e58
             self._auto_commit = self.db.get_ime_property('auto_commit').lower() == u'true'
fc8e58
+        
fc8e58
+        self._auto_select = variant_to_value(self._config.get_value(
fc8e58
+                self._config_section,
fc8e58
+                "AutoSelect"))
fc8e58
+        if self._auto_select == None:
fc8e58
+            self._auto_select = self.db.get_ime_property('auto_select').lower() == u'true'
fc8e58
+        
fc8e58
         # the commit phrases length
fc8e58
         self._len_list = [0]
fc8e58
         # connect to SpeedMeter
fc8e58
@@ -1736,7 +1753,10 @@ class tabengine (IBus.Engine):
fc8e58
                 sp_res = self._editor.space ()
fc8e58
                 #return (KeyProcessResult,whethercommit,commitstring)
fc8e58
                 if sp_res[0]:
fc8e58
-                    self.commit_string (sp_res[1])
fc8e58
+                    if self._auto_select:
fc8e58
+                        self.commit_string ("%s " %sp_res[1])
fc8e58
+                    else:
fc8e58
+                        self.commit_string (sp_res[1])
fc8e58
                     #self.add_string_len(sp_res[1])
fc8e58
                     self.db.check_phrase (sp_res[1], sp_res[2])
fc8e58
                 else:
fc8e58
diff --git a/engine/tabsqlitedb.py b/engine/tabsqlitedb.py
fc8e58
index 78fa85d..fa56053 100644
fc8e58
--- a/engine/tabsqlitedb.py
fc8e58
+++ b/engine/tabsqlitedb.py
fc8e58
@@ -99,6 +99,7 @@ class tabsqlitedb:
fc8e58
                       'user_can_define_phrase':'FALSE',
fc8e58
                       'pinyin_mode':'FALSE',
fc8e58
                       'dynamic_adjust':'FALSE',
fc8e58
+                      'auto_select':'false',
fc8e58
                       'auto_commit':'false',
fc8e58
                       #'no_check_chars':u'',
fc8e58
                       'description':'A IME under IBus Table',
fc8e58
diff --git a/tables/template.txt b/tables/template.txt
fc8e58
index 40bc915..f51cdf8 100644
fc8e58
--- a/tables/template.txt
fc8e58
+++ b/tables/template.txt
fc8e58
@@ -63,6 +63,9 @@ MAX_KEY_LENGTH = 4
fc8e58
 ### Use auto_commit mode as default
fc8e58
 AUTO_COMMIT = FALSE
fc8e58
 
fc8e58
+### Automatically selects the first phrase when typing
fc8e58
+AUTO_SELECT = FALSE
fc8e58
+
fc8e58
 ### Use full width punctuation by default
fc8e58
 DEF_FULL_WIDTH_PUNCT = TRUE
fc8e58
 ### Not use full width letter by default
fc8e58
-- 
fc8e58
1.7.11.7
fc8e58