Skip to content

Commit

Permalink
Merge branch 'master' into indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn authored Oct 2, 2019
2 parents 9fb7822 + d9ec9e0 commit 65f61c3
Show file tree
Hide file tree
Showing 64 changed files with 6,819 additions and 985 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ branches:
- master

jdk:
- oraclejdk8
- openjdk8

# FIXME: for now just complain; do not fail as the present license headers have inconsistent date ranges
install: ./build ci-prepare -Dlicense.failIfMissing=false $MAVEN_OPTIONS
Expand Down
6 changes: 5 additions & 1 deletion builtins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.jline</groupId>
<artifactId>jline-parent</artifactId>
<version>3.11.0-SNAPSHOT</version>
<version>3.12.2-SNAPSHOT</version>
</parent>

<artifactId>jline-builtins</artifactId>
Expand All @@ -27,6 +27,10 @@
<groupId>org.jline</groupId>
<artifactId>jline-reader</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-style</artifactId>
</dependency>

<dependency>
<groupId>com.googlecode.juniversalchardet</groupId>
Expand Down
356 changes: 232 additions & 124 deletions builtins/src/main/java/org/jline/builtins/Commands.java

Large diffs are not rendered by default.

67 changes: 60 additions & 7 deletions builtins/src/main/java/org/jline/builtins/Completers.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Set;
import java.util.UUID;
import java.util.function.Function;
import java.util.function.Supplier;

import org.jline.reader.Candidate;
import org.jline.reader.LineReader;
Expand Down Expand Up @@ -217,21 +218,45 @@ private boolean isTrue(Object result) {

public static class DirectoriesCompleter extends FileNameCompleter {

private final Path currentDir;
private final Supplier<Path> currentDir;
private final boolean forceSlash;

public DirectoriesCompleter(File currentDir) {
this(currentDir.toPath());
this(currentDir.toPath(), false);
}

public DirectoriesCompleter(File currentDir, boolean forceSlash) {
this(currentDir.toPath(), forceSlash);
}

public DirectoriesCompleter(Path currentDir) {
this(currentDir, false);
}

public DirectoriesCompleter(Path currentDir, boolean forceSlash) {
this.currentDir = () -> currentDir;
this.forceSlash = forceSlash;
}

public DirectoriesCompleter(Supplier<Path> currentDir) {
this(currentDir, false);
}

public DirectoriesCompleter(Supplier<Path> currentDir, boolean forceSlash) {
this.currentDir = currentDir;
this.forceSlash = forceSlash;
}

@Override
protected Path getUserDir() {
return currentDir;
return currentDir.get();
}

@Override
protected String getSeparator() {
return forceSlash ? "/" : getUserDir().getFileSystem().getSeparator();
}

@Override
protected boolean accept(Path path) {
return Files.isDirectory(path) && super.accept(path);
Expand All @@ -240,20 +265,44 @@ protected boolean accept(Path path) {

public static class FilesCompleter extends FileNameCompleter {

private final Path currentDir;
private final Supplier<Path> currentDir;
private final boolean forceSlash;

public FilesCompleter(File currentDir) {
this(currentDir.toPath());
this(currentDir.toPath(), false);
}

public FilesCompleter(File currentDir, boolean forceSlash) {
this(currentDir.toPath(), forceSlash);
}

public FilesCompleter(Path currentDir) {
this(currentDir, false);
}

public FilesCompleter(Path currentDir, boolean forceSlash) {
this.currentDir = () -> currentDir;
this.forceSlash = forceSlash;
}

public FilesCompleter(Supplier<Path> currentDir) {
this(currentDir, false);
}

public FilesCompleter(Supplier<Path> currentDir, boolean forceSlash) {
this.currentDir = currentDir;
this.forceSlash = forceSlash;
}

@Override
protected Path getUserDir() {
return currentDir;
return currentDir.get();
}

@Override
protected String getSeparator() {
return forceSlash ? "/" : getUserDir().getFileSystem().getSeparator();
}
}

/**
Expand Down Expand Up @@ -286,7 +335,7 @@ public void complete(LineReader reader, ParsedLine commandLine, final List<Candi

Path current;
String curBuf;
String sep = getUserDir().getFileSystem().getSeparator();
String sep = getSeparator();
int lastSep = buffer.lastIndexOf(sep);
if (lastSep >= 0) {
curBuf = buffer.substring(0, lastSep + 1);
Expand Down Expand Up @@ -336,6 +385,10 @@ protected Path getUserDir() {
protected Path getUserHome() {
return Paths.get(System.getProperty("user.home"));
}

protected String getSeparator() {
return getUserDir().getFileSystem().getSeparator();
}

protected String getDisplay(Terminal terminal, Path p) {
// TODO: use $LS_COLORS for output
Expand Down
Loading

0 comments on commit 65f61c3

Please # to comment.