summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2025-03-12 22:36:13 +0100
committerJulian Hurst <ark@mansus.space>2025-03-12 22:36:13 +0100
commite074c936bb99ccfce311445f4dbf42ba964b44a4 (patch)
treea2ca68130a4a6a532df3f7362d3cad0574d50259 /cmd
parent6bab265109546396730d84a4189610eca094c62a (diff)
downloadhare-tui-e074c936bb99ccfce311445f4dbf42ba964b44a4.tar.gz
Implement global state and clear scheduling
Diffstat (limited to 'cmd')
-rw-r--r--cmd/list.ha6
-rw-r--r--cmd/list_nostyle.ha6
-rw-r--r--cmd/list_strictsz.ha6
-rw-r--r--cmd/text.ha20
4 files changed, 26 insertions, 12 deletions
diff --git a/cmd/list.ha b/cmd/list.ha
index 0148adb..1db46b4 100644
--- a/cmd/list.ha
+++ b/cmd/list.ha
@@ -8,9 +8,9 @@ use fmt;
use time;
export fn main() void = {
- const out = tui::init()!;
- defer io::close(out)!;
- let li = list::newlist(out, (1, 1), void, &widget::style {
+ const state = tui::init()!;
+ defer tui::finish(&state);
+ let li = list::newlist(&state, (1, 1), void, &widget::style {
border = true,
colorfg = widget::color::REDFG,
colorbg = widget::color::REDBG,
diff --git a/cmd/list_nostyle.ha b/cmd/list_nostyle.ha
index 4e77955..4454220 100644
--- a/cmd/list_nostyle.ha
+++ b/cmd/list_nostyle.ha
@@ -8,9 +8,9 @@ use fmt;
use time;
export fn main() void = {
- const out = tui::init()!;
- defer io::close(out)!;
- let li = list::newlist(out, (1, 1), void, void,"hello", "world", "bye", "world")!;
+ const state = tui::init()!;
+ defer tui::finish(&state);
+ let li = list::newlist(&state, (1, 1), void, void,"hello", "world", "bye", "world")!;
let l = layout::newvlayout(&li);
l.layout.print(&l);
};
diff --git a/cmd/list_strictsz.ha b/cmd/list_strictsz.ha
index 13c2808..e0a371d 100644
--- a/cmd/list_strictsz.ha
+++ b/cmd/list_strictsz.ha
@@ -8,9 +8,9 @@ use fmt;
use time;
export fn main() void = {
- const out = tui::init()!;
- defer io::close(out)!;
- let li = list::newlist(out, (1, 1), tty::ttysize {
+ const state = tui::init()!;
+ defer tui::finish(&state);
+ let li = list::newlist(&state, (1, 1), tty::ttysize {
rows = 3,
columns = 4,
}, &widget::style {
diff --git a/cmd/text.ha b/cmd/text.ha
index 3ec0f2a..f7ce1fc 100644
--- a/cmd/text.ha
+++ b/cmd/text.ha
@@ -7,9 +7,9 @@ use fmt;
use time;
export fn main() void = {
- const out = tui::init()!;
- defer io::close(out)!;
- let txt = text::newtext(out, "hello world", (50, 20), &widget::style {
+ const state = tui::init()!;
+ defer tui::finish(&state);
+ let txt = text::newtext(&state, "hello world", (50, 20), &widget::style {
border = true,
colorfg = widget::color::REDFG,
colorbg = widget::color::REDBG,
@@ -17,32 +17,46 @@ export fn main() void = {
let l = layout::newvlayout(&txt);
l.layout.print(&l);
+ tui::clear(&state);
+
time::sleep(1 * time::SECOND);
let st = txt.widget.style as *widget::style;
st.colorfg = widget::color::GREENFG;
text::settext(&txt, "bye world");
l.layout.print(&l);
+ tui::clear(&state);
+
time::sleep(1 * time::SECOND);
st.colorfg = widget::color::BROWNFG;
l.layout.print(&l);
+ tui::clear(&state);
+
time::sleep(1 * time::SECOND);
st.colorfg = widget::color::BLUEFG;
l.layout.print(&l);
+ tui::clear(&state);
+
time::sleep(1 * time::SECOND);
st.colorfg = widget::color::MAGENTAFG;
l.layout.print(&l);
+ tui::clear(&state);
+
time::sleep(1 * time::SECOND);
st.colorfg = widget::color::CYANFG;
l.layout.print(&l);
+ tui::clear(&state);
+
time::sleep(1 * time::SECOND);
st.colorfg = widget::color::WHITEFG;
l.layout.print(&l);
+ tui::clear(&state);
+
time::sleep(1 * time::SECOND);
st.colorfg = widget::color::DEFAULTFG;
l.layout.print(&l);