Examples of CursorBuffer


Examples of jline.console.CursorBuffer

    @JRubyMethod(name = "line_buffer", module = true, visibility = PRIVATE)
    public static IRubyObject s_get_line_buffer(ThreadContext context, IRubyObject recv) {
        Ruby runtime = context.runtime;
        ConsoleHolder holder = getHolderWithReadline(runtime);
        CursorBuffer cb = holder.readline.getCursorBuffer();
        return runtime.newString(cb.toString()).taint(context);
    }
View Full Code Here

Examples of jline.console.CursorBuffer

    @JRubyMethod(name = "point", module = true, visibility = PRIVATE)
    public static IRubyObject s_get_point(ThreadContext context, IRubyObject recv) {
        Ruby runtime = context.runtime;
        ConsoleHolder holder = getHolderWithReadline(runtime);
        CursorBuffer cb = holder.readline.getCursorBuffer();
        return runtime.newFixnum(cb.cursor);
    }
View Full Code Here

Examples of jline.console.CursorBuffer

                        log(percent);
                    }
                }

                private void log(float percent) {
                    CursorBuffer cursorBuffer = console.getCursorBuffer();
                    cursorBuffer.clear();
                    String description = getDescription();
                    if (description != null) {
                        cursorBuffer.write(description);
                    }
                    if (percent > 100) {
                        cursorBuffer.write(numberFormat.format(percent));
                    } else {
                        cursorBuffer.write(percentFormat.format(percent / 100f));
                    }
                    try {
                        console.redrawLine();
                        console.flush();
                    } catch (IOException e) {
View Full Code Here

Examples of jline.console.CursorBuffer

            KeyMap keyMap = lineInputReader.getKeys();
            keyMap.bind(new Character(KeyMap.CTRL_D).toString(), new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    CursorBuffer cursorBuffer = lineInputReader.getCursorBuffer();
                    if (cursorBuffer.length() == 0) {
                        System.exit(0);
                    }
                    else {
                        try {
                            lineInputReader.delete();
View Full Code Here

Examples of jline.console.CursorBuffer

     */
    public static class JlineCompletionHandler implements CompletionHandler {
        // TODO: handle quotes and escaped quotes && enable automatic escaping of whitespace

        public boolean complete(final ConsoleReader reader, final List<CharSequence> candidatesJson, final int pos) throws IOException {
            CursorBuffer buf = reader.getCursorBuffer();
            CompletionResult completionResult = fromJson(sequence(candidatesJson).head().toString());
            Sequence<String> candidatesToPrint = Sequences.empty(String.class);

            // if there is only one completion, then fill in the buffer
            if (completionResult.candidates().size() == 1) {
                CharSequence value = completionResult.candidates().head().value();

                // fail if the only candidate is the same as the current buffer
                if (value.equals(buf.toString())) {
                    return false;
                }

                setBuffer(reader, value, pos);
                candidatesToPrint = completionResult.candidates().flatMap(candidateForms());
View Full Code Here

Examples of jline.console.CursorBuffer

    // TODO: handle quotes and escaped quotes && enable automatic escaping of whitespace

    public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws
        IOException
    {
        CursorBuffer buf = reader.getCursorBuffer();

        // if there is only one completion, then fill in the buffer
        if (candidates.size() == 1) {
            CharSequence value = candidates.get(0);

            // fail if the only candidate is the same as the current buffer
            if (value.equals(buf.toString())) {
                return false;
            }

            setBuffer(reader, value, pos);
View Full Code Here

Examples of org.jboss.forge.shell.console.jline.console.CursorBuffer

   @Override
   public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws
            IOException
   {
      CursorBuffer buf = reader.getCursorBuffer();

      PluginCommandCompleterState state = commandHolder.getState();
      if (state != null)
      {
         if (((candidates.size() == 1) && "".equals(candidates.get(0)))
                  || (state.isDuplicateBuffer() && state.isFinalTokenComplete()))
         {
            if (commandHolder.getState().getOption() != null)
            {
               OptionMetadata option = commandHolder.getState().getOption();
               reader.println();
               reader.println(option.getOptionDescriptor());
               if (candidates.size() == 1)
               {
                  reader.println();
                  reader.drawLine();
                  return true;
               }
            }
         }
      }

      // if there is only one completion, then fill in the buffer
      if (candidates.size() == 1)
      {
         CharSequence value = candidates.get(0);

         // fail if the only candidate is the same as the current buffer
         if (value.equals(buf.toString()))
         {
            return false;
         }

         setBuffer(reader, value, pos);
View Full Code Here

Examples of org.jboss.forge.shell.console.jline.console.CursorBuffer

    @Override
    public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws
                IOException
    {
        CursorBuffer buf = reader.getCursorBuffer();

        PluginCommandCompleterState state = commandHolder.getState();
        if (state != null)
        {
            if (((candidates.size() == 1) && "".equals(candidates.get(0)))
                        || (state.isDuplicateBuffer() && state.isFinalTokenComplete()))
            {
                if (commandHolder.getState().getOption() != null)
                {
                    OptionMetadata option = commandHolder.getState().getOption();
                    reader.println();
                    reader.println(option.getOptionDescriptor());
                    if (candidates.size() == 1)
                    {
                        reader.println();
                        reader.drawLine();
                        return true;
                    }
                }
            }
        }

        // if there is only one completion, then fill in the buffer
        if (candidates.size() == 1)
        {
            String value = candidates.get(0).toString();
            // escape the spaces, except if it's the last character
            if (!Strings.isNullOrEmpty(value))
                value = value.substring(0, value.length() - 1).replace(" ", "\\ ")
                            + value.substring(value.length() - 1);

            // fail if the only candidate is the same as the current buffer
            if (value.equals(buf.toString()))
            {
                return false;
            }

            setBuffer(reader, value, pos);
View Full Code Here

Examples of org.jboss.forge.shell.console.jline.console.CursorBuffer

   @Override
   public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws
            IOException
   {
      CursorBuffer buf = reader.getCursorBuffer();

      PluginCommandCompleterState state = commandHolder.getState();
      if (state != null)
      {
         if (((candidates.size() == 1) && "".equals(candidates.get(0)))
                  || (state.isDuplicateBuffer() && state.isFinalTokenComplete()))
         {
            if (commandHolder.getState().getOption() != null)
            {
               OptionMetadata option = commandHolder.getState().getOption();
               reader.println();
               reader.println(option.getOptionDescriptor());
               if (candidates.size() == 1)
               {
                  reader.println();
                  reader.drawLine();
                  return true;
               }
            }
         }
      }

      // if there is only one completion, then fill in the buffer
      if (candidates.size() == 1)
      {
         String value = candidates.get(0).toString();
         // escape the spaces, except if it's the last character
         value = value.substring(0, value.length() - 1).replace(" ", "\\ ") + value.substring(value.length() - 1);

         // fail if the only candidate is the same as the current buffer
         if (value.equals(buf.toString()))
         {
            return false;
         }

         setBuffer(reader, value, pos);
View Full Code Here

Examples of org.jboss.forge.shell.console.jline.console.CursorBuffer

   @Override
   public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws
            IOException
   {
      CursorBuffer buf = reader.getCursorBuffer();

      PluginCommandCompleterState state = commandHolder.getState();
      if (state != null)
      {
         if (((candidates.size() == 1) && "".equals(candidates.get(0)))
                  || (state.isDuplicateBuffer() && state.isFinalTokenComplete()))
         {
            if (commandHolder.getState().getOption() != null)
            {
               OptionMetadata option = commandHolder.getState().getOption();
               reader.println();
               reader.println(option.getOptionDescriptor());
               if (candidates.size() == 1)
               {
                  reader.println();
                  reader.drawLine();
                  return true;
               }
            }
         }
      }

      // if there is only one completion, then fill in the buffer
      if (candidates.size() == 1)
      {
         String value = candidates.get(0).toString();
         // escape the spaces, except if it's the last character
         if (!Strings.isNullOrEmpty(value))
            value = value.substring(0, value.length() - 1).replace(" ", "\\ ")
                     + value.substring(value.length() - 1);

         // fail if the only candidate is the same as the current buffer
         if (value.equals(buf.toString()))
         {
            return false;
         }

         setBuffer(reader, value, pos);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.