You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/prompt.rst
+23-24
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,7 @@ This can be accomplished with the :func:`prompt` function, which asks for
11
11
valid input according to a type, or the :class:`quo.prompt.Prompt` object, this makes it possible to create a Prompt instance followed by calling prompt() method for every input. This creates a kind of an input session and its packed with lots of features.
12
12
You can also use the :func:`quo.confirm` function, which asks for confirmation (yes/no).
13
13
14
-
The following snippet uses the :func:`quo.prompt` function to ask the user for input
15
-
and returns the text. Just like ``input``.
14
+
The following snippet uses the :func:`quo.prompt` function to ask the user for input just like ``input``.
16
15
17
16
.. code:: python
18
17
@@ -393,16 +392,16 @@ A simple way to add color to create a style, is by using the :meth:`~quo.style.S
393
392
Coloring the prompt itself
394
393
^^^^^^^^^^^^^^^^^^^^^^^^^^
395
394
396
-
It is possible to add some colors to the prompt itself. For this, we need to
397
-
build some :ref:`formatted text <formatted_text>`. One way of doing this is by
398
-
creating a list of style/text tuples. In the following example, the input will be in red
395
+
It is possible to add some colors to the prompt itself. For this, we need to import :func:`quo.color.Color` function.
396
+
In the following example, the input will be in red
style = Style.add({'':'fg:blue'}) # User input (default text)
420
+
style = Color("fg:blue") # User input (default text)
421
+
422
422
session = Prompt(style=style)
423
423
424
424
message = [
@@ -553,37 +553,37 @@ otherwise. So, make sure to disable history search for this.
553
553
554
554
A :class:`~quo.history.History` object keeps track of all the previously entered strings, so that the up-arrow can reveal previously entered items.
555
555
556
-
InMemoryHistory
557
-
^^^^^^^^^^^^^^^^^^^^
558
-
The recommended way is to use a :class:`~quo.prompt.Prompt`, which uses an :class:`~quo.history.InMemoryHistory` which has `^` (up) arrow partial string matching enabled by default.
556
+
MemoryHistory
557
+
^^^^^^^^^^^^^^^^^
558
+
The recommended way is to use a :class:`~quo.prompt.Prompt`, which uses an :class:`~quo.history.MemoryHistory` which has `^` (up) arrow partial string matching enabled by default.
559
559
560
560
.. code:: python
561
561
562
+
from quo.history import MemoryHistory
562
563
from quo.prompt import Prompt
563
-
from quo.history import InMemoryHistory
564
564
565
-
history = InMemoryHistory()
566
-
history.append("import os")
567
-
history.append('print("hello")')
568
-
history.append('print("world")')
569
-
history.append("import path")
565
+
MemoryHistory.append("import os")
566
+
MemoryHistory.append('print("hello")')
567
+
MemoryHistory.append('print("world")')
568
+
MemoryHistory.append("import path")
570
569
571
-
session = Prompt(history=history)
570
+
session = Prompt(history=MemoryHistory)
572
571
573
572
whileTrue:
574
573
session.prompt()
575
574
576
575
FileHistory
577
576
^^^^^^^^^^^^^^^^
578
-
To persist a history to disk, use a :class:`~quo.history.FileHistory` instead of the default :class:`~quo.history.InMemoryHistory`. This history object can be passed to a :class:`~quo.prompt.Prompt`.
577
+
To persist a history to disk, use a :class:`~quo.history.FileHistory` instead of the default :class:`~quo.history.MemoryHistory`. This history object can be passed to a :class:`~quo.prompt.Prompt`.
0 commit comments