本文整理汇总了Python中prompt_toolkit.keys.Keys.Up方法的典型用法代码示例。如果您正苦于以下问题:Python Keys.Up方法的具体用法?Python Keys.Up怎么用?Python Keys.Up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prompt_toolkit.keys.Keys
的用法示例。
在下文中一共展示了Keys.Up方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prompt_toolkit_key_to_vt100_key
# 需要导入模块: from prompt_toolkit.keys import Keys [as 别名]
# 或者: from prompt_toolkit.keys.Keys import Up [as 别名]
def prompt_toolkit_key_to_vt100_key(key, application_mode=False):
"""
Turn a prompt toolkit key. (E.g Keys.ControlB) into a Vt100 key sequence.
(E.g. \x1b[A.)
"""
application_mode_keys = {
Keys.Up: '\x1bOA',
Keys.Left: '\x1bOD',
Keys.Right: '\x1bOC',
Keys.Down: '\x1bOB',
}
if key == Keys.ControlJ:
# Required for redis-cli. This can be removed when prompt_toolkit stops
# replacing \r by \n.
return '\r'
if key == '\n':
return '\r'
elif application_mode and key in application_mode_keys:
return application_mode_keys.get(key)
else:
return _PROMPT_TOOLKIT_KEY_TO_VT100.get(key, key)
示例2: test_arrows
# 需要导入模块: from prompt_toolkit.keys import Keys [as 别名]
# 或者: from prompt_toolkit.keys.Keys import Up [as 别名]
def test_arrows(processor, stream):
stream.feed("\x1b[A\x1b[B\x1b[C\x1b[D")
assert len(processor.keys) == 4
assert processor.keys[0].key == Keys.Up
assert processor.keys[1].key == Keys.Down
assert processor.keys[2].key == Keys.Right
assert processor.keys[3].key == Keys.Left
assert processor.keys[0].data == "\x1b[A"
assert processor.keys[1].data == "\x1b[B"
assert processor.keys[2].data == "\x1b[C"
assert processor.keys[3].data == "\x1b[D"