##// 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 38 else:
39 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 45 # Pre-populate history from IPython's history database
42 46 history = InMemoryHistory()
43 47 last_cell = u""
@@ -67,9 +71,15 b' class PTInteractiveShell(InteractiveShell):'
67 71
68 72 def interact(self):
69 73 while self.keep_running:
70 document = self.pt_cli.run()
71 if document:
72 self.run_cell(document.text, store_history=True)
74 try:
75 document = self.pt_cli.run()
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 85 if __name__ == '__main__':
General Comments 0
You need to be logged in to leave comments. Login now