Closed joguSD closed 8 years ago
Could we get some screenshots?
Visually it should be identical to the standard prompt from prompt_toolkit, and supports most of the same configuration as the args and kwargs are just forwarded along. There are a couple of configurations that the prompt shortcut helper function exposes that I have not included for simplicity.
Slightly more experimental and not being utilized currently is the meta information that would be displayed like this:
How exactly the meta information is rendered is something we need to discuss, but this type of interaction is required for an Info Select interaction.
Awesome job! No big issues, just a lot of wording and a few clarifications.
I realized that there was a potential bug in the select menu when there are multiple options that are the same string. Previously I was using a dict to map options to their complete object, and the select menu prompt would simply return the string that was the selection so that the interaction could use it as a key and get the real object from the dict. However, this has conflicts if the string is the same for two options as they would return the same thing (one of the objects would get overwritten in the dict). I've refactored some things so that the options_meta
is a parallel list to the list of options, and the select menu prompt will now return the tuple (selection, index)
so that even in the case of duplicate options the correct resolution can be made. I also added an integration test to verify this functionality.
___________________________________________________________________
|| * * (( * ||
|| * * * ~ ||
|| ___. * * ||
|| * ___.\__|.__. * ||
|| \__|. .| \_|. ||
|| . X|___|___| . * ||
|| .__/_||____ ||__. * /\ ||
|| * . |/|____ |_\|_ |/ _ / \ ||
|| \ _/ |_X__\|_ |\||~,~{ / \ ||
|| \/\ |/| |_ |/:|`X'{ _ _/ \__||
|| \ \/ |___ |_\|_.|~~~ / . .. . ..||
|| _|X/\ |___\|_ :| |_. - .......... . .||
|| | __\_:____ | ||o-| ___/........ . . .. ..||
|| |/_-|-_|__ \|_ |/--| ____/ . . .. . . .. ... . ||
|| ........:| -|- o-o\_:_\|o-/:....../...........................||
|| ._._._._._\=\====o==o==o=/:.._._._._._._._._._._._._._._._._._||
|| _._._._._._\_\ ._._._._.:._._._._._._._._._._._._._.P_._._._._||
|| ._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._||
||---------------------------------------------------------------||
An implementation of a selection menu using prompt toolkit. This is very similar to the original prompt provided by prompt toolkit but has a few tweaks that are not possible through the parameters exposed by the library itself. Selecting an option from a set of options is a different enough use case that the following features were required: forcing the selection of one of the options, not allowing the editing of options once selected, and showing the prompt without any input from the user. Additionally, it allows me to modify the layout to begin adding a meta information window similar to the shell's docs.
@JordonPhillips @kyleknap @jamesls