Skip to content
Browse files

add copy_raw, interrupt kernel and restart kernel into menu

  • Loading branch information...
1 parent ef6e68c commit 3d888bb6554e52aa9ee8e670ec74ca2650804f72 @Carreau Carreau committed with fperez Oct 15, 2011
Showing with 40 additions and 3 deletions.
  1. +10 −3 IPython/frontend/qt/console/frontend_widget.py
  2. +30 −0 IPython/frontend/qt/console/qtconsoleapp.py
View
13 IPython/frontend/qt/console/frontend_widget.py
@@ -241,19 +241,26 @@ def _context_menu_make(self, pos):
break
return menu
+ def request_interrupt_kernel(self):
+ if self._executing:
+ self.interrupt_kernel()
+
+ def request_restart_kernel(self):
+ message = 'Are you sure you want to restart the kernel?'
+ self.restart_kernel(message, now=False)
+
def _event_filter_console_keypress(self, event):
""" Reimplemented for execution interruption and smart backspace.
"""
key = event.key()
if self._control_key_down(event.modifiers(), include_command=False):
if key == QtCore.Qt.Key_C and self._executing:
- self.interrupt_kernel()
+ self.request_interrupt_kernel()
return True
elif key == QtCore.Qt.Key_Period:
- message = 'Are you sure you want to restart the kernel?'
- self.restart_kernel(message, now=False)
+ self.request_restart_kernel()
return True
elif not event.modifiers() & QtCore.Qt.AltModifier:
View
30 IPython/frontend/qt/console/qtconsoleapp.py
@@ -373,6 +373,13 @@ def init_menu_bar(self):
)
self.edit_menu.addAction(self.copy_action)
+ self.copy_raw_action = QtGui.QAction("Copy (&Raw Text)",
+ self,
+ shortcut="Ctrl+Shift+C",
+ triggered=self.copy_raw_active_frontend
+ )
+ self.edit_menu.addAction(self.copy_raw_action)
+
self.cut_action = QtGui.QAction("&Cut",
self,
shortcut=QtGui.QKeySequence.Cut,
@@ -483,6 +490,20 @@ def init_menu_bar(self):
)
self.help_menu.addAction(self.quickref_active_frontend_action)
+ self.interrupt_kernel_action = QtGui.QAction("Interrupt current Kernel",
+ self,
+ triggered=self.interrupt_kernel_active_frontend
+ )
+ self.kernel_menu.addAction(self.interrupt_kernel_action)
+
+ self.restart_kernel_action = QtGui.QAction("Restart current Kernel",
+ self,
+ triggered=self.restart_kernel_active_frontend
+ )
+ self.kernel_menu.addAction(self.restart_kernel_action)
+ self.kernel_menu.addSeparator()
+
+ #for now this is just a copy and paste, but we should get this dynamically
magiclist=["%alias", "%autocall", "%automagic", "%bookmark", "%cd", "%clear",
"%colors", "%debug", "%dhist", "%dirs", "%doctest_mode", "%ed", "%edit", "%env", "%gui",
"%guiref", "%hist", "%history", "%install_default_config", "%install_profiles",
@@ -507,12 +528,21 @@ def inner_dynamic_magic():
)
self.all_magic_menu.addAction(xaction)
+ def restart_kernel_active_frontend(self):
+ self.active_frontend.request_restart_kernel()
+
+ def interrupt_kernel_active_frontend(self):
+ self.active_frontend.request_interrupt_kernel()
+
def cut_active_frontend(self):
self.active_frontend.cut_action.trigger()
def copy_active_frontend(self):
self.active_frontend.copy_action.trigger()
+ def copy_raw_active_frontend(self):
+ self.active_frontend._copy_raw_action.trigger()
+
def paste_active_frontend(self):
self.active_frontend.paste_action.trigger()

0 comments on commit 3d888bb

Please sign in to comment.
Something went wrong with that request. Please try again.