snowleopard-ncurses 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,101 @@
1
+ /*
2
+ * ncurses-ruby is a ruby module for accessing the FSF's ncurses library
3
+ * (C) 2002, 2003 Tobias Peters <t-peters@berlios.de>
4
+ * (C) 2004 Simon Kaczor <skaczor@cox.net>
5
+ * (C) 2009 Tobias Herzke
6
+ *
7
+ * This module is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2 of the License, or (at your option) any later version.
11
+ *
12
+ * This module is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this module; if not, write to the Free Software
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ *
21
+ * $Id: ncurses_wrap.h,v 1.3 2009/05/03 20:37:26 t-peters Exp $
22
+ *
23
+ * This file was adapted from the original ncurses header file which
24
+ * has the following copyright statements:
25
+ */
26
+
27
+ /****************************************************************************
28
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
29
+ * *
30
+ * Permission is hereby granted, free of charge, to any person obtaining a *
31
+ * copy of this software and associated documentation files (the *
32
+ * "Software"), to deal in the Software without restriction, including *
33
+ * without limitation the rights to use, copy, modify, merge, publish, *
34
+ * distribute, distribute with modifications, sublicense, and/or sell *
35
+ * copies of the Software, and to permit persons to whom the Software is *
36
+ * furnished to do so, subject to the following conditions: *
37
+ * *
38
+ * The above copyright notice and this permission notice shall be included *
39
+ * in all copies or substantial portions of the Software. *
40
+ * *
41
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
42
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
43
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
44
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
45
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
46
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
47
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
48
+ * *
49
+ * Except as contained in this notice, the name(s) of the above copyright *
50
+ * holders shall not be used in advertising or otherwise to promote the *
51
+ * sale, use or other dealings in this Software without prior written *
52
+ * authorization. *
53
+ ****************************************************************************/
54
+
55
+ /****************************************************************************
56
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
57
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
58
+ ****************************************************************************/
59
+
60
+ /*
61
+ NOT IMPLEMENTED:
62
+ - terminfo, termcap-functions
63
+ - rippoffline
64
+ - v*printw functions (but normal printw functions are supported!)
65
+ */
66
+
67
+ #if defined(HAVE_GETWIN) || defined(HAVE_PUTWIN)
68
+ # ifdef HAVE_UNISTD_H
69
+ # include <unistd.h>
70
+ # else
71
+ int dup(int);
72
+ int close(int);
73
+ # endif
74
+ #endif
75
+
76
+ #ifdef HAVE_NCURSES_H
77
+ # include <ncurses.h>
78
+ #else
79
+ # ifdef HAVE_NCURSES_CURSES_H
80
+ # include <ncurses/curses.h>
81
+ # else
82
+ # include <curses.h>
83
+ # endif
84
+ #endif
85
+
86
+ #include <ruby.h>
87
+
88
+ extern VALUE mNcurses; /* module Ncurses */
89
+ extern VALUE cWINDOW; /* class Ncurses::WINDOW */
90
+ extern VALUE cSCREEN; /* class Ncurses::SCREEN */
91
+ extern VALUE eNcurses; /* Ncurses::Exception thrown by this extension */
92
+
93
+ #define NCFUNC(name, nargs) \
94
+ rb_define_singleton_method(mNcurses, \
95
+ #name, \
96
+ &rbncurs_ ## name, \
97
+ nargs)
98
+
99
+ WINDOW* get_window(VALUE rb_window);
100
+ VALUE wrap_window(WINDOW* window);
101
+ long rbncurs_array_length(VALUE rb_array);
@@ -0,0 +1,256 @@
1
+ /*
2
+ * ncurses-ruby is a ruby module for accessing the FSF's ncurses library
3
+ * (C) 2002 Tobias Peters <t-peters@berlios.de>
4
+ *
5
+ * This module is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2 of the License, or (at your option) any later version.
9
+ *
10
+ * This module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this module; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ */
19
+
20
+ /* $Id: panel_wrap.c,v 1.2 2004/07/31 08:35:13 t-peters Exp $ */
21
+
22
+ #ifdef HAVE_PANEL_H
23
+
24
+ #include "panel_wrap.h"
25
+ #include "ncurses_wrap.h"
26
+
27
+ VALUE mPanel;
28
+ VALUE cPANEL;
29
+
30
+ static VALUE wrap_panel(PANEL* panel)
31
+ {
32
+ if (panel == 0) return Qnil;
33
+ {
34
+ VALUE panels_hash = rb_iv_get(mPanel, "@panels_hash");
35
+ VALUE panel_adress = INT2NUM((long)(panel));
36
+ VALUE rb_panel = rb_hash_aref(panels_hash, panel_adress);
37
+ if (rb_panel == Qnil) {
38
+ rb_panel = Data_Wrap_Struct(cPANEL, 0, 0, panel);
39
+ rb_iv_set(rb_panel, "@destroyed", Qfalse);
40
+ rb_hash_aset(panels_hash, panel_adress, rb_panel);
41
+ }
42
+ return rb_panel;
43
+ }
44
+ }
45
+ static PANEL* get_panel(VALUE rb_panel)
46
+ {
47
+ PANEL* panel;
48
+ if (rb_panel == Qnil) return 0;
49
+ if (rb_iv_get(rb_panel, "@destroyed") == Qtrue) {
50
+ rb_raise(rb_eRuntimeError, "Attempt to access a destroyed panel");
51
+ return 0;
52
+ }
53
+ Data_Get_Struct(rb_panel, PANEL, panel);
54
+ return panel;
55
+ }
56
+ static VALUE rbncurs_c_del_panel(VALUE rb_panel) {
57
+ VALUE panels_hash = rb_iv_get(mPanel, "@panels_hash");
58
+ PANEL* panel = get_panel(rb_panel);
59
+ VALUE panel_adress = INT2NUM((long)(panel));
60
+ rb_funcall(panels_hash, rb_intern("delete"), 1, panel_adress);
61
+ rb_iv_set(rb_panel, "@destroyed", Qtrue);
62
+ return INT2NUM(del_panel(panel));
63
+ }
64
+ static VALUE rbncurs_m_del_panel(VALUE dummy, VALUE rb_panel)
65
+ { return rbncurs_c_del_panel(rb_panel); }
66
+
67
+ static VALUE rbncurs_c_panel_window(VALUE rb_panel)
68
+ { return wrap_window(panel_window(get_panel(rb_panel))); }
69
+ static VALUE rbncurs_m_panel_window(VALUE dummy, VALUE rb_panel)
70
+ { return rbncurs_c_panel_window(rb_panel); }
71
+
72
+ static VALUE rbncurs_m_update_panels(VALUE dummy)
73
+ { update_panels(); return Qnil; }
74
+
75
+ static VALUE rbncurs_c_hide_panel(VALUE rb_panel)
76
+ { return INT2NUM(hide_panel(get_panel(rb_panel))); }
77
+ static VALUE rbncurs_m_hide_panel(VALUE dummy, VALUE rb_panel)
78
+ { return rbncurs_c_hide_panel(rb_panel); }
79
+
80
+ static VALUE rbncurs_c_show_panel(VALUE rb_panel)
81
+ { return INT2NUM(show_panel(get_panel(rb_panel))); }
82
+ static VALUE rbncurs_m_show_panel(VALUE dummy, VALUE rb_panel)
83
+ { return rbncurs_c_show_panel(rb_panel); }
84
+
85
+ static VALUE rbncurs_c_top_panel(VALUE rb_panel)
86
+ { return INT2NUM(top_panel(get_panel(rb_panel))); }
87
+ static VALUE rbncurs_m_top_panel(VALUE dummy, VALUE rb_panel)
88
+ { return rbncurs_c_top_panel(rb_panel); }
89
+
90
+ static VALUE rbncurs_c_bottom_panel(VALUE rb_panel)
91
+ { return INT2NUM(bottom_panel(get_panel(rb_panel))); }
92
+ static VALUE rbncurs_m_bottom_panel(VALUE dummy, VALUE rb_panel)
93
+ { return rbncurs_c_bottom_panel(rb_panel); }
94
+
95
+ static VALUE rbncurs_c_new_panel(VALUE rb_window)
96
+ { return wrap_panel(new_panel(get_window(rb_window))); }
97
+ static VALUE rbncurs_m_new_panel(VALUE dummy, VALUE rb_window)
98
+ { return rbncurs_c_new_panel(rb_window); }
99
+ static VALUE rbncurs_c_panel_above(VALUE rb_panel)
100
+ { return wrap_panel(panel_above(get_panel(rb_panel))); }
101
+ static VALUE rbncurs_m_panel_above(VALUE rb_panel)
102
+ { return rbncurs_c_panel_above(rb_panel); }
103
+ static VALUE rbncurs_c_panel_below(VALUE rb_panel)
104
+ { return wrap_panel(panel_below(get_panel(rb_panel))); }
105
+ static VALUE rbncurs_m_panel_below(VALUE rb_panel)
106
+ { return rbncurs_c_panel_below(rb_panel); }
107
+ static VALUE rbncurs_c_set_panel_userptr(VALUE rb_panel, VALUE userptr)
108
+ { return INT2NUM(set_panel_userptr(get_panel(rb_panel),
109
+ (void*)(userptr))); }
110
+ static VALUE rbncurs_m_set_panel_userptr(VALUE dummy, VALUE rb_panel, VALUE userptr)
111
+ { return rbncurs_c_set_panel_userptr(rb_panel, userptr); }
112
+ static VALUE rbncurs_c_panel_userptr(VALUE rb_panel)
113
+ { return (VALUE)(panel_userptr(get_panel(rb_panel))); }
114
+ static VALUE rbncurs_m_panel_userptr(VALUE dummy, VALUE rb_panel)
115
+ { return rbncurs_c_panel_userptr(rb_panel); }
116
+ static VALUE rbncurs_c_move_panel(VALUE rb_panel, VALUE starty, VALUE startx)
117
+ { return INT2NUM(move_panel(get_panel(rb_panel), NUM2INT(starty),
118
+ NUM2INT(startx))); }
119
+ static VALUE rbncurs_m_move_panel(VALUE dummy, VALUE rb_panel, VALUE starty, VALUE startx)
120
+ { return rbncurs_c_move_panel(rb_panel, starty, startx); }
121
+ static VALUE rbncurs_c_replace_panel(VALUE rb_panel, VALUE rb_window)
122
+ { return INT2NUM(replace_panel(get_panel(rb_panel), get_window(rb_window))); }
123
+ static VALUE rbncurs_m_replace_panel(VALUE dummy, VALUE rb_panel, VALUE rb_window)
124
+ { return rbncurs_c_replace_panel(rb_panel, rb_window); }
125
+ static VALUE rbncurs_c_panel_hidden(VALUE rb_panel)
126
+ { return panel_hidden(get_panel(rb_panel)) ? Qtrue : Qfalse; }
127
+ static VALUE rbncurs_m_panel_hidden(VALUE dummy, VALUE rb_panel)
128
+ { return rbncurs_c_panel_hidden(rb_panel); }
129
+
130
+
131
+ void init_panel(void)
132
+ {
133
+ mPanel = rb_define_module_under(mNcurses, "Panel");
134
+ rb_iv_set(mPanel, "@panels_hash", rb_hash_new());
135
+ cPANEL = rb_define_class_under(mPanel, "PANEL", rb_cObject);
136
+ rb_define_singleton_method(mPanel, "del_panel",
137
+ (&rbncurs_m_del_panel),
138
+ 1);
139
+ rb_define_singleton_method(mPanel, "delpanel",
140
+ (&rbncurs_m_del_panel),
141
+ 1);
142
+ rb_define_method(cPANEL, "del",
143
+ (&rbncurs_c_del_panel), 0);
144
+ rb_define_method(cPANEL, "delete",
145
+ (&rbncurs_c_del_panel), 0);
146
+ rb_define_singleton_method(mPanel, "panel_window",
147
+ (&rbncurs_m_panel_window),
148
+ 1);
149
+ rb_define_method(cPANEL, "panel_window",
150
+ (&rbncurs_c_panel_window), 0);
151
+ rb_define_method(cPANEL, "window",
152
+ (&rbncurs_c_panel_window), 0);
153
+ rb_define_singleton_method(mPanel, "update_panels",
154
+ (&rbncurs_m_update_panels),
155
+ 0);
156
+ rb_define_singleton_method(mPanel, "update",
157
+ (&rbncurs_m_update_panels),
158
+ 0);
159
+ rb_define_singleton_method(mPanel, "hide_panel",
160
+ (&rbncurs_m_hide_panel),
161
+ 1);
162
+ rb_define_method(cPANEL, "hide_panel",
163
+ (&rbncurs_c_hide_panel), 0);
164
+
165
+ rb_define_method(cPANEL, "hide",
166
+ (&rbncurs_c_hide_panel), 0);
167
+ rb_define_singleton_method(mPanel, "show_panel",
168
+ (&rbncurs_m_show_panel),
169
+ 1);
170
+ rb_define_method(cPANEL, "show_panel",
171
+ (&rbncurs_c_show_panel), 0);
172
+
173
+ rb_define_method(cPANEL, "show",
174
+ (&rbncurs_c_show_panel), 0);
175
+ rb_define_singleton_method(mPanel, "top_panel",
176
+ (&rbncurs_m_top_panel), 1);
177
+ rb_define_method(cPANEL, "top_panel",
178
+ (&rbncurs_c_top_panel), 0);
179
+
180
+ rb_define_method(cPANEL, "top",
181
+ (&rbncurs_c_top_panel), 0);
182
+ rb_define_singleton_method(mPanel, "bottom_panel",
183
+ (&rbncurs_m_bottom_panel),
184
+ 1);
185
+ rb_define_method(cPANEL, "bottom_panel",
186
+ (&rbncurs_c_bottom_panel), 0);
187
+
188
+ rb_define_method(cPANEL, "bottom",
189
+ (&rbncurs_c_bottom_panel), 0);
190
+ rb_define_singleton_method(mPanel, "new_panel",
191
+ (&rbncurs_m_new_panel),
192
+ 1);
193
+ rb_define_singleton_method(cPANEL, "new",
194
+ (&rbncurs_m_new_panel),
195
+ 1);
196
+ rb_define_method(cWINDOW, "new_panel",
197
+ (&rbncurs_c_new_panel),
198
+ 0);
199
+ rb_define_singleton_method(mPanel, "panel_above",
200
+ (&rbncurs_m_panel_above),
201
+ 1);
202
+ rb_define_method(cPANEL, "panel_above",
203
+ (&rbncurs_c_panel_above), 0);
204
+ rb_define_method(cPANEL, "above",
205
+ (&rbncurs_c_panel_above), 0);
206
+ rb_define_singleton_method(mPanel, "panel_below",
207
+ (&rbncurs_m_panel_below),
208
+ 1);
209
+ rb_define_method(cPANEL, "panel_below",
210
+ (&rbncurs_c_panel_below), 0);
211
+ rb_define_method(cPANEL, "below",
212
+ (&rbncurs_c_panel_below), 0);
213
+ rb_define_singleton_method(mPanel, "set_panel_userptr",
214
+ (&rbncurs_m_set_panel_userptr), 2);
215
+ rb_define_method(cPANEL, "set_panel_userptr",
216
+ (&rbncurs_c_set_panel_userptr),
217
+ 1);
218
+ rb_define_method(cPANEL, "set_userptr",
219
+ (&rbncurs_c_set_panel_userptr),
220
+ 1);
221
+ rb_define_method(cPANEL, "userptr=",
222
+ (&rbncurs_c_set_panel_userptr),
223
+ 1);
224
+ rb_define_singleton_method(mPanel, "panel_userptr",
225
+ (&rbncurs_m_panel_userptr),
226
+ 1);
227
+ rb_define_method(cPANEL, "panel_userptr",
228
+ (&rbncurs_c_panel_userptr),
229
+ 0);
230
+ rb_define_method(cPANEL, "userptr",
231
+ (&rbncurs_c_panel_userptr),
232
+ 0);
233
+ rb_define_singleton_method(mPanel, "move_panel",
234
+ (&rbncurs_m_move_panel),
235
+ 3);
236
+ rb_define_method(cPANEL, "move_panel",
237
+ (&rbncurs_c_move_panel), 2);
238
+ rb_define_method(cPANEL, "move",
239
+ (&rbncurs_c_move_panel), 2);
240
+ rb_define_singleton_method(mPanel, "replace_panel",
241
+ (&rbncurs_m_replace_panel),
242
+ 2);
243
+ rb_define_method(cPANEL, "replace_panel",
244
+ (&rbncurs_c_replace_panel), 1);
245
+ rb_define_method(cPANEL, "replace",
246
+ (&rbncurs_c_replace_panel), 1);
247
+ rb_define_singleton_method(mPanel, "panel_hidden?",
248
+ (&rbncurs_m_panel_hidden),
249
+ 1);
250
+ rb_define_method(cPANEL, "panel_hidden?",
251
+ (&rbncurs_c_panel_hidden), 0);
252
+ rb_define_method(cPANEL, "hidden?",
253
+ (&rbncurs_c_panel_hidden), 0);
254
+ }
255
+
256
+ #endif
@@ -0,0 +1,32 @@
1
+ /*
2
+ * ncurses-ruby is a ruby module for accessing the FSF's ncurses library
3
+ * (C) 2002 Tobias Peters <t-peters@berlios.de>
4
+ *
5
+ * This module is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2 of the License, or (at your option) any later version.
9
+ *
10
+ * This module is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this module; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ */
19
+
20
+ /* $Id: panel_wrap.h,v 1.5 2004/07/31 08:35:13 t-peters Exp $ */
21
+
22
+ #if !defined(PANEL_HH) && defined(HAVE_PANEL_H)
23
+ #define PANEL_HH
24
+ #include <panel.h>
25
+ #include <ruby.h>
26
+
27
+ extern VALUE mPanel;
28
+ extern VALUE cPANEL;
29
+
30
+ void init_panel(void);
31
+
32
+ #endif
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snowleopard-ncurses
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 2
8
+ - 4
9
+ version: 1.2.4
10
+ platform: ruby
11
+ authors:
12
+ - Tobias Peters
13
+ autorequire: ncurses
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-26 00:00:00 +05:30
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Updated for Snow Leopard ruby 1.9.2 (Ralf Papenkordt). 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.
22
+ email: t-peters@users.berlios.de
23
+ executables: []
24
+
25
+ extensions:
26
+ - extconf.rb
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - Changes
31
+ - COPYING
32
+ - Makefile
33
+ - MANIFEST
34
+ - README
35
+ - THANKS
36
+ - TODO
37
+ - VERSION
38
+ - form_wrap.c
39
+ - menu_wrap.c
40
+ - ncurses_wrap.c
41
+ - panel_wrap.c
42
+ - form_wrap.h
43
+ - menu_wrap.h
44
+ - ncurses_wrap.h
45
+ - panel_wrap.h
46
+ - extconf.rb
47
+ - make_dist.rb
48
+ - examples/example.rb
49
+ - examples/form.rb
50
+ - examples/form2.rb
51
+ - examples/hello_ncurses.rb
52
+ - examples/LICENSES_for_examples
53
+ - examples/rain.rb
54
+ - examples/read_line.rb
55
+ - examples/tclock.rb
56
+ - examples/test_scanw.rb
57
+ - lib/ncurses.rb
58
+ has_rdoc: false
59
+ homepage: http://totalrecall.wordpress.com
60
+ licenses: []
61
+
62
+ post_install_message:
63
+ rdoc_options: []
64
+
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.3.7
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Updated for Snow Leopard ruby 1.9.2 (Ralf Papenkordt). 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.
90
+ test_files: []
91
+