##// END OF EJS Templates
Do sensible things on Ctrl-C and Ctrl-D
Thomas Kluyver -
Show More
@@ -38,6 +38,10 b' class PTInteractiveShell(InteractiveShell):'
38 else:
38 else:
39 b.insert_text('\n' + (' ' * (indent or 0)))
39 b.insert_text('\n' + (' ' * (indent or 0)))
40
40
41 @kbmanager.registry.add_binding(Keys.ControlC)
42 def _(event):
43 event.current_buffer.reset()
44
41 # Pre-populate history from IPython's history database
45 # Pre-populate history from IPython's history database
42 history = InMemoryHistory()
46 history = InMemoryHistory()
43 last_cell = u""
47 last_cell = u""
@@ -67,9 +71,15 b' class PTInteractiveShell(InteractiveShell):'
67
71
68 def interact(self):
72 def interact(self):
69 while self.keep_running:
73 while self.keep_running:
70 document = self.pt_cli.run()
74 try:
71 if document:
75 document = self.pt_cli.run()
72 self.run_cell(document.text, store_history=True)
76 except EOFError:
77 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
78 self.ask_exit()
79
80 else:
81 if document:
82 self.run_cell(document.text, store_history=True)
73
83
74
84
75 if __name__ == '__main__':
85 if __name__ == '__main__':
General Comments 0
You need to be logged in to leave comments. Login now