当前位置: 首页>>代码示例>>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;未经允许,请勿转载。