Exemplo n.º 1
0
def tt_my_raw_input():
	cmsg('Testing my_raw_input():')
	msg(fmt("""
		At the Ready? prompt type and hold down "y".
		Then Enter some text, followed by held-down ENTER.
		The held-down "y" and ENTER keys should be blocked, not affecting the output
		on screen or entered text.
	"""))
	get_char_raw('Ready? ',num_chars=1)
	reply = my_raw_input('\nEnter text: ')
	confirm('Did you enter the text {!r}?'.format(reply))
Exemplo n.º 2
0
def _get_random_data_from_user(uchars):
    m = 'Enter {} random symbols' if opt.quiet else crmsg['usr_rand_notice']
    msg(m.format(uchars))
    prompt = 'You may begin typing.  {} symbols left: '
    msg_r(prompt.format(uchars))

    import time
    from mmgen.term import get_char_raw, kb_hold_protect
    key_data, time_data = '', []

    for i in range(uchars):
        kb_hold_protect()
        key_data += get_char_raw()
        msg_r('\r' + prompt.format(uchars - i - 1))
        time_data.append(time.time())

    if opt.quiet: msg_r('\r')
    else: msg_r("\rThank you.  That's enough.{}\n\n".format(' ' * 18))

    fmt_time_data = map('{:.22f}'.format, time_data)
    dmsg('\nUser input:\n{!r}\nKeystroke time values:\n{}\n'.format(
        key_data, '\n'.join(fmt_time_data)))
    prompt = 'User random data successfully acquired.  Press ENTER to continue'
    prompt_and_get_char(prompt, '', enter_ok=True)

    return key_data + ''.join(fmt_time_data)
Exemplo n.º 3
0
 def get_word():
     s = ''
     while True:
         ch = get_char_raw('')
         if ch in '\b\x7f':
             if s: s = s[:-1]
         elif ch in '\n ':
             if s: break
         else: s += ch
     return s
Exemplo n.º 4
0
		def get_word():
			s = ''
			while True:
				ch = get_char_raw('')
				if ch in '\b\x7f':
					if s: s = s[:-1]
				elif ch in '\n ':
					if s: break
				else: s += ch
			return s
Exemplo n.º 5
0
 def get_word():
     s, pad = '', 0
     while True:
         ch = get_char_raw('', num_chars=1).decode()
         if ch in '\b\x7f':
             if s: s = s[:-1]
         elif ch in '\n\r ':
             if s: break
         elif ch not in ascii_lowercase:
             pad += 1
             if s and pad + len(s) > longest_word:
                 break
         else:
             s += ch
     return s
Exemplo n.º 6
0
def _get_random_data_from_user(uchars):
	m = 'Enter {} random symbols' if opt.quiet else crmsg['usr_rand_notice']
	msg(m.format(uchars))
	prompt = 'You may begin typing.  {} symbols left: '

	import time
	from mmgen.term import get_char_raw
	key_data,time_data = bytes(),[]

	for i in range(uchars):
		key_data += get_char_raw('\r'+prompt.format(uchars-i))
		time_data.append(time.time())

	if opt.quiet: msg_r('\r')
	else: msg_r("\rThank you.  That's enough.{}\n\n".format(' '*18))

	fmt_time_data = list(map('{:.22f}'.format,time_data))
	dmsg('\nUser input:\n{!r}\nKeystroke time values:\n{}\n'.format(key_data,'\n'.join(fmt_time_data)))
	prompt = 'User random data successfully acquired.  Press ENTER to continue'
	prompt_and_get_char(prompt,'',enter_ok=True)

	return key_data+''.join(fmt_time_data).encode()