[i=s] 本帖最后由 zjan999 于 2009-10-18 09:38 编辑 [/i]
在网上查了半天,下了个fcitx的gz包,按fcitx说明,一步步的整,整是整起了,桌面却出现了N多的方块,终端也显示不正常起来,毛了,只好反起把fcitx删除了,着眼ibus本身,才发现,众里寻她千百度;蓦然回首,那人却在灯火阑珊处!
简单一个命令:yum install ibus ibus-table-wubi
然后在首选项里的汉语增加五笔输入就可以了
4码自动上屏(软件已作了修改,原来的方法无法实现,找下方法)
#gedit /usr/share/ibus-table/engine/table.py
查找self._direct_commit
将False改成True,重启ibus就可以了
最新的包ibus-table已经更新到20090912,wubi已经更新到20090715,软件源里还是0327,下载新软件更新


haiya820 于 2009-11-19 11:14:32发表:
yum install ibus ibus-table-wubi 谢谢,以安装成功,别外还有一种方法是可以在YUM图形界面下直接查五笔,这样也可以安装五笔,我的意思是指那些不懂文本命令的人可以试试,谢谢楼主了。
wishjiu 于 2009-11-16 22:10:10发表:
从那下载啊?
2088 于 2009-11-16 10:40:04发表:
有这么烦吗?那个fcitx是基于scim的,你直接吧ibus卸了,然后yum install scim 就ok了 我装了好几遍了
chinaitab 于 2009-11-14 11:49:46发表:
# -*- coding: utf-8 -*-
# vim: set et ts=4 sts=4
#
# ibus-table - The Tables engine for IBus
#
# Copyright (c) 2008-2009 Yu Yuwei <acevery@gmail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# $Id: $
#
__all__ = (
"tabengine",
)
import os
import ibus
#from ibus import Property
from ibus import keysyms
from ibus import modifier
from ibus import ascii
#import tabsqlitedb
import tabdict
import re
import editor
import KeyEvent
patt_edit = re.compile (r'(.*)###(.*)###(.*)')
patt_uncommit = re.compile (r'(.*)@@@(.*)')
from gettext import dgettext
_ = lambda a : dgettext ("ibus-table", a)
N_ = lambda a : a
LIBEXECDIR = os.getenv("LIBEXECDIR")
import dbus
########################
### Engine Class #####
####################
class tabengine (ibus.EngineBase):
'''The IM Engine for Tables'''
# colors
# _phrase_color = 0xffffff
# _user_phrase_color = 0xffffff
# _new_phrase_color = 0xffffff
__setup_pid = 0
def __init__ (self, bus, obj_path, db ):
super(tabengine,self).__init__ (bus,obj_path)
config = bus.get_config()
# lookup table page size
tabengine._page_size = config.get_value("engine/Table", "PageSize", 6)
self._lookup_table = ibus.LookupTable (tabengine._page_size)
# this is the backend sql db we need for our IME
# we receive this db from IMEngineFactory
#self.db = tabsqlitedb.tabsqlitedb( name = dbname )
self.db = db
# this is the parer which parse the input string to key object
self._parser = tabdict.parse
self._icon_dir = '%s%s%s%s' % (os.getenv('IBUS_TABLE_LOCATION'),
os.path.sep, 'icons', os.path.sep)
# 0 = english input mode
# 1 = table input mode
self._mode = 1
# self._ime_py: True / False this IME support pinyin mode
self._ime_py = self.db.get_ime_property ('pinyin_mode')
if self._ime_py:
if self._ime_py.lower() == u'true':
self._ime_py = True
else:
self._ime_py = False
else:
print 'We coult not find "pinyin_mode" entry in database, is it a outdated database?'
self._ime_py = False
self._status = self.db.get_ime_property('status_prompt').encode('utf8')
# now we check and update the valid input characters
self._chars = self.db.get_ime_property('valid_input_chars')
self._valid_input_chars = []
for _c in self._chars:
if _c in tabdict.tab_key_list:
self._valid_input_chars.append(_c)
del self._chars
self._pt = self.db.get_phrase_table_index ()
self._ml = int(self.db.get_ime_property ('max_key_length'))
# Containers we used:
self._editor = editor.editor(self._pt, self._valid_input_chars, self._ml, self.db, tabengine._page_size)
# some other vals we used:
# self._prev_key: hold the key event last time.
self._prev_key = None
self._prev_char = None
self._double_quotation_state = False
self._single_quotation_state = False
# [ENmode,TABmode] we get TABmode properties from db
self._full_width_letter = [
False,
self.db.get_ime_property('def_full_width_letter').lower() == u'true'
]
self._full_width_punct = [
False,
self.db.get_ime_property('def_full_width_punct').lower() == u'true'
]
# some properties we will involved, Property is taken from scim.
#self._setup_property = Property ("setup", _("Setup"))
try:
self._auto_commit = self.db.get_ime_property('auto_commit').lower() == u'true'
except:
self._auto_commit = False
# the commit phrases length
self._len_list = [0]
# connect to SpeedMeter
try:
bus = dbus.SessionBus()
user = os.path.basename( os.path.expanduser('~') )
self._sm_bus = bus.get_object ("org.ibus.table.SpeedMeter.%s"\
% user, "/org/ibus/table/SpeedMeter")
self._sm = dbus.Interface(self._sm_bus,\
"org.ibus.table.SpeedMeter")
except:
self._sm = None
self._sm_on = False
self._on = False
self.reset ()
def reset (self):
self._editor.clear ()
self._double_quotation_state = False
self._single_quotation_state = False
self._prev_key = None
#self._editor._onechar = False
self._init_properties ()
self._update_ui ()
def do_destroy(self):
self.reset ()
self.focus_out ()
#self.db.sync_usrdb ()
super(tabengine,self).do_destroy()
def _init_properties (self):
self.properties= ibus.PropList ()
self._status_property = ibus.Property(u'status')
if self.db._is_chinese:
self._cmode_property = ibus.Property(u'cmode')
self._letter_property = ibus.Property(u'letter')
self._punct_property = ibus.Property(u'punct')
self._py_property = ibus.Property(u'py_mode')
self._onechar_property = ibus.Property(u'onechar')
self._auto_commit_property = ibus.Property(u'acommit')
self._setup_property = ibus.Property(u'setup')
for prop in (self._status_property,
self._letter_property,
self._punct_property,
self._py_property,
self._onechar_property,
self._auto_commit_property,
self._setup_property
):
self.properties.append(prop)
# if self.db._is_chinese:
# self.properties.insert( 1, self._cmode_property )
self.register_properties (self.properties)
self._refresh_properties ()
def _refresh_properties (self):
'''Method used to update properties'''
# taken and modified from PinYin.py :)
if self._mode == 1: # refresh mode
if self._status == u'CN':
self._status_property.set_icon( u'%s%s' % (self._icon_dir, 'chinese.svg') )
self._status_property.set_label( _(u'CN') )
else:
self._status_property.set_icon( u'%s%s' % (self._icon_dir, 'ibus-table.svg') )
self._status_property.set_label( self._status )
self._status_property.set_tooltip ( _(u'Switch to English mode') )
else:
self._status_property.set_icon( u'%s%s' % (self._icon_dir, 'english.svg') )
self._status_property.set_label( _(u'EN') )
self._status_property.set_tooltip ( _(u'Switch to Table mode') )
if self._full_width_letter[self._mode]:
self._letter_property.set_icon ( u'%s%s' % (self._icon_dir, 'full-letter.svg') )
self._letter_property.set_tooltip ( _(u'Switch to half letter') )
else:
self._letter_property.set_icon ( u'%s%s' % (self._icon_dir, 'half-letter.svg') )
self._letter_property.set_tooltip ( _(u'Switch to full letter') )
if self._full_width_punct[self._mode]:
self._punct_property.set_icon ( u'%s%s' % (self._icon_dir, 'full-punct.svg') )
self._punct_property.set_tooltip ( _( u'Switch to half punction' ) )
else:
self._punct_property.set_icon ( u'%s%s' % (self._icon_dir,'half-punct.svg' ) )
self._punct_property.set_tooltip ( _( u'Switch to full punction' ) )
if self._editor._py_mode:
self._py_property.set_icon ( u'%s%s' % (self._icon_dir, 'py-mode.svg' ) )
self._py_property.set_tooltip ( _(u'Switch to Table mode') )
else:
self._py_property.set_icon ( u'%s%s' % (self._icon_dir, 'tab-mode.svg' ) )
self._py_property.set_tooltip ( _(u'Switch to PinYin mode') )
if self._editor._onechar:
self._onechar_property.set_icon ( u'%s%s' % (self._icon_dir, 'onechar.svg' ))
self._onechar_property.set_tooltip ( _(u'Switch to phrase mode') )
else:
self._onechar_property.set_icon ( u'%s%s' % (self._icon_dir, 'phrase.svg' ))
self._onechar_property.set_tooltip ( _(u'Switch to single char mode') )
if self._auto_commit:
self._auto_commit_property.set_icon ( u'%s%s' % (self._icon_dir, 'acommit.svg' ) )
self._auto_commit_property.set_tooltip ( _(u'Switch to normal commit mode, which use space to commit') )
else:
self._auto_commit_property.set_icon ( u'%s%s' % (self._icon_dir, 'ncommit.svg' ) )
self._auto_commit_property.set_tooltip ( _(u'Switch to direct commit mode') )
# the chinese_mode:
if self.db._is_chinese:
if self._editor._chinese_mode == 0:
self._cmode_property.set_icon ( u'%s%s' % (self._icon_dir,\
'sc-mode.svg' ) )
self._cmode_property.set_tooltip ( _(u'Switch to Traditional Chinese mode') )
elif self._editor._chinese_mode == 1:
self._cmode_property.set_icon ( u'%s%s' % (self._icon_dir,\
'tc-mode.svg' ) )
self._cmode_property.set_tooltip ( _(u'Switch to Simplify Chinese first Big Charset Mode') )
elif self._editor._chinese_mode == 2:
self._cmode_property.set_icon ( u'%s%s' % (self._icon_dir,\
'scb-mode.svg' ) )
self._cmode_property.set_tooltip ( _(u'Switch to Traditional Chinese first Big Charset Mode') )
elif self._editor._chinese_mode == 3:
self._cmode_property.set_icon ( u'%s%s' % (self._icon_dir,\
'tcb-mode.svg' ) )
self._cmode_property.set_tooltip ( _(u'Switch to Big Charset Mode') )
elif self._editor._chinese_mode == 4:
self._cmode_property.set_icon ( u'%s%s' % (self._icon_dir,\
'cb-mode.svg' ) )
self._cmode_property.set_tooltip ( _(u'Switch to Simplify Chinese Mode') )
# wait for a good looking icon :D
# self._setup_property.set_icon ( u'%s%s' % (self._icon_dir, 'ibus-setup.svg' ) )
self._setup_property.set_tooltip = ( _(u'Configure Table') )
# use buildin method to update properties :)
map (self.update_property, self.properties)
def _change_mode (self):
'''Shift input mode, TAB -> EN -> TAB
'''
self._mode = int (not self._mode)
self.reset ()
self._update_ui ()
def property_activate (self, property,prop_state = ibus.PROP_STATE_UNCHECKED):
'''Shift property'''
if property == u"status":
self._change_mode ()
elif property == u'py_mode' and self._ime_py:
self._editor.r_shift ()
elif property == u'onechar':
self._editor._onechar = not self._editor._onechar
elif property == u'acommit':
self._auto_commit = not self._auto_commit
elif property == u'letter':
self._full_width_letter [self._mode] = not self._full_width_letter [self._mode]
elif property == u'punct':
self._full_width_punct [self._mode] = not self._full_width_punct [self._mode]
elif property == u'setup':
self._start_setup ()
elif property == u'cmode':
self._editor.change_chinese_mode()
self.reset()
self._refresh_properties ()
def _update_preedit (self):
'''Update Preedit String in UI'''
_str = self._editor.get_preedit_strings ()
if _str == u'':
super(tabengine, self).update_preedit_text(ibus.Text(u'',None), 0, False)
else:
attrs = ibus.AttrList()
res = patt_edit.match (_str)
if res:
_str = u''
ures = patt_uncommit.match (res.group(1))
if ures:
_str=u''.join (ures.groups())
lc = len (ures.group(1) )
lu = len (ures.group(2) )
attrs.append (ibus.AttributeForeground(0x1b3f03,0,lc) )
attrs.append (ibus.AttributeForeground(0x0895a2,lc,lu) )
lg1 = len (_str)
else:
_str += res.group (1)
lg1 = len ( res.group(1) )
attrs.append (ibus.AttributeForeground(0x1b3f03,0,lg1) )
_str += res.group(2)
_str += res.group(3)
lg2 = len ( res.group(2) )
lg3 = len ( res.group(3) )
attrs.append( ibus.AttributeForeground(0x0e0ea0,lg1,lg2) )
attrs.append( ibus.AttributeForeground(0x1b3f03,lg1+lg2,lg3) )
else:
attrs.append( ibus.AttributeForeground(0x1b3f03,0,len(_str)) )
# because ibus now can only insert preedit into txt, so...
attrs = ibus.AttrList()
attrs.append(ibus.AttributeUnderline(ibus.ATTR_UNDERLINE_SINGLE, 0, len(_str)))
super(tabengine, self).update_preedit_text(ibus.Text(_str, attrs), self._editor.get_caret(), True)
def _update_aux (self):
'''Update Aux String in UI'''
_ic = self._editor.get_aux_strings ()
if _ic:
attrs = ibus.AttrList([ ibus.AttributeForeground(0x9515b5,0, len(_ic)) ])
#attrs = [ scim.Attribute(0,len(_ic),scim.ATTR_FOREGROUND,0x5540c1)]
super(tabengine, self).update_auxiliary_text(ibus.Text(_ic, attrs), True)
else:
self.hide_auxiliary_text()
#self.update_aux_string (u'', None, False)
def _update_lookup_table (self):
'''Update Lookup Table in UI'''
if self._editor.is_empty ():
self.hide_lookup_table()
return
self.update_lookup_table ( self._editor.get_lookup_table(), True, True )
def _update_ui (self):
'''Update User Interface'''
self._update_lookup_table ()
self._update_preedit ()
self._update_aux ()
def add_string_len(self, astring):
if self._sm_on:
try:
self._sm.Accumulate(len(astring))
except:
pass
def commit_string (self,string):
self._editor.clear ()
self._update_ui ()
super(tabengine,self).commit_text ( ibus.Text(string) )
self._prev_char = string[-1]
def _convert_to_full_width (self, c):
'''convert half width character to full width'''
if c in [u".", u"\\", u"^", u"_", u"$", u"\"", u"'", u">", u"<" ]:
if c == u".":
if self._prev_char and self._prev_char.isdigit () \
and self._prev_key and chr (self._prev_key.code) == self._prev_char:
return u"."
else:
return u"\u3002"
elif c == u"\\":
return u"\u3001"
elif c == u"^":
return u"\u2026\u2026"
elif c == u"_":
return u"\u2014\u2014"
elif c == u"$":
return u"\uffe5"
elif c == u"\"":
self._double_quotation_state = not self._double_quotation_state
if self._double_quotation_state:
return u"\u201c"
else:
return u"\u201d"
elif c == u"'":
self._single_quotation_state = not self._single_quotation_state
if self._single_quotation_state:
return u"\u2018"
else:
return u"\u2019"
elif c == u"<":
if self._mode:
return u"\u300a"
elif c == u">":
if self._mode:
return u"\u300b"
return ibus.unichar_half_to_full (c)
def _match_hotkey (self, key, code, mask):
if key.code == code and key.mask == mask:
if self._prev_key and key.code == self._prev_key.code and key.mask & modifier.RELEASE_MASK:
return True
if not key.mask & modifier.RELEASE_MASK:
return True
return False
def process_key_event(self, keyval, keycode, state):
'''Process Key Events
Key Events include Key Press and Key Release,
modifier means Key Pressed
'''
key = KeyEvent.KeyEvent(keyval, state & modifier.RELEASE_MASK == 0, state)
# ignore NumLock mask
key.mask &= ~modifier.MOD2_MASK
result = self._process_key_event (key)
self._prev_key = key
return result
def _process_key_event (self, key):
'''Internal method to process key event'''
# Match mode switch hotkey
if not self._editor._t_chars and ( self._match_hotkey (key, keysyms.Shift_L, modifier.SHIFT_MASK + modifier.RELEASE_MASK)):
self._change_mode ()
return True
# Match full half letter mode switch hotkey
if self._match_hotkey (key, keysyms.space, modifier.SHIFT_MASK):
self.property_activate ("letter")
return True
# Match full half punct mode switch hotkey
if self._match_hotkey (key, keysyms.period, modifier.CONTROL_MASK):
self.property_activate ("punct")
return True
# we ignore all hotkeys
# if key.mask & modifier.ALT_MASK:
# return False
# Ignore key release event
# if key.mask & modifier.RELEASE_MASK:
# return True
if self._mode:
return self._table_mode_process_key_event (key)
else:
return self._english_mode_process_key_event (key)
def _english_mode_process_key_event (self, key):
'''English Mode Process Key Event'''
# Ignore key release event
if key.mask & modifier.RELEASE_MASK:
return True
if key.code >= 128:
return False
# we ignore all hotkeys here
if key.mask & modifier.CONTROL_MASK+modifier.ALT_MASK:
return False
c = unichr (key.code)
if ascii.ispunct (key.code): # if key code is a punctation
if self._full_width_punct[self._mode]:
self.commit_string (self._convert_to_full_width (c))
return True
else:
self.commit_string (c)
return True
if self._full_width_letter[self._mode]: # if key code is a letter or digit
self.commit_string (self._convert_to_full_width (c))
return True
else:
self.commit_string (c)
return True
# should not reach there
return False
def _table_mode_process_key_event (self, key):
'''Xingma Mode Process Key Event'''
cond_letter_translate = lambda (c): \
self._convert_to_full_width (c) if self._full_width_letter [self._mode] else c
cond_punct_translate = lambda (c): \
self._convert_to_full_width (c) if self._full_width_punct [self._mode] else c
# We have to process the pinyin mode change key event here,
# because we ignore all Release event below.
if self._match_hotkey (key, keysyms.Shift_R, modifier.SHIFT_MASK + modifier.RELEASE_MASK) and self._ime_py:
res = self._editor.r_shift ()
self._refresh_properties ()
self._update_ui ()
return res
# process commit to preedit
if self._match_hotkey (key, keysyms.Shift_R, modifier.SHIFT_MASK + modifier.RELEASE_MASK) or self._match_hotkey (key, keysyms.Shift_L, modifier.SHIFT_MASK + modifier.RELEASE_MASK):
res = self._editor.l_shift ()
self._update_ui ()
return res
# Match single char mode switch hotkey
if self._match_hotkey (key, keysyms.comma, modifier.CONTROL_MASK):
self.property_activate ( u"onechar" )
return True
# Match direct commit mode switch hotkey
if self._match_hotkey (key, keysyms.slash, modifier.CONTROL_MASK):
self.property_activate ( u"acommit" )
return True
# Match Chinese mode shift
if self._match_hotkey (key, keysyms.semicolon, modifier.CONTROL_MASK):
self.property_activate ( u"cmode" )
return True
# Match speedmeter shift
if self._match_hotkey (key, keysyms.apostrophe, modifier.CONTROL_MASK):
self._sm_on = not self._sm_on
if self._sm_on:
self._sm.Show ()
else:
self._sm.Hide ()
return True
# Ignore key release event now :)
if key.mask & modifier.RELEASE_MASK:
return True
if self._editor.is_empty ():
# we have not input anything
if key.code <= 127 and ( unichr(key.code) not in self._valid_input_chars ) \
and (not key.mask & modifier.ALT_MASK + modifier.CONTROL_MASK):
if key.code == keysyms.space:
self.commit_string (cond_letter_translate (unichr (key.code)))
return True
if ascii.ispunct (key.code):
self.commit_string (cond_punct_translate (unichr (key.code)))
return True
if ascii.isdigit (key.code):
self.commit_string (cond_letter_translate (unichr (key.code)))
return True
elif key.code > 127 and (not self._editor._py_mode):
return False
if key.code == keysyms.Escape:
self.reset ()
self._update_ui ()
return True
elif key.code in (keysyms.Return, keysyms.KP_Enter):
commit_string = self._editor.get_all_input_strings ()
self.commit_string (commit_string)
return True
elif key.code in (keysyms.Down, keysyms.KP_Down) :
res = self._editor.arrow_down ()
self._update_ui ()
return res
elif key.code in (keysyms.Up, keysyms.KP_Up):
res = self._editor.arrow_up ()
self._update_ui ()
return res
elif key.code in (keysyms.Left, keysyms.KP_Left) and key.mask & modifier.CONTROL_MASK:
res = self._editor.control_arrow_left ()
self._update_ui ()
return res
elif key.code in (keysyms.Right, keysyms.KP_Right) and key.mask & modifier.CONTROL_MASK:
res = self._editor.control_arrow_right ()
self._update_ui ()
return res
elif key.code in (keysyms.Left, keysyms.KP_Left):
res = self._editor.arrow_left ()
self._update_ui ()
return res
elif key.code in (keysyms.Right, keysyms.KP_Right):
res = self._editor.arrow_right ()
self._update_ui ()
return res
elif key.code == keysyms.BackSpace and key.mask & modifier.CONTROL_MASK:
res = self._editor.control_backspace ()
self._update_ui ()
return res
elif key.code == keysyms.BackSpace:
res = self._editor.backspace ()
self._update_ui ()
return res
elif key.code == keysyms.Delete and key.mask & modifier.CONTROL_MASK:
res = self._editor.control_delete ()
self._update_ui ()
return res
elif key.code == keysyms.Delete:
res = self._editor.delete ()
self._update_ui ()
return res
elif key.code >= keysyms._1 and key.code <= keysyms._9 and self._editor._candidates[0] and key.mask & modifier.CONTROL_MASK:
res = self._editor.number (key.code - keysyms._1)
self._update_ui ()
return res
elif key.code >= keysyms._1 and key.code <= keysyms._9 and self._editor._candidates[0] and key.mask & modifier.ALT_MASK:
res = self._editor.alt_number (key.code - keysyms._1)
self._update_ui ()
return res
elif key.code == keysyms.space:
o_py = self._editor._py_mode
sp_res = self._editor.space ()
#return (KeyProcessResult,whethercommit,commitstring)
if sp_res[0]:
self.commit_string (sp_res[1])
self.add_string_len(sp_res[1])
self.db.check_phrase (sp_res[1], sp_res[2])
else:
if sp_res[1] == u' ':
self.commit_string (cond_letter_translate (u" "))
if o_py != self._editor._py_mode:
self._refresh_properties ()
self._update_ui ()
return True
# now we ignore all else hotkeys
elif key.mask & modifier.CONTROL_MASK+modifier.ALT_MASK:
return False
elif key.mask & modifier.ALT_MASK:
return False
elif unichr(key.code) in self._valid_input_chars or \
( self._editor._py_mode and \
unichr(key.code) in u'abcdefghijklmnopqrstuvwxyz!@#$%' ):
if self._auto_commit and ( len(self._editor._chars[0]) == self._ml \
or len (self._editor._chars[0]) in self.db.pkeylens ):
# it is time to direct commit
sp_res = self._editor.space ()
#return (whethercommit,commitstring)
if sp_res[0]:
self.commit_string (sp_res[1])
self.add_string_len(sp_res[1])
self.db.check_phrase (sp_res[1],sp_res[2])
res = self._editor.add_input ( unichr(key.code) )
if not res:
if ascii.ispunct (key.code):
key_char = cond_punct_translate (unichr (key.code))
else:
key_char = cond_letter_translate (unichr (key.code))
sp_res = self._editor.space ()
#return (KeyProcessResult,whethercommit,commitstring)
if sp_res[0]:
self.commit_string (sp_res[1] + key_char)
self.add_string_len(sp_res[1])
self.db.check_phrase (sp_res[1],sp_res[2])
return True
else:
self.commit_string ( key_char )
return True
else:
if self._auto_commit and self._editor.one_candidate () and \
(len(self._editor._chars[0]) == self._ml \
or not self.db._is_chinese):
# it is time to direct commit
sp_res = self._editor.space ()
#return (whethercommit,commitstring)
if sp_res[0]:
self.commit_string (sp_res[1])
self.add_string_len(sp_res[1])
self.db.check_phrase (sp_res[1], sp_res[2])
return True
self._update_ui ()
return True
elif key.code in (keysyms.equal, keysyms.Page_Down, keysyms.KP_Page_Down) and self._editor._candidates[0]:
res = self._editor.page_down()
self._update_lookup_table ()
return res
elif key.code in (keysyms.minus, keysyms.Page_Up, keysyms.KP_Page_Up) and self._editor._candidates[0]:
res = self._editor.page_up ()
self._update_lookup_table ()
return res
elif key.code >= keysyms._1 and key.code <= keysyms._9 and self._editor._candidates[0]:
input_keys = self._editor.get_all_input_strings ()
res = self._editor.number (key.code - keysyms._1)
if res:
o_py = self._editor._py_mode
commit_string = self._editor.get_preedit_strings ()
self.commit_string (commit_string)
self.add_string_len(commit_string)
if o_py != self._editor._py_mode:
self._refresh_properties ()
self._update_ui ()
# modify freq info
self.db.check_phrase (commit_string, input_keys)
return True
elif key.code <= 127:
if not self._editor._candidates[0]:
commit_string = self._editor.get_all_input_strings ()
else:
self._editor.commit_to_preedit ()
commit_string = self._editor.get_preedit_strings ()
self._editor.clear ()
if ascii.ispunct (key.code):
self.commit_string ( commit_string + cond_punct_translate (unichr (key.code)))
else:
self.commit_string ( commit_string + cond_letter_translate (unichr (key.code)))
return True
return False
# below for initial test
def focus_in (self):
if self._on:
self.register_properties (self.properties)
self._refresh_properties ()
self._update_ui ()
try:
if self._sm_on:
self._sm.Show ()
else:
self._sm.Hide ()
except:
pass
def focus_out (self):
try:
self._sm.Hide()
except:
pass
def enable (self):
try:
self._sm.Reset()
except:
pass
self._on = True
self.focus_in()
def disable (self):
self.reset()
try:
self._sm.Hide()
except:
pass
self._on = False
def lookup_table_page_up (self):
if self._editor.page_up ():
self._update_lookup_table ()
return True
return True
def lookup_table_page_down (self):
if self._editor.page_down ():
self._update_lookup_table ()
return True
return False
def _start_setup (self):
if tabengine.__setup_pid != 0:
pid, state = os.waitpid(tabengine.__setup_pid, os.P_NOWAIT)
if pid != tabengine.__setup_pid:
os.kill(tabengine.__setup_pid, signal.SIGUSR1)
return
tabengine._setup_pid = 0
setup_cmd = os.path.join(LIBEXECDIR, "ibus-setup-table")
tabengine.__setup_pid = os.spawnl(os.P_NOWAIT, setup_cmd, "ibus-setup-table")
zjan999 于 2009-10-15 21:32:19发表:
HOHO,原把自己的探索与大家共享
丁丁当当 于 2009-10-15 14:39:36发表:
Lz辛苦了,谨代表广大网友感谢你!
heijunmasd 于 2009-10-12 21:20:12发表:
很强大
zjan999 于 2009-10-12 21:11:08发表:
已经搞清楚了
### The maxmium length of a key.
MAX_KEY_LENGTH = 4
原来是因为最大?值定义得太小了,定义成12通过
zjan999 于 2009-10-12 20:58:48发表:
在用ibus-table-createdb生成?表,显示信息如下
File "/usr/share/ibus-table/engine/^Ctabsqlitedb.py", line 487, in add_phrase
Traceback (most recent call last):
File "/usr/share/ibus-table/engine/tabcreatedb.py", line 297, in
main ()
File "/usr/share/ibus-table/engine/tabcreatedb.py", line 230, in main
db.add_phrases ( phrases )
File "/usr/share/ibus-table/engine/tabsqlitedb.py", line 389, in add_phrases
map (self.add_phrase, phrases, [database]*len(phrases),[False]*len(phrases) )
File "/usr/share/ibus-table/engine/tabsqlitedb.py", line 492, in add_phrase
traceback.print_exc()
File "/usr/lib/python2.6/traceback.py", line 227, in print_exc
print_exception(etype, value, tb, limit, file)
File "/usr/lib/python2.6/traceback.py", line 125, in print_exception
print_tb(tb, limit, file)
File "/usr/lib/python2.6/traceback.py", line 67, in print_tb
' File "%s", line %d, in %s' % (filename,lineno,name))
File "/usr/lib/python2.6/traceback.py", line 13, in _print
file.write(str+terminator)
?了解ibus的同志帮倒看一下是什么原因?
zjan999 于 2009-09-24 17:30:49发表:
嘿嘿
shiweimath 于 2009-09-24 00:21:43发表:
强大!
opius 于 2009-09-24 00:10:23发表:
很简单很强大