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


Python completion.PathCompleter方法代碼示例

本文整理匯總了Python中prompt_toolkit.completion.PathCompleter方法的典型用法代碼示例。如果您正苦於以下問題:Python completion.PathCompleter方法的具體用法?Python completion.PathCompleter怎麽用?Python completion.PathCompleter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在prompt_toolkit.completion的用法示例。


在下文中一共展示了completion.PathCompleter方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: do_open_file

# 需要導入模塊: from prompt_toolkit import completion [as 別名]
# 或者: from prompt_toolkit.completion import PathCompleter [as 別名]
def do_open_file():
    async def coroutine():
        open_dialog = TextInputDialog(
            title="Open file",
            label_text="Enter the path of a file:",
            completer=PathCompleter(),
        )

        path = await show_dialog_as_float(open_dialog)
        ApplicationState.current_path = path

        if path is not None:
            try:
                with open(path, "rb") as f:
                    text_field.text = f.read().decode("utf-8", errors="ignore")
            except IOError as e:
                show_message("Error", "{}".format(e))

    ensure_future(coroutine()) 
開發者ID:prompt-toolkit,項目名稱:python-prompt-toolkit,代碼行數:21,代碼來源:text-editor.py

示例2: get_path_matches

# 需要導入模塊: from prompt_toolkit import completion [as 別名]
# 或者: from prompt_toolkit.completion import PathCompleter [as 別名]
def get_path_matches(self, _, word_before_cursor):
        completer = PathCompleter(expanduser=True)
        document = Document(
            text=word_before_cursor, cursor_position=len(word_before_cursor)
        )
        for c in completer.get_completions(document, None):
            yield Match(completion=c, priority=(0,)) 
開發者ID:dbcli,項目名稱:pgcli,代碼行數:9,代碼來源:pgcompleter.py

示例3: get_path_matches

# 需要導入模塊: from prompt_toolkit import completion [as 別名]
# 或者: from prompt_toolkit.completion import PathCompleter [as 別名]
def get_path_matches(self, _, word_before_cursor):
        # pylint: disable=no-self-use
        # function cannot be static since it has to be a callable for get_completions
        completer = PathCompleter(expanduser=True)
        document = Document(text=word_before_cursor,
                            cursor_position=len(word_before_cursor))
        for c in completer.get_completions(document, None):
            yield Match(completion=c, priority=(0,)) 
開發者ID:dbcli,項目名稱:mssql-cli,代碼行數:10,代碼來源:mssqlcompleter.py

示例4: create_command_completer

# 需要導入模塊: from prompt_toolkit import completion [as 別名]
# 或者: from prompt_toolkit.completion import PathCompleter [as 別名]
def create_command_completer(editor):
    commands = [c + ' ' for c in get_commands()]

    return GrammarCompleter(COMMAND_GRAMMAR, {
        'command': WordCompleter(commands),
        'location': PathCompleter(expanduser=True),
        'set_option': WordCompleter(sorted(SET_COMMANDS)),
        'buffer_name': BufferNameCompleter(editor),
        'colorscheme': ColorSchemeCompleter(editor),
        'shell_command': SystemCompleter(),
    }) 
開發者ID:prompt-toolkit,項目名稱:pyvim,代碼行數:13,代碼來源:completer.py


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