Exemplo n.º 1
0
 def __init__(self, bus, object_path):
     super(Engine, self).__init__(bus, object_path)
     self.__is_invalidate = False
     self.__preedit_string = u""
     self.__lookup_table = ibus.LookupTable()
     self.__prop_list = ibus.PropList()
     self.__prop_list.append(ibus.Property(u"test", icon=u"ibus-locale"))
Exemplo n.º 2
0
    def __init__(self, bus, object_path):
        super(Engine, self).__init__(bus, object_path)
        im_open_decoder()
        self.__is_invalidate = False
        self.__prepinyin_string = u""
        self.__lookup_table = ibus.LookupTable()

        # 0 = english input mode
        # 1 = chinese input mode
        self.__mode = 1
        self.__full_width_letter = [False, False]
        self.__full_width_punct = [False, True]
        self.__full_width_punct[1] = True #config.get_value("engine/PinYin/FullWidthPunct", True)
        self.__trad_chinese = [False, False]

        self.reset()

        # init properties
        self.__prop_list = ibus.PropList()
        self.__status_property = ibus.Property(u"status")
        self.__prop_list.append(self.__status_property)
        self.__letter_property = ibus.Property(u"full_letter")
        self.__prop_list.append(self.__letter_property)
        self.__punct_property = ibus.Property(u"full_punct")
        self.__prop_list.append(self.__punct_property)
        self.__trad_chinese_property = ibus.Property(u"_trad chinese")
        if globals().get('libopencc'):
            self.__prop_list.append(self.__trad_chinese_property)
            pass
Exemplo n.º 3
0
 def __init__(self, bus, object_path):
     super(SulekhaEngine, self).__init__(bus, object_path)
     self.__keymap = keymap.Keymap("swanalekha_ml_IN")
     self.__input_method="en_US"
     self.__autocomplete=autocomplete.Autocomplete()
     self.__is_invalidate = False
     self.__preedit_string = u""
     self.__current_word = u""
     self.__lookup_table = ibus.LookupTable()
     self.__prop_list = ibus.PropList()
     self.__prop_list.append(ibus.Property(u"test", icon = u"ibus-locale"))
Exemplo n.º 4
0
    def __init__(self,
                 config,
                 phrase_table_index,
                 valid_input_chars,
                 max_key_length,
                 database,
                 parser=tabdict.parse,
                 deparser=tabdict.deparse,
                 max_length=64):
        self.db = database
        self._config = config
        self._name = self.db.get_ime_property('name')
        self._config_section = "engine/Table/%s" % self._name
        self._pt = phrase_table_index
        self._parser = parser
        self._deparser = deparser
        self._max_key_len = int(max_key_length)
        self._max_length = max_length
        self._valid_input_chars = valid_input_chars
        #
        # below vals will be reset in self.clear()
        #
        # we hold this: [str,str,...]
        # self._chars: hold user input in table mode (valid,invalid,prevalid)
        self._chars = [[], [], []]
        #self._t_chars: hold total input for table mode for input check
        self._t_chars = []
        # self._u_chars: hold user input but not manual comitted chars
        self._u_chars = []
        # self._tabkey_list: hold tab_key objects transform from user input chars
        self._tabkey_list = []
        # self._strings: hold preedit strings
        self._strings = []
        # self._cursor: the caret position in preedit phrases
        self._cursor = [0, 0]
        # self._candidates: hold candidates selected from database [[now],[pre]]
        self._candidates = [[], []]
        self._lookup_table = ibus.LookupTable(tabengine._page_size, -1, False)
        self._lookup_table.clean()
        self._lookup_table.show_cursor(False)

        #        tabengine.hide_lookup_table(tabengine)
        #        self._lookup_table.set_cursor_pos_in_current_page(0)
        # self._py_mode: whether in pinyin mode
        self._py_mode = False
        # self._caret: caret position in lookup_table
        self._caret = 0
        # self._onechar: whether we only select single character
        self._onechar = self._config.get_value(self._config_section, "OneChar",
                                               False)
        self._first = 0
        self.is_down_press = False
Exemplo n.º 5
0
    def __init__(self, bus, object_path):
        super(Engine, self).__init__(bus, object_path)
        
        delete_log()
        append_log("Creating engine... ibus version " + ibus.get_version())
        append_log("Time: " + str(datetime.datetime.now()))

        #Set our initial encoding state
        self.__encoding = ENCODING_UNICODE
        self.__typenum = NUMBERS_MYANMAR
        self.__prop_dict = {}
        self.__prop_list = self.__init_props()

        #Prop 1 - Check for saved value
        try:
            mode = self.__prefs.get_value('common', 'output_encoding')
            mode = 'OutputEncoding.' + ['Unicode', 'Zawgyi', 'WinInnwa'][mode]
            self.__output_encoding_activate(mode, ibus.PROP_STATE_CHECKED)
        except: pass

        #Prop 2 - Check for saved value
        try:
            mode = self.__prefs.get_value('common', 'type_numerals')
            mode = 'TypeNumerals.' + ['Burmese', 'Arabaic'][mode]
            self.__type_numerals_activate(mode, ibus.PROP_STATE_CHECKED)
        except: pass
        
        self.__has_focus = False

        #My strings
        self.__typed_string = u""
        self.__aux_string = u""
        self.__guess_string = u""
        self.__prefix_string = u""
        self.__postfix_string = u""
        self.__preedit_string = u""

        self.__is_invalidate = False
        self.__lookup_table = ibus.LookupTable()
        	
        append_log("Engine created")
        
        modelPath = '/usr/share/waitzar/model2/Myanmar.model'
        mywordsPaths = libwaitzar.StringVec()
        mywordsPaths.append('/usr/share/waitzar/model2/mywords.txt')
        
        self.model = libwaitzar.WordBuilder(modelPath, mywordsPaths)
        self.model.reset(True)
        self.sentence = libwaitzar.SentenceList()
        
        append_log("Model created")
Exemplo n.º 6
0
    def __init__(self, bus, object_path):
        super(Engine, self).__init__(bus, object_path)
        self.__is_invalidate = False
        labels = [ibus.Text(c + u':') for c in self.__select_keys]
        page_size = self.config.get_value('page_size')
        pagination_start = self.config.get_value('pagination_start')
        self.__lookup_table = ibus.LookupTable(page_size=page_size,
                                               round=False,
                                               labels=labels)
        #if hasattr(self.__lookup_table, 'set_orientation'):
        #    self.__lookup_table.set_orientation(ibus.ORIENTATION_HORIZONTAL)

        self.__candidate_selector = CandidateSelector(self.__lookup_table,
                                                      self.__select_keys,
                                                      page_size,
                                                      pagination_start)
        if hasattr(self, 'get_surrounding_text'):
            self.__surrounding_text = SurroundingText(self)
        else:
            self.__surrounding_text = None
        usrdict = skkdict.UsrDict(self.config.usrdict_path)
        self.__tutcode = tutcode.Context(usrdict, self.sysdict,
                                         self.__candidate_selector,
                                         self.__surrounding_text)
        self.__tutcode.tutcode_rule = self.config.get_value('tutcode_rule')
        self.__initial_input_mode = self.config.get_value('initial_input_mode')
        self.__use_with_vi = self.config.get_value('use_with_vi')
        self.__vi_escape_keys = self.config.get_value('vi_escape_keys')
        self.__tutcode.translated_strings['dict-edit-prompt'] = \
            _(u'DictEdit').decode('UTF-8')
        self.__tutcode.custom_tutcode_rule = \
            self.config.get_value('custom_tutcode_rule')
        self.__tutcode.on_keys = self.config.get_value('on_keys')
        self.__tutcode.off_keys = self.config.get_value('off_keys')
        self.__tutcode.cancel_keys = self.config.get_value('cancel_keys')
        self.__tutcode.backspace_keys = self.config.get_value('backspace_keys')
        self.__tutcode.conv_keys = self.config.get_value('conv_keys')
        self.__tutcode.next_keys = self.config.get_value('next_keys')
        self.__tutcode.prev_keys = self.config.get_value('prev_keys')
        self.__tutcode.commit_keys = self.config.get_value('commit_keys')
        self.__tutcode.purge_keys = self.config.get_value('purge_keys')
        self.__tutcode.reset()
        self.__tutcode.activate_input_mode(self.__initial_input_mode)
        self.__prop_dict = dict()
        self.__prop_list = self.__init_props()
        self.__input_mode = tutcode.INPUT_MODE_HIRAGANA
        self.__update_input_mode()
        self.__suspended_mode = None
Exemplo n.º 7
0
    def update_lookup_table(self, lookup_table, visible):
        # hide lookup table
        if not visible:
            self.hide_lookup_table()

        self.__lookup_table = lookup_table or ibus.LookupTable()
        orientation = self.__lookup_table.get_orientation()
        if orientation not in (ibus.ORIENTATION_HORIZONTAL,
                               ibus.ORIENTATION_VERTICAL):
            orientation = self.__orientation
        self.set_current_orientation(orientation)
        self.__refresh_candidates()
        self.__refresh_labels()

        # show lookup table
        if visible:
            self.show_lookup_table()
Exemplo n.º 8
0
    def __init__(self, bus, obj_path):
        print 'obj_path is', obj_path
        super(tabengine, self).__init__(bus, obj_path)
        self._bus = bus
        self.sock = None

        self.do_connect()

        self.clear_data()
        self._lookup_table = ibus.LookupTable(tabengine._page_size)

        self._name = 'sdim'
        print 'name is', self._name
        self._config_section = "engine/%s" % self._name

        # config module
        self._config = self._bus.get_config()
        self._on = True
        self.reset()
Exemplo n.º 9
0
    def __init__(self, bus, obj_path):
        print 'obj_path is', obj_path
        super(tabengine, self).__init__(bus, obj_path)
        self._bus = bus

        self.sock = socket(AF_INET, SOCK_STREAM)
        self.sock.connect(("localhost", 12345))
        self.sock = self.sock.makefile("rwb", 0)

        self.clear_data()
        self._lookup_table = ibus.LookupTable(tabengine._page_size)

        self._name = 'sdim'
        print 'name is', self._name
        self._config_section = "engine/%s" % self._name

        # config module
        self._config = self._bus.get_config()
        self._on = True
        self.reset()
Exemplo n.º 10
0
            x = cursor_right

        if window_bottom > monitor_bottom:
            # move the window just above the cursor so the window and a preedit string do not overlap.
            y = cursor_location[1] - self.__toplevel.allocation.height
        else:
            y = cursor_bottom

        self.move(x, y)

    def show_all(self):
        gtk.VBox.show_all(self)
        self.__toplevel.show_all()

    def hide_all(self):
        gtk.VBox.hide_all(self)
        self.__toplevel.hide_all()

    def move(self, x, y):
        self.__toplevel.move(x, y)


if __name__ == "__main__":
    table = ibus.LookupTable()
    table.append_candidate(ibus.Text("AAA"))
    table.append_candidate(ibus.Text("BBB"))
    cp = CandidatePanel()
    cp.show_all()
    cp.update_lookup_table(table, True)
    gtk.main()
Exemplo n.º 11
0
 def __init__(self, schema_id=None):
     self.__lookup_table = ibus.LookupTable()
     self.__backend = Engine(self, schema_id)
Exemplo n.º 12
0
 def __init__(self, conn, object_path):
     super(RimeSession, self).__init__(conn, object_path)
     self.__page_size = storage.DB.read_setting(u'Option/PageSize') or 5
     self.__lookup_table = ibus.LookupTable(self.__page_size)
     self.__backend = Engine(self)
Exemplo n.º 13
0
 def __init__(self, params=None):
     logger.info("init weasel session: %s", params)
     self.__page_size = storage.DB.read_setting(u'Option/PageSize') or 5
     self.__lookup_table = ibus.LookupTable(self.__page_size)
     self.__clear()
     self.__backend = Engine(self, params)
Exemplo n.º 14
0
    def __init__(self, bus, obj_path, db):
        super(tabengine, self).__init__(bus, obj_path)
        self._bus = bus
        self.db = db

        try:
            tabengine._page_size = int(self.db.get_ime_property('page_size'))
        except:
            tabengine._page_size = 6

        if tabengine._page_size > 15:
            tabengine._page_size = 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 )

        # 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_EUROPEAN_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._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

        # check whether we can use '=' and '-' for page_down/up
        self._page_down_keys = [keysyms.Page_Down, keysyms.KP_Page_Down]
        self._page_up_keys = [keysyms.Page_Up, keysyms.KP_Page_Up]
        if '=' not in self._valid_input_chars \
                and '-' not in self._valid_input_chars:
            self._page_down_keys.append(keysyms.equal)
            self._page_up_keys.append(keysyms.minus)

        self._pt = self.db.get_phrase_table_index()
        self._ml = int(self.db.get_ime_property('max_key_length'))

        # name for config section
        self._name = self.db.get_ime_property('name')
        self._config_section = "engine/Table/%s" % self._name

        # config module
        self._config = self._bus.get_config()
        # Containers we used:
        self._editor = editor(self._config, self._pt, self._valid_input_chars,
                              self._ml, self.db)
        # 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 = [
            self._config.get_value(self._config_section,
                                   "EnDefFullWidthLetter", False),
            self._config.get_value(
                self._config_section, "TabDefFullWidthLetter",
                self.db.get_ime_property('def_full_width_letter').lower() ==
                u'true')
        ]
        self._full_width_punct = [
            self._config.get_value(self._config_section, "EnDefFullWidthPunct",
                                   False),
            self._config.get_value(
                self._config_section, "TabDefFullWidthPunct",
                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
        self._auto_commit = self._config.get_value(self._config_section,
                                                   "AutoCommit",
                                                   self._auto_commit)
        # 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()