##// END OF EJS Templates
Add Ctrl-Z shortcut (suspend) in terminal debugger...
Thomas Kluyver -
Show More
@@ -1,13 +1,19 b''
1 import signal
2 import sys
3
1 from IPython.core.debugger import Pdb
4 from IPython.core.debugger import Pdb
2
5
3 from IPython.core.completer import IPCompleter
6 from IPython.core.completer import IPCompleter
4 from .ptutils import IPythonPTCompleter
7 from .ptutils import IPythonPTCompleter
8 from .shortcuts import suspend_to_bg
5
9
10 from prompt_toolkit.filters import Condition
11 from prompt_toolkit.keys import Keys
12 from prompt_toolkit.key_binding.manager import KeyBindingManager
6 from prompt_toolkit.token import Token
13 from prompt_toolkit.token import Token
7 from prompt_toolkit.shortcuts import create_prompt_application
14 from prompt_toolkit.shortcuts import create_prompt_application
8 from prompt_toolkit.interface import CommandLineInterface
15 from prompt_toolkit.interface import CommandLineInterface
9 from prompt_toolkit.enums import EditingMode
16 from prompt_toolkit.enums import EditingMode
10 import sys
11
17
12
18
13 class TerminalPdb(Pdb):
19 class TerminalPdb(Pdb):
@@ -31,8 +37,14 b' class TerminalPdb(Pdb):'
31 )
37 )
32 self._ptcomp = IPythonPTCompleter(compl, patch_stdout=patch_stdout)
38 self._ptcomp = IPythonPTCompleter(compl, patch_stdout=patch_stdout)
33
39
40 kbmanager = KeyBindingManager.for_prompt()
41 supports_suspend = Condition(lambda cli: hasattr(signal, 'SIGTSTP'))
42 kbmanager.registry.add_binding(Keys.ControlZ, filter=supports_suspend
43 )(suspend_to_bg)
44
34 self._pt_app = create_prompt_application(
45 self._pt_app = create_prompt_application(
35 editing_mode=getattr(EditingMode, self.shell.editing_mode.upper()),
46 editing_mode=getattr(EditingMode, self.shell.editing_mode.upper()),
47 key_bindings_registry=kbmanager.registry,
36 history=self.shell.debugger_history,
48 history=self.shell.debugger_history,
37 completer= self._ptcomp,
49 completer= self._ptcomp,
38 enable_history_search=True,
50 enable_history_search=True,
General Comments 0
You need to be logged in to leave comments. Login now