add C.screen_width and C.screen_height methods

This commit is contained in:
Josh Holtrop 2018-02-14 16:37:15 -05:00
parent 66517921ab
commit ee08d9d13e

View File

@ -1,5 +1,30 @@
#include <ruby.h> #include <ruby.h>
#include <curses.h>
static int Screen_Width = -1;
static int Screen_Height = -1;
VALUE Rb_screen_width(void)
{
return INT2FIX(Screen_Width);
}
VALUE Rb_screen_height(void)
{
return INT2FIX(Screen_Height);
}
void Init_svi(void) void Init_svi(void)
{ {
/* Determine screen dimensions. */
initscr();
getmaxyx(stdscr, Screen_Height, Screen_Width);
endwin();
VALUE svi_module = rb_define_module("Svi");
VALUE c_module = rb_define_module_under(svi_module, "C");
rb_define_module_function(c_module, "screen_width",
Rb_screen_width, 0);
rb_define_module_function(c_module, "screen_height",
Rb_screen_height, 0);
} }