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

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