rust-playground icon indicating copy to clipboard operation
rust-playground copied to clipboard

Carriage return (\r) doesn't work

Open amab8901 opened this issue 2 years ago • 4 comments

I write the following in Rust playground:

fn main() {
    let hej = "abc\rdef";
    
    println!("{}", hej);
}

Actual output:

abcdef

Expected output:

def

amab8901 avatar Sep 28 '22 07:09 amab8901

The playground is not attempting to be a terminal emulator, so this behavior is expected. Likewise, if you output ANSI escape codes, those will not take effect either. The output of running cargo is directly captured and shown in the output.

shepmaster avatar Sep 28 '22 15:09 shepmaster

~~Is there an issue linking to an ANSI sort of mode?~~ (#879) xterm.js makes this very simple, and is used by projects such as genact (demo page with xterm).

LeoDog896 avatar Jan 11 '23 01:01 LeoDog896

~Is there an issue linking to an ANSI sort of mode?~ (#879) xterm.js makes this very simple, and is used by projects such as genact (demo page with xterm).

I'm not sure how this is related to the issue?

amab8901 avatar Jan 11 '23 03:01 amab8901

~Is there an issue linking to an ANSI sort of mode?~ (#879) xterm.js makes this very simple, and is used by projects such as genact (demo page with xterm).

I'm not sure how this is related to the issue?

I linked them because carriage return doesn't work along with a suite of other issues -- as the repository owner mentioned:

The playground is not attempting to be a terminal emulator, so this behavior is expected. Likewise, if you output ANSI escape codes, those will not take effect either.

I've created an issue to track whether an ANSI emulator (such as I've mentioned above, xterm.js) wants to be put inside the playground.

LeoDog896 avatar Jan 11 '23 12:01 LeoDog896