Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: qtconsole -- non-standard handling of \a and \b. [Fixes #1561] #1569

Merged
merged 2 commits into from Apr 14, 2012
Merged

BUG: qtconsole -- non-standard handling of \a and \b. [Fixes #1561] #1569

merged 2 commits into from Apr 14, 2012

Conversation

punchagan
Copy link
Contributor

Fixes #1561 and adds many tests

@jdmarch
Copy link

jdmarch commented Apr 11, 2012

This PR also fixes an invisible bug in #1089 -- the actions list was not cleared after processing bell and carriage return, which caused these to be processed twice. This was inconsequential (beep+beep sounds like beep, return+return looks like return), but not so for backspace. The former tests did not catch this because they only tested one element of the actions list; this PR also corrects and expands those tests.

@jdmarch
Copy link

jdmarch commented Apr 11, 2012

This PR makes handling of \a and \b compatible [EDIT: almost compatible, see below] with IPython terminal. However it could cause problems for any users who rely on the non-standard behavior implemented in #1089. Any concerns, @mdboom or @epatters ?

@jdmarch
Copy link

jdmarch commented Apr 11, 2012

Actually in an odd corner case, backspace handling in this PR is still not compatible with terminal.
Terminal: In [7]: print 'xyz\b\b=' x=z
This PR: In [1]: print 'xyz\b\b=' x=
Apparently the terminal metaphor is that the backspace character moves the print position backwards but does not delete any characters. I'm not sure that this is optimal but it probably doesn't matter and may be set in stone by now, so I would think that qtconsole should simply follow suite.

EDIT: replacing spaces with "=" for clarity.

def test_combined(self):
""" Are return and backspace characters processed correctly in combination?
"""
string = 'abc\rdef\b' # CR and backspace
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment should explain that for compatibility with IPython terminal, a BS at EOL is effectively ignored because it is treated as a change in print position rather than a backwards character deletion.

@mdboom
Copy link
Contributor

mdboom commented Apr 11, 2012

My stuff doesn't appear to rely on the broken functionality (it works just as well with this PR), so +1.

@punchagan
Copy link
Contributor Author

@jdmarch Thanks for reviewing and testing the patch, and the elaborate comments! I force pushed a change, to handle the corner case you pointed out.

@jdmarch
Copy link

jdmarch commented Apr 13, 2012

This looks good now, thanks! Tests are much stronger. The new module to test actual output can provide a basis for other such tests in the future.

This is admittedly very 20th Century but still useful for some beginner training in escape sequences, and terminal progress bars. OK to merge?

groups = filter(lambda x: x is not None, match.groups())
if groups[0] == '\r':
if groups[0] == '\a':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: since groups[0] is now used multiple times for this dispatch, it might be a good idea to create a local g0 = groups[0] and do the whole if/elif/elif... dispatch on g0 instead, to avoid the cost of multiple lookups on the groups object...

@punchagan
Copy link
Contributor Author

@fperez -- Thanks for the comments. Fixed the issues and pushed changes.

@fperez
Copy link
Member

fperez commented Apr 14, 2012

Great, these changes look good now. I concur with @jdmarch that it's best to have \b match the pure terminal behavior: if nothing else, we want the qtconsole to feel as much as a classic console as possible, just better (i.e. with images, highlighting, multiline input, etc).

I'll go ahead and merge this one so it's out of the way; on-list we discussed @jdmarch will take care of shepherding these Qt-related PRs, which is fantastic. We'll have a quicker-moving pipeline for all of them.

fperez added a commit that referenced this pull request Apr 14, 2012
…quences

BUG: qtconsole -- non-standard handling of \a and \b. This makes the behavior of the Qt console match that of an ANSI terminal with regards to \a and \b.

Fixes #1561.
@fperez fperez merged commit ed4fe90 into ipython:master Apr 14, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
…beep-sequences

BUG: qtconsole -- non-standard handling of \a and \b. This makes the behavior of the Qt console match that of an ANSI terminal with regards to \a and \b.

Fixes ipython#1561.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qtconsole - nonstandard \a and \b
4 participants