|
1 | 1 | // The code for this demo was largely copied from the tamboui project: |
2 | 2 | package examples; |
3 | 3 |
|
4 | | -import java.io.Reader; |
5 | 4 | import java.util.ArrayList; |
6 | 5 | import java.util.List; |
7 | | -import org.codejive.twinkle.ansi.Ansi; |
8 | 6 | import org.codejive.twinkle.ansi.Color; |
9 | 7 | import org.codejive.twinkle.ansi.Style; |
10 | | -import org.codejive.twinkle.core.terminal.RobotTerminal; |
11 | | -import org.codejive.twinkle.core.text.Buffer; |
12 | 8 | import org.codejive.twinkle.core.text.Canvas; |
13 | 9 | import org.codejive.twinkle.core.text.Line; |
14 | 10 | import org.codejive.twinkle.core.util.Size; |
15 | 11 | import org.codejive.twinkle.core.widget.Widget; |
16 | | -import org.codejive.twinkle.widgets.Framed; |
| 12 | +import org.codejive.twinkle.tui.application.App; |
| 13 | +import org.codejive.twinkle.tui.widgets.Framed; |
17 | 14 | import org.jspecify.annotations.NonNull; |
18 | 15 |
|
19 | 16 | public class RgbColorDemo { |
20 | 17 | public static void main(String[] args) throws Exception { |
21 | | - System.out.print(Ansi.hideCursor() + Ansi.autoWrap(false)); |
22 | | - try (RobotTerminal term = new RobotTerminal(Size.of(40, 20))) { |
23 | | - term.delay(5000).resize(Size.of(80, 40)).delay(5000).key('q'); |
24 | | - Size size = term.size(); |
25 | | - RgbColorWidget w = new RgbColorWidget(); |
26 | | - Widget f = new FpsFrameWidget().widget(w); |
27 | | - Buffer buf = Buffer.of(size); |
28 | | - term.onResize(buf::resize); |
29 | | - |
30 | | - Reader rdr = term.reader(); |
31 | | - while (true) { |
32 | | - while (rdr.ready()) { |
33 | | - int ch = rdr.read(); |
34 | | - if (ch == 'q' || ch == 'Q') { |
35 | | - return; |
36 | | - } |
37 | | - } |
38 | | - f.render(buf); |
39 | | - System.out.print(Ansi.cursorHome()); |
40 | | - System.out.print(buf.toAnsiString()); |
41 | | - // Thread.sleep(1); |
42 | | - } |
43 | | - } finally { |
44 | | - System.out.print(Ansi.showCursor() + Ansi.autoWrap(true)); |
45 | | - } |
| 18 | + RgbColorWidget w = new RgbColorWidget(); |
| 19 | + Widget f = new FpsFrameWidget().widget(w); |
| 20 | + App.run(f); |
| 21 | + //App.using(f).quitOnQ(true).limitFps(30).start(); |
46 | 22 | } |
47 | 23 |
|
48 | 24 | static class RgbColorWidget implements Widget { |
|
0 commit comments