Beispiel #1
0
    def _convert_okuri(self, nn=u''):

        clauses = self._clauses
        wordbuf = self._wordbuf
        charbuf = self._charbuf

        buf = charbuf.getbuffer()
        if not buf:
            return False
        okuri = nn + self._draincharacters()
        self._okuri = okuri
        if nn:
            buf = 'n'
        else:
            buf = buf[0]
        key = wordbuf.get()

        if self._inputmode.iskata():
            key = kanadb.to_hira(key)
        result = dictionary.getokuri(key + buf)
        clauses = dictionary.Clauses()

        self._draw_nothing(self._output)
        if result or key[0] == u'@':
            clauses.add(dictionary.Clause(key, result))
        else:
            if settings.get('cgi-api.enabled'):
                dictionary.get_from_cgi_api(clauses, key)
            if not clauses:
                clauses.add(dictionary.Clause(key, [key]))
            clauses.add(dictionary.Clause(okuri, [okuri]))
            self._okuri = u''

        self._clauses = clauses
        self._listbox.assign(clauses.getcandidates())
        wordbuf.startedit()

        if self._inputmode.iskata():
            key = kanadb.to_kata(key)
        self.settitle(u'%s - %s' % (key, buf))

        return True
Beispiel #2
0
 def _skk_toggle_kana(self, context, c):
     wordbuf = self._wordbuf
     inputmode = self._inputmode
     if self._iscooking():
         s = self._draincharacters()
         wordbuf.append(s)
         word = wordbuf.get()
         self._reset()
         if inputmode.ishira():
             s = kanadb.to_kata(word)
         else:
             s = kanadb.to_hira(word)
         context.putu(s)
         return True
     else:
         self._charbuf.toggle()
         if inputmode.ishira():
             inputmode.startkata()
         elif inputmode.iskata():
             inputmode.starthira()
         self._reset()
         return True
     return False
Beispiel #3
0
def _make_rules(rule):
    hira_rule = rule
    kata_rule = {}
    for key, value in hira_rule.items():
        kata_rule[key] = kanadb.to_kata(value)
    return (hira_rule, kata_rule)