Hydrogen doesn't respect \r symbol
print('ab\rcd') will produce cd in console and/or jupyter notebook. In hydrogen it will show up as
cd
This is especially critical when working on scripts that report progress, e.g. use tqdm
Atom version: 1.10.2
Hydrogen version: 0.14.0
cc/ @rgbkrk
I believe this is a bug in the latest version of Jupyter. Both Hydrogen and IPython 2.4.1 produce the expected output:
cd
I add the bug label again since the output looks like this:

It should be a multiline bubble otherwise it breaks the layout of the following code line.
ipython 2.4.1 was released almost a year ago. Current version is 5.1.0 which produces cd in output.

This is used mostly in progressbars (e.g. keras model training).
In hydrogen output produced can span several hunreds lines.
@kilotaras Oh, I see. Now, I understand what the issue is. I'm going to label this issue as a feature request.
@lgeiger I reckon this is best implemented in transformime.
Yes we should definitely handle this in transformime.
I still don't fully understand the expected behavior.
Is the \r supposed to remove the two surrounding characters? How would that help with progress bars?
r (by itself with no newline) is a carriage return. It returns the console writer to the first position.
Historically, this "carriage" was the printer head on a type writer. When you hit the key, the printer head would go back to the start - allowing you to type over the line you were just on.

Using this, you can overwrite the previous line.
The more general problem is to handle more of the character codes to allow the cursor to move all over. You basically need to manage a TTY then, which, if you're interested I'm happy to explore.
Ahh thanks. I misread the expected behavior.
I read ad instead of cd. That makes sense now!
For reference: https://github.com/nteract/ansi-to-react/issues/2
Thejupyter notebook handles it like this: https://github.com/jupyter/notebook/blob/master/notebook/static/base/js/utils.js#L446
I tried:
print('this sentence\rthat\nwill make you pause')
jupyter notebook prints:
will make you pause
jupyter console prints:
that sentence
will make you pause
As far as progress bars go, #474 does not resolve this:

It seems that since output is updated over time, \rs get ignored.
@lgeiger - you may want to check out stdout and stderr joining as is done in nteract.
However, I'd probably combine stdout and stderr to be more like a terminal.
function reduceOutputs(outputs, output) {
const lastOutputIndex = outputs.length - 1
if (outputs[lastOutputIndex].output_type === 'stream' && output.output_type === 'stream') {
outputs[lastOutputIndex].text = outputs[lastOutputIndex].text + output.text;
return outputs
}
outputs.push(output);
return outputs;
}