I am trying to output string with newlines in xterm.js but it's showcasing the output in a weird format. I need the output to be printed as it would in an actual terminal.
import { Terminal } from 'xterm';
let terminal = new Terminal();
terminal.loadAddon(new FitAddon());
let data = "kumar\nkanhaiya"
this.setState({showOutput: true},() => {
terminal.open(document.getElementById('xterm'));
terminal.writeUtf8(data)
})
<div id="xterm"></div>
I have attached the images for reference to the issue I am facing.
The newline should make the other part of text start from beginning as in an actual terminal. But it leaves some space on the left.
Replace the LF('\n') charecters with CRLF('\r\n') from the data