Reputation: 337
I'm working on a personal experiment using s7 scheme and ncurses. I don't have a lot of experience with ncurses and I'm not able to with the tutorials I have figure out what's going wrong. When using newwin
through a FFI interface, functions like wprintw
or wborder
don't work on the window I created, but the entire available terminal screen.
To start, the C example works as expected. A small window shows up and has some text in the top left corner.
initscr();
cbreak();
WINDOW * w = newwin(5, 15, 2, 2);
box(w, 0, 0);
wprintw(w, "ok");
wrefresh(w);
I define functions to call from s7. It's a 1-to-1 mapping of these functions so the code should be identical. The program functions, but the window doesn't work as expected. The window size isn't correct, or it's not targetting the window pointer I give it.
(nc_initscr)
(nc_cbreak)
(define w (nc_newwin 5 15 2 2))
(nc_box w 0 0)
(nc_wprintw w "ok")
(nc_wrefresh w)
// Example C hook
s7_pointer _newwin(s7_scheme * sc, s7_pointer * args) {
int height = first(args);
int width = second(args);
int y = third(args);
int x = fourth(args);
WINDOW * win = newwin(height, width, y, x);
return s7_make_c_pointer(sc, win);
}
s7_define_function(sc, "nc_newwin", _newwin, 4, "");
Is there something about calling these functions that I'm overlooking?
Upvotes: 0
Views: 185
Reputation: 337
Was an error on my part. I was reading the scheme integer arguments incorrectly. The invalid values were being defaulted to the same size as stdscr
.
Upvotes: 0
Reputation: 54583
Looks like the (define w (nc_newwin 5 15 2 2))
is not passing the window-pointer as expected, or the other hooks are ignoring that. Either way, they are using stdscr
rather than the value returned by newwin
.
Upvotes: 1