private static void applyStyle(AttributedStringBuilder sb, Map<String, String> colors, String type) { String col = colors.get(type); sb.style(AttributedStyle.DEFAULT); if (col != null && !col.isEmpty()) { sb.appendAnsi("\033[" + col + "m"); } }
private static void applyStyle(AttributedStringBuilder sb, Map<String, String> colors, String type) { String col = colors.get(type); sb.style(AttributedStyle.DEFAULT); if (col != null && !col.isEmpty()) { sb.appendAnsi("\033[" + col + "m"); } }
/** * Evaluate expression and append to buffer. * * @param buff the buffer to append to * @param expression the expression to evaluate */ public void evaluate(final AttributedStringBuilder buff, final String expression) { requireNonNull(buff); requireNonNull(expression); String translated = InterpolationHelper.substVars(expression, this::style, false); buff.appendAnsi(translated); }
public static List<String> splitLines(String text, int maxLength, int tabs) throws IOException { AttributedStringBuilder sb = new AttributedStringBuilder(); sb.tabs(tabs); sb.appendAnsi(text); return sb.columnSplitLength(maxLength) .stream() .map(AttributedString::toAnsi) .collect(Collectors.toList()); }
public static List<String> splitLines(String text, int maxLength, int tabs) throws IOException { AttributedStringBuilder sb = new AttributedStringBuilder(); sb.tabs(tabs); sb.appendAnsi(text); return sb.columnSplitLength(maxLength) .stream() .map(AttributedString::toAnsi) .collect(Collectors.toList()); }
public static int length(String text, int tabs) throws IOException { AttributedStringBuilder sb = new AttributedStringBuilder(); sb.tabs(tabs); sb.appendAnsi(text); return sb.columnLength(); }
public static int length(String text, int tabs) throws IOException { AttributedStringBuilder sb = new AttributedStringBuilder(); sb.tabs(tabs); sb.appendAnsi(text); return sb.columnLength(); }
public String readLine() throws IOException { if (lines.isEmpty()) { String line = reader.readLine(); if (line == null) { return null; } if (line.isEmpty()) { lines.add(""); } else { builder.setLength(0); builder.appendAnsi(line); if (builder.length() > 0) { builder.style(builder.styleAt(builder.length() - 1)); } AttributedString str = builder.columnSubSequence(begin, end); str.columnSplitLength(maxLength) .stream() .map(AttributedString::toAnsi) .forEach(lines::add); } } return lines.remove(0); }
public String readLine() throws IOException { if (lines.isEmpty()) { String line = reader.readLine(); if (line == null) { return null; } if (line.isEmpty()) { lines.add(""); } else { builder.setLength(0); builder.appendAnsi(line); if (builder.length() > 0) { builder.style(builder.styleAt(builder.length() - 1)); } AttributedString str = builder.columnSubSequence(begin, end); str.columnSplitLength(maxLength) .stream() .map(AttributedString::toAnsi) .forEach(lines::add); } } return lines.remove(0); }
public static String substring(String text, int begin, int end, int tabs) throws IOException { AttributedStringBuilder sb = new AttributedStringBuilder(); sb.tabs(tabs); sb.appendAnsi(text); return sb.columnSubSequence(begin, end).toAnsi(); }
public static String substring(String text, int begin, int end, int tabs) throws IOException { AttributedStringBuilder sb = new AttributedStringBuilder(); sb.tabs(tabs); sb.appendAnsi(text); return sb.columnSubSequence(begin, end).toAnsi(); }