/** Parses the specified comma-separated sequence of style descriptors and returns the associated * styles. For each markup, strings starting with {@code "bg("} are delegated to * {@link #bg(String)}, others are delegated to {@link #bg(String)}. * @param commaSeparatedCodes one or more descriptors, e.g. {@code "bg(blue),underline,red"} * @return an array with all styles for the specified descriptors */ public static IStyle[] parse(String commaSeparatedCodes) { String[] codes = commaSeparatedCodes.split(","); IStyle[] styles = new IStyle[codes.length]; for(int i = 0; i < codes.length; ++i) { if (codes[i].toLowerCase(ENGLISH).startsWith("fg(")) { int end = codes[i].indexOf(')'); styles[i] = Style.fg(codes[i].substring(3, end < 0 ? codes[i].length() : end)); } else if (codes[i].toLowerCase(ENGLISH).startsWith("bg(")) { int end = codes[i].indexOf(')'); styles[i] = Style.bg(codes[i].substring(3, end < 0 ? codes[i].length() : end)); } else { styles[i] = Style.fg(codes[i]); } } return styles; } }
/** Parses the specified comma-separated sequence of style descriptors and returns the associated * styles. For each markup, strings starting with {@code "bg("} are delegated to * {@link #bg(String)}, others are delegated to {@link #bg(String)}. * @param commaSeparatedCodes one or more descriptors, e.g. {@code "bg(blue),underline,red"} * @return an array with all styles for the specified descriptors */ public static IStyle[] parse(String commaSeparatedCodes) { String[] codes = commaSeparatedCodes.split(","); IStyle[] styles = new IStyle[codes.length]; for(int i = 0; i < codes.length; ++i) { if (codes[i].toLowerCase(ENGLISH).startsWith("fg(")) { int end = codes[i].indexOf(')'); styles[i] = Style.fg(codes[i].substring(3, end < 0 ? codes[i].length() : end)); } else if (codes[i].toLowerCase(ENGLISH).startsWith("bg(")) { int end = codes[i].indexOf(')'); styles[i] = Style.bg(codes[i].substring(3, end < 0 ? codes[i].length() : end)); } else { styles[i] = Style.fg(codes[i]); } } return styles; } }