ffi-ncurses 0.3.3 → 0.4.0
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/COPYING +22 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +13 -0
- data/History.txt +32 -3
- data/README.rdoc +118 -58
- data/Rakefile +30 -0
- data/examples/acs_chars.rb +53 -0
- data/examples/acs_chars.rbc +1502 -0
- data/examples/{example-attributes.rb → attributes.rb} +0 -0
- data/examples/color.rb +63 -0
- data/examples/cursor.rb +27 -0
- data/examples/example.rb +17 -17
- data/examples/getkey.rb +212 -0
- data/examples/{example-getsetsyx.rb → getsetsyx.rb} +2 -2
- data/examples/globals.rb +38 -0
- data/examples/hello.rb +34 -0
- data/examples/hello.rbc +638 -0
- data/examples/hellowide.rb +59 -0
- data/examples/keys.rb +27 -0
- data/examples/{example-mouse.rb → mouse.rb} +2 -2
- data/examples/multiterm.rb +120 -0
- data/examples/ncurses/LICENSES_for_examples +26 -0
- data/examples/{ncurses-example.rb → ncurses/example.rb} +13 -80
- data/examples/ncurses/hello_ncurses.rb +57 -0
- data/examples/ncurses/rain.rb +220 -0
- data/examples/ncurses/read_line.rb +67 -0
- data/examples/ncurses/subwin.rb +71 -0
- data/examples/ncurses/tclock.rb +227 -0
- data/examples/newterm.rb +65 -0
- data/examples/panel_simple.rb +82 -0
- data/examples/{example-printw-variadic.rb → printw-variadic.rb} +1 -1
- data/examples/ripoffline.rb +86 -0
- data/examples/run-all.sh +14 -0
- data/examples/{example-softkeys.rb → softkeys.rb} +0 -0
- data/examples/{example-stdscr.rb → stdscr.rb} +2 -1
- data/examples/temp_leave.rb +99 -0
- data/examples/viewer.rb +350 -0
- data/examples/wacs_chars.rb +64 -0
- data/examples/windows.rb +73 -0
- data/ffi-ncurses.gemspec +39 -52
- data/lib/ffi-ncurses.rb +214 -474
- data/lib/ffi-ncurses/acs.rb +150 -0
- data/lib/ffi-ncurses/bool_wrappers.rb +66 -0
- data/lib/ffi-ncurses/functions.rb +450 -0
- data/lib/ffi-ncurses/keydefs.rb +136 -99
- data/lib/ffi-ncurses/mouse.rb +106 -106
- data/lib/ffi-ncurses/ncurses.rb +176 -0
- data/lib/ffi-ncurses/{ord-shim.rb → ord_shim.rb} +0 -0
- data/lib/ffi-ncurses/panel.rb +21 -0
- data/lib/ffi-ncurses/typedefs.rb +35 -0
- data/lib/ffi-ncurses/version.rb +7 -0
- data/lib/ffi-ncurses/widechars.rb +137 -0
- data/lib/ffi-ncurses/winstruct.rb +55 -33
- data/spec/attached_functions_spec.rb +42 -0
- metadata +95 -85
- data/examples/example-colour.rb +0 -63
- data/examples/example-cursor.rb +0 -22
- data/examples/example-hello.rb +0 -24
- data/examples/example-jruby.rb +0 -14
- data/examples/example-keys.rb +0 -25
- data/examples/example-windows.rb +0 -24
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'minitest/spec'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'ffi-ncurses'
|
5
|
+
|
6
|
+
# Some preliminary sanity tests for FFI::NCurses
|
7
|
+
|
8
|
+
# test if all expected functions have been attached
|
9
|
+
describe "attached functions" do
|
10
|
+
|
11
|
+
FFI::NCurses::FUNCTION_SIGNATURES.each do |sig|
|
12
|
+
name = sig[0].to_s
|
13
|
+
if name =~ /^_.*trace/ || name == "trace"
|
14
|
+
next
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should provide a module level function #{name}" do
|
18
|
+
FFI::NCurses.respond_to?(name).must_equal true
|
19
|
+
end
|
20
|
+
|
21
|
+
# map to_s to handle the change in method names between 1.8.7 and 1.9.x
|
22
|
+
it "should provide an instance level function #{name}" do
|
23
|
+
FFI::NCurses.instance_methods.map{ |x| x.to_s }.include?(name).must_equal true
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# test that initscr and stdscr match up
|
30
|
+
describe "initscr" do
|
31
|
+
|
32
|
+
it "should return an FFI::Pointer" do
|
33
|
+
begin
|
34
|
+
scr = FFI::NCurses.initscr
|
35
|
+
scr.class.must_equal FFI::Pointer
|
36
|
+
scr.must_equal FFI::NCurses.stdscr
|
37
|
+
ensure
|
38
|
+
FFI::NCurses.endwin
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
metadata
CHANGED
@@ -1,114 +1,124 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-ncurses
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 3
|
8
|
-
- 3
|
9
|
-
version: 0.3.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Sean O'Halpin
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-25 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: ffi
|
16
|
+
requirement: &72785530 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.9
|
22
|
+
type: :runtime
|
22
23
|
prerelease: false
|
23
|
-
|
24
|
+
version_requirements: *72785530
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: ffi-locale
|
27
|
+
requirement: &72784780 !ruby/object:Gem::Requirement
|
24
28
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
- 6
|
31
|
-
- 3
|
32
|
-
version: 0.6.3
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
33
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
10.4 (Tiger) with ruby 1.8.6, 1.8.7 and 1.9.x using ffi (>= 0.6.3) and
|
38
|
-
JRuby 1.5.1.
|
39
|
-
|
40
|
-
The API is a transliteration of the C API rather than an attempt to
|
41
|
-
provide an idiomatic Ruby object-oriented API.
|
42
|
-
|
43
|
-
See the examples directory for real working examples.
|
44
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *72784780
|
36
|
+
description: An FFI wrapper around ncursesw 5.x for MRI Ruby 1.8.x, 1.9.x and JRuby.
|
45
37
|
email: sean.ohalpin@gmail.com
|
46
38
|
executables: []
|
47
|
-
|
48
39
|
extensions: []
|
49
|
-
|
50
|
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- ffi-ncurses.gemspec
|
43
|
+
- lib/ffi-ncurses.rb
|
44
|
+
- COPYING
|
54
45
|
- History.txt
|
55
46
|
- README.rdoc
|
56
|
-
-
|
47
|
+
- Rakefile
|
48
|
+
- Gemfile
|
49
|
+
- Gemfile.lock
|
50
|
+
- examples/windows.rb
|
51
|
+
- examples/viewer.rb
|
52
|
+
- examples/softkeys.rb
|
53
|
+
- examples/example.rb
|
54
|
+
- examples/hello.rbc
|
55
|
+
- examples/newterm.rb
|
56
|
+
- examples/hello.rb
|
57
57
|
- examples/doc-eg2.rb
|
58
|
+
- examples/run-all.sh
|
59
|
+
- examples/getsetsyx.rb
|
60
|
+
- examples/wacs_chars.rb
|
61
|
+
- examples/printw-variadic.rb
|
62
|
+
- examples/attributes.rb
|
63
|
+
- examples/doc-eg1.rb
|
64
|
+
- examples/panel_simple.rb
|
65
|
+
- examples/ncurses/tclock.rb
|
66
|
+
- examples/ncurses/LICENSES_for_examples
|
67
|
+
- examples/ncurses/example.rb
|
68
|
+
- examples/ncurses/read_line.rb
|
69
|
+
- examples/ncurses/rain.rb
|
70
|
+
- examples/ncurses/subwin.rb
|
71
|
+
- examples/ncurses/hello_ncurses.rb
|
72
|
+
- examples/globals.rb
|
73
|
+
- examples/hellowide.rb
|
74
|
+
- examples/stdscr.rb
|
75
|
+
- examples/acs_chars.rbc
|
76
|
+
- examples/ripoffline.rb
|
58
77
|
- examples/doc-eg3.rb
|
59
|
-
- examples/
|
60
|
-
- examples/
|
61
|
-
- examples/
|
62
|
-
- examples/
|
63
|
-
- examples/
|
64
|
-
- examples/
|
65
|
-
- examples/
|
66
|
-
- examples/
|
67
|
-
-
|
68
|
-
- examples/example-softkeys.rb
|
69
|
-
- examples/example-stdscr.rb
|
70
|
-
- examples/example-windows.rb
|
71
|
-
- examples/example.rb
|
72
|
-
- examples/ncurses-example.rb
|
73
|
-
- ffi-ncurses.gemspec
|
74
|
-
- lib/ffi-ncurses.rb
|
75
|
-
- lib/ffi-ncurses/darwin.rb
|
78
|
+
- examples/getkey.rb
|
79
|
+
- examples/cursor.rb
|
80
|
+
- examples/multiterm.rb
|
81
|
+
- examples/temp_leave.rb
|
82
|
+
- examples/color.rb
|
83
|
+
- examples/mouse.rb
|
84
|
+
- examples/acs_chars.rb
|
85
|
+
- examples/keys.rb
|
86
|
+
- lib/ffi-ncurses/functions.rb
|
76
87
|
- lib/ffi-ncurses/keydefs.rb
|
77
|
-
- lib/ffi-ncurses/
|
78
|
-
- lib/ffi-ncurses/
|
88
|
+
- lib/ffi-ncurses/ord_shim.rb
|
89
|
+
- lib/ffi-ncurses/bool_wrappers.rb
|
90
|
+
- lib/ffi-ncurses/ncurses.rb
|
79
91
|
- lib/ffi-ncurses/winstruct.rb
|
80
|
-
|
92
|
+
- lib/ffi-ncurses/widechars.rb
|
93
|
+
- lib/ffi-ncurses/panel.rb
|
94
|
+
- lib/ffi-ncurses/typedefs.rb
|
95
|
+
- lib/ffi-ncurses/darwin.rb
|
96
|
+
- lib/ffi-ncurses/acs.rb
|
97
|
+
- lib/ffi-ncurses/version.rb
|
98
|
+
- lib/ffi-ncurses/mouse.rb
|
99
|
+
- spec/attached_functions_spec.rb
|
81
100
|
homepage: http://github.com/seanohalpin/ffi-ncurses
|
82
101
|
licenses: []
|
83
|
-
|
84
102
|
post_install_message:
|
85
|
-
rdoc_options:
|
86
|
-
|
87
|
-
- README.rdoc
|
88
|
-
require_paths:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
89
105
|
- lib
|
90
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
107
|
none: false
|
92
|
-
requirements:
|
93
|
-
- -
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
|
96
|
-
|
97
|
-
version: "0"
|
98
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
113
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
- 0
|
105
|
-
version: "0"
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
106
118
|
requirements: []
|
107
|
-
|
108
|
-
|
109
|
-
rubygems_version: 1.3.7
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 1.8.10
|
110
121
|
signing_key:
|
111
122
|
specification_version: 3
|
112
|
-
summary: FFI wrapper for
|
123
|
+
summary: An FFI wrapper around ncursesw 5.x for MRI Ruby 1.8.x, 1.9.x and JRuby.
|
113
124
|
test_files: []
|
114
|
-
|
data/examples/example-colour.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Sean O'Halpin, 2009-02-15
|
4
|
-
#
|
5
|
-
require 'ffi-ncurses'
|
6
|
-
require 'ffi-ncurses/ord-shim' # for 1.8.6 compatibility
|
7
|
-
include FFI::NCurses
|
8
|
-
|
9
|
-
initscr
|
10
|
-
begin
|
11
|
-
# turn cursor off
|
12
|
-
curs_set 0
|
13
|
-
|
14
|
-
# initialize colour
|
15
|
-
start_color
|
16
|
-
|
17
|
-
# set up colour pairs
|
18
|
-
# Background Foreground
|
19
|
-
init_pair(0, Colour::BLACK, Colour::BLACK)
|
20
|
-
init_pair(1, Colour::RED, Colour::BLACK)
|
21
|
-
init_pair(2, Colour::GREEN, Colour::BLACK)
|
22
|
-
init_pair(3, Colour::YELLOW, Colour::BLACK)
|
23
|
-
init_pair(4, Colour::BLUE, Colour::BLACK)
|
24
|
-
init_pair(5, Colour::MAGENTA, Colour::BLACK)
|
25
|
-
init_pair(6, Colour::CYAN, Colour::BLACK)
|
26
|
-
init_pair(7, Colour::WHITE, Colour::BLACK)
|
27
|
-
|
28
|
-
init_pair(8, Colour::BLACK, Colour::BLACK)
|
29
|
-
init_pair(9, Colour::BLACK, Colour::RED)
|
30
|
-
init_pair(10, Colour::BLACK, Colour::GREEN)
|
31
|
-
init_pair(11, Colour::BLACK, Colour::YELLOW)
|
32
|
-
init_pair(12, Colour::BLACK, Colour::BLUE)
|
33
|
-
init_pair(13, Colour::BLACK, Colour::MAGENTA)
|
34
|
-
init_pair(14, Colour::BLACK, Colour::CYAN)
|
35
|
-
init_pair(15, Colour::BLACK, Colour::WHITE)
|
36
|
-
|
37
|
-
0.upto(15) do |i|
|
38
|
-
attr_set A_NORMAL, i, nil
|
39
|
-
addch("A"[0].ord + i)
|
40
|
-
end
|
41
|
-
|
42
|
-
# add character and attribute together
|
43
|
-
addch("Z"[0].ord | COLOR_PAIR(1)) # red
|
44
|
-
|
45
|
-
# reset attribute and colour to default
|
46
|
-
attr_set A_NORMAL, 0, nil
|
47
|
-
|
48
|
-
# start new line
|
49
|
-
addstr "\n"
|
50
|
-
|
51
|
-
# how to add a single space
|
52
|
-
addch(' '[0].ord)
|
53
|
-
# or
|
54
|
-
addstr(" ")
|
55
|
-
|
56
|
-
addstr "Press any key"
|
57
|
-
|
58
|
-
# display and pause for key press
|
59
|
-
refresh
|
60
|
-
ch = getch
|
61
|
-
ensure
|
62
|
-
endwin
|
63
|
-
end
|
data/examples/example-cursor.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Sean O'Halpin, 2009-02-15
|
4
|
-
#
|
5
|
-
require 'ffi-ncurses'
|
6
|
-
include FFI::NCurses
|
7
|
-
begin
|
8
|
-
initscr
|
9
|
-
addstr "Default"
|
10
|
-
getch
|
11
|
-
addstr "curs_set 0"
|
12
|
-
curs_set 0
|
13
|
-
getch
|
14
|
-
addstr "curs_set 1"
|
15
|
-
curs_set 1
|
16
|
-
getch
|
17
|
-
addstr "curs_set 2"
|
18
|
-
curs_set 2
|
19
|
-
getch
|
20
|
-
ensure
|
21
|
-
FFI::NCurses.endwin
|
22
|
-
end
|
data/examples/example-hello.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Sean O'Halpin, 2009-02-15
|
4
|
-
#
|
5
|
-
require 'ffi-ncurses'
|
6
|
-
include FFI::NCurses
|
7
|
-
begin
|
8
|
-
greeting = ARGV.shift || "World"
|
9
|
-
stdscr = initscr
|
10
|
-
raw
|
11
|
-
keypad stdscr, 1
|
12
|
-
noecho
|
13
|
-
curs_set 0
|
14
|
-
printw "Hello %s", :string, greeting
|
15
|
-
move 3, 0
|
16
|
-
addstr "Press any key to continue"
|
17
|
-
refresh
|
18
|
-
ch = getch
|
19
|
-
printw "\nYou pressed %c (%d)", :char, ch, :int, ch
|
20
|
-
refresh
|
21
|
-
sleep 1
|
22
|
-
ensure
|
23
|
-
endwin
|
24
|
-
end
|
data/examples/example-jruby.rb
DELETED
data/examples/example-keys.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Sean O'Halpin, 2009-02-15
|
4
|
-
#
|
5
|
-
require 'ffi-ncurses'
|
6
|
-
include FFI::NCurses
|
7
|
-
begin
|
8
|
-
initscr
|
9
|
-
raw
|
10
|
-
keypad stdscr, 1
|
11
|
-
noecho
|
12
|
-
curs_set 0
|
13
|
-
ch = 0
|
14
|
-
name = "none"
|
15
|
-
while ch != 27 # Escape
|
16
|
-
clear
|
17
|
-
addstr "Press any key (Escape to exit): "
|
18
|
-
printw "name: %s dec: %d char: [%c]", :string, name, :int, ch, :int, ch
|
19
|
-
refresh
|
20
|
-
ch = getch
|
21
|
-
name = keyname(ch)
|
22
|
-
end
|
23
|
-
ensure
|
24
|
-
endwin
|
25
|
-
end
|
data/examples/example-windows.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Sean O'Halpin, 2009-02-15
|
4
|
-
#
|
5
|
-
require 'ffi-ncurses'
|
6
|
-
include FFI::NCurses
|
7
|
-
|
8
|
-
begin
|
9
|
-
initscr
|
10
|
-
curs_set 0
|
11
|
-
win = newwin(6, 12, 15, 15)
|
12
|
-
box(win, 0, 0)
|
13
|
-
inner_win = newwin(4, 10, 16, 16)
|
14
|
-
waddstr(inner_win, (["Hello window!"] * 5).join(' '))
|
15
|
-
wrefresh(win)
|
16
|
-
wrefresh(inner_win)
|
17
|
-
ch = wgetch(inner_win)
|
18
|
-
|
19
|
-
rescue Object => e
|
20
|
-
endwin
|
21
|
-
puts e
|
22
|
-
ensure
|
23
|
-
endwin
|
24
|
-
end
|