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

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

Projects

None yet

4 participants

@eteq
eteq commented Jul 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.

@epatters

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.

@eteq
eteq commented Jul 28, 2011

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

@fperez
Member
fperez commented Jul 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
v3ss0n commented Oct 16, 2011

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.

@fperez
Member
fperez commented Oct 16, 2011

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.

@fperez fperez closed this in 21c436b Dec 7, 2011
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@punchagan punchagan DOC: Remove regression from qt-console docs.
Issue #629 is closed.  Remove related note from docs.
c8d8687
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment