ffi-tk 2009.12.14 → 2010.01

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 (42) hide show
  1. data/.gitignore +1 -0
  2. data/AUTHORS +5 -0
  3. data/CHANGELOG +340 -192
  4. data/MANIFEST +5 -0
  5. data/README.md +3 -4
  6. data/Rakefile +1 -1
  7. data/example/tile/themes.rb +13 -0
  8. data/ffi-tk.gemspec +6 -6
  9. data/lib/ffi-tk/command/bind.rb +21 -4
  10. data/lib/ffi-tk/command/bindtags.rb +6 -2
  11. data/lib/ffi-tk/command/clipboard.rb +7 -2
  12. data/lib/ffi-tk/command/event.rb +2 -2
  13. data/lib/ffi-tk/command/get_open_file.rb +4 -2
  14. data/lib/ffi-tk/command/get_save_file.rb +4 -2
  15. data/lib/ffi-tk/command/grab.rb +2 -2
  16. data/lib/ffi-tk/command/grid.rb +7 -7
  17. data/lib/ffi-tk/command/place.rb +2 -6
  18. data/lib/ffi-tk/command/scrollable.rb +19 -19
  19. data/lib/ffi-tk/command/selection.rb +3 -3
  20. data/lib/ffi-tk/command/tk_cmd.rb +4 -3
  21. data/lib/ffi-tk/command/winfo.rb +2 -2
  22. data/lib/ffi-tk/core_extensions.rb +41 -14
  23. data/lib/ffi-tk/event/data.rb +40 -10
  24. data/lib/ffi-tk/event/handler.rb +11 -2
  25. data/lib/ffi-tk/ffi/tcl/interp.rb +3 -0
  26. data/lib/ffi-tk/ffi/tcl.rb +1 -0
  27. data/lib/ffi-tk/ffi/tk.rb +33 -0
  28. data/lib/ffi-tk/tk.rb +2 -2
  29. data/lib/ffi-tk/version.rb +3 -0
  30. data/lib/ffi-tk/widget/canvas.rb +11 -7
  31. data/lib/ffi-tk/widget/checkbutton.rb +3 -3
  32. data/lib/ffi-tk/widget/listbox.rb +3 -3
  33. data/lib/ffi-tk/widget/menu.rb +5 -6
  34. data/lib/ffi-tk/widget/panedwindow.rb +95 -69
  35. data/lib/ffi-tk/widget/text.rb +43 -11
  36. data/lib/ffi-tk/widget/tile/notebook.rb +17 -10
  37. data/lib/ffi-tk/widget/tile/panedwindow.rb +53 -1
  38. data/lib/ffi-tk/widget/tile/sizegrip.rb +2 -2
  39. data/lib/ffi-tk/widget/tile/style.rb +1 -1
  40. data/lib/ffi-tk/widget/tile/treeview.rb +6 -2
  41. data/spec/ffi-tk/command/bind.rb +25 -0
  42. metadata +8 -3
@@ -4,6 +4,7 @@ module Tk
4
4
  data = Data::PROPERTIES.transpose[0].join(' ').gsub(/%/, '%%')
5
5
  @callback = %(bind %s %s { ::RubyFFI::event %d %s #{data} })
6
6
  @store = []
7
+ @bound = {}
7
8
  @mutex = Mutex.new
8
9
 
9
10
  module_function
@@ -27,6 +28,7 @@ module Tk
27
28
  def register(tag, sequence, &block)
28
29
  id = register_block(block)
29
30
  Tk.interp.eval(@callback % [tag, sequence, id, sequence])
31
+ @bound[[tag, sequence]] = block
30
32
  id
31
33
  end
32
34
 
@@ -36,8 +38,15 @@ module Tk
36
38
  id
37
39
  end
38
40
 
39
- def unregister(id)
40
- @store[id] = nil
41
+ def unregister(tag, sequence)
42
+ key = [tag, sequence]
43
+
44
+ if block = @bound[key]
45
+ Tk.execute(:bind, tag, sequence, nil)
46
+ id = @store.index(block)
47
+ @store[id] = nil
48
+ @bound.delete(key)
49
+ end
41
50
  end
42
51
  end
43
52
  end
@@ -30,6 +30,9 @@ module FFI
30
30
  Tcl.new_string_obj(ruby_obj, ruby_obj.bytesize)
31
31
  when Fixnum
32
32
  Tcl.new_int_obj(ruby_obj)
33
+ when Exception
34
+ string = [ruby_obj.message, *ruby_obj.backtrace].join("\n")
35
+ Tcl.new_string_obj(string, string.bytesize)
33
36
  else
34
37
  if ruby_obj.respond_to?(:to_tcl)
35
38
  ruby_obj.to_tcl
@@ -37,6 +37,7 @@ module FFI
37
37
  attach_function :Tcl_ParseVar, [Interp, :pointer, :pointer], :pointer
38
38
  attach_function :Tcl_SetObjResult, [Interp, Obj], :void
39
39
  attach_function :Tcl_WaitForEvent, [TclTime], :int
40
+ attach_function :Tcl_SetMaxBlockTime, [TclTime], :void
40
41
 
41
42
  callback :obj_cmd_proc, [:int, Interp, :int, :pointer], :int
42
43
  callback :obj_delete_proc, [:int], :void
data/lib/ffi-tk/ffi/tk.rb CHANGED
@@ -3,11 +3,44 @@ module FFI
3
3
  extend FFI::Library
4
4
  ffi_lib 'libtk8.5.so', 'libtk.so', *::Tk::LIBPATH[:tk]
5
5
 
6
+ class XColor < FFI::Struct
7
+ layout(
8
+ :pixel, :ulong,
9
+ :red, :ushort,
10
+ :green, :ushort,
11
+ :blue, :ushort,
12
+ :flags, :char,
13
+ :pad, :char
14
+ )
15
+
16
+ def red
17
+ self[:red]
18
+ end
19
+
20
+ def green
21
+ self[:green]
22
+ end
23
+
24
+ def blue
25
+ self[:blue]
26
+ end
27
+ end
28
+
29
+ # This is opaque
30
+ class Window < FFI::Struct
31
+ end
32
+
6
33
  attach_function :Tk_Init, [:pointer], :int
34
+ attach_function :Tk_MainWindow, [Tcl::Interp], Window
35
+ attach_function :Tk_GetColor, [Tcl::Interp, Window, name = :string], XColor
7
36
  attach_function :Tk_MainLoop, [], :void
8
37
 
9
38
  module_function
10
39
 
40
+ def get_color(interp, string)
41
+ XColor.new(Tk_GetColor(interp, Tk_MainWindow(interp), string))
42
+ end
43
+
11
44
  def mainloop
12
45
  if ::Tk::RUN_EVENTLOOP_ON_MAIN_THREAD
13
46
  Tk_MainLoop()
data/lib/ffi-tk/tk.rb CHANGED
@@ -124,7 +124,7 @@ module Tk
124
124
 
125
125
  return BREAK
126
126
  rescue => ex
127
- FFI::Tcl::Interp.new(interp).obj_result = ex.message
127
+ FFI::Tcl::Interp.new(interp).obj_result = ex
128
128
  return ERROR
129
129
  end
130
130
  TCL_CALLBACK = method(:tcl_callback)
@@ -145,7 +145,7 @@ module Tk
145
145
 
146
146
  return BREAK
147
147
  rescue => ex
148
- FFI::Tcl::Interp.new(interp).obj_result = ex.message
148
+ FFI::Tcl::Interp.new(interp).obj_result = ex
149
149
  return ERROR
150
150
  end
151
151
  TCL_EVENT = method(:tcl_event)
@@ -0,0 +1,3 @@
1
+ module FFI::Tk
2
+ VERSION = "2010.01"
3
+ end
@@ -163,9 +163,9 @@ module Tk
163
163
  def bind(tag_or_id, sequence = None, &script)
164
164
  unless script
165
165
  if None == sequence
166
- return Tk.execute(:bind, tag_or_id)
166
+ return Tk.execute(tk_pathname, :bind, tag_or_id)
167
167
  else
168
- return Tk.execute(:bind, tag_or_id, sequence)
168
+ return Tk.execute(tk_pathname, :bind, tag_or_id, sequence)
169
169
  end
170
170
  end
171
171
 
@@ -174,9 +174,9 @@ module Tk
174
174
  # unregister_event(name)
175
175
 
176
176
  Event::Handler.register_custom(script) do |id|
177
- code = "%s bind %s %s { ::RubyFFI::event %d '' %s }"
177
+ code = "%s bind %s %s { puts hi\n::RubyFFI::event %d %s %s }"
178
178
  props = Event::Data::PROPERTIES.transpose[0].join(' ')
179
- tcl = code % [tk_pathname, tag_or_id, sequence, id, props]
179
+ tcl = code % [tk_pathname, tag_or_id, sequence, id, sequence, props]
180
180
  Tk.interp.eval(tcl)
181
181
  @events[name] = id
182
182
  end
@@ -372,8 +372,12 @@ module Tk
372
372
  # In most cases it is advisable to follow the focus widget command with the
373
373
  # focus command to set the focus window to the canvas (if it was not there
374
374
  # already).
375
- def focus(tag_or_id)
376
- execute_only(:focus, tag_or_id)
375
+ def focus(tag_or_id = None)
376
+ if None == tag_or_id
377
+ execute(:focus)
378
+ else
379
+ execute_only(:focus, tag_or_id)
380
+ end
377
381
  end
378
382
 
379
383
  # Return a list whose elements are the tags associated with the item given
@@ -778,7 +782,7 @@ module Tk
778
782
  # These are the same values passed to scrollbars via the -yscrollcommand
779
783
  # option.
780
784
  def yview
781
- execute(:yview).to_a?(&:to_f)
785
+ execute(:yview)
782
786
  end
783
787
 
784
788
  # Adjusts the view in the window so that fraction of the canvas's area is
@@ -15,7 +15,7 @@ module Tk
15
15
  end
16
16
  end
17
17
 
18
- # Deselects the checkbutton and sets the associated variable to its off
18
+ # Deselects the checkbutton and sets the associated variable to its "off"
19
19
  # value.
20
20
  def deselect
21
21
  execute_only(:deselect)
@@ -36,12 +36,12 @@ module Tk
36
36
  # Tcl command associated with the checkbutton, if there is one.
37
37
  # The return value is the return value from the Tcl command, or an empty
38
38
  # string if there is no command associated with the checkbutton.
39
- # This command is ignored if the checkbut‐ ton's state is disabled.
39
+ # This command is ignored if the checkbutton's state is disabled.
40
40
  def invoke
41
41
  execute_only(:invoke)
42
42
  end
43
43
 
44
- # Selects the checkbutton and sets the associated variable to its on
44
+ # Selects the checkbutton and sets the associated variable to its "on"
45
45
  # value.
46
46
  def select
47
47
  execute_only(:select)
@@ -20,7 +20,7 @@ module Tk
20
20
  # Sets the active element to the one indicated by index.
21
21
  # If index is outside the range of elements in the listbox then the closest
22
22
  # element is activated.
23
- # The active element is drawn as speci‐ fied by -activestyle when the
23
+ # The active element is drawn as specified by -activestyle when the
24
24
  # widget has the input focus, and its index may be retrieved with the index
25
25
  # active.
26
26
  def activate(index)
@@ -100,7 +100,7 @@ module Tk
100
100
  # of this list).
101
101
  # If option is specified with no value, then the command returns a list
102
102
  # describing the one named option (this list will be identical to the
103
- # correspond‐ ing sublist of the value returned if no option is specified).
103
+ # corresponding sublist of the value returned if no option is specified).
104
104
  # If one or more option-value pairs are specified, then the command
105
105
  # modifies the given widget option(s) to have the given value(s); in this
106
106
  # case the command returns an empty string.
@@ -136,7 +136,7 @@ module Tk
136
136
 
137
137
  # This command computes the difference between its x and y arguments and
138
138
  # the x and y arguments to the last scan mark command for the widget.
139
- # It then adjusts the view by 10 times the dif‐ ference in coordinates.
139
+ # It then adjusts the view by 10 times the difference in coordinates.
140
140
  # This command is typically associated with mouse motion events in the
141
141
  # widget, to produce the effect of dragging the list at high speed through
142
142
  # the window.
@@ -44,7 +44,7 @@ module Tk
44
44
  # This option is not available for separator or tear-off entries.
45
45
  # -bitmap value Specifies a bitmap to display in the menu instead of a
46
46
  # textual label, in any of the forms accepted by Tk_GetBitmap.
47
- # This option overrides the -label option (as controlled by the -com‐ pound
47
+ # This option overrides the -label option (as controlled by the -compound
48
48
  # option) but may be reset to an empty string to enable a textual label to
49
49
  # be displayed.
50
50
  # If a -image option has been specified, it overrides -bitmap.
@@ -58,7 +58,7 @@ module Tk
58
58
  # -compound value Specifies whether the menu entry should display both an
59
59
  # image and text, and if so, where the image should be placed relative to
60
60
  # the text.
61
- # Valid values for this option are bottom, cen‐ ter, left, none, right and
61
+ # Valid values for this option are bottom, center, left, none, right and
62
62
  # top. The default value is none, meaning that the button will display
63
63
  # either an image or text, depending on the values of the -image and
64
64
  # -bitmap options.
@@ -122,7 +122,7 @@ module Tk
122
122
  # bindings will refuse to activate or invoke the entry.
123
123
  # In this state the entry is displayed according to the disabledForeground
124
124
  # option for the menu and the background option from the entry.
125
- # This option is not available for separa‐ tor entries.
125
+ # This option is not available for separator entries.
126
126
  # -underline value Specifies the integer index of a character to underline
127
127
  # in the entry.
128
128
  # This option is also queried by the default bindings and used to implement
@@ -255,7 +255,7 @@ module Tk
255
255
  # Unmap the window so that it is no longer displayed.
256
256
  # If a lower-level cascaded menu is posted, unpost that menu.
257
257
  # Returns an empty string.
258
- # This subcommand does not work on Windows and the Mac‐ intosh, as those
258
+ # This subcommand does not work on Windows and the Macintosh, as those
259
259
  # platforms have their own way of unposting menus.
260
260
  def unpost
261
261
  execute(:unpost)
@@ -263,7 +263,6 @@ module Tk
263
263
 
264
264
  # Returns a decimal string giving the x-coordinate within the menu window
265
265
  # of the leftmost pixel in the entry specified by index.
266
- # │
267
266
  def xposition(index)
268
267
  execute(:xposition, index)
269
268
  end
@@ -299,7 +298,7 @@ module Tk
299
298
  # menus. You create a torn-off menu by invoking the tear-off entry at the
300
299
  # top of an existing menu.
301
300
  # The default bindings will create a new menu that is a copy of the
302
- # original menu and leave it perma‐ nently posted as a top-level window.
301
+ # original menu and leave it permanently posted as a top-level window.
303
302
  # The torn-off menu behaves just the same as the original menu.
304
303
  # and unposts the menu.
305
304
  # If the current menu is a top-level menu posted from a menubutton, then
@@ -62,7 +62,7 @@ module Tk
62
62
 
63
63
  # This command computes the difference between the given coordinates and
64
64
  # the coordinates given to the last sash mark command for the given sash.
65
- # It then moves that sash the computed dif‐ ference.
65
+ # It then moves that sash the computed difference.
66
66
  def sash_dragto(index, x, y)
67
67
  execute_only(:sash, :dragto, index, x, y)
68
68
  end
@@ -84,81 +84,107 @@ module Tk
84
84
  execute(:panecget, window, option.to_tcl_option)
85
85
  end
86
86
 
87
- # Query or modify the management options for window.
88
- # If no option is specified, returns a list describing all of the available
89
- # options for pathName (see Tk_ConfigureInfo for information on the format
87
+ # Query or modify the management options for +window+.
88
+ #
89
+ # If no +options+ is specified, returns a list describing all of the available
90
+ # options for +window+ (see Tk_ConfigureInfo for information on the format
90
91
  # of this list).
91
- # If option is specified with no value, then the command returns a list
92
+ #
93
+ # If +options+ is specified with no value, then the command returns a list
92
94
  # describing the one named option (this list will be identical to the
93
95
  # corresponding sublist of the value returned if no option is specified).
94
- # If one or more option-value pairs are specified, then the command
95
- # modifies the given widget option(s) to have the given value(s); in this
96
- # case the command returns an empty string.
97
- # The following options are supported: -after window Insert the window
98
- # after the window specified.
99
- # window should be the name of a window already managed by pathName.
100
- # -before window Insert the window before the window specified.
101
- # window should be the name of a window already managed by pathName.
102
- # -height size Specify a height for the window.
103
- # The height will be the outer dimension of the window including its
104
- # border, if any.
105
- # If size is an empty string, or if -height is not specified, then the
106
- # height requested internally by the window will be used initially; the
107
- # height may later be adjusted by the movement of sashes in the
108
- # panedwindow. Size may be any value accepted by Tk_GetPixels.
109
- # -hide boolean Controls the visibility of a pane.
110
- # When the boolean is true (according to Tcl_GetBoolean) the pane will not
111
- # be visible, but it will still be maintained in the list of panes.
112
- # -minsize n Specifies that the size of the window cannot be made less
113
- # than n.
114
- # This constraint only affects the size of the widget in the paned
115
- # dimension the x dimension for horizontal panedwin‐ dows, the y
116
- # dimension for vertical panedwindows.
117
- # May be any value accepted by Tk_GetPixels.
118
- # -padx n Specifies a non-negative value indicating how much extra space to
119
- # leave on each side of the window in the X-direction.
120
- # The value may have any of the forms accepted by Tk_GetPixels.
121
- # -pady n Specifies a non-negative value indicating how much extra space to
122
- # leave on each side of the window in the Y-direction.
123
- # The value may have any of the forms accepted by Tk_GetPixels.
124
- # -sticky style If a window's pane is larger than the requested dimensions
125
- # of the window, this option may be used to position (or stretch) the
126
- # window within its pane.
127
- # Style is a string that contains zero or more of the characters n, s, e or
128
- # w. The string can optionally contains spaces or commas, but they are
129
- # ignored. Each letter refers to a side (north, south, east, or west) that
130
- # the window will “stick” to.
131
- # If both n and s (or e and w) are specified, the window will be stretched
132
- # to fill the entire height (or width) of its cavity.
133
- # -stretch when Controls how extra space is allocated to each of the panes.
134
- # When is one of always, first, last, middle, and never.
135
- # The panedwindow will calculate the required size of all its panes.
136
- # Any remaining (or deficit) space will be distributed to those panes
137
- # marked for stretching.
138
- # The space will be distributed based on each panes current ratio of the
139
- # whole. The when values have the following definition: always │ This
140
- # pane will always stretch.
141
- # first │ Only if this pane is the first pane (left-most or top-most)
142
- # will it stretch.
143
- # │ last │ Only if this pane is the last pane (right-most or bottom-most)
144
- # will it stretch.
145
- # This is the default value.
146
- # │ middle │ Only if this pane is not the first or last pane will it
147
- # stretch. never This pane will never stretch.
148
- # -width size Specify a width for the window.
149
- # The width will be the outer dimension of the window including its border,
150
- # if any.
151
- # If size is an empty string, or if -width is not specified, then the width
152
- # requested internally by the window will be used initially; the width may
153
- # later be adjusted by the movement of sashes in the panedwindow.
154
- # Size may be any value accepted by Tk_Get‐ Pixels.
96
+ #
97
+ # If one or more option-value pairs are specified, then the command modifies
98
+ # the given widget option(s) to have the given value(s); in this case the
99
+ # command returns an empty string.
100
+ #
101
+ # The following options are supported:
102
+ # :after window
103
+ # Insert the window after the window specified.
104
+ # window should be the name of a window already managed by +window+.
105
+ #
106
+ # :before window
107
+ # Insert the window before the window specified.
108
+ # window should be the name of a window already managed by +window+.
109
+ #
110
+ # :height size
111
+ # Specify a height for the window.
112
+ # The height will be the outer dimension of the window including its
113
+ # border, if any.
114
+ # If size is an empty string, or if -height is not specified, then the
115
+ # height requested internally by the window will be used initially; the
116
+ # height may later be adjusted by the movement of sashes in the
117
+ # panedwindow. Size may be any value accepted by Tk_GetPixels.
118
+ #
119
+ # :hide boolean
120
+ # Controls the visibility of a pane.
121
+ # When the boolean is true (according to Tcl_GetBoolean) the pane will
122
+ # not be visible, but it will still be maintained in the list of panes.
123
+ #
124
+ # :minsize n
125
+ # Specifies that the size of the window cannot be made less than n.
126
+ # This constraint only affects the size of the widget in the paned
127
+ # dimension -- the x dimension for horizontal panedwindows, the y
128
+ # dimension for vertical panedwindows.
129
+ # May be any value accepted by Tk_GetPixels.
130
+ #
131
+ # :padx n
132
+ # Specifies a non-negative value indicating how much extra space to
133
+ # leave on each side of the window in the X-direction.
134
+ # The value may have any of the forms accepted by Tk_GetPixels.
135
+ #
136
+ # :pady n
137
+ # Specifies a non-negative value indicating how much extra space to
138
+ # leave on each side of the window in the Y-direction.
139
+ # The value may have any of the forms accepted by Tk_GetPixels.
140
+ # :sticky style
141
+ # If a window's pane is larger than the requested dimensions of the
142
+ # window, this option may be used to position (or stretch) the window
143
+ # within its pane.
144
+ # Style is a string that contains zero or more of the characters n, s, e
145
+ # or w.
146
+ # The string can optionally contains spaces or commas, but they are
147
+ # ignored. Each letter refers to a side (north, south, east, or west)
148
+ # that the window will "stick" to.
149
+ # If both n and s (or e and w) are specified, the window will be
150
+ # stretched to fill the entire height (or width) of its cavity.
151
+ # :stretch when
152
+ # Controls how extra space is allocated to each of the panes.
153
+ # When is one of always, first, last, middle, and never.
154
+ # The panedwindow will calculate the required size of all its panes.
155
+ # Any remaining (or deficit) space will be distributed to those panes
156
+ # marked for stretching.
157
+ # The space will be distributed based on each panes current ratio of the
158
+ # whole.
159
+ # The when values have the following definition:
160
+ # :always
161
+ # This pane will always stretch.
162
+ # :first
163
+ # Only if this pane is the first pane (left-most or top-most) will
164
+ # it stretch.
165
+ # :last
166
+ # Only if this pane is the last pane (right-most or bottom-most)
167
+ # will it stretch. This is the default value.
168
+ # :middle
169
+ # Only if this pane is not the first or last pane will it stretch.
170
+ # :never
171
+ # This pane will never stretch.
172
+ #
173
+ # :width size
174
+ # Specify a width for the window.
175
+ # The width will be the outer dimension of the window including its
176
+ # border, if any.
177
+ # If size is an empty string, or if -width is not specified, then the
178
+ # width requested internally by the window will be used initially; the
179
+ # width may later be adjusted by the movement of sashes in the
180
+ # panedwindow. Size may be any value accepted by Tk_GetPixels.
155
181
  def paneconfigure(window, options = None)
156
182
  common_configure([:paneconfigure, window], options)
157
183
  end
158
184
 
159
- # Returns an ordered list of the widgets managed by pathName.
160
- def panes
161
- execute(:panes).to_a
185
+ # Returns an ordered list of the widgets managed by +window+.
186
+ def panes(window = None)
187
+ execute(:panes, window).to_a
162
188
  end
163
189
  end
164
190
  end
@@ -201,18 +201,22 @@ module Tk
201
201
  indices = [given_index]
202
202
 
203
203
  while arg = arguments.shift
204
- case arg.to_tcl
205
- when '-command'
206
- command = arguments.shift
207
- invocation << ['-command', command]
208
- when /^-(all|image|mark|tag|text|window)$/
209
- invocation << tcl_option(arg)
204
+ if arg.respond_to?(:to_tcl_option)
205
+ case tcl_option = arg.to_tcl_option
206
+ when '-command'
207
+ command = arguments.shift
208
+ invocation << ['-command', command]
209
+ when /^-(?:all|image|mark|tag|text|window)$/
210
+ invocation << tcl_option
211
+ else
212
+ indices.unshift(arg)
213
+ end
210
214
  else
211
215
  indices.unshift(arg)
212
216
  end
213
217
  end
214
218
 
215
- execute('dump', *invocation, *indices)
219
+ execute('dump', *invocation, *indices).to_a.each_slice(3).to_a
216
220
  end
217
221
 
218
222
  # If boolean is not specified, returns the modified flag of the widget.
@@ -330,7 +334,7 @@ module Tk
330
334
  # line is the line number and char is the character number. Index may have
331
335
  # any of the forms described under INDICES above.
332
336
  def index(index)
333
- execute('index', index)
337
+ execute('index', index).to_s
334
338
  end
335
339
 
336
340
  # Inserts all of the chars arguments just before the character at index.
@@ -655,7 +659,7 @@ module Tk
655
659
  # and the substitutions performed on script before invoking it.
656
660
  # If all arguments are specified then a new binding is created, replacing
657
661
  # any existing binding for the same sequence and tagName (if the first
658
- # character of script is “+” then script augments an existing binding
662
+ # character of script is "+" then script augments an existing binding
659
663
  # rather than replacing it).
660
664
  # In this case the return value is an empty string.
661
665
  # If script is omitted then the command returns the script associated
@@ -765,8 +769,8 @@ module Tk
765
769
  # active at the character position given by index.
766
770
  # If index is omitted, then the return value will describe all of the tags
767
771
  # that exist for the text (this includes all tags that have been named in a
768
- # pathName tag widget command but have not been deleted by a pathName
769
- # tag delete widget command, even if no characters are currently marked
772
+ # "pathName tag" widget command but have not been deleted by a "pathName
773
+ # tag delete" widget command, even if no characters are currently marked
770
774
  # with the tag).
771
775
  # The list will be sorted in order from lowest priority to highest
772
776
  # priority.
@@ -889,5 +893,33 @@ module Tk
889
893
  def paste
890
894
  Tk.execute(:tk_textPaste, self)
891
895
  end
896
+
897
+ def tk_prev_word_pos(start)
898
+ Tk.execute('tk::TextPrevPos', self, start, 'tcl_startOfPreviousWord').to_s
899
+ end
900
+
901
+ def tk_next_word_pos(start)
902
+ Tk.execute('tk::TextNextPos', self, start, 'tcl_startOfNextWord').to_s
903
+ end
904
+
905
+ def tk_next_word_pos_end(start)
906
+ Tk.execute('tk::TextNextWord', self, start).to_s
907
+ end
908
+
909
+ def tk_prev_line_pos(count)
910
+ Tk.execute('tk::TextUpDownLine', self, -count.abs).to_s
911
+ end
912
+
913
+ def tk_next_line_pos(count)
914
+ Tk.execute('tk::TextUpDownLine', self, count).to_s
915
+ end
916
+
917
+ def tk_prev_page_pos(count)
918
+ Tk.execute('tk::TextScrollPages', self, -count.abs).to_s
919
+ end
920
+
921
+ def tk_next_page_pos(count)
922
+ Tk.execute('tk::TextScrollPages', self, count).to_s
923
+ end
892
924
  end
893
925
  end
@@ -38,17 +38,20 @@ module Tk
38
38
  # the string end, an integer index, or the name of a managed subwindow.
39
39
  # If subwindow is already managed by the notebook, moves it to
40
40
  # the specified position.
41
- def insert(pos, window, options)
42
- execute_only(:insert, pos, window, options.to_tcl_options)
41
+ def insert(pos, window, options = {})
42
+ execute_only(:insert, pos, window, options.to_tcl_options)
43
43
  end
44
44
 
45
45
  # Selects the specified tab. The associated slave window
46
46
  # will be displayed, and the previously-selected window
47
47
  # (if different) is unmapped. If tabid is omitted, returns
48
48
  # the widget name of the currently selected pane.
49
- def select(window)
50
- execute_only(:select, window)
51
- window.tk_pathname
49
+ def select(window = None)
50
+ if None == window
51
+ execute(:select)
52
+ else
53
+ execute_only(:select, window)
54
+ end
52
55
  end
53
56
 
54
57
  # Remove the pane containing window from the panedwindow.
@@ -57,14 +60,18 @@ module Tk
57
60
  execute_only(:forget, window, *windows)
58
61
  end
59
62
 
60
- def hide(window)
61
- execute_only(:hide, window)
63
+ # Hides the tab specified by +tabid+.
64
+ # The tab will not be displayed, but the associated window remains managed
65
+ # by the notebook and its configuration remembered.
66
+ # Hidden tabs may be restored with the add command.
67
+ def hide(tabid)
68
+ execute_only(:hide, tabid)
62
69
  end
63
70
 
64
- # Returns the numeric index of the tab specified by tabid,
71
+ # Returns the numeric index of the tab specified by +tabid+,
65
72
  # or the total number of tabs if tabid is the string 'end'.
66
- def index(window)
67
- execute(:index, window).to_i
73
+ def index(tabid)
74
+ execute(:index, tabid).to_i
68
75
  end
69
76
 
70
77
  def identify(x, y)