Skip to content

Commit

Permalink
panels
Browse files Browse the repository at this point in the history
  • Loading branch information
kucaahbe committed May 27, 2020
1 parent 454bbf0 commit 7bbe324
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
demos = just-text \
window-with-text\
two-windows \
doupdate
doupdate \
panels
demos_files = $(patsubst %, %.exe, $(demos))

.PHONY: all
all: $(demos_files)

%.exe: %.vala
valac -g --pkg curses --pkg posix -X -lcurses $(patsubst %.exe, %, $@).vala -o $@
valac -g --vapidir=. --pkg curses --pkg curses-panel --pkg posix -X -lcurses -X -lpanel $(patsubst %.exe, %, $@).vala -o $@

.PHONY: clean
clean:
Expand Down
10 changes: 10 additions & 0 deletions curses-panel.vapi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Curses {
[Compact]
[CCode (free_function = "del_panel", cname = "PANEL", cprefix = "", cheader_filename = "panel.h")]
public class Panel {
[CCode (cname = "new_panel")]
public Panel(Window win);

public static void update_panels();
}
}
64 changes: 64 additions & 0 deletions panels.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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;

private Panel panel1;
private Panel panel2;
public void activate() {

this.window1 = new Window(5, 20, 1, 1);
panel1 = new Panel(window1);
this.window1.box(0, 0);
this.window1.mvprintw(1, 1, "I am in window 1");
//this.window1.noutrefresh();

this.window2 = new Window(5, 20, 2, 19);
panel2 = new Panel(window2);
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() {
Panel.update_panels();
doupdate();
}

static int main(string[] args) {
var app = new Demo();

app.start();
app.activate();
app.redraw();
app.run();
app.stop();

return EXIT_SUCCESS;
}
}

0 comments on commit 7bbe324

Please sign in to comment.