##// END OF EJS Templates
add Widget._transform_prompt staticmethod...
MinRK -
Show More
@@ -107,6 +107,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
107 exit_requested = QtCore.Signal(object)
107 exit_requested = QtCore.Signal(object)
108
108
109 # Protected class variables.
109 # Protected class variables.
110 _transform_prompt = staticmethod(transform_classic_prompt)
110 _CallTipRequest = namedtuple('_CallTipRequest', ['id', 'pos'])
111 _CallTipRequest = namedtuple('_CallTipRequest', ['id', 'pos'])
111 _CompletionRequest = namedtuple('_CompletionRequest', ['id', 'pos'])
112 _CompletionRequest = namedtuple('_CompletionRequest', ['id', 'pos'])
112 _ExecutionRequest = namedtuple('_ExecutionRequest', ['id', 'kind'])
113 _ExecutionRequest = namedtuple('_ExecutionRequest', ['id', 'kind'])
@@ -174,12 +175,12 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
174 def copy(self):
175 def copy(self):
175 """ Copy the currently selected text to the clipboard, removing prompts.
176 """ Copy the currently selected text to the clipboard, removing prompts.
176 """
177 """
177 if self.layout().currentWidget() == self._page_control :
178 if self._page_control.hasFocus():
178 self._page_control.copy()
179 self._page_control.copy()
179 elif self.layout().currentWidget() == self._control :
180 elif self._control.hasFocus():
180 text = self._control.textCursor().selection().toPlainText()
181 text = self._control.textCursor().selection().toPlainText()
181 if text:
182 if text:
182 lines = map(transform_classic_prompt, text.splitlines())
183 lines = map(self._transform_prompt, text.splitlines())
183 text = '\n'.join(lines)
184 text = '\n'.join(lines)
184 QtGui.QApplication.clipboard().setText(text)
185 QtGui.QApplication.clipboard().setText(text)
185 else:
186 else:
@@ -98,6 +98,7 b' class IPythonWidget(FrontendWidget):'
98
98
99 # FrontendWidget protected class variables.
99 # FrontendWidget protected class variables.
100 _input_splitter_class = IPythonInputSplitter
100 _input_splitter_class = IPythonInputSplitter
101 _transform_prompt = staticmethod(transform_ipy_prompt)
101
102
102 # IPythonWidget protected class variables.
103 # IPythonWidget protected class variables.
103 _PromptBlock = namedtuple('_PromptBlock', ['block', 'length', 'number'])
104 _PromptBlock = namedtuple('_PromptBlock', ['block', 'length', 'number'])
@@ -263,22 +264,6 b' class IPythonWidget(FrontendWidget):'
263 # 'ConsoleWidget' public interface
264 # 'ConsoleWidget' public interface
264 #---------------------------------------------------------------------------
265 #---------------------------------------------------------------------------
265
266
266 def copy(self):
267 """ Copy the currently selected text to the clipboard, removing prompts
268 if possible.
269 """
270 if self._page_control.hasFocus() :
271 self._page_control.copy()
272 elif self._control.hasFocus() :
273 text = self._control.textCursor().selection().toPlainText()
274 if text:
275 lines = map(transform_ipy_prompt, text.splitlines())
276 text = '\n'.join(lines)
277 QtGui.QApplication.clipboard().setText(text)
278 else :
279 self.log.debug("ipython_widget : unknown copy taget")
280
281
282 #---------------------------------------------------------------------------
267 #---------------------------------------------------------------------------
283 # 'FrontendWidget' public interface
268 # 'FrontendWidget' public interface
284 #---------------------------------------------------------------------------
269 #---------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now