123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- CommandLine commandLine;
- void setup() {
- size (800, 420);
- commandLine = new CommandLine();
- }
- int pfc;
- void draw() {
- background(0);
- fill(#FFFFFF);
- stroke(#FFFFFF);
- commandLine.update();
- commandLine.display();
- }
-
- class CommandLine {
- String userInput = "";
- String inputString;
- String[] presentedLines;
- String[] possibleCommands = { "asd" };
- int idleFrameCount;
- boolean busy;
- CommandLine() {
- presentedLines = new String[30];
- for (int i = 0; i < presentedLines.length; i++) {
- presentedLines[i] = "";
- }
- }
- void getUserInput(int code, char c) {
- println(code, c);
- if (!busy) {
- if (code != 8 && code != 10 && code != 16 && code != 17 && code != 18 && code != 20)
- userInput = userInput + c;
- if (code == 8 && userInput.length() > 0) { //backspace
- userInput = userInput.substring(0, userInput.length()-1);
- } else if (code == 10) { //enter
- enterInput();
- userInput = "";
- }
- }
- }
- void pushLineString(String bottomLine) {
- println("bottomline " + bottomLine);
- for (int i = presentedLines.length-1; i > 0; i--) {
- presentedLines[i] = presentedLines[i-1];
- }
- presentedLines[0] = bottomLine;
- }
- void enterInput() { //user Input DEFINE COMMANDS HERE THAT ARE DETECTED
- if (userInput.equals("asd")) {
- goOutside();
- } else {
- pushLineString(inputString);
- }
- }
-
- void update() {
- if (!busy) {
- inputString = "guest@iris ~ $ " + userInput;
- presentedLines[0] = inputString;
- } else {
- if (idleFrameCount + pfc < frameCount) {
- busy = false;
- }
- }
- }
- void display() {
- for (int i = 0; i < presentedLines.length; i++) {
- text(presentedLines[i], 13, height-25-(i*13));
- }
- }
- }
-
- void goOutside() {
- commandLine.busy = true;
- pfc = frameCount;
- // String[] stringList = {"Processing",};
- // l("processing user data...", 10);
- // pfc = frameCount;
- // pushLineString(input);
- // idleFrameCount += f;
- }
-
-
- void keyPressed() {
- //println(keyCode + " " + key);
- commandLine.getUserInput(keyCode, key);
- }
|