Closed plcs2eco closed 2 years ago
window.myApi.on("terminal.incomingData", (event, data) => { term.write(data); console.log(data.substring(1,data.length)); let b=""; for (let i = 0; i < data.length; i++) { b += data.charCodeAt(i).toString(16)+" "; } console.log(b); });
-------------main.js----------------- ptyProcess.onData(data => { mainWindow.webContents.send("terminal.incomingData", data); });
The cd on the separate line may be because your xterm instance size got out of sync with your pty? The form of the sequences coming back is actually out of the control of this package and it's related to conpty which is built-in to Windows. Windows Terminal bundles a newer version of conpty so bugs may be fixed there that you see in your usage.
Hi Tyriar, Thank you very much for clarifying me that Node-pty is just sending the form of the sequences from conpty. I will wait to get the newer version of conpty then.
By the way, the cd on the second line is displaying correctly. It looks the line of the cd is separated because conpty returned incorrect sequence and wiped out all screen including current working directory with ">" after "clear" command. So the screen was all back when "cd" was entered. Then when ENT is pressed after the cd, it changed to the below line and conpty sent the correct strings "PS C:Users_ >. So it is all good. As you clarified me, I just have to wait to get the newer version of conpty from Microsoft though I still figure out how to get it.
Environment details
Issue description
I am trying to put together node-pty and Xterm on electron using ipc. When I enter "clear" at command line in powershell, node-pty sends incorrect data to Xterm. So the screen goes all black with no CWD. I found that Node-pty is sending incorrect data to Xterm. When "clear" is entered, node-pty is sending many \x1b[K commands which clear any characters after cursor at each line. When node-pty sends data correctly 1 out of 7 times, the CWD data with PS prefix and > suffix was sent to Xterm after all \x1b[K were sent. But most cases, the CWD is sent before it starts sending \x1b[K. That's why the CWD was deleted by the first \x1b[K and the screen goes just black.
Here is the capture of the incorrect sequence.![nodepty_clear](https://user-images.githubusercontent.com/49977674/170925168-34f4679c-f2d6-4d32-b60d-428c4053b976.png)
is there any way to fix this on my side? If anyone could help me, I would appreciate it.
The below picture is "cd" was entered and it brought up the CWD at the second line after "clear" deleted all screen including CWD.![image](https://user-images.githubusercontent.com/49977674/170925667-bf99fc70-fbb2-4b49-a4f8-9581605061b0.png)