rpms/ibus-table/devel ibus-table-0.1.1.20081014-4a.rhbz466430.patch, NONE, 1.1 ibus-table-0.1.1.20081014-4b.rhbz466844.patch, NONE, 1.1 ibus-table.spec, 1.6, 1.7

Caius Chance cchance at fedoraproject.org
Wed Feb 4 07:13:43 UTC 2009


Author: cchance

Update of /cvs/pkgs/rpms/ibus-table/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv11911

Modified Files:
	ibus-table.spec 
Added Files:
	ibus-table-0.1.1.20081014-4a.rhbz466430.patch 
	ibus-table-0.1.1.20081014-4b.rhbz466844.patch 
Log Message:
* Wed Feb 04 2009 Caius Chance <cchance at redhat.com> - 0.1.1.20081014-4
- Resolves: rhbz#466430 rhbz#466844
- Added wildcard features.
- Added preedit clearance on refocus.



ibus-table-0.1.1.20081014-4a.rhbz466430.patch:

--- NEW FILE ibus-table-0.1.1.20081014-4a.rhbz466430.patch ---
diff -up ibus-table-0.1.1.20081014/engine/table.py.4a-bz466430 ibus-table-0.1.1.20081014/engine/table.py
--- ibus-table-0.1.1.20081014/engine/table.py.4a-bz466430	2008-10-16 10:59:17.000000000 +1000
+++ ibus-table-0.1.1.20081014/engine/table.py	2009-02-04 09:15:13.000000000 +1000
@@ -148,6 +148,9 @@ class editor:
 					self._chars[0].append (c)
 				except:
 					self._chars[1].append (c)
+			elif (not self._py_mode and ( c in u'*')):
+				self._tabkey_list += self._parser (c)
+				self._chars[0].append (c)
 			else:
 				self._chars[1].append (c)
 		self._t_chars.append(c)
@@ -432,7 +435,17 @@ class editor:
 				# here we need to consider two parts, table and pinyin
 				# first table
 				if not self._py_mode:
-					self._candidates[0] = self.db.select_words( self._tabkey_list, self._onechar )
+					if not u'*' in self._chars[0]:
+						self._candidates[0] = self.db.select_words(\
+													self._tabkey_list, self._onechar)
+					else:
+						if not u'*' in self._chars[0][ len(self._chars[0]) - 1 ]:
+							self._candidates[0] = self.db.select_words_wildcard_closed(\
+													self._tabkey_list, self._onechar)
+						else:
+							# for inputs of '*' as last key inputted, 
+							# but this is not implemented
+							pass
 				else:
 					self._candidates[0] = self.db.select_zi( self._tabkey_list )
 				self._chars[2] = self._chars[0][:]
@@ -1193,6 +1206,7 @@ class tabengine (ibus.EngineBase):
 			return False
 
 		elif unichr(key.code) in self._valid_input_chars or \
+				unichr(key.code) in u'*' or \
 				( self._editor._py_mode and \
 					unichr(key.code) in u'abcdefghijklmnopqrstuvwxyz' ):
 			if self._direct_commit and len(self._editor._chars[0]) == self._ml:
@@ -1270,12 +1284,15 @@ class tabengine (ibus.EngineBase):
 	
 	# below for initial test
 	def focus_in (self):
+		self.reset ()
 		self.register_properties (self.properties)
 		self._refresh_properties ()
 		self._update_ui ()
 	
 	def focus_out (self):
-		pass
+		self._lookup_table.clean ()
+		self._strings = []
+		self._update_ui ()
 
 	def lookup_table_page_up (self):
 		if self._editor.page_up ():
diff -up ibus-table-0.1.1.20081014/engine/tabsqlitedb.py.4a-bz466430 ibus-table-0.1.1.20081014/engine/tabsqlitedb.py
--- ibus-table-0.1.1.20081014/engine/tabsqlitedb.py.4a-bz466430	2008-10-16 10:59:17.000000000 +1000
+++ ibus-table-0.1.1.20081014/engine/tabsqlitedb.py	2009-02-04 09:16:46.000000000 +1000
@@ -595,6 +595,103 @@ class tabsqlitedb:
 		_cand.sort(cmp=self.compare)
 		return _cand[:]
 
+	def select_words_wildcard_closed( self, tabkeys, onechar=False, bitmask=0 ):
+		'''
+		Get phrases from database by tab_key objects
+		( which should be equal or less than the max key length)
+		This method is called in table.py by passing UserInput held data
+		Return result[:] 
+		'''
+		result = []
+		selectlen = 2
+		while selectlen <= 5:
+		    # firstly, we make sure the len we used is equal or less than the max key length
+		    _len = min( selectlen - 1,self._mlen )
+		    _condition = ''
+		    _condition += ''.join ( 'AND mlen = ? ' )
+		    _condition += ''.join ( 'AND m0 = ? ' )
+		    _condition += ''.join ( 'AND m%d = ? ' % _len )
+		    if onechar:
+			# for some users really like to select only single characters
+				_condition += 'AND clen=1 '
+		    if bitmask:
+				# now just the bits for chinese
+				all_ints = xrange(1,5)
+				need_ints = filter (lambda x: x & bitmask, all_ints)
+				bit_condition = 'OR'.join( map(lambda x: ' category = %d ' %x,\
+					need_ints) )
+				_condition += 'AND (%s) ' % bit_condition
+
+		    # you can increase the x in _len + x to include more result, but in the most case, we only need one more key result, so we don't need the extra overhead :)
+		    # we start search for 1 key more, if nothing, then 2 key more and so on
+		    # this is the max len we need to add into the select cause.
+		    w_len = self._mlen - _len +1
+		    # we start from 2, because it is < in the sqlite select, which need 1 more.
+		    x_len = 2
+		    while x_len <= w_len + 1:
+			sqlstr = '''SELECT * FROM (SELECT * FROM main.phrases WHERE mlen < %(mk)d  %(condition)s 
+			UNION ALL
+			SELECT * FROM user_db.phrases WHERE mlen < %(mk)d %(condition)s 
+			UNION ALL
+			SELECT * FROM mudb.phrases WHERE mlen < %(mk)d %(condition)s )
+			ORDER BY mlen ASC, user_freq DESC, freq DESC;''' % { 'mk':_len+x_len, 'condition':_condition}
+			# we have redefine the __int__(self) in class tabdict.tab_key to return the key id, so we can use map to got key id :)
+			_tabkeys = [selectlen, int(tabkeys[0]), int(tabkeys[len(tabkeys) - 1])]
+			_tabkeys += _tabkeys + _tabkeys
+			result_tmp = self.db.execute(sqlstr, _tabkeys).fetchall()
+			#self.db.commit()
+			# if we find word, we stop this while, 
+			if len(result) >0:
+			    break
+			x_len += 1
+		    result += result_tmp
+		    selectlen += 1
+		# here in order to get high speed, I use complicated map
+		# to subtitute for
+		sysdb={}
+		usrdb={}
+		mudb={}
+		_cand = []
+		#searchres = map ( lambda res: res[-2] and [ True, [(res[:-2],[res[:-1],res[-1:]])] ]\
+		#	or [ False, [(res[:-2] , [res[:-1],res[-1:]])] ] \
+		#	, result )
+		searchres = map ( lambda res: [ int(res[-2]), int(res[-1]), [(res[:-2],[res[:-1],res[-1:]])] ], result)
+		# for sysdb
+		reslist=filter( lambda x: not x[1], searchres )
+		map (lambda x: sysdb.update(x[2]), reslist)
+		# for usrdb
+		reslist=filter( lambda x: ( x[0] in [0,-1] ) and x[1], searchres )
+		map (lambda x: usrdb.update(x[2]), reslist)
+		# for mudb
+		reslist=filter( lambda x: ( x[0] not in [0,-1] ) and x[1], searchres )
+		map (lambda x: mudb.update(x[2]), reslist)
+
+		# first process mudb
+		searchres = map ( lambda key: mudb[key][0] + mudb[key][1], mudb )
+		#print searchres
+		map (_cand.append, searchres)
+
+		# now process usrdb and sysdb
+		searchres = map ( lambda key:  (not mudb.has_key(key))  and usrdb[key][0] + usrdb[key][1]\
+			or None , usrdb )
+		searchres = filter(lambda x: bool(x), searchres )
+		#print searchres
+		map (_cand.append, searchres)
+		searchres = map ( lambda key: ((not mudb.has_key(key)) and (not usrdb.has_key(key)) )and sysdb[key][0] + sysdb[key][1]\
+			or None, sysdb )
+		searchres = filter (lambda x: bool(x), searchres)
+		map (_cand.append, searchres)
+		#for key in usrdb:
+		#    if not sysdb.has_key (key):
+		#	_cand.append( usrdb[key][0] + usrdb[key][1] )
+		#    else:
+		#	_cand.append( sysdb[key][0] + usrdb[key][1] )
+		#for key in sysdb:
+		#    if not usrdb.has_key (key):
+		#	_cand.append( sysdb[key][0] + sysdb[key][1] )
+		_cand.sort(cmp=self.compare)
+		return _cand[:]
+
 	def select_zi( self, tabkeys ):
 		'''
 		Get zi from database by tab_key objects

ibus-table-0.1.1.20081014-4b.rhbz466844.patch:

--- NEW FILE ibus-table-0.1.1.20081014-4b.rhbz466844.patch ---
diff -up ibus-table-0.1.1.20081014/engine/table.py.1-rhbz466844 ibus-table-0.1.1.20081014/engine/table.py
--- ibus-table-0.1.1.20081014/engine/table.py.1-rhbz466844	2008-10-16 10:59:17.000000000 +1000
+++ ibus-table-0.1.1.20081014/engine/table.py	2008-10-28 14:42:16.000000000 +1000
@@ -1270,12 +1270,15 @@ class tabengine (ibus.EngineBase):
 	
 	# below for initial test
 	def focus_in (self):
+		self.reset ()
 		self.register_properties (self.properties)
 		self._refresh_properties ()
 		self._update_ui ()
 	
 	def focus_out (self):
-		pass
+		self._lookup_table.clean ()
+		self._strings = []
+		self._update_ui ()
 
 	def lookup_table_page_up (self):
 		if self._editor.page_up ():


Index: ibus-table.spec
===================================================================
RCS file: /cvs/pkgs/rpms/ibus-table/devel/ibus-table.spec,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ibus-table.spec	1 Dec 2008 15:00:31 -0000	1.6
+++ ibus-table.spec	4 Feb 2009 07:13:13 -0000	1.7
@@ -1,11 +1,13 @@
 Name:       ibus-table
 Version:    0.1.1.20081014
-Release:    3%{?dist}
+Release:    4%{?dist}
 Summary:    The Table engine for IBus platform
 License:    GPLv2+
 Group:      System Environment/Libraries
 URL:        http://code.google.com/p/ibus/
 Source0:    http://ibus.googlecode.com/files/%{name}-%{version}.tar.gz
+Patch0:     ibus-table-0.1.1.20081014-4a.rhbz466430.patch
+Patch1:     ibus-table-0.1.1.20081014-4b.rhbz466844.patch
 
 BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch:  noarch
@@ -35,6 +37,8 @@
 
 %prep
 %setup -q
+%patch0 -p1 -b .4a-bz466430
+%patch1 -p1 -b .4b-bz466844
 
 %build
 %configure \
@@ -125,6 +129,11 @@
 %{_datadir}/ibus/engine/latex.engine
 
 %changelog
+* Wed Feb 04 2009 Caius Chance <cchance at redhat.com> - 0.1.1.20081014-4
+- Resolves: rhbz#466430 rhbz#466844
+- Added wildcard features.
+- Added preedit clearance on refocus.
+
 * Mon Dec 01 2008 Ignacio Vazquez-Abrams <ivazqueznet+rpm at gmail.com> - 0.1.1.20081014-3
 - Rebuild for Python 2.6
 




More information about the fedora-extras-commits mailing list