Exemplo n.º 1
0
modStates = {}
for m in dm:
  modStates[m] = [('none', m)]

for m in sorted(dmm, mod_order):
  if len(m) == 2:
    m1, m2 = m
    modStates[m1].append((m2, '%s_%s' % (m1, m2)))
    modStates[m2].append((m1, '%s_%s' % (m1, m2)))
  
print >> deadXMLBuf
print >> deadXMLBuf
for m in sorted(modStates.keys()):
  l = modStates[m]
  print >> deadXMLBuf, '    <action id="%s">' % m
  print >> deadXMLBuf, '      <when state="%s" output="%s"/>' % (m, xmlChar(terminators.get(m, "?")))
  for s, n in sorted(l, mod_order2):
    print >> deadXMLBuf, '      <when state="%s" next="%s"/>' % (s, n)
    
  if compose.charActions.has_key(m):
    a = compose.charActions[m]
    if compose.statesByAction.has_key(a):
      for s in sorted(compose.statesByAction[a]):
        print >> deadXMLBuf, u'      <when state="%s" next="%s"/>' % ('_'.join(s), '_'.join(s+(a,)))
    if compose.outputsByAction.has_key(a):
      for s, c1 in sorted(compose.outputsByAction[a]):
        print >> deadXMLBuf, u'      <when state="%s" output="%s"/>' % ('_'.join(s), xmlChar(c1))   
            
  print >> deadXMLBuf, '    </action>'
  
print >> deadXMLBuf, '    <action id="Multi_key">'
Exemplo n.º 2
0
ascii_set = set([
'^', '~', '<', '=', '>', '|', '_', '-', ',', ';', '!', '?', '/', '.', '"', '(',
')', '[', ']', '{', '}', '@', '$', '*', '&', '#', '%', '+', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E',
'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M',
'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U',
'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z'
])

androidkeys = {}
for k in xkbToQwerty.itervalues():
    androidkeys[k] = {}

for k, v in xkb.tmplValues.iteritems():
    v = terminators.get( v, v )
    if v == "":
        v = " "
    key = k.split('_', 1)
    if len(key) == 0:
        continue
    xkbName = key[0]
    if len(key) > 1:
        modifiers = key[1]
    else:
        modifiers = ""

    #print("Key: %s, modifier: %s, value: %s"%(xkbName,modifiers,v))
    for km, vm in modifiersMap.iteritems():
        if modifiers == km:
            #print("%s %s: %s"%(xkbToQwerty[xkbName], modifiersMap[modifiers], v))
Exemplo n.º 3
0
# print charActions[u'(']
# sys.exit()

if __name__ == "__main__":
    for a in sorted(set(statesByAction.keys() + outputsByAction.keys())):
        C = char(a)
        if C:
            print u'    <action id="%s">' % C
            if statesByAction.has_key(a):
                for s in sorted(statesByAction[a]):
                    print u'      <when state="%s" next="%s"/>' % (
                        '_'.join(s), '_'.join(s + (a, )))
            if outputsByAction.has_key(a):
                for s, c in sorted(outputsByAction[a]):
                    print u'      <when state="%s" output="%s"/>' % (
                        '_'.join(s), c)
            print u'    </action>'

    print '''
    <action id="Multikey">
      <when state="none" next="Multikey"/>
    </action>
  '''

    print "  <terminators>"
    for ss in sorted(states):
        C = ''.join([terminators.get(char(s), char(s)) for s in ss])
        s = '_'.join(list(ss))
        print '    <when state="%s" output="%s"/>' % (s, C)
    print "  </terminators>"
Exemplo n.º 4
0
        #    if terminators.has_key(v):
            if deadNames.has_key(v):
                cl = deadNames[v]
                try:
                    term = codecs.encode(terminators[v], "iso-8859-15")
                except:
                    term = "nop"
            elif terminators.has_key(v):
                print "unsupported", "dead_" + v
                term = "nop"
                try:
                    cl = codecs.encode(terminators[v], "iso-8859-15")
                except:
                    cl = "nop"
            s += prefix + " " + escape(cl) + " "
        else:
            # this is the control modifier. We have to choose a single control char to send which correspond
            # to one of the 4 characters on the key.
            cc = "nop"
            for cm in ["_shift_option", "_option", "_shift", ""]:
                cv = xkb.tmplValues[k + cm]
                cv = terminators.get(cv, cv)
                if charToCtrl.has_key(cv):
                    if cc != "nop" and cc != charToCtrl[cv]:
                        print "ctrl already found for", k, cc, "- using", charToCtrl[
                            cv], "instead."
                    cc = charToCtrl[cv]
            s += prefix + " " + escape(cc) + " "

    print >> out, s
Exemplo n.º 5
0
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#

import defaults, sys
defaults.xkbFile = sys.argv[1]

import xkb, dead_keys, codecs
from terminators import terminators


fullMapTmpl = keyboardTemplate = u"""%(TLDE)s%(AE01)s%(AE02)s%(AE03)s%(AE04)s%(AE05)s%(AE06)s%(AE07)s%(AE08)s%(AE09)s%(AE10)s%(AE11)s%(AE12)s
%(AD01)s%(AD02)s%(AD03)s%(AD04)s%(AD05)s%(AD06)s%(AD07)s%(AD08)s%(AD09)s%(AD10)s%(AD11)s%(AD12)s
%(AC01)s%(AC02)s%(AC03)s%(AC04)s%(AC05)s%(AC06)s%(AC07)s%(AC08)s%(AC09)s%(AC10)s%(AC11)s%(BKSL)s
%(LSGT)s%(AB01)s%(AB02)s%(AB03)s%(AB04)s%(AB05)s%(AB06)s%(AB07)s%(AB08)s%(AB09)s%(AB10)s
%(TLDE_shift)s%(AE01_shift)s%(AE02_shift)s%(AE03_shift)s%(AE04_shift)s%(AE05_shift)s%(AE06_shift)s%(AE07_shift)s%(AE08_shift)s%(AE09_shift)s%(AE10_shift)s%(AE11_shift)s%(AE12_shift)s
%(AD01_shift)s%(AD02_shift)s%(AD03_shift)s%(AD04_shift)s%(AD05_shift)s%(AD06_shift)s%(AD07_shift)s%(AD08_shift)s%(AD09_shift)s%(AD10_shift)s%(AD11_shift)s%(AD12_shift)s
%(AC01_shift)s%(AC02_shift)s%(AC03_shift)s%(AC04_shift)s%(AC05_shift)s%(AC06_shift)s%(AC07_shift)s%(AC08_shift)s%(AC09_shift)s%(AC10_shift)s%(AC11_shift)s%(BKSL_shift)s
%(LSGT_shift)s%(AB01_shift)s%(AB02_shift)s%(AB03_shift)s%(AB04_shift)s%(AB05_shift)s%(AB06_shift)s%(AB07_shift)s%(AB08_shift)s%(AB09_shift)s%(AB10_shift)s
"""

fullMapValues = {}
for k, v in xkb.tmplValues.iteritems():
   v = terminators.get( v, v )
   if v == "":
     v = " "
   fullMapValues[k] = v
out = codecs.open(sys.argv[2], "w", "utf8")
out.write( fullMapTmpl % fullMapValues )
Exemplo n.º 6
0
Arquivo: svg.py Projeto: raifer/bepora

def xmlChar(v):
    if v == u'"':
        v = u"&#x0022;"
    elif v == u'<':
        v = u"&#x003c;"
    elif v == u'&':
        v = u'&#x0026;'
    return v


out = codecs.open(sys.argv[2] + ".svg", "w", "utf8")
print >> out, header
for k, v in xkb.tmplValues.iteritems():
    v2 = terminators.get(v, v)
    if "_capslock" in k or "_command" in k:
        continue
    x, y, color = offsetAndColor(k)
    if terminators.has_key(v):
        color = deadColor
    print >> out, charTmpl % (x, y, color, xmlChar(v2))
print >> out, footer
out.close()

out = codecs.open(sys.argv[2] + "-simplifiee.svg", "w", "utf8")
print >> out, header
for k, v in xkb.tmplValues.iteritems():
    v2 = terminators.get(v, v)
    if "_capslock" in k or "_command" in k:
        continue
Exemplo n.º 7
0
    #    if terminators.has_key(v):
      if deadNames.has_key(v):
        cl = deadNames[v]
        try:
          term = codecs.encode(terminators[v], "iso-8859-15")
        except:
          term = "nop"
      elif terminators.has_key(v):
        print "unsupported", "dead_"+v
        term = "nop"
        try:
          cl = codecs.encode(terminators[v], "iso-8859-15")
        except:
          cl = "nop"
      s += prefix+" "+escape(cl)+" "
    else:
      # this is the control modifier. We have to choose a single control char to send which correspond
      # to one of the 4 characters on the key.
      cc = "nop"
      for cm in ["_shift_option", "_option", "_shift", ""]:
        cv = xkb.tmplValues[k+cm]
        cv = terminators.get(cv, cv)
        if charToCtrl.has_key(cv):
          if cc != "nop" and cc != charToCtrl[cv]:
            print "ctrl already found for", k, cc, "- using", charToCtrl[cv], "instead."
          cc = charToCtrl[cv]
      s += prefix+" "+escape(cc)+" "
   
  print >> out, s

Exemplo n.º 8
0
# print charActions[u'(']
# sys.exit()

if __name__ == "__main__":
  for a in sorted(set(statesByAction.keys() + outputsByAction.keys()) ):
    C = char(a)
    if C:
      print u'    <action id="%s">' % C
      if statesByAction.has_key(a):
        for s in sorted(statesByAction[a]):
          print u'      <when state="%s" next="%s"/>' % ('_'.join(s), '_'.join(s+(a,)))
      if outputsByAction.has_key(a):
        for s, c in sorted(outputsByAction[a]):
          print u'      <when state="%s" output="%s"/>' % ('_'.join(s), c)
      print u'    </action>'

      
  print '''
    <action id="Multikey">
      <when state="none" next="Multikey"/>
    </action>
  '''

  print "  <terminators>"
  for ss in sorted(states):
    C = ''.join([terminators.get(char(s), char(s)) for s in ss])
    s = '_'.join(list(ss))
    print '    <when state="%s" output="%s"/>' % (s, C)
  print "  </terminators>"
  
  
Exemplo n.º 9
0
for m in dm:
    modStates[m] = [('none', m)]

for m in sorted(dmm, mod_order):
    if len(m) == 2:
        m1, m2 = m
        modStates[m1].append((m2, '%s_%s' % (m1, m2)))
        modStates[m2].append((m1, '%s_%s' % (m1, m2)))

print >> deadXMLBuf
print >> deadXMLBuf
for m in sorted(modStates.keys()):
    l = modStates[m]
    print >> deadXMLBuf, '    <action id="%s">' % m
    print >> deadXMLBuf, '      <when state="%s" output="%s"/>' % (
        m, xmlChar(terminators.get(m, "?")))
    for s, n in sorted(l, mod_order2):
        print >> deadXMLBuf, '      <when state="%s" next="%s"/>' % (s, n)

    if compose.charActions.has_key(m):
        a = compose.charActions[m]
        if compose.statesByAction.has_key(a):
            for s in sorted(compose.statesByAction[a]):
                print >> deadXMLBuf, u'      <when state="%s" next="%s"/>' % (
                    '_'.join(s), '_'.join(s + (a, )))
        if compose.outputsByAction.has_key(a):
            for s, c1 in sorted(compose.outputsByAction[a]):
                print >> deadXMLBuf, u'      <when state="%s" output="%s"/>' % (
                    '_'.join(s), xmlChar(c1))

    print >> deadXMLBuf, '    </action>'
Exemplo n.º 10
0
Arquivo: svg.py Projeto: haseebq/bepo

def xmlChar(v):
  if v == u'"':
    v = u"&#x0022;"
  elif v == u'<':
    v = u"&#x003c;"
  elif v == u'&':
    v = u'&#x0026;'
  return v
  
  
out = codecs.open(sys.argv[2]+".svg", "w", "utf8")
print >> out, header
for k, v in xkb.tmplValues.iteritems():
  v2 = terminators.get( v, v )
  if "_capslock" in k or "_command" in k:
   continue
  x, y, color = offsetAndColor(k)
  if terminators.has_key(v):
   color = deadColor
  print >> out, charTmpl % (x, y, color, xmlChar(v2))
print >> out, footer
out.close()


out = codecs.open(sys.argv[2]+"-simplifiee.svg", "w", "utf8")
print >> out, header
for k, v in xkb.tmplValues.iteritems():
  v2 = terminators.get( v, v )
  if "_capslock" in k or "_command" in k: