react-console-emulator
react-console-emulator copied to clipboard
Is it possible to enter text in console manually from server without typing a command?
I'm trying to find a solution where I can automatically put text in the code console without the user typing the command. And the welcome message doesn't help. I need to enter more lines of text depending on what the user is doing on the site, without typing anything in the console. may? and if so, what is the order?
Here is how to do that, just implement the ref that is mentioned in the docs.
const changeBranch = () => {
// clear the terminals input
terminal.clearInput();
// change the text in the terminal
terminal.terminalInput.current.value = `branch ${event.target.value}`;
// run the command, completely optional
terminal.processCommand();
}
If you want to see my implementation, look at my project Pico-Online I use socket.io to sink up the terminals, but you don't have to do that.