8229815: Upgrade Jline to 3.12.1
Reviewed-by: rfield
This commit is contained in:
parent
a66829bc89
commit
a9952bb5d9
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.keymap;
|
package jdk.internal.org.jline.keymap;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.keymap;
|
package jdk.internal.org.jline.keymap;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
@ -41,6 +42,26 @@ public interface History extends Iterable<History.Entry>
|
|||||||
*/
|
*/
|
||||||
void save() throws IOException;
|
void save() throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write history to the file. If incremental only the events that are new since the last incremental operation to
|
||||||
|
* the file are added.
|
||||||
|
* @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.
|
||||||
|
* @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.
|
||||||
|
* @throws IOException if a problem occurs
|
||||||
|
*/
|
||||||
|
void read(Path file, boolean incremental) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purge history.
|
* Purge history.
|
||||||
* @throws IOException if a problem occurs
|
* @throws IOException if a problem occurs
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
@ -95,7 +95,10 @@ public interface LineReader {
|
|||||||
String CALLBACK_FINISH = "callback-finish";
|
String CALLBACK_FINISH = "callback-finish";
|
||||||
String CALLBACK_KEYMAP = "callback-keymap";
|
String CALLBACK_KEYMAP = "callback-keymap";
|
||||||
|
|
||||||
|
String ACCEPT_AND_INFER_NEXT_HISTORY = "accept-and-infer-next-history";
|
||||||
|
String ACCEPT_AND_HOLD = "accept-and-hold";
|
||||||
String ACCEPT_LINE = "accept-line";
|
String ACCEPT_LINE = "accept-line";
|
||||||
|
String ACCEPT_LINE_AND_DOWN_HISTORY = "accept-line-and-down-history";
|
||||||
String ARGUMENT_BASE = "argument-base";
|
String ARGUMENT_BASE = "argument-base";
|
||||||
String BACKWARD_CHAR = "backward-char";
|
String BACKWARD_CHAR = "backward-char";
|
||||||
String BACKWARD_DELETE_CHAR = "backward-delete-char";
|
String BACKWARD_DELETE_CHAR = "backward-delete-char";
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public final class LineReaderBuilder {
|
|||||||
public LineReaderBuilder parser(Parser parser) {
|
public LineReaderBuilder parser(Parser parser) {
|
||||||
if (parser != null) {
|
if (parser != null) {
|
||||||
try {
|
try {
|
||||||
if (!Boolean.parseBoolean(LineReader.PROP_SUPPORT_PARSEDLINE)
|
if (!Boolean.getBoolean(LineReader.PROP_SUPPORT_PARSEDLINE)
|
||||||
&& !(parser.parse("", 0) instanceof CompletingParsedLine)) {
|
&& !(parser.parse("", 0) instanceof CompletingParsedLine)) {
|
||||||
Log.warn("The Parser of class " + parser.getClass().getName() + " does not support the CompletingParsedLine interface. " +
|
Log.warn("The Parser of class " + parser.getClass().getName() + " does not support the CompletingParsedLine interface. " +
|
||||||
"Completion with escaped or quoted words won't work correctly.");
|
"Completion with escaped or quoted words won't work correctly.");
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
@ -16,6 +16,10 @@ public interface Parser {
|
|||||||
return parse(line, cursor, ParseContext.UNSPECIFIED);
|
return parse(line, cursor, ParseContext.UNSPECIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean isEscapeChar(char ch) {
|
||||||
|
return ch == '\\';
|
||||||
|
}
|
||||||
|
|
||||||
enum ParseContext {
|
enum ParseContext {
|
||||||
UNSPECIFIED,
|
UNSPECIFIED,
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader;
|
package jdk.internal.org.jline.reader;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl;
|
package jdk.internal.org.jline.reader.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl;
|
package jdk.internal.org.jline.reader.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl;
|
package jdk.internal.org.jline.reader.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl;
|
package jdk.internal.org.jline.reader.impl;
|
||||||
|
|
||||||
@ -18,6 +18,13 @@ import jdk.internal.org.jline.reader.Parser;
|
|||||||
|
|
||||||
public class DefaultParser implements Parser {
|
public class DefaultParser implements Parser {
|
||||||
|
|
||||||
|
public enum Bracket {
|
||||||
|
ROUND, // ()
|
||||||
|
CURLY, // {}
|
||||||
|
SQUARE, // []
|
||||||
|
ANGLE; // <>
|
||||||
|
}
|
||||||
|
|
||||||
private char[] quoteChars = {'\'', '"'};
|
private char[] quoteChars = {'\'', '"'};
|
||||||
|
|
||||||
private char[] escapeChars = {'\\'};
|
private char[] escapeChars = {'\\'};
|
||||||
@ -26,6 +33,10 @@ public class DefaultParser implements Parser {
|
|||||||
|
|
||||||
private boolean eofOnEscapedNewLine;
|
private boolean eofOnEscapedNewLine;
|
||||||
|
|
||||||
|
private char[] openingBrackets = null;
|
||||||
|
|
||||||
|
private char[] closingBrackets = null;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Chainable setters
|
// Chainable setters
|
||||||
//
|
//
|
||||||
@ -45,6 +56,11 @@ public class DefaultParser implements Parser {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DefaultParser eofOnUnclosedBracket(Bracket... brackets){
|
||||||
|
setEofOnUnclosedBracket(brackets);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DefaultParser eofOnEscapedNewLine(boolean eofOnEscapedNewLine) {
|
public DefaultParser eofOnEscapedNewLine(boolean eofOnEscapedNewLine) {
|
||||||
this.eofOnEscapedNewLine = eofOnEscapedNewLine;
|
this.eofOnEscapedNewLine = eofOnEscapedNewLine;
|
||||||
return this;
|
return this;
|
||||||
@ -86,6 +102,39 @@ public class DefaultParser implements Parser {
|
|||||||
return eofOnEscapedNewLine;
|
return eofOnEscapedNewLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEofOnUnclosedBracket(Bracket... brackets){
|
||||||
|
if (brackets == null) {
|
||||||
|
openingBrackets = null;
|
||||||
|
closingBrackets = null;
|
||||||
|
} else {
|
||||||
|
Set<Bracket> bs = new HashSet<>(Arrays.asList(brackets));
|
||||||
|
openingBrackets = new char[bs.size()];
|
||||||
|
closingBrackets = new char[bs.size()];
|
||||||
|
int i = 0;
|
||||||
|
for (Bracket b : bs) {
|
||||||
|
switch (b) {
|
||||||
|
case ROUND:
|
||||||
|
openingBrackets[i] = '(';
|
||||||
|
closingBrackets[i] = ')';
|
||||||
|
break;
|
||||||
|
case CURLY:
|
||||||
|
openingBrackets[i] = '{';
|
||||||
|
closingBrackets[i] = '}';
|
||||||
|
break;
|
||||||
|
case SQUARE:
|
||||||
|
openingBrackets[i] = '[';
|
||||||
|
closingBrackets[i] = ']';
|
||||||
|
break;
|
||||||
|
case ANGLE:
|
||||||
|
openingBrackets[i] = '<';
|
||||||
|
closingBrackets[i] = '>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ParsedLine parse(final String line, final int cursor, ParseContext context) {
|
public ParsedLine parse(final String line, final int cursor, ParseContext context) {
|
||||||
List<String> words = new LinkedList<>();
|
List<String> words = new LinkedList<>();
|
||||||
StringBuilder current = new StringBuilder();
|
StringBuilder current = new StringBuilder();
|
||||||
@ -95,6 +144,8 @@ public class DefaultParser implements Parser {
|
|||||||
int rawWordCursor = -1;
|
int rawWordCursor = -1;
|
||||||
int rawWordLength = -1;
|
int rawWordLength = -1;
|
||||||
int rawWordStart = 0;
|
int rawWordStart = 0;
|
||||||
|
BracketChecker bracketChecker = new BracketChecker();
|
||||||
|
boolean quotedWord = false;
|
||||||
|
|
||||||
for (int i = 0; (line != null) && (i < line.length()); i++) {
|
for (int i = 0; (line != null) && (i < line.length()); i++) {
|
||||||
// once we reach the cursor, set the
|
// once we reach the cursor, set the
|
||||||
@ -110,36 +161,35 @@ public class DefaultParser implements Parser {
|
|||||||
if (quoteStart < 0 && isQuoteChar(line, i)) {
|
if (quoteStart < 0 && isQuoteChar(line, i)) {
|
||||||
// Start a quote block
|
// Start a quote block
|
||||||
quoteStart = i;
|
quoteStart = i;
|
||||||
} else if (quoteStart >= 0) {
|
if (current.length()==0) {
|
||||||
// In a quote block
|
quotedWord = true;
|
||||||
if (line.charAt(quoteStart) == line.charAt(i) && !isEscaped(line, i)) {
|
|
||||||
// End the block; arg could be empty, but that's fine
|
|
||||||
words.add(current.toString());
|
|
||||||
current.setLength(0);
|
|
||||||
quoteStart = -1;
|
|
||||||
if (rawWordCursor >= 0 && rawWordLength < 0) {
|
|
||||||
rawWordLength = i - rawWordStart + 1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!isEscapeChar(line, i)) {
|
current.append(line.charAt(i));
|
||||||
// Take the next character
|
}
|
||||||
current.append(line.charAt(i));
|
} else if (quoteStart >= 0 && line.charAt(quoteStart) == line.charAt(i) && !isEscaped(line, i)) {
|
||||||
|
// End quote block
|
||||||
|
if (!quotedWord) {
|
||||||
|
current.append(line.charAt(i));
|
||||||
|
} else if (rawWordCursor >= 0 && rawWordLength < 0) {
|
||||||
|
rawWordLength = i - rawWordStart + 1;
|
||||||
|
}
|
||||||
|
quoteStart = -1;
|
||||||
|
quotedWord = false;
|
||||||
|
} else if (quoteStart < 0 && isDelimiter(line, i)) {
|
||||||
|
// Delimiter
|
||||||
|
if (current.length() > 0) {
|
||||||
|
words.add(current.toString());
|
||||||
|
current.setLength(0); // reset the arg
|
||||||
|
if (rawWordCursor >= 0 && rawWordLength < 0) {
|
||||||
|
rawWordLength = i - rawWordStart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rawWordStart = i + 1;
|
||||||
} else {
|
} else {
|
||||||
// Not in a quote block
|
if (!isEscapeChar(line, i)) {
|
||||||
if (isDelimiter(line, i)) {
|
current.append(line.charAt(i));
|
||||||
if (current.length() > 0) {
|
if (quoteStart < 0) {
|
||||||
words.add(current.toString());
|
bracketChecker.check(line, i);
|
||||||
current.setLength(0); // reset the arg
|
|
||||||
if (rawWordCursor >= 0 && rawWordLength < 0) {
|
|
||||||
rawWordLength = i - rawWordStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rawWordStart = i + 1;
|
|
||||||
} else {
|
|
||||||
if (!isEscapeChar(line, i)) {
|
|
||||||
current.append(line.charAt(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,21 +209,29 @@ public class DefaultParser implements Parser {
|
|||||||
rawWordLength = rawWordCursor;
|
rawWordLength = rawWordCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eofOnEscapedNewLine && isEscapeChar(line, line.length() - 1)) {
|
if (context != ParseContext.COMPLETE) {
|
||||||
throw new EOFError(-1, -1, "Escaped new line", "newline");
|
if (eofOnEscapedNewLine && isEscapeChar(line, line.length() - 1)) {
|
||||||
}
|
throw new EOFError(-1, -1, "Escaped new line", "newline");
|
||||||
if (eofOnUnclosedQuote && quoteStart >= 0 && context != ParseContext.COMPLETE) {
|
}
|
||||||
throw new EOFError(-1, -1, "Missing closing quote", line.charAt(quoteStart) == '\''
|
if (eofOnUnclosedQuote && quoteStart >= 0) {
|
||||||
? "quote" : "dquote");
|
throw new EOFError(-1, -1, "Missing closing quote", line.charAt(quoteStart) == '\''
|
||||||
|
? "quote" : "dquote");
|
||||||
|
}
|
||||||
|
if (bracketChecker.isOpeningBracketMissing()) {
|
||||||
|
throw new EOFError(-1, -1, "Missing opening bracket", "missing: " + bracketChecker.getMissingOpeningBracket());
|
||||||
|
}
|
||||||
|
if (bracketChecker.isClosingBracketMissing()) {
|
||||||
|
throw new EOFError(-1, -1, "Missing closing brackets", "add: " + bracketChecker.getMissingClosingBrackets());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String openingQuote = quoteStart >= 0 ? line.substring(quoteStart, quoteStart + 1) : null;
|
String openingQuote = quotedWord ? line.substring(quoteStart, quoteStart + 1) : null;
|
||||||
return new ArgumentList(line, words, wordIndex, wordCursor, cursor, openingQuote, rawWordCursor, rawWordLength);
|
return new ArgumentList(line, words, wordIndex, wordCursor, cursor, openingQuote, rawWordCursor, rawWordLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the specified character is a whitespace parameter. Check to ensure that the character is not
|
* Returns true if the specified character is a whitespace parameter. Check to ensure that the character is not
|
||||||
* escaped by any of {@link #getQuoteChars}, and is not escaped by ant of the {@link #getEscapeChars}, and
|
* escaped by any of {@link #getQuoteChars}, and is not escaped by any of the {@link #getEscapeChars}, and
|
||||||
* returns true from {@link #isDelimiterChar}.
|
* returns true from {@link #isDelimiterChar}.
|
||||||
*
|
*
|
||||||
* @param buffer The complete command buffer
|
* @param buffer The complete command buffer
|
||||||
@ -202,6 +260,18 @@ public class DefaultParser implements Parser {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEscapeChar(char ch) {
|
||||||
|
if (escapeChars != null) {
|
||||||
|
for (char e : escapeChars) {
|
||||||
|
if (e == ch) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this character is a valid escape char (i.e. one that has not been escaped)
|
* Check if this character is a valid escape char (i.e. one that has not been escaped)
|
||||||
*
|
*
|
||||||
@ -216,14 +286,8 @@ public class DefaultParser implements Parser {
|
|||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (escapeChars != null) {
|
char ch = buffer.charAt(pos);
|
||||||
for (char e : escapeChars) {
|
return isEscapeChar(ch) && !isEscaped(buffer, pos);
|
||||||
if (e == buffer.charAt(pos)) {
|
|
||||||
return !isEscaped(buffer, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -245,7 +309,7 @@ public class DefaultParser implements Parser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the character at the specified position if a delimiter. This method will only be called if
|
* Returns true if the character at the specified position if a delimiter. This method will only be called if
|
||||||
* the character is not enclosed in any of the {@link #getQuoteChars}, and is not escaped by ant of the
|
* the character is not enclosed in any of the {@link #getQuoteChars}, and is not escaped by any of the
|
||||||
* {@link #getEscapeChars}. To perform escaping manually, override {@link #isDelimiter} instead.
|
* {@link #getEscapeChars}. To perform escaping manually, override {@link #isDelimiter} instead.
|
||||||
*
|
*
|
||||||
* @param buffer
|
* @param buffer
|
||||||
@ -280,6 +344,67 @@ public class DefaultParser implements Parser {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class BracketChecker {
|
||||||
|
private int missingOpeningBracket = -1;
|
||||||
|
private List<Integer> nested = new ArrayList<>();
|
||||||
|
|
||||||
|
public BracketChecker(){}
|
||||||
|
|
||||||
|
public void check(final CharSequence buffer, final int pos){
|
||||||
|
if (openingBrackets == null || pos < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int bid = bracketId(openingBrackets, buffer, pos);
|
||||||
|
if (bid >= 0) {
|
||||||
|
nested.add(bid);
|
||||||
|
} else {
|
||||||
|
bid = bracketId(closingBrackets, buffer, pos);
|
||||||
|
if (bid >= 0) {
|
||||||
|
if (!nested.isEmpty() && bid == nested.get(nested.size()-1)) {
|
||||||
|
nested.remove(nested.size()-1);
|
||||||
|
} else {
|
||||||
|
missingOpeningBracket = bid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOpeningBracketMissing(){
|
||||||
|
return missingOpeningBracket != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMissingOpeningBracket(){
|
||||||
|
if (!isOpeningBracketMissing()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Character.toString(openingBrackets[missingOpeningBracket]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isClosingBracketMissing(){
|
||||||
|
return !nested.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMissingClosingBrackets(){
|
||||||
|
if (!isClosingBracketMissing()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
StringBuilder out = new StringBuilder();
|
||||||
|
for (int i = nested.size() - 1; i > -1; i--) {
|
||||||
|
out.append(closingBrackets[nested.get(i)]);
|
||||||
|
}
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int bracketId(final char[] brackets, final CharSequence buffer, final int pos){
|
||||||
|
for (int i=0; i < brackets.length; i++) {
|
||||||
|
if (buffer.charAt(pos) == brackets[i]) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result of a delimited buffer.
|
* The result of a delimited buffer.
|
||||||
*
|
*
|
||||||
@ -367,26 +492,50 @@ public class DefaultParser implements Parser {
|
|||||||
public CharSequence escape(CharSequence candidate, boolean complete) {
|
public CharSequence escape(CharSequence candidate, boolean complete) {
|
||||||
StringBuilder sb = new StringBuilder(candidate);
|
StringBuilder sb = new StringBuilder(candidate);
|
||||||
Predicate<Integer> needToBeEscaped;
|
Predicate<Integer> needToBeEscaped;
|
||||||
// Completion is protected by an opening quote:
|
String quote = openingQuote;
|
||||||
// Delimiters (spaces) don't need to be escaped, nor do other quotes, but everything else does.
|
boolean middleQuotes = false;
|
||||||
// Also, close the quote at the end
|
if (openingQuote==null) {
|
||||||
if (openingQuote != null) {
|
for (int i=0; i < sb.length(); i++) {
|
||||||
needToBeEscaped = i -> isRawEscapeChar(sb.charAt(i)) || String.valueOf(sb.charAt(i)).equals(openingQuote);
|
if (isQuoteChar(sb, i)) {
|
||||||
}
|
middleQuotes = true;
|
||||||
// No quote protection, need to escape everything: delimiter chars (spaces), quote chars
|
break;
|
||||||
// and escapes themselves
|
}
|
||||||
else {
|
|
||||||
needToBeEscaped = i -> isDelimiterChar(sb, i) || isRawEscapeChar(sb.charAt(i)) || isRawQuoteChar(sb.charAt(i));
|
|
||||||
}
|
|
||||||
for (int i = 0; i < sb.length(); i++) {
|
|
||||||
if (needToBeEscaped.test(i)) {
|
|
||||||
sb.insert(i++, escapeChars[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (openingQuote != null) {
|
if (escapeChars != null) {
|
||||||
sb.insert(0, openingQuote);
|
// Completion is protected by an opening quote:
|
||||||
|
// Delimiters (spaces) don't need to be escaped, nor do other quotes, but everything else does.
|
||||||
|
// Also, close the quote at the end
|
||||||
|
if (openingQuote != null) {
|
||||||
|
needToBeEscaped = i -> isRawEscapeChar(sb.charAt(i)) || String.valueOf(sb.charAt(i)).equals(openingQuote);
|
||||||
|
}
|
||||||
|
// Completion is protected by middle quotes:
|
||||||
|
// Delimiters (spaces) don't need to be escaped, nor do quotes, but everything else does.
|
||||||
|
else if (middleQuotes) {
|
||||||
|
needToBeEscaped = i -> isRawEscapeChar(sb.charAt(i));
|
||||||
|
}
|
||||||
|
// No quote protection, need to escape everything: delimiter chars (spaces), quote chars
|
||||||
|
// and escapes themselves
|
||||||
|
else {
|
||||||
|
needToBeEscaped = i -> isDelimiterChar(sb, i) || isRawEscapeChar(sb.charAt(i)) || isRawQuoteChar(sb.charAt(i));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < sb.length(); i++) {
|
||||||
|
if (needToBeEscaped.test(i)) {
|
||||||
|
sb.insert(i++, escapeChars[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (openingQuote == null && !middleQuotes) {
|
||||||
|
for (int i = 0; i < sb.length(); i++) {
|
||||||
|
if (isDelimiterChar(sb, i)) {
|
||||||
|
quote = "'";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (quote != null) {
|
||||||
|
sb.insert(0, quote);
|
||||||
if (complete) {
|
if (complete) {
|
||||||
sb.append(openingQuote);
|
sb.append(quote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb;
|
return sb;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl;
|
package jdk.internal.org.jline.reader.impl;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl;
|
package jdk.internal.org.jline.reader.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl;
|
package jdk.internal.org.jline.reader.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl;
|
package jdk.internal.org.jline.reader.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl.completer;
|
package jdk.internal.org.jline.reader.impl.completer;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl.completer;
|
package jdk.internal.org.jline.reader.impl.completer;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl.completer;
|
package jdk.internal.org.jline.reader.impl.completer;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl.completer;
|
package jdk.internal.org.jline.reader.impl.completer;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl.completer;
|
package jdk.internal.org.jline.reader.impl.completer;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl.completer;
|
package jdk.internal.org.jline.reader.impl.completer;
|
||||||
|
|
||||||
@ -43,6 +43,11 @@ public class StringsCompleter implements Completer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StringsCompleter(Candidate ... candidates) {
|
||||||
|
assert candidates != null;
|
||||||
|
this.candidates.addAll(Arrays.asList(candidates));
|
||||||
|
}
|
||||||
|
|
||||||
public void complete(LineReader reader, final ParsedLine commandLine, final List<Candidate> candidates) {
|
public void complete(LineReader reader, final ParsedLine commandLine, final List<Candidate> candidates) {
|
||||||
assert commandLine != null;
|
assert commandLine != null;
|
||||||
assert candidates != null;
|
assert candidates != null;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* JLine 3.
|
* JLine 3.
|
||||||
|
@ -4,12 +4,13 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.reader.impl.history;
|
package jdk.internal.org.jline.reader.impl.history;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
|
import java.time.DateTimeException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -36,8 +37,7 @@ public class DefaultHistory implements History {
|
|||||||
|
|
||||||
private LineReader reader;
|
private LineReader reader;
|
||||||
|
|
||||||
private int lastLoaded = 0;
|
private Map<String, HistoryFileData> historyFiles = new HashMap<>();
|
||||||
private int nbEntriesInFile = 0;
|
|
||||||
private int offset = 0;
|
private int offset = 0;
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class DefaultHistory implements History {
|
|||||||
try {
|
try {
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IllegalArgumentException | IOException e) {
|
||||||
Log.warn("Failed to load history", e);
|
Log.warn("Failed to load history", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,12 +84,11 @@ public class DefaultHistory implements History {
|
|||||||
try (BufferedReader reader = Files.newBufferedReader(path)) {
|
try (BufferedReader reader = Files.newBufferedReader(path)) {
|
||||||
internalClear();
|
internalClear();
|
||||||
reader.lines().forEach(line -> addHistoryLine(path, line));
|
reader.lines().forEach(line -> addHistoryLine(path, line));
|
||||||
lastLoaded = items.size();
|
setHistoryFileData(path, new HistoryFileData(items.size(), items.size()));
|
||||||
nbEntriesInFile = lastLoaded;
|
|
||||||
maybeResize();
|
maybeResize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IllegalArgumentException | IOException e) {
|
||||||
Log.debug("Failed to load history; clearing", e);
|
Log.debug("Failed to load history; clearing", e);
|
||||||
internalClear();
|
internalClear();
|
||||||
throw e;
|
throw e;
|
||||||
@ -97,20 +96,100 @@ public class DefaultHistory implements History {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(Path file, boolean incremental) throws IOException {
|
||||||
|
Path path = file != null ? file : getPath();
|
||||||
|
if (path != null) {
|
||||||
|
try {
|
||||||
|
if (Files.exists(path)) {
|
||||||
|
Log.trace("Reading history from: ", path);
|
||||||
|
try (BufferedReader reader = Files.newBufferedReader(path)) {
|
||||||
|
reader.lines().forEach(line -> addHistoryLine(path, line, incremental));
|
||||||
|
setHistoryFileData(path, new HistoryFileData(items.size(), items.size()));
|
||||||
|
maybeResize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException | IOException e) {
|
||||||
|
Log.debug("Failed to read history; clearing", e);
|
||||||
|
internalClear();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String doHistoryFileDataKey (Path path){
|
||||||
|
return path != null ? path.toAbsolutePath().toString() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HistoryFileData getHistoryFileData(Path path) {
|
||||||
|
String key = doHistoryFileDataKey(path);
|
||||||
|
if (!historyFiles.containsKey(key)){
|
||||||
|
historyFiles.put(key, new HistoryFileData());
|
||||||
|
}
|
||||||
|
return historyFiles.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setHistoryFileData(Path path, HistoryFileData historyFileData) {
|
||||||
|
historyFiles.put(doHistoryFileDataKey(path), historyFileData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isLineReaderHistory (Path path) throws IOException {
|
||||||
|
Path lrp = getPath();
|
||||||
|
if (lrp == null) {
|
||||||
|
if (path != null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Files.isSameFile(lrp, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLastLoaded(Path path, int lastloaded){
|
||||||
|
getHistoryFileData(path).setLastLoaded(lastloaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEntriesInFile(Path path, int entriesInFile){
|
||||||
|
getHistoryFileData(path).setEntriesInFile(entriesInFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void incEntriesInFile(Path path, int amount){
|
||||||
|
getHistoryFileData(path).incEntriesInFile(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getLastLoaded(Path path){
|
||||||
|
return getHistoryFileData(path).getLastLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getEntriesInFile(Path path){
|
||||||
|
return getHistoryFileData(path).getEntriesInFile();
|
||||||
|
}
|
||||||
|
|
||||||
protected void addHistoryLine(Path path, String line) {
|
protected void addHistoryLine(Path path, String line) {
|
||||||
|
addHistoryLine(path, line, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addHistoryLine(Path path, String line, boolean checkDuplicates) {
|
||||||
if (reader.isSet(LineReader.Option.HISTORY_TIMESTAMPED)) {
|
if (reader.isSet(LineReader.Option.HISTORY_TIMESTAMPED)) {
|
||||||
int idx = line.indexOf(':');
|
int idx = line.indexOf(':');
|
||||||
|
final String badHistoryFileSyntax = "Bad history file syntax! " +
|
||||||
|
"The history file `" + path + "` may be an older history: " +
|
||||||
|
"please remove it or use a different history file.";
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
throw new IllegalArgumentException("Bad history file syntax! " +
|
throw new IllegalArgumentException(badHistoryFileSyntax);
|
||||||
"The history file `" + path + "` may be an older history: " +
|
|
||||||
"please remove it or use a different history file.");
|
|
||||||
}
|
}
|
||||||
Instant time = Instant.ofEpochMilli(Long.parseLong(line.substring(0, idx)));
|
Instant time;
|
||||||
|
try {
|
||||||
|
time = Instant.ofEpochMilli(Long.parseLong(line.substring(0, idx)));
|
||||||
|
} catch (DateTimeException | NumberFormatException e) {
|
||||||
|
throw new IllegalArgumentException(badHistoryFileSyntax);
|
||||||
|
}
|
||||||
|
|
||||||
String unescaped = unescape(line.substring(idx + 1));
|
String unescaped = unescape(line.substring(idx + 1));
|
||||||
internalAdd(time, unescaped);
|
internalAdd(time, unescaped, checkDuplicates);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
internalAdd(Instant.now(), unescape(line));
|
internalAdd(Instant.now(), unescape(line), checkDuplicates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,29 +203,46 @@ public class DefaultHistory implements History {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(Path file, boolean incremental) throws IOException {
|
||||||
|
Path path = file != null ? file : getPath();
|
||||||
|
if (path != null && Files.exists(path)) {
|
||||||
|
path.toFile().delete();
|
||||||
|
}
|
||||||
|
internalWrite(path, incremental ? getLastLoaded(path) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void append(Path file, boolean incremental) throws IOException {
|
||||||
|
internalWrite(file != null ? file : getPath(),
|
||||||
|
incremental ? getLastLoaded(file) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save() throws IOException {
|
public void save() throws IOException {
|
||||||
Path path = getPath();
|
internalWrite(getPath(), getLastLoaded(getPath()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalWrite(Path path, int from) throws IOException {
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
Log.trace("Saving history to: ", path);
|
Log.trace("Saving history to: ", path);
|
||||||
Files.createDirectories(path.toAbsolutePath().getParent());
|
Files.createDirectories(path.toAbsolutePath().getParent());
|
||||||
// Append new items to the history file
|
// Append new items to the history file
|
||||||
try (BufferedWriter writer = Files.newBufferedWriter(path.toAbsolutePath(),
|
try (BufferedWriter writer = Files.newBufferedWriter(path.toAbsolutePath(),
|
||||||
StandardOpenOption.WRITE, StandardOpenOption.APPEND, StandardOpenOption.CREATE)) {
|
StandardOpenOption.WRITE, StandardOpenOption.APPEND, StandardOpenOption.CREATE)) {
|
||||||
for (Entry entry : items.subList(lastLoaded, items.size())) {
|
for (Entry entry : items.subList(from, items.size())) {
|
||||||
if (isPersistable(entry)) {
|
if (isPersistable(entry)) {
|
||||||
writer.append(format(entry));
|
writer.append(format(entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nbEntriesInFile += items.size() - lastLoaded;
|
incEntriesInFile(path, items.size() - from);
|
||||||
// If we are over 25% max size, trim history file
|
|
||||||
int max = getInt(reader, LineReader.HISTORY_FILE_SIZE, DEFAULT_HISTORY_FILE_SIZE);
|
int max = getInt(reader, LineReader.HISTORY_FILE_SIZE, DEFAULT_HISTORY_FILE_SIZE);
|
||||||
if (nbEntriesInFile > max + max / 4) {
|
if (getEntriesInFile(path) > max + max / 4) {
|
||||||
trimHistory(path, max);
|
trimHistory(path, max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastLoaded = items.size();
|
setLastLoaded(path, items.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void trimHistory(Path path, int max) throws IOException {
|
protected void trimHistory(Path path, int max) throws IOException {
|
||||||
@ -172,11 +268,14 @@ public class DefaultHistory implements History {
|
|||||||
}
|
}
|
||||||
Files.move(temp, path, StandardCopyOption.REPLACE_EXISTING);
|
Files.move(temp, path, StandardCopyOption.REPLACE_EXISTING);
|
||||||
// Keep items in memory
|
// Keep items in memory
|
||||||
internalClear();
|
if (isLineReaderHistory(path)) {
|
||||||
offset = allItems.get(0).index();
|
internalClear();
|
||||||
items.addAll(allItems);
|
offset = allItems.get(0).index();
|
||||||
lastLoaded = items.size();
|
items.addAll(allItems);
|
||||||
nbEntriesInFile = items.size();
|
setHistoryFileData(path, new HistoryFileData(items.size(), items.size()));
|
||||||
|
} else {
|
||||||
|
setEntriesInFile(path, allItems.size());
|
||||||
|
}
|
||||||
maybeResize();
|
maybeResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +293,7 @@ public class DefaultHistory implements History {
|
|||||||
private void internalClear() {
|
private void internalClear() {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
index = 0;
|
index = 0;
|
||||||
lastLoaded = 0;
|
historyFiles = new HashMap<>();
|
||||||
nbEntriesInFile = 0;
|
|
||||||
items.clear();
|
items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +400,18 @@ public class DefaultHistory implements History {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void internalAdd(Instant time, String line) {
|
protected void internalAdd(Instant time, String line) {
|
||||||
|
internalAdd(time, line, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void internalAdd(Instant time, String line, boolean checkDuplicates) {
|
||||||
Entry entry = new EntryImpl(offset + items.size(), time, line);
|
Entry entry = new EntryImpl(offset + items.size(), time, line);
|
||||||
|
if (checkDuplicates) {
|
||||||
|
for (Entry e: items) {
|
||||||
|
if (e.line().trim().equals(line.trim())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
items.add(entry);
|
items.add(entry);
|
||||||
maybeResize();
|
maybeResize();
|
||||||
}
|
}
|
||||||
@ -310,7 +419,9 @@ public class DefaultHistory implements History {
|
|||||||
private void maybeResize() {
|
private void maybeResize() {
|
||||||
while (size() > getInt(reader, LineReader.HISTORY_SIZE, DEFAULT_HISTORY_SIZE)) {
|
while (size() > getInt(reader, LineReader.HISTORY_SIZE, DEFAULT_HISTORY_SIZE)) {
|
||||||
items.removeFirst();
|
items.removeFirst();
|
||||||
lastLoaded--;
|
for (HistoryFileData hfd: historyFiles.values()) {
|
||||||
|
hfd.decLastLoaded();
|
||||||
|
}
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
index = size();
|
index = size();
|
||||||
@ -503,5 +614,46 @@ public class DefaultHistory implements History {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class HistoryFileData {
|
||||||
|
private int lastLoaded = 0;
|
||||||
|
private int entriesInFile = 0;
|
||||||
|
|
||||||
|
public HistoryFileData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public HistoryFileData(int lastLoaded, int entriesInFile) {
|
||||||
|
this.lastLoaded = lastLoaded;
|
||||||
|
this.entriesInFile = entriesInFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLastLoaded() {
|
||||||
|
return lastLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastLoaded(int lastLoaded) {
|
||||||
|
this.lastLoaded = lastLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decLastLoaded() {
|
||||||
|
lastLoaded = lastLoaded - 1;
|
||||||
|
if (lastLoaded < 0) {
|
||||||
|
lastLoaded = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEntriesInFile() {
|
||||||
|
return entriesInFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntriesInFile(int entriesInFile) {
|
||||||
|
this.entriesInFile = entriesInFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incEntriesInFile(int amount) {
|
||||||
|
entriesInFile = entriesInFile + amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* JLine 3.
|
* JLine 3.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* JLine 3.
|
* JLine 3.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal;
|
package jdk.internal.org.jline.terminal;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal;
|
package jdk.internal.org.jline.terminal;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal;
|
package jdk.internal.org.jline.terminal;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal;
|
package jdk.internal.org.jline.terminal;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal;
|
package jdk.internal.org.jline.terminal;
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ public interface Terminal extends Closeable, Flushable {
|
|||||||
*
|
*
|
||||||
* @return The output stream
|
* @return The output stream
|
||||||
*
|
*
|
||||||
* @see #writer();
|
* @see #writer()
|
||||||
*/
|
*/
|
||||||
OutputStream output();
|
OutputStream output();
|
||||||
|
|
||||||
@ -183,6 +183,11 @@ public interface Terminal extends Closeable, Flushable {
|
|||||||
|
|
||||||
void setAttributes(Attributes attr);
|
void setAttributes(Attributes attr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the size of the visible window
|
||||||
|
* @return the visible terminal size
|
||||||
|
* @see #getBufferSize()
|
||||||
|
*/
|
||||||
Size getSize();
|
Size getSize();
|
||||||
|
|
||||||
void setSize(Size size);
|
void setSize(Size size);
|
||||||
@ -195,6 +200,22 @@ public interface Terminal extends Closeable, Flushable {
|
|||||||
return getSize().getRows();
|
return getSize().getRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the size of the window buffer.
|
||||||
|
* Some terminals can be configured to have a buffer size
|
||||||
|
* larger than the visible window size and provide scroll bars.
|
||||||
|
* In such cases, this method should attempt to return the size
|
||||||
|
* of the whole buffer. The <code>getBufferSize()</code> method
|
||||||
|
* can be used to avoid wrapping when using the terminal in a line
|
||||||
|
* editing mode, while the {@link #getSize()} method should be
|
||||||
|
* used when using full screen mode.
|
||||||
|
* @return the terminal buffer size
|
||||||
|
* @see #getSize()
|
||||||
|
*/
|
||||||
|
default Size getBufferSize() {
|
||||||
|
return getSize();
|
||||||
|
}
|
||||||
|
|
||||||
void flush();
|
void flush();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal;
|
package jdk.internal.org.jline.terminal;
|
||||||
|
|
||||||
@ -33,9 +33,6 @@ import jdk.internal.org.jline.terminal.spi.Pty;
|
|||||||
import jdk.internal.org.jline.utils.Log;
|
import jdk.internal.org.jline.utils.Log;
|
||||||
import jdk.internal.org.jline.utils.OSUtils;
|
import jdk.internal.org.jline.utils.OSUtils;
|
||||||
|
|
||||||
import static jdk.internal.org.jline.terminal.impl.AbstractWindowsTerminal.TYPE_WINDOWS;
|
|
||||||
import static jdk.internal.org.jline.terminal.impl.AbstractWindowsTerminal.TYPE_WINDOWS_256_COLOR;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder class to create terminals.
|
* Builder class to create terminals.
|
||||||
*/
|
*/
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* 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.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
import jdk.internal.org.jline.terminal.Attributes;
|
import jdk.internal.org.jline.terminal.Attributes;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
@ -21,12 +21,10 @@ import jdk.internal.org.jline.utils.ShutdownHooks;
|
|||||||
import jdk.internal.org.jline.utils.Signals;
|
import jdk.internal.org.jline.utils.Signals;
|
||||||
import jdk.internal.org.jline.utils.WriterOutputStream;
|
import jdk.internal.org.jline.utils.WriterOutputStream;
|
||||||
|
|
||||||
import java.io.IOError;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -50,6 +48,7 @@ public abstract class AbstractWindowsTerminal extends AbstractTerminal {
|
|||||||
|
|
||||||
public static final String TYPE_WINDOWS = "windows";
|
public static final String TYPE_WINDOWS = "windows";
|
||||||
public static final String TYPE_WINDOWS_256_COLOR = "windows-256color";
|
public static final String TYPE_WINDOWS_256_COLOR = "windows-256color";
|
||||||
|
public static final String TYPE_WINDOWS_CONEMU = "windows-conemu";
|
||||||
public static final String TYPE_WINDOWS_VTP = "windows-vtp";
|
public static final String TYPE_WINDOWS_VTP = "windows-vtp";
|
||||||
|
|
||||||
public static final int ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
|
public static final int ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
|
||||||
@ -110,7 +109,7 @@ public abstract class AbstractWindowsTerminal extends AbstractTerminal {
|
|||||||
closer = this::close;
|
closer = this::close;
|
||||||
ShutdownHooks.add(closer);
|
ShutdownHooks.add(closer);
|
||||||
// ConEMU extended fonts support
|
// ConEMU extended fonts support
|
||||||
if (TYPE_WINDOWS_256_COLOR.equals(getType())
|
if (TYPE_WINDOWS_CONEMU.equals(getType())
|
||||||
&& !Boolean.getBoolean("org.jline.terminal.conemu.disable-activate")) {
|
&& !Boolean.getBoolean("org.jline.terminal.conemu.disable-activate")) {
|
||||||
writer.write("\u001b[9999E");
|
writer.write("\u001b[9999E");
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2019, the original author or authors.
|
* Copyright (c) 2002-2016, the original author or authors.
|
||||||
*
|
*
|
||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
@ -137,15 +137,12 @@ public class ExecPty extends AbstractPty implements Pty {
|
|||||||
}
|
}
|
||||||
String undef = System.getProperty("os.name").toLowerCase().startsWith("hp") ? "^-" : "undef";
|
String undef = System.getProperty("os.name").toLowerCase().startsWith("hp") ? "^-" : "undef";
|
||||||
for (ControlChar cchar : ControlChar.values()) {
|
for (ControlChar cchar : ControlChar.values()) {
|
||||||
if (attr.getControlChar(cchar) != current.getControlChar(cchar)) {
|
int v = attr.getControlChar(cchar);
|
||||||
|
if (v >= 0 && v != current.getControlChar(cchar)) {
|
||||||
String str = "";
|
String str = "";
|
||||||
int v = attr.getControlChar(cchar);
|
|
||||||
if (v == -1) { // Skip if ControlChar is <UNDEF>
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
commands.add(cchar.name().toLowerCase().substring(1));
|
commands.add(cchar.name().toLowerCase().substring(1));
|
||||||
if (cchar == ControlChar.VMIN || cchar == ControlChar.VTIME) {
|
if (cchar == ControlChar.VMIN || cchar == ControlChar.VTIME) {
|
||||||
commands.add(Integer.toBinaryString(v));
|
commands.add(Integer.toString(v));
|
||||||
}
|
}
|
||||||
else if (v == 0) {
|
else if (v == 0) {
|
||||||
commands.add(undef);
|
commands.add(undef);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl;
|
package jdk.internal.org.jline.terminal.impl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* JLine 3.
|
* JLine 3.
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* 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.terminal.spi;
|
package jdk.internal.org.jline.terminal.spi;
|
||||||
|
|
||||||
import jdk.internal.org.jline.terminal.Attributes;
|
import jdk.internal.org.jline.terminal.Attributes;
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* 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.terminal.spi;
|
package jdk.internal.org.jline.terminal.spi;
|
||||||
|
|
||||||
import jdk.internal.org.jline.terminal.Attributes;
|
import jdk.internal.org.jline.terminal.Attributes;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.spi;
|
package jdk.internal.org.jline.terminal.spi;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
@ -38,6 +38,14 @@ public abstract class AttributedCharSequence implements CharSequence {
|
|||||||
// cache the value here as we can't afford to get it each time
|
// cache the value here as we can't afford to get it each time
|
||||||
static final boolean DISABLE_ALTERNATE_CHARSET = Boolean.getBoolean(PROP_DISABLE_ALTERNATE_CHARSET);
|
static final boolean DISABLE_ALTERNATE_CHARSET = Boolean.getBoolean(PROP_DISABLE_ALTERNATE_CHARSET);
|
||||||
|
|
||||||
|
public void print(Terminal terminal) {
|
||||||
|
terminal.writer().print(toAnsi(terminal));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void println(Terminal terminal) {
|
||||||
|
terminal.writer().println(toAnsi(terminal));
|
||||||
|
}
|
||||||
|
|
||||||
public String toAnsi() {
|
public String toAnsi() {
|
||||||
return toAnsi(null);
|
return toAnsi(null);
|
||||||
}
|
}
|
||||||
@ -54,7 +62,8 @@ public abstract class AttributedCharSequence implements CharSequence {
|
|||||||
if (max_colors != null) {
|
if (max_colors != null) {
|
||||||
colors = max_colors;
|
colors = max_colors;
|
||||||
}
|
}
|
||||||
force256colors = AbstractWindowsTerminal.TYPE_WINDOWS_256_COLOR.equals(terminal.getType());
|
force256colors = AbstractWindowsTerminal.TYPE_WINDOWS_256_COLOR.equals(terminal.getType())
|
||||||
|
|| AbstractWindowsTerminal.TYPE_WINDOWS_CONEMU.equals(terminal.getType());
|
||||||
if (!DISABLE_ALTERNATE_CHARSET) {
|
if (!DISABLE_ALTERNATE_CHARSET) {
|
||||||
alternateIn = Curses.tputs(terminal.getStringCapability(Capability.enter_alt_charset_mode));
|
alternateIn = Curses.tputs(terminal.getStringCapability(Capability.enter_alt_charset_mode));
|
||||||
alternateOut = Curses.tputs(terminal.getStringCapability(Capability.exit_alt_charset_mode));
|
alternateOut = Curses.tputs(terminal.getStringCapability(Capability.exit_alt_charset_mode));
|
||||||
@ -293,7 +302,7 @@ public abstract class AttributedCharSequence implements CharSequence {
|
|||||||
if (col + w > start) {
|
if (col + w > start) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
begin++;
|
begin += Character.charCount(cp);
|
||||||
col += w;
|
col += w;
|
||||||
}
|
}
|
||||||
int end = begin;
|
int end = begin;
|
||||||
@ -305,7 +314,7 @@ public abstract class AttributedCharSequence implements CharSequence {
|
|||||||
if (col + w > stop) {
|
if (col + w > stop) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
end++;
|
end += Character.charCount(cp);
|
||||||
col += w;
|
col += w;
|
||||||
}
|
}
|
||||||
return subSequence(begin, end);
|
return subSequence(begin, end);
|
||||||
|
@ -4,12 +4,13 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
import java.security.InvalidParameterException;
|
import java.security.InvalidParameterException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -98,6 +99,10 @@ public class AttributedString extends AttributedCharSequence {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static AttributedString fromAnsi(String ansi, int tabs) {
|
public static AttributedString fromAnsi(String ansi, int tabs) {
|
||||||
|
return fromAnsi(ansi, Arrays.asList(tabs));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AttributedString fromAnsi(String ansi, List<Integer> tabs) {
|
||||||
if (ansi == null) {
|
if (ansi == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -24,7 +26,7 @@ public class AttributedStringBuilder extends AttributedCharSequence implements A
|
|||||||
private char[] buffer;
|
private char[] buffer;
|
||||||
private int[] style;
|
private int[] style;
|
||||||
private int length;
|
private int length;
|
||||||
private int tabs = 0;
|
private TabStops tabs = new TabStops(0);
|
||||||
private int lastLineLength = 0;
|
private int lastLineLength = 0;
|
||||||
private AttributedStyle current = AttributedStyle.DEFAULT;
|
private AttributedStyle current = AttributedStyle.DEFAULT;
|
||||||
|
|
||||||
@ -151,7 +153,7 @@ public class AttributedStringBuilder extends AttributedCharSequence implements A
|
|||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
char c = str.charAt(i);
|
char c = str.charAt(i);
|
||||||
int s = str.styleCodeAt(i) & ~current.getMask() | current.getStyle();
|
int s = str.styleCodeAt(i) & ~current.getMask() | current.getStyle();
|
||||||
if (tabs > 0 && c == '\t') {
|
if (tabs.defined() && c == '\t') {
|
||||||
insertTab(new AttributedStyle(s, 0));
|
insertTab(new AttributedStyle(s, 0));
|
||||||
} else {
|
} else {
|
||||||
ensureCapacity(length + 1);
|
ensureCapacity(length + 1);
|
||||||
@ -332,7 +334,7 @@ public class AttributedStringBuilder extends AttributedCharSequence implements A
|
|||||||
// This is not a SGR code, so ignore
|
// This is not a SGR code, so ignore
|
||||||
ansiState = 0;
|
ansiState = 0;
|
||||||
}
|
}
|
||||||
} else if (c == '\t' && tabs > 0) {
|
} else if (c == '\t' && tabs.defined()) {
|
||||||
insertTab(current);
|
insertTab(current);
|
||||||
} else {
|
} else {
|
||||||
ensureCapacity(length + 1);
|
ensureCapacity(length + 1);
|
||||||
@ -350,7 +352,7 @@ public class AttributedStringBuilder extends AttributedCharSequence implements A
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void insertTab(AttributedStyle s) {
|
protected void insertTab(AttributedStyle s) {
|
||||||
int nb = tabs - lastLineLength % tabs;
|
int nb = tabs.spaces(lastLineLength);
|
||||||
ensureCapacity(length + nb);
|
ensureCapacity(length + nb);
|
||||||
for (int i = 0; i < nb; i++) {
|
for (int i = 0; i < nb; i++) {
|
||||||
buffer[length] = ' ';
|
buffer[length] = ' ';
|
||||||
@ -373,13 +375,17 @@ public class AttributedStringBuilder extends AttributedCharSequence implements A
|
|||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public AttributedStringBuilder tabs(int tabsize) {
|
public AttributedStringBuilder tabs(int tabsize) {
|
||||||
if (length > 0) {
|
|
||||||
throw new IllegalStateException("Cannot change tab size after appending text");
|
|
||||||
}
|
|
||||||
if (tabsize < 0) {
|
if (tabsize < 0) {
|
||||||
throw new IllegalArgumentException("Tab size must be non negative");
|
throw new IllegalArgumentException("Tab size must be non negative");
|
||||||
}
|
}
|
||||||
this.tabs = tabsize;
|
return tabs(Arrays.asList(tabsize));
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttributedStringBuilder tabs(List<Integer> tabs) {
|
||||||
|
if (length > 0) {
|
||||||
|
throw new IllegalStateException("Cannot change tab size after appending text");
|
||||||
|
}
|
||||||
|
this.tabs = new TabStops(tabs);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,4 +399,60 @@ public class AttributedStringBuilder extends AttributedCharSequence implements A
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AttributedStringBuilder styleMatches(Pattern pattern, List<AttributedStyle> styles) {
|
||||||
|
Matcher matcher = pattern.matcher(this);
|
||||||
|
while (matcher.find()) {
|
||||||
|
for (int group = 0; group < matcher.groupCount(); group++) {
|
||||||
|
AttributedStyle s = styles.get(group);
|
||||||
|
for (int i = matcher.start(group + 1); i < matcher.end(group + 1); i++) {
|
||||||
|
style[i] = (style[i] & ~s.getMask()) | s.getStyle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TabStops {
|
||||||
|
private List<Integer> tabs = new ArrayList<>();
|
||||||
|
private int lastStop = 0;
|
||||||
|
private int lastSize = 0;
|
||||||
|
|
||||||
|
public TabStops(int tabs) {
|
||||||
|
this.lastSize = tabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabStops(List<Integer> tabs) {
|
||||||
|
this.tabs = tabs;
|
||||||
|
int p = 0;
|
||||||
|
for (int s: tabs) {
|
||||||
|
if (s <= p) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
lastStop = s;
|
||||||
|
lastSize = s - p;
|
||||||
|
p = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean defined() {
|
||||||
|
return lastSize > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int spaces(int lastLineLength) {
|
||||||
|
int out = 0;
|
||||||
|
if (lastLineLength >= lastStop) {
|
||||||
|
out = lastSize - (lastLineLength - lastStop) % lastSize;
|
||||||
|
} else {
|
||||||
|
for (int s: tabs) {
|
||||||
|
if (s > lastLineLength) {
|
||||||
|
out = s - lastLineLength;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
@ -74,8 +74,16 @@ public final class Curses {
|
|||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '\\':
|
case '\\':
|
||||||
ch = str.charAt(index++);
|
ch = str.charAt(index++);
|
||||||
if (ch >= '0' && ch <= '9') {
|
if (ch >= '0' && ch <= '7') {
|
||||||
throw new UnsupportedOperationException(); // todo
|
int val = ch - '0';
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
ch = str.charAt(index++);
|
||||||
|
if (ch < '0' || ch > '7') {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
val = val * 8 + (ch - '0');
|
||||||
|
}
|
||||||
|
out.append((char) val);
|
||||||
} else {
|
} else {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'e':
|
case 'e':
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
@ -492,7 +492,7 @@ public class Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void rawPrint(AttributedString str) {
|
void rawPrint(AttributedString str) {
|
||||||
terminal.writer().write(str.toAnsi(terminal));
|
str.print(terminal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int wcwidth(String str) {
|
public int wcwidth(String str) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
@ -578,6 +578,8 @@ public final class InfoCmp {
|
|||||||
int iVal;
|
int iVal;
|
||||||
if (val.startsWith("0x")) {
|
if (val.startsWith("0x")) {
|
||||||
iVal = Integer.parseInt(val.substring(2), 16);
|
iVal = Integer.parseInt(val.substring(2), 16);
|
||||||
|
} else if (val.startsWith("0")) {
|
||||||
|
iVal = Integer.parseInt(val.substring(1), 8);
|
||||||
} else {
|
} else {
|
||||||
iVal = Integer.parseInt(val);
|
iVal = Integer.parseInt(val);
|
||||||
}
|
}
|
||||||
@ -614,7 +616,7 @@ public final class InfoCmp {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
for (String s : Arrays.asList("dumb", "ansi", "xterm", "xterm-256color",
|
for (String s : Arrays.asList("dumb", "ansi", "xterm", "xterm-256color",
|
||||||
"windows", "windows-256color", "windows-vtp",
|
"windows", "windows-256color", "windows-conemu", "windows-vtp",
|
||||||
"screen", "screen-256color")) {
|
"screen", "screen-256color")) {
|
||||||
setDefaultInfoCmp(s, () -> loadDefaultInfoCmp(s));
|
setDefaultInfoCmp(s, () -> loadDefaultInfoCmp(s));
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -85,13 +86,16 @@ public final class Signals {
|
|||||||
|
|
||||||
private static Object doRegister(String name, Object handler) throws Exception {
|
private static Object doRegister(String name, Object handler) throws Exception {
|
||||||
Log.trace(() -> "Registering signal " + name + " with handler " + toString(handler));
|
Log.trace(() -> "Registering signal " + name + " with handler " + toString(handler));
|
||||||
if ("QUIT".equals(name) || "INFO".equals(name) && "9".equals(System.getProperty("java.specification.version"))) {
|
Class<?> signalClass = Class.forName("sun.misc.Signal");
|
||||||
|
Constructor<?> constructor = signalClass.getConstructor(String.class);
|
||||||
|
Object signal;
|
||||||
|
try {
|
||||||
|
signal = constructor.newInstance(name);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
Log.trace(() -> "Ignoring unsupported signal " + name);
|
Log.trace(() -> "Ignoring unsupported signal " + name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Class<?> signalClass = Class.forName("sun.misc.Signal");
|
|
||||||
Class<?> signalHandlerClass = Class.forName("sun.misc.SignalHandler");
|
Class<?> signalHandlerClass = Class.forName("sun.misc.SignalHandler");
|
||||||
Object signal = signalClass.getConstructor(String.class).newInstance(name);
|
|
||||||
return signalClass.getMethod("handle", signalClass, signalHandlerClass)
|
return signalClass.getMethod("handle", signalClass, signalHandlerClass)
|
||||||
.invoke(null, signal, handler);
|
.invoke(null, signal, handler);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
@ -24,9 +24,11 @@ public class Status {
|
|||||||
protected final AbstractTerminal terminal;
|
protected final AbstractTerminal terminal;
|
||||||
protected final boolean supported;
|
protected final boolean supported;
|
||||||
protected List<AttributedString> oldLines = Collections.emptyList();
|
protected List<AttributedString> oldLines = Collections.emptyList();
|
||||||
|
protected List<AttributedString> linesToRestore = Collections.emptyList();
|
||||||
protected int rows;
|
protected int rows;
|
||||||
protected int columns;
|
protected int columns;
|
||||||
protected boolean force;
|
protected boolean force;
|
||||||
|
protected boolean suspended = false;
|
||||||
|
|
||||||
public static Status getStatus(Terminal terminal) {
|
public static Status getStatus(Terminal terminal) {
|
||||||
return getStatus(terminal, true);
|
return getStatus(terminal, true);
|
||||||
@ -61,15 +63,34 @@ public class Status {
|
|||||||
this.force = true;
|
this.force = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void hardReset() {
|
||||||
|
if (suspended) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<AttributedString> lines = new ArrayList<>(oldLines);
|
||||||
|
update(null);
|
||||||
|
update(lines);
|
||||||
|
}
|
||||||
|
|
||||||
public void redraw() {
|
public void redraw() {
|
||||||
|
if (suspended) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
update(oldLines);
|
update(oldLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(List<AttributedString> lines) {
|
public void update(List<AttributedString> lines) {
|
||||||
|
if (!supported) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (lines == null) {
|
if (lines == null) {
|
||||||
lines = Collections.emptyList();
|
lines = Collections.emptyList();
|
||||||
}
|
}
|
||||||
if (!supported || (oldLines.equals(lines) && !force)) {
|
if (suspended) {
|
||||||
|
linesToRestore = new ArrayList<>(lines);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (oldLines.equals(lines) && !force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int nb = lines.size() - oldLines.size();
|
int nb = lines.size() - oldLines.size();
|
||||||
@ -82,10 +103,11 @@ public class Status {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
terminal.puts(Capability.save_cursor);
|
terminal.puts(Capability.save_cursor);
|
||||||
|
terminal.puts(Capability.cursor_address, rows - lines.size(), 0);
|
||||||
terminal.puts(Capability.clr_eos);
|
terminal.puts(Capability.clr_eos);
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
terminal.puts(Capability.cursor_address, rows - lines.size() + i, 0);
|
terminal.puts(Capability.cursor_address, rows - lines.size() + i, 0);
|
||||||
terminal.writer().write(lines.get(i).columnSubSequence(0, columns).toAnsi(terminal));
|
lines.get(i).columnSubSequence(0, columns).print(terminal);
|
||||||
}
|
}
|
||||||
terminal.puts(Capability.change_scroll_region, 0, rows - 1 - lines.size());
|
terminal.puts(Capability.change_scroll_region, 0, rows - 1 - lines.size());
|
||||||
terminal.puts(Capability.restore_cursor);
|
terminal.puts(Capability.restore_cursor);
|
||||||
@ -93,4 +115,27 @@ public class Status {
|
|||||||
oldLines = new ArrayList<>(lines);
|
oldLines = new ArrayList<>(lines);
|
||||||
force = false;
|
force = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void suspend() {
|
||||||
|
if (suspended) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
linesToRestore = new ArrayList<>(oldLines);
|
||||||
|
update(null);
|
||||||
|
suspended = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restore() {
|
||||||
|
if (!suspended) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
suspended = false;
|
||||||
|
update(linesToRestore);
|
||||||
|
linesToRestore = Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return oldLines.size();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.utils;
|
package jdk.internal.org.jline.utils;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# This software is distributable under the BSD license. See the terms of the
|
# This software is distributable under the BSD license. See the terms of the
|
||||||
# BSD license in the documentation provided with this software.
|
# BSD license in the documentation provided with this software.
|
||||||
#
|
#
|
||||||
# http://www.opensource.org/licenses/bsd-license.php
|
# https://opensource.org/licenses/BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
auto_left_margin, bw, bw
|
auto_left_margin, bw, bw
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# This software is distributable under the BSD license. See the terms of the
|
# This software is distributable under the BSD license. See the terms of the
|
||||||
# BSD license in the documentation provided with this software.
|
# BSD license in the documentation provided with this software.
|
||||||
#
|
#
|
||||||
# http://www.opensource.org/licenses/bsd-license.php
|
# https://opensource.org/licenses/BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
black
|
black
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
dumb-color|80-column dumb tty with 256 coors,
|
||||||
|
am,
|
||||||
|
colors#256, cols#80,
|
||||||
|
bel=^G, cr=^M, cud1=^J, ind=^J,
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* JLine 3.
|
* JLine 3.
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
windows-conemu|conemu windows terminal,
|
||||||
|
am, mc5i, mir, msgr,
|
||||||
|
colors#256, cols#80, it#8, lines#24, ncv#3, pairs#64,
|
||||||
|
bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
|
||||||
|
cr=^M, cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
|
||||||
|
cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
|
||||||
|
cuu=\E[%p1%dA, cuu1=\E[A,
|
||||||
|
il=\E[%p1%dL, il1=\E[L,
|
||||||
|
dl=\E[%p1%dM, dl1=\E[M,
|
||||||
|
ech=\E[%p1%dX,
|
||||||
|
el=\E[K, ed=\E[2K,
|
||||||
|
el1=\E[1K, home=\E[H, hpa=\E[%i%p1%dG,
|
||||||
|
ind=^J,
|
||||||
|
invis=\E[8m, kbs=^H, kcbt=\E[Z,
|
||||||
|
kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
|
||||||
|
khome=\E[H,
|
||||||
|
op=\E[39;49m,
|
||||||
|
rev=\E[7m,
|
||||||
|
rmacs=\E[10m, rmpch=\E[10m, rmso=\E[m, rmul=\E[m,
|
||||||
|
setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
|
||||||
|
sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
|
||||||
|
sgr0=\E[0;10m,
|
||||||
|
smso=\E[7m,
|
||||||
|
smul=\E[4m,
|
||||||
|
kdch1=\E[3~, kich1=\E[2~, kend=\E[4~, knp=\E[6~, kpp=\E[5~,
|
||||||
|
kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~,
|
||||||
|
kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
|
@ -1,4 +1,4 @@
|
|||||||
## JLine v3.9.0
|
## JLine v3.12.1
|
||||||
|
|
||||||
### JLine License
|
### JLine License
|
||||||
<pre>
|
<pre>
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2002-2018, 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.terminal.impl.jna;
|
package jdk.internal.org.jline.terminal.impl.jna;
|
||||||
|
|
||||||
import jdk.internal.org.jline.terminal.Attributes;
|
import jdk.internal.org.jline.terminal.Attributes;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This software is distributable under the BSD license. See the terms of the
|
* This software is distributable under the BSD license. See the terms of the
|
||||||
* BSD license in the documentation provided with this software.
|
* BSD license in the documentation provided with this software.
|
||||||
*
|
*
|
||||||
* http://www.opensource.org/licenses/bsd-license.php
|
* https://opensource.org/licenses/BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
package jdk.internal.org.jline.terminal.impl.jna.win;
|
package jdk.internal.org.jline.terminal.impl.jna.win;
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user