ffi-tk 2010.08.23 → 2018.02.20
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.
- 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
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative '../../helper'
|
2
3
|
|
3
4
|
describe Tk::CheckButton do
|
@@ -21,7 +22,7 @@ describe Tk::CheckButton do
|
|
21
22
|
it 'assigns a command block on initialize' do
|
22
23
|
toggled = false
|
23
24
|
value = Tk::Variable.new('checkbutton_value')
|
24
|
-
cb = Tk::CheckButton.new(variable: value){ toggled = !toggled }
|
25
|
+
cb = Tk::CheckButton.new(variable: value) { toggled = !toggled }
|
25
26
|
cb.pack
|
26
27
|
cb.focus
|
27
28
|
|
@@ -30,15 +31,15 @@ describe Tk::CheckButton do
|
|
30
31
|
Tk::Wait.visibility(cb)
|
31
32
|
|
32
33
|
Tk::Event.generate(cb, '<1>')
|
33
|
-
Tk.interp.do_events_until{ toggled }
|
34
|
+
Tk.interp.do_events_until { toggled }
|
34
35
|
toggled.should == true
|
35
36
|
|
36
37
|
Tk::Event.generate(cb, '<1>')
|
37
|
-
Tk.interp.do_events_until{ !toggled }
|
38
|
+
Tk.interp.do_events_until { !toggled }
|
38
39
|
toggled.should == false
|
39
40
|
|
40
41
|
Tk::Event.generate(cb, '<1>')
|
41
|
-
Tk.interp.do_events_until{ toggled }
|
42
|
+
Tk.interp.do_events_until { toggled }
|
42
43
|
toggled.should == true
|
43
44
|
end
|
44
|
-
end
|
45
|
+
end
|
data/spec/ffi-tk/widget/entry.rb
CHANGED
@@ -1,155 +1,164 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative '../../helper'
|
2
3
|
|
3
4
|
describe Tk::Entry do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
entry = Tk::Entry.new
|
6
|
+
|
7
|
+
cget_options = {
|
8
|
+
background: ['systemWindowBody', '#ffffff', '#282828'],
|
9
|
+
bd: [2, 1],
|
10
|
+
bg: ['systemWindowBody', '#ffffff', '#282828'],
|
11
|
+
borderwidth: [2, 1],
|
12
|
+
cursor: ['xterm'],
|
13
|
+
disabledbackground: ['systemWindowBody', '#d9d9d9'],
|
14
|
+
disabledforeground: ['#a3a3a3'],
|
15
|
+
exportselection: [true],
|
16
|
+
fg: ['Black', '#000000', '#ebdbb2'],
|
17
|
+
font: ['TkTextFont'],
|
18
|
+
foreground: ['Black', '#000000', '#ebdbb2'],
|
19
|
+
highlightbackground: ['systemWindowBody', '#d9d9d9'],
|
20
|
+
highlightcolor: ['Black', '#000000'],
|
21
|
+
highlightthickness: [3, 1],
|
22
|
+
insertbackground: ['Black', '#000000'],
|
23
|
+
insertborderwidth: [0],
|
24
|
+
insertofftime: [300],
|
25
|
+
insertontime: [600],
|
26
|
+
insertwidth: [1, 2],
|
27
|
+
invalidcommand: [nil],
|
28
|
+
invcmd: [nil],
|
29
|
+
justify: [:left],
|
30
|
+
readonlybackground: ['systemWindowBody', '#d9d9d9'],
|
31
|
+
relief: [:sunken],
|
32
|
+
selectbackground: ['systemHighlight', '#c3c3c3'],
|
33
|
+
selectborderwidth: [1, 0],
|
34
|
+
selectforeground: [nil, '#000000'],
|
35
|
+
show: [nil],
|
36
|
+
state: [['normal']],
|
37
|
+
takefocus: [false],
|
38
|
+
textvariable: [nil],
|
39
|
+
validate: [:none],
|
40
|
+
validatecommand: [nil],
|
41
|
+
vcmd: [nil],
|
42
|
+
width: [20],
|
43
|
+
xscrollcommand: [nil]
|
44
|
+
}
|
45
|
+
|
46
|
+
describe 'getting options via cget' do
|
47
|
+
cget_options.each do |key, values|
|
48
|
+
it "returns a member of #{values.inspect} for -#{key}" do
|
49
|
+
values.should.include entry.cget(key)
|
50
|
+
end
|
51
|
+
end
|
8
52
|
end
|
9
53
|
|
10
|
-
it '
|
11
|
-
|
12
|
-
|
54
|
+
it 'configures a single option' do
|
55
|
+
entry.configure(validate: :focus)
|
56
|
+
entry.cget(:validate).should == :focus
|
57
|
+
entry.configure(validate: :none)
|
58
|
+
entry.cget(:validate).should == :none
|
13
59
|
end
|
14
60
|
|
15
|
-
it '
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
61
|
+
it 'configures more options at once' do
|
62
|
+
entry.configure(justify: :right, validate: :focus)
|
63
|
+
entry.cget(:validate).should == :focus
|
64
|
+
entry.cget(:justify).should == :right
|
20
65
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@entry.cget(:bg ).should == "#ffffff"
|
25
|
-
@entry.cget(:borderwidth ).should == 1
|
26
|
-
@entry.cget(:cursor ).should == "xterm"
|
27
|
-
@entry.cget(:disabledbackground ).should == "#d9d9d9"
|
28
|
-
@entry.cget(:disabledforeground ).should == "#a3a3a3"
|
29
|
-
@entry.cget(:exportselection ).should == true
|
30
|
-
@entry.cget(:fg ).should == "#000000"
|
31
|
-
@entry.cget(:font ).should == "TkTextFont"
|
32
|
-
@entry.cget(:foreground ).should == "#000000"
|
33
|
-
@entry.cget(:highlightbackground).should == "#d9d9d9"
|
34
|
-
@entry.cget(:highlightcolor ).should == "#000000"
|
35
|
-
@entry.cget(:highlightthickness ).should == 1
|
36
|
-
@entry.cget(:insertbackground ).should == "#000000"
|
37
|
-
@entry.cget(:insertborderwidth ).should == 0
|
38
|
-
@entry.cget(:insertofftime ).should == 300
|
39
|
-
@entry.cget(:insertontime ).should == 600
|
40
|
-
@entry.cget(:insertwidth ).should == 2
|
41
|
-
@entry.cget(:invalidcommand ).should == nil
|
42
|
-
@entry.cget(:invcmd ).should == nil
|
43
|
-
@entry.cget(:justify ).should == :left
|
44
|
-
@entry.cget(:readonlybackground ).should == "#d9d9d9"
|
45
|
-
@entry.cget(:relief ).should == :sunken
|
46
|
-
@entry.cget(:selectbackground ).should == "#c3c3c3"
|
47
|
-
@entry.cget(:selectborderwidth ).should == 0
|
48
|
-
@entry.cget(:selectforeground ).should == "#000000"
|
49
|
-
@entry.cget(:show ).should == nil
|
50
|
-
@entry.cget(:state ).should == ['normal']
|
51
|
-
@entry.cget(:takefocus ).should == false
|
52
|
-
@entry.cget(:textvariable ).should == nil
|
53
|
-
@entry.cget(:validate ).should == :none
|
54
|
-
@entry.cget(:validatecommand ).should == nil
|
55
|
-
@entry.cget(:vcmd ).should == nil
|
56
|
-
@entry.cget(:width ).should == 20
|
57
|
-
@entry.cget(:xscrollcommand ).should == nil
|
66
|
+
entry.configure(justify: :left, validate: :none)
|
67
|
+
entry.cget(:validate).should == :none
|
68
|
+
entry.cget(:justify).should == :left
|
58
69
|
end
|
59
70
|
|
60
|
-
it
|
61
|
-
|
62
|
-
@entry.cget(:validate).should == :focus
|
63
|
-
@entry.configure(validate: :none)
|
64
|
-
@entry.cget(:validate).should == :none
|
71
|
+
it "returns the entry's string" do
|
72
|
+
entry.get.should == ''
|
65
73
|
end
|
66
74
|
|
67
|
-
it '
|
68
|
-
|
69
|
-
|
70
|
-
|
75
|
+
it 'inserts text at index' do
|
76
|
+
entry.insert(:end, 'Hello, World!')
|
77
|
+
entry.get.should == 'Hello, World!'
|
78
|
+
end
|
71
79
|
|
72
|
-
|
73
|
-
|
74
|
-
|
80
|
+
it 'returns a list of four numbers describing the bounding box of the character given by index' do
|
81
|
+
index_bbox = entry.bbox(0)
|
82
|
+
index_bbox.should.be.is_a? Array
|
83
|
+
index_bbox.size.should == 4
|
75
84
|
end
|
76
85
|
|
77
|
-
it
|
78
|
-
|
79
|
-
|
86
|
+
it 'deletes character at index' do
|
87
|
+
entry.delete(5)
|
88
|
+
entry.get.should == 'Hello World!'
|
80
89
|
end
|
81
90
|
|
82
|
-
it
|
83
|
-
|
84
|
-
|
91
|
+
it 'deletes character between indices' do
|
92
|
+
entry.delete(5, 11)
|
93
|
+
entry.get.should == 'Hello!'
|
85
94
|
end
|
86
95
|
|
87
|
-
it
|
88
|
-
|
89
|
-
|
90
|
-
|
96
|
+
it 'Puts the insertion cursor just before the character given by index' do
|
97
|
+
entry.icursor(5)
|
98
|
+
entry.insert(:insert, ', World')
|
99
|
+
entry.get.should == 'Hello, World!'
|
91
100
|
end
|
92
101
|
|
93
|
-
it
|
94
|
-
|
102
|
+
it 'Returns the numerical index corresponding to index' do
|
103
|
+
entry.index(:insert).should == 12
|
95
104
|
end
|
96
105
|
|
97
|
-
it
|
98
|
-
|
99
|
-
|
106
|
+
it 'Insert the string just before the character indicated by index' do
|
107
|
+
entry.insert(0, 'OHAI ')
|
108
|
+
entry.get.should == 'OHAI Hello, World!'
|
100
109
|
end
|
101
110
|
|
102
111
|
it 'uses the scan commands' do
|
103
|
-
lambda
|
104
|
-
|
105
|
-
|
106
|
-
|
112
|
+
lambda do
|
113
|
+
entry.scan_mark(0)
|
114
|
+
entry.scan_dragto(10)
|
115
|
+
end.should.not.raise
|
107
116
|
end
|
108
117
|
|
109
118
|
it 'Returns whether a selection is present' do
|
110
|
-
|
119
|
+
entry.selection_present.should == false
|
111
120
|
end
|
112
121
|
|
113
122
|
it 'adjusts the selection' do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
123
|
+
entry.selection_adjust(0)
|
124
|
+
entry.index('sel.first').should == 0
|
125
|
+
entry.selection_adjust(5)
|
126
|
+
entry.index('sel.last').should == 5
|
118
127
|
end
|
119
128
|
|
120
129
|
it 'Clears the selection' do
|
121
|
-
|
122
|
-
|
123
|
-
|
130
|
+
entry.selection_present.should == true
|
131
|
+
entry.selection_clear
|
132
|
+
entry.selection_present.should == false
|
124
133
|
end
|
125
134
|
|
126
135
|
it 'Selects the characters at start ending with the one just before end' do
|
127
|
-
|
128
|
-
|
129
|
-
|
136
|
+
entry.selection_range(1, 4)
|
137
|
+
entry.index('sel.first').should == 1
|
138
|
+
entry.index('sel.last').should == 4
|
130
139
|
end
|
131
140
|
|
132
141
|
it 'Adjusts selection with the from and to commands' do
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
142
|
+
entry.selection_from(2)
|
143
|
+
entry.selection_to(5)
|
144
|
+
entry.index('sel.first').should == 2
|
145
|
+
entry.index('sel.last').should == 5
|
137
146
|
end
|
138
147
|
|
139
148
|
it 'validates the entry without validation command' do
|
140
|
-
|
149
|
+
entry.validate.should == true
|
141
150
|
end
|
142
151
|
|
143
152
|
it 'validates the entry with validation command' do
|
144
|
-
|
145
|
-
|
153
|
+
entry.configure validatecommand: ->(*_args) { true }
|
154
|
+
entry.validate.should == true
|
146
155
|
|
147
|
-
|
148
|
-
|
156
|
+
entry.configure validatecommand: ->(*_args) { false }
|
157
|
+
entry.validate.should == false
|
149
158
|
end
|
150
159
|
end
|
151
160
|
|
152
161
|
# puts
|
153
|
-
#
|
154
|
-
# puts "
|
155
|
-
# }
|
162
|
+
# entry.configure.map{|c| c.first[1..-1] }.each{|k,v|
|
163
|
+
# puts "entry.cget(%-20p).should == %p" % [k.to_sym, entry.cget(k)]
|
164
|
+
# }
|
data/spec/ffi-tk/widget/frame.rb
CHANGED
data/spec/ffi-tk/widget/label.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative '../../helper'
|
2
3
|
|
3
4
|
describe Tk::Label do
|
@@ -9,7 +10,7 @@ describe Tk::Label do
|
|
9
10
|
|
10
11
|
it 'needs more specs' do
|
11
12
|
label = Tk::Label.new
|
12
|
-
label.value.should
|
13
|
+
label.value.should.nil?
|
13
14
|
label.value = 'Hello, World!'
|
14
15
|
label.value.should == 'Hello, World!'
|
15
16
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative '../../helper'
|
2
3
|
|
3
4
|
describe Tk::Listbox do
|
@@ -9,10 +10,10 @@ describe Tk::Listbox do
|
|
9
10
|
|
10
11
|
it 'Make sure we get contents of the list' do
|
11
12
|
list = Tk::Listbox.new
|
12
|
-
list.insert 0,
|
13
|
-
list.get(0).should ==
|
14
|
-
list.insert 1,
|
15
|
-
list.get(1).should ==
|
13
|
+
list.insert 0, 'first line'
|
14
|
+
list.get(0).should == 'first line'
|
15
|
+
list.insert 1, 'second line'
|
16
|
+
list.get(1).should == 'second line'
|
16
17
|
list.get(0, 1).should == ['first line', 'second line']
|
17
18
|
list.value.should == ['first line', 'second line']
|
18
19
|
end
|
data/spec/ffi-tk/widget/menu.rb
CHANGED
data/spec/ffi-tk/widget/root.rb
CHANGED
data/spec/ffi-tk/widget/scale.rb
CHANGED
data/spec/ffi-tk/widget/text.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative '../../helper'
|
2
3
|
|
3
4
|
describe Tk::Text do
|
@@ -13,50 +14,58 @@ describe Tk::Text do
|
|
13
14
|
text.get('1.0', 'end').should == "Hello, World!\n"
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
17
|
+
cget_options = {
|
18
|
+
autoseparators: [true],
|
19
|
+
background: %w(systemWindowBody #282828),
|
20
|
+
bd: [0, 1],
|
21
|
+
bg: %w(systemWindowBody #ffffff #282828),
|
22
|
+
blockcursor: [false],
|
23
|
+
borderwidth: [0, 1],
|
24
|
+
cursor: ['xterm'],
|
25
|
+
endline: ['', 0],
|
26
|
+
exportselection: [true],
|
27
|
+
fg: %w(Black #000000 #ebdbb2),
|
28
|
+
font: %w(TkFixedFont),
|
29
|
+
foreground: %w(Black #000000 #ebdbb2),
|
30
|
+
height: [24],
|
31
|
+
highlightbackground: %w(systemWindowBody #d9d9d9),
|
32
|
+
highlightcolor: %w(Black #000000),
|
33
|
+
highlightthickness: [3, 1],
|
34
|
+
inactiveselectbackground: %w(systemHighlightSecondary #c3c3c3),
|
35
|
+
insertbackground: %w(Black #000000),
|
36
|
+
insertborderwidth: [0],
|
37
|
+
insertofftime: [300],
|
38
|
+
insertontime: [600],
|
39
|
+
insertwidth: [1, 2],
|
40
|
+
maxundo: [0],
|
41
|
+
padx: [1],
|
42
|
+
pady: [1],
|
43
|
+
relief: [:flat, :sunken],
|
44
|
+
selectbackground: %w(systemHighlight #c3c3c3),
|
45
|
+
selectborderwidth: [1, 0],
|
46
|
+
selectforeground: [nil, '#000000'],
|
47
|
+
setgrid: [false],
|
48
|
+
spacing1: [0],
|
49
|
+
spacing2: [0],
|
50
|
+
spacing3: [0],
|
51
|
+
startline: [0, ''],
|
52
|
+
state: [['normal']],
|
53
|
+
tabs: [nil],
|
54
|
+
tabstyle: [:tabular],
|
55
|
+
takefocus: [false],
|
56
|
+
undo: [false, true],
|
57
|
+
width: [80],
|
58
|
+
wrap: [:char],
|
59
|
+
xscrollcommand: [nil],
|
60
|
+
yscrollcommand: [nil]
|
61
|
+
}
|
62
|
+
|
63
|
+
describe 'getting options via cget' do
|
64
|
+
cget_options.each do |key, values|
|
65
|
+
it "returns a member of #{values.inspect} for -#{key}" do
|
66
|
+
values.should.include text.cget(key)
|
67
|
+
end
|
68
|
+
end
|
60
69
|
end
|
61
70
|
|
62
71
|
it 'configures a single option' do
|
@@ -111,7 +120,7 @@ describe Tk::Text do
|
|
111
120
|
end
|
112
121
|
|
113
122
|
it 'counts ypixels' do
|
114
|
-
text.count(1.0, :end, :ypixels).should ==
|
123
|
+
text.count(1.0, :end, :ypixels).should == 182
|
115
124
|
end
|
116
125
|
|
117
126
|
should 'not be in debug mode' do
|
@@ -131,7 +140,7 @@ describe Tk::Text do
|
|
131
140
|
it 'gives line info' do
|
132
141
|
info = text.dlineinfo(1.0)
|
133
142
|
info.size.should == 5
|
134
|
-
info.all?{|i| i.
|
143
|
+
info.all? { |i| i.is_a?(Integer) }
|
135
144
|
end
|
136
145
|
|
137
146
|
it 'inserts string with taglist' do
|
@@ -189,12 +198,12 @@ describe Tk::Text do
|
|
189
198
|
text.peer_names.should == []
|
190
199
|
end
|
191
200
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
201
|
+
it 'searches for {}' do
|
202
|
+
text.insert :end, '{ now some text in here}'
|
203
|
+
text.search(/\{/, '1.0', 'end', :all).should == ['1.10']
|
204
|
+
text.search(/\}/, '1.0', 'end', :all).should == ['1.33']
|
205
|
+
text.search(/[{}]/, '1.0', 'end', :all).should == ['1.10', '1.33']
|
206
|
+
end
|
198
207
|
|
199
208
|
text.delete '1.0', 'end'
|
200
209
|
text.insert(:end, <<-TEXT)
|
@@ -222,8 +231,8 @@ Voluptates dicta labore impedit deserunt quod. Vero sint rerum at asperiores eos
|
|
222
231
|
|
223
232
|
describe 'Text#search' do
|
224
233
|
it 'searches by exact match' do
|
225
|
-
text.search(
|
226
|
-
text.search(
|
234
|
+
text.search('et', '1.0', :end).should == ['1.13']
|
235
|
+
text.search('labore', '1.0', :end).should == ['20.17']
|
227
236
|
end
|
228
237
|
|
229
238
|
it 'searches by regular expression' do
|