Package jline

Examples of jline.ANSIBuffer$ANSICodes


  }

  public void println(MultiColourString string) {
    progress.clear();

    ANSIBuffer buffy = new ANSIBuffer();

    AnsiUtils.append(buffy, string);
    buffy.append("\n");

    if (ansi) {
      System.out.print(buffy.getAnsiBuffer());
    } else {
      System.out.print(buffy.getPlainBuffer());
    }
  }
View Full Code Here


  }

  public void println(MultiColourString string) {
    progress.clear();

    ANSIBuffer buffy = new ANSIBuffer();

    AnsiUtils.append(buffy, string);
    buffy.append("\n");

    if (ansi) {
      System.out.print(buffy.getAnsiBuffer());
    } else {
      System.out.print(buffy.getPlainBuffer());
    }
  }
View Full Code Here

    public String requiredMessage(String message)
    {
        String formattedMessage = message;
        if (useAnsiColor)
        {
            ANSIBuffer ansiBuffer = new ANSIBuffer();
            ansiBuffer.append(ANSIBuffer.ANSICodes
                                        .attrib(PrettyPrompter.BOLD))
                      .append(ANSIBuffer.ANSICodes
                                        .attrib(PrettyPrompter.FG_RED))
                      .append(message)
                      .append(ANSIBuffer.ANSICodes
                                        .attrib(PrettyPrompter.OFF));
            formattedMessage = ansiBuffer.toString();
        }

        return formattedMessage;
    }
View Full Code Here

                try
                {
                    String invalid = "Invalid selection.";
                    if (useAnsiColor)
                    {
                        ANSIBuffer ansiBuffer = new ANSIBuffer();
                        ansiBuffer.append(ANSIBuffer.ANSICodes
                                                    .attrib(FG_RED))
                                  .append(ANSIBuffer.ANSICodes
                                                    .attrib(BOLD))
                                  .append("Invalid selection.")
                                  .append(ANSIBuffer.ANSICodes
                                                    .attrib(OFF));
                        invalid = ansiBuffer.toString();
                    }
                    outputHandler.writeLine(invalid);
                } catch (IOException e)
                {
                    throw new PrompterException("Failed to present feedback", e);
View Full Code Here

        }
    }

    private String formatAnsiMessage(String message, List possibleValues, String defaultReply)
    {
        ANSIBuffer formatted = new ANSIBuffer();

        formatted.append(message);

        if (possibleValues != null && !possibleValues.isEmpty())
        {
            formatted.append(" (");

            for (Iterator it = possibleValues.iterator(); it.hasNext(); )
            {
                String possibleValue = (String) it.next();

                formatted.attrib(possibleValue, BOLD);

                if (it.hasNext())
                {
                    formatted.append("/");
                }
            }

            formatted.append(")");
        }

        if (defaultReply != null)
        {
            formatted.append(ANSIBuffer.ANSICodes
                                       .attrib(FG_GREEN))
                     .append(ANSIBuffer.ANSICodes
                                       .attrib(BOLD))
                     .append(" [")
                     .append(defaultReply)
                     .append("]")
                     .append(ANSIBuffer.ANSICodes
                                       .attrib(OFF));
        }

        return formatted.toString();
    }
View Full Code Here

        return formatted.toString();
    }

    private MessageAndAnswers formatNumberedAnsiMessage(String message, List<String> possibleValues, String defaultValue)
    {
        ANSIBuffer formatted = new ANSIBuffer();
        formatted.bold(message).append("\n");

        List<String> answers = new ArrayList<String>();
        String defaultAnswer = "1";
        int counter = 1;

        for (String val : possibleValues)
        {

            String answer = String.valueOf(counter);
            if(val.equals(defaultValue))
            {
                formatted.bold(answer);
                defaultAnswer = answer;
            }
            else
            {
                formatted.append(answer);
            }

            if (counter < 10)
            {
                formatted.append(":  ");
            } else
            {
                formatted.append(": ");
            }

            if(val.equals(defaultValue))
            {
                formatted.bold(val).append("\n");
            }
            else
            {
                formatted.append(val).append("\n");
            }

            answers.add(answer);

            counter++;
        }

        formatted.bold("Choose a number");

        return new MessageAndAnswers(formatted.toString(),answers,defaultAnswer);
    }
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) {
        final ANSIBuffer buff = JLineLogHandler.getANSIBuffer();
        if (APPLE_TERMINAL) {
            buff.append(ESCAPE + "7");
        }
        else {
            buff.append(ANSICodes.save());
        }

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

        if (mostFurtherLeftColNumber == Integer.MAX_VALUE) {
            // There is nothing to erase
        }
        else {
            buff.append(ANSICodes.gotoxy(row, mostFurtherLeftColNumber));
            // Clear what was present on the line
            buff.append(ANSICodes.clreol());
        }

        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.getTermwidth() - message.length() + 1;
            if (startFrom < 1) {
                startFrom = 1;
            }
            buff.append(ANSICodes.gotoxy(row, startFrom));
            buff.reverse(message);
            // Record we want to erase from this positioning next time (so we
            // clean up after ourselves)
            rowErasureMap.put(row, startFrom);
        }
        if (APPLE_TERMINAL) {
            buff.append(ESCAPE + "8");
        }
        else {
            buff.append(ANSICodes.restore());
        }

        final String stg = buff.toString();
        try {
            reader.printString(stg);
            reader.flushConsole();
        }
        catch (final IOException ignored) {
View Full Code Here

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

                final ANSIBuffer buff = JLineLogHandler.getANSIBuffer();
                buff.append(ESCAPE + "]0;").append(message).append(BEL);
                final String stg = buff.toString();
                try {
                    reader.printString(stg);
                    reader.flushConsole();
                }
                catch (final IOException ignored) {
View Full Code Here

     *
     * @return new patched ANSIBuffer
     */
    static ANSIBuffer getANSIBuffer() {
        final char esc = (char) 27;
        return new ANSIBuffer() {
            @Override
            public ANSIBuffer attrib(final String str, final int code) {
                if (BRIGHT_COLORS && 30 <= code && code <= 37) {
                    // This is a color code: add a 'bright' code
                    return append(esc + "[" + code + ";1m").append(str).append(
View Full Code Here

    // whatever you might want to do in your constructor, but stay away from Domino objects
  }

  // Some Formatters
  public String NTF(final Object o) {
    ANSIBuffer ab = new ANSIBuffer();
    return ab.cyan(o.toString()).toString();
  }
View Full Code Here

TOP

Related Classes of jline.ANSIBuffer$ANSICodes

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.