def test_common_letter_num_keyseqs(): allowed_keys = ('a', ) case = {} initial_keyseqs = prompt.common(case, Keystroke('a'), [], allowed_keys) assert initial_keyseqs == ['a'] newkeyseqs = prompt.common(case, Keystroke('2'), initial_keyseqs, allowed_keys) assert newkeyseqs == ['a', '2'] final_key_seqs = prompt.common(case, Keystroke('1'), newkeyseqs, allowed_keys) assert final_key_seqs == ['a', '2', '1']
def multiCharInput(self): searchQuery = '' val = Keystroke('') with self.term.cbreak(): while val.name !='KEY_ENTER': val = self.term.inkey() if not val.is_sequence: searchQuery+= val return searchQuery
def test_a_keystroke(): "Test keyboard.Keystroke constructor with set arguments." from blessed.keyboard import Keystroke ks = Keystroke(ucs=u'x', code=1, name=u'the X') assert ks._name == u'the X' assert ks.name == ks._name assert ks._code == 1 assert ks.code == ks._code assert u'xx' == u'x' + ks assert ks.is_sequence assert repr(ks) == "the X"
def test_keystroke_default_args(): "Test keyboard.Keystroke constructor with default arguments." from blessed.keyboard import Keystroke ks = Keystroke() assert ks._name is None assert ks.name == ks._name assert ks._code is None assert ks.code == ks._code assert u'x' == u'x' + ks assert not ks.is_sequence assert repr(ks) in ("u''", # py26, 27 "''",) # py33
def __call__(self): return Keystroke(ucs=letter, code=1, name=letter)
def __call__(self): return Keystroke(ucs='q', code=1, name='q')
def __call__(self): return Keystroke(ucs='', code=1, name='KEY_DOWN')
from blessed import Terminal from blessed.keyboard import Keystroke term = Terminal() with term.cbreak(): val = Keystroke('') query = '' while val.is_sequence != True and val.name != 'KEY_ENTER': val = term.inkey() if val.is_sequence: pass elif val: print("got {0}.".format(val)) query += val print(query) print(f'bye!{term.normal}')
def listener(event): if event.exception: sendjob.remove() scheduler = BackgroundScheduler() scheduler.add_listener(listener, EVENT_JOB_ERROR) sendjob = None # Suppress exception logging on default executor logging.getLogger('apscheduler.executors.default').setLevel('CRITICAL') # open_input(path='data/openlog-20160807-002.TXT') # return from Wilder Ranch # open_input(path='data/openlog-20160807-001.TXT') # return from Wilder Ranch output_stream = live_stream() # Install input handlers (callbacks for commands) d.add_command('send', add_sender) d.add_command('pause', lambda: sendjob.pause()) d.add_command('resume', lambda: sendjob.resume()) # Restart sending: <shift> + F8 def restart(): global sendjob sendjob.remove() add_sender() d.add_key(Keystroke(ucs='', code=284, name='KEY_F20'), restart) # Start the display d.start()