public class POJOExample {
public class Student {
String name;
int age;
public Student(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
@Test
public void test1(){
List<Student> list = new ArrayList<Student>();
for(int i = 0; i < 10; ++i){
list.add(new Student("name" + i, 10 + i));
}
System.err.println(RenderUtil.render(list));
}
}
设置Element的Style
Style有下面六种
Boolean bold 是否粗体
Boolean underline 是否有下划线
Boolean blink 是否闪烁
Color foreground 前景颜色
Color background 背景颜色
public class HighlightExample {
public static void main(String[] args) {
String code = "int a = 123; \nString s = \"sssss\";";
System.out.println(LangRenderUtil.render(code, LangRenderUtil.java));
}
}
text-ui
Introduction
This code extract from crash shell: https://github.com/crashub/crash/tree/1.3.2/shell
输出Table的例子(自适应列宽,字体颜色等)
可以用maven查看运行效果:
输出POJO List的例子
设置Element的Style
Style有下面六种
对于每一个Element都可以设置Style,比如一个Table里的一个小格子。
设置Style可以通过Composite来构造,比如
也可以通过Decoration这个辅助类来设置,这个类定义了一些常见的Style。
语法高亮功能
支持对多种语法的语法高亮。默认是java语言,可以传递不同的语言参数。
需要增加依赖
更多的例子请参考test下面的example。