newt 0.9.7 → 1.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.rdoc +24 -0
- data/examples/test-e.rb +108 -0
- data/examples/test-j.rb +50 -60
- data/examples/test_method/Button.rb +21 -0
- data/examples/test_method/Checkbox.rb +27 -0
- data/examples/test_method/CheckboxTree.rb +27 -0
- data/examples/test_method/CheckboxTreeMulti.rb +25 -0
- data/examples/test_method/CompactButton.rb +21 -0
- data/examples/test_method/Entry.rb +62 -0
- data/examples/test_method/Form.rb +23 -0
- data/examples/test_method/Form_ExitStruct.rb +35 -0
- data/examples/test_method/HelpCallback.rb +48 -0
- data/examples/test_method/Label.rb +26 -0
- data/examples/test_method/Listbox.rb +32 -0
- data/examples/test_method/Newt_FLAG_SCROLL.rb +3 -4
- data/examples/test_method/Newt_cursor.rb +30 -0
- data/examples/test_method/RadioButton.rb +23 -0
- data/examples/test_method/ReflowText.rb +8 -10
- data/examples/test_method/Scale.rb +27 -0
- data/examples/test_method/Screen_bell.rb +1 -1
- data/examples/test_method/Screen_cls.rb +1 -2
- data/examples/test_method/Screen_draw_roottext.rb +2 -3
- data/examples/test_method/Screen_init.rb +1 -2
- data/examples/test_method/Screen_pop_helpline.rb +2 -5
- data/examples/test_method/Screen_push_helpline.rb +2 -5
- data/examples/test_method/Screen_redraw_helpline.rb +2 -5
- data/examples/test_method/Screen_set_colors.rb +11 -13
- data/examples/test_method/Screen_size.rb +1 -1
- data/examples/test_method/Screen_win_menu.rb +3 -7
- data/examples/test_method/SuspendCallback.rb +33 -0
- data/examples/test_method/{Textbox_set_colors.rb → Textbox.rb} +8 -8
- data/examples/test_method/{TextboxReflowed_new.rb → TextboxReflowed.rb} +5 -8
- data/examples/test_method/Widget_callback.rb +76 -0
- data/examples/{memory.rb → test_method/memory.rb} +5 -5
- data/examples/testgrid-e.rb +80 -0
- data/examples/testgrid-j.rb +57 -62
- data/examples/testtree-e.rb +53 -0
- data/examples/testtree-j.rb +37 -39
- data/ext/ruby_newt/extconf.rb +3 -4
- data/ext/ruby_newt/ruby_newt.c +1001 -539
- data/lib/version.rb +1 -1
- metadata +31 -51
- data/examples/test.rb +0 -95
- data/examples/test_method/Button_new.rb +0 -22
- data/examples/test_method/Checkbox_get.rb +0 -25
- data/examples/test_method/Checkbox_new.rb +0 -22
- data/examples/test_method/Checkbox_set.rb +0 -28
- data/examples/test_method/Checkbox_set_flags.rb +0 -28
- data/examples/test_method/CompactButton_new.rb +0 -22
- data/examples/test_method/Entry_get.rb +0 -26
- data/examples/test_method/Entry_new.rb +0 -23
- data/examples/test_method/Entry_set.rb +0 -26
- data/examples/test_method/Entry_set_flags.rb +0 -31
- data/examples/test_method/Form_destroy.rb +0 -33
- data/examples/test_method/Form_set_background.rb +0 -23
- data/examples/test_method/Form_set_height.rb +0 -26
- data/examples/test_method/Form_set_width.rb +0 -26
- data/examples/test_method/Grid_new.rb +0 -26
- data/examples/test_method/Label_new.rb +0 -22
- data/examples/test_method/Label_setText.rb +0 -25
- data/examples/test_method/Label_set_colors.rb +0 -28
- data/examples/test_method/Listbox_clear.rb +0 -25
- data/examples/test_method/Listbox_current_bykey.rb +0 -29
- data/examples/test_method/Listbox_delete.rb +0 -27
- data/examples/test_method/Listbox_get_current.rb +0 -28
- data/examples/test_method/Listbox_get_current_string.rb +0 -28
- data/examples/test_method/Listbox_insert.rb +0 -24
- data/examples/test_method/Listbox_new.rb +0 -24
- data/examples/test_method/Listbox_select.rb +0 -27
- data/examples/test_method/Listbox_set.rb +0 -27
- data/examples/test_method/Listbox_set_current.rb +0 -26
- data/examples/test_method/Listbox_set_width.rb +0 -25
- data/examples/test_method/RadioButton_new.rb +0 -22
- data/examples/test_method/Scale_new.rb +0 -22
- data/examples/test_method/Scale_set.rb +0 -22
- data/examples/test_method/Textbox_get_num_lines.rb +0 -27
- data/examples/test_method/Textbox_new.rb +0 -22
- data/examples/test_method/Textbox_set_height.rb +0 -25
- data/examples/testgrid.rb +0 -84
- data/examples/testtree.rb +0 -54
@@ -1,16 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require
|
4
|
+
require 'newt'
|
5
5
|
|
6
6
|
begin
|
7
7
|
Newt::Screen.new
|
8
8
|
|
9
|
-
Newt::Screen.
|
10
|
-
|
11
|
-
Newt::Screen.push_helpline("Hit Key!!")
|
9
|
+
Newt::Screen.push_helpline('Hit Key!!')
|
12
10
|
Newt::Screen.wait_for_key
|
13
|
-
|
14
11
|
ensure
|
15
12
|
Newt::Screen.finish
|
16
13
|
end
|
@@ -1,18 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require
|
4
|
+
require 'newt'
|
5
5
|
|
6
6
|
begin
|
7
7
|
Newt::Screen.new
|
8
8
|
|
9
|
-
Newt::Screen.
|
10
|
-
|
11
|
-
Newt::Screen.push_helpline("Hit Key!!")
|
9
|
+
Newt::Screen.push_helpline('Hit Key!!')
|
12
10
|
Newt::Screen.wait_for_key
|
13
11
|
Newt::Screen.redraw_helpline
|
14
12
|
Newt::Screen.wait_for_key
|
15
|
-
|
16
13
|
ensure
|
17
14
|
Newt::Screen.finish
|
18
15
|
end
|
@@ -1,34 +1,32 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require
|
4
|
+
require 'newt'
|
5
5
|
|
6
6
|
COLORS = {
|
7
|
-
borderFg:
|
8
|
-
windowFg:
|
9
|
-
titleFg:
|
10
|
-
listboxFg:
|
11
|
-
actListboxFg:
|
12
|
-
buttonFg:
|
13
|
-
}
|
7
|
+
borderFg: 'yellow', borderBg: 'cyan',
|
8
|
+
windowFg: 'black', windowBg: 'cyan',
|
9
|
+
titleFg: 'black', titleBg: 'cyan',
|
10
|
+
listboxFg: 'black', listboxBg: 'cyan',
|
11
|
+
actListboxFg: 'black', actListboxBg: 'red',
|
12
|
+
buttonFg: 'white', buttonBg: 'blue'
|
13
|
+
}.freeze
|
14
14
|
|
15
15
|
begin
|
16
|
-
|
17
16
|
Newt::Screen.new
|
18
17
|
Newt::Screen.set_colors(COLORS)
|
19
18
|
|
20
19
|
l1 = Newt::Listbox.new(1, 1, 10, Newt::FLAG_SCROLL)
|
21
20
|
1.upto(20) do |i|
|
22
|
-
|
21
|
+
l1.append("item #{i}", i)
|
23
22
|
end
|
24
23
|
|
25
|
-
b = Newt::Button.new(1, 12,
|
24
|
+
b = Newt::Button.new(1, 12, 'Exit')
|
26
25
|
|
27
26
|
f = Newt::Form.new
|
28
27
|
f.add(l1, b)
|
29
28
|
|
30
|
-
f.run
|
31
|
-
|
29
|
+
f.run
|
32
30
|
ensure
|
33
31
|
Newt::Screen.finish
|
34
32
|
end
|
@@ -1,17 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require
|
4
|
+
require 'newt'
|
5
5
|
|
6
6
|
begin
|
7
|
-
|
8
7
|
Newt::Screen.new
|
9
8
|
|
10
|
-
v = Newt::Screen.win_menu(
|
11
|
-
|
12
|
-
|
13
|
-
#Newt::Screen.wait_for_key
|
14
|
-
|
9
|
+
v = Newt::Screen.win_menu('Test Menu', 'Text', 50, 5, 5, 3,
|
10
|
+
%w[One Two Three], 'OK')
|
15
11
|
ensure
|
16
12
|
Newt::Screen.finish
|
17
13
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# rubocop:disable Style/GlobalVars
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'newt'
|
6
|
+
|
7
|
+
$suspend_called = false
|
8
|
+
$callback_data = nil
|
9
|
+
|
10
|
+
def global_callback(data)
|
11
|
+
$suspend_called = true
|
12
|
+
$callback_data = data
|
13
|
+
end
|
14
|
+
|
15
|
+
begin
|
16
|
+
Newt::Screen.new
|
17
|
+
Newt::Screen.suspend_callback(:global_callback, 'Hello World!')
|
18
|
+
Newt::Screen.centered_window(20, 8, 'Suspend Callback')
|
19
|
+
|
20
|
+
l = Newt::Label.new(6, 1, 'Press ^Z')
|
21
|
+
b = Newt::Button.new(6, 3, 'Exit')
|
22
|
+
|
23
|
+
f = Newt::Form.new
|
24
|
+
f.add(l, b)
|
25
|
+
|
26
|
+
f.run
|
27
|
+
ensure
|
28
|
+
Newt::Screen.finish
|
29
|
+
end
|
30
|
+
|
31
|
+
puts "suspend_called: #{$suspend_called}"
|
32
|
+
puts "callback_data: #{$callback_data}"
|
33
|
+
# rubocop:enable Style/GlobalVars
|
@@ -1,27 +1,27 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require
|
4
|
+
require 'newt'
|
5
5
|
|
6
6
|
begin
|
7
7
|
TEXTBOX_NORMAL = Newt::COLORSET_CUSTOM 1
|
8
8
|
TEXTBOX_ACTIVE = Newt::COLORSET_CUSTOM 2
|
9
9
|
|
10
10
|
Newt::Screen.new
|
11
|
-
Newt::Screen.set_color(TEXTBOX_NORMAL,
|
12
|
-
Newt::Screen.set_color(TEXTBOX_ACTIVE,
|
11
|
+
Newt::Screen.set_color(TEXTBOX_NORMAL, 'black', 'red')
|
12
|
+
Newt::Screen.set_color(TEXTBOX_ACTIVE, 'white', 'red')
|
13
|
+
Newt::Screen.centered_window(20, 10, 'Textbox')
|
13
14
|
|
14
|
-
t = Newt::Textbox.new(1, 1,
|
15
|
+
t = Newt::Textbox.new(1, 1, 18, 3, Newt::FLAG_WRAP)
|
15
16
|
t.set_colors(TEXTBOX_NORMAL, TEXTBOX_ACTIVE)
|
16
17
|
t.set_text("Line1\nLine2\nLine3")
|
18
|
+
t.set_height(20)
|
17
19
|
|
18
|
-
b = Newt::Button.new(
|
19
|
-
|
20
|
+
b = Newt::Button.new(6, 6, 'Exit')
|
20
21
|
f = Newt::Form.new
|
21
22
|
f.add(t, b)
|
22
23
|
|
23
|
-
f.run
|
24
|
-
|
24
|
+
f.run
|
25
25
|
ensure
|
26
26
|
Newt::Screen.finish
|
27
27
|
end
|
@@ -1,23 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require
|
4
|
+
require 'newt'
|
5
5
|
|
6
6
|
begin
|
7
|
-
|
8
7
|
Newt::Screen.new
|
8
|
+
Newt::Screen.centered_window(20, 10, 'TextboxReflowed')
|
9
9
|
|
10
10
|
text = "Line1 Line1 Line1 Line1 Line1 Line1 Line1 Line1 \nLine2"
|
11
|
-
t = Newt::TextboxReflowed.new(1, 1, text,
|
12
|
-
|
13
|
-
b = Newt::Button.new(1, 15, "Exit")
|
11
|
+
t = Newt::TextboxReflowed.new(1, 1, text, 18, 0, 0, 0)
|
14
12
|
|
13
|
+
b = Newt::Button.new(6, 6, 'Exit')
|
15
14
|
f = Newt::Form.new
|
16
15
|
f.add(t, b)
|
17
16
|
|
18
|
-
f.run
|
19
|
-
|
17
|
+
f.run
|
20
18
|
ensure
|
21
19
|
Newt::Screen.finish
|
22
20
|
end
|
23
|
-
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# rubocop:disable Style/GlobalVars
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'newt'
|
6
|
+
|
7
|
+
$cb1_called = false
|
8
|
+
$cb1_widget = nil
|
9
|
+
$cb1_data = nil
|
10
|
+
|
11
|
+
$cb2_called = false
|
12
|
+
$cb2_widget = nil
|
13
|
+
$cb2_data = nil
|
14
|
+
|
15
|
+
$cb3_called = false
|
16
|
+
$cb3_widget = nil
|
17
|
+
$cb3_data = nil
|
18
|
+
|
19
|
+
def callme(w, data)
|
20
|
+
$cb1_called = true
|
21
|
+
$cb1_widget = w
|
22
|
+
$cb1_data = data
|
23
|
+
end
|
24
|
+
|
25
|
+
class Receiver
|
26
|
+
attr_reader :cb
|
27
|
+
def initialize
|
28
|
+
@cb = Newt::Checkbox.new(1, 12, 'Checkbox3')
|
29
|
+
@cb.callback(:callme, 'Hello Receiver!')
|
30
|
+
end
|
31
|
+
|
32
|
+
def callme(w, data)
|
33
|
+
$cb3_called = true
|
34
|
+
$cb3_widget = w
|
35
|
+
$cb3_data = data
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
begin
|
40
|
+
Newt::Screen.new
|
41
|
+
|
42
|
+
cb1 = Newt::Checkbox.new(1, 10, 'Checkbox1')
|
43
|
+
cb1.callback(:callme, 'Hello World!')
|
44
|
+
|
45
|
+
cb2 = Newt::Checkbox.new(1, 11, 'Checkbox2')
|
46
|
+
cb2.callback(proc { |w, data|
|
47
|
+
$cb2_called = true
|
48
|
+
$cb2_widget = w
|
49
|
+
$cb2_data = data
|
50
|
+
}, 'Hello Proc!')
|
51
|
+
|
52
|
+
cb_receiver = Receiver.new
|
53
|
+
b = Newt::Button.new(1, 14, 'Exit')
|
54
|
+
|
55
|
+
f = Newt::Form.new
|
56
|
+
f.add(cb1, cb2, cb_receiver.cb, b)
|
57
|
+
|
58
|
+
f.run
|
59
|
+
ensure
|
60
|
+
Newt::Screen.finish
|
61
|
+
end
|
62
|
+
|
63
|
+
puts "$cb1_called: #{$cb1_called}"
|
64
|
+
puts "$cb1_widget: #{$cb1_widget}"
|
65
|
+
puts "$cb1_data: #{$cb1_data}"
|
66
|
+
puts
|
67
|
+
|
68
|
+
puts "$cb2_called: #{$cb2_called}"
|
69
|
+
puts "$cb2_widget: #{$cb2_widget}"
|
70
|
+
puts "$cb2_data: #{$cb2_data}"
|
71
|
+
puts
|
72
|
+
|
73
|
+
puts "$cb3_called: #{$cb3_called}"
|
74
|
+
puts "$cb3_widget: #{$cb3_widget}"
|
75
|
+
puts "$cb3_data: #{$cb3_data}"
|
76
|
+
# rubocop:enable Style/GlobalVars
|
@@ -1,18 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
|
-
require
|
3
|
+
require 'newt'
|
4
4
|
|
5
5
|
def cleanup
|
6
6
|
Newt::Screen.finish
|
7
7
|
end
|
8
8
|
|
9
9
|
Newt::Screen.new
|
10
|
-
Signal.trap(
|
10
|
+
Signal.trap('INT') { cleanup }
|
11
11
|
|
12
|
-
|
12
|
+
10.times do
|
13
13
|
f = Newt::Form.new
|
14
|
-
b1 = Newt::Button.new(3, 1,
|
15
|
-
b2 = Newt::Button.new(18, 1,
|
14
|
+
b1 = Newt::Button.new(3, 1, 'Exit')
|
15
|
+
b2 = Newt::Button.new(18, 1, 'Update')
|
16
16
|
f.add(b1, b2)
|
17
17
|
Newt::Screen.refresh
|
18
18
|
GC.start
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
menu_contents = %w[One Two Three Four Five]
|
7
|
+
auto_entries = ['An entry', 'Another entry', 'Third entry', 'Fourth entry']
|
8
|
+
|
9
|
+
Newt::Screen.new
|
10
|
+
|
11
|
+
b1 = Newt::Checkbox.new(-1, -1, 'An pretty long checkbox for testing', ' ', nil)
|
12
|
+
b2 = Newt::Button.new(-1, -1, 'Another Button')
|
13
|
+
b3 = Newt::Button.new(-1, -1, 'But, but')
|
14
|
+
b4 = Newt::Button.new(-1, -1, 'But what?')
|
15
|
+
|
16
|
+
f = Newt::Form.new
|
17
|
+
|
18
|
+
grid = Newt::Grid.new(2, 2)
|
19
|
+
grid.set_field(0, 0, Newt::GRID_COMPONENT, b1, 0, 0, 0, 0,
|
20
|
+
Newt::ANCHOR_RIGHT, 0)
|
21
|
+
grid.set_field(0, 1, Newt::GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0)
|
22
|
+
grid.set_field(1, 0, Newt::GRID_COMPONENT, b3, 0, 0, 0, 0, 0, 0)
|
23
|
+
grid.set_field(1, 1, Newt::GRID_COMPONENT, b4, 0, 0, 0, 0, 0, 0)
|
24
|
+
|
25
|
+
f.add(b1, b2, b3, b4)
|
26
|
+
grid.wrapped_window('first window')
|
27
|
+
f.run
|
28
|
+
|
29
|
+
# f.destroy
|
30
|
+
Newt::Screen.pop_window
|
31
|
+
|
32
|
+
flowed_text, text_width, text_height = Newt.reflow_text('This is a quite a bit of text. It is 40 ' \
|
33
|
+
'columns long, so some wrapping should be ' \
|
34
|
+
'done. Did you know that the quick, brown ' \
|
35
|
+
"fox jumped over the lazy dog?\n\n" \
|
36
|
+
"In other news, it's pretty important that we " \
|
37
|
+
'can properly force a line break.', 40, 5, 5)
|
38
|
+
|
39
|
+
t = Newt::Textbox.new(-1, -1, text_width, text_height, Newt::FLAG_WRAP)
|
40
|
+
t.set_text(flowed_text)
|
41
|
+
|
42
|
+
b1 = Newt::Button.new(-1, -1, 'Okay')
|
43
|
+
b2 = Newt::Button.new(-1, -1, 'Cancel')
|
44
|
+
|
45
|
+
grid = Newt::Grid.new(1, 2)
|
46
|
+
subgrid = Newt::Grid.new(2, 1)
|
47
|
+
|
48
|
+
subgrid.set_field(0, 0, Newt::GRID_COMPONENT, b1, 0, 0, 0, 0, 0, 0)
|
49
|
+
subgrid.set_field(1, 0, Newt::GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0)
|
50
|
+
|
51
|
+
grid.set_field(0, 0, Newt::GRID_COMPONENT, t, 0, 0, 0, 1, 0, 0)
|
52
|
+
grid.set_field(0, 1, Newt::GRID_SUBGRID, subgrid, 0, 0, 0, 0, 0,
|
53
|
+
Newt::GRID_FLAG_GROWX)
|
54
|
+
grid.wrapped_window('another example')
|
55
|
+
|
56
|
+
f = Newt::Form.new
|
57
|
+
f.add(b1, t, b2)
|
58
|
+
f.run
|
59
|
+
|
60
|
+
Newt::Screen.pop_window
|
61
|
+
# f.destroy
|
62
|
+
|
63
|
+
Newt::Screen.win_message('Simple', 'Ok', 'This is a simple message window')
|
64
|
+
result = Newt::Screen.win_choice('Simple', 'Ok', 'Cancel', 'This is a simple choice window')
|
65
|
+
|
66
|
+
text_width = Newt::Screen.win_menu('Test Menu', 'This is a sample invovation of the ' \
|
67
|
+
'newtWinMenu() call. It may or may not have a scrollbar, ' \
|
68
|
+
'depending on the need for one.',
|
69
|
+
50, 5, 5, 3, menu_contents, 'Ok', 'Cancel')
|
70
|
+
|
71
|
+
v = Newt::Screen.win_entries('Text newtWinEntries()', 'This is a sample invovation of ' \
|
72
|
+
'newtWinEntries() call. It lets you get a lot of input ' \
|
73
|
+
'quite easily.',
|
74
|
+
50, 5, 5, 20, auto_entries, 'Ok', 'Cancel')
|
75
|
+
|
76
|
+
Newt::Screen.finish
|
77
|
+
|
78
|
+
printf "item = %d\n", text_width
|
79
|
+
p v
|
80
|
+
p result
|
data/examples/testgrid-j.rb
CHANGED
@@ -1,85 +1,80 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require
|
4
|
+
require 'newt'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
"»°ÈÖÌܤΥ¨¥ó¥È¥ê", "»ÍÈÖÌܤΥ¨¥ó¥È¥ê",]
|
6
|
+
menu_contents = ['°ì', 'Æó', '»°', '»Í', '¸Þ']
|
7
|
+
auto_entries = ['¥¨¥ó¥È¥ê', 'Ê̤Υ¨¥ó¥È¥ê', '»°ÈÖÌܤΥ¨¥ó¥È¥ê', '»ÍÈÖÌܤΥ¨¥ó¥È¥ê']
|
9
8
|
|
10
|
-
|
11
|
-
Newt::Screen.new
|
9
|
+
Newt::Screen.new
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
b1 = Newt::Checkbox.new(-1, -1, '¥Æ¥¹¥È¤Î¤¿¤á¤Î¤«¤Ê¤êŤ¤¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹', ' ', nil)
|
12
|
+
b2 = Newt::Button.new(-1, -1, 'Ê̤Υܥ¿¥ó')
|
13
|
+
b3 = Newt::Button.new(-1, -1, '¤·¤«¤·¡¢¤·¤«¤·')
|
14
|
+
b4 = Newt::Button.new(-1, -1, '¤·¤«¤·²¿¤À¤í¤¦¡©')
|
17
15
|
|
18
|
-
|
16
|
+
f = Newt::Form.new
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
grid = Newt::Grid.new(2, 2)
|
19
|
+
grid.set_field(0, 0, Newt::GRID_COMPONENT, b1, 0, 0, 0, 0,
|
20
|
+
Newt::ANCHOR_RIGHT, 0)
|
21
|
+
grid.set_field(0, 1, Newt::GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0)
|
22
|
+
grid.set_field(1, 0, Newt::GRID_COMPONENT, b3, 0, 0, 0, 0, 0, 0)
|
23
|
+
grid.set_field(1, 1, Newt::GRID_COMPONENT, b4, 0, 0, 0, 0, 0, 0)
|
26
24
|
|
27
|
-
|
25
|
+
f.add(b1, b2, b3, b4)
|
26
|
+
grid.wrapped_window('°ìÈÖÌܤΥ¦¥£¥ó¥É¥¦')
|
27
|
+
f.run
|
28
28
|
|
29
|
-
|
29
|
+
# f.destroy
|
30
|
+
Newt::Screen.pop_window
|
30
31
|
|
31
|
-
|
32
|
+
flowed_text, text_width, text_height = Newt.reflow_text('¤³¤ì¤Ï¤«¤Ê¤ê¥Æ¥¥¹¥È¤é¤·¤¤¤â¤Î¤Ç¤¹¡£40¥«¥é¥à' \
|
33
|
+
'¤ÎŤµ¤Ç¡¢¥é¥Ã¥Ô¥ó¥°¤¬¹Ô¤ï¤ì¤Þ¤¹¡£' \
|
34
|
+
'ÁÇÁᤤ¡¢Ã㿧¤Î¸Ñ¤¬¤Î¤í¤Þ¤Ê¸¤¤òÈô¤Ó' \
|
35
|
+
"±Û¤¨¤¿¤Î¤òÃΤäƤ뤫¤¤?\n\n" \
|
36
|
+
'¾¤Ë¤ªÃΤ餻¤¹¤ë¤³¤È¤È¤·¤Æ¡¢Å¬Åö¤Ë²þ¹Ô¤ò¤¹¤ë' \
|
37
|
+
'¤³¤È¤¬½ÅÍפǤ¹¡£', 40, 5, 5)
|
32
38
|
|
33
|
-
|
34
|
-
|
39
|
+
t = Newt::Textbox.new(-1, -1, text_width, text_height, Newt::FLAG_WRAP)
|
40
|
+
t.set_text(flowed_text)
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
"ÁÇÁᤤ¡¢Ã㿧¤Î¸Ñ¤¬¤Î¤í¤Þ¤Ê¸¤¤òÈô¤Ó" +
|
39
|
-
"±Û¤¨¤¿¤Î¤òÃΤäƤ뤫¤¤?\n\n" +
|
40
|
-
"¾¤Ë¤ªÃΤ餻¤¹¤ë¤³¤È¤È¤·¤Æ¡¢Å¬Åö¤Ë²þ¹Ô¤ò¤¹¤ë" +
|
41
|
-
"¤³¤È¤¬½ÅÍפǤ¹¡£",
|
42
|
-
40, 5, 5)
|
43
|
-
t = Newt::Textbox.new(-1, -1, textWidth, textHeight, Newt::FLAG_WRAP)
|
44
|
-
t.set_text(flowedText)
|
42
|
+
b1 = Newt::Button.new(-1, -1, 'λ²ò')
|
43
|
+
b2 = Newt::Button.new(-1, -1, '¥¥ã¥ó¥»¥ë')
|
45
44
|
|
46
|
-
|
47
|
-
|
45
|
+
grid = Newt::Grid.new(1, 2)
|
46
|
+
subgrid = Newt::Grid.new(2, 1)
|
48
47
|
|
49
|
-
|
50
|
-
|
48
|
+
subgrid.set_field(0, 0, Newt::GRID_COMPONENT, b1, 0, 0, 0, 0, 0, 0)
|
49
|
+
subgrid.set_field(1, 0, Newt::GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0)
|
51
50
|
|
52
|
-
|
53
|
-
|
51
|
+
grid.set_field(0, 0, Newt::GRID_COMPONENT, t, 0, 0, 0, 1, 0, 0)
|
52
|
+
grid.set_field(0, 1, Newt::GRID_SUBGRID, subgrid, 0, 0, 0, 0, 0,
|
53
|
+
Newt::GRID_FLAG_GROWX)
|
54
|
+
grid.wrapped_window('Ê̤ÎÎã')
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
grid.wrapped_window("Ê̤ÎÎã")
|
56
|
+
f = Newt::Form.new
|
57
|
+
f.add(b1, t, b2)
|
58
|
+
f.run
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
#f.add(b1, b2)
|
63
|
-
answer = f.run()
|
60
|
+
Newt::Screen.pop_window
|
61
|
+
# f.destroy
|
64
62
|
|
65
|
-
|
66
|
-
|
63
|
+
Newt::Screen.win_message('¥·¥ó¥×¥ë', 'λ²ò', '¤³¤ì¤Ï¥·¥ó¥×¥ë¤Ê¥á¥Ã¥»¡¼¥¸¥¦¥£¥ó¥É¥¦¤Ç¤¹')
|
64
|
+
result = Newt::Screen.win_choice('¥·¥ó¥×¥ë', 'λ²ò', '¥¥ã¥ó¥»¥ë', '¤³¤ì¤Ï¥·¥ó¥×¥ë¤ÊÁªÂò¥¦¥£¥ó¥É¥¦¤Ç¤¹')
|
67
65
|
|
68
|
-
|
69
|
-
|
66
|
+
text_width = Newt::Screen.win_menu('¥Æ¥¹¥È¥á¥Ë¥å¡¼', '¤³¤ì¤Ï newtWinMenu() ¥³¡¼¥ë¤Î¥µ¥ó¥×¥ë' \
|
67
|
+
'¤Ç¤¹¡£ ¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤ÏɬÍפ˱þ¤¸¤Æ¤Ä¤¤¤¿¤ê¡¢ ' \
|
68
|
+
'¤Ä¤«¤Ê¤«¤Ã¤¿¤ê¤·¤Þ¤¹¡£',
|
69
|
+
50, 5, 5, 3, menu_contents, 'λ²ò', '¥¥ã¥ó¥»¥ë')
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
v = Newt::Screen.win_entries('¥Æ¥¥¹¥È newtWinEntries()', '¤³¤ì¤Ï newtWinEntries()' \
|
72
|
+
'¥³¡¼¥ë¤Î¥µ¥ó¥×¥ë¤Ç¤¹¡£¤¿¤¤¤Ø¤ó´Êñ¤Ë¤¿¤¯¤µ¤ó¤ÎÆþÎϤò' \
|
73
|
+
'°·¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£',
|
74
|
+
50, 5, 5, 20, auto_entries, 'λ²ò', '¥¥ã¥ó¥»¥ë')
|
75
75
|
|
76
|
-
|
77
|
-
"¥³¡¼¥ë¤Î¥µ¥ó¥×¥ë¤Ç¤¹¡£¤¿¤¤¤Ø¤ó´Êñ¤Ë¤¿¤¯¤µ¤ó¤ÎÆþÎϤò" +
|
78
|
-
"°·¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 50, 5, 5, 20, autoEntries, "λ²ò", "¥¥ã¥ó¥»¥ë")
|
76
|
+
Newt::Screen.finish
|
79
77
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
printf "item = %d\n", textWidth
|
84
|
-
p v
|
85
|
-
end
|
78
|
+
printf "item = %d\n", text_width
|
79
|
+
p v
|
80
|
+
p result
|