Package jline

Examples of jline.ANSIBuffer$ANSICodes


        }
    }

    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

    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

    TextDisplayRow row = renderer.getRow(l)
    print(row);
  }

  private void print(TextDisplayRow row) {
    ANSIBuffer buffy = new ANSIBuffer();
   
    List<MultiColourString> lines = row.getLines();
   
    for (MultiColourString string : lines) {
      if (fixedWidth > 0 && string.length() > fixedWidth) {
        string = string.part(0, fixedWidth);
      }
     
      append(buffy, string);
      buffy.append("\n");
    }
   
    if (ansi) {
      System.out.print(buffy.getAnsiBuffer());
    } else {
      System.out.print(buffy.getPlainBuffer());
    }
  }
View Full Code Here

    TextDisplayRow row = renderer.getRow(l);
    print(row);
  }

  private void print(TextDisplayRow row) {
    ANSIBuffer buffy = new ANSIBuffer();

    List<MultiColourString> lines = row.getLines();

    for (MultiColourString string : lines) {
      if (fixedWidth > 0 && string.length() > fixedWidth) {
        string = string.part(0, fixedWidth);
      }

      AnsiUtils.append(buffy, string);
      buffy.append(TextUtil.LINE_SEPERATOR);
    }

    if (ansi) {
      System.out.print(buffy.getAnsiBuffer());
    } else {
      System.out.print(buffy.getPlainBuffer());
    }
  }
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.