當前位置: 首頁>>代碼示例>>Python>>正文


Python Token.PartialKeyBinding方法代碼示例

本文整理匯總了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] 
開發者ID:chrisjim316,項目名稱:Liljimbo-Chatbot,代碼行數:22,代碼來源:containers.py


注:本文中的prompt_toolkit.token.Token.PartialKeyBinding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。