Skip to content

Commit

Permalink
Add support for raw ansi styling to the StyleResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jan 29, 2018
1 parent 9d73f85 commit ae77c8f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions terminal/src/main/java/org/jline/utils/StyleResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ private AttributedStyle apply(AttributedStyle style, final String spec) {
style = applyReference(style, item);
} else if (item.contains(":")) {
style = applyColor(style, item);
} else if (item.matches("[0-9]+(;[0-9]+)*")) {
style = applyAnsi(style, item);
} else {
style = applyNamed(style, item);
}
Expand All @@ -170,6 +172,17 @@ private AttributedStyle apply(AttributedStyle style, final String spec) {
return style;
}

private AttributedStyle applyAnsi(final AttributedStyle style, final String spec) {
if (log.isLoggable(Level.FINEST)) {
log.finest("Apply-ansi: " + spec);
}

return new AttributedStringBuilder()
.style(style)
.ansiAppend("\033[" + spec + "m")
.style();
}

/**
* Apply source-referenced named style.
*/
Expand Down

0 comments on commit ae77c8f

Please sign in to comment.