ncursesw 0.9.2 → 1.2.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/menu_wrap.h ADDED
@@ -0,0 +1,49 @@
1
+ /*
2
+ * This is a curses menu wrapper as part of ncurses-ruby.
3
+ * It borrows heavily from form_wrap.h.
4
+ * Contributed by Earle Clubb <eclubb@valcom.com>
5
+ * Valcom Inc. <http://www.valcom.com>
6
+ * Copyright 2007
7
+ *
8
+ * This module is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU Lesser General Public
10
+ * License as published by the Free Software Foundation; either
11
+ * version 2 of the License, or (at your option) any later version.
12
+ *
13
+ * This module is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ * Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public
19
+ * License along with this module; if not, write to the Free Software
20
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ *
22
+ */
23
+
24
+ #if !defined(MENU_HH) && defined(HAVE_MENU_H)
25
+ #define MENU_HH
26
+
27
+ #include <menu.h>
28
+ #include <ruby.h>
29
+
30
+ extern VALUE mMenu;
31
+ extern VALUE cITEM;
32
+ extern VALUE cMENU;
33
+
34
+ #define MENU_DEF_CONST(name) \
35
+ rb_define_const(mMenu, #name, INT2NUM(name));
36
+
37
+ #define MENU_SNG_FUNC(name, nargs) \
38
+ rb_define_singleton_method(mMenu, #name, &rbncurs_m_ ## name, nargs)
39
+
40
+ #define RB_CLASS_METH(class, alt_name, name, nargs) \
41
+ rb_define_method(class, #name, (&rbncurs_c_ ## name), nargs); \
42
+ if (alt_name != NULL) \
43
+ rb_define_method(class, alt_name, (&rbncurs_c_ ## name), nargs); \
44
+
45
+ //void init_menu_req_constants(void);
46
+ //void init_menu_opts_constants(void);
47
+ void init_menu(void);
48
+
49
+ #endif
data/ncurses_wrap.c CHANGED
@@ -2,7 +2,7 @@
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 Tobias Herzke
5
+ * (C) 2005 2006 2009 Tobias Herzke
6
6
  *
7
7
  * This module is free software; you can redistribute it and/or
8
8
  * modify it under the terms of the GNU Lesser General Public
@@ -18,7 +18,7 @@
18
18
  * License along with this module; if not, write to the Free Software
19
19
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
20
  *
21
- * $Id: ncurses_wrap.c,v 1.13 2006/06/19 09:46:59 t-peters Exp $
21
+ * $Id: ncurses_wrap.c,v 1.18 2009/07/31 10:49:24 t-peters Exp $
22
22
  *
23
23
  * This file was adapted from the original ncurses header file which
24
24
  * has the following copyright statements:
@@ -65,6 +65,9 @@
65
65
  */
66
66
 
67
67
  #include "ncurses_wrap.h"
68
+ #ifdef HAVE_LOCALE_H
69
+ #include <locale.h>
70
+ #endif
68
71
 
69
72
  VALUE mNcurses; /* module Ncurses */
70
73
  VALUE cWINDOW; /* class Ncurses::WINDOW */
@@ -120,6 +123,17 @@ init_constants_1(void)
120
123
  rb_define_const(mNcurses, "WA_TOP", INT2NUM(WA_TOP));
121
124
  rb_define_const(mNcurses, "WA_VERTICAL", INT2NUM(WA_VERTICAL));
122
125
  #endif
126
+
127
+ /* locale flags */
128
+ #ifdef HAVE_LOCALE_H
129
+ rb_define_const(mNcurses, "LC_ALL", INT2NUM(LC_ALL));
130
+ rb_define_const(mNcurses, "LC_COLLATE", INT2NUM(LC_COLLATE));
131
+ rb_define_const(mNcurses, "LC_CTYPE", INT2NUM(LC_CTYPE));
132
+ rb_define_const(mNcurses, "LC_MESSAGES", INT2NUM(LC_MESSAGES));
133
+ rb_define_const(mNcurses, "LC_MONETARY", INT2NUM(LC_MONETARY));
134
+ rb_define_const(mNcurses, "LC_NUMERIC", INT2NUM(LC_NUMERIC));
135
+ rb_define_const(mNcurses, "LC_TIME", INT2NUM(LC_TIME));
136
+ #endif
123
137
  }
124
138
 
125
139
  static VALUE rbncurs_COLORS()
@@ -193,6 +207,12 @@ init_constants_2(void)
193
207
  #endif
194
208
  }
195
209
 
210
+ /// Portable (1.8,1.9) determination of array length (calling #length)
211
+ long rbncurs_array_length(VALUE array)
212
+ {
213
+ return NUM2LONG(rb_funcall(array, rb_intern("length"), 0));
214
+ }
215
+
196
216
  VALUE wrap_window(WINDOW* window)
197
217
  {
198
218
  if (window == 0) return Qnil;
@@ -323,6 +343,10 @@ static VALUE rbncurs_winnstr(VALUE dummy, VALUE rb_win, VALUE rb_chstr, VALUE rb
323
343
  #include "form_wrap.h" /* needs init_form */
324
344
  #endif
325
345
 
346
+ #ifdef HAVE_MENU_H
347
+ #include "menu_wrap.h" /* needs init_menu */
348
+ #endif
349
+
326
350
  static
327
351
  void
328
352
  init_functions_0(void)
@@ -790,7 +814,7 @@ static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
790
814
  int halfdelay = NUM2INT(rb_iv_get(mNcurses, "@halfdelay"));
791
815
  int infd = NUM2INT(rb_iv_get(mNcurses, "@infd"));
792
816
  double screen_delay = halfdelay * 0.1;
793
- #ifdef NCURSES_VERSION
817
+ #if defined(NCURSES_VERSION) && defined(NCURSES_OPAQUE) && !NCURSES_OPAQUE
794
818
  int windelay = c_win->_delay;
795
819
  #else
796
820
  int windelay = 0;
@@ -807,7 +831,7 @@ static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
807
831
  gettimeofday(&tv, &tz);
808
832
  starttime = tv.tv_sec + tv.tv_usec * 1e-6;
809
833
  finishtime = starttime + delay;
810
- #ifdef NCURSES_VERSION
834
+ #if defined(NCURSES_VERSION) && defined(NCURSES_OPAQUE) && !NCURSES_OPAQUE
811
835
  c_win->_delay = 0;
812
836
  #endif
813
837
  while (doupdate() /* detects resize */, (result = wgetch(c_win)) == ERR) {
@@ -826,7 +850,7 @@ static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
826
850
  FD_SET(infd, &in_fds);
827
851
  rb_thread_select(infd + 1, &in_fds, NULL, NULL, &tv);
828
852
  }
829
- #ifdef NCURSES_VERSION
853
+ #if defined(NCURSES_VERSION) && defined(NCURSES_OPAQUE) && !NCURSES_OPAQUE
830
854
  c_win->_delay = windelay;
831
855
  #endif
832
856
  return result;
@@ -2680,6 +2704,11 @@ void init_SCREEN_methods(void)
2680
2704
  #endif
2681
2705
  }
2682
2706
 
2707
+ #ifdef HAVE_LOCALE_H
2708
+ static VALUE rbncurs_setlocale(VALUE dummy, VALUE category, VALUE locale)
2709
+ { return rb_str_new2(setlocale(NUM2INT(category), STR2CSTR(locale)));}
2710
+ #endif
2711
+
2683
2712
  static void init_safe_functions(void)
2684
2713
  {
2685
2714
  NCFUNC(initscr, 0);
@@ -2691,6 +2720,9 @@ static void init_safe_functions(void)
2691
2720
  #ifdef HAVE_USE_ENV
2692
2721
  NCFUNC(use_env, 1);
2693
2722
  #endif
2723
+ #ifdef HAVE_LOCALE_H
2724
+ NCFUNC(setlocale, 2);
2725
+ #endif
2694
2726
  }
2695
2727
  void Init_ncursesw_bin(void)
2696
2728
  {
@@ -2732,4 +2764,7 @@ static void Init_ncurses_full(void)
2732
2764
  #ifdef HAVE_FORM_H
2733
2765
  init_form();
2734
2766
  #endif
2767
+ #ifdef HAVE_MENU_H
2768
+ init_menu();
2769
+ #endif
2735
2770
  }
data/ncurses_wrap.h CHANGED
@@ -2,7 +2,8 @@
2
2
  * ncurses-ruby is a ruby module for accessing the FSF's ncurses library
3
3
  * (C) 2002, 2003 Tobias Peters <t-peters@berlios.de>
4
4
  * (C) 2004 Simon Kaczor <skaczor@cox.net>
5
- *
5
+ * (C) 2009 Tobias Herzke
6
+ *
6
7
  * This module is free software; you can redistribute it and/or
7
8
  * modify it under the terms of the GNU Lesser General Public
8
9
  * License as published by the Free Software Foundation; either
@@ -17,7 +18,7 @@
17
18
  * License along with this module; if not, write to the Free Software
18
19
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20
  *
20
- * $Id: ncurses_wrap.h,v 1.2 2004/07/31 08:35:13 t-peters Exp $
21
+ * $Id: ncurses_wrap.h,v 1.3 2009/05/03 20:37:26 t-peters Exp $
21
22
  *
22
23
  * This file was adapted from the original ncurses header file which
23
24
  * has the following copyright statements:
@@ -98,3 +99,4 @@ extern VALUE eNcurses; /* Ncurses::Exception thrown by this extension */
98
99
 
99
100
  WINDOW* get_window(VALUE rb_window);
100
101
  VALUE wrap_window(WINDOW* window);
102
+ long rbncurs_array_length(VALUE rb_array);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncursesw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 1.2.4.1
5
5
  platform: ruby
6
6
  authors: []
7
7
 
8
8
  autorequire:
9
9
  bindir:
10
10
  cert_chain:
11
- date: 2004-08-18 00:00:00 -07:00
11
+ date: 2009-12-31 18:27:27 -08:00
12
12
  default_executable:
13
13
  dependencies: []
14
14
 
@@ -46,6 +46,8 @@ files:
46
46
  - lib/ncursesw.rb
47
47
  - panel_wrap.c
48
48
  - panel_wrap.h
49
+ - menu_wrap.c
50
+ - menu_wrap.h
49
51
  has_rdoc: true
50
52
  homepage: http://ncurses-ruby.berlios.de/
51
53
  licenses: []
@@ -70,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
72
  requirements: []
71
73
 
72
74
  rubyforge_project:
73
- rubygems_version: 1.3.3
75
+ rubygems_version: 1.3.5
74
76
  signing_key:
75
77
  specification_version: -1
76
78
  summary: "This wrapper provides access to the functions, macros, global variables and constants of the ncurses library. These are mapped to a Ruby Module named \"Ncurses\": Functions and external variables are implemented as singleton functions of the Module Ncurses."