Skip to content

Commit

Permalink
fixed ttop highlighted help
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Feb 24, 2019
1 parent 0b61777 commit acb9342
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions builtins/src/main/java/org/jline/builtins/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ public static void keymap(LineReader reader,
" -e Select emacs keymap and bind it to main",
" -l List existing keymap names",
" -p List bindings which have given key sequence as a a prefix",
" -r Unbind specified in-strings",
" -s Bind each in-string to each out-string",
" -r Unbind specified in-strings ",
" -s Bind each in-string to each out-string ",
" -v Select viins keymap and bind it to main",
};
Options opt = Options.compile(usage).parse(argv);
Expand Down
9 changes: 4 additions & 5 deletions builtins/src/main/java/org/jline/builtins/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,10 @@ public String toString() {
public static class HelpPrinter {
private static HelpPrinter instance = new HelpPrinter();

private final Pattern patternTitle = Pattern.compile("(Usage):\\b");
private final Pattern patternCommand = Pattern.compile("(^\\s*)([a-z]+){1}\\b");
private final Pattern patternCommand = Pattern.compile("(^\\s*)([a-z]+[a-z-]*){1}\\b");
private final Pattern patternArgument = Pattern.compile("(\\[|\\s|=)([A-Za-z]+[A-Za-z_-]*){1}\\b");
private final Pattern patternArgumentInComment = Pattern.compile("(\\s)([a-z]+[-]+[a-z]+){1}\\b");
private final Pattern patternOption = Pattern.compile("(\\s|\\[)(-\\?|[-]{1,2}[\\?A-Za-z-]+\\b){1}");
private final Pattern patternArgumentInComment = Pattern.compile("(\\s)([a-z]+[-]+[a-z]+|[A-Z_]{2,}){1}(\\s)");
private final Pattern patternOption = Pattern.compile("(\\s|\\[)(-\\?|[-]{1,2}[A-Za-z-]+\\b){1}");
private final String title = "Usage";
private final String ansiReset = "\033[0m";
private String ansi4title = "\033[34;1m";
Expand Down Expand Up @@ -598,7 +597,7 @@ private String highlightComment(String comment) {
}
matcher = patternArgumentInComment.matcher(comment);
if (matcher.find()) {
comment = matcher.replaceAll("$1" + ansi4argument + "$2" + ansiReset);
comment = matcher.replaceAll("$1" + ansi4argument + "$2" + ansiReset + "$3");
}
return comment;
}
Expand Down
16 changes: 8 additions & 8 deletions builtins/src/test/java/org/jline/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.jline.builtins.Completers.CompletionData;
import org.jline.builtins.Completers.TreeCompleter;
import org.jline.builtins.Options.HelpPrinter;
import org.jline.builtins.TTop;
import org.jline.keymap.KeyMap;
import org.jline.reader.*;
import org.jline.reader.impl.DefaultParser;
Expand Down Expand Up @@ -413,8 +414,7 @@ else if ("less".equals(pl.word())) {
argv);
}
else if ("history".equals(pl.word())) {
Commands.history(reader, System.out, System.err,
argv);
Commands.history(reader, System.out, System.err, argv);
}
else if ("complete".equals(pl.word())) {
Commands.complete(reader, System.out, System.err,
Expand All @@ -427,16 +427,16 @@ else if ("widget".equals(pl.word())) {
argv);
}
else if ("keymap".equals(pl.word())) {
Commands.keymap(reader, System.out, System.err,
argv);
Commands.keymap(reader, System.out, System.err, argv);
}
else if ("setopt".equals(pl.word())) {
Commands.setopt(reader, System.out, System.err,
argv);
Commands.setopt(reader, System.out, System.err, argv);
}
else if ("unsetopt".equals(pl.word())) {
Commands.unsetopt(reader, System.out, System.err,
argv);
Commands.unsetopt(reader, System.out, System.err, argv);
}
else if ("ttop".equals(pl.word())) {
TTop.ttop(terminal, System.out, System.err, argv);
}
}
}
Expand Down

0 comments on commit acb9342

Please sign in to comment.