Skip to content

Instantly share code, notes, and snippets.

@DerGoogler
Created January 17, 2024 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerGoogler/1a2c544097772354da52f1dea421d755 to your computer and use it in GitHub Desktop.
Save DerGoogler/1a2c544097772354da52f1dea421d755 to your computer and use it in GitHub Desktop.
var useExt = false
const [line, addLine]
const processCommand = (rawCommand) => {
var arg;
var command;
const i = rawCommand.indexOf(' ');
if (i != -1 && rawCommand.length() != i + 1) {
arg = rawCommand.substring(i + 1).trim();
command = rawCommand.substring(0, i);
} else {
arg = "";
command = rawCommand;
}
switch (command) {
case "clearTerminal":
setLines([]);
break;
}
}
const onPrint = (s) => {
if ("#!useExt".equals(s.trim())) {
useExt = true;
return;
}
if (useExt && s.startsWith("#!")) {
this.processCommand(s.substring(2));
} else {
addLine(s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment