You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make it possible to create terminal programs that run both in a browser and a terminal.
Wanted Changes
Something like:
// ./lib/LocalEchoController
...
handleTermData(data){// data may be Buffer!data=data.toString();// Against https://eslint.org/docs/rules/no-param-reassign.
...
Test
importLocalEchoControllerfrom'local-echo';(async()=>{constwindow=globalThis.window;constterm=!window
? (()=>{process.stdin.setRawMode(true);returnprocess.stdin;})()
: awaitnewPromise((resolve)=>{constterm=newTerminal({// rendererType: 'dom',});term.open(document.getElementById('terminal'));resolve(term);});term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ');term.on('data',(data)=>{// In the "raw" mode we must handle ctrl+c manually.if(data.toString().charAt(0)==='\x03'){(window ? console.log('We can\'t close the window.') : process.exit());}});// Create a local echo controllerconstcontroller=newLocalEchoController(term);while(true){awaitcontroller.read("~$ ").then(input=>controller.println(`User entered: ${input}`)).catch(error=>console.log(`Error reading: ${error}`));}})();
The text was updated successfully, but these errors were encountered:
Reason
Make it possible to create terminal programs that run both in a browser and a terminal.
Wanted Changes
Something like:
Test
The text was updated successfully, but these errors were encountered: