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.
data/README CHANGED
@@ -1,4 +1,4 @@
1
- $Id: README,v 1.16 2009/05/03 14:13:27 t-peters Exp $
1
+ $Id: README,v 1.16 2009-05-03 14:13:27 t-peters Exp $
2
2
  ------------------------------------------------------------------------
3
3
  This directory contains a ruby module for accessing the FSF's ncurses
4
4
  library.
data/THANKS CHANGED
@@ -1,4 +1,4 @@
1
- $Id: THANKS,v 1.9 2009/05/03 10:37:54 t-peters Exp $
1
+ $Id: THANKS,v 1.9 2009-05-03 10:37:54 t-peters Exp $
2
2
 
3
3
  A list of people that helped me with ncurses-ruby
4
4
 
data/TODO CHANGED
@@ -1,4 +1,4 @@
1
- $Id: TODO,v 1.6 2003/03/22 22:55:27 t-peters Exp $
1
+ $Id: TODO,v 1.6 2003-03-22 22:55:27 t-peters Exp $
2
2
 
3
3
  This is the complete list of functions present in ncurses that have not yet
4
4
  been wrapped by ncurses-ruby:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.4
1
+ 1.4.0.0
data/compat.h CHANGED
@@ -2,7 +2,7 @@
2
2
  #define _COMPAT_H
3
3
 
4
4
  #ifndef STR2CSTR
5
- #define STR2CSTR(x) ({ VALUE *y = (x); StringValuePtr(y); })
5
+ #define STR2CSTR(x) ({ VALUE y = x; StringValuePtr (y); })
6
6
  #endif
7
7
 
8
8
  #endif
@@ -1,4 +1,4 @@
1
- $Id: LICENSES_for_examples,v 1.6 2004/05/13 21:55:17 t-peters Exp $
1
+ $Id: LICENSES_for_examples,v 1.6 2004-05-13 21:55:17 t-peters Exp $
2
2
 
3
3
  Ideally, an example program on how to use a library should be in the public
4
4
  domain.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # $Id: example.rb,v 1.4 2002/03/04 13:24:29 t-peters Exp $
3
+ # $Id: example.rb,v 1.4 2002-03-04 13:24:29 t-peters Exp $
4
4
 
5
5
  # This file provides an example for the usage of the ncurses-ruby module.
6
6
  # Copyright (C) 2002 Tobias Peters <t-peters@users.berlios.de>
@@ -59,7 +59,7 @@
59
59
 
60
60
 
61
61
 
62
- require "ncurses"
62
+ require "ncursesw"
63
63
 
64
64
  def moving(scr)
65
65
  scr.clear() # clear screen
@@ -8,7 +8,7 @@
8
8
  # Copyright (c) 2001 by Pradeep Padala. This document may be distributed
9
9
  # under the terms set forth in the LDP license at linuxdoc.org/COPYRIGHT.html.
10
10
 
11
- require 'ncurses.rb'
11
+ require 'ncursesw.rb'
12
12
 
13
13
  begin
14
14
  scr = Ncurses.initscr()
@@ -11,7 +11,7 @@
11
11
  # Copyright (c) 2001 by Pradeep Padala. This document may be distributed
12
12
  # under the terms set forth in the LDP license at linuxdoc.org/COPYRIGHT.html.
13
13
 
14
- require 'ncurses'
14
+ require 'ncursesw'
15
15
 
16
16
  include Ncurses
17
17
  include Ncurses::Form
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # $Id: hello_ncurses.rb,v 1.3 2002/02/28 13:50:03 t-peters Exp $
3
+ # $Id: hello_ncurses.rb,v 1.3 2002-02-28 13:50:03 t-peters Exp $
4
4
 
5
5
  # this ncurses-ruby program follows an ancient tradition of example
6
6
  # computer programs: When invoked, it prints a friendly greeting on the
@@ -14,7 +14,7 @@
14
14
 
15
15
  # First, we have to tell Ruby to use the Ncurses extension module:
16
16
 
17
- require "ncurses"
17
+ require "ncursesw"
18
18
 
19
19
 
20
20
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # $Id: rain.rb,v 1.6 2005/08/22 21:41:49 t-peters Exp $
3
+ # $Id: rain.rb,v 1.6 2005-08-22 21:41:49 t-peters Exp $
4
4
 
5
5
  # This program is a translation of the popular rain.c demo program from the
6
6
  # ncurses library distribution.
@@ -40,7 +40,7 @@
40
40
 
41
41
 
42
42
 
43
- require "ncurses"
43
+ require "ncursesw"
44
44
 
45
45
 
46
46
  # A class responsible for raindrop drawing
@@ -7,7 +7,7 @@
7
7
  # No warranties
8
8
  # Share and enjoy!
9
9
 
10
- require "ncurses"
10
+ require "ncursesw"
11
11
 
12
12
  # read_line returns an array
13
13
  # [string, last_cursor_position_in_string, keycode_of_terminating_enter_key].
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # $Id: tclock.rb,v 1.6 2002/02/28 13:50:10 t-peters Exp $
3
+ # $Id: tclock.rb,v 1.6 2002-02-28 13:50:10 t-peters Exp $
4
4
 
5
5
  # tclock - analog/digital clock for curses, translated to ruby
6
6
  # Copyright (C) 2002 Tobias Peters <t-peters@users.berlios.de>
@@ -30,7 +30,7 @@
30
30
  # clearly marked as such. #
31
31
  ###########################################################################
32
32
 
33
- require "ncurses"
33
+ require "ncursesw"
34
34
  PI = Math::PI
35
35
 
36
36
  def sign(_x)
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # $Id: test_scanw.rb,v 1.1 2003/03/22 22:55:00 t-peters Exp $
3
+ # $Id: test_scanw.rb,v 1.1 2003-03-22 22:55:00 t-peters Exp $
4
4
  #
5
5
  # Test of the scanw function. Should really not be used in any serious curses
6
6
  # program. To use it, install scanf for ruby.
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # No warranties. Share and enjoy.
11
11
 
12
- require "ncurses"
12
+ require "ncursesw"
13
13
  begin
14
14
  Ncurses.initscr
15
15
  Ncurses.mvaddstr(4, 19, "Give me a number: ")
data/extconf.rb CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  # ncurses-ruby is a ruby module for accessing the FSF's ncurses library
4
4
  # (C) 2002, 2004 Tobias Peters <t-peters@users.berlios.de>
5
- # (C) 2005, 2009 Tobias Herzke
5
+ # (C) 2005, 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,12 +19,11 @@
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: extconf.rb,v 1.14 2009/05/03 14:13:27 t-peters Exp $
22
+ # $Id: extconf_ncursesw.rb,v 1.1 2011-05-30 23:05:50 t-peters Exp $
22
23
 
23
24
  require "mkmf"
24
25
 
25
- $CFLAGS += " -g"
26
- $CXXFLAGS = $CFLAGS
26
+ $CFLAGS += " -g -Wformat -Werror=format-security"
27
27
 
28
28
  have_header("unistd.h")
29
29
  have_header("locale.h")
@@ -106,6 +106,11 @@ have_func("wchgat")
106
106
  have_func("wcolor_set")
107
107
  have_func("getattrs")
108
108
 
109
+ puts "checking for ncursesw (wide char) functions..."
110
+ if not have_func("wget_wch")
111
+ raise "no wget_wch found."
112
+ end
113
+
109
114
  puts "checking which debugging functions to wrap..."
110
115
  have_func("_tracef")
111
116
  have_func("_tracedump")
@@ -124,14 +129,48 @@ have_func("attr_get")
124
129
  puts "checking for the panel library..."
125
130
  if have_header("panel.h")
126
131
  have_library("panelw", "panel_hidden")
132
+ else
133
+ raise "panel library not found"
127
134
  end
135
+
128
136
  puts "checking for the form library..."
129
137
  if have_header("form.h")
130
- have_library("formw", "new_form")
138
+ if not have_library("formw", "new_form")
139
+ raise "formw library not found"
140
+ end
141
+ else
142
+ raise "form library not found."
143
+ end
144
+
145
+ if have_library("formw", "form_driver_w")
146
+ $CFLAGS += " -DHAVE_FORM_DRIVER_W"
131
147
  end
148
+
132
149
  puts "checking for the menu library..."
133
150
  if have_header("menu.h")
134
151
  have_library("menu", "new_menu")
152
+ else
153
+ raise "menu library not found."
135
154
  end
136
155
 
156
+ puts "checking for various ruby and standard functions.."
157
+ if have_func("rb_thread_fd_select")
158
+ $CFLAGS += " -DHAVE_RB_THREAD_FD_SELECT"
159
+ end
160
+
161
+ # Avoid dereferencing WINDOW pointers on FreeBSD
162
+ if RUBY_PLATFORM =~ /freebsd/
163
+ $CFLAGS += " -DNCURSES_OPAQUE=1"
164
+ else
165
+ # add NCURSES_OPAQUE for mac
166
+ $CFLAGS += " -DNCURSES_OPAQUE=0"
167
+ end
168
+
169
+ if have_func("clock_gettime")
170
+ $CFLAGS += " -DHAVE_CLOCK_GETTIME"
171
+ end
172
+
173
+ $CXXFLAGS = $CFLAGS
174
+
137
175
  create_makefile('ncursesw_bin')
176
+
@@ -3,10 +3,11 @@
3
3
  * Contributed by Simon Kaczor <skaczor@cox.net>
4
4
  * Prognosoft Inc. <http://www.prognosoft.biz>
5
5
  * Copyright 2004
6
- *
6
+ *
7
7
  * Changes:
8
8
  * (C) 2004 Tobias Peters
9
9
  * (C) 2005 2009 Tobias Herzke
10
+ * (C) 2013 Gaute Hope <eg@gaute.vetsj.com>
10
11
  *
11
12
  * This module is free software; you can redistribute it and/or
12
13
  * modify it under the terms of the GNU Lesser General Public
@@ -22,10 +23,14 @@
22
23
  * License along with this module; if not, write to the Free Software
23
24
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
25
  *
26
+ * Changes
27
+ * (C) 2011 Tobias Herzke
25
28
  */
26
29
 
27
30
 
28
- #ifdef HAVE_FORM_H
31
+ #if defined(HAVE_FORM_H) || defined(HAVE_NCURSESW_FORM_H)
32
+
33
+ # include <wchar.h>
29
34
 
30
35
  #include "form_wrap.h"
31
36
  #include "ncurses_wrap.h"
@@ -36,7 +41,7 @@ VALUE cFIELD;
36
41
  VALUE cFIELDTYPE;
37
42
  VALUE cFORM;
38
43
 
39
- void init_err_codes()
44
+ void init_err_codes()
40
45
  {
41
46
  /* The routine succeeded. */
42
47
  FORM_DEF_CONST(E_OK);
@@ -360,14 +365,14 @@ static VALUE get_proc_hash(int hook) {
360
365
  }
361
366
 
362
367
  /*
363
- * Returns an existing Ruby Proc for a given owning "object" and hook type.
368
+ * Returns an existing Ruby Proc for a given owning "object" and hook type.
364
369
  * Qnil will be returned if no Proc was associated with the owner
365
370
  */
366
371
  static VALUE get_proc(void* owner, int hook) {
367
372
  if (owner == 0) return Qnil;
368
373
  {
369
374
  VALUE owner_adress = INT2NUM((long)(owner));
370
- VALUE proc_hash = get_proc_hash(hook);
375
+ VALUE proc_hash = get_proc_hash(hook);
371
376
  VALUE proc = rb_hash_aref(proc_hash, owner_adress);
372
377
  return proc;
373
378
  }
@@ -398,12 +403,12 @@ static VALUE rbncurs_m_new_form(VALUE dummy, VALUE rb_field_array)
398
403
  long n = rbncurs_array_length(rb_field_array);
399
404
  /* Will ncurses free this array? If not, must do it after calling free_form(). */
400
405
  FIELD** fields = ALLOC_N(FIELD*, (n+1));
401
- long i;
406
+ long i;
402
407
  for (i=0; i<n; i++){
403
- fields[i] = get_field(rb_ary_entry(rb_field_array, i));
408
+ fields[i] = get_field(rb_ary_entry(rb_field_array, i));
404
409
  }
405
410
  fields[n] = NULL;
406
- return wrap_form(new_form(fields));
411
+ return wrap_form(new_form(fields));
407
412
  }
408
413
 
409
414
  static VALUE rbncurs_c_free_form(VALUE rb_form) {
@@ -444,12 +449,22 @@ static VALUE rbncurs_c_form_driver(VALUE rb_form, VALUE c) {
444
449
  static VALUE rbncurs_m_form_driver(VALUE dummy, VALUE rb_form, VALUE c)
445
450
  { return rbncurs_c_form_driver(rb_form, c); }
446
451
 
452
+ # ifdef HAVE_FORM_DRIVER_W
453
+ /* Form driver W */
454
+ static VALUE rbncurs_c_form_driver_w(VALUE rb_form, VALUE type, VALUE c) {
455
+ FORM* form = get_form(rb_form);
456
+ return INT2NUM(form_driver_w(form, NUM2INT(type), NUM2INT(c)));
457
+ }
458
+ static VALUE rbncurs_m_form_driver_w(VALUE dummy, VALUE rb_form, VALUE type, VALUE c)
459
+ { return rbncurs_c_form_driver_w(rb_form, type, c); }
460
+ # endif
461
+
447
462
  /*
448
463
  * form_page(3x)
449
464
  */
450
465
  static VALUE rbncurs_c_set_current_field(VALUE rb_form, VALUE rb_field) {
451
466
  FORM* form = get_form(rb_form);
452
- FIELD* field = get_field(rb_field);
467
+ FIELD* field = get_field(rb_field);
453
468
  return INT2NUM(set_current_field(form, field));
454
469
  }
455
470
  static VALUE rbncurs_m_set_current_field(VALUE dummy, VALUE rb_form, VALUE rb_field)
@@ -538,12 +553,12 @@ static VALUE rbncurs_c_free_field(VALUE rb_field) {
538
553
  }
539
554
  static VALUE rbncurs_m_free_field(VALUE dummy, VALUE rb_field)
540
555
  { return rbncurs_c_free_field(rb_field); }
541
-
556
+
542
557
 
543
558
  /*
544
559
  * form_field_info(3x)
545
560
  */
546
- static VALUE rbncurs_c_field_info(VALUE rb_field, VALUE rows, VALUE cols,
561
+ static VALUE rbncurs_c_field_info(VALUE rb_field, VALUE rows, VALUE cols,
547
562
  VALUE frow, VALUE fcol, VALUE nrow, VALUE nbuf) {
548
563
  if (rb_obj_is_instance_of(rows, rb_cArray) != Qtrue
549
564
  || rb_obj_is_instance_of(cols, rb_cArray) != Qtrue
@@ -558,7 +573,7 @@ static VALUE rbncurs_c_field_info(VALUE rb_field, VALUE rows, VALUE cols,
558
573
  else {
559
574
  FIELD* field = get_field(rb_field);
560
575
  int vals[6] = {0,0,0,0,0,0};
561
-
576
+
562
577
  int result = field_info(field, &vals[0],&vals[1],&vals[2],&vals[3],&vals[4],&vals[5]);
563
578
  rb_ary_push(rows, INT2NUM(vals[0]));
564
579
  rb_ary_push(cols, INT2NUM(vals[1]));
@@ -569,15 +584,15 @@ static VALUE rbncurs_c_field_info(VALUE rb_field, VALUE rows, VALUE cols,
569
584
  return INT2NUM(result);
570
585
  }
571
586
  }
572
- static VALUE rbncurs_m_field_info(VALUE dummy, VALUE rb_field, VALUE rows, VALUE cols,
587
+ static VALUE rbncurs_m_field_info(VALUE dummy, VALUE rb_field, VALUE rows, VALUE cols,
573
588
  VALUE frow, VALUE fcol, VALUE nrow, VALUE nbuf)
574
589
  { return rbncurs_c_field_info(rb_field, rows, cols, frow, fcol, nrow, nbuf); }
575
590
 
576
- static VALUE rbncurs_c_dynamic_field_info(VALUE rb_field, VALUE rows, VALUE cols,
591
+ static VALUE rbncurs_c_dynamic_field_info(VALUE rb_field, VALUE rows, VALUE cols,
577
592
  VALUE max) {
578
593
  if (rb_obj_is_instance_of(rows, rb_cArray) != Qtrue
579
594
  || rb_obj_is_instance_of(cols, rb_cArray) != Qtrue
580
- || rb_obj_is_instance_of(max, rb_cArray) != Qtrue) {
595
+ || rb_obj_is_instance_of(max, rb_cArray) != Qtrue) {
581
596
  rb_raise(rb_eArgError,
582
597
  "rows, cols and max arguments must be empty Arrays");
583
598
  return Qnil;
@@ -585,7 +600,7 @@ static VALUE rbncurs_c_dynamic_field_info(VALUE rb_field, VALUE rows, VALUE cols
585
600
  else {
586
601
  FIELD* field = get_field(rb_field);
587
602
  int vals[3] = {0,0,0};
588
-
603
+
589
604
  int result = dynamic_field_info(field, &vals[0],&vals[1],&vals[2]);
590
605
  rb_ary_push(rows, INT2NUM(vals[0]));
591
606
  rb_ary_push(cols, INT2NUM(vals[1]));
@@ -593,7 +608,7 @@ static VALUE rbncurs_c_dynamic_field_info(VALUE rb_field, VALUE rows, VALUE cols
593
608
  return INT2NUM(result);
594
609
  }
595
610
  }
596
- static VALUE rbncurs_m_dynamic_field_info(VALUE dummy, VALUE rb_field, VALUE rows, VALUE cols,
611
+ static VALUE rbncurs_m_dynamic_field_info(VALUE dummy, VALUE rb_field, VALUE rows, VALUE cols,
597
612
  VALUE max)
598
613
  { return rbncurs_c_dynamic_field_info(rb_field, rows, cols, max); }
599
614
  /*
@@ -606,12 +621,12 @@ static VALUE rbncurs_c_set_field_type(int argc, VALUE* argv, VALUE rb_field) {
606
621
 
607
622
  rb_scan_args(argc, argv, "13", &rb_fieldtype, &arg3, &arg4, &arg5);
608
623
  ftype = get_fieldtype(rb_fieldtype);
609
-
624
+
610
625
  if (ftype == TYPE_ALNUM ||
611
626
  ftype == TYPE_ALPHA) {
612
627
  if (argc != 2)
613
628
  rb_raise(rb_eArgError, "TYPE_ALNUM and TYPE_ALPHA require one additional argument");
614
- return INT2NUM(set_field_type(field, ftype,
629
+ return INT2NUM(set_field_type(field, ftype,
615
630
  NUM2INT(arg3)));
616
631
  }
617
632
  if (ftype == TYPE_ENUM) {
@@ -619,7 +634,7 @@ static VALUE rbncurs_c_set_field_type(int argc, VALUE* argv, VALUE rb_field) {
619
634
  rb_raise(rb_eArgError, "TYPE_ENUM requires three additional arguments");
620
635
  }
621
636
  else {
622
- int n = rbncurs_array_length(arg3);
637
+ int n = (int) rbncurs_array_length(arg3);
623
638
  /* Will ncurses free this array of strings in free_field()? */
624
639
  char** list = ALLOC_N(char*, n+1);
625
640
  int i;
@@ -627,7 +642,7 @@ static VALUE rbncurs_c_set_field_type(int argc, VALUE* argv, VALUE rb_field) {
627
642
  list[i] = STR2CSTR(rb_ary_entry(arg3, (long)i));
628
643
  }
629
644
  list[n] = NULL;
630
- return INT2NUM(set_field_type(field, ftype,
645
+ return INT2NUM(set_field_type(field, ftype,
631
646
  list,
632
647
  RTEST(arg4),
633
648
  RTEST(arg5)));
@@ -636,7 +651,7 @@ static VALUE rbncurs_c_set_field_type(int argc, VALUE* argv, VALUE rb_field) {
636
651
  else if (ftype == TYPE_INTEGER) {
637
652
  if (argc != 4)
638
653
  rb_raise(rb_eArgError, "TYPE_INTEGER requires three additional arguments");
639
- return INT2NUM(set_field_type(field, ftype,
654
+ return INT2NUM(set_field_type(field, ftype,
640
655
  NUM2INT(arg3),
641
656
  NUM2LONG(arg4),
642
657
  NUM2LONG(arg5)));
@@ -644,7 +659,7 @@ static VALUE rbncurs_c_set_field_type(int argc, VALUE* argv, VALUE rb_field) {
644
659
  else if (ftype == TYPE_NUMERIC) {
645
660
  if (argc != 4)
646
661
  rb_raise(rb_eArgError, "TYPE_NUMERIC requires three additional arguments");
647
- return INT2NUM(set_field_type(field, ftype,
662
+ return INT2NUM(set_field_type(field, ftype,
648
663
  NUM2INT(arg3),
649
664
  NUM2DBL(arg4),
650
665
  NUM2DBL(arg5)));
@@ -652,15 +667,15 @@ static VALUE rbncurs_c_set_field_type(int argc, VALUE* argv, VALUE rb_field) {
652
667
  else if (ftype == TYPE_REGEXP){
653
668
  if (argc != 2)
654
669
  rb_raise(rb_eArgError, "TYPE_REGEXP requires one additional argument");
655
- return INT2NUM(set_field_type(field, ftype,
670
+ return INT2NUM(set_field_type(field, ftype,
656
671
  STR2CSTR(arg3)));
657
672
  }
658
- else if (ftype == TYPE_IPV4){
673
+ else if (ftype == TYPE_IPV4){
659
674
  if (argc != 1)
660
675
  rb_raise(rb_eArgError, "TYPE_IPV4 has no additional arguments");
661
676
  return INT2NUM(set_field_type(field, ftype));
662
677
  }
663
- else {
678
+ else {
664
679
  /* It is a user-defined field type. */
665
680
  /* Will store the arguments associated with this field */
666
681
  /* for use in the callback function. */
@@ -671,7 +686,7 @@ static VALUE rbncurs_c_set_field_type(int argc, VALUE* argv, VALUE rb_field) {
671
686
  /* the block-argument used in finding the appropriate Ruby Proc */
672
687
  return INT2NUM(set_field_type(field, ftype, field));
673
688
  }
674
-
689
+
675
690
  }
676
691
  static VALUE rbncurs_m_set_field_type(int argc, VALUE* argv, VALUE dummy)
677
692
  { return rbncurs_c_set_field_type(argc-1, argv+1, argv[0]); }
@@ -696,7 +711,7 @@ static VALUE rbncurs_m_field_arg(VALUE dummy, VALUE rb_field)
696
711
  */
697
712
  static VALUE rbncurs_c_set_field_fore(VALUE rb_field, VALUE attr) {
698
713
  FIELD* field = get_field(rb_field);
699
- return INT2NUM(set_field_fore(field, NUM2ULONG(attr)));
714
+ return INT2NUM(set_field_fore(field, (int) NUM2ULONG(attr)));
700
715
  }
701
716
  static VALUE rbncurs_m_set_field_fore(VALUE dummy, VALUE rb_field, VALUE attr)
702
717
  { return rbncurs_c_set_field_fore(rb_field, attr); }
@@ -710,7 +725,7 @@ static VALUE rbncurs_m_field_fore(VALUE dummy, VALUE rb_field)
710
725
 
711
726
  static VALUE rbncurs_c_set_field_back(VALUE rb_field, VALUE attr) {
712
727
  FIELD* field = get_field(rb_field);
713
- return INT2NUM(set_field_back(field, NUM2ULONG(attr)));
728
+ return INT2NUM(set_field_back(field, (int) NUM2ULONG(attr)));
714
729
  }
715
730
  static VALUE rbncurs_m_set_field_back(VALUE dummy, VALUE rb_field, VALUE attr)
716
731
  { return rbncurs_c_set_field_back(rb_field, attr); }
@@ -785,7 +800,7 @@ static VALUE rbncurs_c_set_form_fields(VALUE rb_form, VALUE rb_field_array) {
785
800
  long i;
786
801
  FORM* form = NULL;
787
802
  for (i=0; i<n; i++){
788
- fields[i] = get_field(rb_ary_entry(rb_field_array, i));
803
+ fields[i] = get_field(rb_ary_entry(rb_field_array, i));
789
804
  }
790
805
  fields[n] = NULL;
791
806
  form = get_form(rb_form);
@@ -799,7 +814,7 @@ static VALUE rbncurs_c_form_fields(VALUE rb_form) {
799
814
  FIELD** fields = form_fields(form);
800
815
  VALUE arr = Qundef;
801
816
  int i;
802
- if (fields == NULL)
817
+ if (fields == NULL)
803
818
  rb_raise(rb_eRuntimeError, "Error retrieving form fields");
804
819
  arr = rb_ary_new();
805
820
  i=0;
@@ -841,12 +856,12 @@ static void field_init_hook(FORM* form) {
841
856
  static VALUE rbncurs_c_set_field_init(VALUE rb_form, VALUE proc) {
842
857
  FORM* form = NULL;
843
858
  if (!rb_obj_is_kind_of(rb_form, cFORM))
844
- rb_raise(rb_eArgError, "arg1 must be a FORM object");
859
+ rb_raise(rb_eArgError, "arg1 must be a FORM object");
845
860
  if (!rb_obj_is_kind_of(proc, rb_cProc))
846
- rb_raise(rb_eArgError, "arg2 must be a Proc object");
861
+ rb_raise(rb_eArgError, "arg2 must be a Proc object");
847
862
  form = get_form(rb_form);
848
863
  reg_proc(form, FIELD_INIT_HOOK, proc);
849
- if (proc != Qnil) {
864
+ if (proc != Qnil) {
850
865
  return INT2NUM(set_field_init(form, field_init_hook));
851
866
  }
852
867
  else {
@@ -874,12 +889,12 @@ static void field_term_hook(FORM* form) {
874
889
  static VALUE rbncurs_c_set_field_term(VALUE rb_form, VALUE proc) {
875
890
  FORM * form = NULL;
876
891
  if (!rb_obj_is_kind_of(rb_form, cFORM))
877
- rb_raise(rb_eArgError, "arg1 must be a FORM object");
892
+ rb_raise(rb_eArgError, "arg1 must be a FORM object");
878
893
  if (!rb_obj_is_kind_of(proc, rb_cProc))
879
- rb_raise(rb_eArgError, "arg2 must be a Proc object");
894
+ rb_raise(rb_eArgError, "arg2 must be a Proc object");
880
895
  form = get_form(rb_form);
881
896
  reg_proc(form, FIELD_TERM_HOOK, proc);
882
- if (proc != Qnil) {
897
+ if (proc != Qnil) {
883
898
  return INT2NUM(set_field_term(form, field_term_hook));
884
899
  }
885
900
  else {
@@ -907,12 +922,12 @@ static void form_init_hook(FORM* form) {
907
922
  static VALUE rbncurs_c_set_form_init(VALUE rb_form, VALUE proc) {
908
923
  FORM * form = NULL;
909
924
  if (!rb_obj_is_kind_of(rb_form, cFORM))
910
- rb_raise(rb_eArgError, "arg1 must be a FORM object");
925
+ rb_raise(rb_eArgError, "arg1 must be a FORM object");
911
926
  if (!rb_obj_is_kind_of(proc, rb_cProc))
912
- rb_raise(rb_eArgError, "arg2 must be a Proc object");
927
+ rb_raise(rb_eArgError, "arg2 must be a Proc object");
913
928
  form = get_form(rb_form);
914
929
  reg_proc(form, FORM_INIT_HOOK, proc);
915
- if (proc != Qnil) {
930
+ if (proc != Qnil) {
916
931
  return INT2NUM(set_form_init(form, form_init_hook));
917
932
  }
918
933
  else {
@@ -940,12 +955,12 @@ static void form_term_hook(FORM* form) {
940
955
  static VALUE rbncurs_c_set_form_term(VALUE rb_form, VALUE proc) {
941
956
  FORM * form = NULL;
942
957
  if (!rb_obj_is_kind_of(rb_form, cFORM))
943
- rb_raise(rb_eArgError, "arg1 must be a FORM object");
958
+ rb_raise(rb_eArgError, "arg1 must be a FORM object");
944
959
  if (!rb_obj_is_kind_of(proc, rb_cProc))
945
- rb_raise(rb_eArgError, "arg2 must be a Proc object");
960
+ rb_raise(rb_eArgError, "arg2 must be a Proc object");
946
961
  form = get_form(rb_form);
947
962
  reg_proc(form, FORM_TERM_HOOK, proc);
948
- if (proc != Qnil) {
963
+ if (proc != Qnil) {
949
964
  return INT2NUM(set_form_term(form, form_term_hook));
950
965
  }
951
966
  else {
@@ -1098,7 +1113,7 @@ static VALUE rbncurs_c_scale_form(VALUE rb_form, VALUE rows, VALUE columns) {
1098
1113
  return Qnil;
1099
1114
  }
1100
1115
  else {
1101
- int vals[2] = {0,0};
1116
+ int vals[2] = {0,0};
1102
1117
  int result = scale_form(form, &vals[0],&vals[1]);
1103
1118
  rb_ary_push(rows, INT2NUM(vals[0]));
1104
1119
  rb_ary_push(columns, INT2NUM(vals[1]));
@@ -1111,28 +1126,28 @@ static VALUE rbncurs_m_scale_form(VALUE dummy, VALUE rb_form, VALUE rows, VALUE
1111
1126
  /*
1112
1127
  * form_fieldtype
1113
1128
  */
1114
- static void* make_arg(va_list* ap) {
1129
+ static void* make_arg(va_list* ap) {
1115
1130
  /* This method creates a list of arguments to be passed */
1116
1131
  /* to the validation functions (char_check and field_check). */
1117
- FIELD* field = va_arg(*ap, FIELD*);
1132
+ FIELD* field = va_arg(*ap, FIELD*);
1118
1133
  FIELDTYPE* fieldtype = field_type(field);
1119
1134
  VALUE proc = get_proc(fieldtype, FIELDTYPE_FIELD_CHECK_HOOK);
1120
1135
  if (proc == Qnil) {
1121
1136
  proc = get_proc(fieldtype, FIELDTYPE_CHAR_CHECK_HOOK);
1122
1137
  }
1123
-
1138
+
1124
1139
  /* Compare number of arguments in Ruby Proc with that of set_field_type */
1125
- if (proc != Qnil) {
1140
+ if (proc != Qnil) {
1126
1141
  VALUE argc = rb_funcall(proc, rb_intern("arity"),0);
1127
1142
  VALUE args = get_proc(field, FIELDTYPE_ARGS);
1128
- if (args != Qnil) {
1129
- if (NUM2INT(argc)-1 != rbncurs_array_length(args)) {
1143
+ if (args != Qnil) {
1144
+ if (NUM2INT(argc)-1 != rbncurs_array_length(args)) {
1130
1145
  char msg[500];
1131
- snprintf(msg, 500, "The validation functions for this field type need %d additional arguments.",NUM2INT(argc)-1);
1146
+ snprintf(msg, 500, "The validation functions for this field type need %d additional arguments.",(int)(NUM2INT(argc)-1));
1132
1147
  msg[499]=0;
1133
- rb_raise(rb_eArgError, msg);
1148
+ rb_raise(rb_eArgError, "%s", msg);
1134
1149
  }
1135
- }
1150
+ }
1136
1151
  }
1137
1152
  /* field will be the only argument in field_check/char_check callback */
1138
1153
  /* and will be used to locate the appropriate Ruby Proc */
@@ -1141,10 +1156,10 @@ static void* make_arg(va_list* ap) {
1141
1156
  static bool field_check(FIELD* field, const void* argblock) {
1142
1157
  FIELDTYPE* fieldtype = field_type(field);
1143
1158
  VALUE proc = get_proc(fieldtype, FIELDTYPE_FIELD_CHECK_HOOK);
1144
- if (proc != Qnil)
1159
+ if (proc != Qnil)
1145
1160
  {
1146
1161
  VALUE args = rb_ary_dup(get_proc(field, FIELDTYPE_ARGS));
1147
- rb_ary_unshift(args, wrap_field(field));
1162
+ rb_ary_unshift(args, wrap_field(field));
1148
1163
  return RTEST(rb_apply(proc, rb_intern("call"), args));
1149
1164
  }
1150
1165
  return 1;
@@ -1163,18 +1178,18 @@ static bool char_check(int c, const void* argblock) {
1163
1178
  }
1164
1179
  return 1;
1165
1180
  }
1166
- static VALUE rbncurs_m_new_fieldtype(VALUE dummy, VALUE field_check_proc, VALUE char_check_proc)
1181
+ static VALUE rbncurs_m_new_fieldtype(VALUE dummy, VALUE field_check_proc, VALUE char_check_proc)
1167
1182
  {
1168
1183
  FIELDTYPE* fieldtype = new_fieldtype(field_check_proc == Qnil ? NULL : field_check,
1169
- char_check_proc == Qnil ? NULL : char_check);
1184
+ char_check_proc == Qnil ? NULL : char_check);
1170
1185
  set_fieldtype_arg(fieldtype, make_arg, NULL, NULL);
1171
1186
  if (field_check_proc != Qnil) {
1172
1187
  reg_proc(fieldtype, FIELDTYPE_FIELD_CHECK_HOOK, field_check_proc);
1173
- }
1188
+ }
1174
1189
  if (char_check_proc != Qnil) {
1175
1190
  reg_proc(fieldtype, FIELDTYPE_CHAR_CHECK_HOOK, char_check_proc);
1176
1191
  }
1177
-
1192
+
1178
1193
  return wrap_fieldtype(fieldtype);
1179
1194
  }
1180
1195
 
@@ -1206,13 +1221,13 @@ static bool prev_choice(FIELD* field, const void* argblock) {
1206
1221
 
1207
1222
  static VALUE rbncurs_c_set_fieldtype_choice(VALUE rb_fieldtype, VALUE next_choice_proc, VALUE prev_choice_proc) {
1208
1223
  FIELDTYPE* fieldtype = get_fieldtype(rb_fieldtype);
1209
- int result = set_fieldtype_choice(fieldtype,
1210
- next_choice_proc == Qnil ? NULL : next_choice,
1224
+ int result = set_fieldtype_choice(fieldtype,
1225
+ next_choice_proc == Qnil ? NULL : next_choice,
1211
1226
  prev_choice_proc == Qnil ? NULL : prev_choice);
1212
1227
  if (next_choice_proc != Qnil)
1213
1228
  reg_proc(fieldtype, FIELDTYPE_NEXT_CHOICE_HOOK, next_choice_proc);
1214
1229
  if (prev_choice_proc != Qnil)
1215
- reg_proc(fieldtype, FIELDTYPE_PREV_CHOICE_HOOK, prev_choice_proc);
1230
+ reg_proc(fieldtype, FIELDTYPE_PREV_CHOICE_HOOK, prev_choice_proc);
1216
1231
  return INT2NUM(result);
1217
1232
  }
1218
1233
  static VALUE rbncurs_m_set_fieldtype_choice(VALUE dummy, VALUE rb_fieldtype, VALUE next_choice_proc, VALUE prev_choice_proc)
@@ -1252,9 +1267,9 @@ static VALUE rbncurs_m_pos_form_cursor(VALUE dummy, VALUE rb_form)
1252
1267
 
1253
1268
  void init_form(void)
1254
1269
  {
1255
-
1270
+
1256
1271
  mForm = rb_define_module_under(mNcurses, "Form");
1257
-
1272
+
1258
1273
  FORM_SNG_FUNC(current_field,1);
1259
1274
  FORM_SNG_FUNC(data_ahead,1);
1260
1275
  FORM_SNG_FUNC(data_behind,1);
@@ -1278,6 +1293,11 @@ void init_form(void)
1278
1293
  FORM_SNG_FUNC(field_type,1);
1279
1294
  /* FORM_SNG_FUNC(field_userptr,1); */
1280
1295
  FORM_SNG_FUNC(form_driver,2);
1296
+
1297
+ # ifdef HAVE_FORM_DRIVER_W
1298
+ FORM_SNG_FUNC(form_driver_w,3);
1299
+ #endif
1300
+
1281
1301
  FORM_SNG_FUNC(form_fields,1);
1282
1302
  FORM_SNG_FUNC(form_init,1);
1283
1303
  FORM_SNG_FUNC(form_opts,1);
@@ -1333,7 +1353,7 @@ void init_form(void)
1333
1353
  init_opts_constants();
1334
1354
  init_just_constants();
1335
1355
  init_form_opts_constants();
1336
-
1356
+
1337
1357
  /* Hashes to store registered blocks (Proc) */
1338
1358
  {
1339
1359
  VALUE hashes = rb_iv_set(mForm, "@proc_hashes", rb_ary_new());
@@ -1358,6 +1378,11 @@ void init_form(void)
1358
1378
  RB_CLASS_METH(cFORM, NULL, field_init,0);
1359
1379
  RB_CLASS_METH(cFORM, NULL, field_term,0);
1360
1380
  RB_CLASS_METH(cFORM, "driver", form_driver,1);
1381
+
1382
+ # ifdef HAVE_FORM_DRIVER_W
1383
+ RB_CLASS_METH(cFORM, "driver_w", form_driver_w,2);
1384
+ #endif
1385
+
1361
1386
  RB_CLASS_METH(cFORM, "fields", form_fields,0);
1362
1387
  RB_CLASS_METH(cFORM, "init", form_init,0);
1363
1388
  RB_CLASS_METH(cFORM, "opts", form_opts,0);