AttributedCharSequence implements CharSequence { public String toAnsi() { return toAnsi(null); }  void print(Terminal terminal); void println(Terminal terminal); String toAnsi(); String toAnsi(Terminal terminal); String toAnsi(int colors, boolean force256colors); String toAnsi(int colors, boolean force256colors, String altIn, String altOut); @Deprecated static int rgbColor(int col); @Deprecated static int roundColor(int col, int max); @Deprecated static int roundRgbColor(int r, int g, int b, int max); abstract AttributedStyle styleAt(int index); boolean isHidden(int index); int runStart(int index); int runLimit(int index); @Override abstract AttributedString subSequence(int start, int end); AttributedString substring(int start, int end); @Override char charAt(int index); int codePointAt(int index); boolean contains(char c); int codePointBefore(int index); int codePointCount(int index, int length); int columnLength(); AttributedString columnSubSequence(int start, int stop); List<AttributedString> columnSplitLength(int columns); List<AttributedString> columnSplitLength(int columns, boolean includeNewlines, boolean delayLineWrap); @Override String toString(); AttributedString toAttributedString();  }
@Test public void testUnderline() throws IOException { AttributedString as = AttributedString.fromAnsi("\33[38;5;0m\33[48;5;15mtest\33[0m"); assertEquals("\33[38;5;0;48;5;15mtest\33[0m", as.toAnsi(256, true)); }
@Test public void testBold() throws IOException { ExternalTerminal terminal = new ExternalTerminal( "my term", "windows", new ByteArrayInputStream(new byte[0]), new ByteArrayOutputStream(), StandardCharsets.UTF_8); assertEquals("\33[34;47;1mblue on white\33[31;42;1mred on green\33[0m", AttributedString.fromAnsi("\33[34m\33[47m\33[1mblue on white\33[0m\33[31m\33[42m\33[1mred on green\33[0m").toAnsi(terminal)); assertEquals("\33[32;1mtest\33[0m", AttributedString.fromAnsi("\33[32m\33[1mtest\33[0m").toAnsi(terminal)); assertEquals("\33[32;1mtest\33[0m", AttributedString.fromAnsi("\33[1m\33[32mtest\33[0m").toAnsi(terminal)); }