diff options
author | Jonathan Slenders <jonathan@slenders.be> | 2018-05-25 00:11:57 +0200 |
---|---|---|
committer | Jonathan Slenders <jonathan@slenders.be> | 2018-05-25 00:11:57 +0200 |
commit | 22ec3413b141462cb257c2232661cb1e1b274a39 (patch) | |
tree | ada3594a4320ff2ac2a3084e7cb30a23e4081e20 | |
parent | 70bb2310f1d18b4224db79a5d761a79eab04453e (diff) |
Added screenshot for colored prompt to docs.
-rw-r--r-- | docs/images/colored-prompt.png | bin | 0 -> 94994 bytes | |||
-rw-r--r-- | docs/pages/asking_for_input.rst | 16 |
2 files changed, 10 insertions, 6 deletions
diff --git a/docs/images/colored-prompt.png b/docs/images/colored-prompt.png Binary files differnew file mode 100644 index 00000000..bd859751 --- /dev/null +++ b/docs/images/colored-prompt.png diff --git a/docs/pages/asking_for_input.rst b/docs/pages/asking_for_input.rst index b1dcdd72..c47a9d5a 100644 --- a/docs/pages/asking_for_input.rst +++ b/docs/pages/asking_for_input.rst @@ -196,7 +196,9 @@ Coloring the prompt itself ^^^^^^^^^^^^^^^^^^^^^^^^^^ It is possible to add some colors to the prompt itself. For this, we need to -build some :ref:`formatted text <formatted_text>`. +build some :ref:`formatted text <formatted_text>`. One way of doing is is by +creating a list of style/text tuples. In the following example, we use class +names to refer to the style. .. code:: python @@ -204,16 +206,16 @@ build some :ref:`formatted text <formatted_text>`. from prompt_toolkit.styles import Style style = Style.from_dict({ - # User input. + # User input (default text). '': '#ff0066', # Prompt. 'username': '#884444', 'at': '#00aa00', - 'colon': '#00aa00', + 'colon': '#0000aa', 'pound': '#00aa00', - 'host': '#000088 bg:#aaaaff', - 'path': '#884444 underline', + 'host': '#00ffff bg:#444400', + 'path': 'ansicyan underline', }) message = [ @@ -227,6 +229,8 @@ build some :ref:`formatted text <formatted_text>`. text = prompt(message, style=style) +.. image:: ../images/colored-prompt.png + The `message` can be any kind of formatted text, as discussed :ref:`here <formatted_text>`. It can also be a callable that returns some formatted text. @@ -236,7 +240,7 @@ the :func:`~prompt_toolkit.shortcuts.prompt.prompt` function. .. code:: python - text = prompt(get_prompt, style=style, true_color=True) + text = prompt(message, style=style, true_color=True) Autocompletion |