Example #1
0
 @Override
 public String toString() {
   if (ignoreRendering) return characters;
   return ANSI.getStart()
       + style.toString()
       + ';'
       + this.color.toString()
       + 'm'
       + getCharacters()
       + ANSI.reset();
 }
Example #2
0
 public int getANSILength() {
   if (ignoreRendering) return 0;
   else {
     if (ansiLength == 0)
       ansiLength =
           ANSI.getStart().length()
               + color.getLength()
               + style.getLength()
               + ANSI.reset().length()
               + 2; // ; + m
     return ansiLength;
   }
 }
Example #3
0
    private void init() {
      try {
        if (!operation.getControlOperator().isRedirectionOut()) {
          console.getShell().out().print(ANSI.getAlternateBufferScreen());
          console.getShell().out().println("print alternate screen...");
          console.getShell().out().flush();
        }

        if (console.getShell().in().getStdIn().available() > 0) {
          java.util.Scanner s =
              new java.util.Scanner(console.getShell().in().getStdIn()).useDelimiter("\\A");
          String fileContent = s.hasNext() ? s.next() : "";
          console.getShell().out().println("FILECONTENT: ");
          console.getShell().out().print(fileContent);
          console.getShell().out().flush();
        } else console.getShell().out().println("console.in() == null");

        readFromFile();

        // detach after init if hasRedirectOut()
        if (operation.getControlOperator().isRedirectionOut()) {
          attached = false;
        }
      } catch (IOException ioe) {

      }
    }
 @Override
 public void handle(AeshInputStream inputStream, Document document) {
   int row = document.getLineOfOffset(document.getCursorOffset());
   int column = document.getLineOffset(row);
   String reportCursorPosition =
       ANSI.getStart() + Integer.toString(row) + SEMI_COLON + Integer.toString(column) + 'R';
   // Respond to the Device Status Report with a Cursor Position Report
   inputStream.append(reportCursorPosition);
 }
Example #5
0
 public String getAsString() {
   StringBuilder builder = new StringBuilder();
   builder.append(ANSI.getStart());
   builder.append(type.getValue()).append(';');
   builder.append(this.getTextColor().getValue()).append(';');
   builder.append(this.getBackgroundColor().getValue());
   builder.append('m');
   builder.append(getCharacters());
   return builder.toString();
 }
Example #6
0
    @Override
    public void processOperation(CommandOperation operation) throws IOException {
      if (operation.getInput()[0] == 'q') {
        console.getShell().out().print(ANSI.getMainBufferScreen());
        attached = false;
      } else if (operation.getInput()[0] == 'a') {
        readFromFile();
      } else {

      }
    }
Example #7
0
 public void write(PrintStream out) {
   if (ignoreRendering) {
     out.print(characters);
   } else {
     out.print(ANSI.getStart());
     out.print(style.toString());
     out.print(';');
     this.color.write(out);
     out.print('m');
     out.print(getCharacters());
   }
 }
Example #8
0
  /** style, text color, background color */
  public String toString(TerminalString prev) {
    if (ignoreRendering) return characters;
    if (equalsIgnoreCharacter(prev)) return characters;
    else {
      StringBuilder builder = new StringBuilder();
      builder.append(ANSI.getStart()).append(style.getValueComparedToPrev(prev.getStyle()));

      if (!this.color.equals(prev.color)) {
        if (prev.getStyle().isInvert()) builder.append(';').append(this.color.toString());
        else builder.append(';').append(this.color.toString(prev.color));
      }

      builder.append('m').append(getCharacters());
      return builder.toString();
    }
  }
Example #9
0
  /** type, text color, background color */
  public String getAsString(TerminalString prev) {
    if (equalsIgnoreCharacter(prev)) return characters;
    else {
      StringBuilder builder = new StringBuilder();
      builder.append(ANSI.getStart());
      builder.append(type.getValueComparedToPrev(prev.getType()));
      if (this.getTextColor() != prev.getTextColor() || prev.getType() == CharacterType.INVERT)
        builder.append(';').append(this.getTextColor().getValue());
      if (this.getBackgroundColor() != prev.getBackgroundColor()
          || prev.getType() == CharacterType.INVERT)
        builder.append(';').append(this.getBackgroundColor().getValue());

      builder.append('m');
      builder.append(getCharacters());
      return builder.toString();
    }
  }