diff --git a/IPython/frontend/qt/console/console_widget.py b/IPython/frontend/qt/console/console_widget.py index 6e1a9d8..f768ac2 100644 --- a/IPython/frontend/qt/console/console_widget.py +++ b/IPython/frontend/qt/console/console_widget.py @@ -441,7 +441,12 @@ class ConsoleWidget(LoggingConfigurable, QtGui.QWidget): def copy(self): """ Copy the currently selected text to the clipboard. """ - self._control.copy() + if self.layout().currentWidget() == self._page_control : + self._page_control.copy() + elif self.layout().currentWidget() == self._control : + self._control.copy() + else : + self.log.debug("console widget: unknown copy target") def cut(self): """ Copy the currently selected text to the clipboard and delete it diff --git a/IPython/frontend/qt/console/frontend_widget.py b/IPython/frontend/qt/console/frontend_widget.py index 15eff37..5d510dd 100644 --- a/IPython/frontend/qt/console/frontend_widget.py +++ b/IPython/frontend/qt/console/frontend_widget.py @@ -174,11 +174,16 @@ class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin): def copy(self): """ Copy the currently selected text to the clipboard, removing prompts. """ - text = self._control.textCursor().selection().toPlainText() - if text: - lines = map(transform_classic_prompt, text.splitlines()) - text = '\n'.join(lines) - QtGui.QApplication.clipboard().setText(text) + if self.layout().currentWidget() == self._page_control : + self._page_control.copy() + elif self.layout().currentWidget() == self._control : + text = self._control.textCursor().selection().toPlainText() + if text: + lines = map(transform_classic_prompt, text.splitlines()) + text = '\n'.join(lines) + QtGui.QApplication.clipboard().setText(text) + else: + self.log.debug("frontend widget : unknown copy target") #--------------------------------------------------------------------------- # 'ConsoleWidget' abstract interface diff --git a/IPython/frontend/qt/console/ipython_widget.py b/IPython/frontend/qt/console/ipython_widget.py index 5147139..1c074b5 100644 --- a/IPython/frontend/qt/console/ipython_widget.py +++ b/IPython/frontend/qt/console/ipython_widget.py @@ -267,11 +267,17 @@ class IPythonWidget(FrontendWidget): """ Copy the currently selected text to the clipboard, removing prompts if possible. """ - text = self._control.textCursor().selection().toPlainText() - if text: - lines = map(transform_ipy_prompt, text.splitlines()) - text = '\n'.join(lines) - QtGui.QApplication.clipboard().setText(text) + if self.layout().currentWidget() == self._page_control : + self._page_control.copy() + elif self.layout().currentWidget() == self._control : + text = self._control.textCursor().selection().toPlainText() + if text: + lines = map(transform_ipy_prompt, text.splitlines()) + text = '\n'.join(lines) + QtGui.QApplication.clipboard().setText(text) + else : + self.log.debug("ipython_widget : unknown copy taget") + #--------------------------------------------------------------------------- # 'FrontendWidget' public interface diff --git a/IPython/frontend/qt/console/mainwindow.py b/IPython/frontend/qt/console/mainwindow.py index 7cf24a7..6563dd7 100644 --- a/IPython/frontend/qt/console/mainwindow.py +++ b/IPython/frontend/qt/console/mainwindow.py @@ -795,8 +795,7 @@ class MainWindow(QtGui.QMainWindow): def copy_active_frontend(self): widget = self.active_frontend - if widget.can_copy(): - widget.copy() + widget.copy() def copy_raw_active_frontend(self): self.active_frontend._copy_raw_action.trigger()