prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Overriding ProgressBar key bindings

Open
#1,034 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

So a progress bar has two sets of keybindings in use. The standard keybindings for "c-l" and "c-c" assigned to _ProgressControl (created by create_key_bindings):

https://github.com/prompt-toolkit/python-prompt-toolkit/blob/5ee9df2417f41d6d374b0a716156141061a8ac8f/prompt_toolkit/shortcuts/progress_bar/base.py#L275-L283

https://github.com/prompt-toolkit/python-prompt-toolkit/blob/5ee9df2417f41d6d374b0a716156141061a8ac8f/prompt_toolkit/shortcuts/progress_bar/base.py#L69-L85

and whatever keybindings the user provides which are passed to the Application.
https://github.com/prompt-toolkit/python-prompt-toolkit/blob/5ee9df2417f41d6d374b0a716156141061a8ac8f/prompt_toolkit/shortcuts/progress_bar/base.py#L187-L205

This means, for example, that I cannot overwrite the "c-c" keybinding. Why are there two 2 sets of key bindings and what would be the correct way to overwrite the bindings?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the progress-bar key-binding setup in prompt_toolkit/shortcuts/progress_bar/base.py, especially the _ProgressControl bindings around lines 69-85 and 275-283 and the Application setup around lines 187-205. Trace how the two binding sets are combined, then establish how user-provided bindings should override the default c-c and c-l bindings. Done means the documented override behavior works without breaking the progress bar controls.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.