prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.28k stars 715 forks source link

pt 2.0: `Prompt` object is very different to be subclassed #545

Open randy3k opened 7 years ago

randy3k commented 7 years ago

At the 2.0 branch, I found that the Prompt is very difficult to be subclassed because the whole app and layout are computed in one big function _create_application. It would be nice to dissect this function into smaller pieces to allow more customizability. For instance, I really want to customize the layout in some way, but it is currently quite impossible.

jonathanslenders commented 7 years ago

Good point. I'll see what I can do.

asmeurer commented 7 years ago

_create_application creates a bunch of objects. I think it would be better to have a _create_... for each object. In other words, _create_application should only create the Application (https://github.com/randy3k/Rice/blob/62e6518e248b3d9ba90c6da468b9a438ef8efc5c/rice/deps/prompt_toolkit/shortcuts/prompt.py#L468), and call other methods (or take in arguments) to create the other objects, like _create_layout, _create_buffer, and so on.