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.
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
  module Tk
2
3
  module Destroy
3
4
  def self.destroy(*windows)
@@ -9,4 +10,4 @@ module Tk
9
10
  Destroy.destroy(self)
10
11
  end
11
12
  end
12
- end
13
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  module_function
3
4
 
@@ -18,7 +19,7 @@ module Tk
18
19
  # dialog, to the left of the text.
19
20
  # If this is nil then no bitmap is displayed in the dialog.
20
21
  #
21
- # @param default [nil Fixnum]
22
+ # @param default [nil Integer]
22
23
  # If this is an integer greater than or equal to zero, then it gives the
23
24
  # index of the button that is to be the default button for the dialog (0 for
24
25
  # the leftmost button, and so on).
@@ -48,7 +49,7 @@ module Tk
48
49
  # 'questhead', 0, 'Yes', 'No', "I'm not sure")
49
50
  def dialog(window, title, text, bitmap, default, *answers)
50
51
  answer = Tk.execute(:tk_dialog,
51
- window, title, text, bitmap, default, *answers).to_i
52
+ window, title, text, bitmap, default, *answers).to_i
52
53
  return answer unless answer == -1
53
54
  end
54
- end
55
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Miscellaneous event facilities: define virtual events and generate events
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Utility methods for managing the input focus.
3
4
  module Focus
@@ -17,7 +18,7 @@ module Tk
17
18
  when :lastfor
18
19
  Tk.execute('focus', '-lastfor', window).to_s
19
20
  else
20
- raise ArgumentError, "option must be one of: None, :displayof, :force, :lastfor"
21
+ raise ArgumentError, 'option must be one of: None, :displayof, :force, :lastfor'
21
22
  end
22
23
  end
23
24
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Create and inspect fonts.
3
4
  # The font command provides several facilities for dealing with fonts, such as
@@ -8,8 +9,8 @@ module Tk
8
9
  string_or_hash =~ /^(.*)\s+(\d+)?$/
9
10
 
10
11
  params = {}
11
- params[:family] = $1.to_s
12
- params[:size] = $2.to_i if $2
12
+ params[:family] = Regexp.last_match(1).to_s
13
+ params[:size] = Regexp.last_match(2).to_i if Regexp.last_match(2)
13
14
 
14
15
  @font = Font.create(params)
15
16
  elsif string_or_hash.respond_to?(:to_hash)
@@ -47,8 +48,8 @@ module Tk
47
48
  underline: :boolean,
48
49
  overstrike: :boolean,
49
50
  weight: :symbol,
50
- slant: :symbol,
51
- }
51
+ slant: :symbol
52
+ }.freeze
52
53
 
53
54
  def self.execute(command, *args)
54
55
  Tk.execute(:font, command, *args)
@@ -74,9 +75,9 @@ module Tk
74
75
  char = options.fetch(:char, None)
75
76
 
76
77
  args = []
77
- args << "-displayof" << window unless window == None
78
+ args << '-displayof' << window unless window == None
78
79
  args << option.to_tcl_option unless option == None
79
- args << "--" << char.to_tcl unless char == None
80
+ args << '--' << char.to_tcl unless char == None
80
81
 
81
82
  array = execute(:actual, font, *args)
82
83
  array.tcl_options_to_hash(FONT_CONFIGURE_HINTS)
@@ -84,16 +85,18 @@ module Tk
84
85
 
85
86
  def self.configure(fontname, argument = None)
86
87
  Configure.common(
87
- self, [:configure, fontname], argument, FONT_CONFIGURE_HINTS)
88
+ self, [:configure, fontname], argument, FONT_CONFIGURE_HINTS
89
+ )
88
90
  end
89
91
 
90
92
  def self.create(fontname, options = None)
91
93
  if fontname.respond_to?(:to_tcl_options)
92
- fontname, options = None, fontname
94
+ options = fontname
95
+ fontname = None
93
96
  options = options.to_tcl_options
94
97
  end
95
98
 
96
- execute(:create, fontname, options)
99
+ execute(:create, fontname, options)&.to_str
97
100
  end
98
101
 
99
102
  def self.delete(*fontnames)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  module_function
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  module_function
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Confine pointer and keyboard events to a window sub-tree
3
4
  #
@@ -61,7 +62,7 @@ module Tk
61
62
  # a given display at once.
62
63
  module Grab
63
64
  # @see Grab.global
64
- def grab_global(window)
65
+ def grab_global(_window)
65
66
  Grab.globa(self)
66
67
  end
67
68
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Geometry manager that arranges widgets in a grid
3
4
  #
@@ -37,7 +38,7 @@ module Tk
37
38
  # Bbox.bbox('.', 0, 0) # top left cell
38
39
  # Bbox.bbox('.', 1, 1) # cell in second column and row
39
40
  # Bbox.bbox('.', 0, 0, 1, 1) # cells from top left to second col/row
40
- def self.bbox(master, col1 = None, row1 = None, col2 = None, row2 = None)
41
+ def self.bbox(master, _col1 = None, row1 = None, _col2 = None, row2 = None)
41
42
  bbox = Tk.execute('grid', 'bbox', master, column1, row1, column2, row2)
42
43
  bbox.map(&:to_i)
43
44
  end
@@ -80,7 +81,7 @@ module Tk
80
81
  # The characters -, x and ^, can be specified instead of a window name to
81
82
  # alter the default location of a slave.
82
83
  def self.configure(*arguments)
83
- options, slaves = arguments.partition{|arg| arg.respond_to?(:to_tcl_options?) }
84
+ options, slaves = arguments.partition { |arg| arg.respond_to?(:to_tcl_options?) }
84
85
  options = options.first
85
86
  Tk.execute('grid', 'configure', *slaves, options.to_tcl_options?)
86
87
  end
@@ -104,12 +105,12 @@ module Tk
104
105
  hash = {}
105
106
 
106
107
  info.scan(/(?:-(\w+))\s+([^-][\S]*)/) do
107
- key = $1.to_sym
108
+ key = Regexp.last_match(1).to_sym
108
109
  case key
109
110
  when :column, :row, :columnspan, :rowspan, :ipadx, :ipady, :padx, :pady
110
- hash[key] = Integer($2)
111
+ hash[key] = Integer(Regexp.last_match(2))
111
112
  else
112
- hash[key] = $2.to_str
113
+ hash[key] = Regexp.last_match(2).to_str
113
114
  end
114
115
  end
115
116
 
@@ -187,7 +188,7 @@ module Tk
187
188
  # returned, most recently manages first.
188
189
  # Option can be either -row or -column which causes only the slaves in the
189
190
  # row (or column) specified by value to be returned.
190
- def self.slaves(master, options = {})
191
+ def self.slaves(_master, _options = {})
191
192
  Tk.execute('grid', 'slaves')
192
193
  end
193
194
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  module Image
3
4
  module_function
@@ -29,9 +30,9 @@ module Tk
29
30
  if None == name
30
31
  Tk.execute(:image, :create, type)
31
32
  elsif None == options && name.respond_to?(:to_hash)
32
- Tk.execute(:image, :create, name.to_tcl_options)
33
+ Tk.execute(:image, :create, type, name.to_tcl_options)
33
34
  elsif None != name && None != options
34
- Tk.exeucte(:image, :create, name, options.to_tcl_options)
35
+ Tk.exeucte(:image, :create, type, name, options.to_tcl_options)
35
36
  end
36
37
  end
37
38
 
@@ -73,7 +74,7 @@ module Tk
73
74
  # of the values that may be supplied for the type argument to image
74
75
  # create).
75
76
  def types
76
- Tk.execute(:image, :types).to_sym
77
+ Tk.execute(:image, :types).to_a(&:to_sym)
77
78
  end
78
79
  end
79
- end
80
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Change a window's position in the stacking order
3
4
  module Lower
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  module_function
3
4
 
@@ -62,4 +63,4 @@ module Tk
62
63
  def message_box(options = None)
63
64
  Tk.execute(:tk_messageBox, options.to_tcl_options?).to_sym
64
65
  end
65
- end
66
+ end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  def self.option_menu(pathname, *values)
3
4
  variable = Variable.new('the_option_menu')
4
5
 
5
6
  Tk.execute_only(:tk_optionMenu, pathname, variable, *values)
6
- return variable
7
+ variable
7
8
  end
8
- end
9
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Geometry manager that packs around edges of cavity
3
4
  #
@@ -33,7 +34,7 @@ module Tk
33
34
  def self.info(slave)
34
35
  info = Tk.execute('pack', 'info', slave)
35
36
 
36
- array = info.split.each_slice(2).map{|key, value|
37
+ array = info.map do |key, value|
37
38
  case key = key[1..-1].to_sym
38
39
  when :expand
39
40
  [key, Tk.boolean(value)]
@@ -44,9 +45,9 @@ module Tk
44
45
  when :after, :anchor, :before, :in
45
46
  [key, value]
46
47
  else
47
- raise "Unknown info pair: %p => %p" % [key, value]
48
+ raise 'Unknown info pair: %p => %p' % [key, value]
48
49
  end
49
- }
50
+ end
50
51
 
51
52
  Hash[array]
52
53
  end
@@ -96,4 +97,4 @@ module Tk
96
97
  Pack.slaves(self)
97
98
  end
98
99
  end
99
- end
100
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Geometry manager for fixed or rubber-sheet placement
3
4
  #
@@ -17,7 +18,7 @@ module Tk
17
18
  # +window+'s geometry is managed.
18
19
  # Option may have any of the values accepted by [Place.configure].
19
20
  def self.place(window, options = {})
20
- args = options.map{|k,v| ["-#{k}", v] }.flatten
21
+ args = options.map { |k, v| ["-#{k}", v] }.flatten
21
22
  Tk.execute_only('place', window, *args)
22
23
  end
23
24
 
@@ -42,7 +43,7 @@ module Tk
42
43
  def self.info(window)
43
44
  info = Tk.execute('place', 'info', window).to_s
44
45
 
45
- array = info.split.each_slice(2).map{|key, value|
46
+ array = info.split.each_slice(2).map do |key, value|
46
47
  case key = key[1..-1].to_sym
47
48
  when :anchor, :in
48
49
  [key, value]
@@ -53,9 +54,9 @@ module Tk
53
54
  when :relheight, :relwidth, :relx, :rely
54
55
  [key, value.to_f]
55
56
  else
56
- raise "Unknown info pair: %p => %p" % [key, value]
57
+ raise 'Unknown info pair: %p => %p' % [key, value]
57
58
  end
58
- }
59
+ end
59
60
 
60
61
  Hash[array]
61
62
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # This procedure posts a menu at a given position on the screen and configures
3
4
  # Tk so that the menu and its cascaded children can be traversed with the
@@ -11,4 +12,4 @@ module Tk
11
12
  def self.popup(menu, x, y, entry = None)
12
13
  Tk.execute_only(:tk_popup, menu, x, y, entry)
13
14
  end
14
- end
15
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Change a window's position in the stacking order
3
4
  #
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  module Scrollable
3
-
4
4
  # Returns a list containing two elements.
5
5
  # Each element is a real fraction between 0 and 1; together they describe
6
6
  # the portion of the document's horizontal span that is visible in the
@@ -69,7 +69,6 @@ module Tk
69
69
  end
70
70
  end
71
71
 
72
-
73
72
  # Adjusts the view in the window so that the pixel given by fraction
74
73
  # appears at the top of the top line of the window.
75
74
  # Fraction is a fraction between 0 and 1; 0 indicates the first pixel of
@@ -124,8 +123,8 @@ module Tk
124
123
  @yscrollbar = sbar
125
124
  @yscrollbar.orient :vertical
126
125
 
127
- self.yscrollcommand {|*arg| @yscrollbar.set(*arg); true }
128
- @yscrollbar.command {|action,fraction| self.yview_moveto(fraction) }
126
+ yscrollcommand { |*arg| @yscrollbar.set(*arg); true }
127
+ @yscrollbar.command { |_action, fraction| yview_moveto(fraction) }
129
128
  @yscrollbar
130
129
  end
131
130
 
@@ -133,19 +132,17 @@ module Tk
133
132
  @xscrollbar = sbar
134
133
  @xscrollbar.orient :horizontal
135
134
 
136
- self.xscrollcommand {|*arg| @xscrollbar.set(*arg); true }
137
- @xscrollbar.command {|action,fraction| self.xview_moveto(fraction) }
135
+ xscrollcommand { |*arg| @xscrollbar.set(*arg); true }
136
+ @xscrollbar.command { |_action, fraction| xview_moveto(fraction) }
138
137
  @xscrollbar
139
138
  end
140
139
 
141
140
  def xscrollcommand(&block)
142
- configure(:xscrollcommand => block) if block
141
+ configure(xscrollcommand: block) if block
143
142
  end
144
143
 
145
144
  def yscrollcommand(&block)
146
- configure(:yscrollcommand => block) if block
145
+ configure(yscrollcommand: block) if block
147
146
  end
148
-
149
147
  end
150
148
  end
151
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # This command provides a Tcl interface to the X selection mechanism and
3
4
  # implements the full selection functionality described in the X Inter-Client
@@ -7,11 +8,11 @@ module Tk
7
8
  # clipboard command may also be used.
8
9
  module Selection
9
10
  def selection_clear(options = {})
10
- Selection.clear({displayof: self}.merge(options))
11
+ Selection.clear({ displayof: self }.merge(options))
11
12
  end
12
13
 
13
14
  def selection_get(options = {})
14
- Selection.get({displayof: self}.merge(options))
15
+ Selection.get({ displayof: self }.merge(options))
15
16
  end
16
17
 
17
18
  def selection_handle(options = {}, &command)
@@ -120,7 +121,7 @@ module Tk
120
121
 
121
122
  if cmd = (options[:command] || command)
122
123
  command = register_command(:selection_own, &cmd)
123
- Tk.execute(:selection, :own, {command: command}.merge(options).to_tcl_options)
124
+ Tk.execute(:selection, :own, { command: command }.merge(options).to_tcl_options)
124
125
  else
125
126
  Tk.execute(:selection, :own, options.to_tcl_options)
126
127
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  def self.set_palette(background, *rest)
3
4
  if rest.empty?
@@ -6,4 +7,4 @@ module Tk
6
7
  Tk.execute(:tk_setPalette, background, *rest)
7
8
  end
8
9
  end
9
- end
10
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Manipulate Tk internal state
2
3
  module Tk
3
4
  module TkCmd
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  @library = Variable.new('tk_library')
3
4
 
@@ -79,4 +80,4 @@ module Tk
79
80
  def version
80
81
  @version.to_s
81
82
  end
82
- end
83
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Wait for variable to change or window to be destroyed
3
4
  #
@@ -36,4 +37,4 @@ module Tk
36
37
  Tk.execute_only(:tkwait, :window, name)
37
38
  end
38
39
  end
39
- end
40
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  module Winfo
3
4
  # @see Winfo.atom
@@ -324,7 +325,7 @@ module Tk
324
325
  if None == window
325
326
  Tk.execute(:winfo, :containing, root_x, root_y).to_s?
326
327
  else
327
- Tk.execute(:winfo, :containing, '-displayof', window, root_x, root_y).to_s?
328
+ Tk.execute(:winfo, :containing, '-displayof', window, root_x, root_y)
328
329
  end
329
330
  end
330
331
 
@@ -401,7 +402,7 @@ module Tk
401
402
  # If the geometry manager is a widget, such as canvases or text, the name
402
403
  # is the widget's class command, such as canvas.
403
404
  def manager(window)
404
- Tk.execute(:winfo, :manager, window).to_s?
405
+ Tk.execute(:winfo, :manager, window)
405
406
  end
406
407
 
407
408
  # Returns window's name (i.e. its name within its parent, as opposed to its
@@ -414,7 +415,7 @@ module Tk
414
415
  # Returns the path name of +window+'s parent, or nil if +window+ is the main
415
416
  # window of the application.
416
417
  def parent(window)
417
- Tk.execute(:winfo, :parent, window).to_s?
418
+ Tk.execute(:winfo, :parent, window)
418
419
  end
419
420
 
420
421
  # Returns the path name of the window whose X identifier is +id+.
@@ -491,7 +492,7 @@ module Tk
491
492
  # in the window given by window.
492
493
  # Color may be specified in any of the forms acceptable for a color option.
493
494
  def rgb(window, color)
494
- Tk.execute(:winfo, :rgb, window, color).to_a(&:to_i)
495
+ Tk.execute(:winfo, :rgb, window, color).split.map(&:to_i)
495
496
  end
496
497
 
497
498
  # Returns a decimal string giving the x-coordinate, in the root window of
@@ -602,16 +603,16 @@ module Tk
602
603
  def visualsavailable(window, includeids = None)
603
604
  if None == includeids
604
605
  list = Tk.execute(:winfo, :visualsavailable, window).to_a
605
- list.uniq.map{|string|
606
+ list.uniq.map do |string|
606
607
  klass, depth = string.split
607
608
  [klass, depth.to_i]
608
- }
609
+ end
609
610
  else
610
611
  list = Tk.execute(:winfo, :visualsavailable, window, :includeids).to_a
611
- list.uniq.map{|string|
612
+ list.uniq.map do |string|
612
613
  klass, depth, id = string.split
613
614
  [klass, depth.to_i, id]
614
- }
615
+ end
615
616
  end
616
617
  end
617
618