Show More
@@ -33,7 +33,7 b' which defines the defaults. The required interface is like this:' | |||
|
33 | 33 | Prompt style definition. *shell* is a reference to the |
|
34 | 34 | :class:`~.TerminalInteractiveShell` instance. |
|
35 | 35 | |
|
36 |
.. method:: in_prompt_tokens( |
|
|
36 | .. method:: in_prompt_tokens() | |
|
37 | 37 | continuation_prompt_tokens(self, width=None) |
|
38 | 38 | rewrite_prompt_tokens() |
|
39 | 39 | out_prompt_tokens() |
@@ -43,8 +43,6 b' which defines the defaults. The required interface is like this:' | |||
|
43 | 43 | For continuation prompts, *width* is an integer representing the width of |
|
44 | 44 | the prompt area in terminal columns. |
|
45 | 45 | |
|
46 | *cli*, where used, is the prompt_toolkit ``CommandLineInterface`` instance. | |
|
47 | This is mainly for compatibility with the API prompt_toolkit expects. | |
|
48 | 46 | |
|
49 | 47 | Here is an example Prompt class that will show the current working directory |
|
50 | 48 | in the input prompt: |
@@ -55,7 +53,7 b' in the input prompt:' | |||
|
55 | 53 | import os |
|
56 | 54 | |
|
57 | 55 | class MyPrompt(Prompts): |
|
58 |
def in_prompt_tokens(self |
|
|
56 | def in_prompt_tokens(self): | |
|
59 | 57 | return [(Token, os.getcwd()), |
|
60 | 58 | (Token.Prompt, ' >>>')] |
|
61 | 59 |
@@ -18,10 +18,11 b' The code in this file is deliberately extra-verbose, meant for learning."""' | |||
|
18 | 18 | # %run example-embed.py) |
|
19 | 19 | |
|
20 | 20 | from IPython.terminal.prompts import Prompts, Token |
|
21 | from traitlets.config.loader import Config | |
|
21 | 22 | |
|
22 | 23 | class CustomPrompt(Prompts): |
|
23 | 24 | |
|
24 |
def in_prompt_tokens(self |
|
|
25 | def in_prompt_tokens(self): | |
|
25 | 26 | |
|
26 | 27 | return [ |
|
27 | 28 | (Token.Prompt, 'In <'), |
@@ -37,7 +38,6 b' class CustomPrompt(Prompts):' | |||
|
37 | 38 | ] |
|
38 | 39 | |
|
39 | 40 | |
|
40 | from traitlets.config.loader import Config | |
|
41 | 41 | try: |
|
42 | 42 | get_ipython |
|
43 | 43 | except NameError: |
@@ -6,9 +6,12 b' import os' | |||
|
6 | 6 | |
|
7 | 7 | class MyPrompt(Prompts): |
|
8 | 8 | |
|
9 |
|
|
|
10 | return [(Token, os.getcwd()), | |
|
11 |
|
|
|
9 | def in_prompt_tokens(self): | |
|
10 | return [ | |
|
11 | (Token, os.getcwd()), | |
|
12 | (Token.Prompt, ">>>") | |
|
13 | ] | |
|
14 | ||
|
12 | 15 | |
|
13 | 16 | def load_ipython_extension(shell): |
|
14 | 17 | new_prompts = MyPrompt(shell) |
@@ -20,7 +23,3 b' def unload_ipython_extension(shell):' | |||
|
20 | 23 | print("cannot unload") |
|
21 | 24 | else: |
|
22 | 25 | shell.prompts = shell.prompts.old_prompts |
|
23 | ||
|
24 | ||
|
25 | ||
|
26 |
General Comments 0
You need to be logged in to leave comments.
Login now