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
  module Tk
2
3
  class Canvas
3
4
  # Items of type arc appear on the display as arc-shaped regions.
@@ -15,4 +16,4 @@ module Tk
15
16
  )
16
17
  end
17
18
  end
18
- end
19
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Canvas
3
4
  # Items of type bitmap appear on the display as images with two colors,
@@ -10,4 +11,4 @@ module Tk
10
11
  )
11
12
  end
12
13
  end
13
- end
14
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Canvas
3
4
  # Items of type image are used to display images on a canvas.
@@ -7,4 +8,4 @@ module Tk
7
8
  )
8
9
  end
9
10
  end
10
- end
11
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Canvas
3
4
  class Item < Struct.new(:canvas, :id)
@@ -52,9 +53,8 @@ module Tk
52
53
  text: :string,
53
54
  underline: :integer,
54
55
  width: :integer,
55
- width: :integer,
56
56
  window: :pathname
57
- }
57
+ }.freeze
58
58
 
59
59
  def self.create(canvas, type, id)
60
60
  klass = Canvas.const_get(type.to_s.capitalize)
@@ -79,7 +79,7 @@ end
79
79
  end
80
80
 
81
81
  def inspect
82
- "#<%s %d>" % [self.class.name, id]
82
+ '#<%s %d>' % [self.class.name, id]
83
83
  end
84
84
 
85
85
  def cget(option)
@@ -167,4 +167,4 @@ end
167
167
  end
168
168
  end
169
169
  end
170
- end
170
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Canvas
3
4
  # Items of type line appear on the display as one or more connected line
@@ -13,4 +14,4 @@ module Tk
13
14
  )
14
15
  end
15
16
  end
16
- end
17
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Canvas
3
4
  # Items of type oval appear as circular or oval regions on the display.
@@ -12,4 +13,4 @@ module Tk
12
13
  )
13
14
  end
14
15
  end
15
- end
16
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Canvas
3
4
  # Items of type polygon appear as polygonal or curved filled regions on the
@@ -13,4 +14,4 @@ module Tk
13
14
  )
14
15
  end
15
16
  end
16
- end
17
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Canvas
3
4
  # Items of type rectangle appear as rectangular regions on the display.
@@ -12,4 +13,4 @@ module Tk
12
13
  )
13
14
  end
14
15
  end
15
- end
16
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Canvas
3
4
  # A text item displays a string of characters on the screen in one or more
@@ -12,4 +13,4 @@ module Tk
12
13
  )
13
14
  end
14
15
  end
15
- end
16
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Canvas
3
4
  # Items of type window cause a particular window to be displayed at a given
@@ -8,4 +9,4 @@ module Tk
8
9
  )
9
10
  end
10
11
  end
11
- end
12
+ end
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Create and manipulate checkbutton widgets
3
4
  class CheckButton < Button
4
5
  include Cget, Configure
5
6
 
6
- def self.tk_command; 'checkbutton'; end
7
+ def self.tk_command
8
+ 'checkbutton'
9
+ end
7
10
 
8
11
  def initialize(parent = Tk.root, options = None)
9
12
  if block_given?
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # An entry is a widget that displays a one-line text string and allows that
3
4
  # string to be edited using widget methods described below, which are
@@ -21,7 +22,9 @@ module Tk
21
22
  class Entry < Widget
22
23
  include Cget, Configure
23
24
 
24
- def self.tk_command; 'entry'; end
25
+ def self.tk_command
26
+ 'entry'
27
+ end
25
28
 
26
29
  def value
27
30
  get
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Create and manipulate frame widgets
3
4
  # A frame is a simple widget.
@@ -7,6 +8,8 @@ module Tk
7
8
  class Frame < Widget
8
9
  include Cget, Configure
9
10
 
10
- def self.tk_command; 'frame'; end
11
+ def self.tk_command
12
+ 'frame'
13
+ end
11
14
  end
12
15
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # A label is a widget that displays a textual string, bitmap or image.
3
4
  #
@@ -13,7 +14,9 @@ module Tk
13
14
  class Label < Widget
14
15
  include Cget, Configure
15
16
 
16
- def self.tk_command; 'label'; end
17
+ def self.tk_command
18
+ 'label'
19
+ end
17
20
 
18
21
  def value=(string)
19
22
  configure(text: string)
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class LabelFrame < Frame
3
4
  include Cget, Configure
4
5
 
5
- def self.tk_command; 'labelframe'; end
6
+ def self.tk_command
7
+ 'labelframe'
8
+ end
6
9
  end
7
10
  end
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Listbox < Widget
3
4
  include Cget, Configure, Scrollable
4
5
 
5
- def self.tk_command; 'listbox'; end
6
+ def self.tk_command
7
+ 'listbox'
8
+ end
6
9
 
7
10
  def clear
8
11
  delete 0, :end
@@ -14,7 +17,7 @@ module Tk
14
17
 
15
18
  def value=(enumerable)
16
19
  clear
17
- enumerable.each{|element| insert(:end, element) }
20
+ enumerable.each { |element| insert(:end, element) }
18
21
  end
19
22
 
20
23
  # Sets the active element to the one indicated by index.
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Menu < Widget
3
4
  include Cget, Configure
4
5
 
5
- def self.tk_command; 'menu'; end
6
+ def self.tk_command
7
+ 'menu'
8
+ end
6
9
 
7
10
  # Change the state of the entry indicated by index to active and redisplay
8
11
  # it using its active colors.
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class MenuButton < Button
3
4
  include Cget, Configure
4
5
 
5
- def self.tk_command; 'menubutton'; end
6
+ def self.tk_command
7
+ 'menubutton'
8
+ end
6
9
  end
7
10
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  # Create and manipulate message widgets
3
4
  #
@@ -31,6 +32,8 @@ module Tk
31
32
  class Message < Widget
32
33
  include Cget, Configure
33
34
 
34
- def self.tk_command; 'message'; end
35
+ def self.tk_command
36
+ 'message'
37
+ end
35
38
  end
36
39
  end
@@ -1,15 +1,18 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class PanedWindow < Widget
3
4
  include Cget, Configure
4
5
 
5
- def self.tk_command; 'panedwindow'; end
6
+ def self.tk_command
7
+ 'panedwindow'
8
+ end
6
9
 
7
10
  # Add one or more windows to the panedwindow, each in a separate pane.
8
11
  # The arguments consist of the names of one or more windows followed by
9
12
  # pairs of arguments that specify how to manage the windows.
10
13
  # Option may have any of the values accepted by the configure subcommand.
11
14
  def add(window, *arguments)
12
- options, windows = arguments.partition{|arg| arg.respond_to?(:to_tcl_options) }
15
+ options, windows = arguments.partition { |arg| arg.respond_to?(:to_tcl_options) }
13
16
 
14
17
  if option = options.first
15
18
  execute(:add, window, *windows, option.to_tcl_options)
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class RadioButton < Button
3
4
  include Cget, Configure
4
5
 
5
- def self.tk_command; 'radiobutton'; end
6
+ def self.tk_command
7
+ 'radiobutton'
8
+ end
6
9
 
7
10
  # Deselects the radiobutton and sets the associated variable to an empty
8
11
  # string. If this radiobutton was not currently selected, the command has
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Root < Toplevel
3
4
  def initialize
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Scale < Widget
3
4
  include Cget, Configure
4
5
 
5
- def self.tk_command; 'scale'; end
6
+ def self.tk_command
7
+ 'scale'
8
+ end
6
9
 
7
10
  # Returns a list whose elements are the x and y coordinates of the point
8
11
  # along the centerline of the trough that corresponds to value.
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Scrollbar < Widget
3
4
  include Cget, Configure
4
5
 
5
- def self.tk_command; 'scrollbar'; end
6
+ def self.tk_command
7
+ 'scrollbar'
8
+ end
6
9
 
7
10
  # Marks the element indicated by element as active, which causes it to be
8
11
  # displayed as specified by the activeBackground and activeRelief options.
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Spinbox < Widget
3
4
  include Cget, Configure
4
5
 
5
- def self.tk_command; 'spinbox'; end
6
+ def self.tk_command
7
+ 'spinbox'
8
+ end
6
9
 
7
10
  # Returns a list of four numbers describing the bounding box of the
8
11
  # character given by index.
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Tk
2
3
  class Text < Widget
3
4
  include Cget, Configure, Scrollable
4
5
 
5
- def self.tk_command; 'text'; end
6
+ def self.tk_command
7
+ 'text'
8
+ end
6
9
 
7
10
  autoload :Peer, 'ffi-tk/widget/text/peer'
8
11
 
@@ -111,7 +114,7 @@ module Tk
111
114
  # :xpixels, :ypixels` is perfectly valid and will return a list of two
112
115
  # elements.
113
116
  def count(index1, index2, *options)
114
- args = options.map{|option| option.to_tcl_option }
117
+ args = options.map(&:to_tcl_option)
115
118
  execute('count', *args, index1, index2)
116
119
  end
117
120
 
@@ -200,7 +203,10 @@ module Tk
200
203
  invocation = []
201
204
  indices = [given_index]
202
205
 
203
- while arg = arguments.shift
206
+ loop do
207
+ arg = arguments.shift
208
+ break unless arg
209
+
204
210
  if arg.respond_to?(:to_tcl_option)
205
211
  case tcl_option = arg.to_tcl_option
206
212
  when '-command'
@@ -363,7 +369,7 @@ module Tk
363
369
  # markName is set to the given value.
364
370
  def mark_gravity(name, direction = None)
365
371
  if direction == None
366
- execute('mark', 'gravity', name).to_sym?
372
+ execute('mark', 'gravity', name)&.to_sym
367
373
  else
368
374
  execute_only('mark', 'gravity', name, direction)
369
375
  end
@@ -389,7 +395,7 @@ module Tk
389
395
  # after end with respect to the pathName mark next operation.
390
396
  # nil is returned if there are no marks after index.
391
397
  def mark_next(index)
392
- execute('mark', 'next', index).to_sym?
398
+ execute('mark', 'next', index)&.to_sym
393
399
  end
394
400
 
395
401
  # Returns the name of the mark at or before index.
@@ -404,7 +410,7 @@ module Tk
404
410
  # mark information returned by the pathName dump operation.
405
411
  # nil is returned if there are no marks before index.
406
412
  def mark_previous(index)
407
- execute('mark', 'previous', index).to_sym?
413
+ execute('mark', 'previous', index)&.to_sym
408
414
  end
409
415
 
410
416
  # Sets the mark named markName to a position just before the character at
@@ -592,7 +598,7 @@ module Tk
592
598
  switches << :regexp if pattern.class < CoreExtensions::Regexp
593
599
  to = :end if None == to
594
600
 
595
- switches.map!{|switch| switch.to_s.to_tcl_option }
601
+ switches.map! { |switch| switch.to_s.to_tcl_option }
596
602
  switches.uniq!
597
603
 
598
604
  if switches.include?('-all') && switches.delete('-count')
@@ -607,20 +613,20 @@ module Tk
607
613
 
608
614
  if count
609
615
  SEARCH_MUTEX.synchronize do
610
- list = execute(:search, *switches, sep, pattern, from, to).to_a
616
+ list = [*execute(:search, *switches, sep, pattern, from, to)]
611
617
  return list if list.empty?
612
618
  count_value = Tk.execute('set', count)
613
619
  [*list, count_value]
614
620
  end
615
621
  elsif count_all
616
622
  SEARCH_MUTEX.synchronize do
617
- list = execute(:search, *switches, sep, pattern, from, to).to_a
623
+ list = [*execute(:search, *switches, sep, pattern, from, to)]
618
624
  return list if list.empty?
619
625
  count_list = Tk.execute('set', count_all)
620
626
  list.zip(count_list)
621
627
  end
622
628
  else
623
- execute(:search, *switches, sep, pattern, from, to).to_a
629
+ [*execute(:search, *switches, sep, pattern, from, to)]
624
630
  end
625
631
  end
626
632
 
@@ -695,12 +701,10 @@ module Tk
695
701
  # The tag bindings will be invoked first, followed by bindings for the
696
702
  # window as a whole.
697
703
  def tag_bind(tag_name, sequence = None, &script)
698
- unless script
699
- if None == sequence
700
- return Tk.execute(:tag, :bind, tag_name)
701
- else
702
- return Tk.execute(:tag, :bind, tag_name, sequence)
703
- end
704
+ if !script && None == sequence
705
+ return Tk.execute(:tag, :bind, tag_name)
706
+ elsif !script
707
+ return Tk.execute(:tag, :bind, tag_name, sequence)
704
708
  end
705
709
 
706
710
  # create name for command