|
@@ -0,0 +1,158 @@
|
|
|
+# DTui
|
|
|
+🚧 WIP 🚧 Terminal user interface library for D language
|
|
|
+
|
|
|
+# About
|
|
|
+DTui is a terminal user interface (TUI) library for D language that I am working on in my free time to help better understand D.
|
|
|
+
|
|
|
+_Keep in mind:_
|
|
|
+
|
|
|
+1. The library's first version has not been released yet.
|
|
|
+
|
|
|
+2. Note that I am new to D so this is not a professional project.
|
|
|
+
|
|
|
+3. Output images are in the IntelliJ IDEA 'Run' window.
|
|
|
+
|
|
|
+# Controls
|
|
|
+
|
|
|
+### Tree
|
|
|
+
|
|
|
+#### Construction:
|
|
|
+
|
|
|
+```D
|
|
|
+void main() {
|
|
|
+ Canvas canvas = new Canvas();
|
|
|
+
|
|
|
+ Tree tree = new Tree(Node("A", Node("B1", Node("C1"), Node("C2")), Node("B2", Node("D1"), Node("D2")), Node("B3", Node("E1"), Node("E2"))));
|
|
|
+
|
|
|
+ canvas.updateCache(tree, Coordinate(0, 0));
|
|
|
+ canvas.drawCache();
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+#### Output:
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+### Chart
|
|
|
+
|
|
|
+#### Construction:
|
|
|
+
|
|
|
+```D
|
|
|
+void main() {
|
|
|
+ Canvas canvas = new Canvas();
|
|
|
+
|
|
|
+ Chart chart = new Chart(ChartType.column, [1, 4, 9, 2], 3, 1, Color.Red);
|
|
|
+
|
|
|
+ canvas.updateCache(chart, Coordinate(0, 0));
|
|
|
+ canvas.drawCache();
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+#### Output:
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+### Rect (with fill)
|
|
|
+
|
|
|
+#### Construction
|
|
|
+
|
|
|
+```D
|
|
|
+void main() {
|
|
|
+ Canvas canvas = new Canvas();
|
|
|
+
|
|
|
+ Rect rect = Rect.withFill(Dimensions(20, 10), Color.Orange);
|
|
|
+
|
|
|
+ canvas.updateCache(rect, Coordinate(0, 0));
|
|
|
+ canvas.drawCache();
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+#### Output:
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+### Rect (with frame)
|
|
|
+
|
|
|
+#### Construction
|
|
|
+
|
|
|
+```D
|
|
|
+void main() {
|
|
|
+ Canvas canvas = new Canvas();
|
|
|
+
|
|
|
+ Rect rect = Rect.withFrame(Dimensions(20, 10), Color.Blue);
|
|
|
+
|
|
|
+ canvas.updateCache(rect, Coordinate(0, 0));
|
|
|
+ canvas.drawCache();
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+#### Output
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+### Table
|
|
|
+
|
|
|
+#### Construction
|
|
|
+
|
|
|
+```D
|
|
|
+void main() {
|
|
|
+ Canvas canvas = new Canvas();
|
|
|
+
|
|
|
+ Table table = new Table(10, 5);
|
|
|
+
|
|
|
+ canvas.updateCache(table, Coordinate(0, 0));
|
|
|
+ canvas.drawCache();
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+#### Output
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+### Label
|
|
|
+
|
|
|
+#### Construction
|
|
|
+
|
|
|
+```D
|
|
|
+void main() {
|
|
|
+ Canvas canvas = new Canvas();
|
|
|
+
|
|
|
+ Label label = new Label(Rect.withFill(Dimension.block(30, 11), Color.Black), "Hello World!", Color.Orange);
|
|
|
+
|
|
|
+ canvas.updateCache(label, Coordinate(0, 0));
|
|
|
+ canvas.drawCache();
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+#### Output
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+### StackLayout
|
|
|
+
|
|
|
+#### Construction
|
|
|
+
|
|
|
+```D
|
|
|
+void main() {
|
|
|
+ Canvas canvas = new Canvas();
|
|
|
+
|
|
|
+ Rect rectr = Rect.withFill(Dimension(10, 10), Color.Blue);
|
|
|
+ Rect rectb = Rect.withFill(Dimension(10, 10), Color.Red);
|
|
|
+
|
|
|
+ StackLayout row = new StackLayout(StackLayoutType.row);
|
|
|
+
|
|
|
+ row.add(rectr, rectb, rectr, rectb, rectr);
|
|
|
+
|
|
|
+ canvas.updateCache(row, Coordinate(0, 0));
|
|
|
+ canvas.drawCache();
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+#### Output
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|