ncursesw 0.9.1.a
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +515 -0
- data/Changes +53 -0
- data/MANIFEST +26 -0
- data/README +318 -0
- data/THANKS +14 -0
- data/TODO +15 -0
- data/VERSION +1 -0
- data/examples/LICENSES_for_examples +26 -0
- data/examples/example.rb +129 -0
- data/examples/form.rb +82 -0
- data/examples/form2.rb +184 -0
- data/examples/hello_ncurses.rb +57 -0
- data/examples/rain.rb +219 -0
- data/examples/read_line.rb +67 -0
- data/examples/tclock.rb +227 -0
- data/examples/test_scanw.rb +27 -0
- data/extconf.rb +131 -0
- data/form_wrap.c +1449 -0
- data/form_wrap.h +62 -0
- data/lib/ncursesw.rb +324 -0
- data/make_dist.rb +45 -0
- data/ncurses_wrap.c +2735 -0
- data/ncurses_wrap.h +100 -0
- data/panel_wrap.c +256 -0
- data/panel_wrap.h +32 -0
- metadata +78 -0
data/Changes
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
ncurses-ruby-1.1
|
2
|
+
* Bugfixes by T. Sutherland in _tracef and _tracedump.
|
3
|
+
|
4
|
+
ncurses-ruby-1.0
|
5
|
+
* Mousemask bugfix from P.Duncan.
|
6
|
+
* Solved timing problems that affected visual smoothness of reactions
|
7
|
+
to user input
|
8
|
+
* Each SCREEN got back its own "halfdelay" and "cbreak" settings
|
9
|
+
|
10
|
+
ncurses-ruby-0.9.2
|
11
|
+
* Preventing getch and wgetch functions from blocking other ruby threads.
|
12
|
+
* Previously ncurses-ruby installed two files named "ncurses.rb" and
|
13
|
+
"ncurses.so". The "ncurses.so" is now renamed to "ncurses_bin.so"
|
14
|
+
to prevent "require 'ncurses'" from accidentally loading only the
|
15
|
+
binary file in case that this is found first in ruby's load path.
|
16
|
+
* Reintroduced ability to "include" Ncurses functions:
|
17
|
+
Use "include Ncurses::Namespace" for that. This is implemented via
|
18
|
+
method_missing, so that ncurses functions (some of which have very
|
19
|
+
common names) will not hide other functions defined in the extended
|
20
|
+
scope. (Any existing method_missing function is properly aliased and
|
21
|
+
called after an unsuccessful lookup.)
|
22
|
+
|
23
|
+
ncurses-ruby-0.9.1
|
24
|
+
* Bugfix in *in*str functions (Hiroshi Sainohira)
|
25
|
+
* Fix linking error on Mac OS X and some other platforms (Andreas Schwarz)
|
26
|
+
|
27
|
+
ncurses-ruby-0.9:
|
28
|
+
* Forms wrapper contributed by Simon Kaczor
|
29
|
+
* ncurses-ruby now also works with ncurses-4.2
|
30
|
+
(an old release from 1998, needed for Zaurus-port)
|
31
|
+
* First binary package for Sharp Zaurus (arm-linux)
|
32
|
+
|
33
|
+
ncurses-ruby-0.8:
|
34
|
+
* Bugfix: Calls into the ncurses library prior to calling
|
35
|
+
Ncurses::initscr or Ncurses::newterm had previously crashed
|
36
|
+
the Ruby interpreter.
|
37
|
+
Fixed by delaying the binding of most Ncurses functions
|
38
|
+
until after Ncurses::initscr or Ncurses::newterm have been
|
39
|
+
called.
|
40
|
+
* Replaced module functions with singleton functions. This
|
41
|
+
means that
|
42
|
+
include Ncurses
|
43
|
+
initscr
|
44
|
+
is no longer possible. Instead, use
|
45
|
+
Ncurses.initscr
|
46
|
+
Reasons: - Consistency. The shortcut has never been possible
|
47
|
+
with all ncurses functions.
|
48
|
+
- Namespace pollution. Some ncurses functions have
|
49
|
+
too common names.
|
50
|
+
|
51
|
+
ncurses-ruby-0.7.2:
|
52
|
+
* reintroduced Ncurses::pechochar and Ncurses::redrawwin in the ncurses build.
|
53
|
+
These had been removed by mistake because they did not work with PDCurses.
|
data/MANIFEST
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Changes
|
2
|
+
COPYING
|
3
|
+
MANIFEST
|
4
|
+
README
|
5
|
+
THANKS
|
6
|
+
TODO
|
7
|
+
VERSION
|
8
|
+
examples/example.rb
|
9
|
+
examples/form.rb
|
10
|
+
examples/form2.rb
|
11
|
+
examples/hello_ncurses.rb
|
12
|
+
examples/LICENSES_for_examples
|
13
|
+
examples/rain.rb
|
14
|
+
examples/tclock.rb
|
15
|
+
examples/read_line.rb
|
16
|
+
examples/test_scanw.rb
|
17
|
+
extconf.rb
|
18
|
+
form_wrap.c
|
19
|
+
form_wrap.h
|
20
|
+
make_dist.rb
|
21
|
+
ncurses_wrap.c
|
22
|
+
ncurses_wrap.h
|
23
|
+
lib/ncurses.rb
|
24
|
+
panel_wrap.c
|
25
|
+
panel_wrap.h
|
26
|
+
|
data/README
ADDED
@@ -0,0 +1,318 @@
|
|
1
|
+
$Id: README,v 1.14 2006/06/19 09:43:58 t-peters Exp $
|
2
|
+
------------------------------------------------------------------------
|
3
|
+
This directory contains a ruby module for accessing the FSF's ncurses
|
4
|
+
library.
|
5
|
+
(C) 2002, 2003, 2004 Tobias Peters <t-peters@users.berlios.de>
|
6
|
+
(C) 2004 Simon Kaczor <skaczor@cox.net>
|
7
|
+
(C) 2005 2006 Tobias Herzke <t-peters@users.berlios.de>
|
8
|
+
|
9
|
+
This module is free software; you can redistribute it and/or
|
10
|
+
modify it under the terms of the GNU Lesser General Public
|
11
|
+
License as published by the Free Software Foundation; either
|
12
|
+
version 2 of the License, or (at your option) any later version.
|
13
|
+
|
14
|
+
This module is distributed in the hope that it will be useful,
|
15
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
Lesser General Public License for more details.
|
18
|
+
|
19
|
+
You should have received a copy of the GNU Lesser General Public
|
20
|
+
License along with this module; if not, write to the Free Software
|
21
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22
|
+
------------------------------------------------------------------------
|
23
|
+
|
24
|
+
Overview
|
25
|
+
========
|
26
|
+
|
27
|
+
This README file explains how to use the ncurses ruby interface. It is
|
28
|
+
assumed that the reader has a rough understanding of what the ncurses
|
29
|
+
library is and how to use it from the C language. It then goes into
|
30
|
+
detail, explaining what is covered by the ruby interface, and the
|
31
|
+
rules that were followed in translating the C interface into a ruby
|
32
|
+
interface.
|
33
|
+
|
34
|
+
This ncurses interface provides access to the functions, macros,
|
35
|
+
global variables and constants of the ncurses library. These are
|
36
|
+
mapped to a Ruby Module named "Ncurses": Functions and external
|
37
|
+
variables are implemented as singleton functions of the Module
|
38
|
+
Ncurses.
|
39
|
+
|
40
|
+
This README is organized into the following parts:
|
41
|
+
- Overview
|
42
|
+
- Installation and Usage
|
43
|
+
- External Variables
|
44
|
+
- Constants
|
45
|
+
- Functions (and their Interfaces)
|
46
|
+
- Module / Class Hierarchie
|
47
|
+
- The WINDOW class
|
48
|
+
- The panel Library
|
49
|
+
- The form Library
|
50
|
+
- Ncurses and Ruby Threads
|
51
|
+
- Example programs
|
52
|
+
- Applications using ncurses-ruby
|
53
|
+
|
54
|
+
General Ncurses Literature
|
55
|
+
--------------------------
|
56
|
+
|
57
|
+
If you don't know how to use ncurses from C, then please read an
|
58
|
+
introduction to ncurses before continuing with this README. Eric
|
59
|
+
Raymond has written an introduction that should be part of the ncurses
|
60
|
+
development package installed on your computer.
|
61
|
+
If you'd like a gentler introduction, then you have two options:
|
62
|
+
(1) there is a part of a chapter in "The Linux Programmer's Guide" dealing
|
63
|
+
with ncurses, available from www.tldp.org. It is quite old by now,
|
64
|
+
but the ncurses interface has not changed since then, regarding the
|
65
|
+
scope of covered functions, so it is still a very good read.
|
66
|
+
(2) There is also an up-to-date "NCURSES-Programming-HOWTO" in the HOWTO
|
67
|
+
collection of the Linux Documentation Project, also available at
|
68
|
+
www.tldp.org, which is worth a read.
|
69
|
+
|
70
|
+
You will also appreciate the extensive man-pages of ncurses, a useful
|
71
|
+
reference while coding.
|
72
|
+
|
73
|
+
|
74
|
+
Installation and Usage
|
75
|
+
======================
|
76
|
+
|
77
|
+
ruby extconf.rb
|
78
|
+
make
|
79
|
+
make install
|
80
|
+
|
81
|
+
In your programs:
|
82
|
+
require "ncurses.rb"
|
83
|
+
|
84
|
+
If your programs use the scanw functions (most unlikely) you will have to
|
85
|
+
install the scanf library for ruby (http://www.rubyhacker.com/code/scanf).
|
86
|
+
|
87
|
+
Most ncurses functions are only available after either Ncurses.initscr or
|
88
|
+
Ncurses.newterm has returned successfully.
|
89
|
+
|
90
|
+
External Variables
|
91
|
+
==================
|
92
|
+
|
93
|
+
External variables are accessed read-only, by module functions taking no
|
94
|
+
arguments. They are spelled exactly like their C counterparts. Sometimes, this
|
95
|
+
leads to module functions beginning with an uppercase letter (e.g.
|
96
|
+
Ncurses.LINES).
|
97
|
+
|
98
|
+
One of these external variables, ESCDELAY, is also settable with a ruby method
|
99
|
+
(Ncurses.ESCDELAY=).
|
100
|
+
|
101
|
+
Another external variable, Ncurses.RESIZEDELAY is introduced by this wrapper.
|
102
|
+
It contains the maximum milliseconds delay with which terminal resizesings are
|
103
|
+
recognized.
|
104
|
+
|
105
|
+
Constants
|
106
|
+
=========
|
107
|
+
(static C Preprocessor macros)
|
108
|
+
|
109
|
+
Constants are implemented as module constants in the Ncurses module, if
|
110
|
+
possible. Ruby constants can not start with an underscore, so these constants
|
111
|
+
have been renamed (they lost the leading underscore). There are,however,
|
112
|
+
module functions with the same name as these constants, that also return
|
113
|
+
the constant's value, when invoked (e.g. "Ncurses._ENDLINE" returns the value
|
114
|
+
of the constant "Ncurses::ENDLINE", which has the same value as the C constant
|
115
|
+
"_ENDLINE").
|
116
|
+
|
117
|
+
Note: The ncurses macros starting with ACS_ are not constants, their value
|
118
|
+
depends on the terminal in use. Nevertheless, they are implemented as
|
119
|
+
constants of the Ncurses module, but since they depend on the terminal, they
|
120
|
+
are not initialized before initscr() has been called. If you need more than
|
121
|
+
one terminal in a single program, you can access the ACS_ values through member
|
122
|
+
functions of class SCREEN.
|
123
|
+
|
124
|
+
|
125
|
+
Functions (and their Interfaces)
|
126
|
+
================================
|
127
|
+
|
128
|
+
Functions (also those only implemented by macros in C) can be accessed
|
129
|
+
as module functions of the Module Ncurses. They take exactly the same
|
130
|
+
arguments as their C counterparts. Some of the C functions return additional
|
131
|
+
arguments through pointer arguments. These are implemented as follows:
|
132
|
+
|
133
|
+
|
134
|
+
Functions expecting pointers to integer types
|
135
|
+
---------------------------------------------
|
136
|
+
|
137
|
+
When the C-function expects a pointer to int, short, chtype, or attr_type,
|
138
|
+
You should use a variable containing an empty array as the argument to the ruby
|
139
|
+
function. This is because ruby passes these types (ints) "by value" instead of
|
140
|
+
"by reference"; but arrays are passed by reference, so that you can see the
|
141
|
+
changes to them.
|
142
|
+
Attention: some macro-only functions like getsyx accept variables of type int,
|
143
|
+
but, being macros, they write values to their arguments. Thus, they also need
|
144
|
+
empty array arguments when called from ruby.
|
145
|
+
Example:
|
146
|
+
color_pair_number = 4
|
147
|
+
foreground_color = []
|
148
|
+
background_color = []
|
149
|
+
if (Ncurses.pair_content(color_pair_number, foreground_color,
|
150
|
+
background_color) != Ncurses::ERR)
|
151
|
+
"color pair number #{color_pair_number} contains color number " +
|
152
|
+
"#{foreground_color[0]} as the foreground color, and color " +
|
153
|
+
"number #{background_color[0]} as the background color")
|
154
|
+
end
|
155
|
+
|
156
|
+
There are 2 functions that read a value from the location pointed to by a
|
157
|
+
pointer to int, and store another value at those locations. These functions are
|
158
|
+
mouse_trafo and wmouse_trafo. When calling these functions, you have to provide
|
159
|
+
2 arrays, each filled with exacly one Integer. The values contained in these
|
160
|
+
arrays will then be changed by the ruby module function.
|
161
|
+
|
162
|
+
|
163
|
+
Functions expecting (non-const) pointers to char
|
164
|
+
------------------------------------------------
|
165
|
+
|
166
|
+
When the C-function expects a pointer to char, you should use a variable
|
167
|
+
containing an empty string as the argument to the ruby function.
|
168
|
+
Example:
|
169
|
+
line2 = ""
|
170
|
+
if (Ncurses.mvwinnstr(Ncurses.stdscr, y=2, x=0, line2,
|
171
|
+
Ncurses.getmaxx(Ncurses.stdscr)) == Ncurses::ERR)
|
172
|
+
raise "could not scan 3rd line"
|
173
|
+
else
|
174
|
+
Ncurses.beep if line2.index("|")
|
175
|
+
end
|
176
|
+
The string that the C function would store at the pointer-to-char location
|
177
|
+
will be appended to the given string.
|
178
|
+
|
179
|
+
Functions expecting const pointers to char do not modify the string they
|
180
|
+
receive, you can pass any string to them.
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
Functions expecting pointers to structs
|
185
|
+
---------------------------------------------------
|
186
|
+
|
187
|
+
When the C-function expects a pointer to WINDOW, SCREEN, MEVENT,
|
188
|
+
PANEL, FORM, FIELD or FIELDTYPE then simply pass it the corresponding,
|
189
|
+
already existing ruby object.
|
190
|
+
|
191
|
+
|
192
|
+
scanf style functions expecting various pointers
|
193
|
+
---------------------------------------------------
|
194
|
+
|
195
|
+
namely scanw, mvscanw, wscanw, mvwscanw. Use an array after the format string.
|
196
|
+
The scanned values will be placed there. Remember, you need scanf for ruby
|
197
|
+
installed for these functions to work.
|
198
|
+
|
199
|
+
Module / Class Hierarchie
|
200
|
+
=========================
|
201
|
+
|
202
|
+
module Ncurses
|
203
|
+
class WINDOW; end
|
204
|
+
class SCREEN; end
|
205
|
+
class MEVENT; end
|
206
|
+
module Panel
|
207
|
+
class PANEL; end
|
208
|
+
end
|
209
|
+
module Form
|
210
|
+
class FORM; end
|
211
|
+
class FIELD; end
|
212
|
+
class FIELDTYPE; end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
The WINDOW class
|
218
|
+
================
|
219
|
+
|
220
|
+
The class WINDOW implements method_missing and tries to map invoked
|
221
|
+
methods to Ncurses module functions using a simple heuristic:
|
222
|
+
|
223
|
+
If the method name starts with "mv", it looks for a Ncurses module
|
224
|
+
function that starts with "mvw", and if it exists, adds itself to the
|
225
|
+
argument list and calls this function.
|
226
|
+
If no such module function exists, or the name of the invoked method
|
227
|
+
does not start with "mv", it looks if there is a module function with
|
228
|
+
the name "w" + methodname, and if it exists, adds itself again to the
|
229
|
+
argument list and calls this function.
|
230
|
+
If this module function did not exist either, then, as a last step, it
|
231
|
+
invokes a module function with the same name as the method, adding
|
232
|
+
itself to the argument list.
|
233
|
+
|
234
|
+
Example: If you invoke win.mvaddch(y,x,ch) on an Ncurses::WINDOW
|
235
|
+
object, it will delegate the method call to
|
236
|
+
Ncurses.mvwaddch(win,y,x,ch).
|
237
|
+
|
238
|
+
Other examples:
|
239
|
+
|
240
|
+
win.printw("hello") => Ncurses.wprintw(win, "hello")
|
241
|
+
|
242
|
+
win.getmaxyx(y=[],
|
243
|
+
x=[]) => Ncurses.getmaxyx(win,y,x)
|
244
|
+
|
245
|
+
win.delwin() => Ncurses.delwin(win) # win cannot be used
|
246
|
+
# after this call
|
247
|
+
|
248
|
+
|
249
|
+
The panel Library
|
250
|
+
=================
|
251
|
+
|
252
|
+
The panel library has also been wrapped. All panel functions are
|
253
|
+
implemented as module functions of the module Ncurses::Panel.
|
254
|
+
|
255
|
+
Most of these functions are also implemented as methods of class
|
256
|
+
Ncurses::Panel::PANEL, once with their original name and once with the
|
257
|
+
subword "panel" and an adjacent underscore removed.
|
258
|
+
|
259
|
+
The form Library
|
260
|
+
================
|
261
|
+
|
262
|
+
The form library was wrapped inside the Ncurses:Form module. All
|
263
|
+
form functions are implemented as module functions on the module
|
264
|
+
Ncurses::Form. In addition, all function for which the first
|
265
|
+
parameter is one of the objects are also implemented as an instance
|
266
|
+
method of the respective class. For example, instead of calling
|
267
|
+
post_form(form), you can use form.post_form().
|
268
|
+
|
269
|
+
Three objects are defined in the Ncurses:Form module:
|
270
|
+
1. FORM
|
271
|
+
2. FIELD
|
272
|
+
3. FIELDTYPE
|
273
|
+
|
274
|
+
They are wrapping actual ncurses pointers and should be use whenever a
|
275
|
+
pointer to one of these types is expected in function calls.
|
276
|
+
|
277
|
+
All form constants are defined in the module as Ruby constants with
|
278
|
+
the same name as the curses constants.
|
279
|
+
|
280
|
+
Constructors for FORM, FIELD and FIELDTYPE objects are also provided,
|
281
|
+
and they expect the same parameters as new_form, new_field and
|
282
|
+
new_fieldtype curses functions.
|
283
|
+
|
284
|
+
Field validation is implemented using Ruby Proc objects. You must
|
285
|
+
provide a Ruby block whenever a function pointer is expected in curses
|
286
|
+
function arguments. See the example form2.rb for more details.
|
287
|
+
|
288
|
+
The functions form_userptr and field_userptr are not supported. Use
|
289
|
+
form.user_object and field.user_object to store Ruby objects instead.
|
290
|
+
|
291
|
+
Ncurses and Ruby Threads
|
292
|
+
========================
|
293
|
+
|
294
|
+
The ncurses library is not thread-safe. Your application must properly
|
295
|
+
serialize calls into ncurses.
|
296
|
+
|
297
|
+
Prior to release 0.9.2, the getch and wgetch calls used to block the
|
298
|
+
complete ruby interpreter, all threads. This is no longer so. Other
|
299
|
+
threads should now continue to run during blocking calls to getch and
|
300
|
+
wgetch.
|
301
|
+
|
302
|
+
Example programs
|
303
|
+
================
|
304
|
+
|
305
|
+
Directory "examples" contains a few example programs demonstrating how
|
306
|
+
to use the ncurses library with ruby. Be sure to read the file
|
307
|
+
"examples/LICENSES_for_examples".
|
308
|
+
|
309
|
+
|
310
|
+
Applications using ncurses-ruby
|
311
|
+
===============================
|
312
|
+
|
313
|
+
aeditor (v. 0.x) - Pair programming editor, http://metaeditor.sourceforge.net/
|
314
|
+
raggle - RSS aggregator, http://www.raggle.org/about/
|
315
|
+
ruvi - Editor, http://ruvi.rubyforge.org/
|
316
|
+
diakonos - Editor, http://purepistos.net/diakonos/
|
317
|
+
tpp - text-based presentation program, http://synflood.at/tpp/
|
318
|
+
yapo - ports overview for CRUX linux distribution, http://jue.li/crux/yapo/
|
data/THANKS
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$Id: THANKS,v 1.8 2006/06/19 09:39:40 t-peters Exp $
|
2
|
+
|
3
|
+
A list of people that helped me with ncurses-ruby
|
4
|
+
|
5
|
+
Akinori MUSHA (knu at idaemons dot org)
|
6
|
+
Jan Becvar (jan dot becvar at solnet dot cz)
|
7
|
+
Juergen Daubert
|
8
|
+
Doug Kearns
|
9
|
+
Simon Kaczor (skaczor at cox dut net)
|
10
|
+
Hiroshi Sainohira
|
11
|
+
Andreas Schwarz
|
12
|
+
Simon Strandgaard
|
13
|
+
Paul Duncan
|
14
|
+
Tim Sutherland
|
data/TODO
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$Id: TODO,v 1.6 2003/03/22 22:55:27 t-peters Exp $
|
2
|
+
|
3
|
+
This is the complete list of functions present in ncurses that have not yet
|
4
|
+
been wrapped by ncurses-ruby:
|
5
|
+
|
6
|
+
terminfo functions: setupterm, setterm, set_curterm, del_curterm, restartterm,
|
7
|
+
tparm, tputs, vidputs
|
8
|
+
|
9
|
+
termcap fuctions: tgetent, tgetflag, tgetnum, tgetstr, tgoto
|
10
|
+
|
11
|
+
ncurses
|
12
|
+
kernel functions: ripoffline
|
13
|
+
|
14
|
+
No sense in
|
15
|
+
wrapping these: vw_printw, vwprintw, vwscanw
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1
|
@@ -0,0 +1,26 @@
|
|
1
|
+
$Id: LICENSES_for_examples,v 1.6 2004/05/13 21:55:17 t-peters Exp $
|
2
|
+
|
3
|
+
Ideally, an example program on how to use a library should be in the public
|
4
|
+
domain.
|
5
|
+
|
6
|
+
Some of the example programs contained in this dircectory have not been put in
|
7
|
+
the public domain, however.
|
8
|
+
|
9
|
+
The reason is because I did not write all programs completely myself -- I've
|
10
|
+
adapted the following example programs from ncurses programs in other
|
11
|
+
programming languages, or I have included example programs contributed by
|
12
|
+
other authors, and I have to respect their original licenses:
|
13
|
+
- rain.rb is adapted from rain.c from the ncurses library distribution.
|
14
|
+
- example.rb is adapted from an example program for the python ncurses binding.
|
15
|
+
- tclock.rb is adapted from tclock.c from the ncurses library distribution.
|
16
|
+
- form.rb anf form2.rb have been written by Simon Kaczor, who has adapted them
|
17
|
+
from sample code from the NCurses Programming HOWTO.
|
18
|
+
|
19
|
+
See the comments in the source files for restrictions imposed on copying and
|
20
|
+
modifying these.
|
21
|
+
|
22
|
+
That said, I suppose you may still look at their source code and learn how
|
23
|
+
ncurses programs generally work, as long as you dont start your own programs
|
24
|
+
by loading the example program into your editor and modify it to your needs.
|
25
|
+
|
26
|
+
Tobias Peters <t-peters@users.berlios.de>
|