fusesource / jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
http://fusesource.github.io/jansi/
Apache License 2.0
1.11k stars 140 forks source link

HtmlAnsiOutputStream removed from latest Jansi? #210

Closed Osiris-Team closed 3 years ago

Osiris-Team commented 3 years ago

Is it ever coming back, or should I create a new one by myself?

gnodet commented 3 years ago

There's no plan to bring it back at the moment, I don't think it's used enough.

Osiris-Team commented 3 years ago

@gnodet Im planning to write something for converting ansi to html. Is there a way you would recommend how to tackle that?

Osiris-Team commented 3 years ago

@gnodet I was thinking of something like this:

public class UtilsAnsiHtml {

    public String convertAnsiToHtml(Ansi ansi) throws IOException {
        StringBuilder builder = new StringBuilder();
        builder.append("<ansi>");
        String ansiString = ansi.toString();
        for (int i = 0; i < ansiString.length(); i++) {
            int currentCodePoint = ansiString.codePointAt(i);
            // TODO parse ansi
        }
        builder.append("</ansi>");
        return builder.toString();
    }

}

Then go through each char of the ansi string and convert it to html...

gnodet commented 3 years ago

@Osiris-Team I guess you should be able to adapt the HtmlAnsiOutputStream (https://github.com/fusesource/jansi/blob/jansi-1.x/jansi/src/main/java/org/fusesource/jansi/HtmlAnsiOutputStream.java) to the recent AnsiOutputStream from 2.x.

Osiris-Team commented 3 years ago

@Osiris-Team I guess you should be able to adapt the HtmlAnsiOutputStream (https://github.com/fusesource/jansi/blob/jansi-1.x/jansi/src/main/java/org/fusesource/jansi/HtmlAnsiOutputStream.java) to the recent AnsiOutputStream from 2.x.

Yeah guess that should be easier haha

Osiris-Team commented 3 years ago

@gnodet What is the difference between this: https://github.com/fusesource/jansi/blob/b7c7fbda5b19d5ad9f761e88bb06da8177cdc83e/src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java#L88 and this: https://github.com/fusesource/jansi/blob/b7c7fbda5b19d5ad9f761e88bb06da8177cdc83e/src/main/java/org/fusesource/jansi/io/AnsiOutputStream.java#L78 ?

Osiris-Team commented 3 years ago

@gnodet https://github.com/fusesource/jansi/pull/212