react-console-emulator icon indicating copy to clipboard operation
react-console-emulator copied to clipboard

Is it possible to enter text in console manually from server without typing a command?

Open Iulian-Dragomirescu opened this issue 2 years ago • 1 comments

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?

Iulian-Dragomirescu avatar Feb 17 '22 20:02 Iulian-Dragomirescu

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.

BjornTheProgrammer avatar Aug 26 '22 21:08 BjornTheProgrammer