ffi-tk 2010.08.23 → 2018.02.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +371 -0
- data/AUTHORS +4 -2
- data/CHANGELOG +302 -262
- data/Gemfile +10 -0
- data/Gemfile.lock +45 -0
- data/MANIFEST +6 -6
- data/README.md +1 -1
- data/Rakefile +12 -11
- data/bin/rwish +6 -5
- data/example/choose_color.rb +5 -4
- data/example/choose_directory.rb +5 -4
- data/example/dialog.rb +9 -8
- data/example/hello.rb +2 -1
- data/example/message_box.rb +8 -5
- data/example/option_menu.rb +4 -3
- data/example/popup.rb +4 -3
- data/example/set_palette.rb +5 -4
- data/example/text.rb +30 -30
- data/example/tile/kroc_demo_small.rb +51 -55
- data/example/tile/kroc_rb_demo.rb +74 -83
- data/example/tile/notebook.rb +6 -9
- data/example/tile/theme_hello.rb +6 -8
- data/example/tile/themes.rb +4 -2
- data/example/tile/treeview.rb +16 -14
- data/example/tkgo.rb +120 -88
- data/example/various.rb +8 -7
- data/example/wait.rb +3 -2
- data/ffi-tk.gemspec +21 -20
- data/gemset.nix +134 -0
- data/lib/ffi-tk.rb +10 -11
- data/lib/ffi-tk/command.rb +3 -2
- data/lib/ffi-tk/command/after.rb +8 -7
- data/lib/ffi-tk/command/bell.rb +2 -1
- data/lib/ffi-tk/command/bind.rb +1 -0
- data/lib/ffi-tk/command/bindtags.rb +1 -0
- data/lib/ffi-tk/command/cget.rb +31 -24
- data/lib/ffi-tk/command/choose_color.rb +2 -1
- data/lib/ffi-tk/command/choose_directory.rb +2 -1
- data/lib/ffi-tk/command/clipboard.rb +6 -5
- data/lib/ffi-tk/command/configure.rb +23 -21
- data/lib/ffi-tk/command/destroy.rb +2 -1
- data/lib/ffi-tk/command/dialog.rb +4 -3
- data/lib/ffi-tk/command/event.rb +1 -0
- data/lib/ffi-tk/command/focus.rb +2 -1
- data/lib/ffi-tk/command/font.rb +12 -9
- data/lib/ffi-tk/command/get_open_file.rb +1 -0
- data/lib/ffi-tk/command/get_save_file.rb +1 -0
- data/lib/ffi-tk/command/grab.rb +2 -1
- data/lib/ffi-tk/command/grid.rb +7 -6
- data/lib/ffi-tk/command/image.rb +5 -4
- data/lib/ffi-tk/command/lower.rb +1 -0
- data/lib/ffi-tk/command/message_box.rb +2 -1
- data/lib/ffi-tk/command/option_menu.rb +3 -2
- data/lib/ffi-tk/command/pack.rb +5 -4
- data/lib/ffi-tk/command/place.rb +5 -4
- data/lib/ffi-tk/command/popup.rb +2 -1
- data/lib/ffi-tk/command/raise.rb +1 -0
- data/lib/ffi-tk/command/scrollable.rb +7 -10
- data/lib/ffi-tk/command/selection.rb +4 -3
- data/lib/ffi-tk/command/set_palette.rb +2 -1
- data/lib/ffi-tk/command/tk_cmd.rb +1 -0
- data/lib/ffi-tk/command/vars.rb +2 -1
- data/lib/ffi-tk/command/wait.rb +2 -1
- data/lib/ffi-tk/command/winfo.rb +9 -8
- data/lib/ffi-tk/command/wm.rb +11 -10
- data/lib/ffi-tk/core_extensions.rb +5 -4
- data/lib/ffi-tk/event/data.rb +32 -31
- data/lib/ffi-tk/event/handler.rb +4 -3
- data/lib/ffi-tk/ffi/tcl.rb +42 -31
- data/lib/ffi-tk/ffi/tcl/cmd_proc.rb +2 -1
- data/lib/ffi-tk/ffi/tcl/eval_result.rb +47 -8
- data/lib/ffi-tk/ffi/tcl/interp.rb +7 -4
- data/lib/ffi-tk/ffi/tcl/obj.rb +7 -32
- data/lib/ffi-tk/ffi/tcl/time.rb +2 -1
- data/lib/ffi-tk/ffi/tk.rb +8 -7
- data/lib/ffi-tk/geometry.rb +20 -17
- data/lib/ffi-tk/thread_sender.rb +1 -0
- data/lib/ffi-tk/tk.rb +23 -23
- data/lib/ffi-tk/variable.rb +25 -3
- data/lib/ffi-tk/version.rb +1 -1
- data/lib/ffi-tk/widget.rb +2 -1
- data/lib/ffi-tk/widget/button.rb +4 -1
- data/lib/ffi-tk/widget/canvas.rb +18 -15
- data/lib/ffi-tk/widget/canvas/arc.rb +2 -1
- data/lib/ffi-tk/widget/canvas/bitmap.rb +2 -1
- data/lib/ffi-tk/widget/canvas/image.rb +2 -1
- data/lib/ffi-tk/widget/canvas/item.rb +4 -4
- data/lib/ffi-tk/widget/canvas/line.rb +2 -1
- data/lib/ffi-tk/widget/canvas/oval.rb +2 -1
- data/lib/ffi-tk/widget/canvas/polygon.rb +2 -1
- data/lib/ffi-tk/widget/canvas/rectangle.rb +2 -1
- data/lib/ffi-tk/widget/canvas/text.rb +2 -1
- data/lib/ffi-tk/widget/canvas/window.rb +2 -1
- data/lib/ffi-tk/widget/checkbutton.rb +4 -1
- data/lib/ffi-tk/widget/entry.rb +4 -1
- data/lib/ffi-tk/widget/frame.rb +4 -1
- data/lib/ffi-tk/widget/label.rb +4 -1
- data/lib/ffi-tk/widget/labelframe.rb +4 -1
- data/lib/ffi-tk/widget/listbox.rb +5 -2
- data/lib/ffi-tk/widget/menu.rb +4 -1
- data/lib/ffi-tk/widget/menubutton.rb +4 -1
- data/lib/ffi-tk/widget/message.rb +4 -1
- data/lib/ffi-tk/widget/panedwindow.rb +5 -2
- data/lib/ffi-tk/widget/radiobutton.rb +4 -1
- data/lib/ffi-tk/widget/root.rb +1 -0
- data/lib/ffi-tk/widget/scale.rb +4 -1
- data/lib/ffi-tk/widget/scrollbar.rb +4 -1
- data/lib/ffi-tk/widget/spinbox.rb +4 -1
- data/lib/ffi-tk/widget/text.rb +20 -16
- data/lib/ffi-tk/widget/text/peer.rb +1 -0
- data/lib/ffi-tk/widget/tile.rb +2 -1
- data/lib/ffi-tk/widget/tile/button.rb +4 -1
- data/lib/ffi-tk/widget/tile/checkbutton.rb +4 -1
- data/lib/ffi-tk/widget/tile/combobox.rb +5 -2
- data/lib/ffi-tk/widget/tile/entry.rb +4 -1
- data/lib/ffi-tk/widget/tile/frame.rb +4 -1
- data/lib/ffi-tk/widget/tile/label.rb +4 -2
- data/lib/ffi-tk/widget/tile/labelframe.rb +4 -1
- data/lib/ffi-tk/widget/tile/menubutton.rb +4 -1
- data/lib/ffi-tk/widget/tile/notebook.rb +4 -1
- data/lib/ffi-tk/widget/tile/panedwindow.rb +4 -1
- data/lib/ffi-tk/widget/tile/progressbar.rb +4 -2
- data/lib/ffi-tk/widget/tile/radiobutton.rb +4 -1
- data/lib/ffi-tk/widget/tile/scale.rb +4 -1
- data/lib/ffi-tk/widget/tile/scrollbar.rb +7 -4
- data/lib/ffi-tk/widget/tile/separator.rb +4 -1
- data/lib/ffi-tk/widget/tile/sizegrip.rb +4 -1
- data/lib/ffi-tk/widget/tile/style.rb +16 -17
- data/lib/ffi-tk/widget/tile/treeview.rb +11 -5
- data/lib/ffi-tk/widget/toplevel.rb +4 -1
- data/shell.nix +19 -0
- data/spec/ffi-tk/command/bind.rb +5 -4
- data/spec/ffi-tk/command/bindtags.rb +2 -1
- data/spec/ffi-tk/command/clipboard.rb +4 -3
- data/spec/ffi-tk/command/font.rb +20 -19
- data/spec/ffi-tk/command/image.rb +13 -5
- data/spec/ffi-tk/command/pack.rb +3 -2
- data/spec/ffi-tk/command/place.rb +4 -3
- data/spec/ffi-tk/command/selection.rb +2 -1
- data/spec/ffi-tk/command/vars.rb +3 -2
- data/spec/ffi-tk/command/winfo.rb +10 -10
- data/spec/ffi-tk/command/wm.rb +23 -22
- data/spec/ffi-tk/event.rb +23 -21
- data/spec/ffi-tk/tile/button.rb +8 -8
- data/spec/ffi-tk/tile/checkbutton.rb +1 -1
- data/spec/ffi-tk/tile/combobox.rb +11 -12
- data/spec/ffi-tk/tile/entry.rb +18 -19
- data/spec/ffi-tk/tile/frame.rb +13 -13
- data/spec/ffi-tk/tile/label.rb +2 -2
- data/spec/ffi-tk/tile/labelframe.rb +1 -1
- data/spec/ffi-tk/tile/menubutton.rb +1 -1
- data/spec/ffi-tk/tile/notebook.rb +22 -20
- data/spec/ffi-tk/tile/panedwindow.rb +1 -1
- data/spec/ffi-tk/tile/progressbar.rb +1 -1
- data/spec/ffi-tk/tile/radiobutton.rb +1 -1
- data/spec/ffi-tk/tile/scale.rb +1 -1
- data/spec/ffi-tk/tile/scrollbar.rb +1 -16
- data/spec/ffi-tk/tile/separator.rb +2 -2
- data/spec/ffi-tk/tile/sizegrip.rb +1 -1
- data/spec/ffi-tk/tile/style.rb +63 -65
- data/spec/ffi-tk/tile/treeview.rb +11 -10
- data/spec/ffi-tk/variable.rb +5 -4
- data/spec/ffi-tk/widget/button.rb +3 -2
- data/spec/ffi-tk/widget/canvas.rb +59 -58
- data/spec/ffi-tk/widget/checkbutton.rb +6 -5
- data/spec/ffi-tk/widget/entry.rb +112 -103
- data/spec/ffi-tk/widget/frame.rb +2 -1
- data/spec/ffi-tk/widget/label.rb +2 -1
- data/spec/ffi-tk/widget/labelframe.rb +1 -0
- data/spec/ffi-tk/widget/listbox.rb +5 -4
- data/spec/ffi-tk/widget/menu.rb +3 -2
- data/spec/ffi-tk/widget/menubutton.rb +1 -0
- data/spec/ffi-tk/widget/message.rb +1 -0
- data/spec/ffi-tk/widget/panedwindow.rb +1 -0
- data/spec/ffi-tk/widget/radiobutton.rb +1 -0
- data/spec/ffi-tk/widget/root.rb +2 -1
- data/spec/ffi-tk/widget/scale.rb +1 -0
- data/spec/ffi-tk/widget/scrollbar.rb +1 -0
- data/spec/ffi-tk/widget/spinbox.rb +1 -0
- data/spec/ffi-tk/widget/text.rb +63 -54
- data/spec/ffi-tk/widget/toplevel.rb +1 -0
- data/spec/helper.rb +3 -1
- data/tasks/authors.rake +3 -2
- data/tasks/bacon.rake +13 -11
- data/tasks/changelog.rake +1 -0
- data/tasks/gem.rake +13 -11
- data/tasks/manifest.rake +2 -1
- data/tasks/release.rake +11 -32
- data/tasks/reversion.rake +2 -1
- metadata +52 -75
- data/spec/ffi-tk/command/grid.rb +0 -6
- data/tasks/gem_setup.rake +0 -113
- data/tasks/grancher.rake +0 -12
- data/tasks/rcov.rake +0 -17
- data/tasks/setup.rake +0 -12
- data/tasks/ycov.rake +0 -84
data/example/tile/themes.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'ffi-tk'
|
2
3
|
|
3
4
|
Tk::Tile::Style.theme_names.each do |name|
|
4
5
|
button = Tk::Tile::Button.new(
|
5
6
|
text: name,
|
6
|
-
command: ->{ Tk::Tile.set_theme(name) }
|
7
|
+
command: -> { Tk::Tile.set_theme(name) }
|
8
|
+
)
|
7
9
|
button.pack side: :top, anchor: :nw
|
8
10
|
end
|
9
11
|
|
10
|
-
button = Tk::Tile::Button.new(text: 'Exit', command: ->{ Tk.exit })
|
12
|
+
button = Tk::Tile::Button.new(text: 'Exit', command: -> { Tk.exit })
|
11
13
|
button.pack side: :top, anchor: :nw
|
12
14
|
|
13
15
|
Tk.mainloop
|
data/example/tile/treeview.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'ffi-tk'
|
2
3
|
require 'find'
|
3
4
|
|
@@ -8,11 +9,11 @@ class FileTree < Tk::Tile::Treeview
|
|
8
9
|
|
9
10
|
def populate_roots
|
10
11
|
## Create the tree and set it up
|
11
|
-
configure columns: %w
|
12
|
+
configure columns: %w(fullpath type size), displaycolumns: %w(size)
|
12
13
|
heading('#0', text: 'Directory Structure')
|
13
14
|
heading('size', text: 'File Size')
|
14
15
|
column('size', stretch: 0, width: 70)
|
15
|
-
bind('<<TreeviewOpen>>')
|
16
|
+
bind('<<TreeviewOpen>>') do |_event|
|
16
17
|
begin
|
17
18
|
populate_tree(focus_item)
|
18
19
|
rescue Exception => ex
|
@@ -20,7 +21,7 @@ class FileTree < Tk::Tile::Treeview
|
|
20
21
|
end
|
21
22
|
|
22
23
|
true
|
23
|
-
|
24
|
+
end
|
24
25
|
|
25
26
|
Tk.execute('file', 'volumes').sort.each do |volume|
|
26
27
|
node = insert(nil, :end, text: volume, values: [volume, 'directory'])
|
@@ -35,7 +36,8 @@ class FileTree < Tk::Tile::Treeview
|
|
35
36
|
delete(*node.children.to_a)
|
36
37
|
|
37
38
|
Dir.glob File.join(path, '*') do |path|
|
38
|
-
name
|
39
|
+
name = File.basename(path)
|
40
|
+
type = File.ftype(path)
|
39
41
|
|
40
42
|
item = insert(node, :end, text: name, values: [path, type])
|
41
43
|
|
@@ -46,15 +48,15 @@ class FileTree < Tk::Tile::Treeview
|
|
46
48
|
elsif type == 'file'
|
47
49
|
size = File.size(path)
|
48
50
|
|
49
|
-
if size >= GB
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
size = if size >= GB
|
52
|
+
'%.1f GB' % [size / GB]
|
53
|
+
elsif size >= MB
|
54
|
+
'%.1f MB' % [size / MB]
|
55
|
+
elsif size >= KB
|
56
|
+
'%.1f KB' % [size / KB]
|
57
|
+
else
|
58
|
+
'%.1f bytes' % [size]
|
59
|
+
end
|
58
60
|
|
59
61
|
item.set(:size, size)
|
60
62
|
end
|
@@ -63,7 +65,7 @@ class FileTree < Tk::Tile::Treeview
|
|
63
65
|
end
|
64
66
|
|
65
67
|
tree = FileTree.new
|
66
|
-
tree.bind('<Escape>'){ Tk.exit }
|
68
|
+
tree.bind('<Escape>') { Tk.exit }
|
67
69
|
tree.pack expand: true, fill: :both
|
68
70
|
tree.focus
|
69
71
|
tree.populate_roots
|
data/example/tkgo.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Copyright (c) 2009 Michael Fellinger <m.fellinger@gmail.com>
|
2
3
|
#
|
3
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -42,7 +43,9 @@ class TkGo
|
|
42
43
|
cmd = "gnugo --mode gtp #{options.join(' ')}"
|
43
44
|
|
44
45
|
Open3.popen3 cmd do |sin, sout, serr|
|
45
|
-
@sin
|
46
|
+
@sin = sin
|
47
|
+
@sout = sout
|
48
|
+
@serr = serr
|
46
49
|
setup_widgets
|
47
50
|
Tk.mainloop
|
48
51
|
end
|
@@ -52,17 +55,17 @@ class TkGo
|
|
52
55
|
Tk::Tile.set_theme 'clam'
|
53
56
|
|
54
57
|
@frame = Tk::Tile::Frame.new
|
55
|
-
@passb = Tk::Tile::Button.new(frame, text: 'Pass'){ clicked_field('pass') }
|
56
|
-
@scoreb = Tk::Tile::Button.new(frame, text: 'Score'){ score }
|
57
|
-
@undob = Tk::Tile::Button.new(frame, text: 'Undo')
|
58
|
-
2.times
|
59
|
-
sin.puts(
|
58
|
+
@passb = Tk::Tile::Button.new(frame, text: 'Pass') { clicked_field('pass') }
|
59
|
+
@scoreb = Tk::Tile::Button.new(frame, text: 'Score') { score }
|
60
|
+
@undob = Tk::Tile::Button.new(frame, text: 'Undo') do
|
61
|
+
2.times do
|
62
|
+
sin.puts('undo')
|
60
63
|
read_pipe
|
61
|
-
|
64
|
+
end
|
62
65
|
@white_history.pop
|
63
66
|
@black_history.pop
|
64
67
|
draw_pieces
|
65
|
-
|
68
|
+
end
|
66
69
|
@status = Tk::Tile::Label.new
|
67
70
|
passb.pack(padx: 5, pady: 5, side: :left)
|
68
71
|
scoreb.pack(padx: 5, pady: 5, side: :left)
|
@@ -70,17 +73,18 @@ class TkGo
|
|
70
73
|
status.pack(side: :bottom, expand: true, fill: :both)
|
71
74
|
|
72
75
|
Tk.root.wm_title = 'GO considered'
|
73
|
-
Tk.root.bind('<Destroy>')
|
74
|
-
sin.puts(
|
76
|
+
Tk.root.bind('<Destroy>') do
|
77
|
+
sin.puts('exit')
|
75
78
|
exit
|
76
|
-
|
79
|
+
end
|
77
80
|
|
78
81
|
gobansize = linedist * (boardsize + 1)
|
79
82
|
@goban = Tk::Canvas.new(
|
80
83
|
Tk.root,
|
81
84
|
height: gobansize,
|
82
85
|
width: gobansize,
|
83
|
-
background: '#eebb77'
|
86
|
+
background: '#eebb77'
|
87
|
+
)
|
84
88
|
goban.pack(expand: true)
|
85
89
|
frame.pack(expand: true)
|
86
90
|
draw_board(goban)
|
@@ -88,7 +92,7 @@ class TkGo
|
|
88
92
|
|
89
93
|
# NOTE: there is no I
|
90
94
|
def x_to_letter(x)
|
91
|
-
%w
|
95
|
+
%w(A B C D E F G H J K L M N O P Q R S T)[x]
|
92
96
|
end
|
93
97
|
|
94
98
|
def read_pipe
|
@@ -98,18 +102,18 @@ class TkGo
|
|
98
102
|
end
|
99
103
|
|
100
104
|
def draw_pieces
|
101
|
-
sin.puts(
|
105
|
+
sin.puts('list_stones black')
|
102
106
|
blacks = read_pipe
|
103
107
|
blacks.shift
|
104
108
|
|
105
|
-
sin.puts(
|
109
|
+
sin.puts('list_stones white')
|
106
110
|
whites = read_pipe
|
107
111
|
whites.shift
|
108
112
|
|
109
113
|
goban.delete(:piece, :marker)
|
110
114
|
|
111
|
-
blacks.each{|name| draw_piece(name, :black) }
|
112
|
-
whites.each{|name| draw_piece(name, :white) }
|
115
|
+
blacks.each { |name| draw_piece(name, :black) }
|
116
|
+
whites.each { |name| draw_piece(name, :white) }
|
113
117
|
|
114
118
|
draw_markers(blacks.any?, whites.any?)
|
115
119
|
end
|
@@ -123,10 +127,10 @@ class TkGo
|
|
123
127
|
end
|
124
128
|
|
125
129
|
def draw_markers(blacks, whites)
|
126
|
-
last_white = @white_history.reject{|name| name =~ /pass/i }.last
|
130
|
+
last_white = @white_history.reject { |name| name =~ /pass/i }.last
|
127
131
|
draw_marker(last_white, :black) if whites && last_white
|
128
132
|
|
129
|
-
last_black = @black_history.reject{|name| name =~ /pass/i }.last
|
133
|
+
last_black = @black_history.reject { |name| name =~ /pass/i }.last
|
130
134
|
draw_marker(last_black, :white) if blacks && last_black
|
131
135
|
end
|
132
136
|
|
@@ -145,7 +149,7 @@ class TkGo
|
|
145
149
|
|
146
150
|
return if reply[0] == '?'
|
147
151
|
|
148
|
-
sin.puts(
|
152
|
+
sin.puts('genmove white')
|
149
153
|
pos = read_pipe.last
|
150
154
|
@white_history << pos
|
151
155
|
status.value = "White: #{pos}"
|
@@ -157,7 +161,7 @@ class TkGo
|
|
157
161
|
end
|
158
162
|
|
159
163
|
def score
|
160
|
-
sin.puts(
|
164
|
+
sin.puts('final_score')
|
161
165
|
reply = read_pipe.last
|
162
166
|
status.value = reply
|
163
167
|
end
|
@@ -182,8 +186,9 @@ class TkGo
|
|
182
186
|
# color = '#' << Array.new(3){ rand(255).to_s(16).rjust(2, '0') }.join
|
183
187
|
color = nil
|
184
188
|
board.create_rectangle(
|
185
|
-
x1, y1, x2, y2, tags: [fieldname], outline: nil, fill: color
|
186
|
-
|
189
|
+
x1, y1, x2, y2, tags: [fieldname], outline: nil, fill: color
|
190
|
+
)
|
191
|
+
board.bind(fieldname, '<1>') { clicked_field(fieldname) }
|
187
192
|
end
|
188
193
|
end
|
189
194
|
end
|
@@ -191,78 +196,105 @@ end
|
|
191
196
|
|
192
197
|
options = []
|
193
198
|
|
194
|
-
op = OptionParser.new
|
199
|
+
op = OptionParser.new do |o|
|
195
200
|
o.separator "\nMain Options:"
|
196
|
-
o.on('--level <amount>', Integer, 'strength (default 10)')
|
197
|
-
options << '--level' << amount
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
o.on('-
|
203
|
-
options << '--
|
204
|
-
|
205
|
-
|
206
|
-
options << '--
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
201
|
+
o.on('--level <amount>', Integer, 'strength (default 10)') do |amount|
|
202
|
+
options << '--level' << amount
|
203
|
+
end
|
204
|
+
o.on('--never-resign', 'Forbid GNU Go to resign') do
|
205
|
+
options << '--never-resign'
|
206
|
+
end
|
207
|
+
o.on('--resign-allowed', 'Allow resignation (default)') do
|
208
|
+
options << '--resign-allowed'
|
209
|
+
end
|
210
|
+
o.on('-l', '--infile <file>', 'Load name sgf file') do |file|
|
211
|
+
options << '--infile' << file
|
212
|
+
end
|
213
|
+
o.on('-L', '--until <move>', 'Stop loading just before move is played. <move>
|
214
|
+
can be the move number or location (eg L10).') do |move|
|
215
|
+
options << '--until' << move
|
216
|
+
end
|
217
|
+
o.on('-o', '--outfile <file>', 'Write sgf output to file') do |file|
|
218
|
+
options << '--outfile' << file
|
219
|
+
end
|
220
|
+
o.on('--printsgf <file>', 'Write position as a diagram to file (use with -l)') do |file|
|
221
|
+
options << '--printsgf' << file
|
222
|
+
end
|
211
223
|
|
212
224
|
o.separator "\nGame Options:"
|
213
|
-
o.on('--boardsize <num>', Integer, 'Set the board size to use (1--19)')
|
214
|
-
options << '--boardsize' << num
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
o.on('--
|
220
|
-
options << '--
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
o.on('--
|
226
|
-
options << '--
|
227
|
-
|
228
|
-
o.on('--
|
229
|
-
options << '
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
o.on('--allow-suicide', 'Allow suicide except single-stone suicide.'){
|
235
|
-
options << '--allow-suicide' }
|
236
|
-
o.on('--allow-all-suicide', 'Allow all suicide moves.'){
|
237
|
-
options << '--allow-all-suicide' }
|
238
|
-
o.on('--simple-ko', 'Forbid simple ko recapture. (default)'){
|
239
|
-
options << '--simple-ko' }
|
240
|
-
o.on('--no-ko', 'Allow any ko recapture.'){
|
241
|
-
options << '--no-ko' }
|
242
|
-
o.on('--positional-superko', 'Positional superko restrictions.'){
|
243
|
-
options << '--positional-superko' }
|
244
|
-
o.on('--situational-superko', 'Situational superko restrictions.'){
|
245
|
-
options << '--situational-superko' }
|
246
|
-
|
247
|
-
o.on('--play-out-aftermath'){
|
248
|
-
options << '--play-out-aftermath' }
|
249
|
-
o.on('--capture-all-dead'){
|
250
|
-
options << '--capture-all-dead' }
|
251
|
-
|
252
|
-
o.on('--min-level <amount>', 'minimum level for adjustment schemes'){|amount|
|
253
|
-
options << '--min-level' << amount }
|
254
|
-
o.on('--max-level <amount>', 'maximum level for adjustment schemes'){|amount|
|
255
|
-
options << '--max-level' << amount }
|
256
|
-
o.on('--autolevel', 'adapt gnugo level during game to respect
|
257
|
-
the time specified by --clock <sec>.'){
|
258
|
-
options << '--autolevel' }
|
225
|
+
o.on('--boardsize <num>', Integer, 'Set the board size to use (1--19)') do |num|
|
226
|
+
options << '--boardsize' << num
|
227
|
+
end
|
228
|
+
o.on('--color <color>', "Choose your color ('black' or 'white')") do |color|
|
229
|
+
options << '--color' << color
|
230
|
+
end
|
231
|
+
o.on('--handicap <num>', Integer, 'Set the number of handicap stones (0--9)') do |num|
|
232
|
+
options << '--handicap' << num
|
233
|
+
end
|
234
|
+
o.on('--komi <num>', Integer, 'Set the komi') do |num|
|
235
|
+
options << '--komi' << num
|
236
|
+
end
|
237
|
+
o.on('--clock <sec>', 'Initialize the timer.') do |sec|
|
238
|
+
options << '--clock' << sec
|
239
|
+
end
|
240
|
+
o.on('--byo-time <sec>', 'Initialize the byo-yomi timer.') do |sec|
|
241
|
+
options << '--byo-time' << sec
|
242
|
+
end
|
243
|
+
o.on('--byo-period <stones>', 'Initialize the byo-yomi period.') do |stones|
|
244
|
+
options << '--byo-period' << stones
|
245
|
+
end
|
259
246
|
|
247
|
+
o.on('--japanese-rules', '(default)') do
|
248
|
+
options << '---japanese-rules'
|
249
|
+
end
|
250
|
+
o.on('--chinese-rules') do
|
251
|
+
options << '--chinese-rules'
|
252
|
+
end
|
253
|
+
o.on('--forbid-suicide', 'Forbid suicide. (default)') do
|
254
|
+
options << '--forbid-suicide'
|
255
|
+
end
|
256
|
+
o.on('--allow-suicide', 'Allow suicide except single-stone suicide.') do
|
257
|
+
options << '--allow-suicide'
|
258
|
+
end
|
259
|
+
o.on('--allow-all-suicide', 'Allow all suicide moves.') do
|
260
|
+
options << '--allow-all-suicide'
|
261
|
+
end
|
262
|
+
o.on('--simple-ko', 'Forbid simple ko recapture. (default)') do
|
263
|
+
options << '--simple-ko'
|
264
|
+
end
|
265
|
+
o.on('--no-ko', 'Allow any ko recapture.') do
|
266
|
+
options << '--no-ko'
|
267
|
+
end
|
268
|
+
o.on('--positional-superko', 'Positional superko restrictions.') do
|
269
|
+
options << '--positional-superko'
|
270
|
+
end
|
271
|
+
o.on('--situational-superko', 'Situational superko restrictions.') do
|
272
|
+
options << '--situational-superko'
|
273
|
+
end
|
260
274
|
|
261
|
-
o.on('-
|
275
|
+
o.on('--play-out-aftermath') do
|
276
|
+
options << '--play-out-aftermath'
|
277
|
+
end
|
278
|
+
o.on('--capture-all-dead') do
|
279
|
+
options << '--capture-all-dead'
|
280
|
+
end
|
281
|
+
|
282
|
+
o.on('--min-level <amount>', 'minimum level for adjustment schemes') do |amount|
|
283
|
+
options << '--min-level' << amount
|
284
|
+
end
|
285
|
+
o.on('--max-level <amount>', 'maximum level for adjustment schemes') do |amount|
|
286
|
+
options << '--max-level' << amount
|
287
|
+
end
|
288
|
+
o.on('--autolevel', 'adapt gnugo level during game to respect
|
289
|
+
the time specified by --clock <sec>.') do
|
290
|
+
options << '--autolevel'
|
291
|
+
end
|
292
|
+
|
293
|
+
o.on('-h', '--help') do
|
262
294
|
puts o
|
263
295
|
exit
|
264
|
-
|
265
|
-
|
296
|
+
end
|
297
|
+
end
|
266
298
|
|
267
299
|
op.parse!
|
268
300
|
|
data/example/various.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative '../lib/ffi-tk'
|
4
5
|
|
5
6
|
Tk.init
|
6
7
|
|
7
|
-
Tk.root.bind('Control-c'){|event| p event }
|
8
|
-
Tk.root.bind('Control-q'){|
|
8
|
+
Tk.root.bind('Control-c') { |event| p event }
|
9
|
+
Tk.root.bind('Control-q') { |_event| exit }
|
9
10
|
|
10
|
-
hello = Tk::Button.new('.', text: 'Push me')
|
11
|
-
Tk
|
12
|
-
|
11
|
+
hello = Tk::Button.new('.', text: 'Push me') do
|
12
|
+
Tk.message_box(message: 'Hello, World!')
|
13
|
+
end.pack
|
13
14
|
|
14
15
|
button = Tk::Button.new('.', text: 'Destroy me!').pack
|
15
|
-
button.bind('Enter'){|
|
16
|
+
button.bind('Enter') { |_event| button.destroy }
|
16
17
|
|
17
18
|
text = Tk::Text.new('.')
|
18
19
|
text.insert 'insert', 'Hello, World!'
|
@@ -22,4 +23,4 @@ entry = Tk::Entry.new('.')
|
|
22
23
|
entry.insert 'end', 'Hello, World!'
|
23
24
|
entry.pack fill: :x
|
24
25
|
|
25
|
-
Tk.mainloop
|
26
|
+
Tk.mainloop
|
data/example/wait.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'ffi-tk'
|
2
3
|
|
3
4
|
Tk.init
|
@@ -6,11 +7,11 @@ variable = Tk::Variable.new('showstopper', false)
|
|
6
7
|
label = Tk::Label.new(Tk.root, text: 'enter anything to reflect it here').pack
|
7
8
|
|
8
9
|
entry = Tk::Entry.new(Tk.root, textvariable: variable).pack
|
9
|
-
button = Tk::Button.new(Tk.root, text: 'Exit'){ exit }.pack
|
10
|
+
button = Tk::Button.new(Tk.root, text: 'Exit') { exit }.pack
|
10
11
|
|
11
12
|
loop do
|
12
13
|
Tk::Wait.variable(variable)
|
13
14
|
label.configure text: variable.to_s
|
14
15
|
end
|
15
16
|
|
16
|
-
Tk.mainloop
|
17
|
+
Tk.mainloop
|
data/ffi-tk.gemspec
CHANGED
@@ -1,33 +1,34 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: ffi-tk 2018.02.20 ruby lib
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "
|
5
|
+
s.name = "ffi-tk".freeze
|
6
|
+
s.version = "2018.02.20"
|
6
7
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.3") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.3".freeze) if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib".freeze]
|
10
|
+
s.authors = ["Michael 'manveru' Fellinger".freeze]
|
11
|
+
s.date = "2018-02-20"
|
12
|
+
s.description = "Comfortably talk with Tcl/Tk using FFI.".freeze
|
13
|
+
s.email = "m.fellinger@gmail.com".freeze
|
14
|
+
s.files = [".gitignore".freeze, ".rubocop.yml".freeze, ".rubocop_todo.yml".freeze, "AUTHORS".freeze, "CHANGELOG".freeze, "Gemfile".freeze, "Gemfile.lock".freeze, "MANIFEST".freeze, "README.md".freeze, "Rakefile".freeze, "TODO.md".freeze, "bin/rwish".freeze, "doc/MIT_LICENSE".freeze, "doc/TCL_LICENSE".freeze, "example/choose_color.rb".freeze, "example/choose_directory.rb".freeze, "example/dialog.rb".freeze, "example/hello.rb".freeze, "example/message_box.rb".freeze, "example/option_menu.rb".freeze, "example/popup.rb".freeze, "example/set_palette.rb".freeze, "example/text.rb".freeze, "example/tile/kroc_demo_small.rb".freeze, "example/tile/kroc_rb_demo.rb".freeze, "example/tile/notebook.rb".freeze, "example/tile/theme_hello.rb".freeze, "example/tile/themes.rb".freeze, "example/tile/treeview.rb".freeze, "example/tkgo.rb".freeze, "example/various.rb".freeze, "example/wait.rb".freeze, "ffi-tk.gemspec".freeze, "gemset.nix".freeze, "lib/ffi-tk.rb".freeze, "lib/ffi-tk/command.rb".freeze, "lib/ffi-tk/command/after.rb".freeze, "lib/ffi-tk/command/bell.rb".freeze, "lib/ffi-tk/command/bind.rb".freeze, "lib/ffi-tk/command/bindtags.rb".freeze, "lib/ffi-tk/command/cget.rb".freeze, "lib/ffi-tk/command/choose_color.rb".freeze, "lib/ffi-tk/command/choose_directory.rb".freeze, "lib/ffi-tk/command/clipboard.rb".freeze, "lib/ffi-tk/command/configure.rb".freeze, "lib/ffi-tk/command/destroy.rb".freeze, "lib/ffi-tk/command/dialog.rb".freeze, "lib/ffi-tk/command/event.rb".freeze, "lib/ffi-tk/command/focus.rb".freeze, "lib/ffi-tk/command/font.rb".freeze, "lib/ffi-tk/command/get_open_file.rb".freeze, "lib/ffi-tk/command/get_save_file.rb".freeze, "lib/ffi-tk/command/grab.rb".freeze, "lib/ffi-tk/command/grid.rb".freeze, "lib/ffi-tk/command/image.rb".freeze, "lib/ffi-tk/command/lower.rb".freeze, "lib/ffi-tk/command/message_box.rb".freeze, "lib/ffi-tk/command/option_menu.rb".freeze, "lib/ffi-tk/command/pack.rb".freeze, "lib/ffi-tk/command/place.rb".freeze, "lib/ffi-tk/command/popup.rb".freeze, "lib/ffi-tk/command/raise.rb".freeze, "lib/ffi-tk/command/scrollable.rb".freeze, "lib/ffi-tk/command/selection.rb".freeze, "lib/ffi-tk/command/set_palette.rb".freeze, "lib/ffi-tk/command/tk_cmd.rb".freeze, "lib/ffi-tk/command/vars.rb".freeze, "lib/ffi-tk/command/wait.rb".freeze, "lib/ffi-tk/command/winfo.rb".freeze, "lib/ffi-tk/command/wm.rb".freeze, "lib/ffi-tk/core_extensions.rb".freeze, "lib/ffi-tk/event/data.rb".freeze, "lib/ffi-tk/event/handler.rb".freeze, "lib/ffi-tk/ffi/tcl.rb".freeze, "lib/ffi-tk/ffi/tcl/cmd_proc.rb".freeze, "lib/ffi-tk/ffi/tcl/eval_result.rb".freeze, "lib/ffi-tk/ffi/tcl/interp.rb".freeze, "lib/ffi-tk/ffi/tcl/obj.rb".freeze, "lib/ffi-tk/ffi/tcl/time.rb".freeze, "lib/ffi-tk/ffi/tk.rb".freeze, "lib/ffi-tk/geometry.rb".freeze, "lib/ffi-tk/thread_sender.rb".freeze, "lib/ffi-tk/tk.rb".freeze, "lib/ffi-tk/variable.rb".freeze, "lib/ffi-tk/version.rb".freeze, "lib/ffi-tk/widget.rb".freeze, "lib/ffi-tk/widget/button.rb".freeze, "lib/ffi-tk/widget/canvas.rb".freeze, "lib/ffi-tk/widget/canvas/arc.rb".freeze, "lib/ffi-tk/widget/canvas/bitmap.rb".freeze, "lib/ffi-tk/widget/canvas/image.rb".freeze, "lib/ffi-tk/widget/canvas/item.rb".freeze, "lib/ffi-tk/widget/canvas/line.rb".freeze, "lib/ffi-tk/widget/canvas/oval.rb".freeze, "lib/ffi-tk/widget/canvas/polygon.rb".freeze, "lib/ffi-tk/widget/canvas/rectangle.rb".freeze, "lib/ffi-tk/widget/canvas/text.rb".freeze, "lib/ffi-tk/widget/canvas/window.rb".freeze, "lib/ffi-tk/widget/checkbutton.rb".freeze, "lib/ffi-tk/widget/entry.rb".freeze, "lib/ffi-tk/widget/frame.rb".freeze, "lib/ffi-tk/widget/label.rb".freeze, "lib/ffi-tk/widget/labelframe.rb".freeze, "lib/ffi-tk/widget/listbox.rb".freeze, "lib/ffi-tk/widget/menu.rb".freeze, "lib/ffi-tk/widget/menubutton.rb".freeze, "lib/ffi-tk/widget/message.rb".freeze, "lib/ffi-tk/widget/panedwindow.rb".freeze, "lib/ffi-tk/widget/radiobutton.rb".freeze, "lib/ffi-tk/widget/root.rb".freeze, "lib/ffi-tk/widget/scale.rb".freeze, "lib/ffi-tk/widget/scrollbar.rb".freeze, "lib/ffi-tk/widget/spinbox.rb".freeze, "lib/ffi-tk/widget/text.rb".freeze, "lib/ffi-tk/widget/text/peer.rb".freeze, "lib/ffi-tk/widget/tile.rb".freeze, "lib/ffi-tk/widget/tile/button.rb".freeze, "lib/ffi-tk/widget/tile/checkbutton.rb".freeze, "lib/ffi-tk/widget/tile/combobox.rb".freeze, "lib/ffi-tk/widget/tile/entry.rb".freeze, "lib/ffi-tk/widget/tile/frame.rb".freeze, "lib/ffi-tk/widget/tile/label.rb".freeze, "lib/ffi-tk/widget/tile/labelframe.rb".freeze, "lib/ffi-tk/widget/tile/menubutton.rb".freeze, "lib/ffi-tk/widget/tile/notebook.rb".freeze, "lib/ffi-tk/widget/tile/panedwindow.rb".freeze, "lib/ffi-tk/widget/tile/progressbar.rb".freeze, "lib/ffi-tk/widget/tile/radiobutton.rb".freeze, "lib/ffi-tk/widget/tile/scale.rb".freeze, "lib/ffi-tk/widget/tile/scrollbar.rb".freeze, "lib/ffi-tk/widget/tile/separator.rb".freeze, "lib/ffi-tk/widget/tile/sizegrip.rb".freeze, "lib/ffi-tk/widget/tile/style.rb".freeze, "lib/ffi-tk/widget/tile/treeview.rb".freeze, "lib/ffi-tk/widget/toplevel.rb".freeze, "shell.nix".freeze, "spec/ffi-tk/command/bind.rb".freeze, "spec/ffi-tk/command/bindtags.rb".freeze, "spec/ffi-tk/command/clipboard.rb".freeze, "spec/ffi-tk/command/font.rb".freeze, "spec/ffi-tk/command/image.rb".freeze, "spec/ffi-tk/command/pack.rb".freeze, "spec/ffi-tk/command/place.rb".freeze, "spec/ffi-tk/command/selection.rb".freeze, "spec/ffi-tk/command/vars.rb".freeze, "spec/ffi-tk/command/winfo.rb".freeze, "spec/ffi-tk/command/wm.rb".freeze, "spec/ffi-tk/event.rb".freeze, "spec/ffi-tk/tile/button.rb".freeze, "spec/ffi-tk/tile/checkbutton.rb".freeze, "spec/ffi-tk/tile/combobox.rb".freeze, "spec/ffi-tk/tile/entry.rb".freeze, "spec/ffi-tk/tile/frame.rb".freeze, "spec/ffi-tk/tile/label.rb".freeze, "spec/ffi-tk/tile/labelframe.rb".freeze, "spec/ffi-tk/tile/menubutton.rb".freeze, "spec/ffi-tk/tile/notebook.rb".freeze, "spec/ffi-tk/tile/panedwindow.rb".freeze, "spec/ffi-tk/tile/progressbar.rb".freeze, "spec/ffi-tk/tile/radiobutton.rb".freeze, "spec/ffi-tk/tile/scale.rb".freeze, "spec/ffi-tk/tile/scrollbar.rb".freeze, "spec/ffi-tk/tile/separator.rb".freeze, "spec/ffi-tk/tile/sizegrip.rb".freeze, "spec/ffi-tk/tile/style.rb".freeze, "spec/ffi-tk/tile/treeview.rb".freeze, "spec/ffi-tk/variable.rb".freeze, "spec/ffi-tk/widget/button.rb".freeze, "spec/ffi-tk/widget/canvas.rb".freeze, "spec/ffi-tk/widget/checkbutton.rb".freeze, "spec/ffi-tk/widget/entry.rb".freeze, "spec/ffi-tk/widget/frame.rb".freeze, "spec/ffi-tk/widget/label.rb".freeze, "spec/ffi-tk/widget/labelframe.rb".freeze, "spec/ffi-tk/widget/listbox.rb".freeze, "spec/ffi-tk/widget/menu.rb".freeze, "spec/ffi-tk/widget/menubutton.rb".freeze, "spec/ffi-tk/widget/message.rb".freeze, "spec/ffi-tk/widget/panedwindow.rb".freeze, "spec/ffi-tk/widget/radiobutton.rb".freeze, "spec/ffi-tk/widget/root.rb".freeze, "spec/ffi-tk/widget/scale.rb".freeze, "spec/ffi-tk/widget/scrollbar.rb".freeze, "spec/ffi-tk/widget/spinbox.rb".freeze, "spec/ffi-tk/widget/text.rb".freeze, "spec/ffi-tk/widget/toplevel.rb".freeze, "spec/helper.rb".freeze, "tasks/authors.rake".freeze, "tasks/bacon.rake".freeze, "tasks/changelog.rake".freeze, "tasks/gem.rake".freeze, "tasks/manifest.rake".freeze, "tasks/release.rake".freeze, "tasks/reversion.rake".freeze]
|
15
|
+
s.homepage = "http://github.com/manveru/ffi-tk".freeze
|
16
|
+
s.licenses = ["MIT".freeze]
|
17
|
+
s.rubygems_version = "2.6.13".freeze
|
18
|
+
s.summary = "Pure Ruby FFI wrapper for the Tk GUI toolkit.".freeze
|
17
19
|
|
18
20
|
if s.respond_to? :specification_version then
|
19
|
-
|
20
|
-
s.specification_version = 3
|
21
|
+
s.specification_version = 4
|
21
22
|
|
22
23
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
23
|
-
s.add_runtime_dependency(%q<ffi
|
24
|
-
s.add_development_dependency(%q<bacon
|
24
|
+
s.add_runtime_dependency(%q<ffi>.freeze, ["~> 1.9"])
|
25
|
+
s.add_development_dependency(%q<bacon>.freeze, ["~> 1.2"])
|
25
26
|
else
|
26
|
-
s.add_dependency(%q<ffi
|
27
|
-
s.add_dependency(%q<bacon
|
27
|
+
s.add_dependency(%q<ffi>.freeze, ["~> 1.9"])
|
28
|
+
s.add_dependency(%q<bacon>.freeze, ["~> 1.2"])
|
28
29
|
end
|
29
30
|
else
|
30
|
-
s.add_dependency(%q<ffi
|
31
|
-
s.add_dependency(%q<bacon
|
31
|
+
s.add_dependency(%q<ffi>.freeze, ["~> 1.9"])
|
32
|
+
s.add_dependency(%q<bacon>.freeze, ["~> 1.2"])
|
32
33
|
end
|
33
34
|
end
|