Package org.fusesource.jansi

Examples of org.fusesource.jansi.Ansi


   }

   @Override
   public void cursorLeft(final int x)
   {
      print(new Ansi().cursorLeft(x).toString());
   }
View Full Code Here


      if (!colorEnabled)
      {
         return output;
      }

      Ansi ansi = new Ansi();

      switch (color)
      {
      case BLACK:
         ansi.fg(Ansi.Color.BLACK);
         break;
      case BLUE:
         ansi.fg(Ansi.Color.BLUE);
         break;
      case CYAN:
         ansi.fg(Ansi.Color.CYAN);
         break;
      case GREEN:
         ansi.fg(Ansi.Color.GREEN);
         break;
      case MAGENTA:
         ansi.fg(Ansi.Color.MAGENTA);
         break;
      case RED:
         ansi.fg(Ansi.Color.RED);
         break;
      case WHITE:
         ansi.fg(Ansi.Color.WHITE);
         break;
      case YELLOW:
         ansi.fg(Ansi.Color.YELLOW);
         break;
      case BOLD:
         ansi.a(Ansi.Attribute.INTENSITY_BOLD);
         break;
      case ITALIC:
         ansi.a(Ansi.Attribute.ITALIC);
         ansi.a(Ansi.Attribute.INTENSITY_FAINT);
         break;

      default:
         return output;
      }

      return ansi.render(output).reset().toString();
   }
View Full Code Here

   }

   @Override
   public void clear()
   {
      print(new Ansi().cursor(0, 0).eraseScreen().toString());
   }
View Full Code Here

      return reader.getTerminal().getWidth();
   }

   public String escapeCode(final int code, final String value)
   {
      return new Ansi().a(value).fg(Ansi.Color.BLUE).toString();
   }
View Full Code Here

      threadName = "";
      eventString = getFormatter().format(event);
    }

    if (ansiSupported) {
      Ansi ansi = ansi(sb);
      if (event.getLevel().intValue() >= Level.SEVERE.intValue()) {
        ansi.a(Attribute.NEGATIVE_ON).a(threadName).a(Attribute.NEGATIVE_OFF).fg(RED).a(eventString).reset();
      }
      else if (event.getLevel().intValue() >= Level.WARNING.intValue()) {
        ansi.a(Attribute.NEGATIVE_ON).a(threadName).a(Attribute.NEGATIVE_OFF).fg(MAGENTA).a(eventString)
            .reset();
      }
      else if (event.getLevel().intValue() >= Level.INFO.intValue()) {
        ansi.a(Attribute.NEGATIVE_ON).a(threadName).a(Attribute.NEGATIVE_OFF).fg(GREEN).a(eventString).reset();
      }
      else {
        ansi.a(Attribute.NEGATIVE_ON).a(threadName).a(Attribute.NEGATIVE_OFF).a(eventString);
      }

    }
    else {
      sb.append(threadName).append(eventString);
View Full Code Here

  @Override
  public void setPromptPath(final String path, final boolean overrideStyle) {
    if (reader.getTerminal().isAnsiSupported()) {
      // ANSIBuffer ansi = JLineLogHandler.getANSIBuffer();
      Ansi ansi = ansi();
      if (path == null || "".equals(path)) {
        shellPrompt = ansi.fg(Color.YELLOW).a(getPromptText()).reset().toString();
      }
      else {
        if (overrideStyle) {
          ansi.a(path);
        }
        else {
          ansi.fg(Color.CYAN).a(path).reset();
        }
        shellPrompt = ansi.fg(Color.YELLOW).a(" " + getPromptText()).toString();
      }
    }
    else {
      // The superclass will do for this non-ANSI terminal
      super.setPromptPath(path);
View Full Code Here

        // We can probably update the window title, as requested
        if (!StringUtils.hasText(message)) {
          System.out.println("No text");
        }

        Ansi ansi = ansi();
        ansi.a(ESCAPE + "]0;").a(message).a(BEL);
        try {
          reader.print(ansi.toString());
          reader.flush();
        }
        catch (IOException ignored) {
        }
      }
View Full Code Here

    }
  }

  // Externally synchronized via the two calling methods having a mutex on flashInfoMap
  private void doAnsiFlash(final int row, final Level level, final String message) {
    Ansi ansi = ansi();
    if (isAppleTerminal()) {
      ansi.a(ESCAPE + "7");
    }
    else {
      ansi.saveCursorPosition();
    }

    // Figure out the longest line we're presently displaying (or were) and erase the line from that position
    int mostFurtherLeftColNumber = Integer.MAX_VALUE;
    for (Integer candidate : rowErasureMap.values()) {
      if (candidate < mostFurtherLeftColNumber) {
        mostFurtherLeftColNumber = candidate;
      }
    }

    if (mostFurtherLeftColNumber == Integer.MAX_VALUE) {
      // There is nothing to erase
    }
    else {
      ansi.cursor(row, mostFurtherLeftColNumber);
      ansi.eraseLine(Erase.FORWARD); // Clear what was present on the line
    }

    if (("".equals(message))) {
      // They want the line blank; we've already achieved this if needed via the erasing above
      // Just need to record we no longer care about this line the next time doAnsiFlash is invoked
      rowErasureMap.remove(row);
    }
    else {
      if (shutdownHookFired) {
        return; // ROO-1599
      }
      // They want some message displayed
      int startFrom = reader.getTerminal().getWidth() - message.length() + 1;
      if (startFrom < 1) {
        startFrom = 1;
      }
      ansi.cursor(row, startFrom);
      ansi.a(Attribute.NEGATIVE_ON).a(message).a(Attribute.NEGATIVE_OFF);
      // Record we want to erase from this positioning next time (so we clean up after ourselves)
      rowErasureMap.put(row, startFrom);
    }
    if (isAppleTerminal()) {
      ansi.a(ESCAPE + "8");
    }
    else {
      ansi.reset();
    }

    try {
      reader.print(ansi.toString());
      reader.flush();
    }
    catch (IOException ignored) {
    }
  }
View Full Code Here

  AnsiString append(String text, Code... codes) {
    if (codes.length == 0 || !isAnsiSupported()) {
      this.value.append(text);
      return this;
    }
    Ansi ansi = Ansi.ansi();
    for (Code code : codes) {
      ansi = applyCode(ansi, code);
    }
    this.value.append(ansi.a(text).reset().toString());
    return this;
  }
View Full Code Here

        if ((location.getLineNumber() == lines.size()) && bad.trim().isEmpty()) {
            bad = " <EOF>";
        }

        if (REAL_TERMINAL) {
            Ansi ansi = Ansi.ansi();

            ansi.fg(Ansi.Color.CYAN);
            for (int i = 1; i < location.getLineNumber(); i++) {
                ansi.a(lines.get(i - 1)).newline();
            }
            ansi.a(good);

            ansi.fg(Ansi.Color.RED);
            ansi.a(bad).newline();
            for (int i = location.getLineNumber(); i < lines.size(); i++) {
                ansi.a(lines.get(i)).newline();
            }

            ansi.reset();
            out.println(ansi);
        }
        else {
            String prefix = format("LINE %s: ", location.getLineNumber());
            String padding = Strings.repeat(" ", prefix.length() + (location.getColumnNumber() - 1));
View Full Code Here

TOP

Related Classes of org.fusesource.jansi.Ansi

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.