FileNameCompletor
Date: 2015-12-09

jline

## Class FileNameCompletor

- java.lang.Object
- - jline.FileNameCompletor

- All Implemented Interfaces:
    Completor

      public class FileNameCompletor
      extends java.lang.Object
      implements Completor

  A file name completor takes the buffer and issues a list of potential completions.

  This completor tries to behave as similar as possible to bash's file name completion (using GNU readline) with the following exceptions:

  - Candidates that are directories will end with "/"
  - Wildcard regular expressions are not evaluated or replaced
  - The "~" character can be used to represent the user's home, but it cannot complete to other users' homes, since java does not provide any way of determining that easily

  TODO

  - Handle files with spaces in them
  - Have an option for file type color highlighting
  Author:
    Marc Prud'hommeaux

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileNameCompletor()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `complete(java.lang.String buf, int cursor, java.util.List candidates)` Populates candidates with a list of possible completions for the buffer.
    `int` | `matchFiles(java.lang.String buffer, java.lang.String translated, java.io.File[] entries, java.util.List candidates)` Match the specified buffer to the array of entries and enter the matches into the list of candidates.
    `protected void` | `sortFileNames(java.util.List fileNames)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FileNameCompletor

          public FileNameCompletor()

  - ### Method Detail

    - #### complete

          public int complete(java.lang.String buf,
                     int cursor,
                     java.util.List candidates)

      Description copied from interface: `Completor`
      Populates candidates with a list of possible completions for the buffer. The candidates list will not be sorted before being displayed to the user: thus, the complete method should sort the `List` before returning.
      Specified by:
        `complete` in interface `Completor`
      Parameters:
        `buf` - the buffer
        `candidates` - the `List` of candidates to populate
      Returns:
        the index of the buffer for which the completion will be relative

    - #### sortFileNames

          protected void sortFileNames(java.util.List fileNames)

    - #### matchFiles

          public int matchFiles(java.lang.String buffer,
                       java.lang.String translated,
                       java.io.File[] entries,
                       java.util.List candidates)

      Match the specified buffer to the array of entries and enter the matches into the list of candidates. This method can be overridden in a subclass that wants to do more sophisticated file name completion.
      Parameters:
        `buffer` - the untranslated buffer
        `translated` - the buffer with common characters replaced
        `entries` - the list of files to match
        `candidates` - the list of candidates to populate
      Returns:
        the offset of the match