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.
Files changed (199) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_todo.yml +371 -0
  5. data/AUTHORS +4 -2
  6. data/CHANGELOG +302 -262
  7. data/Gemfile +10 -0
  8. data/Gemfile.lock +45 -0
  9. data/MANIFEST +6 -6
  10. data/README.md +1 -1
  11. data/Rakefile +12 -11
  12. data/bin/rwish +6 -5
  13. data/example/choose_color.rb +5 -4
  14. data/example/choose_directory.rb +5 -4
  15. data/example/dialog.rb +9 -8
  16. data/example/hello.rb +2 -1
  17. data/example/message_box.rb +8 -5
  18. data/example/option_menu.rb +4 -3
  19. data/example/popup.rb +4 -3
  20. data/example/set_palette.rb +5 -4
  21. data/example/text.rb +30 -30
  22. data/example/tile/kroc_demo_small.rb +51 -55
  23. data/example/tile/kroc_rb_demo.rb +74 -83
  24. data/example/tile/notebook.rb +6 -9
  25. data/example/tile/theme_hello.rb +6 -8
  26. data/example/tile/themes.rb +4 -2
  27. data/example/tile/treeview.rb +16 -14
  28. data/example/tkgo.rb +120 -88
  29. data/example/various.rb +8 -7
  30. data/example/wait.rb +3 -2
  31. data/ffi-tk.gemspec +21 -20
  32. data/gemset.nix +134 -0
  33. data/lib/ffi-tk.rb +10 -11
  34. data/lib/ffi-tk/command.rb +3 -2
  35. data/lib/ffi-tk/command/after.rb +8 -7
  36. data/lib/ffi-tk/command/bell.rb +2 -1
  37. data/lib/ffi-tk/command/bind.rb +1 -0
  38. data/lib/ffi-tk/command/bindtags.rb +1 -0
  39. data/lib/ffi-tk/command/cget.rb +31 -24
  40. data/lib/ffi-tk/command/choose_color.rb +2 -1
  41. data/lib/ffi-tk/command/choose_directory.rb +2 -1
  42. data/lib/ffi-tk/command/clipboard.rb +6 -5
  43. data/lib/ffi-tk/command/configure.rb +23 -21
  44. data/lib/ffi-tk/command/destroy.rb +2 -1
  45. data/lib/ffi-tk/command/dialog.rb +4 -3
  46. data/lib/ffi-tk/command/event.rb +1 -0
  47. data/lib/ffi-tk/command/focus.rb +2 -1
  48. data/lib/ffi-tk/command/font.rb +12 -9
  49. data/lib/ffi-tk/command/get_open_file.rb +1 -0
  50. data/lib/ffi-tk/command/get_save_file.rb +1 -0
  51. data/lib/ffi-tk/command/grab.rb +2 -1
  52. data/lib/ffi-tk/command/grid.rb +7 -6
  53. data/lib/ffi-tk/command/image.rb +5 -4
  54. data/lib/ffi-tk/command/lower.rb +1 -0
  55. data/lib/ffi-tk/command/message_box.rb +2 -1
  56. data/lib/ffi-tk/command/option_menu.rb +3 -2
  57. data/lib/ffi-tk/command/pack.rb +5 -4
  58. data/lib/ffi-tk/command/place.rb +5 -4
  59. data/lib/ffi-tk/command/popup.rb +2 -1
  60. data/lib/ffi-tk/command/raise.rb +1 -0
  61. data/lib/ffi-tk/command/scrollable.rb +7 -10
  62. data/lib/ffi-tk/command/selection.rb +4 -3
  63. data/lib/ffi-tk/command/set_palette.rb +2 -1
  64. data/lib/ffi-tk/command/tk_cmd.rb +1 -0
  65. data/lib/ffi-tk/command/vars.rb +2 -1
  66. data/lib/ffi-tk/command/wait.rb +2 -1
  67. data/lib/ffi-tk/command/winfo.rb +9 -8
  68. data/lib/ffi-tk/command/wm.rb +11 -10
  69. data/lib/ffi-tk/core_extensions.rb +5 -4
  70. data/lib/ffi-tk/event/data.rb +32 -31
  71. data/lib/ffi-tk/event/handler.rb +4 -3
  72. data/lib/ffi-tk/ffi/tcl.rb +42 -31
  73. data/lib/ffi-tk/ffi/tcl/cmd_proc.rb +2 -1
  74. data/lib/ffi-tk/ffi/tcl/eval_result.rb +47 -8
  75. data/lib/ffi-tk/ffi/tcl/interp.rb +7 -4
  76. data/lib/ffi-tk/ffi/tcl/obj.rb +7 -32
  77. data/lib/ffi-tk/ffi/tcl/time.rb +2 -1
  78. data/lib/ffi-tk/ffi/tk.rb +8 -7
  79. data/lib/ffi-tk/geometry.rb +20 -17
  80. data/lib/ffi-tk/thread_sender.rb +1 -0
  81. data/lib/ffi-tk/tk.rb +23 -23
  82. data/lib/ffi-tk/variable.rb +25 -3
  83. data/lib/ffi-tk/version.rb +1 -1
  84. data/lib/ffi-tk/widget.rb +2 -1
  85. data/lib/ffi-tk/widget/button.rb +4 -1
  86. data/lib/ffi-tk/widget/canvas.rb +18 -15
  87. data/lib/ffi-tk/widget/canvas/arc.rb +2 -1
  88. data/lib/ffi-tk/widget/canvas/bitmap.rb +2 -1
  89. data/lib/ffi-tk/widget/canvas/image.rb +2 -1
  90. data/lib/ffi-tk/widget/canvas/item.rb +4 -4
  91. data/lib/ffi-tk/widget/canvas/line.rb +2 -1
  92. data/lib/ffi-tk/widget/canvas/oval.rb +2 -1
  93. data/lib/ffi-tk/widget/canvas/polygon.rb +2 -1
  94. data/lib/ffi-tk/widget/canvas/rectangle.rb +2 -1
  95. data/lib/ffi-tk/widget/canvas/text.rb +2 -1
  96. data/lib/ffi-tk/widget/canvas/window.rb +2 -1
  97. data/lib/ffi-tk/widget/checkbutton.rb +4 -1
  98. data/lib/ffi-tk/widget/entry.rb +4 -1
  99. data/lib/ffi-tk/widget/frame.rb +4 -1
  100. data/lib/ffi-tk/widget/label.rb +4 -1
  101. data/lib/ffi-tk/widget/labelframe.rb +4 -1
  102. data/lib/ffi-tk/widget/listbox.rb +5 -2
  103. data/lib/ffi-tk/widget/menu.rb +4 -1
  104. data/lib/ffi-tk/widget/menubutton.rb +4 -1
  105. data/lib/ffi-tk/widget/message.rb +4 -1
  106. data/lib/ffi-tk/widget/panedwindow.rb +5 -2
  107. data/lib/ffi-tk/widget/radiobutton.rb +4 -1
  108. data/lib/ffi-tk/widget/root.rb +1 -0
  109. data/lib/ffi-tk/widget/scale.rb +4 -1
  110. data/lib/ffi-tk/widget/scrollbar.rb +4 -1
  111. data/lib/ffi-tk/widget/spinbox.rb +4 -1
  112. data/lib/ffi-tk/widget/text.rb +20 -16
  113. data/lib/ffi-tk/widget/text/peer.rb +1 -0
  114. data/lib/ffi-tk/widget/tile.rb +2 -1
  115. data/lib/ffi-tk/widget/tile/button.rb +4 -1
  116. data/lib/ffi-tk/widget/tile/checkbutton.rb +4 -1
  117. data/lib/ffi-tk/widget/tile/combobox.rb +5 -2
  118. data/lib/ffi-tk/widget/tile/entry.rb +4 -1
  119. data/lib/ffi-tk/widget/tile/frame.rb +4 -1
  120. data/lib/ffi-tk/widget/tile/label.rb +4 -2
  121. data/lib/ffi-tk/widget/tile/labelframe.rb +4 -1
  122. data/lib/ffi-tk/widget/tile/menubutton.rb +4 -1
  123. data/lib/ffi-tk/widget/tile/notebook.rb +4 -1
  124. data/lib/ffi-tk/widget/tile/panedwindow.rb +4 -1
  125. data/lib/ffi-tk/widget/tile/progressbar.rb +4 -2
  126. data/lib/ffi-tk/widget/tile/radiobutton.rb +4 -1
  127. data/lib/ffi-tk/widget/tile/scale.rb +4 -1
  128. data/lib/ffi-tk/widget/tile/scrollbar.rb +7 -4
  129. data/lib/ffi-tk/widget/tile/separator.rb +4 -1
  130. data/lib/ffi-tk/widget/tile/sizegrip.rb +4 -1
  131. data/lib/ffi-tk/widget/tile/style.rb +16 -17
  132. data/lib/ffi-tk/widget/tile/treeview.rb +11 -5
  133. data/lib/ffi-tk/widget/toplevel.rb +4 -1
  134. data/shell.nix +19 -0
  135. data/spec/ffi-tk/command/bind.rb +5 -4
  136. data/spec/ffi-tk/command/bindtags.rb +2 -1
  137. data/spec/ffi-tk/command/clipboard.rb +4 -3
  138. data/spec/ffi-tk/command/font.rb +20 -19
  139. data/spec/ffi-tk/command/image.rb +13 -5
  140. data/spec/ffi-tk/command/pack.rb +3 -2
  141. data/spec/ffi-tk/command/place.rb +4 -3
  142. data/spec/ffi-tk/command/selection.rb +2 -1
  143. data/spec/ffi-tk/command/vars.rb +3 -2
  144. data/spec/ffi-tk/command/winfo.rb +10 -10
  145. data/spec/ffi-tk/command/wm.rb +23 -22
  146. data/spec/ffi-tk/event.rb +23 -21
  147. data/spec/ffi-tk/tile/button.rb +8 -8
  148. data/spec/ffi-tk/tile/checkbutton.rb +1 -1
  149. data/spec/ffi-tk/tile/combobox.rb +11 -12
  150. data/spec/ffi-tk/tile/entry.rb +18 -19
  151. data/spec/ffi-tk/tile/frame.rb +13 -13
  152. data/spec/ffi-tk/tile/label.rb +2 -2
  153. data/spec/ffi-tk/tile/labelframe.rb +1 -1
  154. data/spec/ffi-tk/tile/menubutton.rb +1 -1
  155. data/spec/ffi-tk/tile/notebook.rb +22 -20
  156. data/spec/ffi-tk/tile/panedwindow.rb +1 -1
  157. data/spec/ffi-tk/tile/progressbar.rb +1 -1
  158. data/spec/ffi-tk/tile/radiobutton.rb +1 -1
  159. data/spec/ffi-tk/tile/scale.rb +1 -1
  160. data/spec/ffi-tk/tile/scrollbar.rb +1 -16
  161. data/spec/ffi-tk/tile/separator.rb +2 -2
  162. data/spec/ffi-tk/tile/sizegrip.rb +1 -1
  163. data/spec/ffi-tk/tile/style.rb +63 -65
  164. data/spec/ffi-tk/tile/treeview.rb +11 -10
  165. data/spec/ffi-tk/variable.rb +5 -4
  166. data/spec/ffi-tk/widget/button.rb +3 -2
  167. data/spec/ffi-tk/widget/canvas.rb +59 -58
  168. data/spec/ffi-tk/widget/checkbutton.rb +6 -5
  169. data/spec/ffi-tk/widget/entry.rb +112 -103
  170. data/spec/ffi-tk/widget/frame.rb +2 -1
  171. data/spec/ffi-tk/widget/label.rb +2 -1
  172. data/spec/ffi-tk/widget/labelframe.rb +1 -0
  173. data/spec/ffi-tk/widget/listbox.rb +5 -4
  174. data/spec/ffi-tk/widget/menu.rb +3 -2
  175. data/spec/ffi-tk/widget/menubutton.rb +1 -0
  176. data/spec/ffi-tk/widget/message.rb +1 -0
  177. data/spec/ffi-tk/widget/panedwindow.rb +1 -0
  178. data/spec/ffi-tk/widget/radiobutton.rb +1 -0
  179. data/spec/ffi-tk/widget/root.rb +2 -1
  180. data/spec/ffi-tk/widget/scale.rb +1 -0
  181. data/spec/ffi-tk/widget/scrollbar.rb +1 -0
  182. data/spec/ffi-tk/widget/spinbox.rb +1 -0
  183. data/spec/ffi-tk/widget/text.rb +63 -54
  184. data/spec/ffi-tk/widget/toplevel.rb +1 -0
  185. data/spec/helper.rb +3 -1
  186. data/tasks/authors.rake +3 -2
  187. data/tasks/bacon.rake +13 -11
  188. data/tasks/changelog.rake +1 -0
  189. data/tasks/gem.rake +13 -11
  190. data/tasks/manifest.rake +2 -1
  191. data/tasks/release.rake +11 -32
  192. data/tasks/reversion.rake +2 -1
  193. metadata +52 -75
  194. data/spec/ffi-tk/command/grid.rb +0 -6
  195. data/tasks/gem_setup.rake +0 -113
  196. data/tasks/grancher.rake +0 -12
  197. data/tasks/rcov.rake +0 -17
  198. data/tasks/setup.rake +0 -12
  199. 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
@@ -1,155 +1,164 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::Entry do
4
- @entry = Tk::Entry.new
5
-
6
- it "returns the entry's string" do
7
- @entry.get.should == ''
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 'inserts text at index' do
11
- @entry.insert(:end, 'Hello, World!')
12
- @entry.get.should == 'Hello, World!'
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 'returns a list of four numbers describing the bounding box of the character given by index' do
16
- index_bbox = @entry.bbox(0)
17
- index_bbox.should.be.kind_of? Array
18
- index_bbox.size.should == 4
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
- it 'Returns the current value of the configuration option given' do
22
- @entry.cget(:background ).should == "#ffffff"
23
- @entry.cget(:bd ).should == 1
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 'configures a single option' do
61
- @entry.configure(validate: :focus)
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 'configures more options at once' do
68
- @entry.configure(justify: :right, validate: :focus)
69
- @entry.cget(:validate).should == :focus
70
- @entry.cget(:justify).should == :right
75
+ it 'inserts text at index' do
76
+ entry.insert(:end, 'Hello, World!')
77
+ entry.get.should == 'Hello, World!'
78
+ end
71
79
 
72
- @entry.configure(justify: :left, validate: :none)
73
- @entry.cget(:validate).should == :none
74
- @entry.cget(:justify).should == :left
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 "deletes character at index" do
78
- @entry.delete(5)
79
- @entry.get.should == "Hello World!"
86
+ it 'deletes character at index' do
87
+ entry.delete(5)
88
+ entry.get.should == 'Hello World!'
80
89
  end
81
90
 
82
- it "deletes character between indices" do
83
- @entry.delete(5, 11)
84
- @entry.get.should == "Hello!"
91
+ it 'deletes character between indices' do
92
+ entry.delete(5, 11)
93
+ entry.get.should == 'Hello!'
85
94
  end
86
95
 
87
- it "Puts the insertion cursor just before the character given by index" do
88
- @entry.icursor(5)
89
- @entry.insert(:insert, ", World")
90
- @entry.get.should == "Hello, World!"
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 "Returns the numerical index corresponding to index" do
94
- @entry.index(:insert).should == 12
102
+ it 'Returns the numerical index corresponding to index' do
103
+ entry.index(:insert).should == 12
95
104
  end
96
105
 
97
- it "Insert the string just before the character indicated by index" do
98
- @entry.insert(0, 'OHAI ')
99
- @entry.get.should == 'OHAI Hello, World!'
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
- @entry.scan_mark(0)
105
- @entry.scan_dragto(10)
106
- }.should.not.raise
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
- @entry.selection_present.should == false
119
+ entry.selection_present.should == false
111
120
  end
112
121
 
113
122
  it 'adjusts the selection' do
114
- @entry.selection_adjust(0)
115
- @entry.index('sel.first').should == 0
116
- @entry.selection_adjust(5)
117
- @entry.index('sel.last').should == 5
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
- @entry.selection_present.should == true
122
- @entry.selection_clear
123
- @entry.selection_present.should == false
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
- @entry.selection_range(1, 4)
128
- @entry.index('sel.first').should == 1
129
- @entry.index('sel.last').should == 4
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
- @entry.selection_from(2)
134
- @entry.selection_to(5)
135
- @entry.index('sel.first').should == 2
136
- @entry.index('sel.last').should == 5
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
- @entry.validate.should == true
149
+ entry.validate.should == true
141
150
  end
142
151
 
143
152
  it 'validates the entry with validation command' do
144
- @entry.configure validatecommand: lambda{|*args| true }
145
- @entry.validate.should == true
153
+ entry.configure validatecommand: ->(*_args) { true }
154
+ entry.validate.should == true
146
155
 
147
- @entry.configure validatecommand: lambda{|*args| false }
148
- @entry.validate.should == false
156
+ entry.configure validatecommand: ->(*_args) { false }
157
+ entry.validate.should == false
149
158
  end
150
159
  end
151
160
 
152
161
  # puts
153
- # @entry.configure.map{|c| c.first[1..-1] }.each{|k,v|
154
- # puts "@entry.cget(%-20p).should == %p" % [k.to_sym, @entry.cget(k)]
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
+ # }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::Frame do
@@ -5,4 +6,4 @@ describe Tk::Frame do
5
6
  @frame = Tk::Frame.new
6
7
  @frame.winfo_exists.should == true
7
8
  end
8
- end
9
+ end
@@ -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 == nil
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::LabelFrame do
@@ -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, "first line"
13
- list.get(0).should == "first line"
14
- list.insert 1, "second line"
15
- list.get(1).should == "second line"
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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::Menu do
@@ -7,6 +8,6 @@ describe Tk::Menu do
7
8
  instance.tk_parent.should == Tk.root
8
9
  end
9
10
 
10
- #it 'needs more specs' do
11
- #end
11
+ # it 'needs more specs' do
12
+ # end
12
13
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::MenuButton do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::Message do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::PanedWindow do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::RadioButton do
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::Root do
4
5
  it 'initializes' do
5
6
  instance = Tk::Root.new
6
7
  instance.class.should == Tk::Root
7
- instance.tk_parent.should == nil
8
+ instance.tk_parent.should.nil?
8
9
  end
9
10
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::Scale do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::Scrollbar do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../helper'
2
3
 
3
4
  describe Tk::Spinbox do
@@ -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
- it 'gets all possible options with cget' do
17
- text.cget(:autoseparators ).should == true
18
- text.cget(:background ).should == "#ffffff"
19
- text.cget(:bd ).should == 1
20
- text.cget(:bg ).should == "#ffffff"
21
- text.cget(:blockcursor ).should == false
22
- text.cget(:borderwidth ).should == 1
23
- text.cget(:cursor ).should == "xterm"
24
- text.cget(:endline ).should == 0
25
- text.cget(:exportselection ).should == true
26
- text.cget(:fg ).should == "#000000"
27
- text.cget(:font ).should == "TkFixedFont"
28
- text.cget(:foreground ).should == "#000000"
29
- text.cget(:height ).should == 24
30
- text.cget(:highlightbackground ).should == "#d9d9d9"
31
- text.cget(:highlightcolor ).should == "#000000"
32
- text.cget(:highlightthickness ).should == 1
33
- text.cget(:inactiveselectbackground).should == "#c3c3c3"
34
- text.cget(:insertbackground ).should == "#000000"
35
- text.cget(:insertborderwidth ).should == 0
36
- text.cget(:insertofftime ).should == 300
37
- text.cget(:insertontime ).should == 600
38
- text.cget(:insertwidth ).should == 2
39
- text.cget(:maxundo ).should == 0
40
- text.cget(:padx ).should == 1
41
- text.cget(:pady ).should == 1
42
- text.cget(:relief ).should == :sunken
43
- text.cget(:selectbackground ).should == "#c3c3c3"
44
- text.cget(:selectborderwidth ).should == 0
45
- text.cget(:selectforeground ).should == "#000000"
46
- text.cget(:setgrid ).should == false
47
- text.cget(:spacing1 ).should == 0
48
- text.cget(:spacing2 ).should == 0
49
- text.cget(:spacing3 ).should == 0
50
- text.cget(:startline ).should == 0
51
- text.cget(:state ).should == ['normal']
52
- text.cget(:tabs ).should == nil
53
- text.cget(:tabstyle ).should == :tabular
54
- text.cget(:takefocus ).should == false
55
- text.cget(:undo ).should == false
56
- text.cget(:width ).should == 80
57
- text.cget(:wrap ).should == :char
58
- text.cget(:xscrollcommand ).should == nil
59
- text.cget(:yscrollcommand ).should == nil
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 == 195
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.kind_of?(Fixnum) }
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
- it 'searches for {}' do
193
- text.insert :end, '{ now some text in here}'
194
- text.search(/\{/, '1.0', 'end', :all).should == ['1.10']
195
- text.search(/\}/, '1.0', 'end', :all).should == ['1.33']
196
- text.search(/[{}]/, '1.0', 'end', :all).should == ['1.10', '1.33']
197
- end
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("et", '1.0', :end).should == ['1.13']
226
- text.search("labore", '1.0', :end).should == ['20.17']
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