diff --git a/builtins/pom.xml b/builtins/pom.xml
index f0eb830bc..94bd6ed97 100644
--- a/builtins/pom.xml
+++ b/builtins/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline-builtins
diff --git a/builtins/src/main/java/org/jline/builtins/Nano.java b/builtins/src/main/java/org/jline/builtins/Nano.java
index 447a7c309..0bf5131ef 100644
--- a/builtins/src/main/java/org/jline/builtins/Nano.java
+++ b/builtins/src/main/java/org/jline/builtins/Nano.java
@@ -1419,16 +1419,16 @@ void replaceFromCursor(int chars, String string) {
}
}
- protected static class SyntaxHighlighter {
+ public static class SyntaxHighlighter {
private List rules = new ArrayList<>();
private int ruleStartId = 0;
private SyntaxHighlighter() {}
- public static SyntaxHighlighter build(List syntaxFiles, String file, String syntaxName) {
+ protected static SyntaxHighlighter build(List syntaxFiles, String file, String syntaxName) {
SyntaxHighlighter out = new SyntaxHighlighter();
List defaultRules = new ArrayList<>();
- if (file != null && (syntaxName == null || (syntaxName != null && !syntaxName.equals("none")))) {
+ if (syntaxName == null || (syntaxName != null && !syntaxName.equals("none"))) {
for (Path p: syntaxFiles) {
NanorcParser parser = new NanorcParser(p, syntaxName, file);
try {
@@ -1447,6 +1447,46 @@ public static SyntaxHighlighter build(List syntaxFiles, String file, Strin
return out;
}
+ /**
+ * Build SyntaxHighlighter
+ *
+ * @param nanorc Path of nano config file jnanorc
+ * @param syntaxName syntax name e.g 'Java'
+ * @return SyntaxHighlighter
+ */
+ public static SyntaxHighlighter build(Path nanorc, String syntaxName) {
+ SyntaxHighlighter out = new SyntaxHighlighter();
+ List syntaxFiles = new ArrayList<>();
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(nanorc.toFile()));
+ String line = reader.readLine();
+ while (line != null) {
+ line = line.trim();
+ if (line.length() > 0 && !line.startsWith("#")) {
+ List parts = Parser.split(line);
+ if (parts.get(0).equals("include")) {
+ if (parts.get(1).contains("*") || parts.get(1).contains("?")) {
+ PathMatcher pathMatcher = FileSystems
+ .getDefault().getPathMatcher("glob:" + parts.get(1));
+ Files.find(
+ Paths.get(new File(parts.get(1)).getParent()),
+ Integer.MAX_VALUE,
+ (path, f) -> pathMatcher.matches(path))
+ .forEach(p -> syntaxFiles.add(p));
+ } else {
+ syntaxFiles.add(Paths.get(parts.get(1)));
+ }
+ }
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ out = build(syntaxFiles, null, syntaxName);
+ } catch (Exception e) {
+ }
+ return out;
+ }
+
private void addRules(List rules) {
this.rules.addAll(rules);
}
@@ -1455,6 +1495,10 @@ public void reset() {
ruleStartId = 0;
}
+ public AttributedString highlight(String string) {
+ return highlight(new AttributedString(string));
+ }
+
public AttributedString highlight(AttributedStringBuilder asb) {
return highlight(asb.toAttributedString());
}
@@ -1584,6 +1628,10 @@ private static class NanorcParser {
private List highlightRules = new ArrayList<>();
private String syntaxName;
+ public NanorcParser(Path file, String name) {
+ this(file, name, null);
+ }
+
public NanorcParser(Path file, String name, String target) {
this.file = file.toFile();
this.name = name;
@@ -1686,6 +1734,26 @@ private void addHighlightRule(List parts, boolean caseInsensitive) {
if (bcolor != null) {
style = style.background(bcolor);
}
+ // extended nanorc..
+ if (styleStrings.length > 2) {
+ if (styleStrings[2].equals("blink")) {
+ style = style.blink();
+ } else if (styleStrings[2].equals("bold")) {
+ style = style.bold();
+ } else if (styleStrings[2].equals("conceal")) {
+ style = style.conceal();
+ } else if (styleStrings[2].equals("faint")) {
+ style = style.faint();
+ } else if (styleStrings[2].equals("hidden")) {
+ style = style.hidden();
+ } else if (styleStrings[2].equals("inverse")) {
+ style = style.inverse();
+ } else if (styleStrings[2].equals("italic")) {
+ style = style.italic();
+ } else if (styleStrings[2].equals("underline")) {
+ style = style.underline();
+ }
+ }
if (HighlightRule.evalRuleType(parts) == HighlightRule.RuleType.PATTERN) {
for (int i = 2; i < parts.size(); i++) {
diff --git a/demo/pom.xml b/demo/pom.xml
index b481b042d..304752e25 100644
--- a/demo/pom.xml
+++ b/demo/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline-demo
diff --git a/jline/pom.xml b/jline/pom.xml
index 4aefa7fbb..ab16a06c0 100644
--- a/jline/pom.xml
+++ b/jline/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline
@@ -58,6 +58,46 @@
jsr305
true
+
+ org.jline
+ jline-terminal
+ provided
+
+
+ org.jline
+ jline-terminal-jansi
+ provided
+
+
+ org.jline
+ jline-terminal-jna
+ provided
+
+
+ org.jline
+ jline-reader
+ provided
+
+
+ org.jline
+ jline-builtins
+ provided
+
+
+ org.jline
+ jline-remote-ssh
+ provided
+
+
+ org.jline
+ jline-remote-telnet
+ provided
+
+
+ org.jline
+ jline-style
+ provided
+
diff --git a/pom.xml b/pom.xml
index 52f152264..5e3cbac19 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
jline-parent
JLine Parent
JLine
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
pom
@@ -420,7 +420,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.0.0
+ 3.1.1
-Xdoclint:none
-notimestamp
diff --git a/reader/pom.xml b/reader/pom.xml
index 7609abe40..d2f80e4b5 100644
--- a/reader/pom.xml
+++ b/reader/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline-reader
diff --git a/reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.java b/reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.java
index 1b1f0a0c8..bbccecb3e 100644
--- a/reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.java
+++ b/reader/src/main/java/org/jline/reader/impl/history/DefaultHistory.java
@@ -344,7 +344,11 @@ private String format(Entry entry) {
}
public String get(final int index) {
- return items.get(index - offset).line();
+ int idx = index - offset;
+ if (idx >= items.size() || idx < 0) {
+ throw new IllegalArgumentException("IndexOutOfBounds: Index:" + idx +", Size:" + items.size());
+ }
+ return items.get(idx).line();
}
@Override
diff --git a/remote-ssh/pom.xml b/remote-ssh/pom.xml
index 496f6a94b..b597602b2 100644
--- a/remote-ssh/pom.xml
+++ b/remote-ssh/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline-remote-ssh
diff --git a/remote-telnet/pom.xml b/remote-telnet/pom.xml
index e7c0a42dd..06a76be56 100644
--- a/remote-telnet/pom.xml
+++ b/remote-telnet/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline-remote-telnet
diff --git a/style/pom.xml b/style/pom.xml
index b4a62adaa..7b1efcffe 100644
--- a/style/pom.xml
+++ b/style/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline-style
diff --git a/terminal-jansi/pom.xml b/terminal-jansi/pom.xml
index 2e6daef6e..a96f13477 100644
--- a/terminal-jansi/pom.xml
+++ b/terminal-jansi/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline-terminal-jansi
diff --git a/terminal-jna/pom.xml b/terminal-jna/pom.xml
index 08fa8f189..7b6fe4003 100644
--- a/terminal-jna/pom.xml
+++ b/terminal-jna/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline-terminal-jna
diff --git a/terminal/pom.xml b/terminal/pom.xml
index 90e6a1011..b5f3d2f47 100644
--- a/terminal/pom.xml
+++ b/terminal/pom.xml
@@ -16,7 +16,7 @@
org.jline
jline-parent
- 3.13.1-SNAPSHOT
+ 3.13.2-SNAPSHOT
jline-terminal
diff --git a/terminal/src/main/java/org/jline/utils/InfoCmp.java b/terminal/src/main/java/org/jline/utils/InfoCmp.java
index 8ba47198d..eb567b972 100644
--- a/terminal/src/main/java/org/jline/utils/InfoCmp.java
+++ b/terminal/src/main/java/org/jline/utils/InfoCmp.java
@@ -576,7 +576,9 @@ public static void parseInfoCmp(
String key = cap.substring(0, index);
String val = cap.substring(index + 1);
int iVal;
- if (val.startsWith("0x")) {
+ if ("0".equals(val)) {
+ iVal = 0;
+ } else if (val.startsWith("0x")) {
iVal = Integer.parseInt(val.substring(2), 16);
} else if (val.startsWith("0")) {
iVal = Integer.parseInt(val.substring(1), 8);
diff --git a/terminal/src/test/java/org/jline/utils/InfoCmpTest.java b/terminal/src/test/java/org/jline/utils/InfoCmpTest.java
index 8cf71544a..84861edad 100644
--- a/terminal/src/test/java/org/jline/utils/InfoCmpTest.java
+++ b/terminal/src/test/java/org/jline/utils/InfoCmpTest.java
@@ -59,10 +59,11 @@ public void testInfoCmpWithHexa() {
Map strings = new HashMap<>();
String infocmp = "xterm-256color|xterm with 256 colors,\n" +
"\tam, bce, ccc, km, mc5i, mir, msgr, npc, xenl,\n" +
- "\tcolors#0x100, cols#80, it#8, lines#24, pairs#0x7fff,\n" +
+ "\tcolors#0x100, cols#010, it#0, lines#24, pairs#0x7fff,\n" +
"\tacsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,\n" +
"\tbel=^G, blink=\\E[5m, bold=\\E[1m, cbt=\\E[Z, civis=\\E[?25l\n";
InfoCmp.parseInfoCmp(infocmp, bools, ints, strings);
+ assertEquals(8, (int) ints.get(Capability.columns));
assertEquals(0x100, (int) ints.get(Capability.max_colors));
assertEquals(0x7fff, (int) ints.get(Capability.max_pairs));
}