public static LabelElement label(String value) { return new LabelElement(value); } }
@Override public LineRenderer renderer(Iterator<Object> stream) { StringBuilder sb = new StringBuilder(); while (stream.hasNext()) { Object next = stream.next(); if (next instanceof CharSequence) { sb.append((CharSequence)next); } else { sb.append(next); } } return new LabelElement(sb.toString()).renderer(); } };
new LabelElement("NAME").style(Style.style(Decoration.bold)), new LabelElement("DESCRIPTION") ); new LabelElement(command.getKey()).style(Style.style(Color.red)), new LabelElement(desc)); } catch (Exception ignore) { context.provide(new LabelElement("Try one of these commands with the -h or --help switch:\n")); context.provide(table);
add(label("b"))) .add(row(). add(label("c").style(Color.green.bg().fg(Color.blue).bold())). add(label("d")));
public void renderLine(RenderAppendable to) { if (index >= height) { throw new IllegalStateException(); } else { Style.Composite style = element.getStyle(); if (style != null) { to.enterStyle(style); } if (index < lines.length) { Pair<Integer, Integer> a = lines[index]; to.append(element.value, a.getFirst(), a.getSecond()); int missing = width - (a.getSecond() - a.getFirst()); if (missing > 0) { to.append(BlankSequence.create(missing)); } } else { for (int i = 0;i < width;i++) { to.append(' '); } } index++; if (style != null) { to.leaveStyle(); } } } }
public void testLabel() { GroovyShell shell = new GroovyShell(); UIBuilder res = (UIBuilder)shell.evaluate( "import org.crsh.text.ui.UIBuilder;\n" + "def builder = new UIBuilder();\n" + "builder.label('foo');\n" + "return builder;\n" ); assertEquals(1, res.getElements().size()); assertTrue(res.getElements().get(0) instanceof LabelElement); assertEquals("foo", ((LabelElement)res.getElements().get(0)).getValue()); }
add(label("b"))). add(row(). add(label("c").style(Color.green.bg().fg(Color.blue).bold())). add(label("d")));
public void renderLine(RenderAppendable to) { if (index >= height) { throw new IllegalStateException(); } else { Style.Composite style = element.getStyle(); if (style != null) { to.enterStyle(style); } if (index < lines.length) { Pair<Integer, Integer> a = lines[index]; to.append(element.value, a.getFirst(), a.getSecond()); int missing = width - (a.getSecond() - a.getFirst()); if (missing > 0) { to.append(BlankSequence.create(missing)); } } else { for (int i = 0;i < width;i++) { to.append(' '); } } index++; if (style != null) { to.leaveStyle(); } } } }
public void testLabelledNode() { GroovyShell shell = new GroovyShell(); UIBuilder res = (UIBuilder)shell.evaluate( "import org.crsh.text.ui.UIBuilder;\n" + "def builder = new UIBuilder();\n" + "builder.node('foo') { };\n" + "return builder;\n" ); assertEquals(1, res.getElements().size()); assertTrue(res.getElements().get(0) instanceof TreeElement); assertTrue(((TreeElement)res.getElements().get(0)).getValue() instanceof LabelElement); assertEquals("foo", ((LabelElement)((TreeElement)res.getElements().get(0)).getValue()).getValue()); assertEquals(0, ((TreeElement)res.getElements().get(0)).getSize()); }
public TreeElement(String value) { this.value = new LabelElement(value); }
ThreadGroup group = thread.getThreadGroup(); table.row( new LabelElement(thread.getId()), new LabelElement(thread.getName()), new LabelElement(group == null ? "" : group.getName()), new LabelElement(thread.getPriority()), new LabelElement(thread.getState()).style(c.fg()), new LabelElement(cpu), new LabelElement(time), new LabelElement(thread.isInterrupted()), new LabelElement(thread.isDaemon()) );
@Override public LineRenderer renderer(Iterator<Value> stream) { ArrayList<LineRenderer> renderers = new ArrayList<LineRenderer>(); while (stream.hasNext()) { Value value = stream.next(); renderers.add(new LabelElement("<value>" + value.getValue() + "</value>").renderer()); } return LineRenderer.vertical(renderers); } }
add(label("b"))). add(row(). add(label("c").style(Color.blue.fg().bg(Color.green).bold())). add(label("d")));
public void renderLine(RenderAppendable to) { if (index >= height) { throw new IllegalStateException(); } else { Style.Composite style = element.getStyle(); if (style != null) { to.enterStyle(style); } if (index < lines.length) { Pair<Integer, Integer> a = lines[index]; to.append(element.value, a.getFirst(), a.getSecond()); int missing = width - (a.getSecond() - a.getFirst()); if (missing > 0) { to.append(BlankSequence.create(missing)); } } else { for (int i = 0;i < width;i++) { to.append(' '); } } index++; if (style != null) { to.leaveStyle(); } } } }
public RowElement add(String... cols) { for (String col : cols) { this.cols.add(new LabelElement(col)); } return this; }
new LabelElement("NAME").style(Style.style(Decoration.bold)), new LabelElement("DISPLAY NAME"), new LabelElement("DESCRIPTION"), new LabelElement("ACTIVE") ); for (Map.Entry<Repl, Boolean> entry : repls.entrySet()) { String langName = entry.getKey().getLanguage().getName(); table.row( new LabelElement(langName).style(Style.style(Color.red)), new LabelElement(langDisplayName != null ? langDisplayName : ""), new LabelElement(langDescription != null ? langDescription : ""), new LabelElement(active) ); context.provide(new LabelElement("Current repl is " + current.getLanguage().getName() + "available repl are:\n")); context.provide(table);
@Override public LineRenderer renderer(Iterator<Object> stream) { StringBuilder sb = new StringBuilder(); while (stream.hasNext()) { Object next = stream.next(); if (next instanceof CharSequence) { sb.append((CharSequence)next); } else { sb.append(next); } } return new LabelElement(sb.toString()).renderer(); } };
public void renderLine(RenderAppendable to) { if (index >= height) { throw new IllegalStateException(); } else { Style.Composite style = element.getStyle(); if (style != null) { to.enterStyle(style); } if (index < lines.length) { Pair<Integer, Integer> a = lines[index]; to.append(element.value, a.getFirst(), a.getSecond()); int missing = width - (a.getSecond() - a.getFirst()); if (missing > 0) { to.append(BlankSequence.create(missing)); } } else { for (int i = 0;i < width;i++) { to.append(' '); } } index++; if (style != null) { to.leaveStyle(); } } } }
public void testActualHeight() { assertEquals(1, new LabelElement("").actualHeight); assertEquals(1, new LabelElement("a").actualHeight); assertEquals(2, new LabelElement("\n").actualHeight); assertEquals(2, new LabelElement("\na").actualHeight); assertEquals(2, new LabelElement("a\n").actualHeight); assertEquals(2, new LabelElement("a\nb").actualHeight); assertEquals(3, new LabelElement("a\nb\n").actualHeight); assertEquals(3, new LabelElement("\n\n").actualHeight); }
LabelElement foo = new LabelElement("foo"); LabelElement bar = new LabelElement("bar").style(Style.style(Decoration.bold_off)); LabelElement juu = new LabelElement("juu");