ncurses-ruby 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Changelog.md +68 -0
- data/LICENSE.txt +17 -0
- data/README.md +327 -0
- data/THANKS +1 -0
- data/examples/tclock.rb +1 -1
- data/ext/ncurses/Makefile +238 -0
- data/ext/ncurses/extconf.rb +6 -1
- data/ext/ncurses/form_wrap.c +1 -1
- data/ext/ncurses/form_wrap.o +0 -0
- data/ext/ncurses/menu_wrap.o +0 -0
- data/ext/ncurses/ncurses.so +0 -0
- data/ext/ncurses/ncurses_wrap.c +14 -13
- data/ext/ncurses/ncurses_wrap.h +1 -0
- data/ext/ncurses/ncurses_wrap.o +0 -0
- data/ext/ncurses/panel_wrap.o +0 -0
- data/lib/ncurses-ruby/version.rb +1 -1
- metadata +39 -51
- data/Changes +0 -53
- data/README +0 -351
data/ext/ncurses/extconf.rb
CHANGED
@@ -27,7 +27,12 @@ $CXXFLAGS = $CFLAGS
|
|
27
27
|
|
28
28
|
# Add paths for NetBSD.
|
29
29
|
$CFLAGS += " -I/usr/pkg/include"
|
30
|
-
|
30
|
+
if (/darwin/ =~ RUBY_PLATFORM)
|
31
|
+
$LDFLAGS = ""
|
32
|
+
$DLDFLAGS = "-undefineddynamic_lookup"
|
33
|
+
else
|
34
|
+
$LDFLAGS += " -L/usr/pkg/lib"
|
35
|
+
end
|
31
36
|
|
32
37
|
have_header("unistd.h")
|
33
38
|
if have_header("ncurses.h")
|
data/ext/ncurses/form_wrap.c
CHANGED
@@ -1130,7 +1130,7 @@ static void* make_arg(va_list* ap) {
|
|
1130
1130
|
char msg[500];
|
1131
1131
|
snprintf(msg, 500, "The validation functions for this field type need %d additional arguments.",NUM2INT(argc)-1);
|
1132
1132
|
msg[499]=0;
|
1133
|
-
rb_raise(rb_eArgError, msg);
|
1133
|
+
rb_raise(rb_eArgError, "%s", msg);
|
1134
1134
|
}
|
1135
1135
|
}
|
1136
1136
|
}
|
Binary file
|
Binary file
|
Binary file
|
data/ext/ncurses/ncurses_wrap.c
CHANGED
@@ -518,7 +518,7 @@ init_functions_1(void)
|
|
518
518
|
#endif
|
519
519
|
}
|
520
520
|
/* FIXME: what's this? */
|
521
|
-
/* extern char ttytype[]; */
|
521
|
+
/* extern char ttytype[]; */ /* needed for backward compatibility */
|
522
522
|
|
523
523
|
|
524
524
|
/* copy a chstr from ruby to c */
|
@@ -807,7 +807,7 @@ static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
|
|
807
807
|
struct timezone tz = {0,0};
|
808
808
|
double starttime, nowtime, finishtime;
|
809
809
|
double resize_delay = NUM2INT(get_RESIZEDELAY()) / 1000.0;
|
810
|
-
|
810
|
+
rb_fdset_t in_fds;
|
811
811
|
gettimeofday(&tv, &tz);
|
812
812
|
starttime = tv.tv_sec + tv.tv_usec * 1e-6;
|
813
813
|
finishtime = starttime + delay;
|
@@ -818,17 +818,17 @@ static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
|
|
818
818
|
gettimeofday(&tv, &tz);
|
819
819
|
nowtime = tv.tv_sec + tv.tv_usec * 1e-6;
|
820
820
|
delay = finishtime - nowtime;
|
821
|
-
|
821
|
+
if (delay <= 0) break;
|
822
822
|
|
823
|
-
|
823
|
+
/* Check for terminal size change every resize_delay seconds */
|
824
824
|
if (resize_delay > delay) resize_delay = delay;
|
825
825
|
tv.tv_sec = (time_t)resize_delay;
|
826
826
|
tv.tv_usec = (unsigned)( (resize_delay - tv.tv_sec) * 1e6 );
|
827
827
|
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
828
|
+
/* sleep on infd until input is available or tv reaches timeout */
|
829
|
+
rb_fd_init(&in_fds);
|
830
|
+
rb_fd_set(infd, &in_fds);
|
831
|
+
rb_thread_fd_select(infd + 1, &in_fds, NULL, NULL, &tv);
|
832
832
|
}
|
833
833
|
#ifdef NCURSES_VERSION
|
834
834
|
c_win->_delay = windelay;
|
@@ -2117,7 +2117,7 @@ static void init_constants_3(void) {
|
|
2117
2117
|
rb_define_const(mNcurses, "KEY_MAX", INT2NUM(KEY_MAX));
|
2118
2118
|
|
2119
2119
|
/* mouse interface */
|
2120
|
-
/* #define NCURSES_MOUSE_VERSION
|
2120
|
+
/* #define NCURSES_MOUSE_VERSION 1 */
|
2121
2121
|
|
2122
2122
|
/* event masks */
|
2123
2123
|
rb_define_const(mNcurses, "BUTTON1_RELEASED", INT2NUM(BUTTON1_RELEASED));
|
@@ -2176,8 +2176,8 @@ static void init_constants_3(void) {
|
|
2176
2176
|
|
2177
2177
|
/* typedef struct */
|
2178
2178
|
/* { */
|
2179
|
-
/* short id; */
|
2180
|
-
/* int x, y, z; */
|
2179
|
+
/* short id; */ /* ID to distinguish multiple devices */
|
2180
|
+
/* int x, y, z; */ /* event coordinates (character-cell) */
|
2181
2181
|
/* mmask_t bstate; *//* button state bits */
|
2182
2182
|
/* } */
|
2183
2183
|
/* MEVENT; */
|
@@ -2328,7 +2328,7 @@ static VALUE rbncurs_getparyx(VALUE dummy, VALUE rb_win, VALUE rb_y, VALUE rb_x)
|
|
2328
2328
|
}
|
2329
2329
|
static VALUE rbncurs_getsyx(VALUE dummy, VALUE rb_y, VALUE rb_x)
|
2330
2330
|
{
|
2331
|
-
int y,x;
|
2331
|
+
int y = -1,x = -1;
|
2332
2332
|
if ((rb_obj_is_instance_of(rb_y, rb_cArray) != Qtrue)
|
2333
2333
|
|| (rb_obj_is_instance_of(rb_x, rb_cArray) != Qtrue)) {
|
2334
2334
|
rb_raise(rb_eArgError,
|
@@ -2353,12 +2353,13 @@ static VALUE rbncurs_setsyx(VALUE dummy, VALUE rb_y, VALUE rb_x)
|
|
2353
2353
|
|
2354
2354
|
static VALUE rbncurs_wprintw(int argc, VALUE * argv, VALUE dummy)
|
2355
2355
|
{
|
2356
|
+
VALUE tmp;
|
2356
2357
|
if (argc < 2) {
|
2357
2358
|
rb_raise(rb_eArgError, "function needs at least 2 arguments: a WINDOW"
|
2358
2359
|
" and a String");
|
2359
2360
|
return Qnil;
|
2360
2361
|
}
|
2361
|
-
|
2362
|
+
tmp = rb_funcall3(rb_mKernel, rb_intern("sprintf"), argc-1, argv + 1);
|
2362
2363
|
wprintw(get_window(argv[0]), "%s", StringValuePtr(tmp));
|
2363
2364
|
return Qnil;
|
2364
2365
|
}
|
data/ext/ncurses/ncurses_wrap.h
CHANGED
Binary file
|
Binary file
|
data/lib/ncurses-ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,96 +1,84 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncurses-ruby
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 1
|
10
|
-
version: 1.2.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.3
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Tobias Herzke
|
14
8
|
- Simon Kaczor
|
15
9
|
- Earle Clubb
|
16
10
|
autorequire:
|
17
11
|
bindir: bin
|
18
12
|
cert_chain: []
|
19
|
-
|
20
|
-
date: 2011-05-11 00:00:00 -04:00
|
21
|
-
default_executable:
|
13
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
22
14
|
dependencies: []
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
description: This wrapper provides access to the functions, macros, global variables
|
16
|
+
and constants of the ncurses library. These are mapped to a Ruby Module named "Ncurses".
|
17
|
+
Functions and external variables are implemented as singleton functions of the Ncurses
|
18
|
+
module.
|
19
|
+
email:
|
26
20
|
- t-peters@users.berlios.de
|
27
21
|
- skaczor@cox.net
|
28
22
|
- eclubb@valcom.com
|
29
23
|
executables: []
|
30
|
-
|
31
|
-
extensions:
|
24
|
+
extensions:
|
32
25
|
- ext/ncurses/extconf.rb
|
33
26
|
extra_rdoc_files: []
|
34
|
-
|
35
|
-
files:
|
36
|
-
- Changes
|
27
|
+
files:
|
37
28
|
- COPYING
|
38
|
-
-
|
29
|
+
- Changelog.md
|
30
|
+
- LICENSE.txt
|
31
|
+
- README.md
|
39
32
|
- THANKS
|
40
33
|
- TODO
|
34
|
+
- examples/LICENSES_for_examples
|
41
35
|
- examples/example.rb
|
42
36
|
- examples/form.rb
|
43
37
|
- examples/form2.rb
|
44
38
|
- examples/hello_ncurses.rb
|
45
|
-
- examples/LICENSES_for_examples
|
46
39
|
- examples/rain.rb
|
47
40
|
- examples/read_line.rb
|
48
41
|
- examples/tclock.rb
|
49
42
|
- examples/test_scanw.rb
|
50
|
-
-
|
51
|
-
- lib/ncurses.rb
|
43
|
+
- ext/ncurses/Makefile
|
52
44
|
- ext/ncurses/extconf.rb
|
53
45
|
- ext/ncurses/form_wrap.c
|
54
46
|
- ext/ncurses/form_wrap.h
|
47
|
+
- ext/ncurses/form_wrap.o
|
55
48
|
- ext/ncurses/menu_wrap.c
|
56
49
|
- ext/ncurses/menu_wrap.h
|
50
|
+
- ext/ncurses/menu_wrap.o
|
51
|
+
- ext/ncurses/ncurses.so
|
57
52
|
- ext/ncurses/ncurses_wrap.c
|
58
53
|
- ext/ncurses/ncurses_wrap.h
|
54
|
+
- ext/ncurses/ncurses_wrap.o
|
59
55
|
- ext/ncurses/panel_wrap.c
|
60
56
|
- ext/ncurses/panel_wrap.h
|
61
|
-
|
57
|
+
- ext/ncurses/panel_wrap.o
|
58
|
+
- lib/ncurses-ruby/version.rb
|
59
|
+
- lib/ncurses.rb
|
62
60
|
homepage: http://github.com/eclubb/ncurses-ruby
|
63
|
-
licenses:
|
64
|
-
|
61
|
+
licenses:
|
62
|
+
- LGPL
|
63
|
+
metadata: {}
|
65
64
|
post_install_message:
|
66
65
|
rdoc_options: []
|
67
|
-
|
68
|
-
require_paths:
|
66
|
+
require_paths:
|
69
67
|
- lib
|
70
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
|
72
|
-
requirements:
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
73
70
|
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
version: "0"
|
79
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
-
none: false
|
81
|
-
requirements:
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
82
75
|
- - ">="
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
|
85
|
-
segments:
|
86
|
-
- 0
|
87
|
-
version: "0"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
88
78
|
requirements: []
|
89
|
-
|
90
79
|
rubyforge_project:
|
91
|
-
rubygems_version:
|
80
|
+
rubygems_version: 2.3.0
|
92
81
|
signing_key:
|
93
|
-
specification_version:
|
94
|
-
summary:
|
82
|
+
specification_version: 4
|
83
|
+
summary: A Ruby module for accessing the ncurses library
|
95
84
|
test_files: []
|
96
|
-
|
data/Changes
DELETED
@@ -1,53 +0,0 @@
|
|
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/README
DELETED
@@ -1,351 +0,0 @@
|
|
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
|
-
- The menu Library
|
51
|
-
- Ncurses and Ruby Threads
|
52
|
-
- Example programs
|
53
|
-
- Applications using ncurses-ruby
|
54
|
-
|
55
|
-
General Ncurses Literature
|
56
|
-
--------------------------
|
57
|
-
|
58
|
-
If you don't know how to use ncurses from C, then please read an
|
59
|
-
introduction to ncurses before continuing with this README. Eric
|
60
|
-
Raymond has written an introduction that should be part of the ncurses
|
61
|
-
development package installed on your computer.
|
62
|
-
If you'd like a gentler introduction, then you have two options:
|
63
|
-
(1) there is a part of a chapter in "The Linux Programmer's Guide" dealing
|
64
|
-
with ncurses, available from www.tldp.org. It is quite old by now,
|
65
|
-
but the ncurses interface has not changed since then, regarding the
|
66
|
-
scope of covered functions, so it is still a very good read.
|
67
|
-
(2) There is also an up-to-date "NCURSES-Programming-HOWTO" in the HOWTO
|
68
|
-
collection of the Linux Documentation Project, also available at
|
69
|
-
www.tldp.org, which is worth a read.
|
70
|
-
|
71
|
-
You will also appreciate the extensive man-pages of ncurses, a useful
|
72
|
-
reference while coding.
|
73
|
-
|
74
|
-
|
75
|
-
Installation and Usage
|
76
|
-
======================
|
77
|
-
|
78
|
-
ruby extconf.rb
|
79
|
-
make
|
80
|
-
make install
|
81
|
-
|
82
|
-
In your programs:
|
83
|
-
require "ncurses.rb"
|
84
|
-
|
85
|
-
If your programs use the scanw functions (most unlikely) you will have to
|
86
|
-
install the scanf library for ruby (http://www.rubyhacker.com/code/scanf).
|
87
|
-
|
88
|
-
Most ncurses functions are only available after either Ncurses.initscr or
|
89
|
-
Ncurses.newterm has returned successfully.
|
90
|
-
|
91
|
-
External Variables
|
92
|
-
==================
|
93
|
-
|
94
|
-
External variables are accessed read-only, by module functions taking no
|
95
|
-
arguments. They are spelled exactly like their C counterparts. Sometimes, this
|
96
|
-
leads to module functions beginning with an uppercase letter (e.g.
|
97
|
-
Ncurses.LINES).
|
98
|
-
|
99
|
-
One of these external variables, ESCDELAY, is also settable with a ruby method
|
100
|
-
(Ncurses.ESCDELAY=).
|
101
|
-
|
102
|
-
Another external variable, Ncurses.RESIZEDELAY is introduced by this wrapper.
|
103
|
-
It contains the maximum milliseconds delay with which terminal resizesings are
|
104
|
-
recognized.
|
105
|
-
|
106
|
-
Constants
|
107
|
-
=========
|
108
|
-
(static C Preprocessor macros)
|
109
|
-
|
110
|
-
Constants are implemented as module constants in the Ncurses module, if
|
111
|
-
possible. Ruby constants can not start with an underscore, so these constants
|
112
|
-
have been renamed (they lost the leading underscore). There are,however,
|
113
|
-
module functions with the same name as these constants, that also return
|
114
|
-
the constant's value, when invoked (e.g. "Ncurses._ENDLINE" returns the value
|
115
|
-
of the constant "Ncurses::ENDLINE", which has the same value as the C constant
|
116
|
-
"_ENDLINE").
|
117
|
-
|
118
|
-
Note: The ncurses macros starting with ACS_ are not constants, their value
|
119
|
-
depends on the terminal in use. Nevertheless, they are implemented as
|
120
|
-
constants of the Ncurses module, but since they depend on the terminal, they
|
121
|
-
are not initialized before initscr() has been called. If you need more than
|
122
|
-
one terminal in a single program, you can access the ACS_ values through member
|
123
|
-
functions of class SCREEN.
|
124
|
-
|
125
|
-
|
126
|
-
Functions (and their Interfaces)
|
127
|
-
================================
|
128
|
-
|
129
|
-
Functions (also those only implemented by macros in C) can be accessed
|
130
|
-
as module functions of the Module Ncurses. They take exactly the same
|
131
|
-
arguments as their C counterparts. Some of the C functions return additional
|
132
|
-
arguments through pointer arguments. These are implemented as follows:
|
133
|
-
|
134
|
-
|
135
|
-
Functions expecting pointers to integer types
|
136
|
-
---------------------------------------------
|
137
|
-
|
138
|
-
When the C-function expects a pointer to int, short, chtype, or attr_type,
|
139
|
-
You should use a variable containing an empty array as the argument to the ruby
|
140
|
-
function. This is because ruby passes these types (ints) "by value" instead of
|
141
|
-
"by reference"; but arrays are passed by reference, so that you can see the
|
142
|
-
changes to them.
|
143
|
-
Attention: some macro-only functions like getsyx accept variables of type int,
|
144
|
-
but, being macros, they write values to their arguments. Thus, they also need
|
145
|
-
empty array arguments when called from ruby.
|
146
|
-
Example:
|
147
|
-
color_pair_number = 4
|
148
|
-
foreground_color = []
|
149
|
-
background_color = []
|
150
|
-
if (Ncurses.pair_content(color_pair_number, foreground_color,
|
151
|
-
background_color) != Ncurses::ERR)
|
152
|
-
"color pair number #{color_pair_number} contains color number " +
|
153
|
-
"#{foreground_color[0]} as the foreground color, and color " +
|
154
|
-
"number #{background_color[0]} as the background color")
|
155
|
-
end
|
156
|
-
|
157
|
-
There are 2 functions that read a value from the location pointed to by a
|
158
|
-
pointer to int, and store another value at those locations. These functions are
|
159
|
-
mouse_trafo and wmouse_trafo. When calling these functions, you have to provide
|
160
|
-
2 arrays, each filled with exacly one Integer. The values contained in these
|
161
|
-
arrays will then be changed by the ruby module function.
|
162
|
-
|
163
|
-
|
164
|
-
Functions expecting (non-const) pointers to char
|
165
|
-
------------------------------------------------
|
166
|
-
|
167
|
-
When the C-function expects a pointer to char, you should use a variable
|
168
|
-
containing an empty string as the argument to the ruby function.
|
169
|
-
Example:
|
170
|
-
line2 = ""
|
171
|
-
if (Ncurses.mvwinnstr(Ncurses.stdscr, y=2, x=0, line2,
|
172
|
-
Ncurses.getmaxx(Ncurses.stdscr)) == Ncurses::ERR)
|
173
|
-
raise "could not scan 3rd line"
|
174
|
-
else
|
175
|
-
Ncurses.beep if line2.index("|")
|
176
|
-
end
|
177
|
-
The string that the C function would store at the pointer-to-char location
|
178
|
-
will be appended to the given string.
|
179
|
-
|
180
|
-
Functions expecting const pointers to char do not modify the string they
|
181
|
-
receive, you can pass any string to them.
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
Functions expecting pointers to structs
|
186
|
-
---------------------------------------------------
|
187
|
-
|
188
|
-
When the C-function expects a pointer to WINDOW, SCREEN, MEVENT,
|
189
|
-
PANEL, FORM, FIELD or FIELDTYPE then simply pass it the corresponding,
|
190
|
-
already existing ruby object.
|
191
|
-
|
192
|
-
|
193
|
-
scanf style functions expecting various pointers
|
194
|
-
---------------------------------------------------
|
195
|
-
|
196
|
-
namely scanw, mvscanw, wscanw, mvwscanw. Use an array after the format string.
|
197
|
-
The scanned values will be placed there. Remember, you need scanf for ruby
|
198
|
-
installed for these functions to work.
|
199
|
-
|
200
|
-
Module / Class Hierarchie
|
201
|
-
=========================
|
202
|
-
|
203
|
-
module Ncurses
|
204
|
-
class WINDOW; end
|
205
|
-
class SCREEN; end
|
206
|
-
class MEVENT; end
|
207
|
-
module Panel
|
208
|
-
class PANEL; end
|
209
|
-
end
|
210
|
-
module Form
|
211
|
-
class FORM; end
|
212
|
-
class FIELD; end
|
213
|
-
class FIELDTYPE; end
|
214
|
-
end
|
215
|
-
module Menu
|
216
|
-
class MENU; end
|
217
|
-
class ITEM; end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
|
222
|
-
The WINDOW class
|
223
|
-
================
|
224
|
-
|
225
|
-
The class WINDOW implements method_missing and tries to map invoked
|
226
|
-
methods to Ncurses module functions using a simple heuristic:
|
227
|
-
|
228
|
-
If the method name starts with "mv", it looks for a Ncurses module
|
229
|
-
function that starts with "mvw", and if it exists, adds itself to the
|
230
|
-
argument list and calls this function.
|
231
|
-
If no such module function exists, or the name of the invoked method
|
232
|
-
does not start with "mv", it looks if there is a module function with
|
233
|
-
the name "w" + methodname, and if it exists, adds itself again to the
|
234
|
-
argument list and calls this function.
|
235
|
-
If this module function did not exist either, then, as a last step, it
|
236
|
-
invokes a module function with the same name as the method, adding
|
237
|
-
itself to the argument list.
|
238
|
-
|
239
|
-
Example: If you invoke win.mvaddch(y,x,ch) on an Ncurses::WINDOW
|
240
|
-
object, it will delegate the method call to
|
241
|
-
Ncurses.mvwaddch(win,y,x,ch).
|
242
|
-
|
243
|
-
Other examples:
|
244
|
-
|
245
|
-
win.printw("hello") => Ncurses.wprintw(win, "hello")
|
246
|
-
|
247
|
-
win.getmaxyx(y=[],
|
248
|
-
x=[]) => Ncurses.getmaxyx(win,y,x)
|
249
|
-
|
250
|
-
win.delwin() => Ncurses.delwin(win) # win cannot be used
|
251
|
-
# after this call
|
252
|
-
|
253
|
-
|
254
|
-
The panel Library
|
255
|
-
=================
|
256
|
-
|
257
|
-
The panel library has also been wrapped. All panel functions are
|
258
|
-
implemented as module functions of the module Ncurses::Panel.
|
259
|
-
|
260
|
-
Most of these functions are also implemented as methods of class
|
261
|
-
Ncurses::Panel::PANEL, once with their original name and once with the
|
262
|
-
subword "panel" and an adjacent underscore removed.
|
263
|
-
|
264
|
-
The form Library
|
265
|
-
================
|
266
|
-
|
267
|
-
The form library was wrapped inside the Ncurses:Form module. All
|
268
|
-
form functions are implemented as module functions on the module
|
269
|
-
Ncurses::Form. In addition, all function for which the first
|
270
|
-
parameter is one of the objects are also implemented as an instance
|
271
|
-
method of the respective class. For example, instead of calling
|
272
|
-
post_form(form), you can use form.post_form().
|
273
|
-
|
274
|
-
Three objects are defined in the Ncurses:Form module:
|
275
|
-
1. FORM
|
276
|
-
2. FIELD
|
277
|
-
3. FIELDTYPE
|
278
|
-
|
279
|
-
They are wrapping actual ncurses pointers and should be use whenever a
|
280
|
-
pointer to one of these types is expected in function calls.
|
281
|
-
|
282
|
-
All form constants are defined in the module as Ruby constants with
|
283
|
-
the same name as the curses constants.
|
284
|
-
|
285
|
-
Constructors for FORM, FIELD and FIELDTYPE objects are also provided,
|
286
|
-
and they expect the same parameters as new_form, new_field and
|
287
|
-
new_fieldtype curses functions.
|
288
|
-
|
289
|
-
Field validation is implemented using Ruby Proc objects. You must
|
290
|
-
provide a Ruby block whenever a function pointer is expected in curses
|
291
|
-
function arguments. See the example form2.rb for more details.
|
292
|
-
|
293
|
-
The functions form_userptr and field_userptr are not supported. Use
|
294
|
-
form.user_object and field.user_object to store Ruby objects instead.
|
295
|
-
|
296
|
-
The menu Library
|
297
|
-
================
|
298
|
-
|
299
|
-
The menu library was wrapped inside the Ncurses:Menu module. All
|
300
|
-
menu functions are implemented as module functions in the module
|
301
|
-
Ncurses::Menu. In addition, all functions for which the first
|
302
|
-
parameter is one of the objects are also implemented as an instance
|
303
|
-
method of the respective class. For example, instead of calling
|
304
|
-
post_menu(menu), you can use menu.post_menu().
|
305
|
-
|
306
|
-
Two objects are defined in the Ncurses:Menu module:
|
307
|
-
1. MENU
|
308
|
-
2. ITEM
|
309
|
-
|
310
|
-
They are wrapping actual ncurses pointers and should be use whenever a
|
311
|
-
pointer to one of these types is expected in function calls.
|
312
|
-
|
313
|
-
All menu constants are defined in the module as Ruby constants with
|
314
|
-
the same name as the curses constants.
|
315
|
-
|
316
|
-
Constructors for MENU and ITEM objects are also provided, and they
|
317
|
-
expect the same parameters as new_menu and new_item curses functions.
|
318
|
-
|
319
|
-
You must provide a Ruby block whenever a function pointer is expected
|
320
|
-
in curses function arguments.
|
321
|
-
|
322
|
-
The functions menu_userptr and item_userptr are not supported. Use
|
323
|
-
menu.user_object and item.user_object to store Ruby objects instead.
|
324
|
-
|
325
|
-
Ncurses and Ruby Threads
|
326
|
-
========================
|
327
|
-
|
328
|
-
The ncurses library is not thread-safe. Your application must properly
|
329
|
-
serialize calls into ncurses.
|
330
|
-
|
331
|
-
Prior to release 0.9.2, the getch and wgetch calls used to block the
|
332
|
-
complete ruby interpreter, all threads. This is no longer so. Other
|
333
|
-
threads should now continue to run during blocking calls to getch and
|
334
|
-
wgetch.
|
335
|
-
|
336
|
-
Example programs
|
337
|
-
================
|
338
|
-
|
339
|
-
Directory "examples" contains a few example programs demonstrating how
|
340
|
-
to use the ncurses library with ruby. Be sure to read the file
|
341
|
-
"examples/LICENSES_for_examples".
|
342
|
-
|
343
|
-
|
344
|
-
Applications using ncurses-ruby
|
345
|
-
===============================
|
346
|
-
|
347
|
-
aeditor (v. 0.x) - Pair programming editor, http://metaeditor.sourceforge.net/
|
348
|
-
raggle - RSS aggregator, http://www.raggle.org/about/
|
349
|
-
ruvi - Editor, http://ruvi.rubyforge.org/
|
350
|
-
tpp - text-based presentation program, http://synflood.at/tpp/
|
351
|
-
yapo - ports overview for CRUX linux distribution, http://jue.li/crux/yapo/
|