Package jline.console

Examples of jline.console.CursorBuffer


  }

  @Override
  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;
      }

      CandidateListCompletionHandler.setBuffer(reader, value, pos);

      return true;
    } else if (candidates.size() > 1) {
      String value = getUnambiguousCompletionsInternal(candidates);
      CandidateListCompletionHandler.setBuffer(reader, value, pos);
    }

    printCandidates(reader, removeLeadingValues(buf.toString(), candidates));

    // redraw the current console buffer
    reader.drawLine();
    return true;
  }
View Full Code Here


   @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

   @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

     */
    private static synchronized void print(ConsoleReader console, String prefix, String message, boolean restore) throws IOException {

        // Store the buffer information so we can restore it
        // after the message has been sent
        CursorBuffer cursorBuffer = console.getCursorBuffer().copy();
        String buffer = cursorBuffer.buffer.toString();
        int cursor = cursorBuffer.cursor;
        String prompt = console.getPrompt();

        console.restoreLine("", 0);
View Full Code Here

    @JRubyMethod(name = "line_buffer", module = true, visibility = PRIVATE, compat = RUBY1_9)
    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

    @JRubyMethod(name = "point", module = true, visibility = PRIVATE, compat = RUBY1_9)
    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

public class JLineCompletionHandler implements CompletionHandler {

    private static final Logger logger = LoggerFactory.getLogger(JLineCompletionHandler.class);

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

        // if there is only one completion, then fill in the buffer, that's all
        if (candidates.size() == 1) {
            CharSequence candidate = candidates.get(0);
            // fail if the only candidate is the same as the current buffer
            if (candidate.equals(buffer.toString())) {
                return false;
            }

            updateBuffer(reader, candidate, pos);
            return true;
View Full Code Here

    public void setAlwaysIncludeNewline(boolean eagerNewlines) {
        this.eagerNewlines = eagerNewlines;
    }

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

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

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

            jline.console.completer.CandidateListCompletionHandler.setBuffer(reader, value, pos);
View Full Code Here

    @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

    @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

TOP

Related Classes of jline.console.CursorBuffer

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.