本文整理匯總了Python中prompt_toolkit.token.Token.PartialKeyBinding方法的典型用法代碼示例。如果您正苦於以下問題:Python Token.PartialKeyBinding方法的具體用法?Python Token.PartialKeyBinding怎麽用?Python Token.PartialKeyBinding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類prompt_toolkit.token.Token
的用法示例。
在下文中一共展示了Token.PartialKeyBinding方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _show_input_processor_key_buffer
# 需要導入模塊: from prompt_toolkit.token import Token [as 別名]
# 或者: from prompt_toolkit.token.Token import PartialKeyBinding [as 別名]
def _show_input_processor_key_buffer(self, cli, new_screen):
"""
When the user is typing a key binding that consists of several keys,
display the last pressed key if the user is in insert mode and the key
is meaningful to be displayed.
E.g. Some people want to bind 'jj' to escape in Vi insert mode. But the
first 'j' needs to be displayed in order to get some feedback.
"""
key_buffer = cli.input_processor.key_buffer
if key_buffer and _in_insert_mode(cli) and not cli.is_done:
# The textual data for the given key. (Can be a VT100 escape
# sequence.)
data = key_buffer[-1].data
# Display only if this is a 1 cell width character.
if get_cwidth(data) == 1:
cpos = new_screen.cursor_position
new_screen.data_buffer[cpos.y][cpos.x] = \
_CHAR_CACHE[data, Token.PartialKeyBinding]