public Screenable append(Style style) throws IOException { if (reader == null) { reader = new ScreenBuffer(); } reader.append(style); return this; }
public ScreenBuffer append(Object o) throws NullPointerException { if (o == null) { throw new NullPointerException("No null accepted"); } if (o instanceof ScreenBuffer) { append((ScreenBuffer)o); } else if (o instanceof Style) { append((Style)o); } else if (o instanceof CharSequence){ append(((CharSequence)o)); } else if (o instanceof CLS) { cls(); } else { append(o.toString()); } return this; }
public void flush() throws IOException { buffer.flush(); } });
public Screenable cls() throws IOException { if (reader == null) { reader = new ScreenBuffer(); } reader.cls(); return this; }
@Override public Screenable append(CharSequence csq, int start, int end) throws IOException { buffer.append(csq, start, end); return this; }
public void testAdaptToChunk() { lifeCycle.bindClass("producer", Commands.ProduceValue.class); lifeCycle.bindClass("consumer", Commands.ConsumeChunk.class); Commands.list.clear(); assertOk("producer | consumer"); ScreenBuffer buffer = new ScreenBuffer().append(Commands.list); assertEquals("<value>abc</value> \n", buffer.toString()); }
@Override public Screenable cls() throws IOException { buffer.cls(); return this; }
public List<String> render(final LineReader renderer, final int width) { ArrayList<String> result = new ArrayList<String>(); while (renderer.hasLine()) { final ScreenBuffer buffer = new ScreenBuffer(); renderer.renderLine(new RenderAppendable(new ScreenContext() { public int getWidth() { StringBuilder sb = new StringBuilder(); try { buffer.format(Format.ANSI, sb);
@Override public String toString() { StringBuilder sb = new StringBuilder(); try { format(Format.TEXT, sb); } catch (IOException ignore) { } return sb.toString(); } }
final ScreenBuffer buffer = new ScreenBuffer(processContext);
private String execute(Command<?> command, String... args) throws IOException, UndeclaredThrowableException, CommandException { if (reader != null) { reader.clear(); } StringBuilder sb = new StringBuilder(); for (String arg : args) { if (sb.length() > 0) { sb.append(" "); } sb.append(arg); } CommandInvoker<C, Object> invoker = (CommandInvoker<C, Object>)command.resolveInvoker(sb.toString()); invoker.open(this); invoker.flush(); invoker.close(); return reader != null ? reader.toString() : null; } }
@Override public Screenable append(Style style) throws IOException { buffer.append(style); return this; }
@Override public int hashCode() { return toString().hashCode(); }
@Override public Screenable cls() throws IOException { buffer.cls(); return this; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); try { format(Format.TEXT, sb); } catch (IOException ignore) { } return sb.toString(); } }
final ScreenBuffer buffer = new ScreenBuffer(processContext);
public Screenable append(char c) throws IOException { if (reader == null) { reader = new ScreenBuffer(); } reader.append(c); return this; }
public ScreenBuffer append(Iterable<?> data) throws NullPointerException { for (Object o : data) { append(o); } return this; }
public ScreenBuffer append(Object o) throws NullPointerException { if (o == null) { throw new NullPointerException("No null accepted"); } if (o instanceof ScreenBuffer) { append((ScreenBuffer)o); } else if (o instanceof Style) { append((Style)o); } else if (o instanceof CharSequence){ append(((CharSequence)o)); } else if (o instanceof CLS) { cls(); } else { append(o.toString()); } return this; }