我正在开发一个小python脚本,它使用curses读取终端的stdin。当用户按下键时,movement_smallstep
应该递增,以便在x'重复'之后进行更快的总体移动。每次按键都会调用此函数。由于移动和函数的UI更改不同步,用户通常会“超调”目标,因此我想刷新一些诅咒的stdin。在
def movement_manager(step,repeats,key):
global old_key #remembering the n-1 pressed key of stdin
global input_repeats #remembering how often the key was pressed
global movement_smallstep #movement for ui change
if key != old_key:
input_key = key
input_repeats = 0
movement_smallstep = 1
if (input_repeats > repeats):
movement_smallstep+=1
#Flush the newest x stdin inputs of the queue here
input_repeats+=1
return movement_smallstep
例如,用户按“A”键23次。在
^{pr2}$
您可以使用^{} 函数放弃输入,或使用^{} 放弃输出(当输出落后时)。对于后者,文件描述符将是
1
(对于标准输出)。在相关问题 更多 >
编程相关推荐