ncursesw 0.9.1.a

Sign up to get free protection for your applications and to get access to all the features.
data/ncurses_wrap.h ADDED
@@ -0,0 +1,100 @@
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
+ *
6
+ * This module is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2 of the License, or (at your option) any later version.
10
+ *
11
+ * This module is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this module; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ *
20
+ * $Id: ncurses_wrap.h,v 1.2 2004/07/31 08:35:13 t-peters Exp $
21
+ *
22
+ * This file was adapted from the original ncurses header file which
23
+ * has the following copyright statements:
24
+ */
25
+
26
+ /****************************************************************************
27
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
28
+ * *
29
+ * Permission is hereby granted, free of charge, to any person obtaining a *
30
+ * copy of this software and associated documentation files (the *
31
+ * "Software"), to deal in the Software without restriction, including *
32
+ * without limitation the rights to use, copy, modify, merge, publish, *
33
+ * distribute, distribute with modifications, sublicense, and/or sell *
34
+ * copies of the Software, and to permit persons to whom the Software is *
35
+ * furnished to do so, subject to the following conditions: *
36
+ * *
37
+ * The above copyright notice and this permission notice shall be included *
38
+ * in all copies or substantial portions of the Software. *
39
+ * *
40
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
41
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
42
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
43
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
44
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
45
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
46
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
47
+ * *
48
+ * Except as contained in this notice, the name(s) of the above copyright *
49
+ * holders shall not be used in advertising or otherwise to promote the *
50
+ * sale, use or other dealings in this Software without prior written *
51
+ * authorization. *
52
+ ****************************************************************************/
53
+
54
+ /****************************************************************************
55
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
56
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
57
+ ****************************************************************************/
58
+
59
+ /*
60
+ NOT IMPLEMENTED:
61
+ - terminfo, termcap-functions
62
+ - rippoffline
63
+ - v*printw functions (but normal printw functions are supported!)
64
+ */
65
+
66
+ #if defined(HAVE_GETWIN) || defined(HAVE_PUTWIN)
67
+ # ifdef HAVE_UNISTD_H
68
+ # include <unistd.h>
69
+ # else
70
+ int dup(int);
71
+ int close(int);
72
+ # endif
73
+ #endif
74
+
75
+ #ifdef HAVE_NCURSES_H
76
+ # include <ncurses.h>
77
+ #else
78
+ # ifdef HAVE_NCURSES_CURSES_H
79
+ # include <ncurses/curses.h>
80
+ # else
81
+ # include <curses.h>
82
+ # endif
83
+ #endif
84
+
85
+ #include <locale.h>
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);
data/panel_wrap.c ADDED
@@ -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
data/panel_wrap.h ADDED
@@ -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,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ncursesw
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1.a
5
+ platform: ruby
6
+ authors: []
7
+
8
+ autorequire:
9
+ bindir:
10
+ cert_chain:
11
+ date: 2004-08-18 00:00:00 -07:00
12
+ default_executable:
13
+ dependencies: []
14
+
15
+ description: Hacked up version of ncurses gem that supports wide characters and ruby1.9.1. Original ncurses gem by t-peters@users.berlios.de.
16
+ email: lanerl@gmail.com
17
+ executables: []
18
+
19
+ extensions:
20
+ - extconf.rb
21
+ extra_rdoc_files: []
22
+
23
+ files:
24
+ - Changes
25
+ - COPYING
26
+ - MANIFEST
27
+ - README
28
+ - THANKS
29
+ - TODO
30
+ - VERSION
31
+ - examples/example.rb
32
+ - examples/form.rb
33
+ - examples/form2.rb
34
+ - examples/hello_ncurses.rb
35
+ - examples/LICENSES_for_examples
36
+ - examples/rain.rb
37
+ - examples/tclock.rb
38
+ - examples/read_line.rb
39
+ - examples/test_scanw.rb
40
+ - extconf.rb
41
+ - form_wrap.c
42
+ - form_wrap.h
43
+ - make_dist.rb
44
+ - ncurses_wrap.c
45
+ - ncurses_wrap.h
46
+ - lib/ncursesw.rb
47
+ - panel_wrap.c
48
+ - panel_wrap.h
49
+ has_rdoc: true
50
+ homepage: http://ncurses-ruby.berlios.de/
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">"
61
+ - !ruby/object:Gem::Version
62
+ version: 0.0.0
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ requirements: []
71
+
72
+ rubyforge_project:
73
+ rubygems_version: 1.3.3
74
+ signing_key:
75
+ specification_version: -1
76
+ 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."
77
+ test_files: []
78
+