Skip to content

qtconsole : allow copy with shortcut in pager #1091

Closed
wants to merge 4 commits into from

2 participants

@Carreau
IPython member
Carreau commented Dec 3, 2011

closes #1088

Carreau added some commits Dec 3, 2011
@Carreau
IPython member
Carreau commented Dec 3, 2011

I also added a little fix that avoid some error message when trying qtconsole with --pure as there won't be user_expressionin message comming from the kernel.

Actually I suspect that some of the gui menu of qtconsole might be broken with --pure

@Carreau Carreau shorten 32dd9b5 logic for one file 40533f7
@Carreau
IPython member
Carreau commented Dec 3, 2011

note that we might want to add a warning in the docstring of
console/console_widget.py: def can_copy(self):
Or change the implementation to check wether or not it returns true if selected text is in the pager...

Which way you think is the best ?

@minrk
IPython member
minrk commented Dec 4, 2011

@Carreau - you are right, there are probably quite a few things broken in pure mode. I wish we would remove it, because nobody ever tests it, and there are huge amounts of duplicate code that typically are not updated in tandem with every change.

@minrk minrk commented on the diff Dec 4, 2011
IPython/frontend/qt/console/ipython_widget.py
@@ -267,11 +267,17 @@ def copy(self):
""" 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)
@minrk
IPython member
minrk added a note Dec 4, 2011

Let's make 'transform_prompt` a widget trait (should be transform_classic_prompt in FrontendWidget, and transform_ipy_prompt in IPythonWidget), then we shouldn't have to override copy() in IPythonWidget at all.

@Carreau
IPython member
Carreau added a note Dec 5, 2011

I'm not quite comfortable with trait , I can give a shot, bu you'll probably be done before I read enough to do it the right way.

@minrk
IPython member
minrk added a note Dec 5, 2011

Sorry, it can just be a class attribute. The traitness is unimportant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@minrk
IPython member
minrk commented Dec 6, 2011

When doing ipython qtconsole --pylab --paging vsplit, and do plot?, I cannot actually copy anything out of the pager area. So it would appear that this does not do what it claims, unless I am mistaken.

@Carreau
IPython member
Carreau commented Dec 6, 2011

hum... I didn't thought of vsplit. I'll take a look.

@Carreau Carreau copy pager also hsplit, vsplit
	check which of the two widget have focus to know from which to copy
594f294
@Carreau
IPython member
Carreau commented Dec 7, 2011

@minrk,
this seem to work with hsplit/vsplit and without splitter

@minrk minrk added a commit that referenced this pull request Dec 7, 2011
@minrk minrk Merge PR #1091 (qtconsole pager copy)
closes #1088
closes #1091
7a144e2
@minrk minrk added a commit that closed this pull request Dec 7, 2011
@minrk minrk Merge PR #1091 (qtconsole pager copy)
closes #1088
closes #1091
7a144e2
@minrk minrk closed this in 7a144e2 Dec 7, 2011
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
@minrk minrk Merge PR #1091 (qtconsole pager copy)
closes #1088
closes #1091
5ce2c2f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.