diff --git a/Makefile b/Makefile index 8df1aca..a21b90f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ demos = just-text \ window-with-text\ - two-windows + two-windows \ + doupdate demos_files = $(patsubst %, %.exe, $(demos)) .PHONY: all diff --git a/doupdate.vala b/doupdate.vala new file mode 100644 index 0000000..37d1cb9 --- /dev/null +++ b/doupdate.vala @@ -0,0 +1,57 @@ +using Curses; +using Posix; + +public class Demo { + public MainLoop loop; + private TimeoutSource time; + + public Demo() { + loop = new MainLoop(); + time = new TimeoutSource (5000); + time.set_callback (() => { loop.quit(); return false; }); + time.attach(loop.get_context()); + } + + public void start() { + initscr(); + noecho(); + } + + public void stop() { + endwin(); + } + + private Window window1; + private Window window2; + public void activate() { + this.window1 = new Window(5, 20, 1, 1); + this.window1.box(0, 0); + this.window1.mvprintw(1, 1, "I am in window 1"); + this.window1.noutrefresh(); + + this.window2 = new Window(5, 20, 1, 21); + this.window2.box(0, 0); + this.window2.mvprintw(1, 1, "I am in window 2"); + //this.window2.noutrefresh(); + } + + public void run() { + loop.run(); + } + + public void redraw() { + doupdate(); + } + + static int main(string[] args) { + var app = new Demo(); + + app.start(); + app.activate(); + app.redraw(); + app.run(); + app.stop(); + + return EXIT_SUCCESS; + } +}