ncursesw 1.2.4.3 → 1.4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- # $Id: make_dist.rb,v 1.6 2003/08/29 22:50:12 t-peters Exp $
2
+ # (C) 2002-2011 Tobias Herzke
3
+ # License: LGPL v2.1
4
+ # $Id: make_dist.rb,v 1.8 2011-05-30 23:05:50 t-peters Exp $
4
5
 
5
6
  require "fileutils"
6
7
 
@@ -10,36 +11,28 @@ def sys(i)
10
11
  end
11
12
 
12
13
  dir = File.dirname(__FILE__)
13
- base = File.basename(dir)
14
- base = "ncurses-ruby" if base == "."
15
14
 
16
- files = IO.readlines(dir + "/MANIFEST").collect{|filename|filename.chomp}
15
+ %w(ncurses ncursesw).each{|flavor|
16
+
17
+ base = flavor+"-ruby"
17
18
 
18
- Version = File.new("#{dir}/VERSION").readline.chomp!
19
+ files = IO.readlines(dir + "/MANIFEST_"+flavor).collect{|filename|filename.chomp}
20
+
21
+ Version = File.new("#{dir}/VERSION").readline.chomp
19
22
 
20
23
  FileUtils.mkdir "#{base}-#{Version}"
21
24
  files.each{|filename|
22
25
  if filename.index "/"
23
26
  FileUtils.mkdir_p "#{base}-#{Version}/#{File.dirname(filename)}"
24
27
  end
25
- sys "cp #{dir}/#{filename} #{base}-#{Version}/#{filename}"
28
+ if filename.index("example")
29
+ sys "sed -e '/require/ s/ncurses/#{flavor}/' <#{dir}/#{filename} >#{base}-#{Version}/#{filename}"
30
+ else
31
+ sys "cp #{dir}/#{filename} #{base}-#{Version}/#{filename}"
32
+ end
26
33
  }
34
+ sys "cp #{dir}/extconf_#{flavor}.rb #{base}-#{Version}/extconf.rb"
27
35
  sys "tar cjf #{base}-#{Version}.tar.bz2 --owner=0 --group=0 #{base}-#{Version}"
28
36
 
29
- # check if we create a binary distribution for a mingw extension
30
- binary_description = `file ncurses.so`
31
-
32
- if ((binary_description =~ /\s(windows)\s/i) &&
33
- (binary_description =~ /\s(pe)|(portable executable)\s/i) &&
34
- (binary_description =~ /\s(dll)\s/i))
35
- sys "cp ncurses.so README.binary #{base}-#{Version}"
36
- Dir.glob("#{base}-#{Version}/README*").each{|textfile|
37
- text = IO.readlines(textfile).map{|line|line.chomp + "\r\n"}
38
- File.open(textfile + ".txt", "wb"){|outfd| outfd.write(text.join)}
39
- sys "rm #{textfile}"
40
- }
41
- sys "rm #{base}-#{Version}/{MANIFEST,make_dist.rb}"
42
- sys "zip -9 -r #{base}-#{Version}-i386-mswin32.zip #{base}-#{Version}"
43
- end
44
-
45
37
  sys "rm -r #{base}-#{Version}/"
38
+ }
@@ -22,9 +22,11 @@
22
22
  * License along with this module; if not, write to the Free Software
23
23
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
24
  *
25
+ * Changes
26
+ * (C) 2011 Tobias Herzke
25
27
  */
26
28
 
27
- #ifdef HAVE_MENU_H
29
+ #if defined(HAVE_MENU_H) || defined(HAVE_NCURSESW_MENU_H)
28
30
 
29
31
  #include "menu_wrap.h"
30
32
  #include "ncurses_wrap.h"
@@ -806,7 +808,7 @@ static VALUE rbncurs_m_item_visible(VALUE dummy, VALUE rb_item)
806
808
  static VALUE rbncurs_c_set_menu_fore(VALUE rb_menu, VALUE attr)
807
809
  {
808
810
  MENU *menu = get_menu(rb_menu);
809
- return INT2NUM(set_menu_fore(menu, NUM2ULONG(attr)));
811
+ return INT2NUM(set_menu_fore(menu, (int) NUM2ULONG(attr)));
810
812
  }
811
813
  static VALUE rbncurs_m_set_menu_fore(VALUE dummy, VALUE rb_menu, VALUE attr)
812
814
  { return rbncurs_c_set_menu_fore(rb_menu, attr); }
@@ -822,7 +824,7 @@ static VALUE rbncurs_m_menu_fore(VALUE dummy, VALUE rb_menu)
822
824
  static VALUE rbncurs_c_set_menu_back(VALUE rb_menu, VALUE attr)
823
825
  {
824
826
  MENU *menu = get_menu(rb_menu);
825
- return INT2NUM(set_menu_back(menu, NUM2ULONG(attr)));
827
+ return INT2NUM(set_menu_back(menu, (int) NUM2ULONG(attr)));
826
828
  }
827
829
  static VALUE rbncurs_m_set_menu_back(VALUE dummy, VALUE rb_menu, VALUE attr)
828
830
  { return rbncurs_c_set_menu_back(rb_menu, attr); }
@@ -838,7 +840,7 @@ static VALUE rbncurs_m_menu_back(VALUE dummy, VALUE rb_menu)
838
840
  static VALUE rbncurs_c_set_menu_grey(VALUE rb_menu, VALUE attr)
839
841
  {
840
842
  MENU *menu = get_menu(rb_menu);
841
- return INT2NUM(set_menu_grey(menu, NUM2ULONG(attr)));
843
+ return INT2NUM(set_menu_grey(menu, (int) NUM2ULONG(attr)));
842
844
  }
843
845
  static VALUE rbncurs_m_set_menu_grey(VALUE dummy, VALUE rb_menu, VALUE attr)
844
846
  { return rbncurs_c_set_menu_grey(rb_menu, attr); }
@@ -19,12 +19,18 @@
19
19
  * License along with this module; if not, write to the Free Software
20
20
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
21
  *
22
+ * Changes
23
+ * (C) 2011 Tobias Herzke
22
24
  */
23
25
 
24
- #if !defined(MENU_HH) && defined(HAVE_MENU_H)
26
+ #if !defined(MENU_HH) && (defined(HAVE_MENU_H) || defined(HAVE_NCURSESW_MENU_H))
25
27
  #define MENU_HH
26
28
 
29
+ #ifdef HAVE_MENU_H
27
30
  #include <menu.h>
31
+ #else
32
+ #include <ncursesw/menu.h>
33
+ #endif
28
34
  #include <ruby.h>
29
35
 
30
36
  extern VALUE mMenu;
@@ -2,7 +2,8 @@
2
2
  * ncurses-ruby is a ruby module for accessing the FSF's ncurses library
3
3
  * (C) 2002, 2003, 2004 Tobias Peters <t-peters@berlios.de>
4
4
  * (C) 2004 Simon Kaczor <skaczor@cox.net>
5
- * (C) 2005 2006 2009 Tobias Herzke
5
+ * (C) 2005 2006 2009 2011 Tobias Herzke
6
+ * (C) 2013 Gaute Hope <eg@gaute.vetsj.com>
6
7
  *
7
8
  * This module is free software; you can redistribute it and/or
8
9
  * modify it under the terms of the GNU Lesser General Public
@@ -18,7 +19,7 @@
18
19
  * License along with this module; if not, write to the Free Software
19
20
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21
  *
21
- * $Id: ncurses_wrap.c,v 1.18 2009/07/31 10:49:24 t-peters Exp $
22
+ * $Id: ncurses_wrap.c,v 1.19 2011-05-30 23:05:50 t-peters Exp $
22
23
  *
23
24
  * This file was adapted from the original ncurses header file which
24
25
  * has the following copyright statements:
@@ -70,6 +71,10 @@
70
71
  #include <locale.h>
71
72
  #endif
72
73
 
74
+ #ifdef HAVE_CLOCK_GETTIME
75
+ #include <time.h>
76
+ #endif
77
+
73
78
  VALUE mNcurses; /* module Ncurses */
74
79
  VALUE cWINDOW; /* class Ncurses::WINDOW */
75
80
  VALUE cSCREEN; /* class Ncurses::SCREEN */
@@ -336,15 +341,15 @@ static VALUE rbncurs_winnstr(VALUE dummy, VALUE rb_win, VALUE rb_chstr, VALUE rb
336
341
  return INT2NUM(return_value);
337
342
  }
338
343
 
339
- #ifdef HAVE_PANEL_H
344
+ #if defined(HAVE_PANEL_H) || defined(HAVE_NCURSESW_PANEL_H)
340
345
  #include "panel_wrap.h" /* needs access to mNcurses, wrap_window, get_window */
341
346
  #endif
342
347
 
343
- #ifdef HAVE_FORM_H
348
+ #if defined(HAVE_FORM_H) || defined(HAVE_NCURSESW_FORM_H)
344
349
  #include "form_wrap.h" /* needs init_form */
345
350
  #endif
346
351
 
347
- #ifdef HAVE_MENU_H
352
+ #if defined(HAVE_MENU_H) || defined(HAVE_NCURSESW_MENU_H)
348
353
  #include "menu_wrap.h" /* needs init_menu */
349
354
  #endif
350
355
 
@@ -428,17 +433,17 @@ init_globals_2(void)
428
433
  rb_iv_set(mNcurses, "@curscr", Qnil);
429
434
  rb_iv_set(mNcurses, "@newscr", Qnil);
430
435
 
431
- rb_define_module_function(mNcurses, "stdscr",
436
+ rb_define_module_function(mNcurses, "stdscr",
432
437
  (&get_stdscr), 0);
433
- rb_define_module_function(mNcurses, "curscr",
438
+ rb_define_module_function(mNcurses, "curscr",
434
439
  (&get_curscr), 0);
435
440
  #ifdef HAVE_NEWSCR
436
- rb_define_module_function(mNcurses, "newscr",
441
+ rb_define_module_function(mNcurses, "newscr",
437
442
  (&get_newscr), 0);
438
443
  #endif
439
- rb_define_module_function(mNcurses, "LINES",
444
+ rb_define_module_function(mNcurses, "LINES",
440
445
  (&get_LINES), 0);
441
- rb_define_module_function(mNcurses, "COLS",
446
+ rb_define_module_function(mNcurses, "COLS",
442
447
  (&get_COLS), 0);
443
448
  #ifdef HAVE_TABSIZE
444
449
  rb_define_module_function(mNcurses, "TABSIZE",
@@ -558,7 +563,7 @@ static chtype * RB2CHSTR(VALUE array)
558
563
  chtype * chstr = ALLOC_N(chtype, vector_length);
559
564
  unsigned long i;
560
565
  for (i = 0; i < string_length; ++i) {
561
- chstr[i] = NUM2ULONG(rb_ary_entry(array, i));
566
+ chstr[i] = (int) NUM2ULONG(rb_ary_entry(array, i));
562
567
  }
563
568
  chstr[string_length] = 0;
564
569
  return chstr;
@@ -566,7 +571,11 @@ static chtype * RB2CHSTR(VALUE array)
566
571
  }
567
572
 
568
573
  static VALUE rbncurs_addch(VALUE dummy, VALUE arg1) {
569
- return INT2NUM(addch(NUM2ULONG(arg1)));
574
+ return INT2NUM(addch((int) NUM2ULONG(arg1)));
575
+ }
576
+ static VALUE rbncurs_add_wch(VALUE dummy, VALUE arg1) {
577
+ wchar_t c = NUM2ULONG(arg1);
578
+ return INT2NUM(add_wch((cchar_t *)&c));
570
579
  }
571
580
  static VALUE rbncurs_addchnstr(VALUE dummy, VALUE arg1, VALUE arg2) {
572
581
  chtype * chstr = RB2CHSTR(arg1);
@@ -593,57 +602,57 @@ static VALUE rbncurs_attron(VALUE dummy, VALUE arg1) {
593
602
  return INT2NUM(attron(NUM2ULONG(arg1)));
594
603
  }
595
604
  static VALUE rbncurs_attrset(VALUE dummy, VALUE arg1) {
596
- return INT2NUM(attrset(NUM2ULONG(arg1)));
605
+ return INT2NUM(attrset((int) NUM2ULONG(arg1)));
597
606
  }
598
607
  #if defined(NCURSES_VERSION_MAJOR) && NCURSES_VERSION_MAJOR > 4
599
608
  #ifdef HAVE_ATTR_OFF
600
609
  static VALUE rbncurs_attr_off(VALUE dummy, VALUE arg1, VALUE arg2) {
601
- return INT2NUM(attr_off(NUM2ULONG(arg1), ((void)(arg2),NULL)));
610
+ return INT2NUM(attr_off((int) NUM2ULONG(arg1), ((void)(arg2),NULL)));
602
611
  }
603
612
  #endif
604
613
  #ifdef HAVE_ATTR_ON
605
614
  static VALUE rbncurs_attr_on(VALUE dummy, VALUE arg1, VALUE arg2) {
606
- return INT2NUM(attr_on(NUM2ULONG(arg1), ((void)(arg2),NULL)));
615
+ return INT2NUM(attr_on((int) NUM2ULONG(arg1), ((void)(arg2),NULL)));
607
616
  }
608
617
  #endif
609
618
  #ifdef HAVE_ATTR_SET
610
619
  static VALUE rbncurs_attr_set(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
611
- return INT2NUM(attr_set(NUM2ULONG(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
620
+ return INT2NUM(attr_set((int) NUM2ULONG(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
612
621
  }
613
622
  #endif
614
623
  #if defined(HAVE_SLK_ATTR_OFF) || defined(slk_attr_off)
615
624
  static VALUE rbncurs_slk_attr_off(VALUE dummy, VALUE arg1, VALUE arg2) {
616
- return INT2NUM(slk_attr_off(NUM2ULONG(arg1), ((void)(arg2),NULL)));
625
+ return INT2NUM(slk_attr_off((int) NUM2ULONG(arg1), ((void)(arg2),NULL)));
617
626
  }
618
627
  #endif
619
628
  #if defined(HAVE_SLK_ATTR_ON) || defined(slk_attr_on)
620
629
  static VALUE rbncurs_slk_attr_on(VALUE dummy, VALUE arg1, VALUE arg2) {
621
- return INT2NUM(slk_attr_on(NUM2ULONG(arg1), ((void)(arg2),NULL)));
630
+ return INT2NUM(slk_attr_on((int) NUM2ULONG(arg1), ((void)(arg2),NULL)));
622
631
  }
623
632
  #endif
624
633
  #ifdef HAVE_SLK_ATTR_SET
625
634
  static VALUE rbncurs_slk_attr_set(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
626
- return INT2NUM(slk_attr_set(NUM2ULONG(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
635
+ return INT2NUM(slk_attr_set((int) NUM2ULONG(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
627
636
  }
628
637
  #endif
629
638
  #ifdef HAVE_WATTR_ON
630
639
  static VALUE rbncurs_wattr_on(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
631
- return INT2NUM(wattr_on(get_window(arg1), NUM2ULONG(arg2), ((void)(arg3),NULL)));
640
+ return INT2NUM(wattr_on(get_window(arg1), (int) NUM2ULONG(arg2), ((void)(arg3),NULL)));
632
641
  }
633
642
  #endif
634
643
  #ifdef HAVE_WATTR_OFF
635
644
  static VALUE rbncurs_wattr_off(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
636
- return INT2NUM(wattr_off(get_window(arg1), NUM2ULONG(arg2), ((void)(arg3),NULL)));
645
+ return INT2NUM(wattr_off(get_window(arg1), (int) NUM2ULONG(arg2), ((void)(arg3),NULL)));
637
646
  }
638
647
  #endif
639
648
  #ifdef HAVE_WATTR_SET
640
649
  static VALUE rbncurs_wattr_set(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
641
- return INT2NUM(wattr_set(get_window(arg1), NUM2ULONG(arg2), NUM2INT(arg3), ((void)(arg4),NULL)));
650
+ return INT2NUM(wattr_set(get_window(arg1), (int) NUM2ULONG(arg2), NUM2INT(arg3), ((void)(arg4),NULL)));
642
651
  }
643
652
  #endif
644
653
  #if defined(HAVE_VID_ATTR) || defined(vid_attr)
645
654
  static VALUE rbncurs_vid_attr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
646
- return INT2NUM(vid_attr(NUM2ULONG(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
655
+ return INT2NUM(vid_attr((int) NUM2ULONG(arg1), NUM2INT(arg2), ((void)(arg3),NULL)));
647
656
  }
648
657
  #endif
649
658
  #ifdef HAVE_ATTR_GET
@@ -693,16 +702,16 @@ static VALUE rbncurs_beep(VALUE dummy) {
693
702
  return INT2NUM(beep());
694
703
  }
695
704
  static VALUE rbncurs_bkgd(VALUE dummy, VALUE arg1) {
696
- return INT2NUM(bkgd(NUM2ULONG(arg1)));
705
+ return INT2NUM(bkgd((int) NUM2ULONG(arg1)));
697
706
  }
698
707
  static VALUE rbncurs_bkgdset(VALUE dummy, VALUE arg1) {
699
- return ((bkgdset(NUM2ULONG(arg1))),Qnil);
708
+ return ((bkgdset((int) NUM2ULONG(arg1))),Qnil);
700
709
  }
701
710
  static VALUE rbncurs_border(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7, VALUE arg8) {
702
- return INT2NUM(border(NUM2ULONG(arg1), NUM2ULONG(arg2), NUM2ULONG(arg3), NUM2ULONG(arg4), NUM2ULONG(arg5), NUM2ULONG(arg6), NUM2ULONG(arg7), NUM2ULONG(arg8)));
711
+ return INT2NUM(border((int) NUM2ULONG(arg1), (int) NUM2ULONG(arg2), (int) NUM2ULONG(arg3), (int) NUM2ULONG(arg4), (int) NUM2ULONG(arg5), (int) NUM2ULONG(arg6), (int) NUM2ULONG(arg7), (int) NUM2ULONG(arg8)));
703
712
  }
704
713
  static VALUE rbncurs_box(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
705
- return INT2NUM(box(get_window(arg1), NUM2ULONG(arg2), NUM2ULONG(arg3)));
714
+ return INT2NUM(box(get_window(arg1), (int) NUM2ULONG(arg2), (int) NUM2ULONG(arg3)));
706
715
  }
707
716
  static VALUE rbncurs_can_change_color(VALUE dummy) {
708
717
  return (can_change_color()) ? Qtrue : Qfalse;
@@ -729,7 +738,7 @@ static VALUE rbncurs_cbreak(VALUE dummy) {
729
738
  }
730
739
  #ifdef HAVE_CHGAT
731
740
  static VALUE rbncurs_chgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
732
- return INT2NUM(chgat(NUM2INT(arg1), NUM2ULONG(arg2), NUM2INT(arg3),
741
+ return INT2NUM(chgat(NUM2INT(arg1), (int) NUM2ULONG(arg2), NUM2INT(arg3),
733
742
  ((void)(arg4),NULL)));
734
743
  }
735
744
  #endif
@@ -787,7 +796,7 @@ static VALUE rbncurs_echo(VALUE dummy) {
787
796
  return INT2NUM(echo());
788
797
  }
789
798
  static VALUE rbncurs_echochar(VALUE dummy, VALUE arg1) {
790
- return INT2NUM(echochar(NUM2ULONG(arg1)));
799
+ return INT2NUM(echochar((int) NUM2ULONG(arg1)));
791
800
  }
792
801
  static VALUE rbncurs_endwin(VALUE dummy) {
793
802
  return INT2NUM(endwin());
@@ -810,7 +819,11 @@ static VALUE rbncurs_getbkgd(VALUE dummy, VALUE arg1) {
810
819
  return INT2NUM(getbkgd(get_window(arg1)));
811
820
  }
812
821
 
813
- static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
822
+ /* typedef of a pointer to a wgetch function */
823
+ typedef int (*wgetch_func) (WINDOW *);
824
+
825
+ /* functor for getting a char nonblocking, pass getchar function */
826
+ static int rbncurshelper_do_wgetch_functor (WINDOW *c_win, wgetch_func _wgetch_func) {
814
827
  /* nonblocking wgetch only implemented for Ncurses */
815
828
  int halfdelay = NUM2INT(rb_iv_get(mNcurses, "@halfdelay"));
816
829
  int infd = NUM2INT(rb_iv_get(mNcurses, "@infd"));
@@ -824,41 +837,109 @@ static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
824
837
  /* FIXME: ^ Infinity ^*/
825
838
  double delay = (screen_delay > 0) ? screen_delay : window_delay;
826
839
  int result;
827
- struct timeval tv;
828
- struct timezone tz = {0,0};
829
840
  double starttime, nowtime, finishtime;
830
841
  double resize_delay = NUM2INT(get_RESIZEDELAY()) / 1000.0;
831
842
  fd_set in_fds;
843
+ #ifdef HAVE_CLOCK_GETTIME
844
+ struct timespec tv;
845
+ struct timeval ts;
846
+ clock_gettime (CLOCK_MONOTONIC, &tv);
847
+ starttime = tv.tv_sec + tv.tv_nsec * 1e-9;
848
+ #else
849
+ struct timeval tv;
850
+ struct timezone tz = {0,0};
832
851
  gettimeofday(&tv, &tz);
833
852
  starttime = tv.tv_sec + tv.tv_usec * 1e-6;
853
+ #endif
834
854
  finishtime = starttime + delay;
835
855
  #if defined(NCURSES_VERSION) && defined(NCURSES_OPAQUE) && !NCURSES_OPAQUE
836
856
  c_win->_delay = 0;
837
857
  #endif
838
- while (doupdate() /* detects resize */, (result = wgetch(c_win)) == ERR) {
839
- gettimeofday(&tv, &tz);
840
- nowtime = tv.tv_sec + tv.tv_usec * 1e-6;
841
- delay = finishtime - nowtime;
842
- if (delay <= 0) break;
843
-
844
- /* Check for terminal size change every resize_delay seconds */
845
- if (resize_delay > delay) resize_delay = delay;
846
- tv.tv_sec = (time_t)resize_delay;
847
- tv.tv_usec = (unsigned)( (resize_delay - tv.tv_sec) * 1e6 );
848
-
849
- /* sleep on infd until input is available or tv reaches timeout */
850
- FD_ZERO(&in_fds);
851
- FD_SET(infd, &in_fds);
852
- rb_thread_select(infd + 1, &in_fds, NULL, NULL, &tv);
858
+ while (doupdate() /* detects resize */, (result = _wgetch_func(c_win)) == ERR) {
859
+ #ifdef HAVE_RB_THREAD_FD_SELECT
860
+ rb_fdset_t fdsets[3];
861
+ rb_fdset_t *rfds = NULL;
862
+ #endif
863
+ #ifdef HAVE_CLOCK_GETTIME
864
+ clock_gettime (CLOCK_MONOTONIC, &tv);
865
+ nowtime = tv.tv_sec + tv.tv_nsec * 1e-9;
866
+ #else
867
+ gettimeofday(&tv, &tz);
868
+ nowtime = tv.tv_sec + tv.tv_usec * 1e-6;
869
+ #endif
870
+ delay = finishtime - nowtime;
871
+ if (delay <= 0) break;
872
+
873
+ /* Check for terminal size change every resize_delay seconds */
874
+ if (resize_delay > delay) resize_delay = delay;
875
+ tv.tv_sec = (time_t)resize_delay;
876
+ #ifdef HAVE_CLOCK_GETTIME
877
+ tv.tv_nsec = (unsigned)( (resize_delay - tv.tv_sec) * 1e9 );
878
+ #else
879
+ tv.tv_usec = (unsigned)( (resize_delay - tv.tv_sec) * 1e6 );
880
+ #endif
881
+
882
+ #if HAVE_CLOCK_GETTIME
883
+ ts.tv_sec = tv.tv_sec;
884
+ ts.tv_usec = tv.tv_nsec * 1e-3;
885
+ #endif
886
+
887
+ /* sleep on infd until input is available or tv reaches timeout */
888
+ FD_ZERO(&in_fds);
889
+ FD_SET(infd, &in_fds);
890
+
891
+ #ifdef HAVE_RB_THREAD_FD_SELECT
892
+ rfds = &fdsets[0];
893
+ rb_fd_init(rfds);
894
+ rb_fd_copy(rfds, &in_fds, infd +1);
895
+
896
+ #if HAVE_CLOCK_GETTIME
897
+ rb_thread_fd_select(infd + 1, rfds, NULL, NULL, &ts);
898
+ #else
899
+ rb_thread_fd_select(infd + 1, rfds, NULL, NULL, &tv);
900
+ #endif
901
+
902
+ #else
903
+ #if HAVE_CLOCK_GETTIME
904
+ rb_thread_select(infd + 1, &in_fds, NULL, NULL, &ts);
905
+ #else
906
+ rb_thread_select(infd + 1, &in_fds, NULL, NULL, &tv);
907
+ #endif
908
+ #endif
853
909
  }
854
910
  #if defined(NCURSES_VERSION) && defined(NCURSES_OPAQUE) && !NCURSES_OPAQUE
855
911
  c_win->_delay = windelay;
856
912
  #endif
857
913
  return result;
858
914
  }
915
+
916
+ /* non-wide char getch */
917
+ static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
918
+ return rbncurshelper_do_wgetch_functor (c_win, &wgetch);
919
+ }
920
+
921
+ /* not thread safe: wide char getch */
922
+ static wint_t wget_wch_back;
923
+ static int my_wget_wch (WINDOW *c_win) {
924
+ return wget_wch (c_win, &wget_wch_back);
925
+ }
926
+
927
+ /* return array with first element being return key code status,
928
+ * and second element the key code */
929
+ static VALUE rbncurshelper_nonblocking_wget_wch(WINDOW *c_win) {
930
+ int retcode = rbncurshelper_do_wgetch_functor (c_win, &my_wget_wch);
931
+ VALUE r = rb_assoc_new (INT2NUM(retcode), LONG2NUM(wget_wch_back));
932
+ return r;
933
+ }
934
+
859
935
  static VALUE rbncurs_getch(VALUE dummy) {
860
936
  return INT2NUM(rbncurshelper_nonblocking_wgetch(stdscr));
861
937
  }
938
+
939
+ static VALUE rbncurs_get_wch(VALUE dummy) {
940
+ return rbncurshelper_nonblocking_wget_wch(stdscr);
941
+ }
942
+
862
943
  static VALUE rbncurs_halfdelay(VALUE dummy, VALUE arg1) {
863
944
  return INT2NUM(rbncurshelper_halfdelay_cbreak(NUM2INT(arg1), 1));
864
945
  }
@@ -872,7 +953,7 @@ static VALUE rbncurs_has_il(VALUE dummy) {
872
953
  return (has_il()) ? Qtrue : Qfalse;
873
954
  }
874
955
  static VALUE rbncurs_hline(VALUE dummy, VALUE arg1, VALUE arg2) {
875
- return INT2NUM(hline(NUM2ULONG(arg1), NUM2INT(arg2)));
956
+ return INT2NUM(hline((int) NUM2ULONG(arg1), NUM2INT(arg2)));
876
957
  }
877
958
  static VALUE rbncurs_idcok(VALUE dummy, VALUE arg1, VALUE arg2) {
878
959
  return ((idcok(get_window(arg1), RTEST(arg2))),Qnil);
@@ -888,7 +969,7 @@ static VALUE rbncurs_inch(VALUE dummy) {
888
969
  }
889
970
  static VALUE rbncurs_initscr(VALUE dummy) {
890
971
  VALUE v = wrap_window(initscr());
891
- if (!RTEST(v))
972
+ if (!RTEST(v))
892
973
  return v;
893
974
 
894
975
  Init_ncurses_full();
@@ -1003,7 +1084,7 @@ static VALUE rbncurs_init_pair(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3)
1003
1084
  return INT2NUM(init_pair(NUM2INT(arg1), NUM2INT(arg2), NUM2INT(arg3)));
1004
1085
  }
1005
1086
  static VALUE rbncurs_insch(VALUE dummy, VALUE arg1) {
1006
- return INT2NUM(insch(NUM2ULONG(arg1)));
1087
+ return INT2NUM(insch((int) NUM2ULONG(arg1)));
1007
1088
  }
1008
1089
  static VALUE rbncurs_insdelln(VALUE dummy, VALUE arg1) {
1009
1090
  return INT2NUM(insdelln(NUM2INT(arg1)));
@@ -1053,7 +1134,7 @@ static VALUE rbncurs_move(VALUE dummy, VALUE arg1, VALUE arg2) {
1053
1134
  return INT2NUM(move(NUM2INT(arg1), NUM2INT(arg2)));
1054
1135
  }
1055
1136
  static VALUE rbncurs_mvaddch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
1056
- return INT2NUM(mvaddch(NUM2INT(arg1), NUM2INT(arg2), NUM2ULONG(arg3)));
1137
+ return INT2NUM(mvaddch(NUM2INT(arg1), NUM2INT(arg2), (int) NUM2ULONG(arg3)));
1057
1138
  }
1058
1139
  static VALUE rbncurs_mvaddchnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3,
1059
1140
  VALUE arg4) {
@@ -1078,7 +1159,7 @@ static VALUE rbncurs_mvaddstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
1078
1159
  }
1079
1160
  #ifdef HAVE_MVCHGAT
1080
1161
  static VALUE rbncurs_mvchgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6) {
1081
- return INT2NUM(mvchgat(NUM2INT(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4), NUM2INT(arg5), ((void)(arg6),NULL)));
1162
+ return INT2NUM(mvchgat(NUM2INT(arg1), NUM2INT(arg2), NUM2INT(arg3), (int) NUM2ULONG(arg4), NUM2INT(arg5), ((void)(arg6),NULL)));
1082
1163
  }
1083
1164
  #endif
1084
1165
  static VALUE rbncurs_mvcur(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
@@ -1097,14 +1178,14 @@ static VALUE rbncurs_mvgetch(VALUE dummy, VALUE arg1, VALUE arg2) {
1097
1178
  }
1098
1179
  #ifdef HAVE_MVHLINE
1099
1180
  static VALUE rbncurs_mvhline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
1100
- return INT2NUM(mvhline(NUM2INT(arg1), NUM2INT(arg2), NUM2ULONG(arg3), NUM2INT(arg4)));
1181
+ return INT2NUM(mvhline(NUM2INT(arg1), NUM2INT(arg2), (int) NUM2ULONG(arg3), NUM2INT(arg4)));
1101
1182
  }
1102
1183
  #endif
1103
1184
  static VALUE rbncurs_mvinch(VALUE dummy, VALUE arg1, VALUE arg2) {
1104
1185
  return INT2NUM(mvinch(NUM2INT(arg1), NUM2INT(arg2)));
1105
1186
  }
1106
1187
  static VALUE rbncurs_mvinsch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
1107
- return INT2NUM(mvinsch(NUM2INT(arg1), NUM2INT(arg2), NUM2ULONG(arg3)));
1188
+ return INT2NUM(mvinsch(NUM2INT(arg1), NUM2INT(arg2), (int) NUM2ULONG(arg3)));
1108
1189
  }
1109
1190
  static VALUE rbncurs_mvinsnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
1110
1191
  return INT2NUM(mvinsnstr(NUM2INT(arg1), NUM2INT(arg2), STR2CSTR(arg3), NUM2INT(arg4)));
@@ -1114,11 +1195,11 @@ static VALUE rbncurs_mvinsstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
1114
1195
  }
1115
1196
  #ifdef HAVE_MVVLINE
1116
1197
  static VALUE rbncurs_mvvline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
1117
- return INT2NUM(mvvline(NUM2INT(arg1), NUM2INT(arg2), NUM2ULONG(arg3), NUM2INT(arg4)));
1198
+ return INT2NUM(mvvline(NUM2INT(arg1), NUM2INT(arg2), (int) NUM2ULONG(arg3), NUM2INT(arg4)));
1118
1199
  }
1119
1200
  #endif
1120
1201
  static VALUE rbncurs_mvwaddch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
1121
- return INT2NUM(mvwaddch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4)));
1202
+ return INT2NUM(mvwaddch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), (int) NUM2ULONG(arg4)));
1122
1203
  }
1123
1204
  static VALUE rbncurs_mvwaddchnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3,
1124
1205
  VALUE arg4, VALUE arg5) {
@@ -1145,7 +1226,7 @@ static VALUE rbncurs_mvwaddstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3,
1145
1226
  }
1146
1227
  #ifdef HAVE_MVWCHGAT
1147
1228
  static VALUE rbncurs_mvwchgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7) {
1148
- return INT2NUM(mvwchgat(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4), NUM2ULONG(arg5), NUM2INT(arg6), ((void)(arg7),NULL)));
1229
+ return INT2NUM(mvwchgat(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4), (int) NUM2ULONG(arg5), NUM2INT(arg6), ((void)(arg7),NULL)));
1149
1230
  }
1150
1231
  #endif
1151
1232
  static VALUE rbncurs_mvwdelch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
@@ -1159,7 +1240,7 @@ static VALUE rbncurs_mvwgetch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
1159
1240
  }
1160
1241
  #ifdef HAVE_MVWHLINE
1161
1242
  static VALUE rbncurs_mvwhline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
1162
- return INT2NUM(mvwhline(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4), NUM2INT(arg5)));
1243
+ return INT2NUM(mvwhline(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), (int) NUM2ULONG(arg4), NUM2INT(arg5)));
1163
1244
  }
1164
1245
  #endif
1165
1246
  static VALUE rbncurs_mvwin(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
@@ -1169,7 +1250,7 @@ static VALUE rbncurs_mvwinch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
1169
1250
  return INT2NUM(mvwinch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
1170
1251
  }
1171
1252
  static VALUE rbncurs_mvwinsch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4) {
1172
- return INT2NUM(mvwinsch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4)));
1253
+ return INT2NUM(mvwinsch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), (int) NUM2ULONG(arg4)));
1173
1254
  }
1174
1255
  static VALUE rbncurs_mvwinsnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
1175
1256
  return INT2NUM(mvwinsnstr(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), STR2CSTR(arg4), NUM2INT(arg5)));
@@ -1179,7 +1260,7 @@ static VALUE rbncurs_mvwinsstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3,
1179
1260
  }
1180
1261
  #ifdef HAVE_MVWVLINE
1181
1262
  static VALUE rbncurs_mvwvline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
1182
- return INT2NUM(mvwvline(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2ULONG(arg4), NUM2INT(arg5)));
1263
+ return INT2NUM(mvwvline(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), (int) NUM2ULONG(arg4), NUM2INT(arg5)));
1183
1264
  }
1184
1265
  #endif
1185
1266
  static VALUE rbncurs_napms(VALUE dummy, VALUE arg1) {
@@ -1228,7 +1309,7 @@ static VALUE rbncurs_PAIR_NUMBER(VALUE dummy, VALUE arg1) {
1228
1309
  }
1229
1310
  #ifndef __PDCURSES__ /* pdcurses "pechochar" macro won't compile*/
1230
1311
  static VALUE rbncurs_pechochar(VALUE dummy, VALUE arg1, VALUE arg2) {
1231
- return INT2NUM(pechochar(get_window(arg1), NUM2ULONG(arg2)));
1312
+ return INT2NUM(pechochar(get_window(arg1), (int) NUM2ULONG(arg2)));
1232
1313
  }
1233
1314
  #endif
1234
1315
  static VALUE rbncurs_pnoutrefresh(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7) {
@@ -1315,13 +1396,13 @@ static VALUE rbncurs_set_term(VALUE dummy, VALUE rb_new_screen) {
1315
1396
  return rb_old_screen;
1316
1397
  }
1317
1398
  static VALUE rbncurs_slk_attroff(VALUE dummy, VALUE arg1) {
1318
- return INT2NUM(slk_attroff(NUM2ULONG(arg1)));
1399
+ return INT2NUM(slk_attroff((int) NUM2ULONG(arg1)));
1319
1400
  }
1320
1401
  static VALUE rbncurs_slk_attron(VALUE dummy, VALUE arg1) {
1321
- return INT2NUM(slk_attron(NUM2ULONG(arg1)));
1402
+ return INT2NUM(slk_attron((int) NUM2ULONG(arg1)));
1322
1403
  }
1323
1404
  static VALUE rbncurs_slk_attrset(VALUE dummy, VALUE arg1) {
1324
- return INT2NUM(slk_attrset(NUM2ULONG(arg1)));
1405
+ return INT2NUM(slk_attrset((int) NUM2ULONG(arg1)));
1325
1406
  }
1326
1407
  #ifdef HAVE_SLK_ATTR
1327
1408
  static VALUE rbncurs_slk_attr(VALUE dummy) {
@@ -1416,14 +1497,18 @@ static VALUE rbncurs_use_env(VALUE dummy, VALUE arg1) {
1416
1497
  #endif
1417
1498
  #ifdef HAVE_VIDATTR
1418
1499
  static VALUE rbncurs_vidattr(VALUE dummy, VALUE arg1) {
1419
- return INT2NUM(vidattr(NUM2ULONG(arg1)));
1500
+ return INT2NUM(vidattr((int) NUM2ULONG(arg1)));
1420
1501
  }
1421
1502
  #endif
1422
1503
  static VALUE rbncurs_vline(VALUE dummy, VALUE arg1, VALUE arg2) {
1423
- return INT2NUM(vline(NUM2ULONG(arg1), NUM2INT(arg2)));
1504
+ return INT2NUM(vline((int) NUM2ULONG(arg1), NUM2INT(arg2)));
1424
1505
  }
1425
1506
  static VALUE rbncurs_waddch(VALUE dummy, VALUE arg1, VALUE arg2) {
1426
- return INT2NUM(waddch(get_window(arg1), NUM2ULONG(arg2)));
1507
+ return INT2NUM(waddch(get_window(arg1), (int) NUM2ULONG(arg2)));
1508
+ }
1509
+ static VALUE rbncurs_wadd_wch(VALUE dummy, VALUE arg1, VALUE arg2) {
1510
+ cchar_t t = { 0, { NUM2ULONG(arg2), 0 } };
1511
+ return INT2NUM(wadd_wch(get_window(arg1), &t));
1427
1512
  }
1428
1513
  static VALUE rbncurs_waddchnstr(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
1429
1514
  chtype * chstr = RB2CHSTR(arg2);
@@ -1454,17 +1539,17 @@ static VALUE rbncurs_wattrset(VALUE dummy, VALUE arg1, VALUE arg2) {
1454
1539
  return INT2NUM(wattrset(get_window(arg1), NUM2INT(arg2)));
1455
1540
  }
1456
1541
  static VALUE rbncurs_wbkgd(VALUE dummy, VALUE arg1, VALUE arg2) {
1457
- return INT2NUM(wbkgd(get_window(arg1), NUM2ULONG(arg2)));
1542
+ return INT2NUM(wbkgd(get_window(arg1), (int) NUM2ULONG(arg2)));
1458
1543
  }
1459
1544
  static VALUE rbncurs_wbkgdset(VALUE dummy, VALUE arg1, VALUE arg2) {
1460
- return ((wbkgdset(get_window(arg1), NUM2ULONG(arg2))),Qnil);
1545
+ return ((wbkgdset(get_window(arg1), (int) NUM2ULONG(arg2))),Qnil);
1461
1546
  }
1462
1547
  static VALUE rbncurs_wborder(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7, VALUE arg8, VALUE arg9) {
1463
- return INT2NUM(wborder(get_window(arg1), NUM2ULONG(arg2), NUM2ULONG(arg3), NUM2ULONG(arg4), NUM2ULONG(arg5), NUM2ULONG(arg6), NUM2ULONG(arg7), NUM2ULONG(arg8), NUM2ULONG(arg9)));
1548
+ return INT2NUM(wborder(get_window(arg1), (int) NUM2ULONG(arg2), (int) NUM2ULONG(arg3), (int) NUM2ULONG(arg4), (int) NUM2ULONG(arg5), (int) NUM2ULONG(arg6), (int) NUM2ULONG(arg7), (int) NUM2ULONG(arg8), (int) NUM2ULONG(arg9)));
1464
1549
  }
1465
1550
  #ifdef HAVE_WCHGAT
1466
1551
  static VALUE rbncurs_wchgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5) {
1467
- return INT2NUM(wchgat(get_window(arg1), NUM2INT(arg2), NUM2ULONG(arg3), NUM2INT(arg4), ((void)(arg5),NULL)));
1552
+ return INT2NUM(wchgat(get_window(arg1), NUM2INT(arg2), (int) NUM2ULONG(arg3), NUM2INT(arg4), ((void)(arg5),NULL)));
1468
1553
  }
1469
1554
  #endif
1470
1555
  static VALUE rbncurs_wclear(VALUE dummy, VALUE arg1) {
@@ -1491,7 +1576,7 @@ static VALUE rbncurs_wdeleteln(VALUE dummy, VALUE arg1) {
1491
1576
  return INT2NUM(wdeleteln(get_window(arg1)));
1492
1577
  }
1493
1578
  static VALUE rbncurs_wechochar(VALUE dummy, VALUE arg1, VALUE arg2) {
1494
- return INT2NUM(wechochar(get_window(arg1), NUM2ULONG(arg2)));
1579
+ return INT2NUM(wechochar(get_window(arg1), (int) NUM2ULONG(arg2)));
1495
1580
  }
1496
1581
  static VALUE rbncurs_werase(VALUE dummy, VALUE arg1) {
1497
1582
  return INT2NUM(werase(get_window(arg1)));
@@ -1499,14 +1584,19 @@ static VALUE rbncurs_werase(VALUE dummy, VALUE arg1) {
1499
1584
  static VALUE rbncurs_wgetch(VALUE dummy, VALUE arg1) {
1500
1585
  return INT2NUM(rbncurshelper_nonblocking_wgetch(get_window(arg1)));
1501
1586
  }
1587
+
1588
+ static VALUE rbncurs_wget_wch(VALUE dummy, VALUE arg1) {
1589
+ return rbncurshelper_nonblocking_wget_wch(get_window(arg1));
1590
+ }
1591
+
1502
1592
  static VALUE rbncurs_whline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
1503
- return INT2NUM(whline(get_window(arg1), NUM2ULONG(arg2), NUM2INT(arg3)));
1593
+ return INT2NUM(whline(get_window(arg1), (int) NUM2ULONG(arg2), NUM2INT(arg3)));
1504
1594
  }
1505
1595
  static VALUE rbncurs_winch(VALUE dummy, VALUE arg1) {
1506
1596
  return INT2NUM(winch(get_window(arg1)));
1507
1597
  }
1508
1598
  static VALUE rbncurs_winsch(VALUE dummy, VALUE arg1, VALUE arg2) {
1509
- return INT2NUM(winsch(get_window(arg1), NUM2ULONG(arg2)));
1599
+ return INT2NUM(winsch(get_window(arg1), (int) NUM2ULONG(arg2)));
1510
1600
  }
1511
1601
  static VALUE rbncurs_winsdelln(VALUE dummy, VALUE arg1, VALUE arg2) {
1512
1602
  return INT2NUM(winsdelln(get_window(arg1), NUM2INT(arg2)));
@@ -1557,7 +1647,7 @@ static VALUE rbncurs_wtouchln(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, V
1557
1647
  return INT2NUM(wtouchln(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3), NUM2INT(arg4)));
1558
1648
  }
1559
1649
  static VALUE rbncurs_wvline(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
1560
- return INT2NUM(wvline(get_window(arg1), NUM2ULONG(arg2), NUM2INT(arg3)));
1650
+ return INT2NUM(wvline(get_window(arg1), (int)NUM2ULONG(arg2), NUM2INT(arg3)));
1561
1651
  }
1562
1652
  static VALUE rbncurs_color_content(VALUE dummy, VALUE color, VALUE r, VALUE g, VALUE b) {
1563
1653
  if (rb_obj_is_instance_of(r, rb_cArray) != Qtrue
@@ -1617,7 +1707,7 @@ static VALUE rbncurs_putwin(VALUE dummy, VALUE rb_win, VALUE io)
1617
1707
  }
1618
1708
  #endif
1619
1709
  static VALUE rbncurs_unctrl(VALUE dummy, VALUE ch)
1620
- { return rb_str_new2(unctrl(NUM2ULONG(ch))); }
1710
+ { return rb_str_new2(unctrl((int)NUM2ULONG(ch))); }
1621
1711
  static VALUE rbncurs_newterm(VALUE dummy, VALUE rb_type, VALUE rb_outfd, VALUE rb_infd)
1622
1712
  {
1623
1713
  char * type = (rb_type == Qnil) ? (char*)0 : STR2CSTR(rb_type);
@@ -1641,6 +1731,7 @@ static VALUE rbncurs_newterm(VALUE dummy, VALUE rb_type, VALUE rb_outfd, VALUE r
1641
1731
 
1642
1732
  static void init_functions_2(void) {
1643
1733
  NCFUNC(addch, 1);
1734
+ NCFUNC(add_wch, 1);
1644
1735
  NCFUNC(addchnstr, 2);
1645
1736
  NCFUNC(addchstr, 1);
1646
1737
  NCFUNC(addnstr, 2);
@@ -1723,6 +1814,8 @@ static void init_functions_2(void) {
1723
1814
  NCFUNC(flushinp, 0);
1724
1815
  NCFUNC(getbkgd, 1);
1725
1816
  NCFUNC(getch, 0);
1817
+ NCFUNC(get_wch, 0);
1818
+ NCFUNC(wget_wch, 1);
1726
1819
  NCFUNC(halfdelay, 1);
1727
1820
  rb_define_module_function(mNcurses, "has_colors?",
1728
1821
  (&rbncurs_has_colors),
@@ -1902,6 +1995,7 @@ static void init_functions_2(void) {
1902
1995
  #endif
1903
1996
  NCFUNC(vline, 2);
1904
1997
  NCFUNC(waddch, 2);
1998
+ NCFUNC(wadd_wch, 2);
1905
1999
  NCFUNC(waddchnstr, 3);
1906
2000
  NCFUNC(waddchstr, 2);
1907
2001
  NCFUNC(waddnstr, 3);
@@ -2349,7 +2443,8 @@ static VALUE rbncurs_getparyx(VALUE dummy, VALUE rb_win, VALUE rb_y, VALUE rb_x)
2349
2443
  }
2350
2444
  static VALUE rbncurs_getsyx(VALUE dummy, VALUE rb_y, VALUE rb_x)
2351
2445
  {
2352
- int y,x;
2446
+ int y = 0;
2447
+ int x = 0;
2353
2448
  if ((rb_obj_is_instance_of(rb_y, rb_cArray) != Qtrue)
2354
2449
  || (rb_obj_is_instance_of(rb_x, rb_cArray) != Qtrue)) {
2355
2450
  rb_raise(rb_eArgError,
@@ -2603,7 +2698,7 @@ VALUE rb_## ACS (VALUE rb_screen) \
2603
2698
  VALUE rb_ACS_CONST = INT2NUM(ACS); \
2604
2699
  rbncurs_set_term(mNcurses, current_screen); \
2605
2700
  return rb_ACS_CONST; \
2606
- }
2701
+ }
2607
2702
  #define wrap_ACS(ACS) \
2608
2703
  rb_define_method(cSCREEN, #ACS, \
2609
2704
  (&rb_ ## ACS), \
@@ -2727,8 +2822,6 @@ static void init_safe_functions(void)
2727
2822
  }
2728
2823
  void Init_ncursesw_bin(void)
2729
2824
  {
2730
- setlocale(LC_ALL, "");
2731
-
2732
2825
  mNcurses = rb_define_module("Ncurses");
2733
2826
  eNcurses = rb_define_class_under(mNcurses, "Exception", rb_eRuntimeError);
2734
2827
  rb_iv_set(mNcurses, "@windows_hash", rb_hash_new());
@@ -2759,13 +2852,13 @@ static void Init_ncurses_full(void)
2759
2852
  init_functions_3();
2760
2853
 
2761
2854
  init_SCREEN_methods();
2762
- #ifdef HAVE_PANEL_H
2855
+ #if defined(HAVE_PANEL_H) || defined(HAVE_NCURSESW_PANEL_H)
2763
2856
  init_panel();
2764
2857
  #endif
2765
- #ifdef HAVE_FORM_H
2858
+ #if defined(HAVE_FORM_H) || defined(HAVE_NCURSESW_FORM_H)
2766
2859
  init_form();
2767
2860
  #endif
2768
- #ifdef HAVE_MENU_H
2861
+ #if defined(HAVE_MENU_H) || defined(HAVE_NCURSESW_MENU_H)
2769
2862
  init_menu();
2770
2863
  #endif
2771
2864
  }