Skip to content
This repository

\r and \b in qtconsole don't behave as expected #629

Closed
eteq opened this Issue July 28, 2011 · 5 comments

4 participants

Erik Tollerud Fernando Perez Evan Patterson v3ss0n
Erik Tollerud
eteq commented July 28, 2011

In a normal terminal, the "\r" and "\b" control characters should move to the beginning of the line and back one character, respectively.

However, in qtconsole, writing '\b' to stdout (or "print '\b'") seems to do nothing at all, and '\r' behaves like '\n'. Is there any way to get around this and return them to the expected behavior?

This is useful for things like download notifiers that shouldn't print a new line to update the percentage downloaded or something like that - I'm not seeing the terminal just fill up with garbage instead of a dynamically updating download notification.

Evan Patterson
Collaborator

I'm afraid you may have re-adjust your expectations somewhat: the qtconsole is not a "normal terminal". In particular, it does not currently support any ANSI sequences for (non-forward) cursor movement, and this includes the '\r' and '\b' characters.

I have tried to emulate a real terminal when practical, but robust support for arbitrary cursor movement is a pretty serious effort. I may find some time to work on this, but don't hold your breath.

That said, you are welcome to dig into the code. Feel free to ask for guidance if you are so inclined.

Erik Tollerud
eteq commented July 28, 2011

Fair enough - if I find time to dig into this, I'll re-post here. Thanks for the info!

Fernando Perez
Owner
fperez commented July 29, 2011

I marked it as low priority/enhancement because as Evan said, the Qt console behaves like a console when feasible, but is not an ANSI terminal emulator. Having said that, it would be very cool to have proper support of non-forward cursor movement, so @eteq, if you manage to have a go at this, we'd be delighted to incorporate the improvements.

v3ss0n

I believe there are terminal emulator libs already in python. I had tried one before , do not remember its name. It have support for all escape characters.

Fernando Perez
Owner

The point is that by necessity, the qt console is not a terminal emulator: it's a widget that feels in many ways like a console, but it has inline graphics, rich html support, and many features that simply break the assumptions of a pure terminal emulator. A terminal emulator is a very constrained device that matches the assumptions of old-style vt-100 type environments, with a character model for addressing the 2-d space with an equispaced grid of rows and columns. Our qt console is a real GUI app with pixel-level addressing, proportional fonts, graphics, etc. That gives it much of its power, but also imposes some limitations in that we can't simply blindly reuse terminal emulator code that wants to address an 80x25 grid of fixed-width characters.

Fernando Perez fperez closed this in 21c436b December 06, 2011
Brian E. Granger ellisonbg referenced this issue from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Fernando Perez fperez referenced this issue from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Puneeth Chaganti punchagan referenced this issue from a commit in punchagan/ipython May 30, 2012
Puneeth Chaganti DOC: Remove regression from qt-console docs.
Issue #629 is closed.  Remove related note from docs.
ab71e94
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.