Created
January 17, 2024 07:02
-
-
Save DerGoogler/1a2c544097772354da52f1dea421d755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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