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

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

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

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

eteq opened this issue Jul 28, 2011 · 5 comments
Milestone

Comments

@eteq
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
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
Copy link

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
Copy link
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 as completed in 21c436b Dec 7, 2011
jdmarch pushed a commit that referenced this issue May 30, 2012
DOC: This removes, from the qt-console docs, an obsolete warning that \r and \b are not supported. This issue was fixed by #629 and #1561.
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Support carriage return ('\r') and beep ('\b') characters in the qtconsole, providing text-mode 'scroll bars' and terminal bell in the console.

It extends AnsiCodeProcessor to understand the '\r' character and move the cursor back to the start of the line. It also understands the '\b' character and calls QTApplication::beep(). Neither are strictly speaking ANSI code sequences, of course, but they seem related enough and was simple enough to do it this way.

Closes ipython#629.
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Issue ipython#629 is closed.  Remove related note from docs.
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
DOC: This removes, from the qt-console docs, an obsolete warning that \r and \b are not supported. This issue was fixed by ipython#629 and ipython#1561.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants