diff options
Diffstat (limited to 'cmd/scrolllist.ha')
| -rw-r--r-- | cmd/scrolllist.ha | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/cmd/scrolllist.ha b/cmd/scrolllist.ha new file mode 100644 index 0000000..6b631fc --- /dev/null +++ b/cmd/scrolllist.ha @@ -0,0 +1,52 @@ +use tui; +use tui::layout; +use tui::widget; +use tui::widget::list; +use unix::tty; +use io; +use fmt; +use time; + +export fn main() void = { + const state = tui::init()!; + defer tui::finish(&state); + let li = list::newscrolllist(&state, (1, 1), tty::ttysize { + rows = 2u16, + columns = 50u16, + }, + &widget::style { + border = true, + colorfg = widget::color::REDFG, + colorbg = widget::color::REDBG, + },"hello", "world", "bye", "world")!; + + let l = layout::newvlayout(&li); + defer l.layout.finish(&l); + l.layout.print(&l); + + for (true) { + const r = tui::read(&state)!; + if (r == 'j') { + list::down(&li); + }; + if (r == 'k') { + list::up(&li); + }; + if (r == 'K') { + list::frameup(&li); + }; + if (r == 'J') { + list::framedown(&li); + }; + if (r == 'g') { + list::top(&li); + }; + if (r == 'G') { + list::bottom(&li); + }; + if (r == 'q') { + break; + }; + l.layout.print(&l); + }; +}; |
