Ejemplo n.º 1
0

def has_key(ch):
    if type(ch) == type(''): ch = ord(ch)

    # Figure out the correct capability name for the keycode.
    capability_name = _capability_names[ch]

    #Check the current terminal description for that capability;
    #if present, return true, else return false.
    if _curses.tigetstr(capability_name): return 1
    else: return 0


if __name__ == '__main__':
    # Compare the output of this implementation and the ncurses has_key,
    # on platforms where has_key is already available
    try:
        L = []
        _curses.initscr()
        for key in _capability_names.keys():
            system = _curses.has_key(key)
            python = has_key(key)
            if system != python:
                L.append('Mismatch for key %s, system=%i, Python=%i' %
                         (_curses.keyname(key), system, python))
    finally:
        _curses.endwin()
        for i in L:
            print i
Ejemplo n.º 2
0
def has_key(ch):
    if type(ch) == type( '' ): ch = ord(ch)

    # Figure out the correct capability name for the keycode.
    capability_name = _capability_names[ch]

    #Check the current terminal description for that capability;
    #if present, return true, else return false.
    if _curses.tigetstr( capability_name ): return 1
    else: return 0

if __name__ == '__main__':
    # Compare the output of this implementation and the ncurses has_key,
    # on platforms where has_key is already available
    import _curses
    try:
        L = []
        _curses.initscr()
        for key in _capability_names.keys():
            system = _curses.has_key(key)
            python = has_key(key)
            if system != python:
                L.append( 'Mismatch for key %s, system=%i, Python=%i'
                          % (_curses.keyname( key ), system, python) )
    finally:
        _curses.endwin()
        for i in L: print i