tk-win 0.2.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (329) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +46 -0
  6. data/VERSION +1 -0
  7. data/lib/tcltk.rb +367 -0
  8. data/lib/tk.rb +5682 -0
  9. data/lib/tk/after.rb +6 -0
  10. data/lib/tk/autoload.rb +760 -0
  11. data/lib/tk/bgerror.rb +29 -0
  12. data/lib/tk/bindtag.rb +138 -0
  13. data/lib/tk/button.rb +31 -0
  14. data/lib/tk/canvas.rb +816 -0
  15. data/lib/tk/canvastag.rb +459 -0
  16. data/lib/tk/checkbutton.rb +32 -0
  17. data/lib/tk/clipboard.rb +75 -0
  18. data/lib/tk/clock.rb +71 -0
  19. data/lib/tk/composite.rb +484 -0
  20. data/lib/tk/console.rb +52 -0
  21. data/lib/tk/dialog.rb +326 -0
  22. data/lib/tk/encodedstr.rb +187 -0
  23. data/lib/tk/entry.rb +120 -0
  24. data/lib/tk/event.rb +562 -0
  25. data/lib/tk/font.rb +2351 -0
  26. data/lib/tk/frame.rb +132 -0
  27. data/lib/tk/grid.rb +279 -0
  28. data/lib/tk/image.rb +275 -0
  29. data/lib/tk/itemconfig.rb +1222 -0
  30. data/lib/tk/itemfont.rb +327 -0
  31. data/lib/tk/kinput.rb +71 -0
  32. data/lib/tk/label.rb +22 -0
  33. data/lib/tk/labelframe.rb +31 -0
  34. data/lib/tk/listbox.rb +284 -0
  35. data/lib/tk/macpkg.rb +80 -0
  36. data/lib/tk/menu.rb +718 -0
  37. data/lib/tk/menubar.rb +137 -0
  38. data/lib/tk/menuspec.rb +456 -0
  39. data/lib/tk/message.rb +24 -0
  40. data/lib/tk/mngfocus.rb +33 -0
  41. data/lib/tk/msgcat.rb +296 -0
  42. data/lib/tk/namespace.rb +551 -0
  43. data/lib/tk/optiondb.rb +377 -0
  44. data/lib/tk/optionobj.rb +212 -0
  45. data/lib/tk/pack.rb +107 -0
  46. data/lib/tk/package.rb +143 -0
  47. data/lib/tk/palette.rb +55 -0
  48. data/lib/tk/panedwindow.rb +260 -0
  49. data/lib/tk/place.rb +128 -0
  50. data/lib/tk/radiobutton.rb +73 -0
  51. data/lib/tk/root.rb +95 -0
  52. data/lib/tk/scale.rb +112 -0
  53. data/lib/tk/scrollable.rb +82 -0
  54. data/lib/tk/scrollbar.rb +183 -0
  55. data/lib/tk/scrollbox.rb +39 -0
  56. data/lib/tk/selection.rb +86 -0
  57. data/lib/tk/spinbox.rb +144 -0
  58. data/lib/tk/tagfont.rb +43 -0
  59. data/lib/tk/text.rb +1604 -0
  60. data/lib/tk/textimage.rb +88 -0
  61. data/lib/tk/textmark.rb +204 -0
  62. data/lib/tk/texttag.rb +321 -0
  63. data/lib/tk/textwindow.rb +154 -0
  64. data/lib/tk/timer.rb +669 -0
  65. data/lib/tk/toplevel.rb +264 -0
  66. data/lib/tk/ttk_selector.rb +98 -0
  67. data/lib/tk/txtwin_abst.rb +39 -0
  68. data/lib/tk/validation.rb +397 -0
  69. data/lib/tk/variable.rb +1799 -0
  70. data/lib/tk/virtevent.rb +139 -0
  71. data/lib/tk/winfo.rb +392 -0
  72. data/lib/tk/winpkg.rb +156 -0
  73. data/lib/tk/wm.rb +552 -0
  74. data/lib/tk/xim.rb +122 -0
  75. data/lib/tkafter.rb +4 -0
  76. data/lib/tkbgerror.rb +4 -0
  77. data/lib/tkcanvas.rb +4 -0
  78. data/lib/tkclass.rb +47 -0
  79. data/lib/tkconsole.rb +4 -0
  80. data/lib/tkdialog.rb +4 -0
  81. data/lib/tkentry.rb +4 -0
  82. data/lib/tkextlib/ICONS.rb +13 -0
  83. data/lib/tkextlib/ICONS/icons.rb +129 -0
  84. data/lib/tkextlib/ICONS/setup.rb +8 -0
  85. data/lib/tkextlib/SUPPORT_STATUS +198 -0
  86. data/lib/tkextlib/blt.rb +189 -0
  87. data/lib/tkextlib/blt/barchart.rb +79 -0
  88. data/lib/tkextlib/blt/bitmap.rb +112 -0
  89. data/lib/tkextlib/blt/busy.rb +83 -0
  90. data/lib/tkextlib/blt/component.rb +2218 -0
  91. data/lib/tkextlib/blt/container.rb +28 -0
  92. data/lib/tkextlib/blt/cutbuffer.rb +23 -0
  93. data/lib/tkextlib/blt/dragdrop.rb +269 -0
  94. data/lib/tkextlib/blt/eps.rb +32 -0
  95. data/lib/tkextlib/blt/graph.rb +67 -0
  96. data/lib/tkextlib/blt/htext.rb +112 -0
  97. data/lib/tkextlib/blt/setup.rb +8 -0
  98. data/lib/tkextlib/blt/spline.rb +23 -0
  99. data/lib/tkextlib/blt/stripchart.rb +74 -0
  100. data/lib/tkextlib/blt/table.rb +412 -0
  101. data/lib/tkextlib/blt/tabnotebook.rb +110 -0
  102. data/lib/tkextlib/blt/tabset.rb +504 -0
  103. data/lib/tkextlib/blt/ted.rb +68 -0
  104. data/lib/tkextlib/blt/tile.rb +25 -0
  105. data/lib/tkextlib/blt/tile/button.rb +16 -0
  106. data/lib/tkextlib/blt/tile/checkbutton.rb +17 -0
  107. data/lib/tkextlib/blt/tile/frame.rb +16 -0
  108. data/lib/tkextlib/blt/tile/label.rb +16 -0
  109. data/lib/tkextlib/blt/tile/radiobutton.rb +17 -0
  110. data/lib/tkextlib/blt/tile/scrollbar.rb +16 -0
  111. data/lib/tkextlib/blt/tile/toplevel.rb +16 -0
  112. data/lib/tkextlib/blt/tree.rb +1058 -0
  113. data/lib/tkextlib/blt/treeview.rb +1287 -0
  114. data/lib/tkextlib/blt/unix_dnd.rb +141 -0
  115. data/lib/tkextlib/blt/vector.rb +256 -0
  116. data/lib/tkextlib/blt/watch.rb +175 -0
  117. data/lib/tkextlib/blt/win_printer.rb +61 -0
  118. data/lib/tkextlib/blt/winop.rb +107 -0
  119. data/lib/tkextlib/bwidget.rb +153 -0
  120. data/lib/tkextlib/bwidget/arrowbutton.rb +21 -0
  121. data/lib/tkextlib/bwidget/bitmap.rb +21 -0
  122. data/lib/tkextlib/bwidget/button.rb +31 -0
  123. data/lib/tkextlib/bwidget/buttonbox.rb +90 -0
  124. data/lib/tkextlib/bwidget/combobox.rb +62 -0
  125. data/lib/tkextlib/bwidget/dialog.rb +194 -0
  126. data/lib/tkextlib/bwidget/dragsite.rb +31 -0
  127. data/lib/tkextlib/bwidget/dropsite.rb +39 -0
  128. data/lib/tkextlib/bwidget/dynamichelp.rb +63 -0
  129. data/lib/tkextlib/bwidget/entry.rb +43 -0
  130. data/lib/tkextlib/bwidget/label.rb +41 -0
  131. data/lib/tkextlib/bwidget/labelentry.rb +80 -0
  132. data/lib/tkextlib/bwidget/labelframe.rb +52 -0
  133. data/lib/tkextlib/bwidget/listbox.rb +361 -0
  134. data/lib/tkextlib/bwidget/mainframe.rb +132 -0
  135. data/lib/tkextlib/bwidget/messagedlg.rb +192 -0
  136. data/lib/tkextlib/bwidget/notebook.rb +166 -0
  137. data/lib/tkextlib/bwidget/pagesmanager.rb +73 -0
  138. data/lib/tkextlib/bwidget/panedwindow.rb +42 -0
  139. data/lib/tkextlib/bwidget/panelframe.rb +67 -0
  140. data/lib/tkextlib/bwidget/passwddlg.rb +44 -0
  141. data/lib/tkextlib/bwidget/progressbar.rb +20 -0
  142. data/lib/tkextlib/bwidget/progressdlg.rb +58 -0
  143. data/lib/tkextlib/bwidget/scrollableframe.rb +40 -0
  144. data/lib/tkextlib/bwidget/scrolledwindow.rb +48 -0
  145. data/lib/tkextlib/bwidget/scrollview.rb +25 -0
  146. data/lib/tkextlib/bwidget/selectcolor.rb +73 -0
  147. data/lib/tkextlib/bwidget/selectfont.rb +91 -0
  148. data/lib/tkextlib/bwidget/separator.rb +20 -0
  149. data/lib/tkextlib/bwidget/setup.rb +8 -0
  150. data/lib/tkextlib/bwidget/spinbox.rb +98 -0
  151. data/lib/tkextlib/bwidget/statusbar.rb +62 -0
  152. data/lib/tkextlib/bwidget/titleframe.rb +33 -0
  153. data/lib/tkextlib/bwidget/tree.rb +500 -0
  154. data/lib/tkextlib/bwidget/widget.rb +129 -0
  155. data/lib/tkextlib/itcl.rb +13 -0
  156. data/lib/tkextlib/itcl/incr_tcl.rb +178 -0
  157. data/lib/tkextlib/itcl/setup.rb +13 -0
  158. data/lib/tkextlib/itk.rb +13 -0
  159. data/lib/tkextlib/itk/incr_tk.rb +446 -0
  160. data/lib/tkextlib/itk/setup.rb +13 -0
  161. data/lib/tkextlib/iwidgets.rb +94 -0
  162. data/lib/tkextlib/iwidgets/buttonbox.rb +121 -0
  163. data/lib/tkextlib/iwidgets/calendar.rb +125 -0
  164. data/lib/tkextlib/iwidgets/canvasprintbox.rb +53 -0
  165. data/lib/tkextlib/iwidgets/canvasprintdialog.rb +38 -0
  166. data/lib/tkextlib/iwidgets/checkbox.rb +130 -0
  167. data/lib/tkextlib/iwidgets/combobox.rb +104 -0
  168. data/lib/tkextlib/iwidgets/dateentry.rb +20 -0
  169. data/lib/tkextlib/iwidgets/datefield.rb +58 -0
  170. data/lib/tkextlib/iwidgets/dialog.rb +20 -0
  171. data/lib/tkextlib/iwidgets/dialogshell.rb +121 -0
  172. data/lib/tkextlib/iwidgets/disjointlistbox.rb +50 -0
  173. data/lib/tkextlib/iwidgets/entryfield.rb +185 -0
  174. data/lib/tkextlib/iwidgets/extbutton.rb +40 -0
  175. data/lib/tkextlib/iwidgets/extfileselectionbox.rb +46 -0
  176. data/lib/tkextlib/iwidgets/extfileselectiondialog.rb +33 -0
  177. data/lib/tkextlib/iwidgets/feedback.rb +35 -0
  178. data/lib/tkextlib/iwidgets/fileselectionbox.rb +46 -0
  179. data/lib/tkextlib/iwidgets/fileselectiondialog.rb +33 -0
  180. data/lib/tkextlib/iwidgets/finddialog.rb +42 -0
  181. data/lib/tkextlib/iwidgets/hierarchy.rb +365 -0
  182. data/lib/tkextlib/iwidgets/hyperhelp.rb +50 -0
  183. data/lib/tkextlib/iwidgets/labeledframe.rb +39 -0
  184. data/lib/tkextlib/iwidgets/labeledwidget.rb +45 -0
  185. data/lib/tkextlib/iwidgets/mainwindow.rb +67 -0
  186. data/lib/tkextlib/iwidgets/menubar.rb +212 -0
  187. data/lib/tkextlib/iwidgets/messagebox.rb +93 -0
  188. data/lib/tkextlib/iwidgets/messagedialog.rb +20 -0
  189. data/lib/tkextlib/iwidgets/notebook.rb +175 -0
  190. data/lib/tkextlib/iwidgets/optionmenu.rb +92 -0
  191. data/lib/tkextlib/iwidgets/panedwindow.rb +134 -0
  192. data/lib/tkextlib/iwidgets/promptdialog.rb +131 -0
  193. data/lib/tkextlib/iwidgets/pushbutton.rb +35 -0
  194. data/lib/tkextlib/iwidgets/radiobox.rb +121 -0
  195. data/lib/tkextlib/iwidgets/scopedobject.rb +24 -0
  196. data/lib/tkextlib/iwidgets/scrolledcanvas.rb +353 -0
  197. data/lib/tkextlib/iwidgets/scrolledframe.rb +59 -0
  198. data/lib/tkextlib/iwidgets/scrolledhtml.rb +58 -0
  199. data/lib/tkextlib/iwidgets/scrolledlistbox.rb +207 -0
  200. data/lib/tkextlib/iwidgets/scrolledtext.rb +568 -0
  201. data/lib/tkextlib/iwidgets/scrolledwidget.rb +20 -0
  202. data/lib/tkextlib/iwidgets/selectionbox.rb +102 -0
  203. data/lib/tkextlib/iwidgets/selectiondialog.rb +92 -0
  204. data/lib/tkextlib/iwidgets/setup.rb +8 -0
  205. data/lib/tkextlib/iwidgets/shell.rb +38 -0
  206. data/lib/tkextlib/iwidgets/spindate.rb +48 -0
  207. data/lib/tkextlib/iwidgets/spinint.rb +30 -0
  208. data/lib/tkextlib/iwidgets/spinner.rb +169 -0
  209. data/lib/tkextlib/iwidgets/spintime.rb +48 -0
  210. data/lib/tkextlib/iwidgets/tabnotebook.rb +181 -0
  211. data/lib/tkextlib/iwidgets/tabset.rb +145 -0
  212. data/lib/tkextlib/iwidgets/timeentry.rb +25 -0
  213. data/lib/tkextlib/iwidgets/timefield.rb +58 -0
  214. data/lib/tkextlib/iwidgets/toolbar.rb +112 -0
  215. data/lib/tkextlib/iwidgets/watch.rb +56 -0
  216. data/lib/tkextlib/pkg_checker.rb +184 -0
  217. data/lib/tkextlib/setup.rb +8 -0
  218. data/lib/tkextlib/tcllib.rb +105 -0
  219. data/lib/tkextlib/tcllib/autoscroll.rb +158 -0
  220. data/lib/tkextlib/tcllib/ctext.rb +160 -0
  221. data/lib/tkextlib/tcllib/cursor.rb +97 -0
  222. data/lib/tkextlib/tcllib/datefield.rb +57 -0
  223. data/lib/tkextlib/tcllib/dialog.rb +84 -0
  224. data/lib/tkextlib/tcllib/getstring.rb +134 -0
  225. data/lib/tkextlib/tcllib/history.rb +73 -0
  226. data/lib/tkextlib/tcllib/ico.rb +146 -0
  227. data/lib/tkextlib/tcllib/ip_entry.rb +75 -0
  228. data/lib/tkextlib/tcllib/panelframe.rb +78 -0
  229. data/lib/tkextlib/tcllib/plotchart.rb +1404 -0
  230. data/lib/tkextlib/tcllib/ruler.rb +65 -0
  231. data/lib/tkextlib/tcllib/screenruler.rb +68 -0
  232. data/lib/tkextlib/tcllib/scrollwin.rb +61 -0
  233. data/lib/tkextlib/tcllib/setup.rb +8 -0
  234. data/lib/tkextlib/tcllib/style.rb +61 -0
  235. data/lib/tkextlib/tcllib/superframe.rb +51 -0
  236. data/lib/tkextlib/tcllib/swaplist.rb +150 -0
  237. data/lib/tkextlib/tcllib/tablelist.rb +28 -0
  238. data/lib/tkextlib/tcllib/tablelist_core.rb +1072 -0
  239. data/lib/tkextlib/tcllib/tablelist_tile.rb +43 -0
  240. data/lib/tkextlib/tcllib/tkpiechart.rb +314 -0
  241. data/lib/tkextlib/tcllib/tooltip.rb +104 -0
  242. data/lib/tkextlib/tcllib/widget.rb +82 -0
  243. data/lib/tkextlib/tclx.rb +13 -0
  244. data/lib/tkextlib/tclx/setup.rb +8 -0
  245. data/lib/tkextlib/tclx/tclx.rb +74 -0
  246. data/lib/tkextlib/tile.rb +449 -0
  247. data/lib/tkextlib/tile/dialog.rb +102 -0
  248. data/lib/tkextlib/tile/setup.rb +8 -0
  249. data/lib/tkextlib/tile/sizegrip.rb +32 -0
  250. data/lib/tkextlib/tile/style.rb +336 -0
  251. data/lib/tkextlib/tile/tbutton.rb +34 -0
  252. data/lib/tkextlib/tile/tcheckbutton.rb +38 -0
  253. data/lib/tkextlib/tile/tcombobox.rb +55 -0
  254. data/lib/tkextlib/tile/tentry.rb +49 -0
  255. data/lib/tkextlib/tile/tframe.rb +34 -0
  256. data/lib/tkextlib/tile/tlabel.rb +34 -0
  257. data/lib/tkextlib/tile/tlabelframe.rb +38 -0
  258. data/lib/tkextlib/tile/tmenubutton.rb +38 -0
  259. data/lib/tkextlib/tile/tnotebook.rb +147 -0
  260. data/lib/tkextlib/tile/tpaned.rb +245 -0
  261. data/lib/tkextlib/tile/tprogressbar.rb +57 -0
  262. data/lib/tkextlib/tile/tradiobutton.rb +38 -0
  263. data/lib/tkextlib/tile/treeview.rb +1306 -0
  264. data/lib/tkextlib/tile/tscale.rb +56 -0
  265. data/lib/tkextlib/tile/tscrollbar.rb +63 -0
  266. data/lib/tkextlib/tile/tseparator.rb +34 -0
  267. data/lib/tkextlib/tile/tsquare.rb +30 -0
  268. data/lib/tkextlib/tkDND.rb +18 -0
  269. data/lib/tkextlib/tkDND/setup.rb +8 -0
  270. data/lib/tkextlib/tkDND/shape.rb +125 -0
  271. data/lib/tkextlib/tkDND/tkdnd.rb +182 -0
  272. data/lib/tkextlib/tkHTML.rb +13 -0
  273. data/lib/tkextlib/tkHTML/htmlwidget.rb +453 -0
  274. data/lib/tkextlib/tkHTML/setup.rb +8 -0
  275. data/lib/tkextlib/tkimg.rb +36 -0
  276. data/lib/tkextlib/tkimg/bmp.rb +33 -0
  277. data/lib/tkextlib/tkimg/gif.rb +33 -0
  278. data/lib/tkextlib/tkimg/ico.rb +33 -0
  279. data/lib/tkextlib/tkimg/jpeg.rb +33 -0
  280. data/lib/tkextlib/tkimg/pcx.rb +33 -0
  281. data/lib/tkextlib/tkimg/pixmap.rb +44 -0
  282. data/lib/tkextlib/tkimg/png.rb +33 -0
  283. data/lib/tkextlib/tkimg/ppm.rb +33 -0
  284. data/lib/tkextlib/tkimg/ps.rb +33 -0
  285. data/lib/tkextlib/tkimg/setup.rb +8 -0
  286. data/lib/tkextlib/tkimg/sgi.rb +33 -0
  287. data/lib/tkextlib/tkimg/sun.rb +33 -0
  288. data/lib/tkextlib/tkimg/tga.rb +33 -0
  289. data/lib/tkextlib/tkimg/tiff.rb +33 -0
  290. data/lib/tkextlib/tkimg/window.rb +33 -0
  291. data/lib/tkextlib/tkimg/xbm.rb +33 -0
  292. data/lib/tkextlib/tkimg/xpm.rb +33 -0
  293. data/lib/tkextlib/tktable.rb +14 -0
  294. data/lib/tkextlib/tktable/setup.rb +8 -0
  295. data/lib/tkextlib/tktable/tktable.rb +966 -0
  296. data/lib/tkextlib/tktrans.rb +14 -0
  297. data/lib/tkextlib/tktrans/setup.rb +8 -0
  298. data/lib/tkextlib/tktrans/tktrans.rb +64 -0
  299. data/lib/tkextlib/treectrl.rb +13 -0
  300. data/lib/tkextlib/treectrl/setup.rb +8 -0
  301. data/lib/tkextlib/treectrl/tktreectrl.rb +2522 -0
  302. data/lib/tkextlib/trofs.rb +13 -0
  303. data/lib/tkextlib/trofs/setup.rb +8 -0
  304. data/lib/tkextlib/trofs/trofs.rb +51 -0
  305. data/lib/tkextlib/version.rb +6 -0
  306. data/lib/tkextlib/vu.rb +48 -0
  307. data/lib/tkextlib/vu/bargraph.rb +61 -0
  308. data/lib/tkextlib/vu/charts.rb +53 -0
  309. data/lib/tkextlib/vu/dial.rb +102 -0
  310. data/lib/tkextlib/vu/pie.rb +286 -0
  311. data/lib/tkextlib/vu/setup.rb +8 -0
  312. data/lib/tkextlib/vu/spinbox.rb +22 -0
  313. data/lib/tkextlib/winico.rb +14 -0
  314. data/lib/tkextlib/winico/setup.rb +8 -0
  315. data/lib/tkextlib/winico/winico.rb +224 -0
  316. data/lib/tkfont.rb +4 -0
  317. data/lib/tkmacpkg.rb +4 -0
  318. data/lib/tkmenubar.rb +4 -0
  319. data/lib/tkmngfocus.rb +4 -0
  320. data/lib/tkpalette.rb +4 -0
  321. data/lib/tkscrollbox.rb +4 -0
  322. data/lib/tktext.rb +4 -0
  323. data/lib/tkvirtevent.rb +4 -0
  324. data/lib/tkwinpkg.rb +4 -0
  325. data/spec/spec.opts +1 -0
  326. data/spec/spec_helper.rb +9 -0
  327. data/spec/tk-win_spec.rb +7 -0
  328. data/tk-win.gemspec +373 -0
  329. metadata +412 -0
@@ -0,0 +1,59 @@
1
+ #
2
+ # tkextlib/iwidgets/scrolledframe.rb
3
+ # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
+ #
5
+
6
+ require 'tk'
7
+ require 'tkextlib/iwidgets.rb'
8
+
9
+ module Tk
10
+ module Iwidgets
11
+ class Scrolledframe < Tk::Iwidgets::Scrolledwidget
12
+ end
13
+ end
14
+ end
15
+
16
+ class Tk::Iwidgets::Scrolledframe
17
+ TkCommandNames = ['::iwidgets::scrolledframe'.freeze].freeze
18
+ WidgetClassName = 'Scrolledframe'.freeze
19
+ WidgetClassNames[WidgetClassName] ||= self
20
+
21
+ def child_site
22
+ window(tk_call(@path, 'childsite'))
23
+ end
24
+
25
+ def justify(dir)
26
+ tk_call(@path, 'justify', dir)
27
+ self
28
+ end
29
+
30
+ def xview(*index)
31
+ if index.size == 0
32
+ list(tk_send_without_enc('xview'))
33
+ else
34
+ tk_send_without_enc('xview', *index)
35
+ self
36
+ end
37
+ end
38
+ def xview_moveto(*index)
39
+ xview('moveto', *index)
40
+ end
41
+ def xview_scroll(*index)
42
+ xview('scroll', *index)
43
+ end
44
+
45
+ def yview(*index)
46
+ if index.size == 0
47
+ list(tk_send_without_enc('yview'))
48
+ else
49
+ tk_send_without_enc('yview', *index)
50
+ self
51
+ end
52
+ end
53
+ def yview_moveto(*index)
54
+ yview('moveto', *index)
55
+ end
56
+ def yview_scroll(*index)
57
+ yview('scroll', *index)
58
+ end
59
+ end
@@ -0,0 +1,58 @@
1
+ #
2
+ # tkextlib/iwidgets/scrolledhtml.rb
3
+ # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
+ #
5
+
6
+ require 'tk'
7
+ require 'tkextlib/iwidgets.rb'
8
+
9
+ module Tk
10
+ module Iwidgets
11
+ class Scrolledhtml < Tk::Iwidgets::Scrolledtext
12
+ end
13
+ end
14
+ end
15
+
16
+ class Tk::Iwidgets::Scrolledhtml
17
+ TkCommandNames = ['::iwidgets::scrolledhtml'.freeze].freeze
18
+ WidgetClassName = 'Scrolledhtml'.freeze
19
+ WidgetClassNames[WidgetClassName] ||= self
20
+
21
+ def __boolval_optkeys
22
+ super() << 'update'
23
+ end
24
+ private :__boolval_optkeys
25
+
26
+ def __strval_optkeys
27
+ super() << 'fontname' << 'link' << 'alink' << 'textbackground'
28
+ end
29
+ private :__strval_optkeys
30
+
31
+ def __font_optkeys
32
+ super() << 'fixedfont'
33
+ end
34
+ private :__font_optkeys
35
+
36
+ def import(href)
37
+ tk_call(@path, 'import', href)
38
+ self
39
+ end
40
+
41
+ def import_link(href)
42
+ tk_call(@path, 'import', '-link', href)
43
+ self
44
+ end
45
+
46
+ def pwd
47
+ tk_call(@path, 'pwd')
48
+ end
49
+
50
+ def render(htmltext, workdir=None)
51
+ tk_call(@path, 'render', htmltext, workdir)
52
+ self
53
+ end
54
+
55
+ def title
56
+ tk_call(@path, 'title')
57
+ end
58
+ end
@@ -0,0 +1,207 @@
1
+ #
2
+ # tkextlib/iwidgets/scrolledlistbox.rb
3
+ # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
+ #
5
+
6
+ require 'tk'
7
+ require 'tk/listbox'
8
+ require 'tkextlib/iwidgets.rb'
9
+
10
+ module Tk
11
+ module Iwidgets
12
+ class Scrolledlistbox < Tk::Iwidgets::Scrolledwidget
13
+ end
14
+ end
15
+ end
16
+
17
+ class Tk::Iwidgets::Scrolledlistbox
18
+ TkCommandNames = ['::iwidgets::scrolledlistbox'.freeze].freeze
19
+ WidgetClassName = 'Scrolledlistbox'.freeze
20
+ WidgetClassNames[WidgetClassName] ||= self
21
+
22
+ def __strval_optkeys
23
+ super() << 'textbackground'
24
+ end
25
+ private :__strval_optkeys
26
+
27
+ def __tkvariable_optkeys
28
+ super() << 'listvariable'
29
+ end
30
+ private :__tkvariable_optkeys
31
+
32
+ def __font_optkeys
33
+ super() << 'textfont'
34
+ end
35
+ private :__font_optkeys
36
+
37
+ ################################
38
+
39
+ def initialize(*args)
40
+ super(*args)
41
+ @listbox = component_widget('listbox')
42
+ end
43
+
44
+ def method_missing(id, *args)
45
+ if @listbox.respond_to?(id)
46
+ @listbox.__send__(id, *args)
47
+ else
48
+ super(id, *args)
49
+ end
50
+ end
51
+
52
+ ################################
53
+
54
+ def clear
55
+ tk_call(@path, 'clear')
56
+ self
57
+ end
58
+
59
+ def get_curselection
60
+ tk_call(@path, 'getcurselection')
61
+ end
62
+
63
+ def justify(dir)
64
+ tk_call(@path, 'justify', dir)
65
+ self
66
+ end
67
+
68
+ def selected_item_count
69
+ number(tk_call(@path, 'selecteditemcount'))
70
+ end
71
+
72
+ def sort(*params, &b)
73
+ # see 'lsort' man page about params
74
+ if b
75
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
76
+ else
77
+ tk_call(@path, 'sort', *params)
78
+ end
79
+ self
80
+ end
81
+ def sort_ascending
82
+ tk_call(@path, 'sort', 'ascending')
83
+ self
84
+ end
85
+ def sort_descending
86
+ tk_call(@path, 'sort', 'descending')
87
+ self
88
+ end
89
+
90
+ #####################################
91
+
92
+ def bbox(index)
93
+ list(tk_send_without_enc('bbox', index))
94
+ end
95
+ def delete(first, last=None)
96
+ tk_send_without_enc('delete', first, last)
97
+ self
98
+ end
99
+ def get(*index)
100
+ _fromUTF8(tk_send_without_enc('get', *index))
101
+ end
102
+ def insert(index, *args)
103
+ tk_send('insert', index, *args)
104
+ self
105
+ end
106
+ def scan_mark(x, y)
107
+ tk_send_without_enc('scan', 'mark', x, y)
108
+ self
109
+ end
110
+ def scan_dragto(x, y)
111
+ tk_send_without_enc('scan', 'dragto', x, y)
112
+ self
113
+ end
114
+ def see(index)
115
+ tk_send_without_enc('see', index)
116
+ self
117
+ end
118
+
119
+ #####################################
120
+
121
+ include TkListItemConfig
122
+
123
+ def tagid(tag)
124
+ if tag.kind_of?(Tk::Itk::Component)
125
+ tag.name
126
+ else
127
+ super(tag)
128
+ end
129
+ end
130
+ private :tagid
131
+
132
+ #####################################
133
+
134
+ def activate(y)
135
+ tk_send_without_enc('activate', y)
136
+ self
137
+ end
138
+ def curselection
139
+ list(tk_send_without_enc('curselection'))
140
+ end
141
+ def get(first, last=nil)
142
+ if last
143
+ # tk_split_simplelist(_fromUTF8(tk_send_without_enc('get', first, last)))
144
+ tk_split_simplelist(tk_send_without_enc('get', first, last),
145
+ false, true)
146
+ else
147
+ _fromUTF8(tk_send_without_enc('get', first))
148
+ end
149
+ end
150
+ def nearest(y)
151
+ tk_send_without_enc('nearest', y).to_i
152
+ end
153
+ def size
154
+ tk_send_without_enc('size').to_i
155
+ end
156
+ def selection_anchor(index)
157
+ tk_send_without_enc('selection', 'anchor', index)
158
+ self
159
+ end
160
+ def selection_clear(first, last=None)
161
+ tk_send_without_enc('selection', 'clear', first, last)
162
+ self
163
+ end
164
+ def selection_includes(index)
165
+ bool(tk_send_without_enc('selection', 'includes', index))
166
+ end
167
+ def selection_set(first, last=None)
168
+ tk_send_without_enc('selection', 'set', first, last)
169
+ self
170
+ end
171
+
172
+ def index(idx)
173
+ tk_send_without_enc('index', idx).to_i
174
+ end
175
+
176
+ #####################################
177
+
178
+ def xview(*index)
179
+ if index.size == 0
180
+ list(tk_send_without_enc('xview'))
181
+ else
182
+ tk_send_without_enc('xview', *index)
183
+ self
184
+ end
185
+ end
186
+ def xview_moveto(*index)
187
+ xview('moveto', *index)
188
+ end
189
+ def xview_scroll(*index)
190
+ xview('scroll', *index)
191
+ end
192
+
193
+ def yview(*index)
194
+ if index.size == 0
195
+ list(tk_send_without_enc('yview'))
196
+ else
197
+ tk_send_without_enc('yview', *index)
198
+ self
199
+ end
200
+ end
201
+ def yview_moveto(*index)
202
+ yview('moveto', *index)
203
+ end
204
+ def yview_scroll(*index)
205
+ yview('scroll', *index)
206
+ end
207
+ end
@@ -0,0 +1,568 @@
1
+ #
2
+ # tkextlib/iwidgets/scrolledtext.rb
3
+ # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
+ #
5
+
6
+ require 'tk'
7
+ require 'tk/text'
8
+ require 'tkextlib/iwidgets.rb'
9
+
10
+ module Tk
11
+ module Iwidgets
12
+ class Scrolledtext < Tk::Iwidgets::Scrolledwidget
13
+ end
14
+ end
15
+ end
16
+
17
+ class Tk::Iwidgets::Scrolledtext
18
+ TkCommandNames = ['::iwidgets::scrolledtext'.freeze].freeze
19
+ WidgetClassName = 'Scrolledtext'.freeze
20
+ WidgetClassNames[WidgetClassName] ||= self
21
+
22
+ def __strval_optkeys
23
+ super() << 'textbackground'
24
+ end
25
+ private :__strval_optkeys
26
+
27
+ def __font_optkeys
28
+ super() << 'textfont'
29
+ end
30
+ private :__font_optkeys
31
+
32
+ ################################
33
+
34
+ def initialize(*args)
35
+ super(*args)
36
+ @text = component_widget('text')
37
+ end
38
+
39
+ def method_missing(id, *args)
40
+ if @text.respond_to?(id)
41
+ @text.__send__(id, *args)
42
+ else
43
+ super(id, *args)
44
+ end
45
+ end
46
+
47
+ ################################
48
+
49
+ def child_site
50
+ window(tk_call(@path, 'childsite'))
51
+ end
52
+
53
+ def clear
54
+ tk_call(@path, 'clear')
55
+ self
56
+ end
57
+
58
+ def import(file, idx=nil)
59
+ if idx
60
+ tk_call(@path, 'import', file, index(idx))
61
+ else
62
+ tk_call(@path, 'import', file)
63
+ end
64
+ self
65
+ end
66
+
67
+ def export(file)
68
+ tk_call(@path, 'export', file)
69
+ self
70
+ end
71
+
72
+ #####################################
73
+
74
+ include TkTextTagConfig
75
+
76
+ def tagid(tag)
77
+ if tag.kind_of?(Tk::Itk::Component)
78
+ tag.name
79
+ else
80
+ super(tag)
81
+ end
82
+ end
83
+ private :tagid
84
+
85
+ def bbox(index)
86
+ list(tk_send('bbox', index))
87
+ end
88
+ def compare(idx1, op, idx2)
89
+ bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
90
+ op, _get_eval_enc_str(idx2)))
91
+ end
92
+
93
+ def debug
94
+ bool(tk_send_without_enc('debug'))
95
+ end
96
+ def debug=(boolean)
97
+ tk_send_without_enc('debug', boolean)
98
+ #self
99
+ boolean
100
+ end
101
+
102
+ def delete(first, last=None)
103
+ tk_send_without_enc('delete', first, last)
104
+ self
105
+ end
106
+
107
+ def dlineinfo(index)
108
+ list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
109
+ end
110
+
111
+ def get(*index)
112
+ _fromUTF8(tk_send_without_enc('get', *index))
113
+ end
114
+ def get_displaychars(*index)
115
+ # Tk8.5 feature
116
+ get('-displaychars', *index)
117
+ end
118
+
119
+ def image_cget_tkstring(index, slot)
120
+ _fromUTF8(tk_send_without_enc('image', 'cget',
121
+ _get_eval_enc_str(index), "-#{slot.to_s}"))
122
+ end
123
+ def image_cget_strict(index, slot)
124
+ case slot.to_s
125
+ when 'text', 'label', 'show', 'data', 'file'
126
+ _fromUTF8(tk_send_without_enc('image', 'cget',
127
+ _get_eval_enc_str(index), "-#{slot}"))
128
+ else
129
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget',
130
+ _get_eval_enc_str(index),
131
+ "-#{slot}")))
132
+ end
133
+ end
134
+ def image_cget(index, slot)
135
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
136
+ image_cget_strict(index, slot)
137
+ else
138
+ begin
139
+ image_cget_strict(index, slot)
140
+ rescue => e
141
+ begin
142
+ if current_image_configinfo.has_key?(slot.to_s)
143
+ # error on known option
144
+ fail e
145
+ else
146
+ # unknown option
147
+ nil
148
+ end
149
+ rescue
150
+ fail e # tag error
151
+ end
152
+ end
153
+ end
154
+ end
155
+
156
+ def image_configure(index, slot, value=None)
157
+ if slot.kind_of? Hash
158
+ _fromUTF8(tk_send_without_enc('image', 'configure',
159
+ _get_eval_enc_str(index),
160
+ *hash_kv(slot, true)))
161
+ else
162
+ _fromUTF8(tk_send_without_enc('image', 'configure',
163
+ _get_eval_enc_str(index),
164
+ "-#{slot}",
165
+ _get_eval_enc_str(value)))
166
+ end
167
+ self
168
+ end
169
+
170
+ def image_configinfo(index, slot = nil)
171
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
172
+ if slot
173
+ case slot.to_s
174
+ when 'text', 'label', 'show', 'data', 'file'
175
+ #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
176
+ conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true)
177
+ else
178
+ #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
179
+ conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true)
180
+ end
181
+ conf[0] = conf[0][1..-1]
182
+ conf
183
+ else
184
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
185
+ # conf = tk_split_simplelist(conflist)
186
+ tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).collect{|conflist|
187
+ conf = tk_split_simplelist(conflist, false, true)
188
+ conf[0] = conf[0][1..-1]
189
+ case conf[0]
190
+ when 'text', 'label', 'show', 'data', 'file'
191
+ else
192
+ if conf[3]
193
+ if conf[3].index('{')
194
+ conf[3] = tk_split_list(conf[3])
195
+ else
196
+ conf[3] = tk_tcl2ruby(conf[3])
197
+ end
198
+ end
199
+ if conf[4]
200
+ if conf[4].index('{')
201
+ conf[4] = tk_split_list(conf[4])
202
+ else
203
+ conf[4] = tk_tcl2ruby(conf[4])
204
+ end
205
+ end
206
+ end
207
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
208
+ conf
209
+ }
210
+ end
211
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
212
+ if slot
213
+ case slot.to_s
214
+ when 'text', 'label', 'show', 'data', 'file'
215
+ #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
216
+ conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true)
217
+ else
218
+ #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
219
+ conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true)
220
+ end
221
+ key = conf.shift[1..-1]
222
+ { key => conf }
223
+ else
224
+ ret = {}
225
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
226
+ # conf = tk_split_simplelist(conflist)
227
+ tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).each{|conflist|
228
+ conf = tk_split_simplelist(conflist, false, true)
229
+ key = conf.shift[1..-1]
230
+ case key
231
+ when 'text', 'label', 'show', 'data', 'file'
232
+ else
233
+ if conf[2]
234
+ if conf[2].index('{')
235
+ conf[2] = tk_split_list(conf[2])
236
+ else
237
+ conf[2] = tk_tcl2ruby(conf[2])
238
+ end
239
+ end
240
+ if conf[3]
241
+ if conf[3].index('{')
242
+ conf[3] = tk_split_list(conf[3])
243
+ else
244
+ conf[3] = tk_tcl2ruby(conf[3])
245
+ end
246
+ end
247
+ end
248
+ if conf.size == 1
249
+ ret[key] = conf[0][1..-1] # alias info
250
+ else
251
+ ret[key] = conf
252
+ end
253
+ }
254
+ ret
255
+ end
256
+ end
257
+ end
258
+
259
+ def current_image_configinfo(index, slot = nil)
260
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
261
+ if slot
262
+ conf = image_configinfo(index, slot)
263
+ {conf[0] => conf[4]}
264
+ else
265
+ ret = {}
266
+ image_configinfo(index).each{|conf|
267
+ ret[conf[0]] = conf[4] if conf.size > 2
268
+ }
269
+ ret
270
+ end
271
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
272
+ ret = {}
273
+ image_configinfo(index, slot).each{|k, conf|
274
+ ret[k] = conf[-1] if conf.kind_of?(Array)
275
+ }
276
+ ret
277
+ end
278
+ end
279
+
280
+ def image_names
281
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'names'))).collect{|elt|
282
+ tk_split_simplelist(tk_send_without_enc('image', 'names'), false, true).collect{|elt|
283
+ tagid2obj(elt)
284
+ }
285
+ end
286
+
287
+ def index(idx)
288
+ tk_send_without_enc('index', _get_eval_enc_str(idx))
289
+ end
290
+
291
+ def insert(index, *args)
292
+ tk_send('insert', index, *args)
293
+ self
294
+ end
295
+
296
+ def mark_names
297
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('mark', 'names'))).collect{|elt|
298
+ tk_split_simplelist(tk_send_without_enc('mark', 'names'), false, true).collect{|elt|
299
+ tagid2obj(elt)
300
+ }
301
+ end
302
+
303
+ def mark_gravity(mark, direction=nil)
304
+ if direction
305
+ tk_send_without_enc('mark', 'gravity',
306
+ _get_eval_enc_str(mark), direction)
307
+ self
308
+ else
309
+ tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark))
310
+ end
311
+ end
312
+
313
+ def mark_set(mark, index)
314
+ tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark),
315
+ _get_eval_enc_str(index))
316
+ self
317
+ end
318
+ alias set_mark mark_set
319
+
320
+ def mark_unset(*marks)
321
+ tk_send_without_enc('mark', 'unset',
322
+ *(marks.collect{|mark| _get_eval_enc_str(mark)}))
323
+ self
324
+ end
325
+ alias unset_mark mark_unset
326
+
327
+ def mark_next(index)
328
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next',
329
+ _get_eval_enc_str(index))))
330
+ end
331
+ alias next_mark mark_next
332
+
333
+ def mark_previous(index)
334
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous',
335
+ _get_eval_enc_str(index))))
336
+ end
337
+ alias previous_mark mark_previous
338
+
339
+ def scan_mark(x, y)
340
+ tk_send_without_enc('scan', 'mark', x, y)
341
+ self
342
+ end
343
+ def scan_dragto(x, y)
344
+ tk_send_without_enc('scan', 'dragto', x, y)
345
+ self
346
+ end
347
+
348
+
349
+ def _ktext_length(txt)
350
+ if TkCore::WITH_ENCODING ### Ruby 1.9 !!!!!!!!!!!!!
351
+ return txt.length
352
+ end
353
+ ###########################
354
+
355
+ if $KCODE !~ /n/i
356
+ return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
357
+ end
358
+
359
+ # $KCODE == 'NONE'
360
+ if JAPANIZED_TK
361
+ tk_call_without_enc('kstring', 'length',
362
+ _get_eval_enc_str(txt)).to_i
363
+ else
364
+ begin
365
+ tk_call_without_enc('encoding', 'convertto', 'ascii',
366
+ _get_eval_enc_str(txt)).length
367
+ rescue StandardError, NameError
368
+ # sorry, I have no plan
369
+ txt.length
370
+ end
371
+ end
372
+ end
373
+ private :_ktext_length
374
+
375
+ def tksearch(*args)
376
+ # call 'search' subcommand of text widget
377
+ # args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
378
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
379
+ if args[0].kind_of?(Array)
380
+ opts = args.shift.collect{|opt| '-' + opt.to_s }
381
+ else
382
+ opts = []
383
+ end
384
+
385
+ opts << '--'
386
+
387
+ ret = tk_send('search', *(opts + args))
388
+ if ret == ""
389
+ nil
390
+ else
391
+ ret
392
+ end
393
+ end
394
+
395
+ def tksearch_with_count(*args)
396
+ # call 'search' subcommand of text widget
397
+ # args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
398
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
399
+ if args[0].kind_of?(Array)
400
+ opts = args.shift.collect{|opt| '-' + opt.to_s }
401
+ else
402
+ opts = []
403
+ end
404
+
405
+ opts << '-count' << args.shift << '--'
406
+
407
+ ret = tk_send('search', *(opts + args))
408
+ if ret == ""
409
+ nil
410
+ else
411
+ ret
412
+ end
413
+ end
414
+
415
+ def search_with_length(pat,start,stop=None)
416
+ pat = pat.chr if pat.kind_of? Integer
417
+ if stop != None
418
+ return ["", 0] if compare(start,'>=',stop)
419
+ txt = get(start,stop)
420
+ if (pos = txt.index(pat))
421
+ match = $&
422
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
423
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
424
+ if pat.kind_of? String
425
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
426
+ return [index(start + " + #{pos} chars"),
427
+ _ktext_length(pat), pat.dup]
428
+ else
429
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
430
+ return [index(start + " + #{pos} chars"),
431
+ _ktext_length(match), match]
432
+ end
433
+ else
434
+ return ["", 0]
435
+ end
436
+ else
437
+ txt = get(start,'end - 1 char')
438
+ if (pos = txt.index(pat))
439
+ match = $&
440
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
441
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
442
+ if pat.kind_of? String
443
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
444
+ return [index(start + " + #{pos} chars"),
445
+ _ktext_length(pat), pat.dup]
446
+ else
447
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
448
+ return [index(start + " + #{pos} chars"),
449
+ _ktext_length(match), match]
450
+ end
451
+ else
452
+ txt = get('1.0','end - 1 char')
453
+ if (pos = txt.index(pat))
454
+ match = $&
455
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
456
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
457
+ if pat.kind_of? String
458
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
459
+ return [index("1.0 + #{pos} chars"),
460
+ _ktext_length(pat), pat.dup]
461
+ else
462
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
463
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
464
+ end
465
+ else
466
+ return ["", 0]
467
+ end
468
+ end
469
+ end
470
+ end
471
+
472
+ def search(pat,start,stop=None)
473
+ search_with_length(pat,start,stop)[0]
474
+ end
475
+
476
+ def rsearch_with_length(pat,start,stop=None)
477
+ pat = pat.chr if pat.kind_of? Integer
478
+ if stop != None
479
+ return ["", 0] if compare(start,'<=',stop)
480
+ txt = get(stop,start)
481
+ if (pos = txt.rindex(pat))
482
+ match = $&
483
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
484
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
485
+ if pat.kind_of? String
486
+ #return [index(stop + " + #{pos} chars"), pat.split('').length]
487
+ return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
488
+ else
489
+ #return [index(stop + " + #{pos} chars"), $&.split('').length]
490
+ return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
491
+ end
492
+ else
493
+ return ["", 0]
494
+ end
495
+ else
496
+ txt = get('1.0',start)
497
+ if (pos = txt.rindex(pat))
498
+ match = $&
499
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
500
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
501
+ if pat.kind_of? String
502
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
503
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
504
+ else
505
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
506
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
507
+ end
508
+ else
509
+ txt = get('1.0','end - 1 char')
510
+ if (pos = txt.rindex(pat))
511
+ match = $&
512
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
513
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
514
+ if pat.kind_of? String
515
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
516
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
517
+ else
518
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
519
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
520
+ end
521
+ else
522
+ return ["", 0]
523
+ end
524
+ end
525
+ end
526
+ end
527
+
528
+ def rsearch(pat,start,stop=None)
529
+ rsearch_with_length(pat,start,stop)[0]
530
+ end
531
+
532
+ def see(index)
533
+ tk_send_without_enc('see', index)
534
+ self
535
+ end
536
+
537
+ ###############################
538
+
539
+ def xview(*index)
540
+ if index.size == 0
541
+ list(tk_send_without_enc('xview'))
542
+ else
543
+ tk_send_without_enc('xview', *index)
544
+ self
545
+ end
546
+ end
547
+ def xview_moveto(*index)
548
+ xview('moveto', *index)
549
+ end
550
+ def xview_scroll(*index)
551
+ xview('scroll', *index)
552
+ end
553
+
554
+ def yview(*index)
555
+ if index.size == 0
556
+ list(tk_send_without_enc('yview'))
557
+ else
558
+ tk_send_without_enc('yview', *index)
559
+ self
560
+ end
561
+ end
562
+ def yview_moveto(*index)
563
+ yview('moveto', *index)
564
+ end
565
+ def yview_scroll(*index)
566
+ yview('scroll', *index)
567
+ end
568
+ end