本文整理匯總了Python中prompt_toolkit.keys.Keys.Down方法的典型用法代碼示例。如果您正苦於以下問題:Python Keys.Down方法的具體用法?Python Keys.Down怎麽用?Python Keys.Down使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類prompt_toolkit.keys.Keys
的用法示例。
在下文中一共展示了Keys.Down方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: prompt_toolkit_key_to_vt100_key
# 需要導入模塊: from prompt_toolkit.keys import Keys [as 別名]
# 或者: from prompt_toolkit.keys.Keys import Down [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 Down [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"