ffi-ncurses 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +20 -0
- data/README.rdoc +14 -22
- data/examples/example-attributes.rb +11 -11
- data/examples/example-colour.rb +10 -9
- data/examples/example-keys.rb +1 -1
- data/examples/example-mouse.rb +3 -2
- data/examples/example.rb +9 -12
- data/examples/ncurses-example.rb +8 -9
- data/ffi-ncurses.gemspec +41 -21
- data/lib/ffi-ncurses.rb +21 -14
- data/lib/ffi-ncurses/keydefs.rb +103 -101
- data/lib/ffi-ncurses/mouse.rb +9 -8
- data/lib/ffi-ncurses/ord-shim.rb +9 -0
- metadata +39 -26
- data/Rakefile +0 -66
- data/tasks/ann.rake +0 -80
- data/tasks/bones.rake +0 -20
- data/tasks/gem.rake +0 -201
- data/tasks/git.rake +0 -40
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -50
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -300
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
data/History.txt
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
== 0.3.3 / 2010-08-24
|
2
|
+
|
3
|
+
* Depends on ffi again (>= 0.6.3)
|
4
|
+
* Now compatible with ffi-0.6.3
|
5
|
+
- thanks and apologies to all those who requested this change months
|
6
|
+
ago
|
7
|
+
* Included keydefs.rb by default
|
8
|
+
* Examples have been tested with:
|
9
|
+
- jruby-1.5.1
|
10
|
+
- rbx-1.0.0-20100514
|
11
|
+
- ree-1.8.7-2010.02
|
12
|
+
- ruby-1.8.6-p399
|
13
|
+
Note: the examples require "ffi-ncurses/ord-shim" to add
|
14
|
+
Integer#ord
|
15
|
+
- ruby-1.8.7-p299
|
16
|
+
- ruby-1.9.2-p0
|
17
|
+
* Removed attempt to load XCurses (PDCurses)
|
18
|
+
* Removed dependency on bones
|
19
|
+
- no Rakefile any more - just use gem build ffi-ncurses.gemspec
|
20
|
+
|
1
21
|
== 0.3.2 / 2009-02-16
|
2
22
|
|
3
23
|
* Bug fix:
|
data/README.rdoc
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
= ffi-ncurses
|
1
|
+
= ffi-ncurses
|
2
2
|
|
3
3
|
Author: Sean O'Halpin
|
4
4
|
|
5
|
-
A wrapper for ncurses 5.x. Tested on
|
6
|
-
|
5
|
+
A wrapper for ncurses 5.x. Tested on Ubuntu 8.04 to 10.04 and Mac OS X
|
6
|
+
10.4 (Tiger) with ruby 1.8.6, 1.8.7 and 1.9.x using ffi (>= 0.6.3) and
|
7
|
+
JRuby 1.5.1.
|
7
8
|
|
8
9
|
The API is a transliteration of the C API rather than an attempt to
|
9
10
|
provide an idiomatic Ruby object-oriented API. The intent is to
|
@@ -20,13 +21,13 @@ directory for real working examples.
|
|
20
21
|
|
21
22
|
== Install
|
22
23
|
|
23
|
-
ruby 1.8.
|
24
|
+
ruby 1.8.x:
|
24
25
|
|
25
|
-
$ sudo gem install ffi
|
26
|
+
$ sudo gem install ffi-ncurses
|
26
27
|
|
27
|
-
jruby 1.1
|
28
|
+
jruby 1.5.1:
|
28
29
|
|
29
|
-
$ jruby -S gem install ffi-ncurses
|
30
|
+
$ jruby -S gem install ffi-ncurses
|
30
31
|
|
31
32
|
== Usage
|
32
33
|
|
@@ -71,9 +72,9 @@ or as included methods:
|
|
71
72
|
== Set up screen
|
72
73
|
|
73
74
|
require 'ffi-ncurses'
|
74
|
-
|
75
|
+
|
75
76
|
FFI::NCurses.initscr
|
76
|
-
begin
|
77
|
+
begin
|
77
78
|
...
|
78
79
|
ensure
|
79
80
|
FFI::NCurses.endwin
|
@@ -90,12 +91,12 @@ or as included methods:
|
|
90
91
|
FFI::NCurses.keypad(stdscr, true)
|
91
92
|
|
92
93
|
== Colours
|
93
|
-
|
94
|
+
|
94
95
|
start_color
|
95
96
|
init_pair(1, FFI::NCurses::COLOR_BLACK, FFI::NCurses::COLOR_RED)
|
96
97
|
attr_set FFI::NCurses::A_NORMAL, 1, nil
|
97
|
-
addch(
|
98
|
-
addch(
|
98
|
+
addch("A"[0].ord) # works in both 1.8.x and 1.9.x
|
99
|
+
addch("Z"[0].ord | COLOR_PAIR(1))
|
99
100
|
|
100
101
|
== Cursor
|
101
102
|
|
@@ -179,7 +180,7 @@ You can specify which variant of curses you want to use by setting the
|
|
179
180
|
environment variable +RUBY_FFI_NCURSES_LIB+ to the one you want. For
|
180
181
|
example, to use PDCurses X11 curses lib, use:
|
181
182
|
|
182
|
-
RUBY_FFI_NCURSES_LIB=XCurses ruby examples/hello.rb
|
183
|
+
RUBY_FFI_NCURSES_LIB=XCurses ruby examples/hello.rb
|
183
184
|
|
184
185
|
You can use this to specify +ncursesw+ for example. Please note that
|
185
186
|
only the bog standard ncurses lib has been in any way tested as of
|
@@ -193,15 +194,6 @@ There are some macros in darwin ncurses.h which I haven't
|
|
193
194
|
implemented yet. I'm working on it but if there are any you
|
194
195
|
desperately need let me know.
|
195
196
|
|
196
|
-
== +curscr+ and +newscr+ for JRuby
|
197
|
-
|
198
|
-
These global variables are not often used but are required for certain
|
199
|
-
situations (e.g. doing a wrefresh after shelling out and for the
|
200
|
-
get/setsyx macros).
|
201
|
-
|
202
|
-
This requires the implementation of +find_sym+ in JRuby (expected in
|
203
|
-
JRuby 1.1.7).
|
204
|
-
|
205
197
|
== Tests
|
206
198
|
|
207
199
|
This is tricky - I'm not sure exactly how to properly test a wrapper
|
@@ -7,23 +7,23 @@ include FFI::NCurses
|
|
7
7
|
initscr
|
8
8
|
begin
|
9
9
|
attributes = %w[
|
10
|
-
A_BLINK
|
11
|
-
A_BOLD
|
10
|
+
A_BLINK
|
11
|
+
A_BOLD
|
12
12
|
A_DIM
|
13
13
|
A_NORMAL
|
14
|
-
A_REVERSE
|
15
|
-
A_STANDOUT
|
16
|
-
A_UNDERLINE
|
14
|
+
A_REVERSE
|
15
|
+
A_STANDOUT
|
16
|
+
A_UNDERLINE
|
17
17
|
]
|
18
18
|
alt_attributes = %w[
|
19
19
|
A_ALTCHARSET
|
20
20
|
A_HORIZONTAL
|
21
|
-
A_INVIS
|
22
|
-
A_LEFT
|
23
|
-
A_LOW
|
24
|
-
A_PROTECT
|
25
|
-
A_RIGHT
|
26
|
-
A_TOP
|
21
|
+
A_INVIS
|
22
|
+
A_LEFT
|
23
|
+
A_LOW
|
24
|
+
A_PROTECT
|
25
|
+
A_RIGHT
|
26
|
+
A_TOP
|
27
27
|
A_VERTICAL
|
28
28
|
]
|
29
29
|
|
data/examples/example-colour.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# Sean O'Halpin, 2009-02-15
|
4
4
|
#
|
5
5
|
require 'ffi-ncurses'
|
6
|
+
require 'ffi-ncurses/ord-shim' # for 1.8.6 compatibility
|
6
7
|
include FFI::NCurses
|
7
8
|
|
8
9
|
initscr
|
@@ -12,7 +13,7 @@ begin
|
|
12
13
|
|
13
14
|
# initialize colour
|
14
15
|
start_color
|
15
|
-
|
16
|
+
|
16
17
|
# set up colour pairs
|
17
18
|
# Background Foreground
|
18
19
|
init_pair(0, Colour::BLACK, Colour::BLACK)
|
@@ -32,26 +33,26 @@ begin
|
|
32
33
|
init_pair(13, Colour::BLACK, Colour::MAGENTA)
|
33
34
|
init_pair(14, Colour::BLACK, Colour::CYAN)
|
34
35
|
init_pair(15, Colour::BLACK, Colour::WHITE)
|
35
|
-
|
36
|
+
|
36
37
|
0.upto(15) do |i|
|
37
38
|
attr_set A_NORMAL, i, nil
|
38
|
-
addch(
|
39
|
+
addch("A"[0].ord + i)
|
39
40
|
end
|
40
|
-
|
41
|
+
|
41
42
|
# add character and attribute together
|
42
|
-
addch(
|
43
|
+
addch("Z"[0].ord | COLOR_PAIR(1)) # red
|
43
44
|
|
44
45
|
# reset attribute and colour to default
|
45
46
|
attr_set A_NORMAL, 0, nil
|
46
|
-
|
47
|
+
|
47
48
|
# start new line
|
48
49
|
addstr "\n"
|
49
|
-
|
50
|
+
|
50
51
|
# how to add a single space
|
51
|
-
addch(' '[0])
|
52
|
+
addch(' '[0].ord)
|
52
53
|
# or
|
53
54
|
addstr(" ")
|
54
|
-
|
55
|
+
|
55
56
|
addstr "Press any key"
|
56
57
|
|
57
58
|
# display and pause for key press
|
data/examples/example-keys.rb
CHANGED
data/examples/example-mouse.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
#
|
5
5
|
require 'ffi-ncurses'
|
6
6
|
require 'ffi-ncurses/mouse'
|
7
|
+
require 'ffi-ncurses/ord-shim' # for 1.8.6 compatibility
|
7
8
|
|
8
9
|
include FFI::NCurses
|
9
10
|
|
@@ -19,7 +20,7 @@ begin
|
|
19
20
|
mouse_event = MEVENT.new
|
20
21
|
ch = 0
|
21
22
|
addstr "Click mouse buttons anywhere on the screen. q to quit\n"
|
22
|
-
until ch ==
|
23
|
+
until ch == "q"[0].ord do
|
23
24
|
ch = getch
|
24
25
|
case ch
|
25
26
|
when KEY_MOUSE
|
@@ -36,7 +37,7 @@ begin
|
|
36
37
|
row = getcury(stdscr) + 1
|
37
38
|
move row, 0
|
38
39
|
move mouse_event[:y], mouse_event[:x]
|
39
|
-
addch " "[0] | WA_STANDOUT
|
40
|
+
addch " "[0].ord | WA_STANDOUT
|
40
41
|
move row, 0
|
41
42
|
end
|
42
43
|
else
|
data/examples/example.rb
CHANGED
@@ -5,7 +5,9 @@
|
|
5
5
|
# Sean O'Halpin, 2009-01-18
|
6
6
|
#
|
7
7
|
require 'ffi-ncurses'
|
8
|
-
|
8
|
+
require 'ffi-ncurses/ord-shim' # for 1.8.6 compatibility
|
9
|
+
|
10
|
+
begin
|
9
11
|
# the methods can be called as module methods
|
10
12
|
FFI::NCurses.initscr
|
11
13
|
FFI::NCurses.clear
|
@@ -26,7 +28,7 @@ begin
|
|
26
28
|
move 10, 10
|
27
29
|
standout
|
28
30
|
# hmmm.. you have to jump through some hoops to avoid temporary variables
|
29
|
-
#
|
31
|
+
#
|
30
32
|
printw("Hi! maxyx %d %d\n", *([:int, :int].zip(getmaxyx(FFI::NCurses.stdscr)).flatten))
|
31
33
|
# easier to do this
|
32
34
|
#addstr(sprintf("paryx %d %d\n", *getparyx(FFI::NCurses.stdscr)))
|
@@ -49,15 +51,15 @@ begin
|
|
49
51
|
init_pair(14, FFI::NCurses::Colour::BLACK, FFI::NCurses::Colour::MAGENTA)
|
50
52
|
init_pair(15, FFI::NCurses::Colour::BLACK, FFI::NCurses::Colour::CYAN)
|
51
53
|
init_pair(16, FFI::NCurses::Colour::BLACK, FFI::NCurses::Colour::WHITE)
|
52
|
-
|
54
|
+
|
53
55
|
1.upto(16) do |i|
|
54
56
|
attr_set FFI::NCurses::A_NORMAL, i, nil
|
55
|
-
addch(
|
57
|
+
addch("A"[0].ord - 1 + i)
|
56
58
|
end
|
57
59
|
attr_set FFI::NCurses::A_HORIZONTAL, 0, nil
|
58
|
-
addch(
|
60
|
+
addch("Z"[0].ord | COLOR_PAIR(3))
|
59
61
|
attr_set A_BOLD, 2, nil
|
60
|
-
addch
|
62
|
+
addch "S"[0].ord
|
61
63
|
|
62
64
|
refresh
|
63
65
|
ch = getch
|
@@ -94,15 +96,10 @@ begin
|
|
94
96
|
wrefresh(win)
|
95
97
|
ch = wgetch(win)
|
96
98
|
delwin(win)
|
97
|
-
|
99
|
+
|
98
100
|
rescue Object => e
|
99
101
|
FFI::NCurses.endwin
|
100
102
|
raise
|
101
103
|
ensure
|
102
104
|
FFI::NCurses.endwin
|
103
|
-
# FFI::NCurses.class_eval {
|
104
|
-
# require 'pp'
|
105
|
-
# pp @unattached_functions
|
106
|
-
|
107
|
-
# }
|
108
105
|
end
|
data/examples/ncurses-example.rb
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
# Copyright (C) 2002 Tobias Peters <t-peters@users.berlios.de>
|
7
7
|
#
|
8
8
|
# The following license applys only to this file. It is less restrictive
|
9
|
-
# than the license for the rest of the ncurses-ruby distribution.
|
10
|
-
# I've adapted this file from someone else, see below.
|
9
|
+
# than the license for the rest of the ncurses-ruby distribution.
|
10
|
+
# I've adapted this file from someone else, see below.
|
11
11
|
#
|
12
12
|
# Permission is hereby granted, free of charge, to any person
|
13
13
|
# obtaining a copy of this file
|
@@ -16,10 +16,10 @@
|
|
16
16
|
# publish, distribute, sublicense, and/or sell copies of the Software,
|
17
17
|
# and to permit persons to whom the Software is furnished to do so,
|
18
18
|
# subject to the following conditions:
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# The above copyright notice and this permission notice shall be
|
21
21
|
# included in all copies or substantial portions of the Software.
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
24
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
25
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -36,7 +36,7 @@
|
|
36
36
|
# statement:
|
37
37
|
|
38
38
|
# Copyright (c) 2000 by Harry Henry Gebel
|
39
|
-
#
|
39
|
+
#
|
40
40
|
# Permission is hereby granted, free of charge, to any person
|
41
41
|
# obtaining a copy of this software and associated documentation files
|
42
42
|
# (the "Software"), to deal in the Software without restriction,
|
@@ -44,10 +44,10 @@
|
|
44
44
|
# publish, distribute, sublicense, and/or sell copies of the Software,
|
45
45
|
# and to permit persons to whom the Software is furnished to do so,
|
46
46
|
# subject to the following conditions:
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# The above copyright notice and this permission notice shall be
|
49
49
|
# included in all copies or substantial portions of the Software.
|
50
|
-
#
|
50
|
+
#
|
51
51
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
52
52
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
53
53
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -57,9 +57,8 @@
|
|
57
57
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
58
58
|
# SOFTWARE.
|
59
59
|
|
60
|
-
|
61
|
-
|
62
60
|
require "ffi-ncurses"
|
61
|
+
require 'ffi-ncurses/ord-shim' # for 1.8.6 compatibility
|
63
62
|
|
64
63
|
module NcursesExtension
|
65
64
|
def method_missing(method, *args, &block)
|
data/ffi-ncurses.gemspec
CHANGED
@@ -2,15 +2,50 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ffi-ncurses}
|
5
|
-
s.version = "0.3.
|
6
|
-
|
5
|
+
s.version = "0.3.3"
|
7
6
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
7
|
s.authors = ["Sean O'Halpin"]
|
9
|
-
s.date = %q{2009-02-
|
10
|
-
s.description =
|
8
|
+
s.date = %q{2009-02-24}
|
9
|
+
s.description = <<-EOT
|
10
|
+
A wrapper for ncurses 5.x. Tested on Ubuntu 8.04 to 10.04 and Mac OS X
|
11
|
+
10.4 (Tiger) with ruby 1.8.6, 1.8.7 and 1.9.x using ffi (>= 0.6.3) and
|
12
|
+
JRuby 1.5.1.
|
13
|
+
|
14
|
+
The API is a transliteration of the C API rather than an attempt to
|
15
|
+
provide an idiomatic Ruby object-oriented API.
|
16
|
+
|
17
|
+
See the examples directory for real working examples.
|
18
|
+
EOT
|
11
19
|
s.email = %q{sean.ohalpin@gmail.com}
|
12
20
|
s.extra_rdoc_files = ["History.txt", "README.rdoc"]
|
13
|
-
s.files = [
|
21
|
+
s.files = [
|
22
|
+
"History.txt",
|
23
|
+
"README.rdoc",
|
24
|
+
"examples/doc-eg1.rb",
|
25
|
+
"examples/doc-eg2.rb",
|
26
|
+
"examples/doc-eg3.rb",
|
27
|
+
"examples/example-attributes.rb",
|
28
|
+
"examples/example-colour.rb",
|
29
|
+
"examples/example-cursor.rb",
|
30
|
+
"examples/example-getsetsyx.rb",
|
31
|
+
"examples/example-hello.rb",
|
32
|
+
"examples/example-jruby.rb",
|
33
|
+
"examples/example-keys.rb",
|
34
|
+
"examples/example-mouse.rb",
|
35
|
+
"examples/example-printw-variadic.rb",
|
36
|
+
"examples/example-softkeys.rb",
|
37
|
+
"examples/example-stdscr.rb",
|
38
|
+
"examples/example-windows.rb",
|
39
|
+
"examples/example.rb",
|
40
|
+
"examples/ncurses-example.rb",
|
41
|
+
"ffi-ncurses.gemspec",
|
42
|
+
"lib/ffi-ncurses.rb",
|
43
|
+
"lib/ffi-ncurses/darwin.rb",
|
44
|
+
"lib/ffi-ncurses/keydefs.rb",
|
45
|
+
"lib/ffi-ncurses/mouse.rb",
|
46
|
+
"lib/ffi-ncurses/ord-shim.rb",
|
47
|
+
"lib/ffi-ncurses/winstruct.rb"
|
48
|
+
]
|
14
49
|
s.has_rdoc = true
|
15
50
|
s.homepage = %q{http://github.com/seanohalpin/ffi-ncurses}
|
16
51
|
s.rdoc_options = ["--main", "README.rdoc"]
|
@@ -18,20 +53,5 @@ Gem::Specification.new do |s|
|
|
18
53
|
s.rubyforge_project = %q{ffi-ncurses}
|
19
54
|
s.rubygems_version = %q{1.3.1}
|
20
55
|
s.summary = %q{FFI wrapper for ncurses}
|
21
|
-
|
22
|
-
if s.respond_to? :specification_version then
|
23
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
-
s.specification_version = 2
|
25
|
-
|
26
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
-
s.add_runtime_dependency(%q<ffi>, [">= 0.2.0"])
|
28
|
-
s.add_development_dependency(%q<bones>, [">= 2.4.0"])
|
29
|
-
else
|
30
|
-
s.add_dependency(%q<ffi>, [">= 0.2.0"])
|
31
|
-
s.add_dependency(%q<bones>, [">= 2.4.0"])
|
32
|
-
end
|
33
|
-
else
|
34
|
-
s.add_dependency(%q<ffi>, [">= 0.2.0"])
|
35
|
-
s.add_dependency(%q<bones>, [">= 2.4.0"])
|
36
|
-
end
|
56
|
+
s.add_dependency("ffi", ">= 0.6.3")
|
37
57
|
end
|
data/lib/ffi-ncurses.rb
CHANGED
@@ -4,9 +4,16 @@
|
|
4
4
|
# version 0.2.0 - 2009-01-18
|
5
5
|
# version 0.3.0 - 2009-01-31
|
6
6
|
# - added stdscr, newscr, curscr
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
7
|
+
# version 0.3.3 - 2010-08-24
|
8
|
+
# - compatible with ffi-0.6.3
|
9
|
+
# - example working with ruby 1.9.x (using "q"[0].ord instead of ?q)
|
10
|
+
# requires ruby-ffi >= 0.6.3 or jruby >= 1.1.6
|
11
|
+
# tested with
|
12
|
+
# - ruby 1.8.7, 1.9.x
|
13
|
+
# - jruby 1.5.1
|
14
|
+
# on
|
15
|
+
# - Ubuntu 8.04, 9.04, 9.10, 10.04 (ncurses 5.7)
|
16
|
+
# - Mac OS X 10.4 (ncurses 5.4)
|
10
17
|
|
11
18
|
require 'ffi'
|
12
19
|
|
@@ -15,21 +22,20 @@ require 'ffi'
|
|
15
22
|
|
16
23
|
module FFI
|
17
24
|
module NCurses
|
18
|
-
VERSION = "0.3.
|
25
|
+
VERSION = "0.3.3"
|
19
26
|
extend FFI::Library
|
20
27
|
|
21
28
|
# use RUBY_FFI_NCURSES_LIB to specify exactly which lib you want, e.g. ncursesw, XCurses (from PDCurses)
|
22
29
|
if ENV["RUBY_FFI_NCURSES_LIB"].to_s != ""
|
23
30
|
LIB_HANDLE = ffi_lib( ENV["RUBY_FFI_NCURSES_LIB"] ).first
|
24
31
|
else
|
25
|
-
LIB_HANDLE = ffi_lib(
|
32
|
+
LIB_HANDLE = ffi_lib(['ncursesw', 'ncurses']).first
|
26
33
|
end
|
27
34
|
|
28
35
|
begin
|
29
|
-
|
36
|
+
symbols = [ "stdscr", "curscr", "newscr" ]
|
30
37
|
if LIB_HANDLE.respond_to?(:find_symbol)
|
31
38
|
# these symbols are defined in ncurses.h
|
32
|
-
symbols = [ "stdscr", "curscr", "newscr" ]
|
33
39
|
SYMBOLS = Hash[*symbols.map { |sym| [sym, LIB_HANDLE.find_symbol(sym)]}.compact.flatten ]
|
34
40
|
SYMBOLS.keys.each do |sym|
|
35
41
|
# note that the symbol table entry in a dll for an exported
|
@@ -43,17 +49,17 @@ module FFI
|
|
43
49
|
# variables need another level of indirection because they are
|
44
50
|
# ~not~ shared between process instances - the sharing is of
|
45
51
|
# code only
|
46
|
-
# p SYMBOLS[sym]
|
47
52
|
define_method sym do
|
48
53
|
SYMBOLS[sym].read_pointer
|
49
54
|
end
|
50
55
|
module_function sym
|
51
56
|
end
|
52
57
|
else
|
58
|
+
warn "#find_symbol not available - #{symbols.inspect} not defined"
|
53
59
|
end
|
54
60
|
rescue Object => e
|
55
61
|
end
|
56
|
-
|
62
|
+
|
57
63
|
# this list of function signatures was generated by the file
|
58
64
|
# generate-ffi-ncurses-function-signatures.rb and inserted here by hand
|
59
65
|
# then edited a bit :)
|
@@ -475,7 +481,7 @@ module FFI
|
|
475
481
|
end
|
476
482
|
end
|
477
483
|
include FixupInitscr
|
478
|
-
|
484
|
+
|
479
485
|
module Attributes
|
480
486
|
# following definitions have been copied (almost verbatim) from ncurses.h
|
481
487
|
NCURSES_ATTR_SHIFT = 8
|
@@ -516,11 +522,11 @@ module FFI
|
|
516
522
|
|
517
523
|
require 'ffi-ncurses/winstruct'
|
518
524
|
include WinStruct
|
519
|
-
|
525
|
+
|
520
526
|
module EmulatedFunctions
|
521
|
-
|
527
|
+
|
522
528
|
# these 'functions' are implemented as macros in ncurses
|
523
|
-
|
529
|
+
|
524
530
|
# I'm departing from the NCurses API here - makes no sense to
|
525
531
|
# force people to use pointer return values when these are
|
526
532
|
# implemented as macros to make them easy to use in C when we have
|
@@ -555,7 +561,7 @@ module FFI
|
|
555
561
|
wmove(newscr, y, x)
|
556
562
|
end
|
557
563
|
end
|
558
|
-
|
564
|
+
|
559
565
|
def self.fixup(function, &block)
|
560
566
|
if NCurses.unattached_functions.include?(function)
|
561
567
|
block.call
|
@@ -583,3 +589,4 @@ module FFI
|
|
583
589
|
end
|
584
590
|
end
|
585
591
|
|
592
|
+
require 'ffi-ncurses/keydefs'
|