Exemplo n.º 1
0
 public boolean runningProgram() {
   if (runningRenderedProgram) {
     return renderedProgram.isRunning();
   } else if (runningInteractiveProgram) {
     return interactiveProgram.isRunning();
   }
   return false;
 }
Exemplo n.º 2
0
 public void renderBase(Context c) {
   // render the static section
   renderStaticSection(c);
   // render the mutable section
   if (runningRenderedProgram) {
     renderedProgram.render(c, -startLine + appendOnly.height() - 1);
   } else {
     renderMutableSection(c);
   }
 }
Exemplo n.º 3
0
 public void charTyped(char c) {
   if (runningRenderedProgram) {
     renderedProgram.charTyped(c);
     return;
   }
   if (insert) {
     insertCharAtCursor(c);
   } else {
     overwriteCharAtCursor(c);
   }
 }
Exemplo n.º 4
0
 public void paste(String s) {
   s = s.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
   if (runningRenderedProgram) {
     renderedProgram.acceptPaste(s);
   } else {
     for (int i = 0; i < s.length(); i++) {
       char c = s.charAt(i);
       insertCharAtCursor(c);
     }
   }
 }
Exemplo n.º 5
0
 public void act(int dt) {
   blinkTime = (blinkTime + dt) % blinkPeriod;
   if (runningInteractiveProgram) {
     if (interactiveProgram.isRunning()) {
       interactiveProgram.act(dt);
     } else {
       runningInteractiveProgram = false;
       interactiveProgram = null;
       newPrompt();
     }
   } else if (runningRenderedProgram) {
     if (renderedProgram.isRunning()) {
       renderedProgram.act(dt);
     } else {
       runningRenderedProgram = false;
       renderedProgram = null;
       newPrompt();
     }
   }
   super.act(dt);
 }
Exemplo n.º 6
0
  public void keyPressed(int key, int modFlags) {
    if (key == GLFW.GLFW_KEY_PAGE_UP) {
      startLine -= rows;
    } else if (key == GLFW.GLFW_KEY_PAGE_DOWN) {
      startLine += rows;
    } else if (key == GLFW.GLFW_KEY_UP && Modifiers.isControlDown(modFlags)) {
      startLine--;
      return;
    } else if (key == GLFW.GLFW_KEY_DOWN && Modifiers.isControlDown(modFlags)) {
      startLine++;
      return;
    }

    if (runningRenderedProgram) {
      if (key == GLFW.GLFW_KEY_END) {
        renderedProgram.stop();
        appendOnly.append(editable.toString());
        appendOnly.append('\n');
        runningRenderedProgram = false;
        renderedProgram = null;
        newPrompt();
      } else {
        renderedProgram.keyPressed(key, modFlags);
      }
      return;
    }

    if (key == GLFW.GLFW_KEY_ENTER) {
      enterCommand();
    } else if (key == GLFW.GLFW_KEY_LEFT) {
      if (cursor > commandStart) {
        cursor--;
      }
    } else if (key == GLFW.GLFW_KEY_RIGHT) {
      if (cursor < editable.length()) {
        cursor++;
      }
    } else if (key == GLFW.GLFW_KEY_BACKSPACE) {
      backspaceAtCursor();
    } else if (key == GLFW.GLFW_KEY_DELETE) {
      deleteAtCursor();
    } else if (key == GLFW.GLFW_KEY_INSERT) {
      insert = !insert;
    } else if (key == GLFW.GLFW_KEY_UP) {
      if (commandIndex >= 0 && commandIndex < commandBuffer.size()) {
        setCommand(commandBuffer.get(commandIndex));
        commandIndex++;
      }
    } else if (key == GLFW.GLFW_KEY_DOWN) {
      if (commandIndex - 2 >= 0 && commandIndex - 2 < commandBuffer.size()) {
        setCommand(commandBuffer.get(commandIndex - 2));
        commandIndex--;
      }
    } else if (key == GLFW.GLFW_KEY_END) {
      if (runningInteractiveProgram) {
        interactiveProgram.stop();
        runningInteractiveProgram = false;
        interactiveProgram = null;
        newPrompt();
      }
    }
  }