Exemplo n.º 1
0
    def __init__(self, keyval, chars, state):
        self.code = keyval
        self.mask = state
        self.name = chars

        if self.name and not (len(self.name) == 1
                              and ord(self.name) < ord(' ')):
            if self.name == ' ':
                self.name = 'space'
            else:
                self.mask &= ~modifier.SHIFT_MASK
        else:
            self.name = keysyms.keycode_to_name(self.code).lower()

        if self.name in (
                "control_l",
                "control_r",
                "alt_l",
                "alt_r",
                "shift_l",
                "shift_r",
        ):
            self.name = ""
            return

        mods = ''
        if self.mask & modifier.ALT_MASK:
            mods += 'A'
        if self.mask & modifier.CONTROL_MASK:
            mods += 'C'
        if self.mask & modifier.SHIFT_MASK:
            mods += 'S'

        if mods != '':
            self.name = mods + ' ' + self.name
Exemplo n.º 2
0
    def __init__(self, keyval, chars, state):
        self.code = keyval
        self.mask = state
        self.name = chars
        
        if self.name and not (len(self.name) == 1 and ord(self.name) < ord(' ')):
            if self.name == ' ':
                self.name = 'space'
            else:
                self.mask &= ~modifier.SHIFT_MASK
        else:
            self.name = keysyms.keycode_to_name(self.code).lower()
        
        if self.name in ("control_l",
                         "control_r",
                         "alt_l",
                         "alt_r",
                         "shift_l",
                         "shift_r",
                         ):
            self.name = ""
            return

        mods = ''
        if self.mask & modifier.ALT_MASK:
            mods += 'A'
        if self.mask & modifier.CONTROL_MASK:
            mods += 'C'
        if self.mask & modifier.SHIFT_MASK:
            mods += 'S'

        if mods != '':
            self.name = mods + ' ' + self.name
Exemplo n.º 3
0
    def __init__(self, keyval, is_press, state):
        self.code = keyval
        self.mask = state
        self.name = ''
        if not is_press:
            self.mask |= IBus.ModifierType.RELEASE_MASK
            return

        try:
            self.name = chr(self.code)
            if self.name == ' ':
                self.name = 'space'
            else:
                self.mask &= ~IBus.ModifierType.SHIFT_MASK
        except:
            self.name = keysyms.keycode_to_name(self.code).lower()

        if self.name in ("control_l",
                         "control_r",
                         "alt_l",
                         "alt_r",
                         "shift_l",
                         "shift_r",
                         ):
            self.name = ""
            return

        mods = ''
        if self.mask & IBus.ModifierType.MOD1_MASK:
            mods += 'A'
        if self.mask & IBus.ModifierType.CONTROL_MASK:
            mods += 'C'
        if self.mask & IBus.ModifierType.SHIFT_MASK:
            mods += 'S'

        if mods != '':
            self.name = mods + ' ' + self.name