##// END OF EJS Templates
remove duplicate function "pasteMagic", and change code not to use it
Matthias BUSSONNIER -
Show More
@@ -602,14 +602,12 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):'
602
602
603 font = property(_get_font, _set_font)
603 font = property(_get_font, _set_font)
604
604
605 def paste(self, mode=QtGui.QClipboard.Clipboard,text=None):
605 def paste(self, mode=QtGui.QClipboard.Clipboard):
606 """ Paste the contents of the clipboard, or given text,
606 """ Paste the contents of the clipboard into the input region.
607 into the input region.
608
607
609 Parameters:
608 Parameters:
610 -----------
609 -----------
611 mode : QClipboard::Mode, optional [default QClipboard::Clipboard]
610 mode : QClipboard::Mode, optional [default QClipboard::Clipboard]
612 text : string, optional, overide mode if given.
613
611
614 Controls which part of the system clipboard is used. This can be
612 Controls which part of the system clipboard is used. This can be
615 used to access the selection clipboard in X11 and the Find buffer
613 used to access the selection clipboard in X11 and the Find buffer
@@ -626,29 +624,6 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):'
626 text = QtGui.QApplication.clipboard().text(mode).rstrip()
624 text = QtGui.QApplication.clipboard().text(mode).rstrip()
627 self._insert_plain_text_into_buffer(cursor, dedent(text))
625 self._insert_plain_text_into_buffer(cursor, dedent(text))
628
626
629 def pasteMagic(self,text):
630 self._keyboard_quit()
631 self.paste(text=text)
632 self.execute()
633
634 def exit_magic(self):
635 self.pasteMagic("%exit")
636
637 def who_magic(self):
638 self.pasteMagic("%who")
639
640 def whos_magic(self):
641 self.pasteMagic("%whos")
642
643 def who_ls_magic(self):
644 self.pasteMagic("%who_ls")
645
646 def clear_magic(self):
647 self.pasteMagic("%clear")
648
649 def reset_magic(self):
650 self.pasteMagic("%reset")
651
652 def print_(self, printer = None):
627 def print_(self, printer = None):
653 """ Print the contents of the ConsoleWidget to the specified QPrinter.
628 """ Print the contents of the ConsoleWidget to the specified QPrinter.
654 """
629 """
@@ -205,7 +205,7 b' class HistoryConsoleWidget(ConsoleWidget):'
205 return self._history[-n:]
205 return self._history[-n:]
206
206
207 def history_magic(self):
207 def history_magic(self):
208 self.pasteMagic("%history")
208 self.execute("%history")
209
209
210 def _request_update_session_history_length(self):
210 def _request_update_session_history_length(self):
211 msg_id = self.kernel_manager.shell_channel.execute('',
211 msg_id = self.kernel_manager.shell_channel.execute('',
@@ -246,7 +246,7 b' class HistoryConsoleWidget(ConsoleWidget):'
246 text=str('1-'+str(self._max_session_history))
246 text=str('1-'+str(self._max_session_history))
247 )
247 )
248 if ok:
248 if ok:
249 self.pasteMagic("%save"+" "+file_name+" "+str(hist_range))
249 self.execute("%save"+" "+file_name+" "+str(hist_range))
250
250
251 #---------------------------------------------------------------------------
251 #---------------------------------------------------------------------------
252 # 'HistoryConsoleWidget' protected interface
252 # 'HistoryConsoleWidget' protected interface
@@ -156,7 +156,7 b' class MainWindow(QtGui.QMainWindow):'
156 tab._hidden = True
156 tab._hidden = True
157 if closing_widget in slaveTabs :
157 if closing_widget in slaveTabs :
158 try :
158 try :
159 self.findMasterTab(closing_widget).pasteMagic('exit')
159 self.findMasterTab(closing_widget).execute('exit')
160 except AttributeError:
160 except AttributeError:
161 self.log.info("Master already closed or not local, closing only current tab")
161 self.log.info("Master already closed or not local, closing only current tab")
162 self.tabWidget.removeTab(currentTab)
162 self.tabWidget.removeTab(currentTab)
@@ -196,13 +196,13 b' class MainWindow(QtGui.QMainWindow):'
196 if reply == 1: # close All
196 if reply == 1: # close All
197 for slave in slaveTabs:
197 for slave in slaveTabs:
198 self.tabWidget.removeTab(self.tabWidget.indexOf(slave))
198 self.tabWidget.removeTab(self.tabWidget.indexOf(slave))
199 closing_widget.pasteMagic("exit")
199 closing_widget.execute("exit")
200 self.tabWidget.removeTab(currentTab)
200 self.tabWidget.removeTab(currentTab)
201 elif reply == 0: # close Console
201 elif reply == 0: # close Console
202 if not closing_widget._existing:
202 if not closing_widget._existing:
203 # Have kernel: don't quit, just close the window
203 # Have kernel: don't quit, just close the window
204 self._app.setQuitOnLastWindowClosed(False)
204 self._app.setQuitOnLastWindowClosed(False)
205 closing_widget.pasteMagic("exit True")
205 closing_widget.execute("exit True")
206 else:
206 else:
207 reply = QtGui.QMessageBox.question(self, title,
207 reply = QtGui.QMessageBox.question(self, title,
208 "Are you sure you want to close this Console?"+
208 "Are you sure you want to close this Console?"+
@@ -491,19 +491,19 b' class MainWindow(QtGui.QMainWindow):'
491 def redo_active_frontend(self):
491 def redo_active_frontend(self):
492 self.activeFrontend.redo()
492 self.activeFrontend.redo()
493 def reset_magic_active_frontend(self):
493 def reset_magic_active_frontend(self):
494 self.activeFrontend.reset_magic()
494 self.activeFrontend.execute("%reset")
495 def history_magic_active_frontend(self):
495 def history_magic_active_frontend(self):
496 self.activeFrontend.history_magic()
496 self.activeFrontend.history_magic()
497 def save_magic_active_frontend(self):
497 def save_magic_active_frontend(self):
498 self.activeFrontend.save_magic()
498 self.activeFrontend.save_magic()
499 def clear_magic_active_frontend(self):
499 def clear_magic_active_frontend(self):
500 self.activeFrontend.clear_magic()
500 self.activeFrontend.execute("%clear")
501 def who_magic_active_frontend(self):
501 def who_magic_active_frontend(self):
502 self.activeFrontend.who_magic()
502 self.activeFrontend.execute("%who")
503 def who_ls_magic_active_frontend(self):
503 def who_ls_magic_active_frontend(self):
504 self.activeFrontend.who_ls_magic()
504 self.activeFrontend.execute("%who_ls")
505 def whos_magic_active_frontend(self):
505 def whos_magic_active_frontend(self):
506 self.activeFrontend.whos_magic()
506 self.activeFrontend.execute("%whos")
507
507
508 def print_action_active_frontend(self):
508 def print_action_active_frontend(self):
509 self.activeFrontend.print_action.trigger()
509 self.activeFrontend.print_action.trigger()
General Comments 0
You need to be logged in to leave comments. Login now