Show More
@@ -1,18 +1,22 | |||
|
1 | 1 | import asyncio |
|
2 | import os | |
|
2 | 3 | import sys |
|
3 | 4 | import threading |
|
4 | 5 | |
|
5 | 6 | from IPython.core.debugger import Pdb |
|
6 | 7 | |
|
8 | ||
|
7 | 9 | from IPython.core.completer import IPCompleter |
|
8 | 10 | from .ptutils import IPythonPTCompleter |
|
9 | 11 | from .shortcuts import create_ipython_shortcuts |
|
10 | 12 | from . import embed |
|
11 | 13 | |
|
14 | from pathlib import Path | |
|
12 | 15 | from pygments.token import Token |
|
13 | 16 | from prompt_toolkit.shortcuts.prompt import PromptSession |
|
14 | 17 | from prompt_toolkit.enums import EditingMode |
|
15 | 18 | from prompt_toolkit.formatted_text import PygmentsTokens |
|
19 | from prompt_toolkit.history import InMemoryHistory, FileHistory | |
|
16 | 20 | |
|
17 | 21 | from prompt_toolkit import __version__ as ptk_version |
|
18 | 22 | PTK3 = ptk_version.startswith('3.') |
@@ -55,6 +59,17 class TerminalPdb(Pdb): | |||
|
55 | 59 | |
|
56 | 60 | self._ptcomp = IPythonPTCompleter(compl) |
|
57 | 61 | |
|
62 | # setup history only when we start pdb | |
|
63 | if self.shell.debugger_history is None: | |
|
64 | if self.shell.debugger_history_file is not None: | |
|
65 | ||
|
66 | p = Path(self.shell.debugger_history_file).expanduser() | |
|
67 | if not p.exists(): | |
|
68 | p.touch() | |
|
69 | self.debugger_history = FileHistory(os.path.expanduser(str(p))) | |
|
70 | else: | |
|
71 | self.debugger_history = InMemoryHistory() | |
|
72 | ||
|
58 | 73 | options = dict( |
|
59 | 74 | message=(lambda: PygmentsTokens(get_prompt_tokens())), |
|
60 | 75 | editing_mode=getattr(EditingMode, self.shell.editing_mode.upper()), |
@@ -124,6 +124,10 class TerminalInteractiveShell(InteractiveShell): | |||
|
124 | 124 | pt_app = None |
|
125 | 125 | debugger_history = None |
|
126 | 126 | |
|
127 | debugger_history_file = Unicode( | |
|
128 | "~/.pdbhistory", help="File in which to store and read history" | |
|
129 | ).tag(config=True) | |
|
130 | ||
|
127 | 131 | simple_prompt = Bool(_use_simple_prompt, |
|
128 | 132 | help="""Use `raw_input` for the REPL, without completion and prompt colors. |
|
129 | 133 | |
@@ -566,7 +570,6 class TerminalInteractiveShell(InteractiveShell): | |||
|
566 | 570 | self.init_term_title() |
|
567 | 571 | self.keep_running = True |
|
568 | 572 | |
|
569 | self.debugger_history = InMemoryHistory() | |
|
570 | 573 | |
|
571 | 574 | def ask_exit(self): |
|
572 | 575 | self.keep_running = False |
General Comments 0
You need to be logged in to leave comments.
Login now