Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#186 Allow rendering more complex sgrs #188

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ private boolean processEscapeCommand(ArrayList<Object> options, int command) thr
processSetForegroundColor(value - 90, true);
} else if (100 <= value && value <= 107) {
processSetBackgroundColor(value - 100, true);
} else if ((value == 38 || value == 48) && count == 1) {
} else if ((value == 38 || value == 48)) {
if (!optionsIterator.hasNext()) {
continue;
}
// extended color like `esc[38;5;<index>m` or `esc[38;2;<r>;<g>;<b>m`
int arg2or5 = getNextOptionInt(optionsIterator);
if (arg2or5 == 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,29 @@ public void canRenderSgrFaintIntensity() {
@Test
public void canHandleSgrsWithMultipleOptions() {
final String input = "\u001B[33mbanana_1 |\u001B[0m 19:59:14.353\u001B[0;38m [debug] Lager installed handler {lager_file_backend,\"banana.log\"} into lager_event\u001B[0m\n";

final Consumer<PrintStream> inputProvider = stream -> stream.println(input);

assertCorrectOutput(
Collections.singletonList("<span style=\"color: #CDCD00;\">banana_1 |</span> 19:59:14.353 [debug] Lager installed handler {lager_file_backend,\"banana.log\"} into lager_event"),
Collections.singletonList(ESC),
inputProvider
);
}

@Issue("186")
@Test
public void canHandleSgrsWithRgbColors() {
final String input = "\u001B[1;38;5;4m[fe1.k8sf.atom.us-west-2 ]\u001B[0m\n\u001B[1;38;5;13m[fe1b.k8sf.atom.us-east-2]\u001B[0m";
final Consumer<PrintStream> inputProvider = stream -> stream.println(input);
assertCorrectOutput(
Arrays.asList(
"<b><span style=\"color: #1E90FF;\">[fe1.k8sf.atom.us-west-2 ]</span></b>",
"<b><span style=\"color: #FF00FF;\">[fe1b.k8sf.atom.us-east-2]</span></b>"
),
Collections.singletonList(ESC),
inputProvider
);
}

private static String csi(CSI csi) {
return csi("", csi);
}
Expand Down