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
Comments
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. |
Fair enough - if I find time to dig into this, I'll re-post here. Thanks for the info! |
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. |
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. |
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. |
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.
Issue ipython#629 is closed. Remove related note from docs.
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.
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.
The text was updated successfully, but these errors were encountered: