ncursesw 1.4.3 → 1.4.4
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/README +9 -7
- data/examples/form_get_wch.rb +5 -1
- data/examples/rain.rb +4 -4
- data/examples/read_line.rb +6 -6
- data/examples/tclock.rb +34 -34
- data/lib/ncurses_sugar.rb +7 -7
- metadata +2 -2
data/README
CHANGED
|
@@ -5,6 +5,8 @@ library.
|
|
|
5
5
|
(C) 2002, 2003, 2004 Tobias Peters <t-peters@users.berlios.de>
|
|
6
6
|
(C) 2004 Simon Kaczor <skaczor@cox.net>
|
|
7
7
|
(C) 2005 2006 Tobias Herzke <t-peters@users.berlios.de>
|
|
8
|
+
(C) 2013 2014 Gaute Hope <eg@gaute.vetsj.com>
|
|
9
|
+
(C) 2013 2014 Sup developers
|
|
8
10
|
|
|
9
11
|
This module is free software; you can redistribute it and/or
|
|
10
12
|
modify it under the terms of the GNU Lesser General Public
|
|
@@ -37,7 +39,7 @@ mapped to a Ruby Module named "Ncurses": Functions and external
|
|
|
37
39
|
variables are implemented as singleton functions of the Module
|
|
38
40
|
Ncurses.
|
|
39
41
|
|
|
40
|
-
This README is organized into the following parts:
|
|
42
|
+
This README is organized into the following parts:
|
|
41
43
|
- Overview
|
|
42
44
|
- Installation and Usage
|
|
43
45
|
- External Variables
|
|
@@ -100,7 +102,7 @@ One of these external variables, ESCDELAY, is also settable with a ruby method
|
|
|
100
102
|
(Ncurses.ESCDELAY=).
|
|
101
103
|
|
|
102
104
|
Another external variable, Ncurses.RESIZEDELAY is introduced by this wrapper.
|
|
103
|
-
It contains the maximum milliseconds delay with which terminal resizesings are
|
|
105
|
+
It contains the maximum milliseconds delay with which terminal resizesings are
|
|
104
106
|
recognized.
|
|
105
107
|
|
|
106
108
|
Constants
|
|
@@ -143,7 +145,7 @@ changes to them.
|
|
|
143
145
|
Attention: some macro-only functions like getsyx accept variables of type int,
|
|
144
146
|
but, being macros, they write values to their arguments. Thus, they also need
|
|
145
147
|
empty array arguments when called from ruby.
|
|
146
|
-
Example:
|
|
148
|
+
Example:
|
|
147
149
|
color_pair_number = 4
|
|
148
150
|
foreground_color = []
|
|
149
151
|
background_color = []
|
|
@@ -204,7 +206,7 @@ module Ncurses
|
|
|
204
206
|
class WINDOW; end
|
|
205
207
|
class SCREEN; end
|
|
206
208
|
class MEVENT; end
|
|
207
|
-
module Panel
|
|
209
|
+
module Panel
|
|
208
210
|
class PANEL; end
|
|
209
211
|
end
|
|
210
212
|
module Form
|
|
@@ -267,7 +269,7 @@ The form Library
|
|
|
267
269
|
The form library was wrapped inside the Ncurses:Form module. All
|
|
268
270
|
form functions are implemented as module functions on the module
|
|
269
271
|
Ncurses::Form. In addition, all function for which the first
|
|
270
|
-
parameter is one of the objects are also implemented as an instance
|
|
272
|
+
parameter is one of the objects are also implemented as an instance
|
|
271
273
|
method of the respective class. For example, instead of calling
|
|
272
274
|
post_form(form), you can use form.post_form().
|
|
273
275
|
|
|
@@ -299,7 +301,7 @@ The menu Library
|
|
|
299
301
|
The menu library was wrapped inside the Ncurses:Menu module. All
|
|
300
302
|
menu functions are implemented as module functions in the module
|
|
301
303
|
Ncurses::Menu. In addition, all functions for which the first
|
|
302
|
-
parameter is one of the objects are also implemented as an instance
|
|
304
|
+
parameter is one of the objects are also implemented as an instance
|
|
303
305
|
method of the respective class. For example, instead of calling
|
|
304
306
|
post_menu(menu), you can use menu.post_menu().
|
|
305
307
|
|
|
@@ -330,7 +332,7 @@ However, it is used by many ncurses programs, and for this purpose,
|
|
|
330
332
|
a wrapper for this function is also included in ncurses-ruby.
|
|
331
333
|
|
|
332
334
|
The function is implemented as a module function Ncurses.ruby, and
|
|
333
|
-
expects two arguments, an Integer and a String. It returns a string.
|
|
335
|
+
expects two arguments, an Integer and a String. It returns a string.
|
|
334
336
|
The constants that can be used as the Integer argument are also wrapped
|
|
335
337
|
as constants in the Ncurses module. See the manual page for setlocale
|
|
336
338
|
for documentation of this function.
|
data/examples/form_get_wch.rb
CHANGED
|
@@ -42,6 +42,10 @@ begin
|
|
|
42
42
|
|
|
43
43
|
buf = ""
|
|
44
44
|
|
|
45
|
+
if not defined? Ncurses::Form.form_driver_w
|
|
46
|
+
raise NotImplementedError, "This example needs a ncurses version with the form_driver_w method"
|
|
47
|
+
end
|
|
48
|
+
|
|
45
49
|
# Loop through to get user requests
|
|
46
50
|
while(true) do
|
|
47
51
|
ret = Ncurses.get_wch()
|
|
@@ -55,7 +59,7 @@ begin
|
|
|
55
59
|
# If this is a normal character, it gets Printed
|
|
56
60
|
#prbuf = fields[0].field_buffer 0
|
|
57
61
|
##buf = buf.force_encoding('utf-8') + [ch].pack('U')
|
|
58
|
-
#buf = prbuf + [ch].pack('U')
|
|
62
|
+
#buf = prbuf + [ch].pack('U')
|
|
59
63
|
|
|
60
64
|
|
|
61
65
|
##buf = sbuf.force_encoding('utf-8') + [ch].pack('U')
|
data/examples/rain.rb
CHANGED
|
@@ -166,7 +166,7 @@ class Rain
|
|
|
166
166
|
num_ceil
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
def fall(pause = 0.1)
|
|
171
171
|
begin
|
|
172
172
|
fall_for_a_moment
|
|
@@ -198,13 +198,13 @@ begin
|
|
|
198
198
|
|
|
199
199
|
begin
|
|
200
200
|
case(Ncurses.getch())
|
|
201
|
-
when 'q'
|
|
201
|
+
when 'q'.ord, 'Q'.ord
|
|
202
202
|
Ncurses.curs_set(1)
|
|
203
203
|
Ncurses.endwin()
|
|
204
204
|
exit
|
|
205
|
-
when 's'
|
|
205
|
+
when 's'.ord
|
|
206
206
|
Ncurses.stdscr.nodelay(false)
|
|
207
|
-
when ' '
|
|
207
|
+
when ' '.ord
|
|
208
208
|
Ncurses.stdscr.nodelay(true)
|
|
209
209
|
when Ncurses::KEY_RESIZE
|
|
210
210
|
Rain.sigwinch_handler
|
data/examples/read_line.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# Emacs: This is -*- ruby -*- code!
|
|
3
|
-
#
|
|
3
|
+
#
|
|
4
4
|
# Unfinished read_line function
|
|
5
5
|
#
|
|
6
6
|
# Written 2003, 2004 by Tobias Peters
|
|
@@ -33,7 +33,7 @@ def read_line(y, x,
|
|
|
33
33
|
cursor_pos = [0, cursor_pos-1].max
|
|
34
34
|
window.mvaddstr(y, x+string.length, " ")
|
|
35
35
|
# when etc...
|
|
36
|
-
when " "
|
|
36
|
+
when " ".ord..255 # remaining printables
|
|
37
37
|
if (cursor_pos < max_len)
|
|
38
38
|
string[cursor_pos,0] = ch.chr
|
|
39
39
|
cursor_pos += 1
|
|
@@ -43,8 +43,8 @@ def read_line(y, x,
|
|
|
43
43
|
else
|
|
44
44
|
Ncurses.beep
|
|
45
45
|
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
48
|
|
|
49
49
|
if (__FILE__ == $0) then begin
|
|
50
50
|
# demo mode
|
|
@@ -54,13 +54,13 @@ if (__FILE__ == $0) then begin
|
|
|
54
54
|
|
|
55
55
|
# recognize KEY_ENTER, KEY_BACKSPACE etc
|
|
56
56
|
Ncurses.keypad(Ncurses.stdscr, true)
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
y = 10
|
|
59
59
|
x = 2
|
|
60
60
|
prompt = "Hallo > "
|
|
61
61
|
Ncurses.mvaddstr(y,x, prompt)
|
|
62
62
|
s = read_line(y, x + prompt.length)
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
ensure
|
|
65
65
|
Ncurses.endwin
|
|
66
66
|
end end
|
data/examples/tclock.rb
CHANGED
|
@@ -48,7 +48,7 @@ end
|
|
|
48
48
|
|
|
49
49
|
# Plot a point
|
|
50
50
|
def plot(x, y, c)
|
|
51
|
-
Ncurses.mvaddch(y, x, c
|
|
51
|
+
Ncurses.mvaddch(y, x, c.ord)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
# Draw a diagonal(arbitrary) line using Bresenham's alogrithm.
|
|
@@ -56,43 +56,43 @@ def dline(pair, from_x, from_y, x2, y2, ch)
|
|
|
56
56
|
if (Ncurses.has_colors?)
|
|
57
57
|
Ncurses.attrset(Ncurses.COLOR_PAIR(pair))
|
|
58
58
|
end
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
dx = x2 - from_x;
|
|
61
61
|
dy = y2 - from_y;
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
ax = (dx * 2).abs
|
|
64
64
|
ay = (dy * 2).abs
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
sx = sign(dx);
|
|
67
67
|
sy = sign(dy);
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
x = from_x;
|
|
70
70
|
y = from_y;
|
|
71
|
-
|
|
72
|
-
if (ax > ay)
|
|
71
|
+
|
|
72
|
+
if (ax > ay)
|
|
73
73
|
d = ay - (ax / 2);
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
while (1)
|
|
76
76
|
plot(x, y, ch);
|
|
77
77
|
if (x == x2)
|
|
78
78
|
return nil
|
|
79
79
|
end
|
|
80
|
-
if (d >= 0)
|
|
80
|
+
if (d >= 0)
|
|
81
81
|
y += sy;
|
|
82
82
|
d -= ax;
|
|
83
83
|
end
|
|
84
84
|
x += sx;
|
|
85
85
|
d += ay;
|
|
86
86
|
end
|
|
87
|
-
else
|
|
87
|
+
else
|
|
88
88
|
d = ax - (ay / 2);
|
|
89
|
-
|
|
90
|
-
while (1)
|
|
89
|
+
|
|
90
|
+
while (1)
|
|
91
91
|
plot(x, y, ch);
|
|
92
92
|
if (y == y2)
|
|
93
93
|
return nil;
|
|
94
94
|
end
|
|
95
|
-
if (d >= 0)
|
|
95
|
+
if (d >= 0)
|
|
96
96
|
x += sx;
|
|
97
97
|
d -= ay;
|
|
98
98
|
end
|
|
@@ -110,20 +110,20 @@ begin
|
|
|
110
110
|
# int mdx, mdy;
|
|
111
111
|
# int sdx, sdy;
|
|
112
112
|
# int ch;
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
|
|
115
115
|
lastbeep = -1;
|
|
116
116
|
my_bg = Ncurses::COLOR_BLACK;
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
Ncurses::initscr();
|
|
119
119
|
Ncurses::noecho();
|
|
120
120
|
Ncurses::cbreak();
|
|
121
121
|
Ncurses::nodelay(Ncurses::stdscr, TRUE);
|
|
122
122
|
Ncurses::curs_set(0);
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
if (Ncurses::has_colors?())
|
|
125
125
|
Ncurses::start_color();
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
Ncurses::init_pair(1, Ncurses::COLOR_RED, my_bg);
|
|
128
128
|
Ncurses::init_pair(2, Ncurses::COLOR_MAGENTA, my_bg);
|
|
129
129
|
Ncurses::init_pair(3, Ncurses::COLOR_GREEN, my_bg);
|
|
@@ -147,70 +147,70 @@ begin
|
|
|
147
147
|
|
|
148
148
|
Ncurses::mvaddstr(cy - sdy, cx + sdx, szChar);
|
|
149
149
|
end
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
Ncurses::mvaddstr(0, 0,
|
|
152
152
|
"ASCII Clock by Howard Jones (ha.jones@ic.ac.uk),1994");
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
sradius -=2
|
|
155
155
|
sradius = 1 if sradius < 1
|
|
156
156
|
window_size_changed = false
|
|
157
157
|
while (window_size_changed == false)
|
|
158
158
|
sleep(0.100);
|
|
159
|
-
|
|
159
|
+
|
|
160
160
|
hours = Time.now.hour + Time.now.min / 60.0;
|
|
161
161
|
if (hours > 12.0)
|
|
162
162
|
hours -= 12.0;
|
|
163
163
|
end
|
|
164
|
-
|
|
164
|
+
|
|
165
165
|
mangle = Time.now.min * (2 * PI) / 60.0;
|
|
166
166
|
mdx = a2x(mangle, mradius);
|
|
167
167
|
mdy = a2y(mangle, mradius);
|
|
168
|
-
|
|
168
|
+
|
|
169
169
|
hangle = ((hours) * (2.0 * PI) / 12.0);
|
|
170
170
|
hdx = a2x(hangle, hradius);
|
|
171
171
|
hdy = a2y(hangle, hradius);
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
sangle = ((Time.now.sec) * (2.0 * PI) / 60.0);
|
|
174
174
|
sdx = a2x(sangle, sradius);
|
|
175
175
|
sdy = a2y(sangle, sradius);
|
|
176
|
-
|
|
176
|
+
|
|
177
177
|
dline(3, cx, cy, cx + mdx, cy - mdy, '#');
|
|
178
|
-
|
|
178
|
+
|
|
179
179
|
Ncurses::attrset(Ncurses::A_REVERSE);
|
|
180
180
|
dline(2, cx, cy, cx + hdx, cy - hdy, '.');
|
|
181
181
|
Ncurses::attroff(Ncurses::A_REVERSE);
|
|
182
|
-
|
|
182
|
+
|
|
183
183
|
if (Ncurses::has_colors?())
|
|
184
184
|
Ncurses::attrset(Ncurses::COLOR_PAIR(1));
|
|
185
185
|
end
|
|
186
186
|
plot(cx + sdx, cy - sdy, 'O');
|
|
187
|
-
|
|
187
|
+
|
|
188
188
|
if (Ncurses::has_colors?())
|
|
189
189
|
Ncurses::attrset(Ncurses::COLOR_PAIR(0));
|
|
190
190
|
end
|
|
191
191
|
Ncurses::mvaddstr(Ncurses.LINES - 2, 0, Time.now.to_s);
|
|
192
192
|
Ncurses::refresh();
|
|
193
193
|
if ((Time.now.sec % 5) == 0 &&
|
|
194
|
-
Time.now.sec != lastbeep)
|
|
194
|
+
Time.now.sec != lastbeep)
|
|
195
195
|
lastbeep = Time.now.sec;
|
|
196
196
|
Ncurses::beep();
|
|
197
197
|
end
|
|
198
|
-
|
|
198
|
+
|
|
199
199
|
if ((ch = Ncurses::getch()) != Ncurses::ERR)
|
|
200
|
-
if (ch == Ncurses::KEY_RESIZE)
|
|
200
|
+
if (ch == Ncurses::KEY_RESIZE)
|
|
201
201
|
Ncurses::erase();
|
|
202
202
|
window_size_changed = true;
|
|
203
203
|
else
|
|
204
204
|
break;
|
|
205
205
|
end
|
|
206
206
|
end
|
|
207
|
-
|
|
207
|
+
|
|
208
208
|
plot(cx + sdx, cy - sdy, ' ');
|
|
209
209
|
dline(0, cx, cy, cx + hdx, cy - hdy, ' ');
|
|
210
210
|
dline(0, cx, cy, cx + mdx, cy - mdy, ' ');
|
|
211
|
-
|
|
211
|
+
|
|
212
212
|
end
|
|
213
|
-
|
|
213
|
+
|
|
214
214
|
if ! window_size_changed
|
|
215
215
|
$stderr.puts "! window_size_changed"
|
|
216
216
|
break
|
|
@@ -220,7 +220,7 @@ ensure
|
|
|
220
220
|
Ncurses::curs_set(1);
|
|
221
221
|
Ncurses::endwin();
|
|
222
222
|
end
|
|
223
|
-
|
|
223
|
+
|
|
224
224
|
|
|
225
225
|
|
|
226
226
|
|
data/lib/ncurses_sugar.rb
CHANGED
|
@@ -57,20 +57,20 @@ module Ncurses
|
|
|
57
57
|
module Destroy_checker; def destroyed?; @destroyed; end; end
|
|
58
58
|
class WINDOW
|
|
59
59
|
include Destroy_checker
|
|
60
|
-
def method_missing(name, *args)
|
|
60
|
+
def method_missing(name, *args, &block)
|
|
61
61
|
name = name.to_s
|
|
62
62
|
if (name[0,2] == "mv")
|
|
63
63
|
test_name = name.dup
|
|
64
64
|
test_name[2,0] = "w" # insert "w" after"mv"
|
|
65
65
|
if (Ncurses.respond_to?(test_name))
|
|
66
|
-
return Ncurses.send(test_name, self, *args)
|
|
66
|
+
return Ncurses.send(test_name, self, *args, &block)
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
test_name = "w" + name
|
|
70
70
|
if (Ncurses.respond_to?(test_name))
|
|
71
|
-
return Ncurses.send(test_name, self, *args)
|
|
71
|
+
return Ncurses.send(test_name, self, *args, &block)
|
|
72
72
|
end
|
|
73
|
-
Ncurses.send(name, self, *args)
|
|
73
|
+
Ncurses.send(name, self, *args, &block)
|
|
74
74
|
end
|
|
75
75
|
def respond_to?(name)
|
|
76
76
|
name = name.to_s
|
|
@@ -323,11 +323,11 @@ module Ncurses
|
|
|
323
323
|
unless target.respond_to?(:pre_Ncurses_method_missing)
|
|
324
324
|
target.module_eval{
|
|
325
325
|
alias pre_Ncurses_method_missing method_missing
|
|
326
|
-
def method_missing(name, *args)
|
|
326
|
+
def method_missing(name, *args, &block)
|
|
327
327
|
if Ncurses.respond_to?(name)
|
|
328
|
-
Ncurses.send(name, *args)
|
|
328
|
+
Ncurses.send(name, *args, &block)
|
|
329
329
|
else
|
|
330
|
-
pre_Ncurses_method_missing(name, *args)
|
|
330
|
+
pre_Ncurses_method_missing(name, *args, &block)
|
|
331
331
|
end
|
|
332
332
|
end
|
|
333
333
|
}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ncursesw
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.4
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2014-01-
|
|
13
|
+
date: 2014-01-27 00:00:00.000000000 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
description: Tweaked version of ncursesw from http://ncurses-ruby.berlios.de/.
|
|
16
16
|
email:
|