Skip to content
Permalink
Browse files

8241598: Upgrade JLine to 3.14.0

Upgrading to JLine 3.14.0

Reviewed-by: psandoz, rfield
  • Loading branch information
Jan Lahoda committed Apr 1, 2020
1 parent c8b1f96 commit f1ef83b02e40882bad9dc0c0daac071896099529
Showing with 1,343 additions and 237 deletions.
  1. +68 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/keymap/BindingReader.java
  2. +3 −4 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/Candidate.java
  3. +75 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/ConfigurationPath.java
  4. +16 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/EOFError.java
  5. +18 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/Editor.java
  6. +5 −1 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/Highlighter.java
  7. +16 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/History.java
  8. +59 −2 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/LineReader.java
  9. +49 −1 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/Parser.java
  10. +153 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/ScriptEngine.java
  11. +25 −1 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/impl/DefaultHighlighter.java
  12. +123 −17 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/impl/DefaultParser.java
  13. +312 −56 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/impl/LineReaderImpl.java
  14. +17 −3 ...jdk.internal.le/share/classes/jdk/internal/org/jline/reader/impl/completer/ArgumentCompleter.java
  15. +22 −4 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/impl/completer/StringsCompleter.java
  16. +9 −1 src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/impl/history/DefaultHistory.java
  17. +34 −17 src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/TerminalBuilder.java
  18. +2 −2 src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/AbstractPosixTerminal.java
  19. +5 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/AbstractPty.java
  20. +16 −1 src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/AbstractTerminal.java
  21. +5 −3 src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/AbstractWindowsTerminal.java
  22. +21 −2 src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/ExternalTerminal.java
  23. +2 −2 src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/LineDisciplineTerminal.java
  24. +2 −2 src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/PosixPtyTerminal.java
  25. +2 −2 src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/PosixSysTerminal.java
  26. +9 −12 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/Display.java
  27. +6 −4 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/InfoCmp.java
  28. +27 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/NonBlocking.java
  29. +10 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/NonBlockingInputStream.java
  30. +134 −85 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/NonBlockingPumpReader.java
  31. +2 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/NonBlockingReader.java
  32. +28 −0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/NonBlockingReaderImpl.java
  33. +62 −9 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/Status.java
  34. 0 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/{dumb-colors.caps → dumb-color.caps}
  35. +1 −1 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/windows-256color.caps
  36. +1 −1 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/windows-conemu.caps
  37. +1 −1 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/windows-vtp.caps
  38. +1 −1 src/jdk.internal.le/share/classes/jdk/internal/org/jline/utils/windows.caps
  39. +1 −1 src/jdk.internal.le/share/legal/jline.md
  40. +1 −1 src/jdk.internal.le/windows/classes/jdk/internal/org/jline/terminal/impl/jna/JnaSupportImpl.java
@@ -117,6 +117,33 @@ public BindingReader(NonBlockingReader reader) {
return null;
}

public String readStringUntil(String sequence) {
StringBuilder sb = new StringBuilder();
if (!pushBackChar.isEmpty()) {
pushBackChar.forEach(sb::appendCodePoint);
}
try {
char[] buf = new char[64];
while (true) {
int idx = sb.indexOf(sequence, Math.max(0, sb.length() - buf.length - sequence.length()));
if (idx >= 0) {
String rem = sb.substring(idx + sequence.length());
runMacro(rem);
return sb.substring(0, idx);
}
int l = reader.readBuffered(buf);
if (l < 0) {
throw new ClosedException();
}
sb.append(buf, 0, l);
}
} catch (ClosedException e) {
throw new EndOfFileException(e);
} catch (IOException e) {
throw new IOError(e);
}
}

/**
* Read a codepoint from the terminal.
*
@@ -144,6 +171,47 @@ public int readCharacter() {
}
}

public int readCharacterBuffered() {
try {
if (pushBackChar.isEmpty()) {
char[] buf = new char[32];
int l = reader.readBuffered(buf);
if (l <= 0) {
return -1;
}
int s = 0;
for (int i = 0; i < l; ) {
int c = buf[i++];
if (Character.isHighSurrogate((char) c)) {
s = c;
if (i < l) {
c = buf[i++];
pushBackChar.addLast(Character.toCodePoint((char) s, (char) c));
} else {
break;
}
} else {
s = 0;
pushBackChar.addLast(c);
}
}
if (s != 0) {
int c = reader.read();
if (c >= 0) {
pushBackChar.addLast(Character.toCodePoint((char) s, (char) c));
} else {
return -1;
}
}
}
return pushBackChar.pop();
} catch (ClosedException e) {
throw new EndOfFileException(e);
} catch (IOException e) {
throw new IOError(e);
}
}

public int peekCharacter(long timeout) {
if (!pushBackChar.isEmpty()) {
return pushBackChar.peek();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2018, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
@@ -46,9 +46,8 @@ public Candidate(String value) {
* @param complete the complete flag
*/
public Candidate(String value, String displ, String group, String descr, String suffix, String key, boolean complete) {
Objects.requireNonNull(value);
this.value = value;
this.displ = displ;
this.value = Objects.requireNonNull(value);
this.displ = Objects.requireNonNull(displ);
this.group = group;
this.descr = descr;
this.suffix = suffix;
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
*
* https://opensource.org/licenses/BSD-3-Clause
*/
package org.jline.reader;

import java.io.IOException;
import java.nio.file.Path;

public class ConfigurationPath {
private Path appConfig;
private Path userConfig;

/**
* Configuration class constructor.
* @param appConfig Application configuration directory
* @param userConfig User private configuration directory
*/
public ConfigurationPath(Path appConfig, Path userConfig) {
this.appConfig = appConfig;
this.userConfig = userConfig;
}

/**
* Search configuration file first from userConfig and then appConfig directory. Returns null if file is not found.
* @param name Configuration file name.
* @return Configuration file.
*
*/
public Path getConfig(String name) {
Path out = null;
if (userConfig != null && userConfig.resolve(name).toFile().exists()) {
out = userConfig.resolve(name);
} else if (appConfig != null && appConfig.resolve(name).toFile().exists()) {
out = appConfig.resolve(name);
}
return out;
}

/**
* Search configuration file from userConfig directory. Returns null if file is not found.
* @param name Configuration file name.
* @return Configuration file.
* @throws IOException When we do not have read access to the file or directory.
*
*/
public Path getUserConfig(String name) throws IOException {
return getUserConfig(name, false);
}

/**
* Search configuration file from userConfig directory. Returns null if file is not found.
* @param name Configuration file name
* @param create When true configuration file is created if not found.
* @return Configuration file.
* @throws IOException When we do not have read/write access to the file or directory.
*/
public Path getUserConfig(String name, boolean create) throws IOException {
Path out = null;
if (userConfig != null) {
if (!userConfig.resolve(name).toFile().exists() && create) {
userConfig.resolve(name).toFile().createNewFile();
}
if (userConfig.resolve(name).toFile().exists()) {
out = userConfig.resolve(name);
}
}
return out;
}

}
@@ -23,17 +23,33 @@
private static final long serialVersionUID = 1L;

private final String missing;
private final int openBrackets;
private final String nextClosingBracket;

public EOFError(int line, int column, String message) {
this(line, column, message, null);
}

public EOFError(int line, int column, String message, String missing) {
this(line, column, message, missing, 0, null);
}

public EOFError(int line, int column, String message, String missing, int openBrackets, String nextClosingBracket) {
super(line, column, message);
this.missing = missing;
this.openBrackets = openBrackets;
this.nextClosingBracket = nextClosingBracket;
}

public String getMissing() {
return missing;
}

public int getOpenBrackets(){
return openBrackets;
}

public String getNextClosingBracket() {
return nextClosingBracket;
}
}
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
*
* https://opensource.org/licenses/BSD-3-Clause
*/
package jdk.internal.org.jline.reader;

import java.io.IOException;
import java.util.List;

public interface Editor {
public void open(List<String> files) throws IOException;
public void run() throws IOException;
public void setRestricted(boolean restricted);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2016, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
@@ -8,9 +8,13 @@
*/
package jdk.internal.org.jline.reader;

import java.util.regex.Pattern;

import jdk.internal.org.jline.utils.AttributedString;

public interface Highlighter {

AttributedString highlight(LineReader reader, String buffer);
public void setErrorPattern(Pattern errorPattern);
public void setErrorIndex(int errorIndex);
}
@@ -45,19 +45,25 @@
/**
* Write history to the file. If incremental only the events that are new since the last incremental operation to
* the file are added.
* @param file History file
* @param incremental If true incremental write operation is performed.
* @throws IOException if a problem occurs
*/
void write(Path file, boolean incremental) throws IOException;

/**
* Append history to the file. If incremental only the events that are new since the last incremental operation to
* the file are added.
* @param file History file
* @param incremental If true incremental append operation is performed.
* @throws IOException if a problem occurs
*/
void append(Path file, boolean incremental) throws IOException;

/**
* Read history from the file. If incremental only the events that are not contained within the internal list are added.
* @param file History file
* @param incremental If true incremental read operation is performed.
* @throws IOException if a problem occurs
*/
void read(Path file, boolean incremental) throws IOException;
@@ -133,6 +139,11 @@ public boolean hasNext() {
public Entry next() {
return it.previous();
}
@Override
public void remove() {
it.remove();
resetIndex();
}
};
}

@@ -191,4 +202,9 @@ public Entry next() {
* all of the other iterator.
*/
void moveToEnd();

/**
* Reset index after remove
*/
void resetIndex();
}

0 comments on commit f1ef83b

Please sign in to comment.