summaryrefslogtreecommitdiff
path: root/ext/curses
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-29 19:24:43 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-29 19:24:43 +0000
commit9a8935fc65850894d412e783e3bcfb220b9285ae (patch)
tree5fc7c203afe3f5bbed72ef5904fb2d6d76adfa44 /ext/curses
parent46d98fe87b33796f4299985f962ae615bd363bbd (diff)
Add wresize, resizeterm and KEY_RESIZE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/curses')
-rw-r--r--ext/curses/curses.c31
-rw-r--r--ext/curses/extconf.rb2
2 files changed, 32 insertions, 1 deletions
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index c152382..2a48508 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -511,6 +511,16 @@ curses_bkgd(VALUE obj, VALUE ch)
return CHR2FIX(bkgd(NUM2CHR(ch)));
}
+static VALUE
+curses_resizeterm(VALUE obj, VALUE lines, VALUE columns)
+{
+#if defined(HAVE_RESIZETERM)
+ return (resizeterm(NUM2INT(lines),NUM2INT(columns)) == OK) ? Qtrue : Qfalse;
+#else
+ return Qnil;
+#endif
+}
+
#ifdef USE_COLOR
static VALUE
curses_start_color(VALUE obj)
@@ -1180,6 +1190,20 @@ window_getbkgd(VALUE obj)
return CHR2FIX(getbkgd(winp->window));
}
+static VALUE
+window_resize(VALUE obj, VALUE lines, VALUE columns)
+{
+#if defined(HAVE_WRESIZE)
+ struct windata *winp;
+
+ GetWINDOW(obj,winp);
+ return wresize(winp->window, NUM2INT(lines), NUM2INT(columns)) == OK ? Qtrue : Qfalse;
+#else
+ return Qnil;
+#endif
+}
+
+
#ifdef HAVE_KEYPAD
static VALUE
window_keypad(VALUE obj, VALUE val)
@@ -1258,6 +1282,8 @@ Init_curses()
rb_define_module_function(mCurses, "attrset", curses_attrset, 1);
rb_define_module_function(mCurses, "bkgdset", curses_bkgdset, 1);
rb_define_module_function(mCurses, "bkgd", curses_bkgd, 1);
+ rb_define_module_function(mCurses, "resizeterm", curses_resizeterm, 2);
+ rb_define_module_function(mCurses, "resize", curses_resizeterm, 2);
#ifdef USE_COLOR
rb_define_module_function(mCurses, "start_color", curses_start_color, 0);
rb_define_module_function(mCurses, "init_pair", curses_init_pair, 3);
@@ -1309,6 +1335,7 @@ Init_curses()
rb_define_method(cWindow, "idlok", window_idlok, 1);
rb_define_method(cWindow, "setscrreg", window_setscrreg, 2);
rb_define_method(cWindow, "scrl", window_scrl, 1);
+ rb_define_method(cWindow, "resize", window_resize, 2);
#ifdef HAVE_KEYPAD
rb_define_method(cWindow, "keypad", window_keypad, 1);
rb_define_method(cWindow, "keypad=", window_keypad, 1);
@@ -1825,6 +1852,10 @@ Init_curses()
rb_curses_define_const(KEY_UNDO);
rb_define_const(mKey, "UNDO", INT2NUM(KEY_UNDO));
#endif
+#ifdef KEY_RESIZE
+ rb_curses_define_const(KEY_RESIZE);
+ rb_define_const(mKey, "RESIZE", INT2NUM(KEY_RESIZE));
+#endif
#ifdef KEY_MAX
rb_curses_define_const(KEY_MAX);
rb_define_const(mKey, "MAX", INT2NUM(KEY_MAX));
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index ef83af7..94443b4 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -20,7 +20,7 @@ else
end
if make
- for f in %w(isendwin ungetch beep getnstr wgetnstr doupdate flash deleteln wdeleteln keypad keyname init_color)
+ for f in %w(isendwin ungetch beep getnstr wgetnstr doupdate flash deleteln wdeleteln keypad keyname init_color wresize resizeterm)
have_func(f)
end
create_makefile("curses")