Skip to content

Refresh prompt from custom key binding  #788

@ibeex

Description

@ibeex

I am trying to oweride ctrl+d with custom command, calling command works but after presing c-d prompt and bottom toolbar are same. (commands.exit() changes prompt and bottom toolbar but) They change only if I pres enter, how can I redraw prompt and bottom toolbar from custom binding?

here is example code

def shell():
    """Repl shell"""
    print("Welcome")
    prompt = PromptSession(
        history=FileHistory(os.path.join(os.path.expanduser("~"), ".history.txt"))
    )
    commands = Commands()
    bindings = KeyBindings()

    @bindings.add("c-d")
    def _(event):
        def print_exit():
            print(commands.exit())

        run_in_terminal(print_exit)

    while True:
        try:
            user_input = prompt.prompt(
                commands.prompt,
                auto_suggest=AutoSuggestFromHistory(),
                enable_history_search=True,
                key_bindings=bindings,
                bottom_toolbar=commands.bottom,
            )
            if not user_input:
                continue
            except (EOFError, KeyboardInterrupt):
                break

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions