summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-11 04:51:21 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-11 04:51:21 +0000
commit3514110b89bee5c37e308b4ca887e66dfe841456 (patch)
treed280d8542cc44d1cd1a75e8ec87b1f9d231561b7
parent05f5928c9d0f094d1e7e21a9bd9d8a8fc2f1a805 (diff)
* ext/tk/lib/tk/*: untabify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--ext/tcltklib/extconf.rb84
-rw-r--r--ext/tcltklib/lib/tcltk.rb32
-rw-r--r--ext/tcltklib/sample/sample1.rb4
-rw-r--r--ext/tcltklib/sample/sample2.rb504
-rw-r--r--ext/tcltklib/stubs.c40
-rw-r--r--ext/tcltklib/tcltklib.c4261
-rw-r--r--ext/tk/lib/multi-tk.rb976
-rw-r--r--ext/tk/lib/remote-tk.rb34
-rw-r--r--ext/tk/lib/tk.rb1964
-rw-r--r--ext/tk/lib/tk/canvas.rb372
-rw-r--r--ext/tk/lib/tk/clock.rb24
-rw-r--r--ext/tk/lib/tk/composite.rb328
-rw-r--r--ext/tk/lib/tk/console.rb2
-rw-r--r--ext/tk/lib/tk/dialog.rb60
-rw-r--r--ext/tk/lib/tk/encodedstr.rb48
-rw-r--r--ext/tk/lib/tk/entry.rb6
-rw-r--r--ext/tk/lib/tk/event.rb38
-rw-r--r--ext/tk/lib/tk/font.rb806
-rw-r--r--ext/tk/lib/tk/grid.rb50
-rw-r--r--ext/tk/lib/tk/image.rb34
-rw-r--r--ext/tk/lib/tk/itemconfig.rb1168
-rw-r--r--ext/tk/lib/tk/itemfont.rb184
-rw-r--r--ext/tk/lib/tk/kinput.rb6
-rw-r--r--ext/tk/lib/tk/listbox.rb226
-rw-r--r--ext/tk/lib/tk/menu.rb238
-rw-r--r--ext/tk/lib/tk/menubar.rb20
-rw-r--r--ext/tk/lib/tk/menuspec.rb194
-rw-r--r--ext/tk/lib/tk/msgcat.rb94
-rw-r--r--ext/tk/lib/tk/namespace.rb46
-rw-r--r--ext/tk/lib/tk/optiondb.rb162
-rw-r--r--ext/tk/lib/tk/optionobj.rb148
-rw-r--r--ext/tk/lib/tk/package.rb20
-rw-r--r--ext/tk/lib/tk/palette.rb8
-rw-r--r--ext/tk/lib/tk/panedwindow.rb132
-rw-r--r--ext/tk/lib/tk/place.rb50
-rw-r--r--ext/tk/lib/tk/root.rb22
-rw-r--r--ext/tk/lib/tk/scale.rb12
-rw-r--r--ext/tk/lib/tk/scrollable.rb32
-rw-r--r--ext/tk/lib/tk/scrollbar.rb10
-rw-r--r--ext/tk/lib/tk/scrollbox.rb6
-rw-r--r--ext/tk/lib/tk/selection.rb6
-rw-r--r--ext/tk/lib/tk/spinbox.rb6
-rw-r--r--ext/tk/lib/tk/text.rb994
-rw-r--r--ext/tk/lib/tk/textimage.rb14
-rw-r--r--ext/tk/lib/tk/textmark.rb6
-rw-r--r--ext/tk/lib/tk/texttag.rb60
-rw-r--r--ext/tk/lib/tk/textwindow.rb72
-rw-r--r--ext/tk/lib/tk/timer.rb78
-rw-r--r--ext/tk/lib/tk/toplevel.rb58
-rw-r--r--ext/tk/lib/tk/validation.rb198
-rw-r--r--ext/tk/lib/tk/variable.rb386
-rw-r--r--ext/tk/lib/tk/virtevent.rb32
-rw-r--r--ext/tk/lib/tk/winfo.rb10
-rw-r--r--ext/tk/lib/tk/winpkg.rb32
-rw-r--r--ext/tk/lib/tk/wm.rb206
-rw-r--r--ext/tk/lib/tk/xim.rb60
-rw-r--r--ext/tk/lib/tkclass.rb8
-rw-r--r--ext/tk/lib/tkextlib/ICONS/icons.rb58
-rw-r--r--ext/tk/lib/tkextlib/bwidget.rb12
-rw-r--r--ext/tk/lib/tkextlib/bwidget/dialog.rb14
-rw-r--r--ext/tk/lib/tkextlib/bwidget/listbox.rb10
-rw-r--r--ext/tk/lib/tkextlib/bwidget/messagedlg.rb108
-rw-r--r--ext/tk/lib/tkextlib/bwidget/notebook.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/passwddlg.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/tree.rb22
-rw-r--r--ext/tk/lib/tkextlib/itcl/incr_tcl.rb60
-rw-r--r--ext/tk/lib/tkextlib/itk/incr_tk.rb406
-rw-r--r--ext/tk/lib/tkextlib/iwidgets.rb4
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/calendar.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/entryfield.rb16
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/hierarchy.rb34
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/menubar.rb50
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/notebook.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb12
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb346
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spinner.rb16
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/toolbar.rb2
-rwxr-xr-xext/tk/lib/tkextlib/pkg_checker.rb34
-rw-r--r--ext/tk/lib/tkextlib/tcllib/autoscroll.rb72
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ctext.rb16
-rw-r--r--ext/tk/lib/tkextlib/tcllib/cursor.rb24
-rw-r--r--ext/tk/lib/tkextlib/tcllib/datefield.rb12
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ip_entry.rb10
-rw-r--r--ext/tk/lib/tkextlib/tcllib/plotchart.rb258
-rw-r--r--ext/tk/lib/tkextlib/tcllib/style.rb4
-rw-r--r--ext/tk/lib/tkextlib/tcllib/tkpiechart.rb56
-rw-r--r--ext/tk/lib/tkextlib/tclx/tclx.rb30
-rw-r--r--ext/tk/lib/tkextlib/tile.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkDND/shape.rb96
-rw-r--r--ext/tk/lib/tkextlib/tkDND/tkdnd.rb118
-rw-r--r--ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb6
-rw-r--r--ext/tk/lib/tkextlib/tkimg.rb4
-rw-r--r--ext/tk/lib/tkextlib/tkimg/bmp.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/gif.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/ico.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/jpeg.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/pcx.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/pixmap.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/png.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/ppm.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/ps.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/sgi.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/sun.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/tga.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/tiff.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/window.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/xbm.rb10
-rw-r--r--ext/tk/lib/tkextlib/tkimg/xpm.rb10
-rw-r--r--ext/tk/lib/tkextlib/tktable/tktable.rb172
-rw-r--r--ext/tk/lib/tkextlib/tktrans/tktrans.rb4
-rw-r--r--ext/tk/lib/tkextlib/treectrl/tktreectrl.rb56
-rw-r--r--ext/tk/lib/tkextlib/vu.rb4
-rw-r--r--ext/tk/lib/tkextlib/vu/charts.rb4
-rw-r--r--ext/tk/lib/tkextlib/vu/dial.rb4
-rw-r--r--ext/tk/lib/tkextlib/winico/winico.rb64
-rw-r--r--ext/tk/sample/binding_sample.rb36
-rw-r--r--ext/tk/sample/bindtag_sample.rb74
-rw-r--r--ext/tk/sample/cmd_res_test.rb2
-rw-r--r--ext/tk/sample/demos-en/arrow.rb74
-rw-r--r--ext/tk/sample/demos-en/bind.rb22
-rw-r--r--ext/tk/sample/demos-en/bitmap.rb16
-rw-r--r--ext/tk/sample/demos-en/check.rb2
-rw-r--r--ext/tk/sample/demos-en/check2.rb62
-rw-r--r--ext/tk/sample/demos-en/clrpick.rb6
-rw-r--r--ext/tk/sample/demos-en/cscroll.rb22
-rw-r--r--ext/tk/sample/demos-en/ctext.rb42
-rw-r--r--ext/tk/sample/demos-en/dialog2.rb6
-rw-r--r--ext/tk/sample/demos-en/entry3.rb74
-rw-r--r--ext/tk/sample/demos-en/filebox.rb14
-rw-r--r--ext/tk/sample/demos-en/floor.rb724
-rw-r--r--ext/tk/sample/demos-en/floor2.rb724
-rw-r--r--ext/tk/sample/demos-en/icon.rb14
-rw-r--r--ext/tk/sample/demos-en/image3.rb12
-rw-r--r--ext/tk/sample/demos-en/items.rb148
-rw-r--r--ext/tk/sample/demos-en/label.rb4
-rw-r--r--ext/tk/sample/demos-en/labelframe.rb22
-rw-r--r--ext/tk/sample/demos-en/menu.rb50
-rw-r--r--ext/tk/sample/demos-en/menu84.rb80
-rw-r--r--ext/tk/sample/demos-en/menubu.rb2
-rw-r--r--ext/tk/sample/demos-en/msgbox.rb24
-rw-r--r--ext/tk/sample/demos-en/paned1.rb14
-rw-r--r--ext/tk/sample/demos-en/paned2.rb54
-rw-r--r--ext/tk/sample/demos-en/plot.rb28
-rw-r--r--ext/tk/sample/demos-en/puzzle.rb8
-rw-r--r--ext/tk/sample/demos-en/radio2.rb14
-rw-r--r--ext/tk/sample/demos-en/radio3.rb52
-rw-r--r--ext/tk/sample/demos-en/ruler.rb50
-rw-r--r--ext/tk/sample/demos-en/sayings.rb6
-rw-r--r--ext/tk/sample/demos-en/search.rb78
-rw-r--r--ext/tk/sample/demos-en/spin.rb22
-rw-r--r--ext/tk/sample/demos-en/style.rb30
-rw-r--r--ext/tk/sample/demos-en/text.rb18
-rw-r--r--ext/tk/sample/demos-en/twind.rb138
-rw-r--r--ext/tk/sample/demos-en/twind2.rb244
-rw-r--r--ext/tk/sample/demos-en/unicodeout.rb42
-rw-r--r--ext/tk/sample/demos-en/widget246
-rw-r--r--ext/tk/sample/demos-jp/arrow.rb74
-rw-r--r--ext/tk/sample/demos-jp/bind.rb22
-rw-r--r--ext/tk/sample/demos-jp/bitmap.rb16
-rw-r--r--ext/tk/sample/demos-jp/check.rb2
-rw-r--r--ext/tk/sample/demos-jp/check2.rb62
-rw-r--r--ext/tk/sample/demos-jp/clrpick.rb6
-rw-r--r--ext/tk/sample/demos-jp/cscroll.rb22
-rw-r--r--ext/tk/sample/demos-jp/ctext.rb42
-rw-r--r--ext/tk/sample/demos-jp/dialog2.rb6
-rw-r--r--ext/tk/sample/demos-jp/entry3.rb74
-rw-r--r--ext/tk/sample/demos-jp/filebox.rb14
-rw-r--r--ext/tk/sample/demos-jp/floor.rb724
-rw-r--r--ext/tk/sample/demos-jp/floor2.rb724
-rw-r--r--ext/tk/sample/demos-jp/icon.rb14
-rw-r--r--ext/tk/sample/demos-jp/image3.rb12
-rw-r--r--ext/tk/sample/demos-jp/items.rb148
-rw-r--r--ext/tk/sample/demos-jp/label.rb4
-rw-r--r--ext/tk/sample/demos-jp/labelframe.rb22
-rw-r--r--ext/tk/sample/demos-jp/menu.rb50
-rw-r--r--ext/tk/sample/demos-jp/menu84.rb72
-rw-r--r--ext/tk/sample/demos-jp/menu8x.rb72
-rw-r--r--ext/tk/sample/demos-jp/menubu.rb2
-rw-r--r--ext/tk/sample/demos-jp/msgbox.rb24
-rw-r--r--ext/tk/sample/demos-jp/paned1.rb14
-rw-r--r--ext/tk/sample/demos-jp/paned2.rb56
-rw-r--r--ext/tk/sample/demos-jp/plot.rb28
-rw-r--r--ext/tk/sample/demos-jp/puzzle.rb8
-rw-r--r--ext/tk/sample/demos-jp/radio2.rb14
-rw-r--r--ext/tk/sample/demos-jp/radio3.rb52
-rw-r--r--ext/tk/sample/demos-jp/ruler.rb50
-rw-r--r--ext/tk/sample/demos-jp/sayings.rb6
-rw-r--r--ext/tk/sample/demos-jp/search.rb78
-rw-r--r--ext/tk/sample/demos-jp/spin.rb22
-rw-r--r--ext/tk/sample/demos-jp/style.rb42
-rw-r--r--ext/tk/sample/demos-jp/text.rb18
-rw-r--r--ext/tk/sample/demos-jp/twind.rb144
-rw-r--r--ext/tk/sample/demos-jp/twind2.rb220
-rw-r--r--ext/tk/sample/demos-jp/unicodeout.rb44
-rw-r--r--ext/tk/sample/demos-jp/widget292
-rw-r--r--ext/tk/sample/encstr_usage.rb4
-rw-r--r--ext/tk/sample/menubar2.rb10
-rw-r--r--ext/tk/sample/msgs_rb/ru.msg4
-rw-r--r--ext/tk/sample/multi-ip_sample.rb20
-rw-r--r--ext/tk/sample/multi-ip_sample2.rb2
-rw-r--r--ext/tk/sample/optobj_sample.rb20
-rw-r--r--ext/tk/sample/propagate.rb10
-rw-r--r--ext/tk/sample/remote-ip_sample.rb2
-rw-r--r--ext/tk/sample/remote-ip_sample2.rb18
-rw-r--r--ext/tk/sample/safe-tk.rb66
-rw-r--r--ext/tk/sample/tkalignbox.rb80
-rw-r--r--ext/tk/sample/tkballoonhelp.rb4
-rw-r--r--ext/tk/sample/tkbiff.rb12
-rw-r--r--ext/tk/sample/tkbrowse.rb8
-rw-r--r--ext/tk/sample/tkcombobox.rb40
-rw-r--r--ext/tk/sample/tkextlib/ICONS/viewIcons.rb56
-rw-r--r--ext/tk/sample/tkextlib/bwidget/basic.rb118
-rw-r--r--ext/tk/sample/tkextlib/bwidget/demo.rb138
-rw-r--r--ext/tk/sample/tkextlib/bwidget/dnd.rb16
-rw-r--r--ext/tk/sample/tkextlib/bwidget/manager.rb64
-rw-r--r--ext/tk/sample/tkextlib/bwidget/select.rb82
-rw-r--r--ext/tk/sample/tkextlib/bwidget/tmpldlg.rb180
-rw-r--r--ext/tk/sample/tkextlib/bwidget/tree.rb260
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb16
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb18
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb16
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb16
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb16
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb6
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb6
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb16
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb4
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb82
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb170
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb24
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb6
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb6
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb4
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb6
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb20
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb4
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/shell.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb2
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/watch.rb2
-rw-r--r--ext/tk/sample/tkextlib/tcllib/datefield.rb4
-rw-r--r--ext/tk/sample/tkextlib/tcllib/plotdemos1.rb22
-rw-r--r--ext/tk/sample/tkextlib/tcllib/plotdemos2.rb30
-rw-r--r--ext/tk/sample/tkextlib/tcllib/plotdemos3.rb38
-rw-r--r--ext/tk/sample/tkextlib/tcllib/xyplot.rb2
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/hv.rb68
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/ss.rb52
-rw-r--r--ext/tk/sample/tkextlib/tktable/basic.rb26
-rw-r--r--ext/tk/sample/tkextlib/tktable/buttons.rb40
-rw-r--r--ext/tk/sample/tkextlib/tktable/command.rb74
-rw-r--r--ext/tk/sample/tkextlib/tktable/debug.rb24
-rw-r--r--ext/tk/sample/tkextlib/tktable/dynarows.rb34
-rw-r--r--ext/tk/sample/tkextlib/tktable/maxsize.rb18
-rw-r--r--ext/tk/sample/tkextlib/tktable/spreadsheet.rb56
-rw-r--r--ext/tk/sample/tkextlib/tktable/valid.rb18
-rw-r--r--ext/tk/sample/tkextlib/vu/canvItems.rb68
-rw-r--r--ext/tk/sample/tkextlib/vu/canvSticker.rb4
-rw-r--r--ext/tk/sample/tkextlib/vu/canvSticker2.rb24
-rw-r--r--ext/tk/sample/tkextlib/vu/dial.rb78
-rw-r--r--ext/tk/sample/tkextlib/vu/oscilloscope.rb34
-rw-r--r--ext/tk/sample/tkextlib/vu/pie.rb28
-rw-r--r--ext/tk/sample/tkextlib/vu/vu.rb48
-rw-r--r--ext/tk/sample/tkfrom.rb12
-rw-r--r--ext/tk/sample/tkhello.rb8
-rw-r--r--ext/tk/sample/tkline.rb4
-rw-r--r--ext/tk/sample/tkmenubutton.rb38
-rw-r--r--ext/tk/sample/tkmsgcat-load_rb.rb30
-rw-r--r--ext/tk/sample/tkmsgcat-load_rb2.rb30
-rw-r--r--ext/tk/sample/tkmsgcat-load_tk.rb52
-rw-r--r--ext/tk/sample/tkmulticolumnlist.rb284
-rw-r--r--ext/tk/sample/tkmultilistbox.rb156
-rw-r--r--ext/tk/sample/tkmultilistframe.rb246
-rw-r--r--ext/tk/sample/tkoptdb-safeTk.rb6
-rw-r--r--ext/tk/sample/tkoptdb.rb42
-rw-r--r--ext/tk/sample/tktextframe.rb12
-rw-r--r--ext/tk/sample/tktree.rb12
-rw-r--r--ext/tk/tkutil.c664
296 files changed, 13911 insertions, 13878 deletions
diff --git a/ChangeLog b/ChangeLog
index 915d96061e8..bb181df20f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Oct 11 13:48:20 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk/*: untabify
+
Sun Oct 10 12:32:08 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Allow 'require'
diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb
index f17354fcaf9..8ec34f02147 100644
--- a/ext/tcltklib/extconf.rb
+++ b/ext/tcltklib/extconf.rb
@@ -42,7 +42,7 @@ def find_tcl(tcllib, stubs)
else
%w[8.5 8.4 8.3 8.2 8.1 8.0 7.6].find { |ver|
find_library("tcl#{ver}", func, *paths) or
- find_library("tcl#{ver.delete('.')}", func, *paths)
+ find_library("tcl#{ver.delete('.')}", func, *paths)
}
end
end
@@ -63,7 +63,7 @@ def find_tk(tklib, stubs)
else
%w[8.5 8.4 8.3 8.2 8.1 8.0 4.2].find { |ver|
find_library("tk#{ver}", func, *paths) or
- find_library("tk#{ver.delete('.')}", func, *paths)
+ find_library("tk#{ver.delete('.')}", func, *paths)
}
end
end
@@ -90,47 +90,47 @@ def pthread_check()
else
# tcl-thread is unknown and tclConfig.sh is given
begin
- open(tclConfig, "r") do |cfg|
- while line = cfg.gets()
- if line =~ /^\s*TCL_THREADS=(0|1)/
- tcl_enable_thread = ($1 == "1")
- break
- end
-
- if line =~ /^\s*TCL_MAJOR_VERSION=("|')(\d+)\1/
- tcl_major_ver = $2
- if tcl_major_ver =~ /^[1-7]$/
- tcl_enable_thread = false
- break
- end
- if tcl_major_ver == "8" && tcl_minor_ver == "0"
- tcl_enable_thread = false
- break
- end
- end
-
- if line =~ /^\s*TCL_MINOR_VERSION=("|')(\d+)\1/
- tcl_minor_ver = $2
- if tcl_major_ver == "8" && tcl_minor_ver == "0"
- tcl_enable_thread = false
- break
- end
- end
- end
- end
-
- if tcl_enable_thread == nil
- # not find definition
- if tcl_major_ver
- puts("Warning: '#{tclConfig}' doesn't include TCL_THREADS definition.")
- else
- puts("Warning: '#{tclConfig}' may not be a tclConfig file.")
- end
- tclConfig = false
- end
+ open(tclConfig, "r") do |cfg|
+ while line = cfg.gets()
+ if line =~ /^\s*TCL_THREADS=(0|1)/
+ tcl_enable_thread = ($1 == "1")
+ break
+ end
+
+ if line =~ /^\s*TCL_MAJOR_VERSION=("|')(\d+)\1/
+ tcl_major_ver = $2
+ if tcl_major_ver =~ /^[1-7]$/
+ tcl_enable_thread = false
+ break
+ end
+ if tcl_major_ver == "8" && tcl_minor_ver == "0"
+ tcl_enable_thread = false
+ break
+ end
+ end
+
+ if line =~ /^\s*TCL_MINOR_VERSION=("|')(\d+)\1/
+ tcl_minor_ver = $2
+ if tcl_major_ver == "8" && tcl_minor_ver == "0"
+ tcl_enable_thread = false
+ break
+ end
+ end
+ end
+ end
+
+ if tcl_enable_thread == nil
+ # not find definition
+ if tcl_major_ver
+ puts("Warning: '#{tclConfig}' doesn't include TCL_THREADS definition.")
+ else
+ puts("Warning: '#{tclConfig}' may not be a tclConfig file.")
+ end
+ tclConfig = false
+ end
rescue Exception
- puts("Warning: fail to read '#{tclConfig}'!! --> ignore the file")
- tclConfig = false
+ puts("Warning: fail to read '#{tclConfig}'!! --> ignore the file")
+ tclConfig = false
end
end
end
diff --git a/ext/tcltklib/lib/tcltk.rb b/ext/tcltklib/lib/tcltk.rb
index a6bc773b96b..1a6694dbff7 100644
--- a/ext/tcltklib/lib/tcltk.rb
+++ b/ext/tcltklib/lib/tcltk.rb
@@ -1,7 +1,7 @@
# tof
#### tcltk library, more direct manipulation of tcl/tk
-#### Sep. 5, 1997 Y. Shigehiro
+#### Sep. 5, 1997 Y. Shigehiro
require "tcltklib"
@@ -103,14 +103,14 @@ class TclTkInterpreter
def @ip._get_eval_string(*args)
argstr = ""
args.each{|arg|
- argstr += " " if argstr != ""
- # call to_eval if it is defined
- if (arg.respond_to?(:to_eval))
- argstr += arg.to_eval()
- else
- # call to_s unless defined
- argstr += arg.to_s()
- end
+ argstr += " " if argstr != ""
+ # call to_eval if it is defined
+ if (arg.respond_to?(:to_eval))
+ argstr += arg.to_eval()
+ else
+ # call to_s unless defined
+ argstr += arg.to_s()
+ end
}
return argstr
end
@@ -126,9 +126,9 @@ class TclTkInterpreter
print("_eval: \"", argstr, "\"") if $DEBUG
res = _eval(argstr)
if $DEBUG
- print(" -> \"", res, "\"\n")
+ print(" -> \"", res, "\"\n")
elsif _return_value() != 0
- print(res, "\n")
+ print(res, "\n")
end
fail(%Q/can't eval "#{argstr}"/) if _return_value() != 0 #'
return res
@@ -139,12 +139,12 @@ class TclTkInterpreter
# for all commands registered in tcl/tk interpreter:
@ip._eval("info command").split(/ /).each{|comname|
if comname =~ /^[.]/
- # if command is a widget (path), generate TclTkWidget,
- # and register it in the hash
- @commands[comname] = TclTkWidget.new(@ip, comname)
+ # if command is a widget (path), generate TclTkWidget,
+ # and register it in the hash
+ @commands[comname] = TclTkWidget.new(@ip, comname)
else
- # otherwise, generate TclTkCommand
- @commands[comname] = TclTkCommand.new(@ip, comname)
+ # otherwise, generate TclTkCommand
+ @commands[comname] = TclTkCommand.new(@ip, comname)
end
}
end
diff --git a/ext/tcltklib/sample/sample1.rb b/ext/tcltklib/sample/sample1.rb
index 21ee0f29d55..77b79e6dbf8 100644
--- a/ext/tcltklib/sample/sample1.rb
+++ b/ext/tcltklib/sample/sample1.rb
@@ -189,8 +189,8 @@ class Test1
grid.e(w, "-row", ro, "-column", co, "-sticky news")
ro += 1
if ro == 7
- ro = 0
- co += 1
+ ro = 0
+ co += 1
end
}
end
diff --git a/ext/tcltklib/sample/sample2.rb b/ext/tcltklib/sample/sample2.rb
index 969d8de09a2..5d43470de32 100644
--- a/ext/tcltklib/sample/sample2.rb
+++ b/ext/tcltklib/sample/sample2.rb
@@ -6,13 +6,13 @@
# maeda shugo (shuto@po.aianet.ne.jp)
#---------------------------------------------------------------------------
-# Sep. 17, 1997 modified by Y. Shigehiro for tcltk library
-# maeda shugo (shugo@po.aianet.ne.jp) 氏による
+# Sep. 17, 1997 modified by Y. Shigehiro for tcltk library
+# maeda shugo (shugo@po.aianet.ne.jp) 氏による
# (ruby/tk で書かれていた) ruby のサンプルプログラム
-# http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz
-# を tcltk ライブラリを使うように, 機械的に変更してみました.
+# http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz
+# を tcltk ライブラリを使うように, 機械的に変更してみました.
#
-# なるべくオリジナルと同じになるようにしてあります.
+# なるべくオリジナルと同じになるようにしてあります.
require "observer"
require "tcltk"
@@ -36,141 +36,141 @@ class Othello
include Observable
DIRECTIONS = [
- [-1, -1], [-1, 0], [-1, 1],
- [ 0, -1], [ 0, 1],
- [ 1, -1], [ 1, 0], [ 1, 1]
+ [-1, -1], [-1, 0], [-1, 1],
+ [ 0, -1], [ 0, 1],
+ [ 1, -1], [ 1, 0], [ 1, 1]
]
attr :com_disk, TRUE
def initialize(othello)
- @othello = othello
- reset
+ @othello = othello
+ reset
end
def notify_observers(*arg)
- if @observer_peers != nil
- super(*arg)
- end
+ if @observer_peers != nil
+ super(*arg)
+ end
end
def reset
- @data = [
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, WHITE, BLACK, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, BLACK, WHITE, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY]
- ]
- changed
- notify_observers
+ @data = [
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, WHITE, BLACK, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, BLACK, WHITE, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY]
+ ]
+ changed
+ notify_observers
end
def man_disk
- return - @com_disk
+ return - @com_disk
end
def other_disk(disk)
- return - disk
+ return - disk
end
def get_disk(row, col)
- return @data[row][col]
+ return @data[row][col]
end
def reverse_to(row, col, my_disk, dir_y, dir_x)
- y = row
- x = col
- begin
- y += dir_y
- x += dir_x
- if y < 0 || x < 0 || y > 7 || x > 7 ||
- @data[y][x] == EMPTY
- return
- end
- end until @data[y][x] == my_disk
- begin
- @data[y][x] = my_disk
- changed
- notify_observers(y, x)
- y -= dir_y
- x -= dir_x
- end until y == row && x == col
+ y = row
+ x = col
+ begin
+ y += dir_y
+ x += dir_x
+ if y < 0 || x < 0 || y > 7 || x > 7 ||
+ @data[y][x] == EMPTY
+ return
+ end
+ end until @data[y][x] == my_disk
+ begin
+ @data[y][x] = my_disk
+ changed
+ notify_observers(y, x)
+ y -= dir_y
+ x -= dir_x
+ end until y == row && x == col
end
def put_disk(row, col, disk)
- @data[row][col] = disk
- changed
- notify_observers(row, col)
- DIRECTIONS.each do |dir|
- reverse_to(row, col, disk, *dir)
- end
+ @data[row][col] = disk
+ changed
+ notify_observers(row, col)
+ DIRECTIONS.each do |dir|
+ reverse_to(row, col, disk, *dir)
+ end
end
def count_disk(disk)
- num = 0
- @data.each do |rows|
- rows.each do |d|
- if d == disk
- num += 1
- end
- end
- end
- return num
+ num = 0
+ @data.each do |rows|
+ rows.each do |d|
+ if d == disk
+ num += 1
+ end
+ end
+ end
+ return num
end
def count_point_to(row, col, my_disk, dir_y, dir_x)
- return 0 if @data[row][col] != EMPTY
- count = 0
- loop do
- row += dir_y
- col += dir_x
- break if row < 0 || col < 0 || row > 7 || col > 7
- case @data[row][col]
- when my_disk
- return count
- when other_disk(my_disk)
- count += 1
- when EMPTY
- break
- end
- end
- return 0
+ return 0 if @data[row][col] != EMPTY
+ count = 0
+ loop do
+ row += dir_y
+ col += dir_x
+ break if row < 0 || col < 0 || row > 7 || col > 7
+ case @data[row][col]
+ when my_disk
+ return count
+ when other_disk(my_disk)
+ count += 1
+ when EMPTY
+ break
+ end
+ end
+ return 0
end
def count_point(row, col, my_disk)
- count = 0
- DIRECTIONS.each do |dir|
- count += count_point_to(row, col, my_disk, *dir)
- end
- return count
+ count = 0
+ DIRECTIONS.each do |dir|
+ count += count_point_to(row, col, my_disk, *dir)
+ end
+ return count
end
def corner?(row, col)
- return (row == 0 && col == 0) ||
- (row == 0 && col == 7) ||
- (row == 7 && col == 0) ||
- (row == 7 && col == 7)
+ return (row == 0 && col == 0) ||
+ (row == 0 && col == 7) ||
+ (row == 7 && col == 0) ||
+ (row == 7 && col == 7)
end
def search(my_disk)
- max = 0
- max_row = nil
- max_col = nil
- for row in 0 .. 7
- for col in 0 .. 7
- buf = count_point(row, col, my_disk)
- if (corner?(row, col) && buf > 0) || max < buf
- max = buf
- max_row = row
- max_col = col
- end
- end
- end
- return max_row, max_col
+ max = 0
+ max_row = nil
+ max_col = nil
+ for row in 0 .. 7
+ for col in 0 .. 7
+ buf = count_point(row, col, my_disk)
+ if (corner?(row, col) && buf > 0) || max < buf
+ max = buf
+ max_row = row
+ max_col = col
+ end
+ end
+ end
+ return max_row, max_col
end
end #--------------------------> class Board ends here
@@ -189,145 +189,145 @@ class Othello
attr :bottom
class Square
-
- attr :oval, TRUE
- attr :row
- attr :col
-
- def initialize(view, row, col)
- @view = view
- @id = @view.e("create rectangle", *view.tk_rect(view.left + col,
- view.top + row,
- view.left + col + 1,
- view.top + row + 1))
- @row = row
- @col = col
- @view.e("itemconfigure", @id,
- "-width 0.5m -outline #{BORDER_COLOR}")
- @view.e("bind", @id, "<Any-Enter>", TclTkCallback.new($ip, proc{
- if @oval == nil
- view.e("itemconfigure", @id, "-fill #{HILIT_BG_COLOR}")
- end
- }))
- @view.e("bind", @id, "<Any-Leave>", TclTkCallback.new($ip, proc{
- view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
- }))
- @view.e("bind", @id, "<ButtonRelease-1>", TclTkCallback.new($ip,
- proc{
- view.click_square(self)
- }))
- end
-
- def blink(color)
- @view.e("itemconfigure", @id, "-fill #{color}")
- $update.e()
- sleep(0.1)
- @view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
- end
+
+ attr :oval, TRUE
+ attr :row
+ attr :col
+
+ def initialize(view, row, col)
+ @view = view
+ @id = @view.e("create rectangle", *view.tk_rect(view.left + col,
+ view.top + row,
+ view.left + col + 1,
+ view.top + row + 1))
+ @row = row
+ @col = col
+ @view.e("itemconfigure", @id,
+ "-width 0.5m -outline #{BORDER_COLOR}")
+ @view.e("bind", @id, "<Any-Enter>", TclTkCallback.new($ip, proc{
+ if @oval == nil
+ view.e("itemconfigure", @id, "-fill #{HILIT_BG_COLOR}")
+ end
+ }))
+ @view.e("bind", @id, "<Any-Leave>", TclTkCallback.new($ip, proc{
+ view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
+ }))
+ @view.e("bind", @id, "<ButtonRelease-1>", TclTkCallback.new($ip,
+ proc{
+ view.click_square(self)
+ }))
+ end
+
+ def blink(color)
+ @view.e("itemconfigure", @id, "-fill #{color}")
+ $update.e()
+ sleep(0.1)
+ @view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
+ end
end #-----------------------> class Square ends here
def initialize(othello, board)
- super($ip, $root, $canvas)
- @othello = othello
- @board = board
- @board.add_observer(self)
-
- @squares = Array.new(8)
- for i in 0 .. 7
- @squares[i] = Array.new(8)
- end
- @left = 1
- @top = 0.5
- @right = @left + 8
- @bottom = @top + 8
-
- i = self.e("create rectangle", *tk_rect(@left, @top, @right, @bottom))
- self.e("itemconfigure", i,
- "-width 1m -outline #{BORDER_COLOR} -fill #{BACK_GROUND_COLOR}")
+ super($ip, $root, $canvas)
+ @othello = othello
+ @board = board
+ @board.add_observer(self)
+
+ @squares = Array.new(8)
+ for i in 0 .. 7
+ @squares[i] = Array.new(8)
+ end
+ @left = 1
+ @top = 0.5
+ @right = @left + 8
+ @bottom = @top + 8
+
+ i = self.e("create rectangle", *tk_rect(@left, @top, @right, @bottom))
+ self.e("itemconfigure", i,
+ "-width 1m -outline #{BORDER_COLOR} -fill #{BACK_GROUND_COLOR}")
- for row in 0 .. 7
- for col in 0 .. 7
- @squares[row][col] = Square.new(self, row, col)
- end
- end
-
- update
+ for row in 0 .. 7
+ for col in 0 .. 7
+ @squares[row][col] = Square.new(self, row, col)
+ end
+ end
+
+ update
end
def tk_rect(left, top, right, bottom)
- return left.to_s + "c", top.to_s + "c",
- right.to_s + "c", bottom.to_s + "c"
+ return left.to_s + "c", top.to_s + "c",
+ right.to_s + "c", bottom.to_s + "c"
end
def clear
- each_square do |square|
- if square.oval != nil
- self.e("delete", square.oval)
- square.oval = nil
- end
- end
+ each_square do |square|
+ if square.oval != nil
+ self.e("delete", square.oval)
+ square.oval = nil
+ end
+ end
end
def draw_disk(row, col, disk)
- if disk == EMPTY
- if @squares[row][col].oval != nil
- self.e("delete", @squares[row][col].oval)
- @squares[row][col].oval = nil
- end
- return
- end
-
- $update.e()
- sleep(0.05)
- oval = @squares[row][col].oval
- if oval == nil
- oval = self.e("create oval", *tk_rect(@left + col + 0.2,
- @top + row + 0.2,
- @left + col + 0.8,
- @top + row + 0.8))
- @squares[row][col].oval = oval
- end
- case disk
- when BLACK
- color = BLACK_COLOR
- when WHITE
- color = WHITE_COLOR
- else
- fail format("Unknown disk type: %d", disk)
- end
- self.e("itemconfigure", oval, "-outline #{color} -fill #{color}")
+ if disk == EMPTY
+ if @squares[row][col].oval != nil
+ self.e("delete", @squares[row][col].oval)
+ @squares[row][col].oval = nil
+ end
+ return
+ end
+
+ $update.e()
+ sleep(0.05)
+ oval = @squares[row][col].oval
+ if oval == nil
+ oval = self.e("create oval", *tk_rect(@left + col + 0.2,
+ @top + row + 0.2,
+ @left + col + 0.8,
+ @top + row + 0.8))
+ @squares[row][col].oval = oval
+ end
+ case disk
+ when BLACK
+ color = BLACK_COLOR
+ when WHITE
+ color = WHITE_COLOR
+ else
+ fail format("Unknown disk type: %d", disk)
+ end
+ self.e("itemconfigure", oval, "-outline #{color} -fill #{color}")
end
def update(row = nil, col = nil)
- if row && col
- draw_disk(row, col, @board.get_disk(row, col))
- else
- each_square do |square|
- draw_disk(square.row, square.col,
- @board.get_disk(square.row, square.col))
- end
- end
- @othello.show_point
+ if row && col
+ draw_disk(row, col, @board.get_disk(row, col))
+ else
+ each_square do |square|
+ draw_disk(square.row, square.col,
+ @board.get_disk(square.row, square.col))
+ end
+ end
+ @othello.show_point
end
def each_square
- @squares.each do |rows|
- rows.each do |square|
- yield(square)
- end
- end
+ @squares.each do |rows|
+ rows.each do |square|
+ yield(square)
+ end
+ end
end
def click_square(square)
- if @othello.in_com_turn || @othello.game_over ||
- @board.count_point(square.row,
- square.col,
- @board.man_disk) == 0
- square.blink(STOP_COLOR)
- return
- end
- @board.put_disk(square.row, square.col, @board.man_disk)
- @othello.com_turn
+ if @othello.in_com_turn || @othello.game_over ||
+ @board.count_point(square.row,
+ square.col,
+ @board.man_disk) == 0
+ square.blink(STOP_COLOR)
+ return
+ end
+ @board.put_disk(square.row, square.col, @board.man_disk)
+ @othello.com_turn
end
private :draw_disk
@@ -347,7 +347,7 @@ class Othello
@board_view.e("configure -height", y2 - y1)
## scrollregion を設定する.
@board_view.e("configure -scrollregion {", @board_view.e("bbox all"),
- "}")
+ "}")
#### ここまで
$pack.e(@board_view, "-fill both -expand true")
@@ -355,19 +355,19 @@ class Othello
@play_black = TclTkWidget.new($ip, panel, $checkbutton,
"-text {com is black} -command", TclTkCallback.new($ip, proc{
- switch_side
+ switch_side
}))
$pack.e(@play_black, "-side left")
quit = TclTkWidget.new($ip, panel, $button, "-text Quit -command",
- TclTkCallback.new($ip, proc{
- exit
+ TclTkCallback.new($ip, proc{
+ exit
}))
$pack.e(quit, "-side right -fill x")
reset = TclTkWidget.new($ip, panel, $button, "-text Reset -command",
- TclTkCallback.new($ip, proc{
- reset_game
+ TclTkCallback.new($ip, proc{
+ reset_game
}))
$pack.e(reset, "-side right -fill x")
@@ -385,17 +385,17 @@ class Othello
def switch_side
if @in_com_turn
- @play_black.e("toggle")
+ @play_black.e("toggle")
else
- @board.com_disk = @board.man_disk
- com_turn unless @game_over
+ @board.com_disk = @board.man_disk
+ com_turn unless @game_over
end
end
def reset_game
if @board.com_disk == BLACK
- @board.com_disk = WHITE
- @play_black.e("toggle")
+ @board.com_disk = WHITE
+ @play_black.e("toggle")
end
@board_view.clear
@board.reset
@@ -408,30 +408,30 @@ class Othello
$update.e()
sleep(0.5)
begin
- com_disk = @board.count_disk(@board.com_disk)
- man_disk = @board.count_disk(@board.man_disk)
- if @board.count_disk(EMPTY) == 0
- if man_disk == com_disk
- $wm.e("title", $root, "{Othello - Draw!}")
- elsif man_disk > com_disk
- $wm.e("title", $root, "{Othello - You Win!}")
- else
- $wm.e("title", $root, "{Othello - You Loose!}")
- end
- @game_over = TRUE
- break
- elsif com_disk == 0
- $wm.e("title", $root, "{Othello - You Win!}")
- @game_over = TRUE
- break
- elsif man_disk == 0
- $wm.e("title", $root, "{Othello - You Loose!}")
- @game_over = TRUE
- break
- end
- row, col = @board.search(@board.com_disk)
- break if row == nil || col == nil
- @board.put_disk(row, col, @board.com_disk)
+ com_disk = @board.count_disk(@board.com_disk)
+ man_disk = @board.count_disk(@board.man_disk)
+ if @board.count_disk(EMPTY) == 0
+ if man_disk == com_disk
+ $wm.e("title", $root, "{Othello - Draw!}")
+ elsif man_disk > com_disk
+ $wm.e("title", $root, "{Othello - You Win!}")
+ else
+ $wm.e("title", $root, "{Othello - You Loose!}")
+ end
+ @game_over = TRUE
+ break
+ elsif com_disk == 0
+ $wm.e("title", $root, "{Othello - You Win!}")
+ @game_over = TRUE
+ break
+ elsif man_disk == 0
+ $wm.e("title", $root, "{Othello - You Loose!}")
+ @game_over = TRUE
+ break
+ end
+ row, col = @board.search(@board.com_disk)
+ break if row == nil || col == nil
+ @board.put_disk(row, col, @board.com_disk)
end while @board.search(@board.man_disk) == [nil, nil]
@in_com_turn = FALSE
end
@@ -440,7 +440,7 @@ class Othello
black = @board.count_disk(BLACK)
white = @board.count_disk(WHITE)
@msg_label.e("configure -text",
- %Q/{#{format("BLACK: %.2d WHITE: %.2d", black, white)}}/)
+ %Q/{#{format("BLACK: %.2d WHITE: %.2d", black, white)}}/)
end
end #----------------------> class Othello ends here
diff --git a/ext/tcltklib/stubs.c b/ext/tcltklib/stubs.c
index 8faa4ca24ec..3913abb570e 100644
--- a/ext/tcltklib/stubs.c
+++ b/ext/tcltklib/stubs.c
@@ -50,20 +50,20 @@ ruby_tcltk_stubs()
#endif
ruby_tk_dll = getenv("RUBY_TK_DLL");
if (ruby_tcl_dll && ruby_tk_dll) {
- tcl_dll = (DL_HANDLE)DL_OPEN(ruby_tcl_dll);
- tk_dll = (DL_HANDLE)DL_OPEN(ruby_tk_dll);
+ tcl_dll = (DL_HANDLE)DL_OPEN(ruby_tcl_dll);
+ tk_dll = (DL_HANDLE)DL_OPEN(ruby_tk_dll);
} else {
- snprintf(tcl_name, sizeof tcl_name, TCL_NAME, DLEXT);
- snprintf(tk_name, sizeof tk_name, TK_NAME, DLEXT);
- /* examine from 8.9 to 8.1 */
- for (n = '9'; n > '0'; n--) {
- tcl_name[TCL_INDEX] = n;
- tk_name[TK_INDEX] = n;
- tcl_dll = (DL_HANDLE)DL_OPEN(tcl_name);
- tk_dll = (DL_HANDLE)DL_OPEN(tk_name);
- if (tcl_dll && tk_dll)
- break;
- }
+ snprintf(tcl_name, sizeof tcl_name, TCL_NAME, DLEXT);
+ snprintf(tk_name, sizeof tk_name, TK_NAME, DLEXT);
+ /* examine from 8.9 to 8.1 */
+ for (n = '9'; n > '0'; n--) {
+ tcl_name[TCL_INDEX] = n;
+ tk_name[TK_INDEX] = n;
+ tcl_dll = (DL_HANDLE)DL_OPEN(tcl_name);
+ tk_dll = (DL_HANDLE)DL_OPEN(tk_name);
+ if (tcl_dll && tk_dll)
+ break;
+ }
}
#if defined _WIN32
@@ -71,31 +71,31 @@ ruby_tcltk_stubs()
#endif
if (!tcl_dll || !tk_dll)
- return -1;
+ return -1;
p_Tcl_FindExecutable = (void (*)(const char *))DL_SYM(tcl_dll, "Tcl_FindExecutable");
if (!p_Tcl_FindExecutable)
- return -7;
+ return -7;
p_Tcl_FindExecutable("ruby");
p_Tcl_CreateInterp = (Tcl_Interp *(*)())DL_SYM(tcl_dll, "Tcl_CreateInterp");
if (!p_Tcl_CreateInterp)
- return -2;
+ return -2;
tcl_ip = (*p_Tcl_CreateInterp)();
if (!tcl_ip)
- return -3;
+ return -3;
p_Tk_Init = (int (*)(Tcl_Interp *))DL_SYM(tk_dll, "Tk_Init");
if (!p_Tk_Init)
- return -4;
+ return -4;
(*p_Tk_Init)(tcl_ip);
if (!Tcl_InitStubs(tcl_ip, "8.1", 0))
- return -5;
+ return -5;
if (!Tk_InitStubs(tcl_ip, "8.1", 0))
- return -6;
+ return -6;
Tcl_DeleteInterp(tcl_ip);
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index 8b180bf4930..765417d925c 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -1,12 +1,12 @@
/*
- * tcltklib.c
- * Aug. 27, 1997 Y. Shigehiro
- * Oct. 24, 1997 Y. Matsumoto
+ * tcltklib.c
+ * Aug. 27, 1997 Y. Shigehiro
+ * Oct. 24, 1997 Y. Matsumoto
*/
#include "ruby.h"
#include "rubysig.h"
-#undef EXTERN /* avoid conflict with tcl.h of tcl8.2 or before */
+#undef EXTERN /* avoid conflict with tcl.h of tcl8.2 or before */
#include <stdio.h>
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
@@ -196,12 +196,12 @@ static int ip_ruby_cmd _((ClientData, Tcl_Interp *, int, char **));
/*---- class TclTkIp ----*/
struct tcltkip {
- Tcl_Interp *ip; /* the interpreter */
- int has_orig_exit; /* has original 'exit' command ? */
- Tcl_CmdInfo orig_exit_info; /* command info of original 'exit' command */
- int ref_count; /* reference count of rbtk_preserve_ip call */
- int allow_ruby_exit; /* allow exiting ruby by 'exit' function */
- int return_value; /* return value */
+ Tcl_Interp *ip; /* the interpreter */
+ int has_orig_exit; /* has original 'exit' command ? */
+ Tcl_CmdInfo orig_exit_info; /* command info of original 'exit' command */
+ int ref_count; /* reference count of rbtk_preserve_ip call */
+ int allow_ruby_exit; /* allow exiting ruby by 'exit' function */
+ int return_value; /* return value */
};
static struct tcltkip *
@@ -212,7 +212,7 @@ get_ip(self)
Data_Get_Struct(self, struct tcltkip, ptr);
if (ptr == 0) {
- rb_raise(rb_eTypeError, "uninitialized TclTkIp");
+ rb_raise(rb_eTypeError, "uninitialized TclTkIp");
}
return ptr;
}
@@ -233,9 +233,9 @@ rbtk_release_ip(ptr)
{
ptr->ref_count--;
if (ptr->ref_count < 0) {
- ptr->ref_count = 0;
+ ptr->ref_count = 0;
} else {
- Tcl_Release((ClientData)ptr->ip);
+ Tcl_Release((ClientData)ptr->ip);
}
return(ptr->ref_count);
}
@@ -267,46 +267,46 @@ call_original_exit(ptr, state)
Tcl_IncrRefCount(state_obj);
if (info->isNativeObjectProc) {
- Tcl_Obj **argv;
- argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3);
- argv[0] = Tcl_NewStringObj("exit", 4);
- argv[1] = state_obj;
- argv[2] = (Tcl_Obj *)NULL;
+ Tcl_Obj **argv;
+ argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3);
+ argv[0] = Tcl_NewStringObj("exit", 4);
+ argv[1] = state_obj;
+ argv[2] = (Tcl_Obj *)NULL;
- ptr->return_value
- = (*(info->objProc))(info->objClientData, ptr->ip, 2, argv);
+ ptr->return_value
+ = (*(info->objProc))(info->objClientData, ptr->ip, 2, argv);
- free(argv);
+ free(argv);
} else {
- /* string interface */
- char **argv;
- argv = (char **)ALLOC_N(char *, 3);
- argv[0] = "exit";
- argv[1] = Tcl_GetString(state_obj);
- argv[2] = (char *)NULL;
+ /* string interface */
+ char **argv;
+ argv = (char **)ALLOC_N(char *, 3);
+ argv[0] = "exit";
+ argv[1] = Tcl_GetString(state_obj);
+ argv[2] = (char *)NULL;
- ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
- 2, (CONST84 char **)argv);
+ ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
+ 2, (CONST84 char **)argv);
- free(argv);
+ free(argv);
}
Tcl_DecrRefCount(state_obj);
#else /* TCL_MAJOR_VERSION < 8 */
{
- /* string interface */
- char **argv;
- argv = (char **)ALLOC_N(char *, 3);
- argv[0] = "exit";
- argv[1] = RSTRING(rb_fix2str(INT2NUM(state), 10))->ptr;
- argv[2] = (char *)NULL;
+ /* string interface */
+ char **argv;
+ argv = (char **)ALLOC_N(char *, 3);
+ argv[0] = "exit";
+ argv[1] = RSTRING(rb_fix2str(INT2NUM(state), 10))->ptr;
+ argv[2] = (char *)NULL;
- ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
- 2, argv);
+ ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
+ 2, argv);
- free(argv);
+ free(argv);
}
#endif
@@ -337,10 +337,10 @@ _timer_for_tcl(clientData)
run_timer_flag = 1;
if (timer_tick > 0) {
- timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
- (ClientData)0);
+ timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
+ (ClientData)0);
} else {
- timer_token = (Tcl_TimerToken)NULL;
+ timer_token = (Tcl_TimerToken)NULL;
}
rb_thread_critical = thr_crit_bup;
@@ -360,8 +360,8 @@ set_eventloop_tick(self, tick)
rb_secure(4);
if (ttick < 0) {
- rb_raise(rb_eArgError,
- "timer-tick parameter must be 0 or positive number");
+ rb_raise(rb_eArgError,
+ "timer-tick parameter must be 0 or positive number");
}
thr_crit_bup = rb_thread_critical;
@@ -372,11 +372,11 @@ set_eventloop_tick(self, tick)
timer_tick = req_timer_tick = ttick;
if (timer_tick > 0) {
- /* start timer callback */
- timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
- (ClientData)0);
+ /* start timer callback */
+ timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
+ (ClientData)0);
} else {
- timer_token = (Tcl_TimerToken)NULL;
+ timer_token = (Tcl_TimerToken)NULL;
}
rb_thread_critical = thr_crit_bup;
@@ -400,13 +400,13 @@ ip_set_eventloop_tick(self, tick)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return get_eventloop_tick(self);
+ DUMP1("ip is deleted");
+ return get_eventloop_tick(self);
}
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
- /* slave IP */
- return get_eventloop_tick(self);
+ /* slave IP */
+ return get_eventloop_tick(self);
}
return set_eventloop_tick(self, tick);
}
@@ -428,8 +428,8 @@ set_no_event_wait(self, wait)
rb_secure(4);
if (t_wait <= 0) {
- rb_raise(rb_eArgError,
- "no_event_wait parameter must be positive number");
+ rb_raise(rb_eArgError,
+ "no_event_wait parameter must be positive number");
}
no_event_wait = t_wait;
@@ -453,13 +453,13 @@ ip_set_no_event_wait(self, wait)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return get_no_event_wait(self);
+ DUMP1("ip is deleted");
+ return get_no_event_wait(self);
}
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
- /* slave IP */
- return get_no_event_wait(self);
+ /* slave IP */
+ return get_no_event_wait(self);
}
return set_no_event_wait(self, wait);
}
@@ -483,7 +483,7 @@ set_eventloop_weight(self, loop_max, no_event)
rb_secure(4);
if (lpmax <= 0 || no_ev <= 0) {
- rb_raise(rb_eArgError, "weight parameters must be positive numbers");
+ rb_raise(rb_eArgError, "weight parameters must be positive numbers");
}
event_loop_max = lpmax;
@@ -509,13 +509,13 @@ ip_set_eventloop_weight(self, loop_max, no_event)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return get_eventloop_weight(self);
+ DUMP1("ip is deleted");
+ return get_eventloop_weight(self);
}
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
- /* slave IP */
- return get_eventloop_weight(self);
+ /* slave IP */
+ return get_eventloop_weight(self);
}
return set_eventloop_weight(self, loop_max, no_event);
}
@@ -538,21 +538,21 @@ set_max_block_time(self, time)
switch(TYPE(time)) {
case T_FIXNUM:
case T_BIGNUM:
- /* time is micro-second value */
- divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000));
- tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
- tcl_time.usec = NUM2LONG(RARRAY(divmod)->ptr[1]);
- break;
+ /* time is micro-second value */
+ divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000));
+ tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
+ tcl_time.usec = NUM2LONG(RARRAY(divmod)->ptr[1]);
+ break;
case T_FLOAT:
- /* time is second value */
- divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1));
- tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
- tcl_time.usec = (long)(NUM2DBL(RARRAY(divmod)->ptr[1]) * 1000000);
+ /* time is second value */
+ divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1));
+ tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
+ tcl_time.usec = (long)(NUM2DBL(RARRAY(divmod)->ptr[1]) * 1000000);
default:
- rb_raise(rb_eArgError, "invalid value for time: '%s'",
- RSTRING(rb_funcall(time, ID_inspect, 0, 0))->ptr);
+ rb_raise(rb_eArgError, "invalid value for time: '%s'",
+ RSTRING(rb_funcall(time, ID_inspect, 0, 0))->ptr);
}
Tcl_SetMaxBlockTime(&tcl_time);
@@ -565,11 +565,11 @@ lib_evloop_abort_on_exc(self)
VALUE self;
{
if (event_loop_abort_on_exc > 0) {
- return Qtrue;
+ return Qtrue;
} else if (event_loop_abort_on_exc == 0) {
- return Qfalse;
+ return Qfalse;
} else {
- return Qnil;
+ return Qnil;
}
}
@@ -586,11 +586,11 @@ lib_evloop_abort_on_exc_set(self, val)
{
rb_secure(4);
if (RTEST(val)) {
- event_loop_abort_on_exc = 1;
+ event_loop_abort_on_exc = 1;
} else if (NIL_P(val)) {
- event_loop_abort_on_exc = -1;
+ event_loop_abort_on_exc = -1;
} else {
- event_loop_abort_on_exc = 0;
+ event_loop_abort_on_exc = 0;
}
return lib_evloop_abort_on_exc(self);
}
@@ -605,13 +605,13 @@ ip_evloop_abort_on_exc_set(self, val)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return lib_evloop_abort_on_exc(self);
+ DUMP1("ip is deleted");
+ return lib_evloop_abort_on_exc(self);
}
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
- /* slave IP */
- return lib_evloop_abort_on_exc(self);
+ /* slave IP */
+ return lib_evloop_abort_on_exc(self);
}
return lib_evloop_abort_on_exc_set(self, val);
}
@@ -644,134 +644,134 @@ lib_eventloop_core(check_root, update_flag, check_var)
Tk_DeleteTimerHandler(timer_token);
run_timer_flag = 0;
if (timer_tick > 0) {
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
- timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
- (ClientData)0);
- rb_thread_critical = thr_crit_bup;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
+ (ClientData)0);
+ rb_thread_critical = thr_crit_bup;
} else {
- timer_token = (Tcl_TimerToken)NULL;
+ timer_token = (Tcl_TimerToken)NULL;
}
for(;;) {
- if (rb_thread_alone()) {
- DUMP1("no other thread");
- event_loop_wait_event = 0;
-
- if (update_flag) {
- event_flag = update_flag | TCL_DONT_WAIT; /* for safety */
- } else {
- event_flag = TCL_ALL_EVENTS;
- }
-
- if (timer_tick == 0 && update_flag == 0) {
- timer_tick = NO_THREAD_INTERRUPT_TIME;
- timer_token = Tk_CreateTimerHandler(timer_tick,
- _timer_for_tcl,
- (ClientData)0);
- }
-
- if (check_var != (int *)NULL) {
- if (*check_var || !found_event) {
- return found_event;
- }
- }
-
- found_event = Tcl_DoOneEvent(event_flag);
-
- if (update_flag != 0) {
- if (found_event) {
- DUMP1("next update loop");
- continue;
- } else {
- DUMP1("update complete");
- return 0;
- }
- }
-
- DUMP1("check Root Widget");
- if (check_root && Tk_GetNumMainWindows() == 0) {
- run_timer_flag = 0;
- if (!rb_prohibit_interrupt) {
- if (rb_trap_pending) rb_trap_exec();
- }
- return 1;
- }
-
- if (loop_counter++ > 30000) {
- /* fprintf(stderr, "loop_counter > 30000\n"); */
- loop_counter = 0;
- }
-
- } else {
- int tick_counter;
-
- DUMP1("there are other threads");
- event_loop_wait_event = 1;
-
- found_event = 1;
-
- if (update_flag) {
- event_flag = update_flag | TCL_DONT_WAIT; /* for safety */
- } else {
- event_flag = TCL_ALL_EVENTS | TCL_DONT_WAIT;
- }
-
- timer_tick = req_timer_tick;
- tick_counter = 0;
- while(tick_counter < event_loop_max) {
- if (check_var != (int *)NULL) {
- if (*check_var || !found_event) {
- return found_event;
- }
- }
-
- if (Tcl_DoOneEvent(event_flag)) {
- tick_counter++;
- } else {
- if (update_flag != 0) {
- DUMP1("update complete");
- return 0;
- }
- tick_counter += no_event_tick;
- rb_thread_wait_for(t);
- }
-
- if (watchdog_thread != 0 && eventloop_thread != current) {
- return 1;
- }
-
- DUMP1("check Root Widget");
- if (check_root && Tk_GetNumMainWindows() == 0) {
- run_timer_flag = 0;
- if (!rb_prohibit_interrupt) {
- if (rb_trap_pending) rb_trap_exec();
- }
- return 1;
- }
-
- DUMP1("trap check");
- if (!rb_prohibit_interrupt) {
- if (rb_trap_pending) rb_trap_exec();
- }
-
- if (loop_counter++ > 30000) {
- /* fprintf(stderr, "loop_counter > 30000\n"); */
- loop_counter = 0;
- }
-
- if (run_timer_flag) {
- /*
- DUMP1("timer interrupt");
- run_timer_flag = 0;
- */
- break; /* switch to other thread */
- }
- }
- }
-
- DUMP1("trap check & thread scheduling");
- if (update_flag == 0) CHECK_INTS;
+ if (rb_thread_alone()) {
+ DUMP1("no other thread");
+ event_loop_wait_event = 0;
+
+ if (update_flag) {
+ event_flag = update_flag | TCL_DONT_WAIT; /* for safety */
+ } else {
+ event_flag = TCL_ALL_EVENTS;
+ }
+
+ if (timer_tick == 0 && update_flag == 0) {
+ timer_tick = NO_THREAD_INTERRUPT_TIME;
+ timer_token = Tk_CreateTimerHandler(timer_tick,
+ _timer_for_tcl,
+ (ClientData)0);
+ }
+
+ if (check_var != (int *)NULL) {
+ if (*check_var || !found_event) {
+ return found_event;
+ }
+ }
+
+ found_event = Tcl_DoOneEvent(event_flag);
+
+ if (update_flag != 0) {
+ if (found_event) {
+ DUMP1("next update loop");
+ continue;
+ } else {
+ DUMP1("update complete");
+ return 0;
+ }
+ }
+
+ DUMP1("check Root Widget");
+ if (check_root && Tk_GetNumMainWindows() == 0) {
+ run_timer_flag = 0;
+ if (!rb_prohibit_interrupt) {
+ if (rb_trap_pending) rb_trap_exec();
+ }
+ return 1;
+ }
+
+ if (loop_counter++ > 30000) {
+ /* fprintf(stderr, "loop_counter > 30000\n"); */
+ loop_counter = 0;
+ }
+
+ } else {
+ int tick_counter;
+
+ DUMP1("there are other threads");
+ event_loop_wait_event = 1;
+
+ found_event = 1;
+
+ if (update_flag) {
+ event_flag = update_flag | TCL_DONT_WAIT; /* for safety */
+ } else {
+ event_flag = TCL_ALL_EVENTS | TCL_DONT_WAIT;
+ }
+
+ timer_tick = req_timer_tick;
+ tick_counter = 0;
+ while(tick_counter < event_loop_max) {
+ if (check_var != (int *)NULL) {
+ if (*check_var || !found_event) {
+ return found_event;
+ }
+ }
+
+ if (Tcl_DoOneEvent(event_flag)) {
+ tick_counter++;
+ } else {
+ if (update_flag != 0) {
+ DUMP1("update complete");
+ return 0;
+ }
+ tick_counter += no_event_tick;
+ rb_thread_wait_for(t);
+ }
+
+ if (watchdog_thread != 0 && eventloop_thread != current) {
+ return 1;
+ }
+
+ DUMP1("check Root Widget");
+ if (check_root && Tk_GetNumMainWindows() == 0) {
+ run_timer_flag = 0;
+ if (!rb_prohibit_interrupt) {
+ if (rb_trap_pending) rb_trap_exec();
+ }
+ return 1;
+ }
+
+ DUMP1("trap check");
+ if (!rb_prohibit_interrupt) {
+ if (rb_trap_pending) rb_trap_exec();
+ }
+
+ if (loop_counter++ > 30000) {
+ /* fprintf(stderr, "loop_counter > 30000\n"); */
+ loop_counter = 0;
+ }
+
+ if (run_timer_flag) {
+ /*
+ DUMP1("timer interrupt");
+ run_timer_flag = 0;
+ */
+ break; /* switch to other thread */
+ }
+ }
+ }
+
+ DUMP1("trap check & thread scheduling");
+ if (update_flag == 0) CHECK_INTS;
}
return 1;
@@ -784,9 +784,9 @@ lib_eventloop_main(check_rootwidget)
check_rootwidget_flag = RTEST(check_rootwidget);
if (lib_eventloop_core(check_rootwidget_flag, 0, (int *)NULL)) {
- return Qtrue;
+ return Qtrue;
} else {
- return Qfalse;
+ return Qfalse;
}
}
@@ -799,8 +799,8 @@ lib_eventloop_ensure(parent_evloop)
DUMP2("eventloop-ensure: current-thread : %lx\n", rb_thread_current());
DUMP2("eventloop-ensure: eventloop-thread : %lx\n", eventloop_thread);
if (eventloop_thread == rb_thread_current()) {
- DUMP2("eventloop-thread -> %lx\n", parent_evloop);
- eventloop_thread = parent_evloop;
+ DUMP2("eventloop-thread -> %lx\n", parent_evloop);
+ eventloop_thread = parent_evloop;
}
return Qnil;
}
@@ -814,12 +814,12 @@ lib_eventloop_launcher(check_rootwidget)
eventloop_thread = rb_thread_current();
if (ruby_debug) {
- fprintf(stderr, "tcltklib: eventloop-thread : %lx -> %lx\n",
- parent_evloop, eventloop_thread);
+ fprintf(stderr, "tcltklib: eventloop-thread : %lx -> %lx\n",
+ parent_evloop, eventloop_thread);
}
return rb_ensure(lib_eventloop_main, check_rootwidget,
- lib_eventloop_ensure, parent_evloop);
+ lib_eventloop_ensure, parent_evloop);
}
/* execute Tk_MainLoop */
@@ -832,11 +832,11 @@ lib_mainloop(argc, argv, self)
VALUE check_rootwidget;
if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) {
- check_rootwidget = Qtrue;
+ check_rootwidget = Qtrue;
} else if (RTEST(check_rootwidget)) {
- check_rootwidget = Qtrue;
+ check_rootwidget = Qtrue;
} else {
- check_rootwidget = Qfalse;
+ check_rootwidget = Qfalse;
}
return lib_eventloop_launcher(check_rootwidget);
@@ -852,13 +852,13 @@ ip_mainloop(argc, argv, self)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return Qnil;
+ DUMP1("ip is deleted");
+ return Qnil;
}
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
- /* slave IP */
- return Qnil;
+ /* slave IP */
+ return Qnil;
}
return lib_mainloop(argc, argv, self);
}
@@ -880,40 +880,40 @@ lib_watchdog_core(check_rootwidget)
/* check other watchdog thread */
if (watchdog_thread != 0) {
- if (RTEST(rb_funcall(watchdog_thread, ID_stop_p, 0))) {
- rb_funcall(watchdog_thread, ID_kill, 0);
- } else {
- return Qnil;
- }
+ if (RTEST(rb_funcall(watchdog_thread, ID_stop_p, 0))) {
+ rb_funcall(watchdog_thread, ID_kill, 0);
+ } else {
+ return Qnil;
+ }
}
watchdog_thread = rb_thread_current();
/* watchdog start */
do {
- if (eventloop_thread == 0
- || (loop_counter == prev_val
- && RTEST(rb_funcall(eventloop_thread, ID_stop_p, 0))
- && ++chance >= 3 )
- ) {
- /* start new eventloop thread */
- DUMP2("eventloop thread %lx is sleeping or dead",
- eventloop_thread);
- evloop = rb_thread_create(lib_eventloop_launcher,
- (void*)&check_rootwidget);
- DUMP2("create new eventloop thread %lx", evloop);
- loop_counter = -1;
- chance = 0;
- rb_thread_run(evloop);
- } else {
- loop_counter = prev_val;
- chance = 0;
- if (event_loop_wait_event) {
- rb_thread_wait_for(t0);
- } else {
- rb_thread_wait_for(t1);
- }
- /* rb_thread_schedule(); */
- }
+ if (eventloop_thread == 0
+ || (loop_counter == prev_val
+ && RTEST(rb_funcall(eventloop_thread, ID_stop_p, 0))
+ && ++chance >= 3 )
+ ) {
+ /* start new eventloop thread */
+ DUMP2("eventloop thread %lx is sleeping or dead",
+ eventloop_thread);
+ evloop = rb_thread_create(lib_eventloop_launcher,
+ (void*)&check_rootwidget);
+ DUMP2("create new eventloop thread %lx", evloop);
+ loop_counter = -1;
+ chance = 0;
+ rb_thread_run(evloop);
+ } else {
+ loop_counter = prev_val;
+ chance = 0;
+ if (event_loop_wait_event) {
+ rb_thread_wait_for(t0);
+ } else {
+ rb_thread_wait_for(t1);
+ }
+ /* rb_thread_schedule(); */
+ }
} while(!check || Tk_GetNumMainWindows() != 0);
return Qnil;
@@ -936,15 +936,15 @@ lib_mainloop_watchdog(argc, argv, self)
VALUE check_rootwidget;
if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) {
- check_rootwidget = Qtrue;
+ check_rootwidget = Qtrue;
} else if (RTEST(check_rootwidget)) {
- check_rootwidget = Qtrue;
+ check_rootwidget = Qtrue;
} else {
- check_rootwidget = Qfalse;
+ check_rootwidget = Qfalse;
}
return rb_ensure(lib_watchdog_core, check_rootwidget,
- lib_watchdog_ensure, Qnil);
+ lib_watchdog_ensure, Qnil);
}
static VALUE
@@ -957,13 +957,13 @@ ip_mainloop_watchdog(argc, argv, self)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return Qnil;
+ DUMP1("ip is deleted");
+ return Qnil;
}
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
- /* slave IP */
- return Qnil;
+ /* slave IP */
+ return Qnil;
}
return lib_mainloop_watchdog(argc, argv, self);
}
@@ -980,10 +980,10 @@ lib_do_one_event_core(argc, argv, self, is_ip)
int found_event;
if (rb_scan_args(argc, argv, "01", &vflags) == 0) {
- flags = TCL_ALL_EVENTS | TCL_DONT_WAIT;
+ flags = TCL_ALL_EVENTS | TCL_DONT_WAIT;
} else {
- Check_Type(vflags, T_FIXNUM);
- flags = FIX2INT(vflags);
+ Check_Type(vflags, T_FIXNUM);
+ flags = FIX2INT(vflags);
}
if (rb_safe_level() >= 4 || (rb_safe_level() >=1 && OBJ_TAINTED(vflags))) {
@@ -991,28 +991,28 @@ lib_do_one_event_core(argc, argv, self, is_ip)
}
if (is_ip) {
- /* check IP */
- struct tcltkip *ptr = get_ip(self);
+ /* check IP */
+ struct tcltkip *ptr = get_ip(self);
- /* ip is deleted? */
- if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return Qfalse;
- }
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return Qfalse;
+ }
- if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
- /* slave IP */
- flags |= TCL_DONT_WAIT;
- }
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ flags |= TCL_DONT_WAIT;
+ }
}
/* found_event = Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT); */
found_event = Tcl_DoOneEvent(flags);
if (found_event) {
- return Qtrue;
+ return Qtrue;
} else {
- return Qfalse;
+ return Qfalse;
}
}
@@ -1058,18 +1058,18 @@ ip_set_exc_message(interp, exc)
#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0)
enc = Qnil;
if (RTEST(rb_ivar_defined(exc, ID_at_enc))) {
- enc = rb_ivar_get(exc, ID_at_enc);
+ enc = rb_ivar_get(exc, ID_at_enc);
}
if (NIL_P(enc) && RTEST(rb_ivar_defined(msg, ID_at_enc))) {
- enc = rb_ivar_get(msg, ID_at_enc);
+ enc = rb_ivar_get(msg, ID_at_enc);
}
if (NIL_P(enc)) {
- encoding = (Tcl_Encoding)NULL;
+ encoding = (Tcl_Encoding)NULL;
} else if (TYPE(enc) == T_STRING) {
- encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
} else {
- enc = rb_funcall(enc, ID_to_s, 0, 0);
- encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ enc = rb_funcall(enc, ID_to_s, 0, 0);
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
}
/* to avoid a garbled error message dialog */
@@ -1098,24 +1098,24 @@ TkStringValue(obj)
{
switch(TYPE(obj)) {
case T_STRING:
- return obj;
+ return obj;
case T_NIL:
- return rb_str_new2("");
+ return rb_str_new2("");
case T_TRUE:
- return rb_str_new2("1");
+ return rb_str_new2("1");
case T_FALSE:
- return rb_str_new2("0");
+ return rb_str_new2("0");
case T_ARRAY:
- return rb_funcall(obj, ID_join, 1, rb_str_new2(" "));
+ return rb_funcall(obj, ID_join, 1, rb_str_new2(" "));
default:
- if (rb_respond_to(obj, ID_to_s)) {
- return rb_funcall(obj, ID_to_s, 0, 0);
- }
+ if (rb_respond_to(obj, ID_to_s)) {
+ return rb_funcall(obj, ID_to_s, 0, 0);
+ }
}
return rb_funcall(obj, ID_inspect, 0, 0);
@@ -1153,105 +1153,105 @@ ip_ruby_eval_body(arg)
#if 0
ret = rb_rescue2(rb_eval_string, (VALUE)arg->string,
- ip_ruby_eval_rescue, arg->failed,
- rb_eStandardError, rb_eScriptError, rb_eSystemExit,
- (VALUE)0);
+ ip_ruby_eval_rescue, arg->failed,
+ rb_eStandardError, rb_eScriptError, rb_eSystemExit,
+ (VALUE)0);
#else
rb_thread_critical = Qfalse;
ret = rb_eval_string_protect(arg->string, &status);
rb_thread_critical = Qtrue;
if (status) {
- char *errtype, *buf;
- int errtype_len, len;
- VALUE old_gc;
-
- old_gc = rb_gc_disable();
-
- switch(status) {
- case TAG_RETURN:
- errtype = "LocalJumpError: ";
- errtype_len = strlen(errtype);
- len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
- buf = ALLOC_N(char, len + 1);
- strncpy(buf, errtype, errtype_len);
- strncpy(buf + errtype_len,
- RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
- RSTRING(rb_obj_as_string(ruby_errinfo))->len);
- *(buf + len) = 0;
-
- RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf);
- free(buf);
- break;
-
- case TAG_BREAK:
- errtype = "LocalJumpError: ";
- errtype_len = strlen(errtype);
- len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
- buf = ALLOC_N(char, len + 1);
- strncpy(buf, errtype, errtype_len);
- strncpy(buf + errtype_len,
- RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
- RSTRING(rb_obj_as_string(ruby_errinfo))->len);
- *(buf + len) = 0;
-
- RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf);
- free(buf);
- break;
-
- case TAG_NEXT:
- errtype = "LocalJumpError: ";
- errtype_len = strlen(errtype);
- len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
- buf = ALLOC_N(char, len + 1);
- strncpy(buf, errtype, errtype_len);
- strncpy(buf + errtype_len,
- RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
- RSTRING(rb_obj_as_string(ruby_errinfo))->len);
- *(buf + len) = 0;
-
- RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf);
- free(buf);
- break;
-
- case TAG_RETRY:
- case TAG_REDO:
- if (NIL_P(ruby_errinfo)) {
- rb_jump_tag(status);
- } else {
- RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
- }
- break;
-
- case TAG_RAISE:
- case TAG_FATAL:
- if (NIL_P(ruby_errinfo)) {
- RARRAY(arg->failed)->ptr[0]
- = rb_exc_new2(rb_eException, "unknown exception");
- } else {
- RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
- }
- break;
-
- case TAG_THROW:
- if (NIL_P(ruby_errinfo)) {
- rb_jump_tag(TAG_THROW);
- } else {
- RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
- }
- break;
-
- default:
- buf = ALLOC_N(char, 256);
- sprintf(buf, "unknown loncaljmp status %d", status);
- RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf);
- free(buf);
- break;
- }
-
- if (old_gc == Qfalse) rb_gc_enable();
-
- ret = Qnil;
+ char *errtype, *buf;
+ int errtype_len, len;
+ VALUE old_gc;
+
+ old_gc = rb_gc_disable();
+
+ switch(status) {
+ case TAG_RETURN:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf);
+ free(buf);
+ break;
+
+ case TAG_BREAK:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf);
+ free(buf);
+ break;
+
+ case TAG_NEXT:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf);
+ free(buf);
+ break;
+
+ case TAG_RETRY:
+ case TAG_REDO:
+ if (NIL_P(ruby_errinfo)) {
+ rb_jump_tag(status);
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ case TAG_RAISE:
+ case TAG_FATAL:
+ if (NIL_P(ruby_errinfo)) {
+ RARRAY(arg->failed)->ptr[0]
+ = rb_exc_new2(rb_eException, "unknown exception");
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ case TAG_THROW:
+ if (NIL_P(ruby_errinfo)) {
+ rb_jump_tag(TAG_THROW);
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ default:
+ buf = ALLOC_N(char, 256);
+ sprintf(buf, "unknown loncaljmp status %d", status);
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf);
+ free(buf);
+ break;
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+
+ ret = Qnil;
}
#endif
@@ -1292,8 +1292,8 @@ ip_ruby_eval(clientData, interp, argc, argv)
/* ruby command has 1 arg. */
if (argc != 2) {
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
- argc - 1);
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
+ argc - 1);
}
/* allocate */
@@ -1329,11 +1329,11 @@ ip_ruby_eval(clientData, interp, argc, argv)
old_trapflag = rb_trap_immediate;
#ifdef HAVE_NATIVETHREAD
if (!is_ruby_native_thread()) {
- rb_bug("cross-thread violation on ip_ruby_eval()");
+ rb_bug("cross-thread violation on ip_ruby_eval()");
}
#endif
res = rb_ensure(ip_ruby_eval_body, (VALUE)arg,
- ip_ruby_eval_ensure, INT2FIX(old_trapflag));
+ ip_ruby_eval_ensure, INT2FIX(old_trapflag));
#if TCL_MAJOR_VERSION >= 8
free(arg->string);
@@ -1348,93 +1348,93 @@ ip_ruby_eval(clientData, interp, argc, argv)
volatile VALUE bt_ary;
volatile VALUE backtrace;
- DUMP1("(rb_eval_string result) failed");
+ DUMP1("(rb_eval_string result) failed");
- Tcl_ResetResult(interp);
+ Tcl_ResetResult(interp);
- res = RARRAY(exception)->ptr[0];
- eclass = rb_obj_class(res);
+ res = RARRAY(exception)->ptr[0];
+ eclass = rb_obj_class(res);
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- DUMP1("set backtrace");
- if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) {
- backtrace = rb_ary_join(bt_ary, rb_str_new2("\n"));
- StringValue(backtrace);
- Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr);
- }
+ DUMP1("set backtrace");
+ if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) {
+ backtrace = rb_ary_join(bt_ary, rb_str_new2("\n"));
+ StringValue(backtrace);
+ Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr);
+ }
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- if (eclass == eTkCallbackReturn) {
- ip_set_exc_message(interp, res);
- return TCL_RETURN;
+ if (eclass == eTkCallbackReturn) {
+ ip_set_exc_message(interp, res);
+ return TCL_RETURN;
- } else if (eclass == eTkCallbackBreak) {
- ip_set_exc_message(interp, res);
- return TCL_BREAK;
+ } else if (eclass == eTkCallbackBreak) {
+ ip_set_exc_message(interp, res);
+ return TCL_BREAK;
- } else if (eclass == eTkCallbackContinue) {
- ip_set_exc_message(interp, res);
- return TCL_CONTINUE;
+ } else if (eclass == eTkCallbackContinue) {
+ ip_set_exc_message(interp, res);
+ return TCL_CONTINUE;
- } else if (eclass == rb_eSystemExit) {
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ } else if (eclass == rb_eSystemExit) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- /* Tcl_Eval(interp, "destroy ."); */
- if (Tk_GetNumMainWindows() > 0) {
- Tk_Window main_win = Tk_MainWindow(interp);
- if (main_win != (Tk_Window)NULL) {
- Tk_DestroyWindow(main_win);
- }
- }
+ /* Tcl_Eval(interp, "destroy ."); */
+ if (Tk_GetNumMainWindows() > 0) {
+ Tk_Window main_win = Tk_MainWindow(interp);
+ if (main_win != (Tk_Window)NULL) {
+ Tk_DestroyWindow(main_win);
+ }
+ }
- /* StringValue(res); */
- res = rb_funcall(res, ID_message, 0, 0);
+ /* StringValue(res); */
+ res = rb_funcall(res, ID_message, 0, 0);
- Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL);
+ Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- rb_raise(rb_eSystemExit, RSTRING(res)->ptr);
+ rb_raise(rb_eSystemExit, RSTRING(res)->ptr);
- } else if (rb_obj_is_kind_of(res, eLocalJumpError)) {
- VALUE reason = rb_ivar_get(res, ID_at_reason);
+ } else if (rb_obj_is_kind_of(res, eLocalJumpError)) {
+ VALUE reason = rb_ivar_get(res, ID_at_reason);
- if (TYPE(reason) != T_SYMBOL) {
- ip_set_exc_message(interp, res);
- return TCL_ERROR;
- }
+ if (TYPE(reason) != T_SYMBOL) {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
- if (SYM2ID(reason) == ID_return) {
- ip_set_exc_message(interp, res);
- return TCL_RETURN;
+ if (SYM2ID(reason) == ID_return) {
+ ip_set_exc_message(interp, res);
+ return TCL_RETURN;
- } else if (SYM2ID(reason) == ID_break) {
- ip_set_exc_message(interp, res);
- return TCL_BREAK;
+ } else if (SYM2ID(reason) == ID_break) {
+ ip_set_exc_message(interp, res);
+ return TCL_BREAK;
- } else if (SYM2ID(reason) == ID_next) {
- ip_set_exc_message(interp, res);
- return TCL_CONTINUE;
+ } else if (SYM2ID(reason) == ID_next) {
+ ip_set_exc_message(interp, res);
+ return TCL_CONTINUE;
- } else {
- ip_set_exc_message(interp, res);
- return TCL_ERROR;
- }
- } else {
- ip_set_exc_message(interp, res);
- return TCL_ERROR;
- }
+ } else {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
+ } else {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
}
/* result must be string or nil */
if (NIL_P(res)) {
- DUMP1("(rb_eval_string result) nil");
- Tcl_ResetResult(interp);
- return TCL_OK;
+ DUMP1("(rb_eval_string result) nil");
+ Tcl_ResetResult(interp);
+ return TCL_OK;
}
/* copy result to the tcl interpreter */
@@ -1509,102 +1509,102 @@ ip_ruby_cmd_body(arg)
#if 0
ret = rb_rescue2(ip_ruby_cmd_core, (VALUE)arg,
- ip_ruby_cmd_rescue, arg->failed,
- rb_eStandardError, rb_eScriptError, rb_eSystemExit,
- (VALUE)0);
+ ip_ruby_cmd_rescue, arg->failed,
+ rb_eStandardError, rb_eScriptError, rb_eSystemExit,
+ (VALUE)0);
#else
ret = rb_protect(ip_ruby_cmd_core, (VALUE)arg, &status);
if (status) {
- char *errtype, *buf;
- int errtype_len, len;
-
- old_gc = rb_gc_disable();
-
- switch(status) {
- case TAG_RETURN:
- errtype = "LocalJumpError: ";
- errtype_len = strlen(errtype);
- len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
- buf = ALLOC_N(char, len + 1);
- strncpy(buf, errtype, errtype_len);
- strncpy(buf + errtype_len,
- RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
- RSTRING(rb_obj_as_string(ruby_errinfo))->len);
- *(buf + len) = 0;
-
- RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf);
- free(buf);
- break;
-
- case TAG_BREAK:
- errtype = "LocalJumpError: ";
- errtype_len = strlen(errtype);
- len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
- buf = ALLOC_N(char, len + 1);
- strncpy(buf, errtype, errtype_len);
- strncpy(buf + errtype_len,
- RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
- RSTRING(rb_obj_as_string(ruby_errinfo))->len);
- *(buf + len) = 0;
-
- RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf);
- free(buf);
- break;
-
- case TAG_NEXT:
- errtype = "LocalJumpError: ";
- errtype_len = strlen(errtype);
- len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
- buf = ALLOC_N(char, len + 1);
- strncpy(buf, errtype, errtype_len);
- strncpy(buf + errtype_len,
- RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
- RSTRING(rb_obj_as_string(ruby_errinfo))->len);
- *(buf + len) = 0;
-
- RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf);
- free(buf);
- break;
-
- case TAG_RETRY:
- case TAG_REDO:
- if (NIL_P(ruby_errinfo)) {
- rb_jump_tag(status);
- } else {
- RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
- }
- break;
-
- case TAG_RAISE:
- case TAG_FATAL:
- if (NIL_P(ruby_errinfo)) {
- RARRAY(arg->failed)->ptr[0]
- = rb_exc_new2(rb_eException, "unknown exception");
- } else {
- RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
- }
- break;
-
- case TAG_THROW:
- if (NIL_P(ruby_errinfo)) {
- rb_jump_tag(TAG_THROW);
- } else {
- RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
- }
- break;
-
- default:
- buf = ALLOC_N(char, 256);
- rb_warn(buf, "unknown loncaljmp status %d", status);
- RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf);
- free(buf);
- break;
- }
-
- if (old_gc == Qfalse) rb_gc_enable();
-
- ret = Qnil;
+ char *errtype, *buf;
+ int errtype_len, len;
+
+ old_gc = rb_gc_disable();
+
+ switch(status) {
+ case TAG_RETURN:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf);
+ free(buf);
+ break;
+
+ case TAG_BREAK:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf);
+ free(buf);
+ break;
+
+ case TAG_NEXT:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf);
+ free(buf);
+ break;
+
+ case TAG_RETRY:
+ case TAG_REDO:
+ if (NIL_P(ruby_errinfo)) {
+ rb_jump_tag(status);
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ case TAG_RAISE:
+ case TAG_FATAL:
+ if (NIL_P(ruby_errinfo)) {
+ RARRAY(arg->failed)->ptr[0]
+ = rb_exc_new2(rb_eException, "unknown exception");
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ case TAG_THROW:
+ if (NIL_P(ruby_errinfo)) {
+ rb_jump_tag(TAG_THROW);
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ default:
+ buf = ALLOC_N(char, 256);
+ rb_warn(buf, "unknown loncaljmp status %d", status);
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf);
+ free(buf);
+ break;
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+
+ ret = Qnil;
}
#endif
@@ -1652,7 +1652,7 @@ ip_ruby_cmd(clientData, interp, argc, argv)
VALUE old_gc;
if (argc < 3) {
- rb_raise(rb_eArgError, "too few arguments");
+ rb_raise(rb_eArgError, "too few arguments");
}
/* allocate */
@@ -1671,26 +1671,26 @@ ip_ruby_cmd(clientData, interp, argc, argv)
#endif
DUMP2("receiver:%s",str);
if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) {
- /* class | module | constant */
- receiver = rb_const_get(rb_cObject, rb_intern(str));
+ /* class | module | constant */
+ receiver = rb_const_get(rb_cObject, rb_intern(str));
} else if (str[0] == '$') {
- /* global variable */
- receiver = rb_gv_get(str);
+ /* global variable */
+ receiver = rb_gv_get(str);
} else {
- /* global variable omitted '$' */
- char *buf;
+ /* global variable omitted '$' */
+ char *buf;
- len = strlen(str);
- buf = ALLOC_N(char, len + 2);
- buf[0] = '$';
- strncpy(buf + 1, str, len);
- buf[len + 1] = 0;
- receiver = rb_gv_get(buf);
- free(buf);
+ len = strlen(str);
+ buf = ALLOC_N(char, len + 2);
+ buf[0] = '$';
+ strncpy(buf + 1, str, len);
+ buf[len + 1] = 0;
+ receiver = rb_gv_get(buf);
+ free(buf);
}
if (NIL_P(receiver)) {
- rb_raise(rb_eArgError, "unknown class/module/global-variable '%s'",
- str);
+ rb_raise(rb_eArgError, "unknown class/module/global-variable '%s'",
+ str);
}
/* get metrhod */
@@ -1705,12 +1705,12 @@ ip_ruby_cmd(clientData, interp, argc, argv)
RARRAY(args)->len = 0;
for(i = 3; i < argc; i++) {
#if TCL_MAJOR_VERSION >= 8
- str = Tcl_GetStringFromObj(argv[i], &len);
- DUMP2("arg:%s",str);
- RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len);
+ str = Tcl_GetStringFromObj(argv[i], &len);
+ DUMP2("arg:%s",str);
+ RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len);
#else /* TCL_MAJOR_VERSION < 8 */
- DUMP2("arg:%s",argv[i]);
- RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]);
+ DUMP2("arg:%s",argv[i]);
+ RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]);
#endif
}
@@ -1729,12 +1729,12 @@ ip_ruby_cmd(clientData, interp, argc, argv)
old_trapflag = rb_trap_immediate;
#ifdef HAVE_NATIVETHREAD
if (!is_ruby_native_thread()) {
- rb_bug("cross-thread violation on ip_ruby_cmd()");
+ rb_bug("cross-thread violation on ip_ruby_cmd()");
}
#endif
res = rb_ensure(ip_ruby_cmd_body, (VALUE)arg,
- ip_ruby_cmd_ensure, INT2FIX(old_trapflag));
+ ip_ruby_cmd_ensure, INT2FIX(old_trapflag));
free(arg);
@@ -1745,93 +1745,93 @@ ip_ruby_cmd(clientData, interp, argc, argv)
volatile VALUE bt_ary;
volatile VALUE backtrace;
- DUMP1("(rb_eval_cmd result) failed");
+ DUMP1("(rb_eval_cmd result) failed");
- Tcl_ResetResult(interp);
+ Tcl_ResetResult(interp);
- res = RARRAY(exception)->ptr[0];
- eclass = rb_obj_class(res);
+ res = RARRAY(exception)->ptr[0];
+ eclass = rb_obj_class(res);
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- DUMP1("set backtrace");
- if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) {
- backtrace = rb_ary_join(bt_ary, rb_str_new2("\n"));
- StringValue(backtrace);
- Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr);
- }
+ DUMP1("set backtrace");
+ if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) {
+ backtrace = rb_ary_join(bt_ary, rb_str_new2("\n"));
+ StringValue(backtrace);
+ Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr);
+ }
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- if (eclass == eTkCallbackReturn) {
- ip_set_exc_message(interp, res);
- return TCL_RETURN;
+ if (eclass == eTkCallbackReturn) {
+ ip_set_exc_message(interp, res);
+ return TCL_RETURN;
- } else if (eclass == eTkCallbackBreak) {
- ip_set_exc_message(interp, res);
- return TCL_BREAK;
+ } else if (eclass == eTkCallbackBreak) {
+ ip_set_exc_message(interp, res);
+ return TCL_BREAK;
- } else if (eclass == eTkCallbackContinue) {
- ip_set_exc_message(interp, res);
- return TCL_CONTINUE;
+ } else if (eclass == eTkCallbackContinue) {
+ ip_set_exc_message(interp, res);
+ return TCL_CONTINUE;
- } else if (eclass == rb_eSystemExit) {
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ } else if (eclass == rb_eSystemExit) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- /* Tcl_Eval(interp, "destroy ."); */
- if (Tk_GetNumMainWindows() > 0) {
- Tk_Window main_win = Tk_MainWindow(interp);
- if (main_win != (Tk_Window)NULL) {
- Tk_DestroyWindow(main_win);
- }
- }
+ /* Tcl_Eval(interp, "destroy ."); */
+ if (Tk_GetNumMainWindows() > 0) {
+ Tk_Window main_win = Tk_MainWindow(interp);
+ if (main_win != (Tk_Window)NULL) {
+ Tk_DestroyWindow(main_win);
+ }
+ }
- /* StringValue(res); */
- res = rb_funcall(res, ID_message, 0, 0);
+ /* StringValue(res); */
+ res = rb_funcall(res, ID_message, 0, 0);
- Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL);
+ Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- rb_raise(rb_eSystemExit, RSTRING(res)->ptr);
+ rb_raise(rb_eSystemExit, RSTRING(res)->ptr);
- } else if (rb_obj_is_kind_of(res, eLocalJumpError)) {
- VALUE reason = rb_ivar_get(res, ID_at_reason);
+ } else if (rb_obj_is_kind_of(res, eLocalJumpError)) {
+ VALUE reason = rb_ivar_get(res, ID_at_reason);
- if (TYPE(reason) != T_SYMBOL) {
- ip_set_exc_message(interp, res);
- return TCL_ERROR;
- }
+ if (TYPE(reason) != T_SYMBOL) {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
- if (SYM2ID(reason) == ID_return) {
- ip_set_exc_message(interp, res);
- return TCL_RETURN;
+ if (SYM2ID(reason) == ID_return) {
+ ip_set_exc_message(interp, res);
+ return TCL_RETURN;
- } else if (SYM2ID(reason) == ID_break) {
- ip_set_exc_message(interp, res);
- return TCL_BREAK;
+ } else if (SYM2ID(reason) == ID_break) {
+ ip_set_exc_message(interp, res);
+ return TCL_BREAK;
- } else if (SYM2ID(reason) == ID_next) {
- ip_set_exc_message(interp, res);
- return TCL_CONTINUE;
+ } else if (SYM2ID(reason) == ID_next) {
+ ip_set_exc_message(interp, res);
+ return TCL_CONTINUE;
- } else {
- ip_set_exc_message(interp, res);
- return TCL_ERROR;
- }
- } else {
- ip_set_exc_message(interp, res);
- return TCL_ERROR;
- }
+ } else {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
+ } else {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
}
/* result must be string or nil */
if (NIL_P(res)) {
- DUMP1("(rb_eval_cmd result) nil");
- Tcl_ResetResult(interp);
- return TCL_OK;
+ DUMP1("(rb_eval_cmd result) nil");
+ Tcl_ResetResult(interp);
+ return TCL_OK;
}
@@ -1839,7 +1839,6 @@ ip_ruby_cmd(clientData, interp, argc, argv)
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
-
old_gc = rb_gc_disable();
res = TkStringValue(res);
@@ -1873,9 +1872,9 @@ ip_InterpExitCommand(clientData, interp, argc, argv)
#endif
{
if (!Tcl_InterpDeleted(interp)) {
- Tcl_Preserve(interp);
- Tcl_Eval(interp, "interp eval {} {destroy .}; interp delete {}");
- Tcl_Release(interp);
+ Tcl_Preserve(interp);
+ Tcl_Eval(interp, "interp eval {} {destroy .}; interp delete {}");
+ Tcl_Release(interp);
}
return TCL_OK;
}
@@ -1907,19 +1906,19 @@ ip_RubyExitCommand(clientData, interp, argc, argv)
#endif
if (rb_safe_level() >= 4) {
- rb_raise(rb_eSecurityError,
- "Insecure operation `exit' at level %d",
- rb_safe_level());
+ rb_raise(rb_eSecurityError,
+ "Insecure operation `exit' at level %d",
+ rb_safe_level());
} else if (Tcl_IsSafe(interp)) {
- rb_raise(rb_eSecurityError,
- "Insecure operation `exit' on a safe interpreter");
+ rb_raise(rb_eSecurityError,
+ "Insecure operation `exit' on a safe interpreter");
#if 0
} else if (Tcl_GetMaster(interp) != (Tcl_Interp *)NULL) {
- Tcl_Preserve(interp);
- Tcl_Eval(interp, "interp eval {} {destroy .}");
- Tcl_Eval(interp, "interp delete {}");
- Tcl_Release(interp);
- return TCL_OK;
+ Tcl_Preserve(interp);
+ Tcl_Eval(interp, "interp eval {} {destroy .}");
+ Tcl_Eval(interp, "interp delete {}");
+ Tcl_Release(interp);
+ return TCL_OK;
#endif
}
@@ -1927,38 +1926,38 @@ ip_RubyExitCommand(clientData, interp, argc, argv)
switch(argc) {
case 1:
- rb_exit(0); /* not return if succeed */
+ rb_exit(0); /* not return if succeed */
- Tcl_AppendResult(interp,
- "fail to call \"", cmd, "\"", (char *)NULL);
- return TCL_ERROR;
+ Tcl_AppendResult(interp,
+ "fail to call \"", cmd, "\"", (char *)NULL);
+ return TCL_ERROR;
case 2:
#if TCL_MAJOR_VERSION >= 8
- if (!Tcl_GetIntFromObj(interp, argv[1], &state)) {
- return TCL_ERROR;
- }
- param = Tcl_GetString(argv[1]);
+ if (!Tcl_GetIntFromObj(interp, argv[1], &state)) {
+ return TCL_ERROR;
+ }
+ param = Tcl_GetString(argv[1]);
#else /* TCL_MAJOR_VERSION < 8 */
- state = (int)strtol(argv[1], &endptr, 0);
- if (endptr) {
- Tcl_AppendResult(interp,
- "expected integer but got \"",
- argv[1], "\"", (char *)NULL);
- }
- param = argv[1];
-#endif
- rb_exit(state); /* not return if succeed */
-
- Tcl_AppendResult(interp, "fail to call \"", cmd, " ",
- param, "\"", (char *)NULL);
- return TCL_ERROR;
+ state = (int)strtol(argv[1], &endptr, 0);
+ if (endptr) {
+ Tcl_AppendResult(interp,
+ "expected integer but got \"",
+ argv[1], "\"", (char *)NULL);
+ }
+ param = argv[1];
+#endif
+ rb_exit(state); /* not return if succeed */
+
+ Tcl_AppendResult(interp, "fail to call \"", cmd, " ",
+ param, "\"", (char *)NULL);
+ return TCL_ERROR;
default:
- /* arguemnt error */
- Tcl_AppendResult(interp,
- "wrong number of arguments: should be \"",
- cmd, " ?returnCode?\"", (char *)NULL);
- return TCL_ERROR;
+ /* arguemnt error */
+ Tcl_AppendResult(interp,
+ "wrong number of arguments: should be \"",
+ cmd, " ?returnCode?\"", (char *)NULL);
+ return TCL_ERROR;
}
}
@@ -1968,10 +1967,10 @@ ip_RubyExitCommand(clientData, interp, argc, argv)
/**************************/
#if 0 /*
- Disable the following "update" and "thread_update". Bcause,
- they don't work in a callback-proc. After calling update in
- a callback-proc, the callback proc never be worked.
- If the problem will be fixed in the future, may enable the
+ Disable the following "update" and "thread_update". Bcause,
+ they don't work in a callback-proc. After calling update in
+ a callback-proc, the callback proc never be worked.
+ If the problem will be fixed in the future, may enable the
functions.
*/
/*********************/
@@ -1979,7 +1978,7 @@ ip_RubyExitCommand(clientData, interp, argc, argv)
/*********************/
#if TCL_MAJOR_VERSION >= 8
static int ip_rbUpdateObjCmd _((ClientData, Tcl_Interp *, int,
- Tcl_Obj *CONST []));
+ Tcl_Obj *CONST []));
static int
ip_rbUpdateObjCmd(clientData, interp, objc, objv)
ClientData clientData;
@@ -2006,37 +2005,37 @@ ip_rbUpdateCommand(clientData, interp, objc, objv)
DUMP1("Ruby's 'update' is called");
if (objc == 1) {
- flags = TCL_ALL_EVENTS|TCL_DONT_WAIT;
+ flags = TCL_ALL_EVENTS|TCL_DONT_WAIT;
} else if (objc == 2) {
- if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions,
- "option", 0, &optionIndex) != TCL_OK) {
- return TCL_ERROR;
- }
- switch ((enum updateOptions) optionIndex) {
- case REGEXP_IDLETASKS: {
- flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
- break;
- }
- default: {
+ if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions,
+ "option", 0, &optionIndex) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch ((enum updateOptions) optionIndex) {
+ case REGEXP_IDLETASKS: {
+ flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
+ break;
+ }
+ default: {
Tcl_Panic("ip_rbUpdateObjCmd: bad option index to UpdateOptions");
- }
- }
+ }
+ }
} else {
#ifdef Tcl_WrongNumArgs
Tcl_WrongNumArgs(interp, 1, objv, "[ idletasks ]");
#else
# if TCL_MAJOR_VERSION >= 8
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- Tcl_GetStringFromObj(objv[0], &dummy),
- " [ idletasks ]\"",
- (char *) NULL);
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " [ idletasks ]\"",
+ (char *) NULL);
# else /* TCL_MAJOR_VERSION < 8 */
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- objv[0], " [ idletasks ]\"", (char *) NULL);
+ objv[0], " [ idletasks ]\"", (char *) NULL);
# endif
#endif
- return TCL_ERROR;
+ return TCL_ERROR;
}
/* call eventloop */
@@ -2082,7 +2081,7 @@ rb_threadUpdateProc(clientData)
#if TCL_MAJOR_VERSION >= 8
static int ip_rb_threadUpdateObjCmd _((ClientData, Tcl_Interp *, int,
- Tcl_Obj *CONST []));
+ Tcl_Obj *CONST []));
static int
ip_rb_threadUpdateObjCmd(clientData, interp, objc, objv)
ClientData clientData;
@@ -2091,7 +2090,7 @@ ip_rb_threadUpdateObjCmd(clientData, interp, objc, objv)
Tcl_Obj *CONST objv[];
#else /* TCL_MAJOR_VERSION < 8 */
static int ip_rb_threadUpdateCommand _((ClientData, Tcl_Interp *, int,
- char *[]));
+ char *[]));
static int
ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
ClientData clientData;
@@ -2115,19 +2114,19 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
#define USE_TCL_UPDATE 0
#if TCL_MAJOR_VERSION >= 8
# if USE_TCL_UPDATE
- DUMP1("call Tcl_UpdateObjCmd");
- return Tcl_UpdateObjCmd(clientData, interp, objc, objv);
+ DUMP1("call Tcl_UpdateObjCmd");
+ return Tcl_UpdateObjCmd(clientData, interp, objc, objv);
# else
- DUMP1("call ip_rbUpdateObjCmd");
- return ip_rbUpdateObjCmd(clientData, interp, objc, objv);
+ DUMP1("call ip_rbUpdateObjCmd");
+ return ip_rbUpdateObjCmd(clientData, interp, objc, objv);
# endif
#else /* TCL_MAJOR_VERSION < 8 */
# if USE_TCL_UPDATE
- DUMP1("call ip_rbUpdateCommand");
- return Tcl_UpdateCommand(clientData, interp, objc, objv);
+ DUMP1("call ip_rbUpdateCommand");
+ return Tcl_UpdateCommand(clientData, interp, objc, objv);
# else
- DUMP1("call ip_rbUpdateCommand");
- return ip_rbUpdateCommand(clientData, interp, objc, objv);
+ DUMP1("call ip_rbUpdateCommand");
+ return ip_rbUpdateCommand(clientData, interp, objc, objv);
# endif
#endif
}
@@ -2135,37 +2134,37 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
DUMP1("start Ruby's 'thread_update' body");
if (objc == 1) {
- flags = TCL_ALL_EVENTS|TCL_DONT_WAIT;
+ flags = TCL_ALL_EVENTS|TCL_DONT_WAIT;
} else if (objc == 2) {
- if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions,
- "option", 0, &optionIndex) != TCL_OK) {
- return TCL_ERROR;
- }
- switch ((enum updateOptions) optionIndex) {
- case REGEXP_IDLETASKS: {
- flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
- break;
- }
- default: {
+ if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions,
+ "option", 0, &optionIndex) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch ((enum updateOptions) optionIndex) {
+ case REGEXP_IDLETASKS: {
+ flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
+ break;
+ }
+ default: {
Tcl_Panic("ip_rb_threadUpdateObjCmd: bad option index to UpdateOptions");
- }
- }
+ }
+ }
} else {
#ifdef Tcl_WrongNumArgs
Tcl_WrongNumArgs(interp, 1, objv, "[ idletasks ]");
#else
# if TCL_MAJOR_VERSION >= 8
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- Tcl_GetStringFromObj(objv[0], &dummy),
- " [ idletasks ]\"",
- (char *) NULL);
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " [ idletasks ]\"",
+ (char *) NULL);
# else /* TCL_MAJOR_VERSION < 8 */
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- objv[0], " [ idletasks ]\"", (char *) NULL);
+ objv[0], " [ idletasks ]\"", (char *) NULL);
# endif
#endif
- return TCL_ERROR;
+ return TCL_ERROR;
}
DUMP1("pass argument check");
@@ -2179,8 +2178,8 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
Tcl_DoWhenIdle(rb_threadUpdateProc, (ClientData) param);
while(!param->done) {
- DUMP1("wait for complete idle proc");
- rb_thread_stop();
+ DUMP1("wait for complete idle proc");
+ rb_thread_stop();
}
Tcl_Release(param);
@@ -2197,7 +2196,7 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
/***************************/
#if TCL_MAJOR_VERSION >= 8
static char *VwaitVarProc _((ClientData, Tcl_Interp *,
- CONST84 char *,CONST84 char *, int));
+ CONST84 char *,CONST84 char *, int));
static char *
VwaitVarProc(clientData, interp, name1, name2, flags)
ClientData clientData; /* Pointer to integer to set to 1. */
@@ -2224,7 +2223,7 @@ VwaitVarProc(clientData, interp, name1, name2, flags)
#if TCL_MAJOR_VERSION >= 8
static int ip_rbVwaitObjCmd _((ClientData, Tcl_Interp *, int,
- Tcl_Obj *CONST []));
+ Tcl_Obj *CONST []));
static int
ip_rbVwaitObjCmd(clientData, interp, objc, objv)
ClientData clientData;
@@ -2253,22 +2252,22 @@ ip_rbVwaitCommand(clientData, interp, objc, objv)
#ifdef Tcl_WrongNumArgs
Tcl_WrongNumArgs(interp, 1, objv, "name");
#else
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
#if TCL_MAJOR_VERSION >= 8
- /* nameString = Tcl_GetString(objv[0]); */
- nameString = Tcl_GetStringFromObj(objv[0], &dummy);
+ /* nameString = Tcl_GetString(objv[0]); */
+ nameString = Tcl_GetStringFromObj(objv[0], &dummy);
#else /* TCL_MAJOR_VERSION < 8 */
- nameString = objv[0];
+ nameString = objv[0];
#endif
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- nameString, " name\"", (char *) NULL);
+ nameString, " name\"", (char *) NULL);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
#endif
- Tcl_Release(interp);
+ Tcl_Release(interp);
return TCL_ERROR;
}
@@ -2285,22 +2284,22 @@ ip_rbVwaitCommand(clientData, interp, objc, objv)
/*
if (Tcl_TraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- VwaitVarProc, (ClientData) &done) != TCL_OK) {
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ VwaitVarProc, (ClientData) &done) != TCL_OK) {
return TCL_ERROR;
}
*/
ret = Tcl_TraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- VwaitVarProc, (ClientData) &done);
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ VwaitVarProc, (ClientData) &done);
rb_thread_critical = thr_crit_bup;
if (ret != TCL_OK) {
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[1]);
+ Tcl_DecrRefCount(objv[1]);
#endif
- Tcl_Release(interp);
+ Tcl_Release(interp);
return TCL_ERROR;
}
done = 0;
@@ -2310,8 +2309,8 @@ ip_rbVwaitCommand(clientData, interp, objc, objv)
rb_thread_critical = Qtrue;
Tcl_UntraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- VwaitVarProc, (ClientData) &done);
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ VwaitVarProc, (ClientData) &done);
rb_thread_critical = thr_crit_bup;
@@ -2322,18 +2321,18 @@ ip_rbVwaitCommand(clientData, interp, objc, objv)
Tcl_ResetResult(interp);
if (!foundEvent) {
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
Tcl_AppendResult(interp, "can't wait for variable \"", nameString,
- "\": would wait forever", (char *) NULL);
+ "\": would wait forever", (char *) NULL);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[1]);
+ Tcl_DecrRefCount(objv[1]);
#endif
- Tcl_Release(interp);
+ Tcl_Release(interp);
return TCL_ERROR;
}
@@ -2350,7 +2349,7 @@ ip_rbVwaitCommand(clientData, interp, objc, objv)
/**************************/
#if TCL_MAJOR_VERSION >= 8
static char *WaitVariableProc _((ClientData, Tcl_Interp *,
- CONST84 char *,CONST84 char *, int));
+ CONST84 char *,CONST84 char *, int));
static char *
WaitVariableProc(clientData, interp, name1, name2, flags)
ClientData clientData; /* Pointer to integer to set to 1. */
@@ -2360,7 +2359,7 @@ WaitVariableProc(clientData, interp, name1, name2, flags)
int flags; /* Information about what happened. */
#else /* TCL_MAJOR_VERSION < 8 */
static char *WaitVariableProc _((ClientData, Tcl_Interp *,
- char *, char *, int));
+ char *, char *, int));
static char *
WaitVariableProc(clientData, interp, name1, name2, flags)
ClientData clientData; /* Pointer to integer to set to 1. */
@@ -2407,7 +2406,7 @@ WaitWindowProc(clientData, eventPtr)
#if TCL_MAJOR_VERSION >= 8
static int ip_rbTkWaitObjCmd _((ClientData, Tcl_Interp *, int,
- Tcl_Obj *CONST []));
+ Tcl_Obj *CONST []));
static int
ip_rbTkWaitObjCmd(clientData, interp, objc, objv)
ClientData clientData;
@@ -2428,7 +2427,7 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv)
Tk_Window window;
int done, index;
static CONST char *optionStrings[] = { "variable", "visibility", "window",
- (char *) NULL };
+ (char *) NULL };
enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
char *nameString;
int ret, dummy;
@@ -2442,24 +2441,24 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv)
#ifdef Tcl_WrongNumArgs
Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
#else
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
#if TCL_MAJOR_VERSION >= 8
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- Tcl_GetStringFromObj(objv[0], &dummy),
- " variable|visibility|window name\"",
- (char *) NULL);
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " variable|visibility|window name\"",
+ (char *) NULL);
#else /* TCL_MAJOR_VERSION < 8 */
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- objv[0], " variable|visibility|window name\"",
- (char *) NULL);
+ objv[0], " variable|visibility|window name\"",
+ (char *) NULL);
#endif
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
#endif
- Tcl_Release(interp);
+ Tcl_Release(interp);
return TCL_ERROR;
}
@@ -2470,40 +2469,40 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv)
/*
if (Tcl_GetIndexFromObj(interp, objv[1],
(CONST84 char **)optionStrings,
- "option", 0, &index) != TCL_OK) {
+ "option", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
*/
ret = Tcl_GetIndexFromObj(interp, objv[1],
- (CONST84 char **)optionStrings,
- "option", 0, &index);
+ (CONST84 char **)optionStrings,
+ "option", 0, &index);
rb_thread_critical = thr_crit_bup;
if (ret != TCL_OK) {
- Tcl_Release(interp);
+ Tcl_Release(interp);
return TCL_ERROR;
}
#else /* TCL_MAJOR_VERSION < 8 */
{
- int c = objv[1][0];
- size_t length = strlen(objv[1]);
-
- if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
- && (length >= 2)) {
- index = TKWAIT_VARIABLE;
- } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
- && (length >= 2)) {
- index = TKWAIT_VISIBILITY;
- } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
- index = TKWAIT_WINDOW;
- } else {
- Tcl_AppendResult(interp, "bad option \"", objv[1],
- "\": must be variable, visibility, or window",
- (char *) NULL);
- Tcl_Release(interp);
- return TCL_ERROR;
- }
+ int c = objv[1][0];
+ size_t length = strlen(objv[1]);
+
+ if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VARIABLE;
+ } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VISIBILITY;
+ } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
+ index = TKWAIT_WINDOW;
+ } else {
+ Tcl_AppendResult(interp, "bad option \"", objv[1],
+ "\": must be variable, visibility, or window",
+ (char *) NULL);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
}
#endif
@@ -2522,142 +2521,142 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv)
switch ((enum options) index) {
case TKWAIT_VARIABLE:
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
- /*
- if (Tcl_TraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- WaitVariableProc, (ClientData) &done) != TCL_OK) {
- return TCL_ERROR;
- }
- */
- ret = Tcl_TraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- WaitVariableProc, (ClientData) &done);
-
- rb_thread_critical = thr_crit_bup;
-
- if (ret != TCL_OK) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- Tcl_Release(interp);
- return TCL_ERROR;
- }
- done = 0;
- lib_eventloop_core(check_rootwidget_flag, 0, &done);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ done = 0;
+ lib_eventloop_core(check_rootwidget_flag, 0, &done);
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- Tcl_UntraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- WaitVariableProc, (ClientData) &done);
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done);
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- break;
+ break;
case TKWAIT_VISIBILITY:
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
- window = NULL;
- } else {
- window = Tk_NameToWindow(interp, nameString, tkwin);
- }
+ if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
- if (window == NULL) {
- rb_thread_critical = thr_crit_bup;
+ if (window == NULL) {
+ rb_thread_critical = thr_crit_bup;
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- Tcl_Release(interp);
- return TCL_ERROR;
- }
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
- Tk_CreateEventHandler(window,
- VisibilityChangeMask|StructureNotifyMask,
- WaitVisibilityProc, (ClientData) &done);
+ Tk_CreateEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ WaitVisibilityProc, (ClientData) &done);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- done = 0;
- lib_eventloop_core(check_rootwidget_flag, 0, &done);
- if (done != 1) {
- /*
- * Note that we do not delete the event handler because it
- * was deleted automatically when the window was destroyed.
- */
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ done = 0;
+ lib_eventloop_core(check_rootwidget_flag, 0, &done);
+ if (done != 1) {
+ /*
+ * Note that we do not delete the event handler because it
+ * was deleted automatically when the window was destroyed.
+ */
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "window \"", nameString,
- "\" was deleted before its visibility changed",
- (char *) NULL);
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "window \"", nameString,
+ "\" was deleted before its visibility changed",
+ (char *) NULL);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- Tcl_Release(interp);
- return TCL_ERROR;
- }
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- Tk_DeleteEventHandler(window,
- VisibilityChangeMask|StructureNotifyMask,
- WaitVisibilityProc, (ClientData) &done);
+ Tk_DeleteEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ WaitVisibilityProc, (ClientData) &done);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- break;
+ break;
case TKWAIT_WINDOW:
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
- window = NULL;
- } else {
- window = Tk_NameToWindow(interp, nameString, tkwin);
- }
+ if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- if (window == NULL) {
- rb_thread_critical = thr_crit_bup;
- Tcl_Release(interp);
- return TCL_ERROR;
- }
+ if (window == NULL) {
+ rb_thread_critical = thr_crit_bup;
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
- Tk_CreateEventHandler(window, StructureNotifyMask,
- WaitWindowProc, (ClientData) &done);
+ Tk_CreateEventHandler(window, StructureNotifyMask,
+ WaitWindowProc, (ClientData) &done);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- done = 0;
- lib_eventloop_core(check_rootwidget_flag, 0, &done);
- /*
- * Note: there's no need to delete the event handler. It was
- * deleted automatically when the window was destroyed.
- */
- break;
+ done = 0;
+ lib_eventloop_core(check_rootwidget_flag, 0, &done);
+ /*
+ * Note: there's no need to delete the event handler. It was
+ * deleted automatically when the window was destroyed.
+ */
+ break;
}
/*
@@ -2680,7 +2679,7 @@ struct th_vwait_param {
#if TCL_MAJOR_VERSION >= 8
static char *rb_threadVwaitProc _((ClientData, Tcl_Interp *,
- CONST84 char *,CONST84 char *, int));
+ CONST84 char *,CONST84 char *, int));
static char *
rb_threadVwaitProc(clientData, interp, name1, name2, flags)
ClientData clientData; /* Pointer to integer to set to 1. */
@@ -2690,7 +2689,7 @@ rb_threadVwaitProc(clientData, interp, name1, name2, flags)
int flags; /* Information about what happened. */
#else /* TCL_MAJOR_VERSION < 8 */
static char *rb_threadVwaitProc _((ClientData, Tcl_Interp *,
- char *, char *, int));
+ char *, char *, int));
static char *
rb_threadVwaitProc(clientData, interp, name1, name2, flags)
ClientData clientData; /* Pointer to integer to set to 1. */
@@ -2703,9 +2702,9 @@ rb_threadVwaitProc(clientData, interp, name1, name2, flags)
struct th_vwait_param *param = (struct th_vwait_param *) clientData;
if (flags & (TCL_INTERP_DESTROYED | TCL_TRACE_DESTROYED)) {
- param->done = -1;
+ param->done = -1;
} else {
- param->done = 1;
+ param->done = 1;
}
rb_thread_wakeup(param->thread);
@@ -2748,7 +2747,7 @@ rb_threadWaitWindowProc(clientData, eventPtr)
#if TCL_MAJOR_VERSION >= 8
static int ip_rb_threadVwaitObjCmd _((ClientData, Tcl_Interp *, int,
- Tcl_Obj *CONST []));
+ Tcl_Obj *CONST []));
static int
ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv)
ClientData clientData;
@@ -2757,7 +2756,7 @@ ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv)
Tcl_Obj *CONST objv[];
#else /* TCL_MAJOR_VERSION < 8 */
static int ip_rb_threadVwaitCommand _((ClientData, Tcl_Interp *, int,
- char *[]));
+ char *[]));
static int
ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
ClientData clientData;
@@ -2776,11 +2775,11 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
if (rb_thread_alone() || eventloop_thread == current_thread) {
#if TCL_MAJOR_VERSION >= 8
- DUMP1("call ip_rbVwaitObjCmd");
- return ip_rbVwaitObjCmd(clientData, interp, objc, objv);
+ DUMP1("call ip_rbVwaitObjCmd");
+ return ip_rbVwaitObjCmd(clientData, interp, objc, objv);
#else /* TCL_MAJOR_VERSION < 8 */
- DUMP1("call ip_rbVwaitCommand");
- return ip_rbVwaitCommand(clientData, interp, objc, objv);
+ DUMP1("call ip_rbVwaitCommand");
+ return ip_rbVwaitCommand(clientData, interp, objc, objv);
#endif
}
@@ -2790,22 +2789,22 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
#ifdef Tcl_WrongNumArgs
Tcl_WrongNumArgs(interp, 1, objv, "name");
#else
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
#if TCL_MAJOR_VERSION >= 8
- /* nameString = Tcl_GetString(objv[0]); */
- nameString = Tcl_GetStringFromObj(objv[0], &dummy);
+ /* nameString = Tcl_GetString(objv[0]); */
+ nameString = Tcl_GetStringFromObj(objv[0], &dummy);
#else /* TCL_MAJOR_VERSION < 8 */
- nameString = objv[0];
+ nameString = objv[0];
#endif
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- nameString, " name\"", (char *) NULL);
+ nameString, " name\"", (char *) NULL);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
#endif
- Tcl_Release(interp);
+ Tcl_Release(interp);
return TCL_ERROR;
}
@@ -2826,37 +2825,37 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
/*
if (Tcl_TraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
return TCL_ERROR;
}
*/
ret = Tcl_TraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- rb_threadVwaitProc, (ClientData) param);
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
rb_thread_critical = thr_crit_bup;
if (ret != TCL_OK) {
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[1]);
+ Tcl_DecrRefCount(objv[1]);
#endif
- Tcl_Release(interp);
+ Tcl_Release(interp);
return TCL_ERROR;
}
/* if (!param->done) { */
while(!param->done) {
- rb_thread_stop();
+ rb_thread_stop();
}
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
if (param->done > 0) {
- Tcl_UntraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- rb_threadVwaitProc, (ClientData) param);
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
}
Tcl_Release(param);
@@ -2873,7 +2872,7 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
#if TCL_MAJOR_VERSION >= 8
static int ip_rb_threadTkWaitObjCmd _((ClientData, Tcl_Interp *, int,
- Tcl_Obj *CONST []));
+ Tcl_Obj *CONST []));
static int
ip_rb_threadTkWaitObjCmd(clientData, interp, objc, objv)
ClientData clientData;
@@ -2882,7 +2881,7 @@ ip_rb_threadTkWaitObjCmd(clientData, interp, objc, objv)
Tcl_Obj *CONST objv[];
#else /* TCL_MAJOR_VERSION < 8 */
static int ip_rb_threadTkWaitCommand _((ClientData, Tcl_Interp *, int,
- char *[]));
+ char *[]));
static int
ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
ClientData clientData;
@@ -2896,7 +2895,7 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
Tk_Window window;
int index;
static CONST char *optionStrings[] = { "variable", "visibility", "window",
- (char *) NULL };
+ (char *) NULL };
enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
char *nameString;
int ret, dummy;
@@ -2907,11 +2906,11 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
if (rb_thread_alone() || eventloop_thread == current_thread) {
#if TCL_MAJOR_VERSION >= 8
- DUMP1("call ip_rbTkWaitObjCmd");
- return ip_rbTkWaitObjCmd(clientData, interp, objc, objv);
+ DUMP1("call ip_rbTkWaitObjCmd");
+ return ip_rbTkWaitObjCmd(clientData, interp, objc, objv);
#else /* TCL_MAJOR_VERSION < 8 */
- DUMP1("call rb_VwaitCommand");
- return ip_rbTkWaitCommand(clientData, interp, objc, objv);
+ DUMP1("call rb_VwaitCommand");
+ return ip_rbTkWaitCommand(clientData, interp, objc, objv);
#endif
}
@@ -2922,25 +2921,25 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
#ifdef Tcl_WrongNumArgs
Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
#else
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
#if TCL_MAJOR_VERSION >= 8
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- Tcl_GetStringFromObj(objv[0], &dummy),
- " variable|visibility|window name\"",
- (char *) NULL);
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " variable|visibility|window name\"",
+ (char *) NULL);
#else /* TCL_MAJOR_VERSION < 8 */
Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
- objv[0], " variable|visibility|window name\"",
- (char *) NULL);
+ objv[0], " variable|visibility|window name\"",
+ (char *) NULL);
#endif
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
#endif
- Tcl_Release(tkwin);
- Tcl_Release(interp);
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
return TCL_ERROR;
}
@@ -2950,42 +2949,42 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
/*
if (Tcl_GetIndexFromObj(interp, objv[1],
(CONST84 char **)optionStrings,
- "option", 0, &index) != TCL_OK) {
+ "option", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
*/
ret = Tcl_GetIndexFromObj(interp, objv[1],
- (CONST84 char **)optionStrings,
- "option", 0, &index);
+ (CONST84 char **)optionStrings,
+ "option", 0, &index);
rb_thread_critical = thr_crit_bup;
if (ret != TCL_OK) {
- Tcl_Release(tkwin);
- Tcl_Release(interp);
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
return TCL_ERROR;
}
#else /* TCL_MAJOR_VERSION < 8 */
{
- int c = objv[1][0];
- size_t length = strlen(objv[1]);
-
- if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
- && (length >= 2)) {
- index = TKWAIT_VARIABLE;
- } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
- && (length >= 2)) {
- index = TKWAIT_VISIBILITY;
- } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
- index = TKWAIT_WINDOW;
- } else {
- Tcl_AppendResult(interp, "bad option \"", objv[1],
- "\": must be variable, visibility, or window",
- (char *) NULL);
- Tcl_Release(tkwin);
- Tcl_Release(interp);
- return TCL_ERROR;
- }
+ int c = objv[1][0];
+ size_t length = strlen(objv[1]);
+
+ if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VARIABLE;
+ } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VISIBILITY;
+ } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
+ index = TKWAIT_WINDOW;
+ } else {
+ Tcl_AppendResult(interp, "bad option \"", objv[1],
+ "\": must be variable, visibility, or window",
+ (char *) NULL);
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
}
#endif
@@ -3009,196 +3008,196 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
switch ((enum options) index) {
case TKWAIT_VARIABLE:
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
- /*
- if (Tcl_TraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
- return TCL_ERROR;
- }
- */
- ret = Tcl_TraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- rb_threadVwaitProc, (ClientData) param);
-
- rb_thread_critical = thr_crit_bup;
-
- if (ret != TCL_OK) {
- Tcl_Release(param);
- Tcl_Free((char *)param);
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- Tcl_Release(tkwin);
- Tcl_Release(interp);
- return TCL_ERROR;
- }
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
- /* if (!param->done) { */
- while(!param->done) {
- rb_thread_stop();
- }
+ /* if (!param->done) { */
+ while(!param->done) {
+ rb_thread_stop();
+ }
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- if (param->done > 0) {
- Tcl_UntraceVar(interp, nameString,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- rb_threadVwaitProc, (ClientData) param);
- }
+ if (param->done > 0) {
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+ }
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- break;
+ break;
case TKWAIT_VISIBILITY:
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
- window = NULL;
- } else {
- window = Tk_NameToWindow(interp, nameString, tkwin);
- }
+ if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
- if (window == NULL) {
- rb_thread_critical = thr_crit_bup;
+ if (window == NULL) {
+ rb_thread_critical = thr_crit_bup;
- Tcl_Release(param);
- Tcl_Free((char *)param);
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
-#endif
- Tcl_Release(tkwin);
- Tcl_Release(interp);
- return TCL_ERROR;
- }
- Tcl_Preserve(window);
-
- Tk_CreateEventHandler(window,
- VisibilityChangeMask|StructureNotifyMask,
- rb_threadWaitVisibilityProc, (ClientData) param);
-
- rb_thread_critical = thr_crit_bup;
-
- /* if (!param->done) { */
- /*
- while(!param->done) {
- rb_thread_stop();
- }
- */
- while(param->done != TKWAIT_MODE_VISIBILITY) {
- if (param->done == TKWAIT_MODE_DESTROY) break;
- rb_thread_stop();
- }
-
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
-
- /* when a window is destroyed, no need to call Tk_DeleteEventHandler */
- if (param->done != TKWAIT_MODE_DESTROY) {
- Tk_DeleteEventHandler(window,
- VisibilityChangeMask|StructureNotifyMask,
- rb_threadWaitVisibilityProc,
- (ClientData) param);
- }
-
- if (param->done != 1) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "window \"", nameString,
- "\" was deleted before its visibility changed",
- (char *) NULL);
-
- rb_thread_critical = thr_crit_bup;
-
- Tcl_Release(window);
-
- Tcl_Release(param);
- Tcl_Free((char *)param);
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ Tcl_Preserve(window);
+
+ Tk_CreateEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ rb_threadWaitVisibilityProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* if (!param->done) { */
+ /*
+ while(!param->done) {
+ rb_thread_stop();
+ }
+ */
+ while(param->done != TKWAIT_MODE_VISIBILITY) {
+ if (param->done == TKWAIT_MODE_DESTROY) break;
+ rb_thread_stop();
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* when a window is destroyed, no need to call Tk_DeleteEventHandler */
+ if (param->done != TKWAIT_MODE_DESTROY) {
+ Tk_DeleteEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ rb_threadWaitVisibilityProc,
+ (ClientData) param);
+ }
+
+ if (param->done != 1) {
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "window \"", nameString,
+ "\" was deleted before its visibility changed",
+ (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+ Tcl_Release(window);
+
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- Tcl_Release(tkwin);
- Tcl_Release(interp);
- return TCL_ERROR;
- }
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
- Tcl_Release(window);
+ Tcl_Release(window);
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- break;
+ break;
case TKWAIT_WINDOW:
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
- window = NULL;
- } else {
- window = Tk_NameToWindow(interp, nameString, tkwin);
- }
+ if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(objv[2]);
+ Tcl_DecrRefCount(objv[2]);
#endif
- if (window == NULL) {
- rb_thread_critical = thr_crit_bup;
+ if (window == NULL) {
+ rb_thread_critical = thr_crit_bup;
- Tcl_Release(param);
- Tcl_Free((char *)param);
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
- Tcl_Release(tkwin);
- Tcl_Release(interp);
- return TCL_ERROR;
- }
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
- Tcl_Preserve(window);
+ Tcl_Preserve(window);
- Tk_CreateEventHandler(window, StructureNotifyMask,
- rb_threadWaitWindowProc, (ClientData) param);
+ Tk_CreateEventHandler(window, StructureNotifyMask,
+ rb_threadWaitWindowProc, (ClientData) param);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- /* if (!param->done) { */
- /*
- while(!param->done) {
- rb_thread_stop();
- }
- */
- while(param->done != TKWAIT_MODE_DESTROY) {
- rb_thread_stop();
- }
+ /* if (!param->done) { */
+ /*
+ while(!param->done) {
+ rb_thread_stop();
+ }
+ */
+ while(param->done != TKWAIT_MODE_DESTROY) {
+ rb_thread_stop();
+ }
- Tcl_Release(window);
+ Tcl_Release(window);
- /* when a window is destroyed, no need to call Tk_DeleteEventHandler
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ /* when a window is destroyed, no need to call Tk_DeleteEventHandler
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- Tk_DeleteEventHandler(window, StructureNotifyMask,
- rb_threadWaitWindowProc, (ClientData) param);
+ Tk_DeleteEventHandler(window, StructureNotifyMask,
+ rb_threadWaitWindowProc, (ClientData) param);
- rb_thread_critical = thr_crit_bup;
- */
+ rb_thread_critical = thr_crit_bup;
+ */
- break;
+ break;
} /* end of 'switch' statement */
Tcl_Release(param);
@@ -3251,12 +3250,12 @@ VALUE del_root(ip)
Tk_Window main_win;
if (!Tcl_InterpDeleted(ip)) {
- Tcl_Preserve(ip);
- while((main_win = Tk_MainWindow(ip)) != (Tk_Window)NULL) {
- DUMP1("wait main_win is destroyed");
- Tk_DestroyWindow(main_win);
- }
- Tcl_Release(ip);
+ Tcl_Preserve(ip);
+ while((main_win = Tk_MainWindow(ip)) != (Tk_Window)NULL) {
+ DUMP1("wait main_win is destroyed");
+ Tk_DestroyWindow(main_win);
+ }
+ Tcl_Release(ip);
}
return Qnil;
}
@@ -3276,52 +3275,52 @@ delete_slaves(ip)
Tcl_Preserve(ip);
if (Tcl_Eval(ip, "info slaves") == TCL_ERROR) {
- DUMP2("ip(%lx) cannot get a list of slave IPs", ip);
- return;
+ DUMP2("ip(%lx) cannot get a list of slave IPs", ip);
+ return;
}
slave_list = Tcl_GetObjResult(ip);
Tcl_IncrRefCount(slave_list);
if (Tcl_ListObjLength((Tcl_Interp*)NULL, slave_list, &len) == TCL_ERROR) {
- DUMP1("slave_list is not a list object");
- Tcl_DecrRefCount(slave_list);
- return;
+ DUMP1("slave_list is not a list object");
+ Tcl_DecrRefCount(slave_list);
+ return;
}
for(i = 0; i < len; i++) {
- Tcl_ListObjIndex((Tcl_Interp*)NULL, slave_list, i, &elem);
- Tcl_IncrRefCount(elem);
+ Tcl_ListObjIndex((Tcl_Interp*)NULL, slave_list, i, &elem);
+ Tcl_IncrRefCount(elem);
- if (elem == (Tcl_Obj*)NULL) continue;
+ if (elem == (Tcl_Obj*)NULL) continue;
- /* get slave */
- slave_name = Tcl_GetString(elem);
- slave = Tcl_GetSlave(ip, slave_name);
- if (slave == (Tcl_Interp*)NULL) {
- DUMP2("slave \"%s\" does not exist", slave_name);
- continue;
- }
+ /* get slave */
+ slave_name = Tcl_GetString(elem);
+ slave = Tcl_GetSlave(ip, slave_name);
+ if (slave == (Tcl_Interp*)NULL) {
+ DUMP2("slave \"%s\" does not exist", slave_name);
+ continue;
+ }
- Tcl_DecrRefCount(elem);
+ Tcl_DecrRefCount(elem);
- Tcl_Preserve(slave);
+ Tcl_Preserve(slave);
- if (!Tcl_InterpDeleted(slave)) {
- Tcl_Eval(slave, "foreach i [after info] { after cancel $i }");
- }
+ if (!Tcl_InterpDeleted(slave)) {
+ Tcl_Eval(slave, "foreach i [after info] { after cancel $i }");
+ }
- /* delete slaves of slave */
- delete_slaves(slave);
+ /* delete slaves of slave */
+ delete_slaves(slave);
- /* delete slave */
- del_root(slave);
- while(!Tcl_InterpDeleted(slave)) {
- DUMP1("wait ip is deleted");
- Tcl_DeleteInterp(slave);
- }
+ /* delete slave */
+ del_root(slave);
+ while(!Tcl_InterpDeleted(slave)) {
+ DUMP1("wait ip is deleted");
+ Tcl_DeleteInterp(slave);
+ }
- Tcl_Release(slave);
+ Tcl_Release(slave);
}
Tcl_DecrRefCount(slave_list);
@@ -3338,47 +3337,47 @@ ip_free(ptr)
DUMP2("free Tcl Interp %lx", ptr->ip);
if (ptr) {
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- DUMP2("IP ref_count = %d", ptr->ref_count);
+ DUMP2("IP ref_count = %d", ptr->ref_count);
- if (!Tcl_InterpDeleted(ptr->ip)) {
- DUMP2("IP(%lx) is not deleted", ptr->ip);
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
+ if (!Tcl_InterpDeleted(ptr->ip)) {
+ DUMP2("IP(%lx) is not deleted", ptr->ip);
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
- delete_slaves(ptr->ip);
+ delete_slaves(ptr->ip);
- Tcl_ResetResult(ptr->ip);
+ Tcl_ResetResult(ptr->ip);
- if (Tcl_GetCommandInfo(ptr->ip, finalize_hook_name, &info)) {
- DUMP2("call finalize hook proc '%s'", finalize_hook_name);
- Tcl_Eval(ptr->ip, finalize_hook_name);
- }
+ if (Tcl_GetCommandInfo(ptr->ip, finalize_hook_name, &info)) {
+ DUMP2("call finalize hook proc '%s'", finalize_hook_name);
+ Tcl_Eval(ptr->ip, finalize_hook_name);
+ }
- if (!Tcl_InterpDeleted(ptr->ip)) {
- Tcl_Eval(ptr->ip, "foreach i [after info] {after cancel $i}");
- }
+ if (!Tcl_InterpDeleted(ptr->ip)) {
+ Tcl_Eval(ptr->ip, "foreach i [after info] {after cancel $i}");
+ }
- del_root(ptr->ip);
+ del_root(ptr->ip);
- DUMP1("delete interp");
- while(!Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("wait ip is deleted");
- Tcl_DeleteInterp(ptr->ip);
- }
+ DUMP1("delete interp");
+ while(!Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("wait ip is deleted");
+ Tcl_DeleteInterp(ptr->ip);
+ }
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- }
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ }
- rbtk_release_ip(ptr);
- DUMP2("IP ref_count = %d", ptr->ref_count);
+ rbtk_release_ip(ptr);
+ DUMP2("IP ref_count = %d", ptr->ref_count);
- free(ptr);
+ free(ptr);
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
}
DUMP1("complete freeing Tcl Interp");
}
@@ -3398,7 +3397,7 @@ ip_init(argc, argv, self)
VALUE *argv;
VALUE self;
{
- struct tcltkip *ptr; /* tcltkip data struct */
+ struct tcltkip *ptr; /* tcltkip data struct */
VALUE argv0, opts;
int cnt;
int with_tk = 1;
@@ -3406,7 +3405,7 @@ ip_init(argc, argv, self)
/* security check */
if (ruby_safe_level >= 4) {
- rb_raise(rb_eSecurityError, "Cannot create a TclTkIp object at level %d", ruby_safe_level);
+ rb_raise(rb_eSecurityError, "Cannot create a TclTkIp object at level %d", ruby_safe_level);
}
/* create object */
@@ -3421,7 +3420,7 @@ ip_init(argc, argv, self)
DUMP1("Tcl_CreateInterp");
ptr->ip = Tcl_CreateInterp();
if (ptr->ip == NULL) {
- rb_raise(rb_eRuntimeError, "fail to create a new Tk interpreter");
+ rb_raise(rb_eRuntimeError, "fail to create a new Tk interpreter");
}
rbtk_preserve_ip(ptr);
@@ -3429,15 +3428,15 @@ ip_init(argc, argv, self)
current_interp = ptr->ip;
ptr->has_orig_exit
- = Tcl_GetCommandInfo(ptr->ip, "exit", &(ptr->orig_exit_info));
+ = Tcl_GetCommandInfo(ptr->ip, "exit", &(ptr->orig_exit_info));
/* from Tcl_AppInit() */
DUMP1("Tcl_Init");
if (Tcl_Init(ptr->ip) == TCL_ERROR) {
#if TCL_MAJOR_VERSION >= 8
- rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
#endif
}
@@ -3445,41 +3444,41 @@ ip_init(argc, argv, self)
cnt = rb_scan_args(argc, argv, "02", &argv0, &opts);
switch(cnt) {
case 2:
- /* options */
- if (NIL_P(opts) || opts == Qfalse) {
- /* without Tk */
- with_tk = 0;
- } else {
- /* Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0); */
- Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), TCL_GLOBAL_ONLY);
- }
+ /* options */
+ if (NIL_P(opts) || opts == Qfalse) {
+ /* without Tk */
+ with_tk = 0;
+ } else {
+ /* Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0); */
+ Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), TCL_GLOBAL_ONLY);
+ }
case 1:
- /* argv0 */
- if (!NIL_P(argv0)) {
- /* Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0); */
- Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), TCL_GLOBAL_ONLY);
- }
+ /* argv0 */
+ if (!NIL_P(argv0)) {
+ /* Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0); */
+ Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), TCL_GLOBAL_ONLY);
+ }
case 0:
- /* no args */
- ;
+ /* no args */
+ ;
}
/* from Tcl_AppInit() */
if (with_tk) {
- DUMP1("Tk_Init");
- if (Tk_Init(ptr->ip) == TCL_ERROR) {
+ DUMP1("Tk_Init");
+ if (Tk_Init(ptr->ip) == TCL_ERROR) {
#if TCL_MAJOR_VERSION >= 8
- rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
#endif
- }
- DUMP1("Tcl_StaticPackage(\"Tk\")");
+ }
+ DUMP1("Tcl_StaticPackage(\"Tk\")");
#if TCL_MAJOR_VERSION >= 8
- Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit);
+ Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit);
#else /* TCL_MAJOR_VERSION < 8 */
- Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init,
- (Tcl_PackageInitProc *) NULL);
+ Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init,
+ (Tcl_PackageInitProc *) NULL);
#endif
}
@@ -3491,75 +3490,75 @@ ip_init(argc, argv, self)
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"ruby\")");
Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby_eval, (ClientData)NULL,
- (Tcl_CmdDeleteProc *)NULL);
+ (Tcl_CmdDeleteProc *)NULL);
DUMP1("Tcl_CreateObjCommand(\"ruby_eval\")");
Tcl_CreateObjCommand(ptr->ip, "ruby_eval", ip_ruby_eval, (ClientData)NULL,
- (Tcl_CmdDeleteProc *)NULL);
+ (Tcl_CmdDeleteProc *)NULL);
DUMP1("Tcl_CreateObjCommand(\"ruby_cmd\")");
Tcl_CreateObjCommand(ptr->ip, "ruby_cmd", ip_ruby_cmd, (ClientData)NULL,
- (Tcl_CmdDeleteProc *)NULL);
+ (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"ruby\")");
Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby_eval, (ClientData)NULL,
- (Tcl_CmdDeleteProc *)NULL);
+ (Tcl_CmdDeleteProc *)NULL);
DUMP1("Tcl_CreateCommand(\"ruby_eval\")");
Tcl_CreateCommand(ptr->ip, "ruby_eval", ip_ruby_eval, (ClientData)NULL,
- (Tcl_CmdDeleteProc *)NULL);
+ (Tcl_CmdDeleteProc *)NULL);
DUMP1("Tcl_CreateCommand(\"ruby_cmd\")");
Tcl_CreateCommand(ptr->ip, "ruby_cmd", ip_ruby_cmd, (ClientData)NULL,
- (Tcl_CmdDeleteProc *)NULL);
+ (Tcl_CmdDeleteProc *)NULL);
#endif
/* add 'interp_exit', 'ruby_exit' and replace 'exit' command */
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"interp_exit\")");
Tcl_CreateObjCommand(ptr->ip, "interp_exit", ip_InterpExitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
DUMP1("Tcl_CreateObjCommand(\"ruby_exit\")");
Tcl_CreateObjCommand(ptr->ip, "ruby_exit", ip_RubyExitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"interp_exit\")");
Tcl_CreateCommand(ptr->ip, "interp_exit", ip_InterpExitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
DUMP1("Tcl_CreateCommand(\"ruby_exit\")");
Tcl_CreateCommand(ptr->ip, "ruby_exit", ip_RubyExitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
#if 0 /*
- Disable the following "update" and "thread_update". Bcause,
- they don't work in a callback-proc. After calling update in
- a callback-proc, the callback proc never be worked.
- If the problem will be fixed in the future, may enable the
+ Disable the following "update" and "thread_update". Bcause,
+ they don't work in a callback-proc. After calling update in
+ a callback-proc, the callback proc never be worked.
+ If the problem will be fixed in the future, may enable the
functions.
*/
/* replace 'update' command */
# if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"update\")");
Tcl_CreateObjCommand(ptr->ip, "update", ip_rbUpdateObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
# else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"update\")");
Tcl_CreateCommand(ptr->ip, "update", ip_rbUpdateCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
# endif
/* add 'thread_update' command */
# if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"thread_update\")");
Tcl_CreateObjCommand(ptr->ip, "thread_update", ip_rb_threadUpdateObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
# else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"thread_update\")");
Tcl_CreateCommand(ptr->ip, "thread_update", ip_rb_threadUpdateCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
# endif
#endif
@@ -3567,44 +3566,44 @@ ip_init(argc, argv, self)
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"vwait\")");
Tcl_CreateObjCommand(ptr->ip, "vwait", ip_rbVwaitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"vwait\")");
Tcl_CreateCommand(ptr->ip, "vwait", ip_rbVwaitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
/* replace 'tkwait' command */
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"tkwait\")");
Tcl_CreateObjCommand(ptr->ip, "tkwait", ip_rbTkWaitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"tkwait\")");
Tcl_CreateCommand(ptr->ip, "tkwait", ip_rbTkWaitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
/* add 'thread_vwait' command */
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"thread_vwait\")");
Tcl_CreateObjCommand(ptr->ip, "thread_vwait", ip_rb_threadVwaitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"thread_vwait\")");
Tcl_CreateCommand(ptr->ip, "thread_vwait", ip_rb_threadVwaitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
/* add 'thread_tkwait' command */
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"thread_tkwait\")");
Tcl_CreateObjCommand(ptr->ip, "thread_tkwait", ip_rb_threadTkWaitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"thread_tkwait\")");
Tcl_CreateCommand(ptr->ip, "thread_tkwait", ip_rb_threadTkWaitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
Tk_Release((ClientData)mainWin);
@@ -3628,15 +3627,15 @@ ip_create_slave(argc, argv, self)
/* safe-mode check */
if (rb_scan_args(argc, argv, "11", &name, &safemode) == 1) {
- safemode = Qfalse;
+ safemode = Qfalse;
}
if (Tcl_IsSafe(master->ip) == 1) {
- safe = 1;
+ safe = 1;
} else if (safemode == Qfalse || NIL_P(safemode)) {
- safe = 0;
- rb_secure(4);
+ safe = 0;
+ rb_secure(4);
} else {
- safe = 1;
+ safe = 1;
}
thr_crit_bup = rb_thread_critical;
@@ -3644,9 +3643,9 @@ ip_create_slave(argc, argv, self)
/* ip is deleted? */
if (Tcl_InterpDeleted(master->ip)) {
- DUMP1("master-ip is deleted");
- rb_thread_critical = thr_crit_bup;
- rb_raise(rb_eRuntimeError, "deleted master cannot create a new slave interpreter");
+ DUMP1("master-ip is deleted");
+ rb_thread_critical = thr_crit_bup;
+ rb_raise(rb_eRuntimeError, "deleted master cannot create a new slave interpreter");
}
/* create slave-ip */
@@ -3656,24 +3655,24 @@ ip_create_slave(argc, argv, self)
slave->ip = Tcl_CreateSlave(master->ip, StringValuePtr(name), safe);
if (slave->ip == NULL) {
- rb_thread_critical = thr_crit_bup;
- rb_raise(rb_eRuntimeError, "fail to create the new slave interpreter");
+ rb_thread_critical = thr_crit_bup;
+ rb_raise(rb_eRuntimeError, "fail to create the new slave interpreter");
}
rbtk_preserve_ip(slave);
slave->has_orig_exit
- = Tcl_GetCommandInfo(slave->ip, "exit", &(slave->orig_exit_info));
+ = Tcl_GetCommandInfo(slave->ip, "exit", &(slave->orig_exit_info));
/* replace 'exit' command --> 'interp_exit' command */
mainWin = Tk_MainWindow(slave->ip);
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
Tcl_CreateObjCommand(slave->ip, "exit", ip_InterpExitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
Tcl_CreateCommand(slave->ip, "exit", ip_InterpExitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
rb_thread_critical = thr_crit_bup;
@@ -3691,15 +3690,15 @@ ip_make_safe(self)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
}
if (Tcl_MakeSafe(ptr->ip) == TCL_ERROR) {
#if TCL_MAJOR_VERSION >= 8
- rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
#endif
}
@@ -3710,11 +3709,11 @@ ip_make_safe(self)
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
return self;
@@ -3729,14 +3728,14 @@ ip_is_safe_p(self)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
}
if (Tcl_IsSafe(ptr->ip)) {
- return Qtrue;
+ return Qtrue;
} else {
- return Qfalse;
+ return Qfalse;
}
}
@@ -3749,14 +3748,14 @@ ip_allow_ruby_exit_p(self)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
}
if (ptr->allow_ruby_exit) {
- return Qtrue;
+ return Qtrue;
} else {
- return Qfalse;
+ return Qfalse;
}
}
@@ -3772,42 +3771,42 @@ ip_allow_ruby_exit_set(self, val)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
}
if (Tcl_IsSafe(ptr->ip)) {
- rb_raise(rb_eSecurityError,
- "insecure operation on a safe interpreter");
+ rb_raise(rb_eSecurityError,
+ "insecure operation on a safe interpreter");
}
mainWin = Tk_MainWindow(ptr->ip);
if (RTEST(val)) {
- ptr->allow_ruby_exit = 1;
+ ptr->allow_ruby_exit = 1;
#if TCL_MAJOR_VERSION >= 8
- DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
- Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
- DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
- Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
- return Qtrue;
+ return Qtrue;
} else {
- ptr->allow_ruby_exit = 0;
+ ptr->allow_ruby_exit = 0;
#if TCL_MAJOR_VERSION >= 8
- DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
- Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#else /* TCL_MAJOR_VERSION < 8 */
- DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
- Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand,
- (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
#endif
- return Qfalse;
+ return Qfalse;
}
}
@@ -3822,15 +3821,15 @@ ip_delete(self)
rbtk_preserve_ip(ptr);
if (!Tcl_InterpDeleted(ptr->ip)) {
- Tcl_Eval(ptr->ip, "foreach i [after info] { after cancel $i }");
+ Tcl_Eval(ptr->ip, "foreach i [after info] { after cancel $i }");
}
del_root(ptr->ip);
DUMP1("delete interp");
while(!Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("wait ip is deleted");
- Tcl_DeleteInterp(ptr->ip);
+ DUMP1("wait ip is deleted");
+ Tcl_DeleteInterp(ptr->ip);
}
/* Tcl_Release(ptr->ip); */
@@ -3847,9 +3846,9 @@ ip_is_deleted_p(self)
struct tcltkip *ptr = get_ip(self);
if (Tcl_InterpDeleted(ptr->ip)) {
- return Qtrue;
+ return Qtrue;
} else {
- return Qfalse;
+ return Qfalse;
}
}
@@ -3903,14 +3902,14 @@ ip_get_result_string_obj(interp)
rb_thread_critical = Qtrue;
if (Tcl_GetCharLength(retobj) != Tcl_UniCharLen(Tcl_GetUnicode(retobj))) {
- /* possibly binary string */
- s = Tcl_GetByteArrayFromObj(retobj, &len);
- strval = rb_tainted_str_new(s, len);
- rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary"));
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(retobj, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary"));
} else {
- /* possibly text string */
- s = Tcl_GetStringFromObj(retobj, &len);
- strval = rb_tainted_str_new(s, len);
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(retobj, &len);
+ strval = rb_tainted_str_new(s, len);
}
rb_thread_critical = thr_crit_bup;
@@ -3951,17 +3950,17 @@ ip_eval_real(self, cmd_str, cmd_len)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- Tcl_DecrRefCount(cmd);
- rb_thread_critical = thr_crit_bup;
- ptr->return_value = TCL_OK;
- return rb_tainted_str_new2("");
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(cmd);
+ rb_thread_critical = thr_crit_bup;
+ ptr->return_value = TCL_OK;
+ return rb_tainted_str_new2("");
} else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
-
- ptr->return_value = Tcl_EvalObj(ptr->ip, cmd);
- /* ptr->return_value = Tcl_GlobalEvalObj(ptr->ip, cmd); */
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+
+ ptr->return_value = Tcl_EvalObj(ptr->ip, cmd);
+ /* ptr->return_value = Tcl_GlobalEvalObj(ptr->ip, cmd); */
}
Tcl_DecrRefCount(cmd);
@@ -3969,14 +3968,14 @@ ip_eval_real(self, cmd_str, cmd_len)
}
if (ptr->return_value == TCL_ERROR) {
- volatile VALUE exc;
- exc = create_ip_exc(self, rb_eRuntimeError,
- "%s", Tcl_GetStringResult(ptr->ip));
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
+ volatile VALUE exc;
+ exc = create_ip_exc(self, rb_eRuntimeError,
+ "%s", Tcl_GetStringResult(ptr->ip));
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- rb_exc_raise(exc);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
}
DUMP2("(TCL_Eval result) %d", ptr->return_value);
@@ -3992,22 +3991,22 @@ ip_eval_real(self, cmd_str, cmd_len)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- ptr->return_value = TCL_OK;
- return rb_tainted_str_new2("");
+ DUMP1("ip is deleted");
+ ptr->return_value = TCL_OK;
+ return rb_tainted_str_new2("");
} else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
- ptr->return_value = Tcl_Eval(ptr->ip, cmd_str);
- /* ptr->return_value = Tcl_GlobalEval(ptr->ip, cmd_str); */
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ptr->return_value = Tcl_Eval(ptr->ip, cmd_str);
+ /* ptr->return_value = Tcl_GlobalEval(ptr->ip, cmd_str); */
}
if (ptr->return_value == TCL_ERROR) {
- volatile VALUE exc;
- exc = create_ip_exc(self, rb_eRuntimeError, "%s", ptr->ip->result);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_exc_raise(exc);
+ volatile VALUE exc;
+ exc = create_ip_exc(self, rb_eRuntimeError, "%s", ptr->ip->result);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_exc_raise(exc);
}
DUMP2("(TCL_Eval result) %d", ptr->return_value);
@@ -4047,10 +4046,10 @@ eval_queue_handler(evPtr, flags)
DUMP2("added by thread : %lx", q->thread);
if (*(q->done)) {
- DUMP1("processed by another event-loop");
- return 0;
+ DUMP1("processed by another event-loop");
+ return 0;
} else {
- DUMP1("process it on current event-loop");
+ DUMP1("process it on current event-loop");
}
/* process it */
@@ -4059,19 +4058,19 @@ eval_queue_handler(evPtr, flags)
/* check safe-level */
if (rb_safe_level() != q->safe_level) {
#ifdef HAVE_NATIVETHREAD
- if (!is_ruby_native_thread()) {
- rb_bug("cross-thread violation on eval_queue_handler()");
- }
-#endif
- /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
- q_dat = Data_Wrap_Struct(rb_cData,eval_queue_mark,0,q);
- ret = rb_funcall(rb_proc_new(evq_safelevel_handler, q_dat),
- ID_call, 0);
- rb_gc_force_recycle(q_dat);
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on eval_queue_handler()");
+ }
+#endif
+ /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
+ q_dat = Data_Wrap_Struct(rb_cData,eval_queue_mark,0,q);
+ ret = rb_funcall(rb_proc_new(evq_safelevel_handler, q_dat),
+ ID_call, 0);
+ rb_gc_force_recycle(q_dat);
} else {
- DUMP2("call eval_real (for caller thread:%lx)", q->thread);
- DUMP2("call eval_real (current thread:%lx)", rb_thread_current());
- ret = ip_eval_real(q->interp, q->str, q->len);
+ DUMP2("call eval_real (for caller thread:%lx)", q->thread);
+ DUMP2("call eval_real (current thread:%lx)", rb_thread_current());
+ ret = ip_eval_real(q->interp, q->str, q->len);
}
/* set result */
@@ -4111,16 +4110,16 @@ ip_eval(self, str)
rb_thread_critical = thr_crit_bup;
if (eventloop_thread == 0 || current == eventloop_thread) {
- if (eventloop_thread) {
- DUMP2("eval from current eventloop %lx", current);
- } else {
- DUMP2("eval from thread:%lx but no eventloop", current);
- }
- result = ip_eval_real(self, RSTRING(str)->ptr, RSTRING(str)->len);
- if (rb_obj_is_kind_of(result, rb_eException)) {
- rb_exc_raise(result);
- }
- return result;
+ if (eventloop_thread) {
+ DUMP2("eval from current eventloop %lx", current);
+ } else {
+ DUMP2("eval from thread:%lx but no eventloop", current);
+ }
+ result = ip_eval_real(self, RSTRING(str)->ptr, RSTRING(str)->len);
+ if (rb_obj_is_kind_of(result, rb_eException)) {
+ rb_exc_raise(result);
+ }
+ return result;
}
DUMP2("eval from thread %lx (NOT current eventloop)", current);
@@ -4165,7 +4164,7 @@ ip_eval(self, str)
/* wait for the handler to be processed */
DUMP2("wait for handler (current thread:%lx)", current);
while(*alloc_done >= 0) {
- rb_thread_stop();
+ rb_thread_stop();
}
DUMP2("back from handler (current thread:%lx)", current);
@@ -4177,7 +4176,7 @@ ip_eval(self, str)
Tcl_Release(evq);
if (rb_obj_is_kind_of(ret, rb_eException)) {
- rb_exc_raise(ret);
+ rb_exc_raise(ret);
}
return ret;
@@ -4197,8 +4196,8 @@ lib_restart(self)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
}
thr_crit_bup = rb_thread_critical;
@@ -4228,31 +4227,31 @@ lib_restart(self)
/* execute Tk_Init of Tk_SafeInit */
#if TCL_MAJOR_VERSION >= 8
if (Tcl_IsSafe(ptr->ip)) {
- DUMP1("Tk_SafeInit");
- if (Tk_SafeInit(ptr->ip) == TCL_ERROR) {
- exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- rb_exc_raise(exc);
- }
+ DUMP1("Tk_SafeInit");
+ if (Tk_SafeInit(ptr->ip) == TCL_ERROR) {
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
} else {
- DUMP1("Tk_Init");
- if (Tk_Init(ptr->ip) == TCL_ERROR) {
- exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- rb_exc_raise(exc);
- }
+ DUMP1("Tk_Init");
+ if (Tk_Init(ptr->ip) == TCL_ERROR) {
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
}
#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tk_Init");
if (Tk_Init(ptr->ip) == TCL_ERROR) {
- exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_exc_raise(exc);
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_exc_raise(exc);
}
#endif
@@ -4275,13 +4274,13 @@ ip_restart(self)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
}
if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
- /* slave IP */
- return Qnil;
+ /* slave IP */
+ return Qnil;
}
return lib_restart(self);
}
@@ -4304,76 +4303,76 @@ lib_toUTF8_core(ip_obj, src, encodename)
int thr_crit_bup;
if (NIL_P(ip_obj)) {
- interp = (Tcl_Interp *)NULL;
+ interp = (Tcl_Interp *)NULL;
} else {
- interp = get_ip(ip_obj)->ip;
+ interp = get_ip(ip_obj)->ip;
- /* ip is deleted? */
- if (Tcl_InterpDeleted(interp)) {
- DUMP1("ip is deleted");
- interp = (Tcl_Interp *)NULL;
- }
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(interp)) {
+ DUMP1("ip is deleted");
+ interp = (Tcl_Interp *)NULL;
+ }
}
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
if (NIL_P(encodename)) {
- if (TYPE(str) == T_STRING) {
- volatile VALUE enc;
-
- enc = Qnil;
- if (RTEST(rb_ivar_defined(str, ID_at_enc))) {
- enc = rb_ivar_get(str, ID_at_enc);
- }
- if (NIL_P(enc)) {
- if (NIL_P(ip_obj)) {
- encoding = (Tcl_Encoding)NULL;
- } else {
- if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) {
- enc = rb_ivar_get(ip_obj, ID_at_enc);
- }
- if (NIL_P(enc)) {
- encoding = (Tcl_Encoding)NULL;
- } else {
- StringValue(enc);
- encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
- if (encoding == (Tcl_Encoding)NULL) {
- rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
- }
- }
- }
- } else {
- StringValue(enc);
- if (strcmp(RSTRING(enc)->ptr, "binary") == 0) {
- rb_thread_critical = thr_crit_bup;
- return str;
- }
- encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
- if (encoding == (Tcl_Encoding)NULL) {
- rb_warning("string has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
- }
- }
- } else {
- encoding = (Tcl_Encoding)NULL;
- }
+ if (TYPE(str) == T_STRING) {
+ volatile VALUE enc;
+
+ enc = Qnil;
+ if (RTEST(rb_ivar_defined(str, ID_at_enc))) {
+ enc = rb_ivar_get(str, ID_at_enc);
+ }
+ if (NIL_P(enc)) {
+ if (NIL_P(ip_obj)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) {
+ enc = rb_ivar_get(ip_obj, ID_at_enc);
+ }
+ if (NIL_P(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ StringValue(enc);
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
+ }
+ }
+ }
+ } else {
+ StringValue(enc);
+ if (strcmp(RSTRING(enc)->ptr, "binary") == 0) {
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ rb_warning("string has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
+ }
+ }
+ } else {
+ encoding = (Tcl_Encoding)NULL;
+ }
} else {
- StringValue(encodename);
- encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
- if (encoding == (Tcl_Encoding)NULL) {
- /*
- rb_warning("unknown encoding name '%s'",
- RSTRING(encodename)->ptr);
- */
- rb_raise(rb_eArgError, "unknown encoding name '%s'",
- RSTRING(encodename)->ptr);
- }
+ StringValue(encodename);
+ encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ /*
+ rb_warning("unknown encoding name '%s'",
+ RSTRING(encodename)->ptr);
+ */
+ rb_raise(rb_eArgError, "unknown encoding name '%s'",
+ RSTRING(encodename)->ptr);
+ }
}
StringValue(str);
if (!RSTRING(str)->len) {
- rb_thread_critical = thr_crit_bup;
- return str;
+ rb_thread_critical = thr_crit_bup;
+ return str;
}
buf = ALLOC_N(char,(RSTRING(str)->len)+1);
@@ -4391,7 +4390,7 @@ lib_toUTF8_core(ip_obj, src, encodename)
if (taint_flag) OBJ_TAINT(str);
if (encoding != (Tcl_Encoding)NULL) {
- Tcl_FreeEncoding(encoding);
+ Tcl_FreeEncoding(encoding);
}
Tcl_DStringFree(&dstr);
@@ -4412,7 +4411,7 @@ lib_toUTF8(argc, argv, self)
VALUE str, encodename;
if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
- encodename = Qnil;
+ encodename = Qnil;
}
return lib_toUTF8_core(Qnil, str, encodename);
}
@@ -4426,7 +4425,7 @@ ip_toUTF8(argc, argv, self)
VALUE str, encodename;
if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
- encodename = Qnil;
+ encodename = Qnil;
}
return lib_toUTF8_core(self, str, encodename);
}
@@ -4448,82 +4447,82 @@ lib_fromUTF8_core(ip_obj, src, encodename)
int thr_crit_bup;
if (NIL_P(ip_obj)) {
- interp = (Tcl_Interp *)NULL;
+ interp = (Tcl_Interp *)NULL;
} else {
- interp = get_ip(ip_obj)->ip;
+ interp = get_ip(ip_obj)->ip;
}
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
if (NIL_P(encodename)) {
- volatile VALUE enc;
-
- if (TYPE(str) == T_STRING) {
- enc = Qnil;
- if (RTEST(rb_ivar_defined(str, ID_at_enc))) {
- enc = rb_ivar_get(str, ID_at_enc);
- }
- if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
- rb_thread_critical = thr_crit_bup;
- return str;
- }
- }
-
- if (NIL_P(ip_obj)) {
- encoding = (Tcl_Encoding)NULL;
- } else {
- enc = Qnil;
- if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) {
- enc = rb_ivar_get(ip_obj, ID_at_enc);
- }
- if (NIL_P(enc)) {
- encoding = (Tcl_Encoding)NULL;
- } else {
- StringValue(enc);
- encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
- if (encoding == (Tcl_Encoding)NULL) {
- rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
- } else {
- encodename = rb_obj_dup(enc);
- }
- }
- }
+ volatile VALUE enc;
+
+ if (TYPE(str) == T_STRING) {
+ enc = Qnil;
+ if (RTEST(rb_ivar_defined(str, ID_at_enc))) {
+ enc = rb_ivar_get(str, ID_at_enc);
+ }
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+ }
+
+ if (NIL_P(ip_obj)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ enc = Qnil;
+ if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) {
+ enc = rb_ivar_get(ip_obj, ID_at_enc);
+ }
+ if (NIL_P(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ StringValue(enc);
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
+ } else {
+ encodename = rb_obj_dup(enc);
+ }
+ }
+ }
} else {
- StringValue(encodename);
-
- if (strcmp(RSTRING(encodename)->ptr, "binary") == 0) {
- char *s;
- int len;
-
- s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING(str)->ptr,
- RSTRING(str)->len),
- &len);
- str = rb_tainted_str_new(s, len);
- rb_ivar_set(str, ID_at_enc, rb_tainted_str_new2("binary"));
-
- rb_thread_critical = thr_crit_bup;
- return str;
- }
-
- encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
- if (encoding == (Tcl_Encoding)NULL) {
- /*
- rb_warning("unknown encoding name '%s'",
- RSTRING(encodename)->ptr);
- encodename = Qnil;
- */
- rb_raise(rb_eArgError, "unknown encoding name '%s'",
- RSTRING(encodename)->ptr);
- }
+ StringValue(encodename);
+
+ if (strcmp(RSTRING(encodename)->ptr, "binary") == 0) {
+ char *s;
+ int len;
+
+ s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING(str)->ptr,
+ RSTRING(str)->len),
+ &len);
+ str = rb_tainted_str_new(s, len);
+ rb_ivar_set(str, ID_at_enc, rb_tainted_str_new2("binary"));
+
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+
+ encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ /*
+ rb_warning("unknown encoding name '%s'",
+ RSTRING(encodename)->ptr);
+ encodename = Qnil;
+ */
+ rb_raise(rb_eArgError, "unknown encoding name '%s'",
+ RSTRING(encodename)->ptr);
+ }
}
StringValue(str);
if (RSTRING(str)->len == 0) {
- rb_thread_critical = thr_crit_bup;
- return rb_tainted_str_new2("");
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
}
buf = ALLOC_N(char,strlen(RSTRING(str)->ptr)+1);
@@ -4542,7 +4541,7 @@ lib_fromUTF8_core(ip_obj, src, encodename)
if (taint_flag) OBJ_TAINT(str);
if (encoding != (Tcl_Encoding)NULL) {
- Tcl_FreeEncoding(encoding);
+ Tcl_FreeEncoding(encoding);
}
Tcl_DStringFree(&dstr);
@@ -4563,7 +4562,7 @@ lib_fromUTF8(argc, argv, self)
VALUE str, encodename;
if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
- encodename = Qnil;
+ encodename = Qnil;
}
return lib_fromUTF8_core(Qnil, str, encodename);
}
@@ -4577,7 +4576,7 @@ ip_fromUTF8(argc, argv, self)
VALUE str, encodename;
if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
- encodename = Qnil;
+ encodename = Qnil;
}
return lib_fromUTF8_core(self, str, encodename);
}
@@ -4596,7 +4595,7 @@ lib_UTF_backslash_core(self, str, all_bs)
StringValue(str);
if (!RSTRING(str)->len) {
- return str;
+ return str;
}
thr_crit_bup = rb_thread_critical;
@@ -4610,12 +4609,12 @@ lib_UTF_backslash_core(self, str, all_bs)
ptr = src_buf;
while(RSTRING(str)->len > ptr - src_buf) {
- if (*ptr == '\\' && (all_bs || *(ptr + 1) == 'u')) {
- dst_len += Tcl_UtfBackslash(ptr, &read_len, (dst_buf + dst_len));
- ptr += read_len;
- } else {
- *(dst_buf + (dst_len++)) = *(ptr++);
- }
+ if (*ptr == '\\' && (all_bs || *(ptr + 1) == 'u')) {
+ dst_len += Tcl_UtfBackslash(ptr, &read_len, (dst_buf + dst_len));
+ ptr += read_len;
+ } else {
+ *(dst_buf + (dst_len++)) = *(ptr++);
+ }
}
str = rb_str_new(dst_buf, dst_len);
@@ -4686,28 +4685,28 @@ ip_invoke_core(interp, argc, argv)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return rb_tainted_str_new2("");
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
}
/* map from the command name to a C procedure */
DUMP2("call Tcl_GetCommandInfo, %s", cmd);
if (!Tcl_GetCommandInfo(ptr->ip, cmd, &info)) {
- DUMP1("error Tcl_GetCommandInfo");
- /* if (event_loop_abort_on_exc || cmd[0] != '.') { */
- if (event_loop_abort_on_exc > 0) {
- /*rb_ip_raise(obj,rb_eNameError,"invalid command name `%s'",cmd);*/
- return create_ip_exc(interp, rb_eNameError,
- "invalid command name `%s'", cmd);
- } else {
- if (event_loop_abort_on_exc < 0) {
- rb_warning("invalid command name `%s' (ignore)", cmd);
- } else {
- rb_warn("invalid command name `%s' (ignore)", cmd);
- }
- Tcl_ResetResult(ptr->ip);
- return rb_tainted_str_new2("");
- }
+ DUMP1("error Tcl_GetCommandInfo");
+ /* if (event_loop_abort_on_exc || cmd[0] != '.') { */
+ if (event_loop_abort_on_exc > 0) {
+ /*rb_ip_raise(obj,rb_eNameError,"invalid command name `%s'",cmd);*/
+ return create_ip_exc(interp, rb_eNameError,
+ "invalid command name `%s'", cmd);
+ } else {
+ if (event_loop_abort_on_exc < 0) {
+ rb_warning("invalid command name `%s' (ignore)", cmd);
+ } else {
+ rb_warn("invalid command name `%s' (ignore)", cmd);
+ }
+ Tcl_ResetResult(ptr->ip);
+ return rb_tainted_str_new2("");
+ }
}
DUMP1("end Tcl_GetCommandInfo");
@@ -4717,12 +4716,12 @@ ip_invoke_core(interp, argc, argv)
/* memory allocation for arguments of this command */
#if TCL_MAJOR_VERSION >= 8
if (!info.isNativeObjectProc) {
- /* string interface */
- argv = (char **)ALLOC_N(char *, argc+1);
- for (i = 0; i < argc; ++i) {
- argv[i] = Tcl_GetStringFromObj(objv[i], &len);
- }
- argv[argc] = (char *)NULL;
+ /* string interface */
+ argv = (char **)ALLOC_N(char *, argc+1);
+ for (i = 0; i < argc; ++i) {
+ argv[i] = Tcl_GetStringFromObj(objv[i], &len);
+ }
+ argv[argc] = (char *)NULL;
}
#endif
@@ -4731,27 +4730,27 @@ ip_invoke_core(interp, argc, argv)
/* Invoke the C procedure */
#if TCL_MAJOR_VERSION >= 8
if (info.isNativeObjectProc) {
- ptr->return_value = (*info.objProc)(info.objClientData, ptr->ip,
- objc, objv);
+ ptr->return_value = (*info.objProc)(info.objClientData, ptr->ip,
+ objc, objv);
#if 0
- /* get the string value from the result object */
- resultPtr = Tcl_GetObjResult(ptr->ip);
- Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &len),
- TCL_VOLATILE);
+ /* get the string value from the result object */
+ resultPtr = Tcl_GetObjResult(ptr->ip);
+ Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &len),
+ TCL_VOLATILE);
#endif
}
else
#endif
{
#if TCL_MAJOR_VERSION >= 8
- ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
- argc, (CONST84 char **)argv);
+ ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
+ argc, (CONST84 char **)argv);
- free(argv);
+ free(argv);
#else /* TCL_MAJOR_VERSION < 8 */
- ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
- argc, argv);
+ ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
+ argc, argv);
#endif
}
@@ -4759,31 +4758,31 @@ ip_invoke_core(interp, argc, argv)
/* exception on mainloop */
if (ptr->return_value == TCL_ERROR) {
- if (event_loop_abort_on_exc > 0 && !Tcl_InterpDeleted(ptr->ip)) {
+ if (event_loop_abort_on_exc > 0 && !Tcl_InterpDeleted(ptr->ip)) {
#if TCL_MAJOR_VERSION >= 8
- return create_ip_exc(interp, rb_eRuntimeError,
- "%s", Tcl_GetStringResult(ptr->ip));
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "%s", Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- return create_ip_exc(interp, rb_eRuntimeError,
- "%s", ptr->ip->result);
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "%s", ptr->ip->result);
#endif
- } else {
- if (event_loop_abort_on_exc < 0) {
+ } else {
+ if (event_loop_abort_on_exc < 0) {
#if TCL_MAJOR_VERSION >= 8
- rb_warning("%s (ignore)", Tcl_GetStringResult(ptr->ip));
+ rb_warning("%s (ignore)", Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- rb_warning("%s (ignore)", ptr->ip->result);
+ rb_warning("%s (ignore)", ptr->ip->result);
#endif
- } else {
+ } else {
#if TCL_MAJOR_VERSION >= 8
- rb_warn("%s (ignore)", Tcl_GetStringResult(ptr->ip));
+ rb_warn("%s (ignore)", Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- rb_warn("%s (ignore)", ptr->ip->result);
+ rb_warn("%s (ignore)", ptr->ip->result);
#endif
- }
- Tcl_ResetResult(ptr->ip);
- return rb_tainted_str_new2("");
- }
+ }
+ Tcl_ResetResult(ptr->ip);
+ return rb_tainted_str_new2("");
+ }
}
/* pass back the result (as string) */
@@ -4819,30 +4818,30 @@ alloc_invoke_arguments(argc, argv)
#if TCL_MAJOR_VERSION >= 8
av = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, argc+1);
for (i = 0; i < argc; ++i) {
- VALUE enc;
+ VALUE enc;
- v = argv[i];
- s = StringValuePtr(v);
+ v = argv[i];
+ s = StringValuePtr(v);
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
- av[i] = Tcl_NewStringObj(s, RSTRING(v)->len);
+ av[i] = Tcl_NewStringObj(s, RSTRING(v)->len);
# else /* TCL_VERSION >= 8.1 */
- enc = Qnil;
- if (RTEST(rb_ivar_defined(v, ID_at_enc))) {
- enc = rb_ivar_get(v, ID_at_enc);
- }
- if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
- /* binary string */
- av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len);
- } else if (strlen(s) != RSTRING(v)->len) {
- /* probably binary string */
- av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len);
- } else {
- /* probably text string */
- av[i] = Tcl_NewStringObj(s, RSTRING(v)->len);
- }
+ enc = Qnil;
+ if (RTEST(rb_ivar_defined(v, ID_at_enc))) {
+ enc = rb_ivar_get(v, ID_at_enc);
+ }
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ /* binary string */
+ av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len);
+ } else if (strlen(s) != RSTRING(v)->len) {
+ /* probably binary string */
+ av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len);
+ } else {
+ /* probably text string */
+ av[i] = Tcl_NewStringObj(s, RSTRING(v)->len);
+ }
# endif
- Tcl_IncrRefCount(av[i]);
+ Tcl_IncrRefCount(av[i]);
}
av[argc] = (Tcl_Obj *)NULL;
@@ -4850,10 +4849,10 @@ alloc_invoke_arguments(argc, argv)
/* string interface */
av = (char **)ALLOC_N(char *, argc+1);
for (i = 0; i < argc; ++i) {
- v = argv[i];
- s = StringValuePtr(v);
- av[i] = ALLOC_N(char, strlen(s)+1);
- strcpy(av[i], s);
+ v = argv[i];
+ s = StringValuePtr(v);
+ av[i] = ALLOC_N(char, strlen(s)+1);
+ strcpy(av[i], s);
}
av[argc] = (char *)NULL;
#endif
@@ -4876,9 +4875,9 @@ free_invoke_arguments(argc, av)
for (i = 0; i < argc; ++i) {
#if TCL_MAJOR_VERSION >= 8
- Tcl_DecrRefCount(av[i]);
+ Tcl_DecrRefCount(av[i]);
#else /* TCL_MAJOR_VERSION < 8 */
- free(av[i]);
+ free(av[i]);
#endif
}
free(av);
@@ -4891,7 +4890,7 @@ ip_invoke_real(argc, argv, interp)
VALUE interp;
{
VALUE v;
- struct tcltkip *ptr; /* tcltkip data struct */
+ struct tcltkip *ptr; /* tcltkip data struct */
int i;
Tcl_CmdInfo info;
char *s;
@@ -4915,8 +4914,8 @@ ip_invoke_real(argc, argv, interp)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return rb_tainted_str_new2("");
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
}
/* Invoke the C procedure */
@@ -4957,10 +4956,10 @@ invoke_queue_handler(evPtr, flags)
DUMP2("added by thread : %lx", q->thread);
if (*(q->done)) {
- DUMP1("processed by another event-loop");
- return 0;
+ DUMP1("processed by another event-loop");
+ return 0;
} else {
- DUMP1("process it on current event-loop");
+ DUMP1("process it on current event-loop");
}
/* process it */
@@ -4968,15 +4967,15 @@ invoke_queue_handler(evPtr, flags)
/* check safe-level */
if (rb_safe_level() != q->safe_level) {
- /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
- q_dat = Data_Wrap_Struct(rb_cData,invoke_queue_mark,0,q);
- ret = rb_funcall(rb_proc_new(ivq_safelevel_handler, q_dat),
- ID_call, 0);
- rb_gc_force_recycle(q_dat);
+ /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
+ q_dat = Data_Wrap_Struct(rb_cData,invoke_queue_mark,0,q);
+ ret = rb_funcall(rb_proc_new(ivq_safelevel_handler, q_dat),
+ ID_call, 0);
+ rb_gc_force_recycle(q_dat);
} else {
- DUMP2("call invoke_real (for caller thread:%lx)", q->thread);
- DUMP2("call invoke_real (current thread:%lx)", rb_thread_current());
- ret = ip_invoke_core(q->interp, q->argc, q->argv);
+ DUMP2("call invoke_real (for caller thread:%lx)", q->thread);
+ DUMP2("call invoke_real (current thread:%lx)", rb_thread_current());
+ ret = ip_invoke_core(q->interp, q->argc, q->argv);
}
/* set result */
@@ -5020,19 +5019,19 @@ ip_invoke_with_position(argc, argv, obj, position)
#endif
if (argc < 1) {
- rb_raise(rb_eArgError, "command name missing");
+ rb_raise(rb_eArgError, "command name missing");
}
if (eventloop_thread == 0 || current == eventloop_thread) {
- if (eventloop_thread) {
- DUMP2("invoke from current eventloop %lx", current);
- } else {
- DUMP2("invoke from thread:%lx but no eventloop", current);
- }
- result = ip_invoke_real(argc, argv, ip_obj);
- if (rb_obj_is_kind_of(result, rb_eException)) {
- rb_exc_raise(result);
- }
- return result;
+ if (eventloop_thread) {
+ DUMP2("invoke from current eventloop %lx", current);
+ } else {
+ DUMP2("invoke from thread:%lx but no eventloop", current);
+ }
+ result = ip_invoke_real(argc, argv, ip_obj);
+ if (rb_obj_is_kind_of(result, rb_eException)) {
+ rb_exc_raise(result);
+ }
+ return result;
}
DUMP2("invoke from thread %lx (NOT current eventloop)", current);
@@ -5075,7 +5074,7 @@ ip_invoke_with_position(argc, argv, obj, position)
/* wait for the handler to be processed */
DUMP2("wait for handler (current thread:%lx)", current);
while(*alloc_done >= 0) {
- rb_thread_stop();
+ rb_thread_stop();
}
DUMP2("back from handler (current thread:%lx)", current);
@@ -5090,8 +5089,8 @@ ip_invoke_with_position(argc, argv, obj, position)
/* exception? */
if (rb_obj_is_kind_of(ret, rb_eException)) {
- DUMP1("raise exception");
- rb_exc_raise(ret);
+ DUMP1("raise exception");
+ rb_exc_raise(ret);
}
DUMP1("exit ip_invoke");
@@ -5104,15 +5103,15 @@ static VALUE
ip_retval(self)
VALUE self;
{
- struct tcltkip *ptr; /* tcltkip data struct */
+ struct tcltkip *ptr; /* tcltkip data struct */
/* get the data strcut */
ptr = get_ip(self);
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return rb_tainted_str_new2("");
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
}
return (INT2FIX(ptr->return_value));
@@ -5154,112 +5153,112 @@ ip_get_variable(self, varname_arg, flag_arg)
#if TCL_MAJOR_VERSION >= 8
{
- Tcl_Obj *nameobj, *ret;
- char *s;
- int len;
- volatile VALUE strval;
-
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
-
- nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
- RSTRING(varname)->len);
- Tcl_IncrRefCount(nameobj);
-
- /* ip is deleted? */
- if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- Tcl_DecrRefCount(nameobj);
- rb_thread_critical = thr_crit_bup;
- return rb_tainted_str_new2("");
- } else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
- ret = Tcl_ObjGetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL,
- FIX2INT(flag));
- }
-
- Tcl_DecrRefCount(nameobj);
-
- if (ret == (Tcl_Obj*)NULL) {
- volatile VALUE exc;
+ Tcl_Obj *nameobj, *ret;
+ char *s;
+ int len;
+ volatile VALUE strval;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
+ RSTRING(varname)->len);
+ Tcl_IncrRefCount(nameobj);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(nameobj);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_ObjGetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL,
+ FIX2INT(flag));
+ }
+
+ Tcl_DecrRefCount(nameobj);
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
#if TCL_MAJOR_VERSION >= 8
- exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
#endif
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- rb_exc_raise(exc);
- }
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
- Tcl_IncrRefCount(ret);
+ Tcl_IncrRefCount(ret);
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
- s = Tcl_GetStringFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- Tcl_DecrRefCount(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- return(strval);
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return(strval);
# else /* TCL_VERSION >= 8.1 */
- if (Tcl_GetCharLength(ret)
- != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
- /* possibly binary string */
- s = Tcl_GetByteArrayFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary"));
- } else {
- /* possibly text string */
- s = Tcl_GetStringFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- }
-
- Tcl_DecrRefCount(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
-
- return(strval);
+ if (Tcl_GetCharLength(ret)
+ != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ }
+
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
# endif
}
#else /* TCL_MAJOR_VERSION < 8 */
{
- char *ret;
-
- /* ip is deleted? */
- if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return rb_tainted_str_new2("");
- } else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
- ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr,
- (char*)NULL, FIX2INT(flag));
- }
-
- if (ret == (char*)NULL) {
- volatile VALUE exc;
+ char *ret;
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr,
+ (char*)NULL, FIX2INT(flag));
+ }
+
+ if (ret == (char*)NULL) {
+ volatile VALUE exc;
#if TCL_MAJOR_VERSION >= 8
- exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
#endif
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- rb_exc_raise(exc);
- }
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
- strval = rb_tainted_str_new2(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
+ strval = rb_tainted_str_new2(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
- return(strval);
+ return(strval);
}
#endif
}
@@ -5288,115 +5287,115 @@ ip_get_variable2(self, varname_arg, index_arg, flag_arg)
#if TCL_MAJOR_VERSION >= 8
{
- Tcl_Obj *nameobj, *idxobj, *ret;
- char *s;
- int len;
- volatile VALUE strval;
-
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
-
- nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
- RSTRING(varname)->len);
- Tcl_IncrRefCount(nameobj);
- idxobj = Tcl_NewStringObj(RSTRING(index)->ptr, RSTRING(index)->len);
- Tcl_IncrRefCount(idxobj);
-
- /* ip is deleted? */
- if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- Tcl_DecrRefCount(nameobj);
- Tcl_DecrRefCount(idxobj);
- rb_thread_critical = thr_crit_bup;
- return rb_tainted_str_new2("");
- } else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
- ret = Tcl_ObjGetVar2(ptr->ip, nameobj, idxobj, FIX2INT(flag));
- }
-
- Tcl_DecrRefCount(nameobj);
- Tcl_DecrRefCount(idxobj);
-
- if (ret == (Tcl_Obj*)NULL) {
- volatile VALUE exc;
+ Tcl_Obj *nameobj, *idxobj, *ret;
+ char *s;
+ int len;
+ volatile VALUE strval;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
+ RSTRING(varname)->len);
+ Tcl_IncrRefCount(nameobj);
+ idxobj = Tcl_NewStringObj(RSTRING(index)->ptr, RSTRING(index)->len);
+ Tcl_IncrRefCount(idxobj);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(idxobj);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_ObjGetVar2(ptr->ip, nameobj, idxobj, FIX2INT(flag));
+ }
+
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(idxobj);
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
#if TCL_MAJOR_VERSION >= 8
- exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
#endif
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- rb_exc_raise(exc);
- }
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
- Tcl_IncrRefCount(ret);
+ Tcl_IncrRefCount(ret);
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
- s = Tcl_GetStringFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- Tcl_DecrRefCount(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- return(strval);
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return(strval);
# else /* TCL_VERSION >= 8.1 */
- if (Tcl_GetCharLength(ret)
- != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
- /* possibly binary string */
- s = Tcl_GetByteArrayFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary"));
- } else {
- /* possibly text string */
- s = Tcl_GetStringFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- }
-
- Tcl_DecrRefCount(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
-
- return(strval);
+ if (Tcl_GetCharLength(ret)
+ != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ }
+
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
# endif
}
#else /* TCL_MAJOR_VERSION < 8 */
{
- char *ret;
-
- /* ip is deleted? */
- if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return rb_tainted_str_new2("");
- } else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
- ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr,
- RSTRING(index)->ptr, FIX2INT(flag));
- }
-
- if (ret == (char*)NULL) {
- volatile VALUE exc;
+ char *ret;
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr,
+ RSTRING(index)->ptr, FIX2INT(flag));
+ }
+
+ if (ret == (char*)NULL) {
+ volatile VALUE exc;
#if TCL_MAJOR_VERSION >= 8
- exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
#endif
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- rb_exc_raise(exc);
- }
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
- strval = rb_tainted_str_new2(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
+ strval = rb_tainted_str_new2(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
- return(strval);
+ return(strval);
}
#endif
}
@@ -5421,137 +5420,137 @@ ip_set_variable(self, varname_arg, value_arg, flag_arg)
#if TCL_MAJOR_VERSION >= 8
{
- Tcl_Obj *nameobj, *valobj, *ret;
- char *s;
- int len;
- volatile VALUE strval;
+ Tcl_Obj *nameobj, *valobj, *ret;
+ char *s;
+ int len;
+ volatile VALUE strval;
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
- RSTRING(varname)->len);
+ nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
+ RSTRING(varname)->len);
- Tcl_IncrRefCount(nameobj);
+ Tcl_IncrRefCount(nameobj);
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
- valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
- RSTRING(value)->len);
- Tcl_IncrRefCount(valobj);
+ valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ Tcl_IncrRefCount(valobj);
# else /* TCL_VERSION >= 8.1 */
- {
- volatile VALUE enc = Qnil;
-
- if (RTEST(rb_ivar_defined(value, ID_at_enc))) {
- enc = rb_ivar_get(value, ID_at_enc);
- }
-
- if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
- /* binary string */
- valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
- RSTRING(value)->len);
- } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) {
- /* probably binary string */
- valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
- RSTRING(value)->len);
- } else {
- /* probably text string */
- valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
- RSTRING(value)->len);
- }
-
- Tcl_IncrRefCount(valobj);
- }
+ {
+ volatile VALUE enc = Qnil;
+
+ if (RTEST(rb_ivar_defined(value, ID_at_enc))) {
+ enc = rb_ivar_get(value, ID_at_enc);
+ }
+
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ /* binary string */
+ valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) {
+ /* probably binary string */
+ valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ } else {
+ /* probably text string */
+ valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ }
+
+ Tcl_IncrRefCount(valobj);
+ }
# endif
- /* ip is deleted? */
- if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- Tcl_DecrRefCount(nameobj);
- Tcl_DecrRefCount(valobj);
- rb_thread_critical = thr_crit_bup;
- return rb_tainted_str_new2("");
- } else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
- ret = Tcl_ObjSetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL, valobj,
- FIX2INT(flag));
- }
-
- Tcl_DecrRefCount(nameobj);
- Tcl_DecrRefCount(valobj);
-
- if (ret == (Tcl_Obj*)NULL) {
- volatile VALUE exc;
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(valobj);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_ObjSetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL, valobj,
+ FIX2INT(flag));
+ }
+
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(valobj);
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
#if TCL_MAJOR_VERSION >= 8
- exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
#endif
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- rb_exc_raise(exc);
- }
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
- Tcl_IncrRefCount(ret);
+ Tcl_IncrRefCount(ret);
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
- s = Tcl_GetStringFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
# else /* TCL_VERSION >= 8.1 */
- {
- VALUE old_gc;
-
- old_gc = rb_gc_disable();
-
- if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
- /* possibly binary string */
- s = Tcl_GetByteArrayFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary"));
- } else {
- /* possibly text string */
- s = Tcl_GetStringFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- }
- if (old_gc == Qfalse) rb_gc_enable();
- }
+ {
+ VALUE old_gc;
+
+ old_gc = rb_gc_disable();
+
+ if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ }
+ if (old_gc == Qfalse) rb_gc_enable();
+ }
# endif
- Tcl_DecrRefCount(ret);
+ Tcl_DecrRefCount(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
- return(strval);
+ return(strval);
}
#else /* TCL_MAJOR_VERSION < 8 */
{
- CONST char *ret;
+ CONST char *ret;
- /* ip is deleted? */
- if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return rb_tainted_str_new2("");
- } else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
- ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr, (char*)NULL,
- RSTRING(value)->ptr, (int)FIX2INT(flag));
- }
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr, (char*)NULL,
+ RSTRING(value)->ptr, (int)FIX2INT(flag));
+ }
- if (ret == NULL) {
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
- }
+ if (ret == NULL) {
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ }
- strval = rb_tainted_str_new2(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
+ strval = rb_tainted_str_new2(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
- return(strval);
+ return(strval);
}
#endif
}
@@ -5583,138 +5582,138 @@ ip_set_variable2(self, varname_arg, index_arg, value_arg, flag_arg)
#if TCL_MAJOR_VERSION >= 8
{
- Tcl_Obj *nameobj, *idxobj, *valobj, *ret;
- char *s;
- int len;
- volatile VALUE strval;
+ Tcl_Obj *nameobj, *idxobj, *valobj, *ret;
+ char *s;
+ int len;
+ volatile VALUE strval;
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
- RSTRING(varname)->len);
- Tcl_IncrRefCount(nameobj);
+ nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
+ RSTRING(varname)->len);
+ Tcl_IncrRefCount(nameobj);
- idxobj = Tcl_NewStringObj(RSTRING(index)->ptr,
- RSTRING(index)->len);
- Tcl_IncrRefCount(idxobj);
+ idxobj = Tcl_NewStringObj(RSTRING(index)->ptr,
+ RSTRING(index)->len);
+ Tcl_IncrRefCount(idxobj);
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
- valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
- RSTRING(value)->len);
+ valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
# else /* TCL_VERSION >= 8.1 */
- {
- VALUE enc = Qnil;
-
- if (RTEST(rb_ivar_defined(value, ID_at_enc))) {
- enc = rb_ivar_get(value, ID_at_enc);
- }
-
- if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
- /* binary string */
- valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
- RSTRING(value)->len);
- } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) {
- /* probably binary string */
- valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
- RSTRING(value)->len);
- } else {
- /* probably text string */
- valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
- RSTRING(value)->len);
- }
- }
+ {
+ VALUE enc = Qnil;
+
+ if (RTEST(rb_ivar_defined(value, ID_at_enc))) {
+ enc = rb_ivar_get(value, ID_at_enc);
+ }
+
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ /* binary string */
+ valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) {
+ /* probably binary string */
+ valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ } else {
+ /* probably text string */
+ valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ }
+ }
# endif
- Tcl_IncrRefCount(valobj);
-
- /* ip is deleted? */
- if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- Tcl_DecrRefCount(nameobj);
- Tcl_DecrRefCount(idxobj);
- Tcl_DecrRefCount(valobj);
- rb_thread_critical = thr_crit_bup;
- return rb_tainted_str_new2("");
- } else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
- ret = Tcl_ObjSetVar2(ptr->ip, nameobj, idxobj, valobj,
- FIX2INT(flag));
- }
-
- Tcl_DecrRefCount(nameobj);
- Tcl_DecrRefCount(idxobj);
- Tcl_DecrRefCount(valobj);
-
- if (ret == (Tcl_Obj*)NULL) {
- volatile VALUE exc;
+ Tcl_IncrRefCount(valobj);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(idxobj);
+ Tcl_DecrRefCount(valobj);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_ObjSetVar2(ptr->ip, nameobj, idxobj, valobj,
+ FIX2INT(flag));
+ }
+
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(idxobj);
+ Tcl_DecrRefCount(valobj);
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
#if TCL_MAJOR_VERSION >= 8
- exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
#endif
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
- rb_exc_raise(exc);
- }
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
- Tcl_IncrRefCount(ret);
+ Tcl_IncrRefCount(ret);
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
- s = Tcl_GetStringFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
# else /* TCL_VERSION >= 8.1 */
- if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
- /* possibly binary string */
- s = Tcl_GetByteArrayFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary"));
- } else {
- /* possibly text string */
- s = Tcl_GetStringFromObj(ret, &len);
- strval = rb_tainted_str_new(s, len);
- }
+ if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ }
# endif
- Tcl_DecrRefCount(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
- return(strval);
+ return(strval);
}
#else /* TCL_MAJOR_VERSION < 8 */
{
- CONST char *ret;
+ CONST char *ret;
- /* ip is deleted? */
- if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return rb_tainted_str_new2("");
- } else {
- /* Tcl_Preserve(ptr->ip); */
- rbtk_preserve_ip(ptr);
- ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr,
- RSTRING(index)->ptr,
- RSTRING(value)->ptr, FIX2INT(flag));
- }
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr,
+ RSTRING(index)->ptr,
+ RSTRING(value)->ptr, FIX2INT(flag));
+ }
- if (ret == (char*)NULL) {
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
- }
+ if (ret == (char*)NULL) {
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ }
- Tcl_IncrRefCount(ret);
+ Tcl_IncrRefCount(ret);
- strval = rb_tainted_str_new2(ret);
+ strval = rb_tainted_str_new2(ret);
- Tcl_DecrRefCount(ret);
- /* Tcl_Release(ptr->ip); */
- rbtk_release_ip(ptr);
- rb_thread_critical = thr_crit_bup;
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
- return(strval);
+ return(strval);
}
#endif
}
@@ -5735,21 +5734,21 @@ ip_unset_variable(self, varname_arg, flag_arg)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return Qtrue;
+ DUMP1("ip is deleted");
+ return Qtrue;
}
ptr->return_value = Tcl_UnsetVar(ptr->ip, RSTRING(varname)->ptr,
- FIX2INT(flag));
+ FIX2INT(flag));
if (ptr->return_value == TCL_ERROR) {
- if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) {
+ if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) {
#if TCL_MAJOR_VERSION >= 8
- rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
#endif
- }
- return Qfalse;
+ }
+ return Qfalse;
}
return Qtrue;
}
@@ -5777,21 +5776,21 @@ ip_unset_variable2(self, varname_arg, index_arg, flag_arg)
/* ip is deleted? */
if (Tcl_InterpDeleted(ptr->ip)) {
- DUMP1("ip is deleted");
- return Qtrue;
+ DUMP1("ip is deleted");
+ return Qtrue;
}
ptr->return_value = Tcl_UnsetVar2(ptr->ip, RSTRING(varname)->ptr,
- RSTRING(index)->ptr, FIX2INT(flag));
+ RSTRING(index)->ptr, FIX2INT(flag));
if (ptr->return_value == TCL_ERROR) {
- if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) {
+ if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) {
#if TCL_MAJOR_VERSION >= 8
- rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
#else /* TCL_MAJOR_VERSION < 8 */
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
#endif
- }
- return Qfalse;
+ }
+ return Qfalse;
}
return Qtrue;
}
@@ -5802,7 +5801,7 @@ ip_get_global_var(self, varname)
VALUE varname;
{
return ip_get_variable(self, varname,
- INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
}
static VALUE
@@ -5812,7 +5811,7 @@ ip_get_global_var2(self, varname, index)
VALUE index;
{
return ip_get_variable2(self, varname, index,
- INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
}
static VALUE
@@ -5822,7 +5821,7 @@ ip_set_global_var(self, varname, value)
VALUE value;
{
return ip_set_variable(self, varname, value,
- INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
}
static VALUE
@@ -5833,7 +5832,7 @@ ip_set_global_var2(self, varname, index, value)
VALUE value;
{
return ip_set_variable2(self, varname, index, value,
- INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
}
static VALUE
@@ -5842,7 +5841,7 @@ ip_unset_global_var(self, varname)
VALUE varname;
{
return ip_unset_variable(self, varname,
- INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
}
static VALUE
@@ -5852,7 +5851,7 @@ ip_unset_global_var2(self, varname, index)
VALUE index;
{
return ip_unset_variable2(self, varname, index,
- INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
}
@@ -5870,161 +5869,161 @@ lib_split_tklist_core(ip_obj, list_str)
VALUE old_gc;
if (NIL_P(ip_obj)) {
- interp = (Tcl_Interp *)NULL;
+ interp = (Tcl_Interp *)NULL;
} else {
- interp = get_ip(ip_obj)->ip;
+ interp = get_ip(ip_obj)->ip;
}
StringValue(list_str);
{
#if TCL_MAJOR_VERSION >= 8
- /* object style interface */
- Tcl_Obj *listobj;
- int objc;
- Tcl_Obj **objv;
- int thr_crit_bup;
+ /* object style interface */
+ Tcl_Obj *listobj;
+ int objc;
+ Tcl_Obj **objv;
+ int thr_crit_bup;
# if 1
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
- listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr,
- RSTRING(list_str)->len);
+ listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
# else /* TCL_VERSION >= 8.1 */
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
-
- {
- VALUE enc = Qnil;
-
- if (RTEST(rb_ivar_defined(list_str, ID_at_enc))) {
- enc = rb_ivar_get(list_str, ID_at_enc);
- }
-
- if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
- /* binary string */
- listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr,
- RSTRING(list_str)->len);
- } else if (strlen(RSTRING(list_str)->ptr)
- != RSTRING(list_str)->len) {
- /* probably binary string */
- listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr,
- RSTRING(list_str)->len);
- } else {
- /* probably text string */
- listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr,
- RSTRING(list_str)->len);
- }
- }
-
- rb_thread_critical = thr_crit_bup;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ {
+ VALUE enc = Qnil;
+
+ if (RTEST(rb_ivar_defined(list_str, ID_at_enc))) {
+ enc = rb_ivar_get(list_str, ID_at_enc);
+ }
+
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ /* binary string */
+ listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
+ } else if (strlen(RSTRING(list_str)->ptr)
+ != RSTRING(list_str)->len) {
+ /* probably binary string */
+ listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
+ } else {
+ /* probably text string */
+ listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
+ }
+ }
+
+ rb_thread_critical = thr_crit_bup;
# endif
# else
- listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr,
- RSTRING(list_str)->len);
+ listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
# endif
- Tcl_IncrRefCount(listobj);
+ Tcl_IncrRefCount(listobj);
- result = Tcl_ListObjGetElements(interp, listobj, &objc, &objv);
+ result = Tcl_ListObjGetElements(interp, listobj, &objc, &objv);
- if (result == TCL_ERROR) {
- Tcl_DecrRefCount(listobj);
- if (interp == (Tcl_Interp*)NULL) {
- rb_raise(rb_eRuntimeError, "cannot get elements from list");
- } else {
+ if (result == TCL_ERROR) {
+ Tcl_DecrRefCount(listobj);
+ if (interp == (Tcl_Interp*)NULL) {
+ rb_raise(rb_eRuntimeError, "cannot get elements from list");
+ } else {
#if TCL_MAJOR_VERSION >= 8
- rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(interp));
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(interp));
#else /* TCL_MAJOR_VERSION < 8 */
- rb_raise(rb_eRuntimeError, "%s", interp->result);
+ rb_raise(rb_eRuntimeError, "%s", interp->result);
#endif
- }
- }
+ }
+ }
- for(idx = 0; idx < objc; idx++) {
- Tcl_IncrRefCount(objv[idx]);
- }
+ for(idx = 0; idx < objc; idx++) {
+ Tcl_IncrRefCount(objv[idx]);
+ }
- thr_crit_bup = rb_thread_critical;
- rb_thread_critical = Qtrue;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- ary = rb_ary_new2(objc);
- if (taint_flag) OBJ_TAINT(ary);
+ ary = rb_ary_new2(objc);
+ if (taint_flag) OBJ_TAINT(ary);
- old_gc = rb_gc_disable();
+ old_gc = rb_gc_disable();
- for(idx = 0; idx < objc; idx++) {
- char *str;
- int len;
+ for(idx = 0; idx < objc; idx++) {
+ char *str;
+ int len;
# if 1
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
- str = Tcl_GetStringFromObj(objv[idx], &len);
- elem = rb_str_new(str, len);
+ str = Tcl_GetStringFromObj(objv[idx], &len);
+ elem = rb_str_new(str, len);
# else /* TCL_VERSION >= 8.1 */
- if (Tcl_GetCharLength(objv[idx])
- != Tcl_UniCharLen(Tcl_GetUnicode(objv[idx]))) {
- /* possibly binary string */
- str = Tcl_GetByteArrayFromObj(objv[idx], &len);
- elem = rb_str_new(str, len);
- rb_ivar_set(elem, ID_at_enc, rb_tainted_str_new2("binary"));
- } else {
- /* possibly text string */
- str = Tcl_GetStringFromObj(objv[idx], &len);
- elem = rb_str_new(str, len);
- }
+ if (Tcl_GetCharLength(objv[idx])
+ != Tcl_UniCharLen(Tcl_GetUnicode(objv[idx]))) {
+ /* possibly binary string */
+ str = Tcl_GetByteArrayFromObj(objv[idx], &len);
+ elem = rb_str_new(str, len);
+ rb_ivar_set(elem, ID_at_enc, rb_tainted_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ str = Tcl_GetStringFromObj(objv[idx], &len);
+ elem = rb_str_new(str, len);
+ }
# endif
# else
- str = Tcl_GetStringFromObj(objv[idx], &len);
- elem = rb_str_new(str, len);
+ str = Tcl_GetStringFromObj(objv[idx], &len);
+ elem = rb_str_new(str, len);
# endif
- if (taint_flag) OBJ_TAINT(elem);
- RARRAY(ary)->ptr[idx] = elem;
- }
+ if (taint_flag) OBJ_TAINT(elem);
+ RARRAY(ary)->ptr[idx] = elem;
+ }
- RARRAY(ary)->len = objc;
+ RARRAY(ary)->len = objc;
- if (old_gc == Qfalse) rb_gc_enable();
+ if (old_gc == Qfalse) rb_gc_enable();
- rb_thread_critical = thr_crit_bup;
+ rb_thread_critical = thr_crit_bup;
- for(idx = 0; idx < objc; idx++) {
- Tcl_DecrRefCount(objv[idx]);
- }
+ for(idx = 0; idx < objc; idx++) {
+ Tcl_DecrRefCount(objv[idx]);
+ }
- Tcl_DecrRefCount(listobj);
+ Tcl_DecrRefCount(listobj);
#else /* TCL_MAJOR_VERSION < 8 */
- /* string style interface */
- int argc;
- char **argv;
+ /* string style interface */
+ int argc;
+ char **argv;
- if (Tcl_SplitList(interp, RSTRING(list_str)->ptr,
- &argc, &argv) == TCL_ERROR) {
- if (interp == (Tcl_Interp*)NULL) {
- rb_raise(rb_eRuntimeError, "cannot get elements from list");
- } else {
- rb_raise(rb_eRuntimeError, "%s", interp->result);
- }
- }
+ if (Tcl_SplitList(interp, RSTRING(list_str)->ptr,
+ &argc, &argv) == TCL_ERROR) {
+ if (interp == (Tcl_Interp*)NULL) {
+ rb_raise(rb_eRuntimeError, "cannot get elements from list");
+ } else {
+ rb_raise(rb_eRuntimeError, "%s", interp->result);
+ }
+ }
- ary = rb_ary_new2(argc);
- if (taint_flag) OBJ_TAINT(ary);
+ ary = rb_ary_new2(argc);
+ if (taint_flag) OBJ_TAINT(ary);
- old_gc = rb_gc_disable();
+ old_gc = rb_gc_disable();
- for(idx = 0; idx < argc; idx++) {
- if (taint_flag) {
- elem = rb_tainted_str_new2(argv[idx]);
- } else {
- elem = rb_str_new2(argv[idx]);
- }
- /* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */
- RARRAY(ary)->ptr[idx] = elem;
- }
- RARRAY(ary)->len = argc;
+ for(idx = 0; idx < argc; idx++) {
+ if (taint_flag) {
+ elem = rb_tainted_str_new2(argv[idx]);
+ } else {
+ elem = rb_str_new2(argv[idx]);
+ }
+ /* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */
+ RARRAY(ary)->ptr[idx] = elem;
+ }
+ RARRAY(ary)->len = argc;
- if (old_gc == Qfalse) rb_gc_enable();
+ if (old_gc == Qfalse) rb_gc_enable();
#endif
}
@@ -6074,13 +6073,13 @@ lib_merge_tklist(argc, argv, obj)
/* pass 1 */
len = 1;
for(num = 0; num < argc; num++) {
- if (OBJ_TAINTED(argv[num])) taint_flag = 1;
- dst = StringValuePtr(argv[num]);
+ if (OBJ_TAINTED(argv[num])) taint_flag = 1;
+ dst = StringValuePtr(argv[num]);
#if TCL_MAJOR_VERSION >= 8
- len += Tcl_ScanCountedElement(dst, RSTRING(argv[num])->len,
- &flagPtr[num]) + 1;
+ len += Tcl_ScanCountedElement(dst, RSTRING(argv[num])->len,
+ &flagPtr[num]) + 1;
#else /* TCL_MAJOR_VERSION < 8 */
- len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
+ len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
#endif
}
@@ -6090,8 +6089,8 @@ lib_merge_tklist(argc, argv, obj)
for(num = 0; num < argc; num++) {
#if TCL_MAJOR_VERSION >= 8
len = Tcl_ConvertCountedElement(RSTRING(argv[num])->ptr,
- RSTRING(argv[num])->len,
- dst, flagPtr[num]);
+ RSTRING(argv[num])->len,
+ dst, flagPtr[num]);
#else /* TCL_MAJOR_VERSION < 8 */
len = Tcl_ConvertElement(RSTRING(argv[num])->ptr, dst, flagPtr[num]);
#endif
@@ -6135,10 +6134,10 @@ lib_conv_listelement(self, src)
#if TCL_MAJOR_VERSION >= 8
len = Tcl_ScanCountedElement(RSTRING(src)->ptr, RSTRING(src)->len,
- &scan_flag);
+ &scan_flag);
dst = rb_str_new(0, len + 1);
len = Tcl_ConvertCountedElement(RSTRING(src)->ptr, RSTRING(src)->len,
- RSTRING(dst)->ptr, scan_flag);
+ RSTRING(dst)->ptr, scan_flag);
#else /* TCL_MAJOR_VERSION < 8 */
len = Tcl_ScanElement(RSTRING(src)->ptr, &scan_flag);
dst = rb_str_new(0, len + 1);
@@ -6183,7 +6182,7 @@ Init_tcltklib()
int ret = ruby_tcltk_stubs();
if (ret)
- rb_raise(rb_eLoadError, "tcltklib: tcltk_stubs init error(%d)", ret);
+ rb_raise(rb_eLoadError, "tcltklib: tcltk_stubs init error(%d)", ret);
#endif
/* --------------------------------------------------------------- */
@@ -6198,7 +6197,7 @@ Init_tcltklib()
/* --------------------------------------------------------------- */
rb_define_const(lib, "FINALIZE_PROC_NAME",
- rb_str_new2(finalize_hook_name));
+ rb_str_new2(finalize_hook_name));
/* --------------------------------------------------------------- */
@@ -6262,7 +6261,7 @@ Init_tcltklib()
rb_define_module_function(lib, "mainloop", lib_mainloop, -1);
rb_define_module_function(lib, "mainloop_watchdog",
- lib_mainloop_watchdog, -1);
+ lib_mainloop_watchdog, -1);
rb_define_module_function(lib, "do_one_event", lib_do_one_event, -1);
rb_define_module_function(lib, "mainloop_abort_on_exception",
lib_evloop_abort_on_exc, 0);
@@ -6273,25 +6272,25 @@ Init_tcltklib()
rb_define_module_function(lib, "set_no_event_wait", set_no_event_wait, 1);
rb_define_module_function(lib, "get_no_event_wait", get_no_event_wait, 0);
rb_define_module_function(lib, "set_eventloop_weight",
- set_eventloop_weight, 2);
+ set_eventloop_weight, 2);
rb_define_module_function(lib, "set_max_block_time", set_max_block_time,1);
rb_define_module_function(lib, "get_eventloop_weight",
- get_eventloop_weight, 0);
+ get_eventloop_weight, 0);
rb_define_module_function(lib, "num_of_mainwindows",
- lib_num_of_mainwindows, 0);
+ lib_num_of_mainwindows, 0);
/* --------------------------------------------------------------- */
rb_define_module_function(lib, "_split_tklist", lib_split_tklist, 1);
rb_define_module_function(lib, "_merge_tklist", lib_merge_tklist, -1);
rb_define_module_function(lib, "_conv_listelement",
- lib_conv_listelement, 1);
+ lib_conv_listelement, 1);
rb_define_module_function(lib, "_toUTF8", lib_toUTF8, -1);
rb_define_module_function(lib, "_fromUTF8", lib_fromUTF8, -1);
rb_define_module_function(lib, "_subst_UTF_backslash",
- lib_UTF_backslash, 1);
+ lib_UTF_backslash, 1);
rb_define_module_function(lib, "_subst_Tcl_backslash",
- lib_Tcl_backslash, 1);
+ lib_Tcl_backslash, 1);
/* --------------------------------------------------------------- */
@@ -6339,9 +6338,9 @@ Init_tcltklib()
rb_define_method(ip, "mainloop_watchdog", ip_mainloop_watchdog, -1);
rb_define_method(ip, "do_one_event", ip_do_one_event, -1);
rb_define_method(ip, "mainloop_abort_on_exception",
- ip_evloop_abort_on_exc, 0);
+ ip_evloop_abort_on_exc, 0);
rb_define_method(ip, "mainloop_abort_on_exception=",
- ip_evloop_abort_on_exc_set, 1);
+ ip_evloop_abort_on_exc_set, 1);
rb_define_method(ip, "set_eventloop_tick", ip_set_eventloop_tick, 1);
rb_define_method(ip, "get_eventloop_tick", ip_get_eventloop_tick, 0);
rb_define_method(ip, "set_no_event_wait", ip_set_no_event_wait, 1);
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb
index 061123b79ec..38e4b28decc 100644
--- a/ext/tk/lib/multi-tk.rb
+++ b/ext/tk/lib/multi-tk.rb
@@ -1,6 +1,6 @@
#
-# multi-tk.rb - supports multi Tk interpreters
-# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+# multi-tk.rb - supports multi Tk interpreters
+# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
require 'tcltklib'
require 'tkutil'
@@ -78,17 +78,17 @@ class MultiTkIp
end
def call(*args)
begin
- unless @ip.deleted?
- @ip.cb_eval(@cmd, *args)
- end
+ unless @ip.deleted?
+ @ip.cb_eval(@cmd, *args)
+ end
rescue TkCallbackBreak, TkCallbackContinue => e
- fail e
+ fail e
rescue Exception => e
- if @ip.safe?
- # ignore
- else
- fail e
- end
+ if @ip.safe?
+ # ignore
+ else
+ fail e
+ end
end
end
}.freeze
@@ -106,19 +106,19 @@ class MultiTkIp
def _check_and_return(thread, exception, wait=0)
unless thread
unless exception.kind_of?(MultiTkIp_OK) || safe?
- msg = "#{exception.class}: #{exception.message}"
- begin
- if @interp.deleted?
- warn('Warning: ' + msg)
- elsif @interp._eval_without_enc('info command bgerror').size != 0
- @interp._eval(@interp._merge_tklist('bgerror', msg))
- else
- warn('Warning: ' + msg)
- end
- rescue Exception => e
- warn('Warning: ' + msg)
- warn('Warning: ' + e.message)
- end
+ msg = "#{exception.class}: #{exception.message}"
+ begin
+ if @interp.deleted?
+ warn('Warning: ' + msg)
+ elsif @interp._eval_without_enc('info command bgerror').size != 0
+ @interp._eval(@interp._merge_tklist('bgerror', msg))
+ else
+ warn('Warning: ' + msg)
+ end
+ rescue Exception => e
+ warn('Warning: ' + msg)
+ warn('Warning: ' + e.message)
+ end
end
return nil
end
@@ -127,7 +127,7 @@ class MultiTkIp
# no wait
Thread.pass
if thread.stop?
- thread.raise exception
+ thread.raise exception
end
return thread
end
@@ -135,9 +135,9 @@ class MultiTkIp
# wait to stop the caller thread
wait.times{
if thread.stop?
- # ready to send exception
- thread.raise exception
- return thread
+ # ready to send exception
+ thread.raise exception
+ return thread
end
# wait
@@ -188,39 +188,39 @@ class MultiTkIp
def _destroy_slaves_of_slaveIP(ip)
unless ip.deleted?
ip._split_tklist(ip._invoke('interp', 'slaves')).each{|name|
- begin
- ip._eval_without_enc("#{name} eval {foreach i [after info] {after cancel $i}}")
- rescue Exception
- end
- begin
- # ip._invoke('interp', 'eval', name, 'destroy', '.')
- ip._invoke(name, 'eval', 'destroy', '.')
- rescue Exception
- end
-
- # safe_base?
- if ip._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
- begin
- ip._eval_without_enc("::safe::interpDelete #{name}")
- rescue Exception
- end
- end
+ begin
+ ip._eval_without_enc("#{name} eval {foreach i [after info] {after cancel $i}}")
+ rescue Exception
+ end
+ begin
+ # ip._invoke('interp', 'eval', name, 'destroy', '.')
+ ip._invoke(name, 'eval', 'destroy', '.')
+ rescue Exception
+ end
+
+ # safe_base?
+ if ip._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ ip._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ end
+ end
=begin
- if ip._invoke('interp', 'exists', name) == '1'
- begin
- ip._invoke(name, 'eval', 'exit')
- rescue Exception
- end
- end
+ if ip._invoke('interp', 'exists', name) == '1'
+ begin
+ ip._invoke(name, 'eval', 'exit')
+ rescue Exception
+ end
+ end
=end
- unless ip.deleted?
- if ip._invoke('interp', 'exists', name) == '1'
- begin
- ip._invoke('interp', 'delete', name)
- rescue Exception
- end
- end
- end
+ unless ip.deleted?
+ if ip._invoke('interp', 'exists', name) == '1'
+ begin
+ ip._invoke('interp', 'delete', name)
+ rescue Exception
+ end
+ end
+ end
}
end
end
@@ -233,139 +233,139 @@ class MultiTkIp
rescue SystemExit => e
# delete IP
unless @interp.deleted?
- @slave_ip_tbl.each{|name, subip|
- _destroy_slaves_of_slaveIP(subip)
- begin
- subip._eval_without_enc("foreach i [after info] {after cancel $i}")
- rescue Exception
- end
+ @slave_ip_tbl.each{|name, subip|
+ _destroy_slaves_of_slaveIP(subip)
+ begin
+ subip._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
=begin
- begin
- subip._invoke('destroy', '.') unless subip.deleted?
- rescue Exception
- end
+ begin
+ subip._invoke('destroy', '.') unless subip.deleted?
+ rescue Exception
+ end
=end
- # safe_base?
- if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
- begin
- @interp._eval_without_enc("::safe::interpDelete #{name}")
- rescue Exception
- else
- next if subip.deleted?
- end
- end
- if subip.respond_to?(:safe_base?) && subip.safe_base? &&
- !subip.deleted?
- # do 'exit' to call the delete_hook procedure
- begin
- subip._eval_without_enc('exit')
- rescue Exception
- end
- else
- begin
- subip.delete unless subip.deleted?
- rescue Exception
- end
- end
- }
-
- begin
- @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
- rescue Exception
- end
- begin
- @interp._invoke('destroy', '.') unless @interp.deleted?
- rescue Exception
- end
- if @safe_base && !@interp.deleted?
- # do 'exit' to call the delete_hook procedure
- @interp._eval_without_enc('exit')
- else
- @interp.delete unless @interp.deleted?
- end
+ # safe_base?
+ if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ @interp._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ else
+ next if subip.deleted?
+ end
+ end
+ if subip.respond_to?(:safe_base?) && subip.safe_base? &&
+ !subip.deleted?
+ # do 'exit' to call the delete_hook procedure
+ begin
+ subip._eval_without_enc('exit')
+ rescue Exception
+ end
+ else
+ begin
+ subip.delete unless subip.deleted?
+ rescue Exception
+ end
+ end
+ }
+
+ begin
+ @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
+ begin
+ @interp._invoke('destroy', '.') unless @interp.deleted?
+ rescue Exception
+ end
+ if @safe_base && !@interp.deleted?
+ # do 'exit' to call the delete_hook procedure
+ @interp._eval_without_enc('exit')
+ else
+ @interp.delete unless @interp.deleted?
+ end
end
if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/
- _check_and_return(thread, MultiTkIp_OK.new($3 == 'exit'))
+ _check_and_return(thread, MultiTkIp_OK.new($3 == 'exit'))
else
- _check_and_return(thread, MultiTkIp_OK.new(nil))
+ _check_and_return(thread, MultiTkIp_OK.new(nil))
end
if master? && !safe? && allow_ruby_exit?
=begin
- ObjectSpace.each_object(TclTkIp){|obj|
- obj.delete unless obj.deleted?
- }
+ ObjectSpace.each_object(TclTkIp){|obj|
+ obj.delete unless obj.deleted?
+ }
=end
- #exit(e.status)
- fail e
+ #exit(e.status)
+ fail e
end
# break
rescue SecurityError => e
# in 'exit', 'exit!', and 'abort' : security error --> delete IP
if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/
- ret = ($3 == 'exit')
- unless @interp.deleted?
- @slave_ip_tbl.each{|name, subip|
- _destroy_slaves_of_slaveIP(subip)
- begin
- subip._eval_without_enc("foreach i [after info] {after cancel $i}")
- rescue Exception
- end
+ ret = ($3 == 'exit')
+ unless @interp.deleted?
+ @slave_ip_tbl.each{|name, subip|
+ _destroy_slaves_of_slaveIP(subip)
+ begin
+ subip._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
=begin
- begin
- subip._invoke('destroy', '.') unless subip.deleted?
- rescue Exception
- end
+ begin
+ subip._invoke('destroy', '.') unless subip.deleted?
+ rescue Exception
+ end
=end
- # safe_base?
- if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
- begin
- @interp._eval_without_enc("::safe::interpDelete #{name}")
- rescue Exception
- else
- next if subip.deleted?
- end
- end
- if subip.respond_to?(:safe_base?) && subip.safe_base? &&
- !subip.deleted?
- # do 'exit' to call the delete_hook procedure
- begin
- subip._eval_without_enc('exit')
- rescue Exception
- end
- else
- begin
- subip.delete unless subip.deleted?
- rescue Exception
- end
- end
- }
-
- begin
- @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
- rescue Exception
- end
+ # safe_base?
+ if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ @interp._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ else
+ next if subip.deleted?
+ end
+ end
+ if subip.respond_to?(:safe_base?) && subip.safe_base? &&
+ !subip.deleted?
+ # do 'exit' to call the delete_hook procedure
+ begin
+ subip._eval_without_enc('exit')
+ rescue Exception
+ end
+ else
+ begin
+ subip.delete unless subip.deleted?
+ rescue Exception
+ end
+ end
+ }
+
+ begin
+ @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
=begin
- begin
- @interp._invoke('destroy', '.') unless @interp.deleted?
- rescue Exception
- end
+ begin
+ @interp._invoke('destroy', '.') unless @interp.deleted?
+ rescue Exception
+ end
=end
- if @safe_base && !@interp.deleted?
- # do 'exit' to call the delete_hook procedure
- @interp._eval_without_enc('exit')
- else
- @interp.delete unless @interp.deleted?
- end
- end
- _check_and_return(thread, MultiTkIp_OK.new(ret))
- # break
+ if @safe_base && !@interp.deleted?
+ # do 'exit' to call the delete_hook procedure
+ @interp._eval_without_enc('exit')
+ else
+ @interp.delete unless @interp.deleted?
+ end
+ end
+ _check_and_return(thread, MultiTkIp_OK.new(ret))
+ # break
else
- # raise security error
- _check_and_return(thread, e)
+ # raise security error
+ _check_and_return(thread, e)
end
rescue Exception => e
@@ -381,16 +381,16 @@ class MultiTkIp
def _receiver_eval_proc(last_thread, safe_level, thread, cmd, *args)
if thread
Thread.new{
- last_thread.join if last_thread
- unless @interp.deleted?
- _receiver_eval_proc_core(safe_level, thread, cmd, *args)
- end
+ last_thread.join if last_thread
+ unless @interp.deleted?
+ _receiver_eval_proc_core(safe_level, thread, cmd, *args)
+ end
}
else
Thread.new{
- unless @interp.deleted?
- _receiver_eval_proc_core(safe_level, thread, cmd, *args)
- end
+ unless @interp.deleted?
+ _receiver_eval_proc_core(safe_level, thread, cmd, *args)
+ end
}
last_thread
end
@@ -401,8 +401,8 @@ class MultiTkIp
def _receiver_mainloop(check_root)
Thread.new{
while !@interp.deleted?
- break if @interp._invoke_without_enc('info', 'command', '.').size == 0
- sleep 0.5
+ break if @interp._invoke_without_enc('info', 'command', '.').size == 0
+ sleep 0.5
end
}
end
@@ -415,54 +415,54 @@ class MultiTkIp
last_thread = nil
loop do
- break if @interp.deleted?
- thread, cmd, *args = @cmd_queue.deq
- if thread == @system
- # control command
- case cmd
- when 'set_safe_level'
- begin
- safe_level = args[0] if safe_level < args[0]
- rescue Exception
- end
- when 'call_mainloop'
- thread = args.shift
- _check_and_return(thread,
- MultiTkIp_OK.new(_receiver_mainloop(*args)))
- else
- # ignore
- end
-
- else
- # procedure
- last_thread = _receiver_eval_proc(last_thread, safe_level,
- thread, cmd, *args)
- end
+ break if @interp.deleted?
+ thread, cmd, *args = @cmd_queue.deq
+ if thread == @system
+ # control command
+ case cmd
+ when 'set_safe_level'
+ begin
+ safe_level = args[0] if safe_level < args[0]
+ rescue Exception
+ end
+ when 'call_mainloop'
+ thread = args.shift
+ _check_and_return(thread,
+ MultiTkIp_OK.new(_receiver_mainloop(*args)))
+ else
+ # ignore
+ end
+
+ else
+ # procedure
+ last_thread = _receiver_eval_proc(last_thread, safe_level,
+ thread, cmd, *args)
+ end
end
}
# watchdog of receiver
watchdog = Thread.new{
begin
- loop do
- sleep 1
- break unless receiver.alive?
- end
+ loop do
+ sleep 1
+ break unless receiver.alive?
+ end
rescue Exception
- # ignore all kind of Exception
+ # ignore all kind of Exception
end
# receiver is dead
loop do
- thread, cmd, *args = @cmd_queue.deq
- next unless thread
- if thread.alive?
- if @interp.deleted?
- thread.raise RuntimeError, 'the interpreter is already deleted'
- else
- thread.raise RuntimeError,
- 'the interpreter no longer receives command procedures'
- end
- end
+ thread, cmd, *args = @cmd_queue.deq
+ next unless thread
+ if thread.alive?
+ if @interp.deleted?
+ thread.raise RuntimeError, 'the interpreter is already deleted'
+ else
+ thread.raise RuntimeError,
+ 'the interpreter no longer receives command procedures'
+ end
+ end
end
}
@@ -528,38 +528,38 @@ class MultiTkIp
@assign_request = Class.new(Exception){
def self.new(target, ret)
- obj = super()
- obj.target = target
- obj.ret = ret
- obj
+ obj = super()
+ obj.target = target
+ obj.ret = ret
+ obj
end
attr_accessor :target, :ret
}
@assign_thread = Thread.new{
loop do
- begin
- Thread.stop
- rescue @assign_request=>req
- begin
- req.ret[0] = req.target.instance_eval{
- @cmd_receiver, @receiver_watchdog =
- _create_receiver_and_watchdog(@safe_level[0])
- @threadgroup.add @cmd_receiver
- @threadgroup.add @receiver_watchdog
- @threadgroup.enclose
- true
- }
- rescue Exception=>e
- begin
- req.ret[0] = e
- rescue Exception
- # ignore
- end
- end
- rescue Exception
- # ignore
- end
+ begin
+ Thread.stop
+ rescue @assign_request=>req
+ begin
+ req.ret[0] = req.target.instance_eval{
+ @cmd_receiver, @receiver_watchdog =
+ _create_receiver_and_watchdog(@safe_level[0])
+ @threadgroup.add @cmd_receiver
+ @threadgroup.add @receiver_watchdog
+ @threadgroup.enclose
+ true
+ }
+ rescue Exception=>e
+ begin
+ req.ret[0] = e
+ rescue Exception
+ # ignore
+ end
+ end
+ rescue Exception
+ # ignore
+ end
end
}
@@ -567,14 +567,14 @@ class MultiTkIp
ret = [nil]
@assign_thread.raise(@assign_request.new(target, ret))
while ret[0] == nil
- unless @assign_thread.alive?
- raise RuntimeError, 'lost the thread to assign a receiver and a watchdog thread'
- end
+ unless @assign_thread.alive?
+ raise RuntimeError, 'lost the thread to assign a receiver and a watchdog thread'
+ end
end
if ret[0].kind_of?(Exception)
- raise ret[0]
+ raise ret[0]
else
- ret[0]
+ ret[0]
end
end
@@ -592,21 +592,21 @@ class MultiTkIp
# trust if on ThreadGroup::Default or @@DEFAULT_MASTER's ThreadGroup
if @@IP_TABLE[Thread.current.group] == @@DEFAULT_MASTER
begin
- class << subclass
- self.methods.each{|m|
- begin
- unless m == '__id__' || m == '__send__' || m == 'freeze'
- undef_method(m)
- end
- rescue Exception
- # ignore all exceptions
- end
- }
- end
+ class << subclass
+ self.methods.each{|m|
+ begin
+ unless m == '__id__' || m == '__send__' || m == 'freeze'
+ undef_method(m)
+ end
+ rescue Exception
+ # ignore all exceptions
+ end
+ }
+ end
ensure
- subclass.freeze
- fail SecurityError,
- "cannot create subclass of MultiTkIp on a untrusted ThreadGroup"
+ subclass.freeze
+ fail SecurityError,
+ "cannot create subclass of MultiTkIp on a untrusted ThreadGroup"
end
end
end
@@ -629,13 +629,13 @@ class MultiTkIp
keys.each{|k,v|
k_str = k.to_s
if k_str == 'name'
- name = v
+ name = v
elsif k_str == 'safe'
- safe = v
+ safe = v
elsif SAFE_OPT_LIST.member?(k_str)
- safe_opts[k_str] = v
+ safe_opts[k_str] = v
else
- tk_opts[k_str] = v
+ tk_opts[k_str] = v
end
}
@@ -664,15 +664,15 @@ class MultiTkIp
# check 'display'
if !new_keys.key?('display')
begin
- #new_keys['display'] = @interp._invoke('winfo screen .')
- new_keys['display'] = @interp._invoke('winfo', 'screen', '.')
+ #new_keys['display'] = @interp._invoke('winfo screen .')
+ new_keys['display'] = @interp._invoke('winfo', 'screen', '.')
rescue
- if ENV[DISPLAY]
- new_keys['display'] = ENV[DISPLAY]
- elsif !new_keys.key?('use')
- warn "Warning: no screen info or ENV[DISPLAY], so use ':0.0'"
- new_keys['display'] = ':0.0'
- end
+ if ENV[DISPLAY]
+ new_keys['display'] = ENV[DISPLAY]
+ elsif !new_keys.key?('use')
+ warn "Warning: no screen info or ENV[DISPLAY], so use ':0.0'"
+ new_keys['display'] = ':0.0'
+ end
end
end
@@ -681,30 +681,30 @@ class MultiTkIp
# given 'use'
case new_keys['use']
when TkWindow
- new_keys['use'] = TkWinfo.id(new_keys['use'])
- #assoc_display = @interp._eval('winfo screen .')
- assoc_display = @interp._invoke('winfo', 'screen', '.')
+ new_keys['use'] = TkWinfo.id(new_keys['use'])
+ #assoc_display = @interp._eval('winfo screen .')
+ assoc_display = @interp._invoke('winfo', 'screen', '.')
when /^\..*/
- new_keys['use'] = @interp._invoke('winfo', 'id', new_keys['use'])
- assoc_display = @interp._invoke('winfo', 'screen', new_keys['use'])
+ new_keys['use'] = @interp._invoke('winfo', 'id', new_keys['use'])
+ assoc_display = @interp._invoke('winfo', 'screen', new_keys['use'])
else
- begin
- pathname = @interp._invoke('winfo', 'pathname', new_keys['use'])
- assco_display = @interp._invoke('winfo', 'screen', pathname)
- rescue
- assoc_display = new_keys['display']
- end
+ begin
+ pathname = @interp._invoke('winfo', 'pathname', new_keys['use'])
+ assco_display = @interp._invoke('winfo', 'screen', pathname)
+ rescue
+ assoc_display = new_keys['display']
+ end
end
# match display?
if assoc_display != new_keys['display']
- if optkeys.keys?(:display) || optkeys.keys?('display')
- fail RuntimeError,
- "conflicting 'display'=>#{new_keys['display']} " +
- "and display '#{assoc_display}' on 'use'=>#{new_keys['use']}"
- else
- new_keys['display'] = assoc_display
- end
+ if optkeys.keys?(:display) || optkeys.keys?('display')
+ fail RuntimeError,
+ "conflicting 'display'=>#{new_keys['display']} " +
+ "and display '#{assoc_display}' on 'use'=>#{new_keys['use']}"
+ else
+ new_keys['display'] = assoc_display
+ end
end
end
@@ -746,11 +746,11 @@ class MultiTkIp
# procedure to delete slave interpreter
slave_delete_proc = proc{
unless slave_ip.deleted?
- #if slave_ip._invoke('info', 'command', '.') != ""
- # slave_ip._invoke('destroy', '.')
- #end
- #slave_ip.delete
- slave_ip._eval_without_enc('exit')
+ #if slave_ip._invoke('info', 'command', '.') != ""
+ # slave_ip._invoke('destroy', '.')
+ #end
+ #slave_ip.delete
+ slave_ip._eval_without_enc('exit')
end
top.destroy if top.winfo_exist?
}
@@ -763,15 +763,15 @@ class MultiTkIp
fc.bindtags = fc.bindtags.unshift(tag)
TkFrame.new(fc, :bd=>0){|f|
- TkButton.new(f,
- :text=>'Delete', :bd=>1, :padx=>2, :pady=>0,
- :highlightthickness=>0, :command=>slave_delete_proc
- ).pack(:side=>:right, :fill=>:both)
- f.pack(:side=>:right, :fill=>:both, :expand=>true)
+ TkButton.new(f,
+ :text=>'Delete', :bd=>1, :padx=>2, :pady=>0,
+ :highlightthickness=>0, :command=>slave_delete_proc
+ ).pack(:side=>:right, :fill=>:both)
+ f.pack(:side=>:right, :fill=>:both, :expand=>true)
}
TkLabel.new(fc, :text=>msg, :padx=>2, :pady=>0,
- :anchor=>:w).pack(:side=>:left, :fill=>:both, :expand=>true)
+ :anchor=>:w).pack(:side=>:left, :fill=>:both, :expand=>true)
fc.pack(:side=>:bottom, :fill=>:x)
}
@@ -803,11 +803,11 @@ class MultiTkIp
if tk_opts
tk_opts = __check_safetk_optkeys(tk_opts)
if tk_opts.key?('use')
- @slave_ip_top[ip_name] = ''
+ @slave_ip_top[ip_name] = ''
else
- tk_opts, top_path = __create_safetk_frame(slave_ip, ip_name, app_name,
- tk_opts)
- @slave_ip_top[ip_name] = top_path
+ tk_opts, top_path = __create_safetk_frame(slave_ip, ip_name, app_name,
+ tk_opts)
+ @slave_ip_top[ip_name] = top_path
end
@interp._eval("::safe::loadTk #{ip_name} #{_keys2opts(tk_opts)}")
else
@@ -816,13 +816,13 @@ class MultiTkIp
if safe_opts.key?('deleteHook') || safe_opts.key?(:deleteHook)
@interp._eval("::safe::interpConfigure #{ip_name} " +
- _keys2opts(safe_opts))
+ _keys2opts(safe_opts))
else
@interp._eval("::safe::interpConfigure #{ip_name} " +
- _keys2opts(safe_opts) + '-deleteHook {' +
- TkComm._get_eval_string(proc{|slave|
- self._default_delete_hook(slave)
- }) + '}')
+ _keys2opts(safe_opts) + '-deleteHook {' +
+ TkComm._get_eval_string(proc{|slave|
+ self._default_delete_hook(slave)
+ }) + '}')
end
[slave_ip, ip_name]
@@ -890,34 +890,34 @@ class MultiTkIp
@ip_name = nil
if safe
- safe = $SAFE if safe < $SAFE
- @safe_level = [safe]
+ safe = $SAFE if safe < $SAFE
+ @safe_level = [safe]
else
- @safe_level = [$SAFE]
+ @safe_level = [$SAFE]
end
else
# create slave-ip
if safeip || master.safe?
- @safe_base = true
- @interp, @ip_name = master.__create_safe_slave_obj(safe_opts,
- name, tk_opts)
- if safe
- safe = master.safe_level if safe < master.safe_level
- @safe_level = [safe]
- else
- @safe_level = [4]
- end
+ @safe_base = true
+ @interp, @ip_name = master.__create_safe_slave_obj(safe_opts,
+ name, tk_opts)
+ if safe
+ safe = master.safe_level if safe < master.safe_level
+ @safe_level = [safe]
+ else
+ @safe_level = [4]
+ end
else
- @interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts)
- if safe
- safe = master.safe_level if safe < master.safe_level
- @safe_level = [safe]
- else
- @safe_level = [master.safe_level]
- end
+ @interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts)
+ if safe
+ safe = master.safe_level if safe < master.safe_level
+ @safe_level = [safe]
+ else
+ @safe_level = [master.safe_level]
+ end
end
@set_alias_proc = proc{|name|
- master._invoke('interp', 'alias', @ip_name, name, '', name)
+ master._invoke('interp', 'alias', @ip_name, name, '', name)
}.freeze
end
@@ -959,22 +959,22 @@ class MultiTkIp
if @slave_ip_top[slave].kind_of?(String)
# call default hook of safetk.tcl (ignore exceptions)
if @slave_ip_top[slave] == ''
- begin
- @interp._eval("::safe::disallowTk #{slave}")
- rescue
- warn("Waring: fail to call '::safe::disallowTk'") if $DEBUG
- end
+ begin
+ @interp._eval("::safe::disallowTk #{slave}")
+ rescue
+ warn("Waring: fail to call '::safe::disallowTk'") if $DEBUG
+ end
else # toplevel path
- begin
- @interp._eval("::safe::tkDelete {} #{@slave_ip_top[slave]} #{slave}")
- rescue
- warn("Waring: fail to call '::safe::tkDelete'") if $DEBUG
- begin
- @interp._eval("destroy #{@slave_ip_top[slave]}")
- rescue
- warn("Waring: fail to destroy toplevel") if $DEBUG
- end
- end
+ begin
+ @interp._eval("::safe::tkDelete {} #{@slave_ip_top[slave]} #{slave}")
+ rescue
+ warn("Waring: fail to call '::safe::tkDelete'") if $DEBUG
+ begin
+ @interp._eval("destroy #{@slave_ip_top[slave]}")
+ rescue
+ warn("Waring: fail to destroy toplevel") if $DEBUG
+ end
+ end
end
end
@slave_ip_tbl.delete(slave)
@@ -998,8 +998,8 @@ class MultiTkIp
else
ip = @@IP_TABLE[Thread.current.group]
unless ip
- fail SecurityError,
- "cannot call Tk methods on #{Thread.current.inspect}"
+ fail SecurityError,
+ "cannot call Tk methods on #{Thread.current.inspect}"
end
ip
end
@@ -1019,7 +1019,7 @@ class << MultiTkIp
elsif safe.kind_of?(Integer)
raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash)
if !keys.key?(:safe) && !keys.key?('safe')
- keys[:safe] = safe
+ keys[:safe] = safe
end
elsif safe == nil
# do nothing
@@ -1040,7 +1040,7 @@ class << MultiTkIp
elsif safe.kind_of?(Integer)
raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash)
if !keys.key?(:safe) && !keys.key?('safe')
- keys[:safe] = safe
+ keys[:safe] = safe
end
elsif safe == nil
# do nothing
@@ -1060,7 +1060,7 @@ class << MultiTkIp
elsif safe.kind_of?(Integer)
raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash)
if !keys.key?(:safe) && !keys.key?('safe')
- keys[:safe] = safe
+ keys[:safe] = safe
end
else
raise ArgumentError, "unexpected argument(s)"
@@ -1082,9 +1082,9 @@ class MultiTkIp
s << ':master'
else
if @interp.safe?
- s << ':safe-slave'
+ s << ':safe-slave'
else
- s << ':trusted-slave'
+ s << ':trusted-slave'
end
end
s << '>'
@@ -1144,11 +1144,11 @@ class MultiTkIp
def slaves(all = false)
@interp._invoke('interp','slaves').split.map!{|name|
if @slave_ip_tbl.key?(name)
- @slave_ip_tbl[name]
+ @slave_ip_tbl[name]
elsif all
- name
+ name
else
- nil
+ nil
end
}.compact!
end
@@ -1197,9 +1197,9 @@ class MultiTkIp
init_ip_env.each{|script| script.call(self)}
add_tk_procs.each{|name, args, body|
if master?
- @interp._invoke('proc', name, args, body) if args && body
+ @interp._invoke('proc', name, args, body) if args && body
else
- @set_alias_proc.call(name)
+ @set_alias_proc.call(name)
end
}
end
@@ -1226,7 +1226,7 @@ class MultiTkIp
@@TK_TABLE_LIST << obj
obj.instance_eval <<-EOD
def self.method_missing(m, *args)
- MultiTkIp.tk_object_table(#{id}).__send__(m, *args)
+ MultiTkIp.tk_object_table(#{id}).__send__(m, *args)
end
EOD
obj.freeze
@@ -1285,23 +1285,23 @@ class MultiTkIp
# on IP thread
if (@cmd_receiver == Thread.current)
begin
- ret = cmd.call(*args)
+ ret = cmd.call(*args)
rescue SystemExit
- # exit IP
- warn("Warning: "+ $! + " on " + self.inspect) if $DEBUG
- begin
- self._eval_without_enc('exit')
- rescue Exception
- end
- self.delete
- ret = nil
+ # exit IP
+ warn("Warning: "+ $! + " on " + self.inspect) if $DEBUG
+ begin
+ self._eval_without_enc('exit')
+ rescue Exception
+ end
+ self.delete
+ ret = nil
rescue Exception => e
- if $DEBUG
- warn("Warning: " + e.class.inspect +
- ((e.message.length > 0)? ' "' + e.message + '"': '') +
- " on " + self.inspect)
- end
- ret = e
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ ret = e
end
return ret
end
@@ -1309,15 +1309,15 @@ class MultiTkIp
# send cmd to the proc-queue
unless req_val
begin
- @cmd_queue.enq([nil, cmd, *args])
+ @cmd_queue.enq([nil, cmd, *args])
rescue Exception => e
- # ignore
- if $DEBUG || true
- warn("Warning: " + e.class.inspect +
- ((e.message.length > 0)? ' "' + e.message + '"': '') +
- " on " + self.inspect)
- end
- return e
+ # ignore
+ if $DEBUG || true
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ return e
end
return nil
end
@@ -1333,20 +1333,20 @@ class MultiTkIp
# exit IP
warn("Warning: " + $! + " on " + self.inspect) if $DEBUG
begin
- self._eval_without_enc('exit')
+ self._eval_without_enc('exit')
rescue Exception
end
if !safe? && allow_ruby_exit?
- self.delete
- fail e
+ self.delete
+ fail e
else
- self.delete
+ self.delete
end
rescue Exception => e
if $DEBUG
- warn("Warning: " + e.class.inspect +
- ((e.message.length > 0)? ' "' + e.message + '"': '') +
- " on " + self.inspect)
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
end
return e
end
@@ -1388,14 +1388,14 @@ class MultiTkIp
cmd = Proc.new
else
unless (cmd = args.shift)
- fail ArgumentError, "A Proc or Method object is expected for 1st argument"
+ fail ArgumentError, "A Proc or Method object is expected for 1st argument"
end
end
eval_proc_core(true,
- proc{|safe, *params|
- $SAFE=safe; Thread.new(*params, &cmd).value
- },
- *args)
+ proc{|safe, *params|
+ $SAFE=safe; Thread.new(*params, &cmd).value
+ },
+ *args)
end
alias call eval_proc
@@ -1404,15 +1404,15 @@ class MultiTkIp
cmd = Proc.new
else
unless (cmd = args.shift)
- fail ArgumentError, "A Proc or Method object is expected for 1st argument"
+ fail ArgumentError, "A Proc or Method object is expected for 1st argument"
end
end
Thread.new{
eval_proc_core(false,
- proc{|safe, *params|
- $SAFE=safe; Thread.new(*params, &cmd).value
- },
- *args)
+ proc{|safe, *params|
+ $SAFE=safe; Thread.new(*params, &cmd).value
+ },
+ *args)
}
end
alias background_eval_proc bg_eval_proc
@@ -1436,7 +1436,7 @@ class MultiTkIp
end
Thread.new{
eval_proc_core(true,
- proc{|safe| $SAFE=safe; Kernel.eval(cmd, *eval_args)})
+ proc{|safe| $SAFE=safe; Kernel.eval(cmd, *eval_args)})
}
end
alias background_eval_string bg_eval_string
@@ -1723,35 +1723,35 @@ class MultiTkIp
#return self if self != @@DEFAULT_MASTER
if self != @@DEFAULT_MASTER
if @wait_on_mainloop[0]
- begin
- @wait_on_mainloop[1] = true
- @cmd_queue.enq([@system, 'call_mainloop',
- Thread.current, check_root])
- Thread.stop
- rescue MultiTkIp_OK => ret
- # return value
- @wait_on_mainloop[1] = false
- return ret.value.value
- rescue SystemExit
- # exit IP
- warn("Warning: " + $! + " on " + self.inspect) if $DEBUG
- @wait_on_mainloop[1] = false
- begin
- self._eval_without_enc('exit')
- rescue Exception
- end
- self.delete
- rescue Exception => e
- if $DEBUG
- warn("Warning: " + e.class.inspect +
- ((e.message.length > 0)? ' "' + e.message + '"': '') +
- " on " + self.inspect)
- end
- @wait_on_mainloop[1] = false
- return e
- ensure
- @wait_on_mainloop[1] = false
- end
+ begin
+ @wait_on_mainloop[1] = true
+ @cmd_queue.enq([@system, 'call_mainloop',
+ Thread.current, check_root])
+ Thread.stop
+ rescue MultiTkIp_OK => ret
+ # return value
+ @wait_on_mainloop[1] = false
+ return ret.value.value
+ rescue SystemExit
+ # exit IP
+ warn("Warning: " + $! + " on " + self.inspect) if $DEBUG
+ @wait_on_mainloop[1] = false
+ begin
+ self._eval_without_enc('exit')
+ rescue Exception
+ end
+ self.delete
+ rescue Exception => e
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ @wait_on_mainloop[1] = false
+ return e
+ ensure
+ @wait_on_mainloop[1] = false
+ end
end
return
end
@@ -1762,27 +1762,27 @@ class MultiTkIp
@wait_on_mainloop[1] = false
else
begin
- @wait_on_mainloop[1] = true
- loop do
- break unless self.alive?
- if check_root
- begin
- break if TclTkLib.num_of_mainwindows == 0
- rescue Exception
- break
- end
- end
- @interp.mainloop(check_root)
- end
+ @wait_on_mainloop[1] = true
+ loop do
+ break unless self.alive?
+ if check_root
+ begin
+ break if TclTkLib.num_of_mainwindows == 0
+ rescue Exception
+ break
+ end
+ end
+ @interp.mainloop(check_root)
+ end
#rescue StandardError
rescue Exception
- if TclTkLib.mainloop_abort_on_exception != nil
- STDERR.print("Warning: Tk mainloop receives ", $!.class.inspect,
- " exception (ignore) : ", $!.message, "\n");
- end
- retry
+ if TclTkLib.mainloop_abort_on_exception != nil
+ STDERR.print("Warning: Tk mainloop receives ", $!.class.inspect,
+ " exception (ignore) : ", $!.message, "\n");
+ end
+ retry
ensure
- @wait_on_mainloop[1] = false
+ @wait_on_mainloop[1] = false
end
end
self
@@ -1813,36 +1813,36 @@ class MultiTkIp
_destroy_slaves_of_slaveIP(subip)
=begin
begin
- subip._invoke('destroy', '.') unless subip.deleted?
+ subip._invoke('destroy', '.') unless subip.deleted?
rescue Exception
end
=end
begin
- subip._eval_without_enc("foreach i [after info] {after cancel $i}")
+ subip._eval_without_enc("foreach i [after info] {after cancel $i}")
rescue Exception
end
# safe_base?
if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
- begin
- @interp._eval_without_enc("::safe::interpDelete #{name}")
- rescue Exception
- else
- next if subip.deleted?
- end
+ begin
+ @interp._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ else
+ next if subip.deleted?
+ end
end
if subip.respond_to?(:safe_base?) && subip.safe_base? &&
- !subip.deleted?
- # do 'exit' to call the delete_hook procedure
- begin
- subip._eval_without_enc('exit')
- rescue Exception
- end
+ !subip.deleted?
+ # do 'exit' to call the delete_hook procedure
+ begin
+ subip._eval_without_enc('exit')
+ rescue Exception
+ end
else
- begin
- subip.delete unless subip.deleted?
- rescue Exception
- end
+ begin
+ subip.delete unless subip.deleted?
+ rescue Exception
+ end
end
}
@@ -1872,9 +1872,9 @@ class MultiTkIp
def abort(msg = nil)
if master?
if msg
- Kernel.abort(msg)
+ Kernel.abort(msg)
else
- Kernel.abort
+ Kernel.abort
end
else
# ignore msg
@@ -2076,7 +2076,7 @@ class MultiTkIp
def def_alias(slave, new_cmd, org_cmd, *args)
ret = @interp._invoke('interp', 'alias', _slavearg(slave), new_cmd,
- '', org_cmd, *args)
+ '', org_cmd, *args)
(ret == new_cmd)? self: nil
end
def self.def_alias(slave, new_cmd, org_cmd, *args)
@@ -2161,7 +2161,7 @@ class MultiTkIp
def invoke_hidden_on_global(slave, cmd, *args)
@interp._invoke('interp', 'invokehidden', _slavearg(slave),
- '-global', cmd, *args)
+ '-global', cmd, *args)
end
def self.invoke_hidden_on_global(slave, cmd, *args)
__getip.invoke_hidden_on_global(slave, cmd, *args)
@@ -2178,7 +2178,7 @@ class MultiTkIp
def recursion_limit(slave = '', limit = None)
number(@interp._invoke('interp', 'recursionlimit',
- _slavearg(slave), limit))
+ _slavearg(slave), limit))
end
def self.recursion_limit(slave = '', limit = None)
__getip.recursion_limit(slave)
@@ -2279,7 +2279,7 @@ class MultiTkIp
ip._eval('::safe::interpConfigure ' + @ip_name + ' ' + _keys2opts(slot))
else
ip._eval('::safe::interpConfigure ' + @ip_name + ' ' +
- "-#{slot} #{_get_eval_string(value)}")
+ "-#{slot} #{_get_eval_string(value)}")
end
self
end
@@ -2289,28 +2289,28 @@ class MultiTkIp
ret = {}
if slot
conf = _lst2ary(ip._eval("::safe::interpConfigure " +
- @ip_name + " -#{slot}"))
+ @ip_name + " -#{slot}"))
if conf[0] == '-deleteHook'
- if conf[1] =~ /^rb_out\S* (c(_\d+_)?\d+)/
- ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$1]
- else
- ret[conf[0][1..-1]] = conf[1]
- end
+ if conf[1] =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$1]
+ else
+ ret[conf[0][1..-1]] = conf[1]
+ end
else
- ret[conf[0][1..-1]] = conf[1]
+ ret[conf[0][1..-1]] = conf[1]
end
else
Hash[*_lst2ary(ip._eval("::safe::interpConfigure " +
- @ip_name))].each{|k, v|
- if k == '-deleteHook'
- if v =~ /^rb_out\S* (c(_\d+_)?\d+)/
- ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$1]
- else
- ret[k[1..-1]] = v
- end
- else
- ret[k[1..-1]] = v
- end
+ @ip_name))].each{|k, v|
+ if k == '-deleteHook'
+ if v =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$1]
+ else
+ ret[k[1..-1]] = v
+ end
+ else
+ ret[k[1..-1]] = v
+ end
}
end
ret
diff --git a/ext/tk/lib/remote-tk.rb b/ext/tk/lib/remote-tk.rb
index 77dbacfb130..1ef5310bdeb 100644
--- a/ext/tk/lib/remote-tk.rb
+++ b/ext/tk/lib/remote-tk.rb
@@ -1,6 +1,6 @@
#
-# remote-tk.rb - supports to control remote Tk interpreters
-# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+# remote-tk.rb - supports to control remote Tk interpreters
+# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
if defined? MultiTkIp
fail RuntimeError, "'remote-tk' library must be required before requiring 'multi-tk'"
@@ -137,14 +137,14 @@ class RemoteTkIp
return nil if timeout < 1
@ret_val.value = ''
@interp._invoke('send', '-async', @remote,
- 'send', '-async', Tk.appname,
- "set #{@ret_val.id} ready")
+ 'send', '-async', Tk.appname,
+ "set #{@ret_val.id} ready")
Tk.update
if @ret_val != 'ready'
(1..(timeout*5)).each{
- sleep 0.2
- Tk.update
- break if @ret_val == 'ready'
+ sleep 0.2
+ Tk.update
+ break if @ret_val == 'ready'
}
end
@ret_val.value == 'ready'
@@ -154,16 +154,16 @@ class RemoteTkIp
def _create_connection
ip_id = '_' + @interp._invoke('send', @remote, <<-'EOS') + '_'
if {[catch {set _rubytk_control_ip_id_} ret] != 0} {
- set _rubytk_control_ip_id_ 0
+ set _rubytk_control_ip_id_ 0
} else {
- set _rubytk_control_ip_id_ [expr $ret + 1]
+ set _rubytk_control_ip_id_ [expr $ret + 1]
}
return $_rubytk_control_ip_id_
EOS
@interp._invoke('send', @remote, <<-EOS)
proc rb_out#{ip_id} args {
- send #{@appname} rb_out \$args
+ send #{@appname} rb_out \$args
}
EOS
@@ -182,17 +182,17 @@ class RemoteTkIp
cmds = @interp._merge_tklist(*_conv_args([], enc_mode, *cmds))
if @displayof
if async
- @interp.__invoke('send', '-async', '-displayof', @displayof,
- '--', @remote, *cmds)
+ @interp.__invoke('send', '-async', '-displayof', @displayof,
+ '--', @remote, *cmds)
else
- @interp.__invoke('send', '-displayof', @displayof,
- '--', @remote, *cmds)
+ @interp.__invoke('send', '-displayof', @displayof,
+ '--', @remote, *cmds)
end
else
if async
- @interp.__invoke('send', '-async', '--', @remote, *cmds)
+ @interp.__invoke('send', '-async', '--', @remote, *cmds)
else
- @interp.__invoke('send', '--', @remote, *cmds)
+ @interp.__invoke('send', '--', @remote, *cmds)
end
end
end
@@ -271,7 +271,7 @@ class RemoteTkIp
def deleted?
if @displayof
lst = @interp._invoke_without_enc('winfo', 'interps',
- '-displayof', @displayof)
+ '-displayof', @displayof)
else
lst = @interp._invoke_without_enc('winfo', 'interps')
end
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index a5d2645e984..5fa4665922d 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -1,7 +1,7 @@
#
-# tk.rb - Tk interface module using tcltklib
-# $Date$
-# by Yukihiro Matsumoto <matz@netlab.jp>
+# tk.rb - Tk interface module using tcltklib
+# $Date$
+# by Yukihiro Matsumoto <matz@netlab.jp>
# use Shigehiro's tcltklib
require 'tcltklib'
@@ -96,32 +96,32 @@ module TkComm
else # ruby_class == nil
mods = TkExtlibAutoloadModule.find_all{|m| m.const_defined?(tk_class)}
mods.each{|mod|
- begin
- mod.const_get(tk_class) # auto_load
- break if (ruby_class = WidgetClassNames[tk_class])
- rescue LoadError
- # ignore load error
- end
+ begin
+ mod.const_get(tk_class) # auto_load
+ break if (ruby_class = WidgetClassNames[tk_class])
+ rescue LoadError
+ # ignore load error
+ end
}
unless ruby_class
- std_class = 'Tk' << tk_class
- if Object.const_defined?(std_class)
- Object.const_get(std_class) # auto_load
- ruby_class = WidgetClassNames[tk_class]
- end
+ std_class = 'Tk' << tk_class
+ if Object.const_defined?(std_class)
+ Object.const_get(std_class) # auto_load
+ ruby_class = WidgetClassNames[tk_class]
+ end
end
if ruby_class
- # found
- ruby_class_name = ruby_class.name
- gen_class_name = ruby_class_name
- classname_def = ''
+ # found
+ ruby_class_name = ruby_class.name
+ gen_class_name = ruby_class_name
+ classname_def = ''
else
- # unknown
- ruby_class_name = 'TkWindow'
- gen_class_name = 'TkWidget_' + tk_class
- classname_def = "WidgetClassName = '#{tk_class}'.freeze"
+ # unknown
+ ruby_class_name = 'TkWindow'
+ gen_class_name = 'TkWidget_' + tk_class
+ classname_def = "WidgetClassName = '#{tk_class}'.freeze"
end
end
@@ -135,19 +135,19 @@ module TkComm
else
mod = TkExtlibAutoloadModule.find{|m| m.const_defined?(tk_class)}
if mod
- ruby_class_name = mod.name + '::' + tk_class
- gen_class_name = ruby_class_name
- classname_def = ''
+ ruby_class_name = mod.name + '::' + tk_class
+ gen_class_name = ruby_class_name
+ classname_def = ''
elsif Object.const_defined?('Tk' + tk_class)
- ruby_class_name = 'Tk' + tk_class
- # gen_class_name = ruby_class_name + 'GeneratedOnTk'
- gen_class_name = ruby_class_name
- classname_def = ''
+ ruby_class_name = 'Tk' + tk_class
+ # gen_class_name = ruby_class_name + 'GeneratedOnTk'
+ gen_class_name = ruby_class_name
+ classname_def = ''
else
- ruby_class_name = 'TkWindow'
- # gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk'
- gen_class_name = 'TkWidget_' + tk_class
- classname_def = "WidgetClassName = '#{tk_class}'.freeze"
+ ruby_class_name = 'TkWindow'
+ # gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk'
+ gen_class_name = 'TkWidget_' + tk_class
+ classname_def = "WidgetClassName = '#{tk_class}'.freeze"
end
end
=end
@@ -165,9 +165,9 @@ module TkComm
gen_class_name.split('::').each{|klass|
next if klass == ''
if base.const_defined?(klass)
- base = base.class_eval klass
+ base = base.class_eval klass
else
- base = base.class_eval "class #{klass}<#{ruby_class_name}
+ base = base.class_eval "class #{klass}<#{ruby_class_name}
#{classname_def}
end
#{klass}"
@@ -215,19 +215,19 @@ module TkComm
val.gsub(/\\ /, ' ')
when /[^\\] /
if listobj
- tk_split_escstr(val).collect{|elt|
- tk_tcl2ruby(elt, enc_mode, listobj)
- }
+ tk_split_escstr(val).collect{|elt|
+ tk_tcl2ruby(elt, enc_mode, listobj)
+ }
elsif enc_mode
- _fromUTF8(val)
+ _fromUTF8(val)
else
- val
+ val
end
else
if enc_mode
- _fromUTF8(val)
+ _fromUTF8(val)
else
- val
+ val
end
end
end
@@ -288,14 +288,14 @@ if USE_TCLs_LIST_FUNCTIONS
dst = ary.collect{|e|
if e.kind_of? Array
- array2tk_list(e)
+ array2tk_list(e)
elsif e.kind_of? Hash
- tmp_ary = []
- #e.each{|k,v| tmp_ary << k << v }
- e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
- array2tk_list(tmp_ary)
+ tmp_ary = []
+ #e.each{|k,v| tmp_ary << k << v }
+ e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
+ array2tk_list(tmp_ary)
else
- _get_eval_string(e)
+ _get_eval_string(e)
end
}
TkCore::INTERP._merge_tklist(*dst)
@@ -402,7 +402,7 @@ else
if c == '\\' && !escape
escape = true
token = (token || "") << c if brace > 0
- next
+ next
end
brace += 1 if c == '{' && !escape
brace -= 1 if c == '}' && !escape
@@ -421,14 +421,14 @@ else
def array2tk_list(ary)
ary.collect{|e|
if e.kind_of? Array
- "{#{array2tk_list(e)}}"
+ "{#{array2tk_list(e)}}"
elsif e.kind_of? Hash
- # "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}"
- e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
- array2tk_list(tmp_ary)
+ # "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}"
+ e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
+ array2tk_list(tmp_ary)
else
- s = _get_eval_string(e)
- (s.index(/\s/) || s.size == 0)? "{#{s}}": s
+ s = _get_eval_string(e)
+ (s.index(/\s/) || s.size == 0)? "{#{s}}": s
end
}.join(" ")
end
@@ -466,13 +466,13 @@ end
dst = []
if keys and keys != None
keys.each{|k, v|
- #dst.push("-#{k}")
- dst.push('-' + k.to_s)
- if v != None
- # v = _get_eval_string(v, enc_mode) if (enc_mode || flat)
- v = _get_eval_string(v, enc_mode) if enc_mode
- dst.push(v)
- end
+ #dst.push("-#{k}")
+ dst.push('-' + k.to_s)
+ if v != None
+ # v = _get_eval_string(v, enc_mode) if (enc_mode || flat)
+ v = _get_eval_string(v, enc_mode) if enc_mode
+ dst.push(v)
+ end
}
end
if conf
@@ -600,7 +600,7 @@ end
else
str = str.to_s() || ''
unless str.kind_of? String
- fail RuntimeError, "fail to convert the object to a string"
+ fail RuntimeError, "fail to convert the object to a string"
end
str = _toUTF8(str) if enc_mode
end
@@ -634,14 +634,14 @@ end
nil
else
if (obj.respond_to?(:to_eval))
- (enc_mode)? _toUTF8(obj.to_eval): obj.to_eval
+ (enc_mode)? _toUTF8(obj.to_eval): obj.to_eval
else
- begin
- obj = obj.to_s || ''
- rescue
- fail RuntimeError, "fail to convert object '#{obj}' to string"
- end
- (enc_mode)? _toUTF8(obj): obj
+ begin
+ obj = obj.to_s || ''
+ rescue
+ fail RuntimeError, "fail to convert object '#{obj}' to string"
+ end
+ (enc_mode)? _toUTF8(obj): obj
end
end
end
@@ -751,12 +751,12 @@ end
def install_win(ppath,name=nil)
if name
if name == ''
- raise ArgumentError, "invalid wiget-name '#{name}'"
+ raise ArgumentError, "invalid wiget-name '#{name}'"
end
if name[0] == ?.
- @path = '' + name
- @path.freeze
- return TkCore::INTERP.tk_windows[@path] = self
+ @path = '' + name
+ @path.freeze
+ return TkCore::INTERP.tk_windows[@path] = self
end
else
name = "w" + TkCore::INTERP._ip_id_ + Tk_IDs[1]
@@ -800,11 +800,11 @@ module TkComm
end
if context.kind_of? Array
context = context.collect{|ev|
- if ev.kind_of? TkVirtualEvent
- ev.path
- else
- ev
- end
+ if ev.kind_of? TkVirtualEvent
+ ev.path
+ else
+ ev
+ end
}.join("><")
end
if /,/ =~ context
@@ -818,7 +818,7 @@ module TkComm
id = install_bind(cmd, args) if cmd
begin
tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>",
- mode + id]))
+ mode + id]))
rescue
uninstall_cmd(id) if cmd
fail
@@ -840,26 +840,26 @@ module TkComm
def _bindinfo(what, context=nil)
if context
tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"]) .collect {|cmdline|
- if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/
- #[Tk_CMDTBL[$1], $2]
- [TkCore::INTERP.tk_cmd_tbl[$1], $2]
- else
- cmdline
- end
+ if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/
+ #[Tk_CMDTBL[$1], $2]
+ [TkCore::INTERP.tk_cmd_tbl[$1], $2]
+ else
+ cmdline
+ end
}
else
tk_split_simplelist(tk_call_without_enc(*what)).collect!{|seq|
- l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
- case (subseq)
- when /^<<[^<>]+>>$/
- TkVirtualEvent.getobj(subseq[1..-2])
- when /^<[^<>]+>$/
- subseq[1..-2]
- else
- subseq.split('')
- end
- }.flatten
- (l.size == 1) ? l[0] : l
+ l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
+ case (subseq)
+ when /^<<[^<>]+>>$/
+ TkVirtualEvent.getobj(subseq[1..-2])
+ when /^<[^<>]+>$/
+ subseq[1..-2]
+ else
+ subseq.split('')
+ end
+ }.flatten
+ (l.size == 1) ? l[0] : l
}
end
end
@@ -868,7 +868,7 @@ module TkComm
id = install_bind_for_event_class(klass, cmd, args) if cmd
begin
tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>",
- mode + id]))
+ mode + id]))
rescue
uninstall_cmd(id) if cmd
fail
@@ -950,9 +950,9 @@ module TkCore
end
if self.const_defined? :IP_OPTS
if IP_OPTS.kind_of?(Hash)
- opts = hash_kv(IP_OPTS).join(' ')
+ opts = hash_kv(IP_OPTS).join(' ')
else
- opts = IP_OPTS.to_s
+ opts = IP_OPTS.to_s
end
else
opts = ''
@@ -974,25 +974,25 @@ module TkCore
@add_tk_procs = [].taint # table of [name, args, body]
@cb_entry_class = Class.new(TkCallbackEntry){|c|
- class << c
- def inspect
- sprintf("#<Class(TkCallbackEntry):%0x>", self.__id__)
- end
- alias to_s inspect
- end
-
- def initialize(ip, cmd)
- @ip = ip
- @cmd = cmd
- end
- attr_reader :ip, :cmd
- def call(*args)
- @ip.cb_eval(@cmd, *args)
- end
- def inspect
- sprintf("#<cb_entry:%0x>", self.__id__)
- end
- alias to_s inspect
+ class << c
+ def inspect
+ sprintf("#<Class(TkCallbackEntry):%0x>", self.__id__)
+ end
+ alias to_s inspect
+ end
+
+ def initialize(ip, cmd)
+ @ip = ip
+ @cmd = cmd
+ end
+ attr_reader :ip, :cmd
+ def call(*args)
+ @ip.cb_eval(@cmd, *args)
+ end
+ def inspect
+ sprintf("#<cb_entry:%0x>", self.__id__)
+ end
+ alias to_s inspect
}.freeze
}
@@ -1008,10 +1008,10 @@ module TkCore
class Tk_OBJECT_TABLE
def initialize(id)
- @id = id
+ @id = id
end
def method_missing(m, *args, &b)
- TkCore::INTERP.tk_object_table(@id).__send__(m, *args, &b)
+ TkCore::INTERP.tk_object_table(@id).__send__(m, *args, &b)
end
end
@@ -1025,7 +1025,7 @@ module TkCore
# obj = Object.new
# obj.instance_eval <<-EOD
# def self.method_missing(m, *args)
-# TkCore::INTERP.tk_object_table(#{id}).send(m, *args)
+# TkCore::INTERP.tk_object_table(#{id}).send(m, *args)
# end
# EOD
# return obj
@@ -1056,23 +1056,23 @@ module TkCore
WIDGET_DESTROY_HOOK = '<WIDGET_DESTROY_HOOK>'
INTERP._invoke_without_enc('event', 'add',
- "<#{WIDGET_DESTROY_HOOK}>", 'Destroy')
+ "<#{WIDGET_DESTROY_HOOK}>", 'Destroy')
INTERP._invoke_without_enc('bind', 'all', "<#{WIDGET_DESTROY_HOOK}>",
- install_bind(proc{|xpath|
- path = xpath[1..-1]
- unless TkCore::INTERP.deleted?
- if (widget = TkCore::INTERP.tk_windows[path])
- if widget.respond_to?(:__destroy_hook__)
- begin
- widget.__destroy_hook__
- rescue Exception
- end
- end
- end
- end
- }, 'x%W'))
+ install_bind(proc{|xpath|
+ path = xpath[1..-1]
+ unless TkCore::INTERP.deleted?
+ if (widget = TkCore::INTERP.tk_windows[path])
+ if widget.respond_to?(:__destroy_hook__)
+ begin
+ widget.__destroy_hook__
+ rescue Exception
+ end
+ end
+ end
+ end
+ }, 'x%W'))
INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '',
- "bind all <#{WIDGET_DESTROY_HOOK}> {}")
+ "bind all <#{WIDGET_DESTROY_HOOK}> {}")
INTERP.add_tk_procs('rb_out', 'args', <<-'EOL')
if {[set st [catch {eval {ruby_cmd TkCore callback} $args} ret]] != 0} {
@@ -1087,7 +1087,7 @@ module TkCore
return -code $st $ret
}
} else {
- return $ret
+ return $ret
}
EOL
=begin
@@ -1108,7 +1108,7 @@ module TkCore
return -code $st $ret
}
} else {
- return $ret
+ return $ret
}
EOL
=end
@@ -1132,17 +1132,17 @@ module TkCore
exit!(1)
rescue Exception => e
begin
- msg = _toUTF8(e.class.inspect) + ': ' +
- _toUTF8(e.message) + "\n" +
- "\n---< backtrace of Ruby side >-----\n" +
- _toUTF8(e.backtrace.join("\n")) +
- "\n---< backtrace of Tk side >-------"
- msg.instance_variable_set(:@encoding, 'utf-8')
+ msg = _toUTF8(e.class.inspect) + ': ' +
+ _toUTF8(e.message) + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ _toUTF8(e.backtrace.join("\n")) +
+ "\n---< backtrace of Tk side >-------"
+ msg.instance_variable_set(:@encoding, 'utf-8')
rescue Exception
- msg = e.class.inspect + ': ' + e.message + "\n" +
- "\n---< backtrace of Ruby side >-----\n" +
- e.backtrace.join("\n") +
- "\n---< backtrace of Tk side >-------"
+ msg = e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------"
end
fail(e, msg)
end
@@ -1153,7 +1153,7 @@ module TkCore
arg = tk_split_simplelist(arg_str)
#_get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg))
#_get_eval_string(TkUtil.eval_cmd(TkCore::INTERP.tk_cmd_tbl[arg.shift],
- # *arg))
+ # *arg))
# TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
begin
TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
@@ -1169,17 +1169,17 @@ module TkCore
# cb_obj.call(*arg)
# else
# begin
-# raise 'check backtrace'
+# raise 'check backtrace'
# rescue
-# # ignore backtrace before 'callback'
-# pos = -($!.backtrace.size)
+# # ignore backtrace before 'callback'
+# pos = -($!.backtrace.size)
# end
# begin
-# cb_obj.call(*arg)
+# cb_obj.call(*arg)
# rescue
-# trace = $!.backtrace
-# raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" +
-# "\tfrom #{trace[1..pos].join("\n\tfrom ")}"
+# trace = $!.backtrace
+# raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" +
+# "\tfrom #{trace[1..pos].join("\n\tfrom ")}"
# end
# end
#=end
@@ -1203,10 +1203,10 @@ module TkCore
# return
# if false #defined? Thread
# Thread.start do
-# ms = Float(ms)/1000
-# ms = 10 if ms == 0
-# sleep ms/1000
-# cmd.call
+# ms = Float(ms)/1000
+# ms = 10 if ms == 0
+# sleep ms/1000
+# cmd.call
# end
# else
# cmdid = install_cmd(cmd)
@@ -1383,11 +1383,11 @@ module TkCore
#window = window.path if window.kind_of?(TkObject)
if keys
tk_call_without_enc('event', 'generate', window,
- "<#{tk_event_sequence(context)}>",
- *hash_kv(keys, true))
+ "<#{tk_event_sequence(context)}>",
+ *hash_kv(keys, true))
else
tk_call_without_enc('event', 'generate', window,
- "<#{tk_event_sequence(context)}>")
+ "<#{tk_event_sequence(context)}>")
end
nil
end
@@ -1488,10 +1488,10 @@ module TkCore
#res = INTERP._invoke(*args).taint
#res = INTERP._invoke(enc_mode, *args)
res = _ip_invoke_core(enc_mode, *args)
- # >>>>> _invoke returns a TAINTED string <<<<<
+ # >>>>> _invoke returns a TAINTED string <<<<<
rescue StandardError => err2
- fail err2 unless /^invalid command/ =~ err2.message
- fail err
+ fail err2 unless /^invalid command/ =~ err2.message
+ fail err
end
end
if INTERP._return_value() != 0
@@ -1535,7 +1535,7 @@ module Tk
TK_MINOR_VERSION = minor.to_i
JAPANIZED_TK = (INTERP._invoke_without_enc("info", "commands",
- "kanji") != "").freeze
+ "kanji") != "").freeze
def Tk.const_missing(sym)
case(sym)
@@ -1560,11 +1560,11 @@ module Tk
when :PLATFORM, :TCL_PLATFORM
if $SAFE >= 4
- fail SecurityError, "can't get #{sym} when $SAFE >= 4"
+ fail SecurityError, "can't get #{sym} when $SAFE >= 4"
end
INTERP._invoke_without_enc('global', 'tcl_platform')
Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get',
- 'tcl_platform'))]
+ 'tcl_platform'))]
when :ENV
INTERP._invoke_without_enc('global', 'env')
@@ -1583,22 +1583,22 @@ module Tk
when :PRIV, :PRIVATE, :TK_PRIV
priv = {}
if INTERP._invoke_without_enc('info', 'vars', 'tk::Priv') != ""
- var_nam = 'tk::Priv'
+ var_nam = 'tk::Priv'
else
- var_nam = 'tkPriv'
+ var_nam = 'tkPriv'
end
INTERP._invoke_without_enc('global', var_nam)
Hash[*tk_split_simplelist(INTERP._invoke('array', 'get',
- var_nam))].each{|k,v|
- k.freeze
- case v
- when /^-?\d+$/
- priv[k] = v.to_i
- when /^-?\d+\.?\d*(e[-+]?\d+)?$/
- priv[k] = v.to_f
- else
- priv[k] = v.freeze
- end
+ var_nam))].each{|k,v|
+ k.freeze
+ case v
+ when /^-?\d+$/
+ priv[k] = v.to_i
+ when /^-?\d+\.?\d*(e[-+]?\d+)?$/
+ priv[k] = v.to_f
+ else
+ priv[k] = v.freeze
+ end
}
priv
@@ -1618,8 +1618,8 @@ module Tk
case code[0]
when 'CHILDKILLED', 'CHILDSTATUS', 'CHILDSUSP'
begin
- pid = Integer(code[1])
- code[1] = pid
+ pid = Integer(code[1])
+ code[1] = pid
rescue
end
end
@@ -1840,45 +1840,45 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
def _toUTF8(str, encoding = nil)
# decide encoding
if encoding
- encoding = encoding.to_s
+ encoding = encoding.to_s
elsif str.kind_of?(Tk::EncodedString) && str.encoding != nil
- encoding = str.encoding.to_s
+ encoding = str.encoding.to_s
elsif str.instance_variable_get(:@encoding)
- encoding = str.instance_variable_get(:@encoding).to_s
+ encoding = str.instance_variable_get(:@encoding).to_s
elsif defined?(@encoding) && @encoding != nil
- encoding = @encoding.to_s
+ encoding = @encoding.to_s
else
- encoding = __invoke('encoding', 'system')
+ encoding = __invoke('encoding', 'system')
end
# convert
case encoding
when 'utf-8', 'binary'
- str
+ str
else
- __toUTF8(str, encoding)
+ __toUTF8(str, encoding)
end
end
def _fromUTF8(str, encoding = nil)
unless encoding
- if defined?(@encoding) && @encoding != nil
- encoding = @encoding.to_s
- else
- encoding = __invoke('encoding', 'system')
- end
+ if defined?(@encoding) && @encoding != nil
+ encoding = @encoding.to_s
+ else
+ encoding = __invoke('encoding', 'system')
+ end
end
if str.kind_of?(Tk::EncodedString)
- if str.encoding == 'binary'
- str
- else
- __fromUTF8(str, encoding)
- end
+ if str.encoding == 'binary'
+ str
+ else
+ __fromUTF8(str, encoding)
+ end
elsif str.instance_variable_get(:@encoding).to_s == 'binary'
- str
+ str
else
- __fromUTF8(str, encoding)
+ __fromUTF8(str, encoding)
end
end
=end
@@ -1897,53 +1897,53 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
=begin
def _eval(cmd)
if defined?(@encoding) && @encoding != 'utf-8'
- ret = if cmd.kind_of?(Tk::EncodedString)
- case cmd.encoding
- when 'utf-8', 'binary'
- __eval(cmd)
- else
- __eval(_toUTF8(cmd, cmd.encoding))
- end
- elsif cmd.instance_variable_get(:@encoding) == 'binary'
- __eval(cmd)
- else
- __eval(_toUTF8(cmd, @encoding))
- end
- if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary'
- ret
- else
- _fromUTF8(ret, @encoding)
- end
+ ret = if cmd.kind_of?(Tk::EncodedString)
+ case cmd.encoding
+ when 'utf-8', 'binary'
+ __eval(cmd)
+ else
+ __eval(_toUTF8(cmd, cmd.encoding))
+ end
+ elsif cmd.instance_variable_get(:@encoding) == 'binary'
+ __eval(cmd)
+ else
+ __eval(_toUTF8(cmd, @encoding))
+ end
+ if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary'
+ ret
+ else
+ _fromUTF8(ret, @encoding)
+ end
else
- __eval(cmd)
+ __eval(cmd)
end
end
def _invoke(*cmds)
if defined?(@encoding) && @encoding != 'utf-8'
- cmds = cmds.collect{|cmd|
- if cmd.kind_of?(Tk::EncodedString)
- case cmd.encoding
- when 'utf-8', 'binary'
- cmd
- else
- _toUTF8(cmd, cmd.encoding)
- end
- elsif cmd.instance_variable_get(:@encoding) == 'binary'
- cmd
- else
- _toUTF8(cmd, @encoding)
- end
- }
- ret = __invoke(*cmds)
- if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary'
- ret
- else
- _fromUTF8(ret, @encoding)
- end
+ cmds = cmds.collect{|cmd|
+ if cmd.kind_of?(Tk::EncodedString)
+ case cmd.encoding
+ when 'utf-8', 'binary'
+ cmd
+ else
+ _toUTF8(cmd, cmd.encoding)
+ end
+ elsif cmd.instance_variable_get(:@encoding) == 'binary'
+ cmd
+ else
+ _toUTF8(cmd, @encoding)
+ end
+ }
+ ret = __invoke(*cmds)
+ if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary'
+ ret
+ else
+ _fromUTF8(ret, @encoding)
+ end
else
- __invoke(*cmds)
- end
+ __invoke(*cmds)
+ end
end
=end
end
@@ -1955,39 +1955,39 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
TkCommandNames = ['encoding'.freeze].freeze
def encoding=(name)
- TkCore::INTERP.encoding = name
+ TkCore::INTERP.encoding = name
end
def encoding
- TkCore::INTERP.encoding
+ TkCore::INTERP.encoding
end
def encoding_names
- tk_split_simplelist(tk_call('encoding', 'names'))
+ tk_split_simplelist(tk_call('encoding', 'names'))
end
def encoding_system
- tk_call('encoding', 'system')
+ tk_call('encoding', 'system')
end
def encoding_system=(enc)
- tk_call('encoding', 'system', enc)
+ tk_call('encoding', 'system', enc)
end
def encoding_convertfrom(str, enc=nil)
- # str must be a Tcl's internal string expression in enc.
- # the return value is a UTF-8 string.
- enc = encoding_system unless enc
- TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str)
+ # str must be a Tcl's internal string expression in enc.
+ # the return value is a UTF-8 string.
+ enc = encoding_system unless enc
+ TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str)
end
alias encoding_convert_from encoding_convertfrom
def encoding_convertto(str, enc=nil)
- # str must be a UTF-8 string.
- # The return value is a Tcl's internal string expression in enc.
+ # str must be a UTF-8 string.
+ # The return value is a Tcl's internal string expression in enc.
# To get an usual enc string, use Tk.fromUTF8(ret_val, enc).
- enc = encoding_system unless enc
- TkCore::INTERP.__invoke('encoding', 'convertto', enc, str)
+ enc = encoding_system unless enc
+ TkCore::INTERP.__invoke('encoding', 'convertto', enc, str)
end
alias encoding_convert_to encoding_convertto
end
@@ -2026,28 +2026,28 @@ else
extend Encoding
def encoding=(name)
- nil
+ nil
end
def encoding
- nil
+ nil
end
def encoding_names
- nil
+ nil
end
def encoding_system
- nil
+ nil
end
def encoding_system=(enc)
- nil
+ nil
end
def encoding_convertfrom(str, enc=None)
- str
+ str
end
alias encoding_convert_from encoding_convertfrom
def encoding_convertto(str, enc=None)
- str
+ str
end
alias encoding_convert_to encoding_convertto
end
@@ -2098,19 +2098,19 @@ module TkTreatFont
if key
pathname = [win, tag, key].join(';')
TkFont.used_on(pathname) ||
- TkFont.init_widget_font(pathname, *__config_cmd)
+ TkFont.init_widget_font(pathname, *__config_cmd)
elsif optkeys.size == 1
pathname = [win, tag, optkeys[0]].join(';')
TkFont.used_on(pathname) ||
- TkFont.init_widget_font(pathname, *__config_cmd)
+ TkFont.init_widget_font(pathname, *__config_cmd)
else
fonts = {}
optkeys.each{|key|
- key = key.to_s
- pathname = [win, tag, key].join(';')
- fonts[key] =
- TkFont.used_on(pathname) ||
- TkFont.init_widget_font(pathname, *__config_cmd)
+ key = key.to_s
+ pathname = [win, tag, key].join(';')
+ fonts[key] =
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname, *__config_cmd)
}
fonts
end
@@ -2129,38 +2129,38 @@ module TkTreatFont
k_optkey = 'kanji' << optkey
if slot.key?(optkey)
- fnt = slot.delete(optkey)
- if fnt.kind_of?(TkFont)
- slot.delete(l_optkey)
- slot.delete(a_optkey)
- slot.delete(k_optkey)
-
- fnt.call_font_configure([pathname, optkey], *(__config_cmd << {}))
- next
- else
- if fnt
- if (slot.key?(l_optkey) ||
- slot.key?(a_optkey) ||
- slot.key?(k_optkey))
- fnt = TkFont.new(fnt)
-
- lfnt = slot.delete(l_optkey)
- lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
- kfnt = slot.delete(k_optkey)
-
- fnt.latin_replace(lfnt) if lfnt
- fnt.kanji_replace(kfnt) if kfnt
-
- fnt.call_font_configure([pathname, optkey],
- *(__config_cmd << {}))
- next
- else
- fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
- tk_call(*(__config_cmd << "-#{optkey}" << fnt))
- end
- end
- next
- end
+ fnt = slot.delete(optkey)
+ if fnt.kind_of?(TkFont)
+ slot.delete(l_optkey)
+ slot.delete(a_optkey)
+ slot.delete(k_optkey)
+
+ fnt.call_font_configure([pathname, optkey], *(__config_cmd << {}))
+ next
+ else
+ if fnt
+ if (slot.key?(l_optkey) ||
+ slot.key?(a_optkey) ||
+ slot.key?(k_optkey))
+ fnt = TkFont.new(fnt)
+
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ fnt.latin_replace(lfnt) if lfnt
+ fnt.kanji_replace(kfnt) if kfnt
+
+ fnt.call_font_configure([pathname, optkey],
+ *(__config_cmd << {}))
+ next
+ else
+ fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
+ tk_call(*(__config_cmd << "-#{optkey}" << fnt))
+ end
+ end
+ next
+ end
end
lfnt = slot.delete(l_optkey)
@@ -2168,12 +2168,12 @@ module TkTreatFont
kfnt = slot.delete(k_optkey)
if lfnt && kfnt
- TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
- *(__config_cmd << {}))
+ TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
+ *(__config_cmd << {}))
elsif lfnt
- latinfont_configure([lfnt, optkey])
+ latinfont_configure([lfnt, optkey])
elsif kfnt
- kanjifont_configure([kfnt, optkey])
+ kanjifont_configure([kfnt, optkey])
end
}
@@ -2205,27 +2205,27 @@ module TkTreatFont
pathname = [win, tag, optkey].join(';')
if (fobj = TkFont.used_on(pathname))
- fobj = TkFont.new(fobj) # create a new TkFont object
+ fobj = TkFont.new(fobj) # create a new TkFont object
elsif Tk::JAPANIZED_TK
- fobj = fontobj # create a new TkFont object
+ fobj = fontobj # create a new TkFont object
else
- ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
- tk_call(*(__config_cmd << "-#{optkey}" << ltn))
- next
+ ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
+ tk_call(*(__config_cmd << "-#{optkey}" << ltn))
+ next
end
if fobj.kind_of?(TkFont)
- if ltn.kind_of?(TkFont)
- conf = {}
- ltn.latin_configinfo.each{|key,val| conf[key] = val}
- if keys
- fobj.latin_configure(conf.update(keys))
- else
- fobj.latin_configure(conf)
- end
- else
- fobj.latin_replace(ltn)
- end
+ if ltn.kind_of?(TkFont)
+ conf = {}
+ ltn.latin_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.latin_configure(conf.update(keys))
+ else
+ fobj.latin_configure(conf)
+ end
+ else
+ fobj.latin_replace(ltn)
+ end
end
fobj.call_font_configure([pathname, optkey], *(__config_cmd << {}))
@@ -2257,27 +2257,27 @@ module TkTreatFont
pathname = [win, tag, optkey].join(';')
if (fobj = TkFont.used_on(pathname))
- fobj = TkFont.new(fobj) # create a new TkFont object
+ fobj = TkFont.new(fobj) # create a new TkFont object
elsif Tk::JAPANIZED_TK
- fobj = fontobj # create a new TkFont object
+ fobj = fontobj # create a new TkFont object
else
- knj = hash_kv(knj) if knj.kind_of?(Hash)
- tk_call(*(__config_cmd << "-#{optkey}" << knj))
- next
+ knj = hash_kv(knj) if knj.kind_of?(Hash)
+ tk_call(*(__config_cmd << "-#{optkey}" << knj))
+ next
end
if fobj.kind_of?(TkFont)
- if knj.kind_of?(TkFont)
- conf = {}
- knj.kanji_configinfo.each{|key,val| conf[key] = val}
- if keys
- fobj.kanji_configure(conf.update(keys))
- else
- fobj.kanji_configure(conf)
- end
- else
- fobj.kanji_replace(knj)
- end
+ if knj.kind_of?(TkFont)
+ conf = {}
+ knj.kanji_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.kanji_configure(conf.update(keys))
+ else
+ fobj.kanji_configure(conf)
+ end
+ else
+ fobj.kanji_replace(knj)
+ end
end
fobj.call_font_configure([pathname, optkey], *(__config_cmd << {}))
@@ -2288,15 +2288,15 @@ module TkTreatFont
def font_copy(window, wintag=nil, winkey=nil, targetkey=nil)
if wintag
if winkey
- fnt = window.tagfontobj(wintag, winkey).dup
+ fnt = window.tagfontobj(wintag, winkey).dup
else
- fnt = window.tagfontobj(wintag).dup
+ fnt = window.tagfontobj(wintag).dup
end
else
if winkey
- fnt = window.fontobj(winkey).dup
+ fnt = window.fontobj(winkey).dup
else
- fnt = window.fontobj.dup
+ fnt = window.fontobj.dup
end
end
@@ -2311,22 +2311,22 @@ module TkTreatFont
def latinfont_copy(window, wintag=nil, winkey=nil, targetkey=nil)
if targetkey
fontobj(targetkey).dup.call_font_configure([__pathname, targetkey],
- *(__config_cmd << {}))
+ *(__config_cmd << {}))
else
fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {}))
end
if wintag
if winkey
- fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
+ fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
else
- fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
+ fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
end
else
if winkey
- fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
+ fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
else
- fontobj.latin_replace(window.fontobj.latin_font_id)
+ fontobj.latin_replace(window.fontobj.latin_font_id)
end
end
self
@@ -2336,22 +2336,22 @@ module TkTreatFont
def kanjifont_copy(window, wintag=nil, winkey=nil, targetkey=nil)
if targetkey
fontobj(targetkey).dup.call_font_configure([__pathname, targetkey],
- *(__config_cmd << {}))
+ *(__config_cmd << {}))
else
- fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {}))
+ fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {}))
end
if wintag
if winkey
- fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
+ fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
else
- fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
+ fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
end
else
if winkey
- fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
+ fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
else
- fontobj.kanji_replace(window.fontobj.kanji_font_id)
+ fontobj.kanji_replace(window.fontobj.kanji_font_id)
end
end
self
@@ -2426,16 +2426,16 @@ module TkConfigMethod
keys.each{|k, v|
optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s}
if optkey
- defkey, undefkey = optkey
- if v
- keys2[defkey.to_s] = None
- elsif undefkey
- keys2[undefkey.to_s] = None
- else
- # remove key
- end
+ defkey, undefkey = optkey
+ if v
+ keys2[defkey.to_s] = None
+ elsif undefkey
+ keys2[undefkey.to_s] = None
+ else
+ # remove key
+ end
else
- keys2[k.to_s] = v
+ keys2[k.to_s] = v
end
}
keys2
@@ -2466,9 +2466,9 @@ module TkConfigMethod
case slot
when /^(#{__numval_optkeys.join('|')})$/
begin
- number(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
+ number(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
rescue
- nil
+ nil
end
when /^(#{__numstrval_optkeys.join('|')})$/
@@ -2476,9 +2476,9 @@ module TkConfigMethod
when /^(#{__boolval_optkeys.join('|')})$/
begin
- bool(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
+ bool(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
rescue
- nil
+ nil
end
when /^(#{__listval_optkeys.join('|')})$/
@@ -2487,9 +2487,9 @@ module TkConfigMethod
when /^(#{__numlistval_optkeys.join('|')})$/
conf = tk_call_without_enc(*(__cget_cmd << "-#{slot}"))
if conf =~ /^[0-9+-]/
- list(conf)
+ list(conf)
else
- conf
+ conf
end
when /^(#{__strval_optkeys.join('|')})$/
@@ -2500,13 +2500,13 @@ module TkConfigMethod
fontkey = $2
fnt = tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{fontkey}")), true)
unless fnt.kind_of?(TkFont)
- fnt = fontobj(fontkey)
+ fnt = fontobj(fontkey)
end
if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
- # obsolete; just for compatibility
- fnt.kanji_font
+ # obsolete; just for compatibility
+ fnt.kanji_font
else
- fnt
+ fnt
end
else
@@ -2519,48 +2519,48 @@ module TkConfigMethod
slot = _symbolkey2str(slot)
__methodcall_optkeys.each{|key, method|
- value = slot.delete(key.to_s)
- self.__send__(method, value) if value
+ value = slot.delete(key.to_s)
+ self.__send__(method, value) if value
}
__keyonly_optkeys.each{|defkey, undefkey|
- conf = slot.find{|kk, vv| kk == defkey.to_s}
- if conf
- k, v = conf
- if v
- slot[k] = None
- else
- slot[undefkey.to_s] = None if undefkey
- slot.delete(k)
- end
- end
+ conf = slot.find{|kk, vv| kk == defkey.to_s}
+ if conf
+ k, v = conf
+ if v
+ slot[k] = None
+ else
+ slot[undefkey.to_s] = None if undefkey
+ slot.delete(k)
+ end
+ end
}
if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/})
- font_configure(slot)
+ font_configure(slot)
elsif slot.size > 0
- tk_call(*(__config_cmd.concat(hash_kv(slot))))
+ tk_call(*(__config_cmd.concat(hash_kv(slot))))
end
else
slot = slot.to_s
if ( conf = __keyonly_optkeys.find{|k, v| k.to_s == slot} )
- defkey, undefkey = conf
- if value
- tk_call(*(__config_cmd << "-#{defkey}"))
- elsif undefkey
- tk_call(*(__config_cmd << "-#{undefkey}"))
- end
+ defkey, undefkey = conf
+ if value
+ tk_call(*(__config_cmd << "-#{defkey}"))
+ elsif undefkey
+ tk_call(*(__config_cmd << "-#{undefkey}"))
+ end
elsif ( method = _symbolkey2str(__methodcall_optkeys)[slot] )
- self.__send__(method, value)
+ self.__send__(method, value)
elsif (slot =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
- if value == None
- fontobj($2)
- else
- font_configure({slot=>value})
- end
+ if value == None
+ fontobj($2)
+ else
+ font_configure({slot=>value})
+ end
else
- tk_call(*(__config_cmd << "-#{slot}" << value))
+ tk_call(*(__config_cmd << "-#{slot}" << value))
end
end
self
@@ -2573,529 +2573,529 @@ module TkConfigMethod
def configinfo(slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
- fontkey = $2
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}"))))
- conf[__configinfo_struct[:key]] =
- conf[__configinfo_struct[:key]][1..-1]
- if ( ! __configinfo_struct[:alias] \
- || conf.size > __configinfo_struct[:alias] + 1 )
- conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
- elsif ( __configinfo_struct[:alias] \
- && conf.size == __configinfo_struct[:alias] + 1 \
- && conf[__configinfo_struct[:alias]][0] == ?- )
- conf[__configinfo_struct[:alias]] =
- conf[__configinfo_struct[:alias]][1..-1]
- end
- conf
+ fontkey = $2
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}"))))
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
+ elsif ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 \
+ && conf[__configinfo_struct[:alias]][0] == ?- )
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ conf
else
- if slot
- slot = slot.to_s
- case slot
- when /^(#{__methodcall_optkeys.keys.join('|')})$/
- method = _symbolkey2str(__methodcall_optkeys)[slot]
- return [slot, '', '', '', self.__send__(method)]
-
- when /^(#{__numval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]])
- begin
- conf[__configinfo_struct[:default_value]] =
- number(conf[__configinfo_struct[:default_value]])
- rescue
- conf[__configinfo_struct[:default_value]] = nil
- end
- end
- if ( conf[__configinfo_struct[:current_value]] )
- begin
- conf[__configinfo_struct[:current_value]] =
- number(conf[__configinfo_struct[:current_value]])
- rescue
- conf[__configinfo_struct[:current_value]] = nil
- end
- end
-
- when /^(#{__numstrval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]])
- conf[__configinfo_struct[:default_value]] =
- num_or_str(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] )
- conf[__configinfo_struct[:current_value]] =
- num_or_str(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__boolval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]])
- begin
- conf[__configinfo_struct[:default_value]] =
- bool(conf[__configinfo_struct[:default_value]])
- rescue
- conf[__configinfo_struct[:default_value]] = nil
- end
- end
- if ( conf[__configinfo_struct[:current_value]] )
- begin
- conf[__configinfo_struct[:current_value]] =
- bool(conf[__configinfo_struct[:current_value]])
- rescue
- conf[__configinfo_struct[:current_value]] = nil
- end
- end
-
- when /^(#{__listval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]])
- conf[__configinfo_struct[:default_value]] =
- simplelist(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] )
- conf[__configinfo_struct[:current_value]] =
- simplelist(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__numlistval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] \
- && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
- conf[__configinfo_struct[:default_value]] =
- list(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] \
- && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
- conf[__configinfo_struct[:current_value]] =
- list(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__strval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
- else
- conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
- end
- conf[__configinfo_struct[:key]] =
- conf[__configinfo_struct[:key]][1..-1]
-
- if ( __configinfo_struct[:alias] \
- && conf.size == __configinfo_struct[:alias] + 1 \
- && conf[__configinfo_struct[:alias]][0] == ?- )
- conf[__configinfo_struct[:alias]] =
- conf[__configinfo_struct[:alias]][1..-1]
- end
-
- conf
-
- else
- ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[__configinfo_struct[:key]] =
- conf[__configinfo_struct[:key]][1..-1]
-
- case conf[__configinfo_struct[:key]]
- when /^(#{__strval_optkeys.join('|')})$/
- # do nothing
-
- when /^(#{__numval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- begin
- conf[__configinfo_struct[:default_value]] =
- number(conf[__configinfo_struct[:default_value]])
- rescue
- conf[__configinfo_struct[:default_value]] = nil
- end
- end
- if ( conf[__configinfo_struct[:current_value]] )
- begin
- conf[__configinfo_struct[:current_value]] =
- number(conf[__configinfo_struct[:current_value]])
- rescue
- conf[__configinfo_struct[:current_value]] = nil
- end
- end
-
- when /^(#{__numstrval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- conf[__configinfo_struct[:default_value]] =
- num_or_str(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] )
- conf[__configinfo_struct[:current_value]] =
- num_or_str(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__boolval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- begin
- conf[__configinfo_struct[:default_value]] =
- bool(conf[__configinfo_struct[:default_value]])
- rescue
- conf[__configinfo_struct[:default_value]] = nil
- end
- end
- if ( conf[__configinfo_struct[:current_value]] )
- begin
- conf[__configinfo_struct[:current_value]] =
- bool(conf[__configinfo_struct[:current_value]])
- rescue
- conf[__configinfo_struct[:current_value]] = nil
- end
- end
-
- when /^(#{__listval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- conf[__configinfo_struct[:default_value]] =
- simplelist(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] )
- conf[__configinfo_struct[:current_value]] =
- simplelist(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__numlistval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] \
- && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
- conf[__configinfo_struct[:default_value]] =
- list(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] \
- && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
- conf[__configinfo_struct[:current_value]] =
- list(conf[__configinfo_struct[:current_value]])
- end
-
- else
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- if conf[__configinfo_struct[:default_value]].index('{')
- conf[__configinfo_struct[:default_value]] =
- tk_split_list(conf[__configinfo_struct[:default_value]])
- else
- conf[__configinfo_struct[:default_value]] =
- tk_tcl2ruby(conf[__configinfo_struct[:default_value]])
- end
- end
- if conf[__configinfo_struct[:current_value]]
- if conf[__configinfo_struct[:current_value]].index('{')
- conf[__configinfo_struct[:current_value]] =
- tk_split_list(conf[__configinfo_struct[:current_value]])
- else
- conf[__configinfo_struct[:current_value]] =
- tk_tcl2ruby(conf[__configinfo_struct[:current_value]])
- end
- end
- end
-
- if ( __configinfo_struct[:alias] \
- && conf.size == __configinfo_struct[:alias] + 1 \
- && conf[__configinfo_struct[:alias]][0] == ?- )
- conf[__configinfo_struct[:alias]] =
- conf[__configinfo_struct[:alias]][1..-1]
- end
-
- conf
- }
-
- __font_optkeys.each{|optkey|
- optkey = optkey.to_s
- fontconf = ret.assoc(optkey)
- if fontconf && fontconf.size > 2
- ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
- fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
- ret.push(fontconf)
- end
- }
-
- __methodcall_optkeys.each{|optkey, method|
- ret << [optkey.to_s, '', '', '', self.__send__(method)]
- }
-
- ret
- end
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__methodcall_optkeys.keys.join('|')})$/
+ method = _symbolkey2str(__methodcall_optkeys)[slot]
+ return [slot, '', '', '', self.__send__(method)]
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__strval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+ else
+ conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+ end
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 \
+ && conf[__configinfo_struct[:alias]][0] == ?- )
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+
+ conf
+
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ case conf[__configinfo_struct[:key]]
+ when /^(#{__strval_optkeys.join('|')})$/
+ # do nothing
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ else
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ if conf[__configinfo_struct[:default_value]].index('{')
+ conf[__configinfo_struct[:default_value]] =
+ tk_split_list(conf[__configinfo_struct[:default_value]])
+ else
+ conf[__configinfo_struct[:default_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:default_value]])
+ end
+ end
+ if conf[__configinfo_struct[:current_value]]
+ if conf[__configinfo_struct[:current_value]].index('{')
+ conf[__configinfo_struct[:current_value]] =
+ tk_split_list(conf[__configinfo_struct[:current_value]])
+ else
+ conf[__configinfo_struct[:current_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:current_value]])
+ end
+ end
+ end
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 \
+ && conf[__configinfo_struct[:alias]][0] == ?- )
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+
+ conf
+ }
+
+ __font_optkeys.each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret.assoc(optkey)
+ if fontconf && fontconf.size > 2
+ ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
+ fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
+ ret.push(fontconf)
+ end
+ }
+
+ __methodcall_optkeys.each{|optkey, method|
+ ret << [optkey.to_s, '', '', '', self.__send__(method)]
+ }
+
+ ret
+ end
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
- fontkey = $2
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}"))))
- conf[__configinfo_struct[:key]] =
- conf[__configinfo_struct[:key]][1..-1]
-
- if ( ! __configinfo_struct[:alias] \
- || conf.size > __configinfo_struct[:alias] + 1 )
- conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
- { conf.shift => conf }
- elsif ( __configinfo_struct[:alias] \
- && conf.size == __configinfo_struct[:alias] + 1 )
- if conf[__configinfo_struct[:alias]][0] == ?-
- conf[__configinfo_struct[:alias]] =
- conf[__configinfo_struct[:alias]][1..-1]
- end
- { conf[0] => conf[1] }
- else
- { conf.shift => conf }
- end
+ fontkey = $2
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}"))))
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
+ { conf.shift => conf }
+ elsif ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 )
+ if conf[__configinfo_struct[:alias]][0] == ?-
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
else
- if slot
- slot = slot.to_s
- case slot
- when /^(#{__methodcall_optkeys.keys.join('|')})$/
- method = _symbolkey2str(__methodcall_optkeys)[slot]
- return {slot => ['', '', '', self.__send__(method)]}
-
- when /^(#{__numval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- begin
- conf[__configinfo_struct[:default_value]] =
- number(conf[__configinfo_struct[:default_value]])
- rescue
- conf[__configinfo_struct[:default_value]] = nil
- end
- end
- if ( conf[__configinfo_struct[:current_value]] )
- begin
- conf[__configinfo_struct[:current_value]] =
- number(conf[__configinfo_struct[:current_value]])
- rescue
- conf[__configinfo_struct[:current_value]] = nil
- end
- end
-
- when /^(#{__numstrval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- conf[__configinfo_struct[:default_value]] =
- num_or_str(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] )
- conf[__configinfo_struct[:current_value]] =
- num_or_str(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__boolval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- begin
- conf[__configinfo_struct[:default_value]] =
- bool(conf[__configinfo_struct[:default_value]])
- rescue
- conf[__configinfo_struct[:default_value]] = nil
- end
- end
- if ( conf[__configinfo_struct[:current_value]] )
- begin
- conf[__configinfo_struct[:current_value]] =
- bool(conf[__configinfo_struct[:current_value]])
- rescue
- conf[__configinfo_struct[:current_value]] = nil
- end
- end
-
- when /^(#{__listval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- conf[__configinfo_struct[:default_value]] =
- simplelist(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] )
- conf[__configinfo_struct[:current_value]] =
- simplelist(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__numlistval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
-
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] \
- && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
- conf[__configinfo_struct[:default_value]] =
- list(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] \
- && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
- conf[__configinfo_struct[:current_value]] =
- list(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__strval_optkeys.join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
- else
- conf = tk_split_list(_fromUTF8(tk_send_without_enc(*(__config_cmd << "-#{slot}"))))
- end
- conf[__configinfo_struct[:key]] =
- conf[__configinfo_struct[:key]][1..-1]
-
- if ( __configinfo_struct[:alias] \
- && conf.size == __configinfo_struct[:alias] + 1 )
- if conf[__configinfo_struct[:alias]][0] == ?-
- conf[__configinfo_struct[:alias]] =
- conf[__configinfo_struct[:alias]][1..-1]
- end
- { conf[0] => conf[1] }
- else
- { conf.shift => conf }
- end
-
- else
- ret = {}
- tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).each{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[__configinfo_struct[:key]] =
- conf[__configinfo_struct[:key]][1..-1]
-
- case conf[__configinfo_struct[:key]]
- when /^(#{__strval_optkeys.join('|')})$/
- # do nothing
-
- when /^(#{__numval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- begin
- conf[__configinfo_struct[:default_value]] =
- number(conf[__configinfo_struct[:default_value]])
- rescue
- conf[__configinfo_struct[:default_value]] = nil
- end
- end
- if ( conf[__configinfo_struct[:current_value]] )
- begin
- conf[__configinfo_struct[:current_value]] =
- number(conf[__configinfo_struct[:current_value]])
- rescue
- conf[__configinfo_struct[:current_value]] = nil
- end
- end
-
- when /^(#{__numstrval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- conf[__configinfo_struct[:default_value]] =
- num_or_str(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] )
- conf[__configinfo_struct[:current_value]] =
- num_or_str(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__boolval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- begin
- conf[__configinfo_struct[:default_value]] =
- bool(conf[__configinfo_struct[:default_value]])
- rescue
- conf[__configinfo_struct[:default_value]] = nil
- end
- end
- if ( conf[__configinfo_struct[:current_value]] )
- begin
- conf[__configinfo_struct[:current_value]] =
- bool(conf[__configinfo_struct[:current_value]])
- rescue
- conf[__configinfo_struct[:current_value]] = nil
- end
- end
-
- when /^(#{__listval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- conf[__configinfo_struct[:default_value]] =
- simplelist(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] )
- conf[__configinfo_struct[:current_value]] =
- simplelist(conf[__configinfo_struct[:current_value]])
- end
-
- when /^(#{__numlistval_optkeys.join('|')})$/
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] \
- && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
- conf[__configinfo_struct[:default_value]] =
- list(conf[__configinfo_struct[:default_value]])
- end
- if ( conf[__configinfo_struct[:current_value]] \
- && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
- conf[__configinfo_struct[:current_value]] =
- list(conf[__configinfo_struct[:current_value]])
- end
-
- else
- if ( __configinfo_struct[:default_value] \
- && conf[__configinfo_struct[:default_value]] )
- if conf[__configinfo_struct[:default_value]].index('{')
- conf[__configinfo_struct[:default_value]] =
- tk_split_list(conf[__configinfo_struct[:default_value]])
- else
- conf[__configinfo_struct[:default_value]] =
- tk_tcl2ruby(conf[__configinfo_struct[:default_value]])
- end
- end
- if conf[__configinfo_struct[:current_value]]
- if conf[__configinfo_struct[:current_value]].index('{')
- conf[__configinfo_struct[:current_value]] =
- tk_split_list(conf[__configinfo_struct[:current_value]])
- else
- conf[__configinfo_struct[:current_value]] =
- tk_tcl2ruby(conf[__configinfo_struct[:current_value]])
- end
- end
- end
-
- if ( __configinfo_struct[:alias] \
- && conf.size == __configinfo_struct[:alias] + 1 )
- if conf[__configinfo_struct[:alias]][0] == ?-
- conf[__configinfo_struct[:alias]] =
- conf[__configinfo_struct[:alias]][1..-1]
- end
- ret[conf[0]] = conf[1]
- else
- ret[conf.shift] = conf
- end
- }
-
- __font_optkeys.each{|optkey|
- optkey = optkey.to_s
- fontconf = ret[optkey]
- if fontconf.kind_of?(Array)
- ret.delete(optkey)
- ret.delete('latin' << optkey)
- ret.delete('ascii' << optkey)
- ret.delete('kanji' << optkey)
- fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
- ret[optkey] = fontconf
- end
- }
-
- __methodcall_optkeys.each{|optkey, method|
- ret[optkey.to_s] = ['', '', '', self.__send__(method)]
- }
-
- ret
- end
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__methodcall_optkeys.keys.join('|')})$/
+ method = _symbolkey2str(__methodcall_optkeys)[slot]
+ return {slot => ['', '', '', self.__send__(method)]}
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__strval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}"))))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc(*(__config_cmd << "-#{slot}"))))
+ end
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 )
+ if conf[__configinfo_struct[:alias]][0] == ?-
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
+
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ case conf[__configinfo_struct[:key]]
+ when /^(#{__strval_optkeys.join('|')})$/
+ # do nothing
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ else
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ if conf[__configinfo_struct[:default_value]].index('{')
+ conf[__configinfo_struct[:default_value]] =
+ tk_split_list(conf[__configinfo_struct[:default_value]])
+ else
+ conf[__configinfo_struct[:default_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:default_value]])
+ end
+ end
+ if conf[__configinfo_struct[:current_value]]
+ if conf[__configinfo_struct[:current_value]].index('{')
+ conf[__configinfo_struct[:current_value]] =
+ tk_split_list(conf[__configinfo_struct[:current_value]])
+ else
+ conf[__configinfo_struct[:current_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:current_value]])
+ end
+ end
+ end
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 )
+ if conf[__configinfo_struct[:alias]][0] == ?-
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ ret[conf[0]] = conf[1]
+ else
+ ret[conf.shift] = conf
+ end
+ }
+
+ __font_optkeys.each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret[optkey]
+ if fontconf.kind_of?(Array)
+ ret.delete(optkey)
+ ret.delete('latin' << optkey)
+ ret.delete('ascii' << optkey)
+ ret.delete('kanji' << optkey)
+ fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
+ ret[optkey] = fontconf
+ end
+ }
+
+ __methodcall_optkeys.each{|optkey, method|
+ ret[optkey.to_s] = ['', '', '', self.__send__(method)]
+ }
+
+ ret
+ end
end
end
end
@@ -3103,31 +3103,31 @@ module TkConfigMethod
def current_configinfo(slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if slot
- org_slot = slot
- begin
- conf = configinfo(slot)
- if ( ! __configinfo_struct[:alias] \
- || conf.size > __configinfo_struct[:alias] + 1 )
- return {conf[0] => conf[-1]}
- end
- slot = conf[__configinfo_struct[:alias]]
- end while(org_slot != slot)
- fail RuntimeError,
- "there is a configure alias loop about '#{org_slot}'"
+ org_slot = slot
+ begin
+ conf = configinfo(slot)
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ return {conf[0] => conf[-1]}
+ end
+ slot = conf[__configinfo_struct[:alias]]
+ end while(org_slot != slot)
+ fail RuntimeError,
+ "there is a configure alias loop about '#{org_slot}'"
else
- ret = {}
- configinfo().each{|conf|
- if ( ! __configinfo_struct[:alias] \
- || conf.size > __configinfo_struct[:alias] + 1 )
- ret[conf[0]] = conf[-1]
- end
- }
- ret
+ ret = {}
+ configinfo().each{|conf|
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ ret[conf[0]] = conf[-1]
+ end
+ }
+ ret
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
ret = {}
- configinfo(slot).each{|key, conf|
- ret[key] = conf[-1] if conf.kind_of?(Array)
+ configinfo(slot).each{|key, conf|
+ ret[key] = conf[-1] if conf.kind_of?(Array)
}
ret
end
@@ -3169,17 +3169,17 @@ class TkObject<TkKernel
case args.length
when 1
if name[-1] == ?=
- configure name[0..-2], args[0]
+ configure name[0..-2], args[0]
else
- configure name, args[0]
+ configure name, args[0]
end
when 0
begin
- cget(name)
+ cget(name)
rescue
- fail NameError,
- "undefined local variable or method `#{name}' for #{self.to_s}",
- error_at
+ fail NameError,
+ "undefined local variable or method `#{name}' for #{self.to_s}",
+ error_at
end
else
fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
@@ -3200,14 +3200,14 @@ class TkObject<TkKernel
def event_generate(context, keys=nil)
if keys
#tk_call('event', 'generate', path,
- # "<#{tk_event_sequence(context)}>", *hash_kv(keys))
+ # "<#{tk_event_sequence(context)}>", *hash_kv(keys))
tk_call_without_enc('event', 'generate', path,
- "<#{tk_event_sequence(context)}>",
- *hash_kv(keys, true))
+ "<#{tk_event_sequence(context)}>",
+ *hash_kv(keys, true))
else
#tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>")
tk_call_without_enc('event', 'generate', path,
- "<#{tk_event_sequence(context)}>")
+ "<#{tk_event_sequence(context)}>")
end
end
@@ -3277,24 +3277,24 @@ class TkWindow<TkObject
#['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key|
# fontkeys[key] = keys.delete(key) if keys.key?(key)
#}
- __font_optkeys.each{|key|
- fkey = key.to_s
- fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ __font_optkeys.each{|key|
+ fkey = key.to_s
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
- fkey = "kanji#{key}"
- fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ fkey = "kanji#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
- fkey = "latin#{key}"
- fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ fkey = "latin#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
- fkey = "ascii#{key}"
- fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
- }
+ fkey = "ascii#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ }
- __methodcall_optkeys.each{|key|
- key = key.to_s
- methodkeys[key] = keys.delete(key) if keys.key?(key)
- }
+ __methodcall_optkeys.each{|key|
+ key = key.to_s
+ methodkeys[key] = keys.delete(key) if keys.key?(key)
+ }
end
if without_creating && keys
#configure(keys)
@@ -3491,7 +3491,7 @@ class TkWindow<TkObject
# ilist = list(tk_call('grid', 'columnconfigure', epath, index))
# info = {}
# while key = ilist.shift
- # info[key[1..-1]] = ilist.shift
+ # info[key[1..-1]] = ilist.shift
# end
# info
#end
@@ -3505,7 +3505,7 @@ class TkWindow<TkObject
# ilist = list(tk_call('grid', 'rowconfigure', epath, index))
# info = {}
# while key = ilist.shift
- # info[key[1..-1]] = ilist.shift
+ # info[key[1..-1]] = ilist.shift
# end
# info
#end
@@ -3596,10 +3596,10 @@ class TkWindow<TkObject
# conf
#else
# tk_split_simplelist(tk_call('place',
- # 'configure', epath)).collect{|conflist|
- # conf = tk_split_simplelist(conflist)
- # conf[0] = conf[0][1..-1]
- # conf
+ # 'configure', epath)).collect{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ # conf[0] = conf[0][1..-1]
+ # conf
# }
#end
TkPlace.configinfo(self, slot)
@@ -3718,15 +3718,15 @@ class TkWindow<TkObject
}
if defined?(@cmdtbl)
for id in @cmdtbl
- uninstall_cmd id
+ uninstall_cmd id
end
end
children.each{|path, obj|
if defined?(@cmdtbl)
- for id in @cmdtbl
- uninstall_cmd id
- end
+ for id in @cmdtbl
+ uninstall_cmd id
+ end
end
TkCore::INTERP.tk_windows.delete(path)
}
@@ -3801,17 +3801,17 @@ class TkWindow<TkObject
taglist
else
list(tk_call('bindtags', path)).collect{|tag|
- if tag.kind_of?(String)
- if cls = WidgetClassNames[tag]
- cls
- elsif btag = TkBindTag.id2obj(tag)
- btag
- else
- tag
- end
- else
- tag
- end
+ if tag.kind_of?(String)
+ if cls = WidgetClassNames[tag]
+ cls
+ elsif btag = TkBindTag.id2obj(tag)
+ btag
+ else
+ tag
+ end
+ else
+ tag
+ end
}
end
end
diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb
index ac297c8ce5f..1a8a7927d3a 100644
--- a/ext/tk/lib/tk/canvas.rb
+++ b/ext/tk/lib/tk/canvas.rb
@@ -1,9 +1,7 @@
#
-# tk/canvas.rb - Tk canvas classes
-# $Date$
-# by Yukihiro Matsumoto <matz@caelum.co.jp>
-# $Date$
-# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+# tk/canvas.rb - Tk canvas classes
+# $Date$
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
#
require 'tk'
require 'tk/canvastag'
@@ -93,7 +91,7 @@ class TkCanvas<TkWindow
def bbox(tagOrId, *tags)
list(tk_send_without_enc('bbox', tagid(tagOrId),
- *tags.collect{|t| tagid(t)}))
+ *tags.collect{|t| tagid(t)}))
end
def itembind(tag, context, cmd=Proc.new, args=nil)
@@ -135,14 +133,14 @@ class TkCanvas<TkWindow
def dchars(tag, first, last=None)
tk_send_without_enc('dchars', tagid(tag),
- _get_eval_enc_str(first), _get_eval_enc_str(last))
+ _get_eval_enc_str(first), _get_eval_enc_str(last))
self
end
def delete(*args)
if TkcItem::CItemID_TBL[self.path]
find('withtag', *args).each{|item|
- TkcItem::CItemID_TBL[self.path].delete(item.id)
+ TkcItem::CItemID_TBL[self.path].delete(item.id)
}
end
tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
@@ -189,9 +187,9 @@ class TkCanvas<TkWindow
else
ret = tk_send_without_enc('focus')
if ret == ""
- nil
+ nil
else
- TkcItem.id2obj(self, ret)
+ TkcItem.id2obj(self, ret)
end
end
end
@@ -213,7 +211,7 @@ class TkCanvas<TkWindow
def insert(tagOrId, index, string)
tk_send_without_enc('insert', tagid(tagOrId), index,
- _get_eval_enc_str(string))
+ _get_eval_enc_str(string))
self
end
@@ -223,9 +221,9 @@ class TkCanvas<TkWindow
when 'dash', 'activedash', 'disableddash'
conf = tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}")
if conf =~ /^[0-9]/
- list(conf)
+ list(conf)
else
- conf
+ conf
end
when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}"))
@@ -233,17 +231,17 @@ class TkCanvas<TkWindow
#fnt = tk_tcl2ruby(tk_send('itemcget', tagid(tagOrId), "-#{option}"))
fnt = tk_tcl2ruby(_fromUTF8(tk_send_with_enc('itemcget', tagid(tagOrId), '-font')))
unless fnt.kind_of?(TkFont)
- fnt = tagfontobj(tagid(tagOrId), fnt)
+ fnt = tagfontobj(tagid(tagOrId), fnt)
end
if option.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
- # obsolete; just for compatibility
- fnt.kanji_font
+ # obsolete; just for compatibility
+ fnt.kanji_font
else
- fnt
+ fnt
end
else
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId),
- "-#{option}")))
+ "-#{option}")))
end
end
@@ -254,28 +252,28 @@ class TkCanvas<TkWindow
self.coords(tagOrId, coords) if coords
if ( key['font'] || key['kanjifont'] \
- || key['latinfont'] || key['asciifont'] )
- tagfont_configure(tagid(tagOrId), key.dup)
+ || key['latinfont'] || key['asciifont'] )
+ tagfont_configure(tagid(tagOrId), key.dup)
else
- _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
- *hash_kv(key, true)))
+ _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
+ *hash_kv(key, true)))
end
else
if ( key == 'coords' || key == :coords )
- self.coords(tagOrId, value)
+ self.coords(tagOrId, value)
elsif ( key == 'font' || key == :font ||
- key == 'kanjifont' || key == :kanjifont ||
- key == 'latinfont' || key == :latinfont ||
- key == 'asciifont' || key == :asciifont )
- if value == None
- tagfontobj(tagid(tagOrId))
- else
- tagfont_configure(tagid(tagOrId), {key=>value})
- end
+ key == 'kanjifont' || key == :kanjifont ||
+ key == 'latinfont' || key == :latinfont ||
+ key == 'asciifont' || key == :asciifont )
+ if value == None
+ tagfontobj(tagid(tagOrId))
+ else
+ tagfont_configure(tagid(tagOrId), {key=>value})
+ end
else
- _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
- "-#{key}", _get_eval_enc_str(value)))
+ _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
+ "-#{key}", _get_eval_enc_str(value)))
end
end
self
@@ -294,142 +292,142 @@ class TkCanvas<TkWindow
def itemconfiginfo(tagOrId, key=nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if key
- case key.to_s
- when 'coords'
- return ['coords', '', '', '', self.coords(tagOrId)]
- when 'dash', 'activedash', 'disableddash'
- conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))
- if conf[3] && conf[3] =~ /^[0-9]/
- conf[3] = list(conf[3])
- end
- if conf[4] && conf[4] =~ /^[0-9]/
- conf[4] = list(conf[4])
- end
- when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
- when 'font', 'kanjifont'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
- conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
- else
- conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
- end
- conf[0] = conf[0][1..-1]
- conf
+ case key.to_s
+ when 'coords'
+ return ['coords', '', '', '', self.coords(tagOrId)]
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
+ conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
else
- ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
- when 'dash', 'activedash', 'disableddash'
- if conf[3] && conf[3] =~ /^[0-9]/
- conf[3] = list(conf[3])
- end
- if conf[4] && conf[4] =~ /^[0-9]/
- conf[4] = list(conf[4])
- end
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
- conf
- }
-
- fontconf = ret.assoc('font')
- if fontconf
- ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
- fontconf[4] = tagfont_configinfo(tagid(tagOrId), fontconf[4])
- ret.push(fontconf)
- end
-
- ret << ['coords', '', '', '', self.coords(tagOrId)]
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ when 'dash', 'activedash', 'disableddash'
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+
+ fontconf = ret.assoc('font')
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(tagid(tagOrId), fontconf[4])
+ ret.push(fontconf)
+ end
+
+ ret << ['coords', '', '', '', self.coords(tagOrId)]
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
if key
- case key.to_s
- when 'coords'
- {'coords' => ['', '', '', self.coords(tagOrId)]}
- when 'dash', 'activedash', 'disableddash'
- conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
- tagid(tagOrId),
- "-#{key}"))
- if conf[3] && conf[3] =~ /^[0-9]/
- conf[3] = list(conf[3])
- end
- if conf[4] && conf[4] =~ /^[0-9]/
- conf[4] = list(conf[4])
- end
- when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
- when 'font', 'kanjifont'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
- conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
- else
- conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
- end
- key = conf.shift[1..-1]
- { key => conf }
+ case key.to_s
+ when 'coords'
+ {'coords' => ['', '', '', self.coords(tagOrId)]}
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
+ tagid(tagOrId),
+ "-#{key}"))
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
+ conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
else
- ret = {}
- tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).each{|conflist|
- conf = tk_split_simplelist(conflist)
- key = conf.shift[1..-1]
- case key
- when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
- when 'dash', 'activedash', 'disableddash'
- if conf[2] && conf[2] =~ /^[0-9]/
- conf[2] = list(conf[2])
- end
- if conf[3] && conf[3] =~ /^[0-9]/
- conf[3] = list(conf[3])
- end
- else
- if conf[2]
- if conf[2].index('{')
- conf[2] = tk_split_list(conf[2])
- else
- conf[2] = tk_tcl2ruby(conf[2])
- end
- end
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- end
- if conf.size == 1
- ret[key] = conf[0][1..-1] # alias info
- else
- ret[key] = conf
- end
- }
-
- fontconf = ret['font']
- if fontconf
- ret.delete('font')
- ret.delete('kanjifont')
- fontconf[3] = tagfont_configinfo(tagid(tagOrId), fontconf[3])
- ret['font'] = fontconf
- end
-
- ret['coords'] = ['', '', '', self.coords(tagOrId)]
-
- ret
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ when 'dash', 'activedash', 'disableddash'
+ if conf[2] && conf[2] =~ /^[0-9]/
+ conf[2] = list(conf[2])
+ end
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(tagid(tagOrId), fontconf[3])
+ ret['font'] = fontconf
+ end
+
+ ret['coords'] = ['', '', '', self.coords(tagOrId)]
+
+ ret
end
end
end
@@ -437,19 +435,19 @@ class TkCanvas<TkWindow
def current_itemconfiginfo(tagOrId, key=nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if key
- conf = itemconfiginfo(tagOrId, key)
- {conf[0] => conf[4]}
+ conf = itemconfiginfo(tagOrId, key)
+ {conf[0] => conf[4]}
else
- ret = {}
- itemconfiginfo(tagOrId).each{|conf|
- ret[conf[0]] = conf[4] if conf.size > 2
- }
- ret
+ ret = {}
+ itemconfiginfo(tagOrId).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
ret = {}
itemconfiginfo(tagOrId, key).each{|k, conf|
- ret[k] = conf[-1] if conf.kind_of?(Array)
+ ret[k] = conf[-1] if conf.kind_of?(Array)
}
ret
end
@@ -551,32 +549,32 @@ class TkcItem<TkObject
if args[-1].kind_of? Hash
keys = _symbolkey2str(args.pop)
if args.size == 0
- args = keys.delete('coords')
- unless args.kind_of?(Array)
- fail "coords parameter must be given by an Array"
- end
+ args = keys.delete('coords')
+ unless args.kind_of?(Array)
+ fail "coords parameter must be given by an Array"
+ end
end
#['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key|
# fontkeys[key] = keys.delete(key) if keys.key?(key)
#}
__item_font_optkeys(nil).each{|key|
- fkey = key.to_s
- fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ fkey = key.to_s
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
- fkey = "kanji#{key}"
- fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ fkey = "kanji#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
- fkey = "latin#{key}"
- fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ fkey = "latin#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
- fkey = "ascii#{key}"
- fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ fkey = "ascii#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
}
__item_methodcall_optkeys(nil).each{|key|
- key = key.to_s
- methodkeys[key] = keys.delete(key) if keys.key?(key)
+ key = key.to_s
+ methodkeys[key] = keys.delete(key) if keys.key?(key)
}
#args = args.flatten.concat(hash_kv(keys))
@@ -595,7 +593,7 @@ class TkcItem<TkObject
end
args, fontkeys = _parse_create_args(args)
idnum = tk_call_without_enc(canvas.path, 'create',
- self::CItemTypeName, *args)
+ self::CItemTypeName, *args)
canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty?
idnum.to_i # 'canvas item id' is an integer number
end
diff --git a/ext/tk/lib/tk/clock.rb b/ext/tk/lib/tk/clock.rb
index 88b66129ea8..823b8a63415 100644
--- a/ext/tk/lib/tk/clock.rb
+++ b/ext/tk/lib/tk/clock.rb
@@ -8,45 +8,45 @@ module Tk
def self.clicks(ms=nil)
case ms
when nil
- tk_call_without_enc('clock','clicks').to_i
+ tk_call_without_enc('clock','clicks').to_i
when /^mic/
- tk_call_without_enc('clock','clicks','-microseconds').to_i
+ tk_call_without_enc('clock','clicks','-microseconds').to_i
when /^mil/
- tk_call_without_enc('clock','clicks','-milliseconds').to_i
+ tk_call_without_enc('clock','clicks','-milliseconds').to_i
else
- tk_call_without_enc('clock','clicks','-milliseconds').to_i
+ tk_call_without_enc('clock','clicks','-milliseconds').to_i
end
end
def self.format(clk, form=nil)
if form
- tk_call('clock','format',clk,'-format',form)
+ tk_call('clock','format',clk,'-format',form)
else
- tk_call('clock','format',clk)
+ tk_call('clock','format',clk)
end
end
def self.formatGMT(clk, form=nil)
if form
- tk_call('clock','format',clk,'-format',form,'-gmt','1')
+ tk_call('clock','format',clk,'-format',form,'-gmt','1')
else
- tk_call('clock','format',clk,'-gmt','1')
+ tk_call('clock','format',clk,'-gmt','1')
end
end
def self.scan(str, base=nil)
if base
- tk_call('clock','scan',str,'-base',base).to_i
+ tk_call('clock','scan',str,'-base',base).to_i
else
- tk_call('clock','scan',str).to_i
+ tk_call('clock','scan',str).to_i
end
end
def self.scanGMT(str, base=nil)
if base
- tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
+ tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
else
- tk_call('clock','scan',str,'-gmt','1').to_i
+ tk_call('clock','scan',str,'-gmt','1').to_i
end
end
diff --git a/ext/tk/lib/tk/composite.rb b/ext/tk/lib/tk/composite.rb
index ac5ed2f171c..d85b815dd76 100644
--- a/ext/tk/lib/tk/composite.rb
+++ b/ext/tk/lib/tk/composite.rb
@@ -39,7 +39,7 @@ module TkComposite
m_cget = m_cget.to_s if m_cget
m_info = m_info.to_s if m_info
@option_methods[m_set] = {
- :set => m_set, :cget => m_cget, :info => m_info
+ :set => m_set, :cget => m_cget, :info => m_info
}
}
end
@@ -55,9 +55,9 @@ module TkComposite
option = option.to_s
if @delegates[alias_opt].kind_of?(Array)
if (elem = @delegates[alias_opt].assoc(option))
- wins.each{|w| elem[1].push(w)}
+ wins.each{|w| elem[1].push(w)}
else
- @delegates[alias_opt] << [option, wins]
+ @delegates[alias_opt] << [option, wins]
end
else
@delegates[alias_opt] = [ [option, wins] ]
@@ -73,13 +73,13 @@ module TkComposite
if @option_methods.include?(slot)
if @option_methods[slot][:cget]
- return self.__send__(@option_methods[slot][:cget])
+ return self.__send__(@option_methods[slot][:cget])
else
- if @option_setting[slot]
- return @option_setting[slot]
- else
- return ''
- end
+ if @option_setting[slot]
+ return @option_setting[slot]
+ else
+ return ''
+ end
end
end
@@ -88,11 +88,11 @@ module TkComposite
begin
if tbl
- opt, wins = tbl[-1]
- opt = slot if opt == 'DEFAULT'
- if wins && wins[-1]
- return wins[-1].cget(opt)
- end
+ opt, wins = tbl[-1]
+ opt = slot if opt == 'DEFAULT'
+ if wins && wins[-1]
+ return wins[-1].cget(opt)
+ end
end
rescue
end
@@ -110,11 +110,11 @@ module TkComposite
if @option_methods.include?(slot)
unless @option_methods[slot][:cget]
- if value.kind_of?(Symbol)
- @option_setting[slot] = value.to_s
- else
- @option_setting[slot] = value
- end
+ if value.kind_of?(Symbol)
+ @option_setting[slot] = value.to_s
+ else
+ @option_setting[slot] = value
+ end
end
return self.__send__(@option_methods[slot][:set], value)
end
@@ -124,12 +124,12 @@ module TkComposite
begin
if tbl
- last = nil
- tbl.each{|opt, wins|
- opt = slot if opt == 'DEFAULT'
- wins.each{|w| last = w.configure(opt, value)}
- }
- return last
+ last = nil
+ tbl.each{|opt, wins|
+ opt = slot if opt == 'DEFAULT'
+ wins.each{|w| last = w.configure(opt, value)}
+ }
+ return last
end
rescue
end
@@ -140,153 +140,153 @@ module TkComposite
def configinfo(slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if slot
- slot = slot.to_s
- if @option_methods.include?(slot)
- if @option_methods[slot][:info]
- return self.__send__(@option_methods[slot][:info])
- else
- return [slot, '', '', '', self.cget(slot)]
- end
- end
-
- tbl = @delegates[slot]
- tbl = @delegates['DEFAULT'] unless tbl
-
- begin
- if tbl
- if tbl.length == 1
- opt, wins = tbl[0]
- if slot == opt || opt == 'DEFAULT'
- return wins[-1].configinfo(slot)
- else
- info = wins[-1].configinfo(opt)
- info[0] = slot
- return info
- end
- else
- opt, wins = tbl[-1]
- return [slot, '', '', '', wins[-1].cget(opt)]
- end
- end
- rescue
- end
-
- super
+ slot = slot.to_s
+ if @option_methods.include?(slot)
+ if @option_methods[slot][:info]
+ return self.__send__(@option_methods[slot][:info])
+ else
+ return [slot, '', '', '', self.cget(slot)]
+ end
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ if slot == opt || opt == 'DEFAULT'
+ return wins[-1].configinfo(slot)
+ else
+ info = wins[-1].configinfo(opt)
+ info[0] = slot
+ return info
+ end
+ else
+ opt, wins = tbl[-1]
+ return [slot, '', '', '', wins[-1].cget(opt)]
+ end
+ end
+ rescue
+ end
+
+ super
else # slot == nil
- info_list = super
-
- tbl = @delegates['DEFAULT']
- if tbl
- wins = tbl[0][1]
- if wins && wins[-1]
- wins[-1].configinfo.each{|info|
- slot = info[0]
- info_list.delete_if{|i| i[0] == slot} << info
- }
- end
- end
-
- @delegates.each{|slot, tbl|
- next if slot == 'DEFAULT'
- if tbl.length == 1
- opt, wins = tbl[0]
- next unless wins && wins[-1]
- if slot == opt
- info_list.delete_if{|i| i[0] == slot} <<
- wins[-1].configinfo(slot)
- else
- info = wins[-1].configinfo(opt)
- info[0] = slot
- info_list.delete_if{|i| i[0] == slot} << info
- end
- else
- opt, wins = tbl[-1]
- info_list.delete_if{|i| i[0] == slot} <<
- [slot, '', '', '', wins[-1].cget(opt)]
- end
- }
-
- @option_methods.each{|slot, m|
- if m[:info]
- info = self.__send__(m[:info])
- else
- info = [slot, '', '', '', self.cget(slot)]
- end
- info_list.delete_if{|i| i[0] == slot} << info
- }
-
- info_list
+ info_list = super
+
+ tbl = @delegates['DEFAULT']
+ if tbl
+ wins = tbl[0][1]
+ if wins && wins[-1]
+ wins[-1].configinfo.each{|info|
+ slot = info[0]
+ info_list.delete_if{|i| i[0] == slot} << info
+ }
+ end
+ end
+
+ @delegates.each{|slot, tbl|
+ next if slot == 'DEFAULT'
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ next unless wins && wins[-1]
+ if slot == opt
+ info_list.delete_if{|i| i[0] == slot} <<
+ wins[-1].configinfo(slot)
+ else
+ info = wins[-1].configinfo(opt)
+ info[0] = slot
+ info_list.delete_if{|i| i[0] == slot} << info
+ end
+ else
+ opt, wins = tbl[-1]
+ info_list.delete_if{|i| i[0] == slot} <<
+ [slot, '', '', '', wins[-1].cget(opt)]
+ end
+ }
+
+ @option_methods.each{|slot, m|
+ if m[:info]
+ info = self.__send__(m[:info])
+ else
+ info = [slot, '', '', '', self.cget(slot)]
+ end
+ info_list.delete_if{|i| i[0] == slot} << info
+ }
+
+ info_list
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
if slot
- slot = slot.to_s
- if @option_methods.include?(slot)
- if @option_methods[slot][:info]
- return self.__send__(@option_methods[slot][:info])
- else
- return {slot => ['', '', '', self.cget(slot)]}
- end
- end
-
- tbl = @delegates[slot]
- tbl = @delegates['DEFAULT'] unless tbl
-
- begin
- if tbl
- if tbl.length == 1
- opt, wins = tbl[0]
- if slot == opt || opt == 'DEFAULT'
- return wins[-1].configinfo(slot)
- else
- return {slot => wins[-1].configinfo(opt)[opt]}
- end
- else
- opt, wins = tbl[-1]
- return {slot => ['', '', '', wins[-1].cget(opt)]}
- end
- end
- rescue
- end
-
- super
+ slot = slot.to_s
+ if @option_methods.include?(slot)
+ if @option_methods[slot][:info]
+ return self.__send__(@option_methods[slot][:info])
+ else
+ return {slot => ['', '', '', self.cget(slot)]}
+ end
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ if slot == opt || opt == 'DEFAULT'
+ return wins[-1].configinfo(slot)
+ else
+ return {slot => wins[-1].configinfo(opt)[opt]}
+ end
+ else
+ opt, wins = tbl[-1]
+ return {slot => ['', '', '', wins[-1].cget(opt)]}
+ end
+ end
+ rescue
+ end
+
+ super
else # slot == nil
- info_list = super
-
- tbl = @delegates['DEFAULT']
- if tbl
- wins = tbl[0][1]
- info_list.update(wins[-1].configinfo) if wins && wins[-1]
- end
-
- @delegates.each{|slot, tbl|
- next if slot == 'DEFAULT'
- if tbl.length == 1
- opt, wins = tbl[0]
- next unless wins && wins[-1]
- if slot == opt
- info_list.update(wins[-1].configinfo(slot))
- else
- info_list.update({slot => wins[-1].configinfo(opt)[opt]})
- end
- else
- opt, wins = tbl[-1]
- info_list.update({slot => ['', '', '', wins[-1].cget(opt)]})
- end
- }
-
- @option_methods.each{|slot, m|
- if m[:info]
- info = self.__send__(m[:info])
- else
- info = {slot => ['', '', '', self.cget(slot)]}
- end
- info_list.update(info)
- }
-
- info_list
+ info_list = super
+
+ tbl = @delegates['DEFAULT']
+ if tbl
+ wins = tbl[0][1]
+ info_list.update(wins[-1].configinfo) if wins && wins[-1]
+ end
+
+ @delegates.each{|slot, tbl|
+ next if slot == 'DEFAULT'
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ next unless wins && wins[-1]
+ if slot == opt
+ info_list.update(wins[-1].configinfo(slot))
+ else
+ info_list.update({slot => wins[-1].configinfo(opt)[opt]})
+ end
+ else
+ opt, wins = tbl[-1]
+ info_list.update({slot => ['', '', '', wins[-1].cget(opt)]})
+ end
+ }
+
+ @option_methods.each{|slot, m|
+ if m[:info]
+ info = self.__send__(m[:info])
+ else
+ info = {slot => ['', '', '', self.cget(slot)]}
+ end
+ info_list.update(info)
+ }
+
+ info_list
end
end
end
diff --git a/ext/tk/lib/tk/console.rb b/ext/tk/lib/tk/console.rb
index 855ee6a94fd..f0d2c7aa87c 100644
--- a/ext/tk/lib/tk/console.rb
+++ b/ext/tk/lib/tk/console.rb
@@ -24,6 +24,6 @@ module TkConsole
# I have no idea to support a Ruby script seamlessly.
#
_fromUTF8(tk_call_without_enc('console', 'eval',
- _get_eval_enc_str(tcl_script)))
+ _get_eval_enc_str(tcl_script)))
end
end
diff --git a/ext/tk/lib/tk/dialog.rb b/ext/tk/lib/tk/dialog.rb
index d6355f21c14..2ced26b193e 100644
--- a/ext/tk/lib/tk/dialog.rb
+++ b/ext/tk/lib/tk/dialog.rb
@@ -17,34 +17,34 @@ class TkDialog2 < TkWindow
def _set_button_config(configs)
set_config = proc{|c,i|
if $VERBOSE && (c.has_key?('command') || c.has_key?(:command))
- STDERR.print("Warning: cannot give a command option " +
- "to the dialog button#{i}. It was removed.\n")
+ STDERR.print("Warning: cannot give a command option " +
+ "to the dialog button#{i}. It was removed.\n")
end
c.delete('command'); c.delete(:command)
# @config << Kernel.format("%s.button%s configure %s; ",
- # @path, i, hash_kv(c).join(' '))
+ # @path, i, hash_kv(c).join(' '))
@config << @path+'.button'+i.to_s+'configure '+hash_kv(c).join(' ')+'; '
}
case configs
when Proc
@buttons.each_index{|i|
- if (c = configs.call(i)).kind_of? Hash
- set_config.call(c,i)
- end
+ if (c = configs.call(i)).kind_of? Hash
+ set_config.call(c,i)
+ end
}
when Array
@buttons.each_index{|i|
- if (c = configs[i]).kind_of? Hash
- set_config.call(c,i)
- end
+ if (c = configs[i]).kind_of? Hash
+ set_config.call(c,i)
+ end
}
when Hash
@buttons.each_with_index{|s,i|
- if (c = configs[s]).kind_of? Hash
- set_config.call(c,i)
- end
+ if (c = configs[s]).kind_of? Hash
+ set_config.call(c,i)
+ end
}
end
@config = 'after idle {' + @config + '};' if @config != ""
@@ -99,7 +99,7 @@ class TkDialog2 < TkWindow
if @buttons.kind_of? Array
_set_button_config(@buttons.collect{|cfg|
- (cfg.kind_of? Array)? cfg[1]: nil})
+ (cfg.kind_of? Array)? cfg[1]: nil})
@buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg}
end
if @buttons.kind_of? Hash
@@ -109,36 +109,36 @@ class TkDialog2 < TkWindow
@buttons = tk_split_simplelist(@buttons) if @buttons.kind_of? String
@buttons = @buttons.collect{|s|
if s.kind_of? Array
- s = s.join(' ')
+ s = s.join(' ')
end
if s.include? ?\s
- '{' + s + '}'
+ '{' + s + '}'
else
- s
+ s
end
}
if @message_config.kind_of? Hash
# @config << Kernel.format("%s.msg configure %s;",
- # @path, hash_kv(@message_config).join(' '))
+ # @path, hash_kv(@message_config).join(' '))
@config << @path+'.msg configure '+hash_kv(@message_config).join(' ')+';'
end
if @msgframe_config.kind_of? Hash
# @config << Kernel.format("%s.top configure %s;",
- # @path, hash_kv(@msgframe_config).join(' '))
+ # @path, hash_kv(@msgframe_config).join(' '))
@config << @path+'.top configure '+hash_kv(@msgframe_config).join(' ')+';'
end
if @btnframe_config.kind_of? Hash
# @config << Kernel.format("%s.bot configure %s;",
- # @path, hash_kv(@btnframe_config).join(' '))
+ # @path, hash_kv(@btnframe_config).join(' '))
@config << @path+'.bot configure '+hash_kv(@btnframe_config).join(' ')+';'
end
if @bitmap_config.kind_of? Hash
# @config << Kernel.format("%s.bitmap configure %s;",
- # @path, hash_kv(@bitmap_config).join(' '))
+ # @path, hash_kv(@bitmap_config).join(' '))
@config << @path+'.bitmap configure '+hash_kv(@bitmap_config).join(' ')+';'
end
@@ -158,16 +158,16 @@ class TkDialog2 < TkWindow
end
default_button = '{}' if default_button == nil
#Tk.ip_eval('eval {global '+@var.id+';'+@config+
- # 'set '+@var.id+' [tk_dialog '+
- # @path+" "+@title+" {#{@message}} "+@bitmap+" "+
- # String(default_button)+" "+@buttons.join(' ')+']}')
+ # 'set '+@var.id+' [tk_dialog '+
+ # @path+" "+@title+" {#{@message}} "+@bitmap+" "+
+ # String(default_button)+" "+@buttons.join(' ')+']}')
Tk.ip_eval(@config)
# @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title +
- # ' {' + @message + '} ' + @bitmap + ' ' +
- # String(default_button) + ' ' + @buttons.join(' ')).to_i
+ # ' {' + @message + '} ' + @bitmap + ' ' +
+ # String(default_button) + ' ' + @buttons.join(' ')).to_i
@val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' +
- @title + ' {' + @message + '} ' + @bitmap + ' ' +
- String(default_button) + ' ' + @buttons.join(' ')).to_i
+ @title + ' {' + @message + '} ' + @bitmap + ' ' +
+ String(default_button) + ' ' + @buttons.join(' ')).to_i
end
def value
@@ -248,10 +248,10 @@ class TkWarning2 < TkDialog2
def initialize(parent = nil, mes = nil)
if !mes
if parent.kind_of? TkWindow
- mes = ""
+ mes = ""
else
- mes = parent.to_s
- parent = nil
+ mes = parent.to_s
+ parent = nil
end
end
super(parent, :message=>mes)
diff --git a/ext/tk/lib/tk/encodedstr.rb b/ext/tk/lib/tk/encodedstr.rb
index 5eb989f4203..aed0e7524e2 100644
--- a/ext/tk/lib/tk/encodedstr.rb
+++ b/ext/tk/lib/tk/encodedstr.rb
@@ -24,11 +24,11 @@ module Tk
def self.utf_to_backslash_sequence(str)
str.unpack('U*').collect{|c|
- if c <= 0xFF # ascii character
- c.chr
- else
- format('\u%X', c)
- end
+ if c <= 0xFF # ascii character
+ c.chr
+ else
+ format('\u%X', c)
+ end
}.join('')
end
def self.utf_to_backslash(str)
@@ -37,23 +37,23 @@ module Tk
def self.to_backslash_sequence(str)
str.unpack('U*').collect{|c|
- if c <= 0x1F # control character
- case c
- when 0x07; '\a'
- when 0x08; '\b'
- when 0x09; '\t'
- when 0x0a; '\n'
- when 0x0b; '\v'
- when 0x0c; '\f'
- when 0x0d; '\r'
- else
- format('\x%02X', c)
- end
- elsif c <= 0xFF # ascii character
- c.chr
- else
- format('\u%X', c)
- end
+ if c <= 0x1F # control character
+ case c
+ when 0x07; '\a'
+ when 0x08; '\b'
+ when 0x09; '\t'
+ when 0x0a; '\n'
+ when 0x0b; '\v'
+ when 0x0c; '\f'
+ when 0x0d; '\r'
+ else
+ format('\x%02X', c)
+ end
+ elsif c <= 0xFF # ascii character
+ c.chr
+ else
+ format('\u%X', c)
+ end
}.join('')
end
@@ -68,8 +68,8 @@ module Tk
def initialize(str, enc = nil)
super(str)
@encoding = ( enc ||
- ((self.class::Encoding)?
- self.class::Encoding : Tk.encoding_system) )
+ ((self.class::Encoding)?
+ self.class::Encoding : Tk.encoding_system) )
end
attr_reader :encoding
diff --git a/ext/tk/lib/tk/entry.rb b/ext/tk/lib/tk/entry.rb
index 0e45538c769..2a8a9d413cc 100644
--- a/ext/tk/lib/tk/entry.rb
+++ b/ext/tk/lib/tk/entry.rb
@@ -1,7 +1,7 @@
#
-# tk/entry.rb - Tk entry classes
-# $Date$
-# by Yukihiro Matsumoto <matz@caelum.co.jp>
+# tk/entry.rb - Tk entry classes
+# $Date$
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
require 'tk'
require 'tk/label'
diff --git a/ext/tk/lib/tk/event.rb b/ext/tk/lib/tk/event.rb
index 9c46cb5d756..16adeedc6ce 100644
--- a/ext/tk/lib/tk/event.rb
+++ b/ext/tk/lib/tk/event.rb
@@ -33,7 +33,7 @@ module TkEvent
CreateNotify = 16
DestroyNotify = 17
UnmapNotify = 18
- MapNotify = 19
+ MapNotify = 19
MapRequest = 20
ReparentNotify = 21
ConfigureNotify = 22
@@ -93,12 +93,12 @@ module TkEvent
[ ?w, TkComm.method(:window) ],
[ ?x, proc{|val|
- begin
- TkComm::number(val)
- rescue ArgumentError
- val
- end
- }
+ begin
+ TkComm::number(val)
+ rescue ArgumentError
+ val
+ end
+ }
],
nil
@@ -141,14 +141,14 @@ module TkEvent
keys = klass._get_subst_key(args)
if cmd.kind_of?(String)
- id = cmd
+ id = cmd
elsif cmd.kind_of?(TkCallbackEntry)
- id = install_cmd(cmd)
+ id = install_cmd(cmd)
else
- id = install_cmd(proc{|*arg|
- ex_args = []
- extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
- TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg))))
+ id = install_cmd(proc{|*arg|
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg))))
})
end
id + ' ' + args
@@ -156,15 +156,15 @@ module TkEvent
keys, args = klass._get_all_subst_keys
if cmd.kind_of?(String)
- id = cmd
+ id = cmd
elsif cmd.kind_of?(TkCallbackEntry)
- id = install_cmd(cmd)
+ id = install_cmd(cmd)
else
id = install_cmd(proc{|*arg|
- ex_args = []
- extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
- TkUtil.eval_cmd(cmd,
- *(ex_args << klass.new(*klass.scan_args(keys, arg))))
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ TkUtil.eval_cmd(cmd,
+ *(ex_args << klass.new(*klass.scan_args(keys, arg))))
})
end
id + ' ' + args
diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb
index 527584f1ed4..02e09c6066f 100644
--- a/ext/tk/lib/tk/font.rb
+++ b/ext/tk/lib/tk/font.rb
@@ -30,36 +30,36 @@ class TkFont
if JAPANIZED_TK
begin
fontnames = tk_call('font', 'names')
- case fontnames
- when /defaultgui/
+ case fontnames
+ when /defaultgui/
# Tcl/Tk-JP for Windows
ltn = 'defaultgui'
knj = 'defaultgui'
- when /Mincho:Helvetica-Bold-12/
+ when /Mincho:Helvetica-Bold-12/
# Tcl/Tk-JP for UNIX/X
ltn, knj = tk_split_simplelist(tk_call('font', 'configure',
'Mincho:Helvetica-Bold-12',
'-compound'))
else
# unknown Tcl/Tk-JP
- platform = tk_call('set', 'tcl_platform(platform)')
- case platform
- when 'unix'
- ltn = {'family'=>'Helvetica'.freeze,
- 'size'=>-12, 'weight'=>'bold'.freeze}
- #knj = 'k14'
- #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0'
- knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0'
- when 'windows'
- ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
- knj = 'mincho'
- when 'macintosh'
- ltn = 'system'
- knj = 'mincho'
- else # unknown
- ltn = 'Helvetica'
- knj = 'mincho'
- end
+ platform = tk_call('set', 'tcl_platform(platform)')
+ case platform
+ when 'unix'
+ ltn = {'family'=>'Helvetica'.freeze,
+ 'size'=>-12, 'weight'=>'bold'.freeze}
+ #knj = 'k14'
+ #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0'
+ knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0'
+ when 'windows'
+ ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
+ knj = 'mincho'
+ when 'macintosh'
+ ltn = 'system'
+ knj = 'mincho'
+ else # unknown
+ ltn = 'Helvetica'
+ knj = 'mincho'
+ end
end
rescue
ltn = 'Helvetica'
@@ -68,20 +68,20 @@ class TkFont
else # not JAPANIZED_TK
begin
- platform = tk_call('set', 'tcl_platform(platform)')
- case platform
- when 'unix'
- ltn = {'family'=>'Helvetica'.freeze,
- 'size'=>-12, 'weight'=>'bold'.freeze}
- when 'windows'
- ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
- when 'macintosh'
- ltn = 'system'
- else # unknown
- ltn = 'Helvetica'
- end
+ platform = tk_call('set', 'tcl_platform(platform)')
+ case platform
+ when 'unix'
+ ltn = {'family'=>'Helvetica'.freeze,
+ 'size'=>-12, 'weight'=>'bold'.freeze}
+ when 'windows'
+ ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
+ when 'macintosh'
+ ltn = 'system'
+ else # unknown
+ ltn = 'Helvetica'
+ end
rescue
- ltn = 'Helvetica'
+ ltn = 'Helvetica'
end
knj = ltn.dup
@@ -106,14 +106,14 @@ class TkFont
class DescendantFont
def initialize(compound, type)
unless compound.kind_of?(TkFont)
- fail ArgumentError, "a TkFont object is expected for the 1st argument"
+ fail ArgumentError, "a TkFont object is expected for the 1st argument"
end
@compound = compound
case type
when 'kanji', 'latin', 'ascii'
- @type = type
+ @type = type
else
- fail ArgumentError, "unknown type '#{type}'"
+ fail ArgumentError, "unknown type '#{type}'"
end
end
@@ -155,9 +155,9 @@ class TkFont
when /^8\.*/
if window
- tk_split_simplelist(tk_call('font', 'families', '-displayof', window))
+ tk_split_simplelist(tk_call('font', 'families', '-displayof', window))
else
- tk_split_simplelist(tk_call('font', 'families'))
+ tk_split_simplelist(tk_call('font', 'families'))
end
end
end
@@ -205,11 +205,11 @@ class TkFont
regexp = /^-(|kanji)#{key} /
conf_list = tk_split_simplelist(tk_call(*args)).
- find_all{|prop| prop =~ regexp}.
- collect{|prop| tk_split_simplelist(prop)}
+ find_all{|prop| prop =~ regexp}.
+ collect{|prop| tk_split_simplelist(prop)}
if conf_list.size == 0
- raise RuntimeError, "the widget may not support 'font' option"
+ raise RuntimeError, "the widget may not support 'font' option"
end
args << {}
@@ -231,11 +231,11 @@ class TkFont
regexp = /^-#{key} /
conf_list = tk_split_simplelist(tk_call(*args)).
- find_all{|prop| prop =~ regexp}.
- collect{|prop| tk_split_simplelist(prop)}
+ find_all{|prop| prop =~ regexp}.
+ collect{|prop| tk_split_simplelist(prop)}
if conf_list.size == 0
- raise RuntimeError, "the widget may not support 'font' option"
+ raise RuntimeError, "the widget may not support 'font' option"
end
args << {}
@@ -247,23 +247,23 @@ class TkFont
fnt = nil if fnt == [] || fnt == ""
unless fnt
- TkFont.new(nil, nil).call_font_configure([path, key], *args)
+ TkFont.new(nil, nil).call_font_configure([path, key], *args)
else
- begin
- compound = tk_split_simplelist(
+ begin
+ compound = tk_split_simplelist(
Hash[*tk_split_simplelist(tk_call('font', 'configure',
- fnt))].collect{|key,value|
+ fnt))].collect{|key,value|
[key[1..-1], value]
}.assoc('compound')[1])
- rescue
- compound = []
- end
- if compound == []
- TkFont.new(fnt).call_font_configure([path, key], *args)
- else
- TkFont.new(compound[0],
- compound[1]).call_font_configure([path, key], *args)
- end
+ rescue
+ compound = []
+ end
+ if compound == []
+ TkFont.new(fnt).call_font_configure([path, key], *args)
+ else
+ TkFont.new(compound[0],
+ compound[1]).call_font_configure([path, key], *args)
+ end
end
end
end
@@ -307,33 +307,33 @@ class TkFont
# compound font check
if Tk::TK_VERSION == '8.0' && JAPANIZED_TK
begin
- compound = tk_split_simplelist(tk_call('font', 'configure',
- ltn, '-compound'))
- if knj == nil
- if compound != []
- ltn, knj = compound
- end
- else
- if compound != []
- ltn = compound[0]
- end
- compound = tk_split_simplelist(tk_call('font', 'configure',
- knj, '-compound'))
- if compound != []
- knj = compound[1]
- end
- end
+ compound = tk_split_simplelist(tk_call('font', 'configure',
+ ltn, '-compound'))
+ if knj == nil
+ if compound != []
+ ltn, knj = compound
+ end
+ else
+ if compound != []
+ ltn = compound[0]
+ end
+ compound = tk_split_simplelist(tk_call('font', 'configure',
+ knj, '-compound'))
+ if compound != []
+ knj = compound[1]
+ end
+ end
rescue
end
end
if ltn
if JAPANIZED_TK && !knj
- if Tk::TK_VERSION =~ /^4.*/
- knj = DEFAULT_KANJI_FONT_NAME
- else
- knj = ltn
- end
+ if Tk::TK_VERSION =~ /^4.*/
+ knj = DEFAULT_KANJI_FONT_NAME
+ else
+ knj = ltn
+ end
end
else
ltn = DEFAULT_LATIN_FONT_NAME
@@ -372,28 +372,28 @@ class TkFont
finfo = {}
finfo['family'] = font[0].to_s
if font[1]
- fsize = font[1].to_s
- if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
- if $1 == '-'
- finfo['pixels'] = $2
- else
- finfo['points'] = $2
- end
- else
- finfo['points'] = '13'
- end
+ fsize = font[1].to_s
+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
+ if $1 == '-'
+ finfo['pixels'] = $2
+ else
+ finfo['points'] = $2
+ end
+ else
+ finfo['points'] = '13'
+ end
end
font[2..-1].each{|style|
- case (style)
- when 'normal'
- finfo['weight'] = style
- when 'bold'
- finfo['weight'] = style
- when 'roman'
- finfo['slant'] = 'r'
- when 'italic'
- finfo['slant'] = 'i'
- end
+ case (style)
+ when 'normal'
+ finfo['weight'] = style
+ when 'bold'
+ finfo['weight'] = style
+ when 'roman'
+ finfo['slant'] = 'r'
+ when 'italic'
+ finfo['slant'] = 'i'
+ end
}
@latinfont = '-' + _get_font_info_from_hash(finfo).join('-') + '-'
@@ -424,28 +424,28 @@ class TkFont
finfo = {}
finfo['family'] = font[0].to_s
if font[1]
- fsize = font[1].to_s
- if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
- if $1 == '-'
- finfo['pixels'] = $2
- else
- finfo['points'] = $2
- end
- else
- finfo['points'] = '13'
- end
+ fsize = font[1].to_s
+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
+ if $1 == '-'
+ finfo['pixels'] = $2
+ else
+ finfo['points'] = $2
+ end
+ else
+ finfo['points'] = '13'
+ end
end
font[2..-1].each{|style|
- case (style)
- when 'normal'
- finfo['weight'] = style
- when 'bold'
- finfo['weight'] = style
- when 'roman'
- finfo['slant'] = 'r'
- when 'italic'
- finfo['slant'] = 'i'
- end
+ case (style)
+ when 'normal'
+ finfo['weight'] = style
+ when 'bold'
+ finfo['weight'] = style
+ when 'roman'
+ finfo['slant'] = 'r'
+ when 'italic'
+ finfo['slant'] = 'i'
+ end
}
@kanjifont = '-' + _get_font_info_from_hash(finfo).join('-') + '-'
@@ -478,42 +478,42 @@ class TkFont
if JAPANIZED_TK
if font.kind_of? Hash
- if font[:charset] || font['charset']
- tk_call('font', 'create', @latinfont, *hash_kv(font))
- else
- tk_call('font', 'create', @latinfont,
+ if font[:charset] || font['charset']
+ tk_call('font', 'create', @latinfont, *hash_kv(font))
+ else
+ tk_call('font', 'create', @latinfont,
'-charset', 'iso8859', *hash_kv(font))
- end
+ end
elsif font.kind_of? Array
- tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font))
+ tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font))
tk_call('font', 'configure', @latinfont, '-charset', 'iso8859')
elsif font.kind_of? TkFont
- tk_call('font', 'create', @latinfont, '-copy', font.latin_font)
+ tk_call('font', 'create', @latinfont, '-copy', font.latin_font)
elsif font
- tk_call('font', 'create', @latinfont, '-copy', font,
+ tk_call('font', 'create', @latinfont, '-copy', font,
'-charset', 'iso8859')
else
- tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
+ tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
end
else
if font.kind_of? Hash
- tk_call('font', 'create', @latinfont, *hash_kv(font))
+ tk_call('font', 'create', @latinfont, *hash_kv(font))
else
- keys = {}
- if font.kind_of? Array
- actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
- elsif font.kind_of? TkFont
- actual_core(font.latin_font).each{|key,val| keys[key] = val}
- elsif font
- actual_core(font).each{|key,val| keys[key] = val}
- end
- tk_call('font', 'create', @latinfont, *hash_kv(keys))
+ keys = {}
+ if font.kind_of? Array
+ actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
+ elsif font.kind_of? TkFont
+ actual_core(font.latin_font).each{|key,val| keys[key] = val}
+ elsif font
+ actual_core(font).each{|key,val| keys[key] = val}
+ end
+ tk_call('font', 'create', @latinfont, *hash_kv(keys))
end
if font && @compoundfont
keys = {}
actual_core(@latinfont).each{|key,val| keys[key] = val}
- tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
+ tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
end
end
end
@@ -524,10 +524,10 @@ class TkFont
if JAPANIZED_TK
if font.kind_of? Hash
if font[:charset] || font['charset']
- tk_call('font', 'create', @kanjifont, *hash_kv(font))
+ tk_call('font', 'create', @kanjifont, *hash_kv(font))
else
- tk_call('font', 'create', @kanjifont,
- '-charset', 'jisx0208.1983', *hash_kv(font))
+ tk_call('font', 'create', @kanjifont,
+ '-charset', 'jisx0208.1983', *hash_kv(font))
end
elsif font.kind_of? Array
tk_call('font', 'create', @kanjifont, '-copy', array2tk_list(font))
@@ -536,7 +536,7 @@ class TkFont
tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font_id)
elsif font
tk_call('font', 'create', @kanjifont, '-copy', font,
- '-charset', 'jisx0208.1983')
+ '-charset', 'jisx0208.1983')
else
tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983')
end
@@ -548,11 +548,11 @@ class TkFont
else
keys = {}
if font.kind_of? Array
- actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
+ actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
elsif font.kind_of? TkFont
- actual_core(font.kanji_font_id).each{|key,val| keys[key] = val}
+ actual_core(font.kanji_font_id).each{|key,val| keys[key] = val}
elsif font
- actual_core(font).each{|key,val| keys[key] = val}
+ actual_core(font).each{|key,val| keys[key] = val}
end
tk_call('font', 'create', @kanjifont, *hash_kv(keys))
end
@@ -572,87 +572,87 @@ class TkFont
@compoundfont = @id + 'c'
if JAPANIZED_TK
unless keys
- keys = {}
+ keys = {}
else
- keys = keys.dup
+ keys = keys.dup
end
if (tk_call('font', 'configure', @latinfont, '-underline') == '1' &&
- tk_call('font', 'configure', @kanjifont, '-underline') == '1' &&
- !keys.key?('underline'))
- keys['underline'] = true
+ tk_call('font', 'configure', @kanjifont, '-underline') == '1' &&
+ !keys.key?('underline'))
+ keys['underline'] = true
end
if (tk_call('font', 'configure', @latinfont, '-overstrike') == '1' &&
- tk_call('font', 'configure', @kanjifont, '-overstrike') == '1' &&
- !keys.key?('overstrike'))
- keys['overstrike'] = true
+ tk_call('font', 'configure', @kanjifont, '-overstrike') == '1' &&
+ !keys.key?('overstrike'))
+ keys['overstrike'] = true
end
@fontslot = {'font'=>@compoundfont}
begin
- tk_call('font', 'create', @compoundfont,
- '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
rescue RuntimeError => e
- if ltn == knj
- if e.message =~ /kanji font .* specified/
- tk_call('font', 'delete', @latinfont)
- create_latinfont(DEFAULT_LATIN_FONT_NAME)
- opts = []
- Hash[*(tk_split_simplelist(tk_call('font', 'configure',
- @kanjifont)))].each{|k,v|
- case k
- when '-size', '-weight', '-slant', '-underline', '-overstrike'
- opts << k << v
- end
- }
- tk_call('font', 'configure', @latinfont, *opts)
- tk_call('font', 'create', @compoundfont,
- '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
-
- elsif e.message =~ /ascii font .* specified/
- tk_call('font', 'delete', @kanjifont)
- create_kanjifont(DEFAULT_KANJI_FONT_NAME)
- opts = []
- Hash[*(tk_split_simplelist(tk_call('font', 'configure',
- @latinfont)))].each{|k,v|
- case k
- when '-size', '-weight', '-slant', '-underline', '-overstrike'
- opts << k << v
- end
- }
- tk_call('font', 'configure', @kanjifont, *opts)
- tk_call('font', 'create', @compoundfont,
- '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
-
- else
- raise e
- end
- else
- raise e
- end
+ if ltn == knj
+ if e.message =~ /kanji font .* specified/
+ tk_call('font', 'delete', @latinfont)
+ create_latinfont(DEFAULT_LATIN_FONT_NAME)
+ opts = []
+ Hash[*(tk_split_simplelist(tk_call('font', 'configure',
+ @kanjifont)))].each{|k,v|
+ case k
+ when '-size', '-weight', '-slant', '-underline', '-overstrike'
+ opts << k << v
+ end
+ }
+ tk_call('font', 'configure', @latinfont, *opts)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+
+ elsif e.message =~ /ascii font .* specified/
+ tk_call('font', 'delete', @kanjifont)
+ create_kanjifont(DEFAULT_KANJI_FONT_NAME)
+ opts = []
+ Hash[*(tk_split_simplelist(tk_call('font', 'configure',
+ @latinfont)))].each{|k,v|
+ case k
+ when '-size', '-weight', '-slant', '-underline', '-overstrike'
+ opts << k << v
+ end
+ }
+ tk_call('font', 'configure', @kanjifont, *opts)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+
+ else
+ raise e
+ end
+ else
+ raise e
+ end
end
else
tk_call('font', 'create', @compoundfont)
latinkeys = {}
begin
- actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
+ actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
rescue
- latinkeys {}
+ latinkeys {}
end
if latinkeys != {}
- tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
end
if knj
- kanjikeys = {}
- begin
- actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val}
- rescue
- kanjikeys {}
- end
- if kanjikeys != {}
- tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys))
- end
+ kanjikeys = {}
+ begin
+ actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val}
+ rescue
+ kanjikeys {}
+ end
+ if kanjikeys != {}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys))
+ end
end
@fontslot = {'font'=>@compoundfont}
@@ -666,8 +666,8 @@ class TkFont
""
else
[['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
- ['underline',[]], ['overstrike',[]], ['charset',[]],
- ['pointadjust',[]]]
+ ['underline',[]], ['overstrike',[]], ['charset',[]],
+ ['pointadjust',[]]]
end
end
@@ -676,24 +676,24 @@ class TkFont
""
elsif option
if window
- tk_call('font', 'actual', font, "-displayof", window, "-#{option}")
+ tk_call('font', 'actual', font, "-displayof", window, "-#{option}")
else
- tk_call('font', 'actual', font, "-#{option}")
+ tk_call('font', 'actual', font, "-#{option}")
end
else
l = tk_split_simplelist(if window
- tk_call('font', 'actual', font,
- "-displayof", window)
- else
- tk_call('font', 'actual', font)
- end)
+ tk_call('font', 'actual', font,
+ "-displayof", window)
+ else
+ tk_call('font', 'actual', font)
+ end)
r = []
while key=l.shift
- if key == '-compound'
- l.shift
- else
- r.push [key[1..-1], l.shift]
- end
+ if key == '-compound'
+ l.shift
+ else
+ r.push [key[1..-1], l.shift]
+ end
end
r
end
@@ -708,11 +708,11 @@ class TkFont
# dummy
if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
if option
- ""
+ ""
else
- [['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
- ['underline',[]], ['overstrike',[]], ['charset',[]],
- ['pointadjust',[]]]
+ [['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
+ ['underline',[]], ['overstrike',[]], ['charset',[]],
+ ['pointadjust',[]]]
end
else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
current_configinfo_core_tk4x(font, option)
@@ -724,69 +724,69 @@ class TkFont
""
else
{'family'=>'', 'size'=>'', 'weight'=>'', 'slant'=>'',
- 'underline'=>'', 'overstrike'=>'', 'charset'=>'', 'pointadjust'=>''}
+ 'underline'=>'', 'overstrike'=>'', 'charset'=>'', 'pointadjust'=>''}
end
end
def configure_core_tk8x(font, slot, value=None)
if JAPANIZED_TK
begin
- padjust = tk_call('font', 'configure', font, '-pointadjust')
+ padjust = tk_call('font', 'configure', font, '-pointadjust')
rescue
- padjust = nil
+ padjust = nil
end
else
padjust = nil
end
if slot.kind_of? Hash
if JAPANIZED_TK && (slot.key?('family') || slot.key?(:family))
- slot = _symbolkey2str(slot)
- configure_core_tk8x(font, 'family', slot.delete('family'))
+ slot = _symbolkey2str(slot)
+ configure_core_tk8x(font, 'family', slot.delete('family'))
end
if ((slot.key?('size') || slot.key?(:size)) &&
- padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust))
- tk_call('font', 'configure', font,
- '-pointadjust', padjust, *hash_kv(slot))
+ padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust))
+ tk_call('font', 'configure', font,
+ '-pointadjust', padjust, *hash_kv(slot))
else
- tk_call('font', 'configure', font, *hash_kv(slot))
+ tk_call('font', 'configure', font, *hash_kv(slot))
end
elsif (slot == 'size' || slot == :size) && padjust != nil
tk_call('font', 'configure', font,
- "-#{slot}", value, '-pointadjust', padjust)
+ "-#{slot}", value, '-pointadjust', padjust)
elsif JAPANIZED_TK && (slot == 'family' || slot == :family)
# coumpund font?
begin
- compound = tk_split_simplelist(tk_call('font', 'configure',
- font, '-compound'))
+ compound = tk_split_simplelist(tk_call('font', 'configure',
+ font, '-compound'))
rescue
- tk_call('font', 'configure', font, '-family', value)
- return self
+ tk_call('font', 'configure', font, '-family', value)
+ return self
end
if compound == []
- tk_call('font', 'configure', font, '-family', value)
- return self
+ tk_call('font', 'configure', font, '-family', value)
+ return self
end
ltn, knj = compound
lfnt = tk_call('font', 'create', '-copy', ltn)
begin
- tk_call('font', 'configure', lfnt, '-family', value)
- latin_replace_core_tk8x(lfnt)
+ tk_call('font', 'configure', lfnt, '-family', value)
+ latin_replace_core_tk8x(lfnt)
rescue RuntimeError => e
- fail e if $DEBUG
+ fail e if $DEBUG
ensure
- tk_call('font', 'delete', lfnt) if lfnt != ''
+ tk_call('font', 'delete', lfnt) if lfnt != ''
end
kfnt = tk_call('font', 'create', '-copy', knj)
begin
- tk_call('font', 'configure', kfnt, '-family', value)
- kanji_replace_core_tk8x(lfnt)
+ tk_call('font', 'configure', kfnt, '-family', value)
+ kanji_replace_core_tk8x(lfnt)
rescue RuntimeError => e
- fail e if $DEBUG
+ fail e if $DEBUG
ensure
- tk_call('font', 'delete', kfnt) if kfnt != ''
+ tk_call('font', 'delete', kfnt) if kfnt != ''
end
else
@@ -798,20 +798,20 @@ class TkFont
def configinfo_core_tk8x(font, option=nil)
if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
if option == 'compound'
- ""
+ ""
elsif option
- tk_call('font', 'configure', font, "-#{option}")
+ tk_call('font', 'configure', font, "-#{option}")
else
- l = tk_split_simplelist(tk_call('font', 'configure', font))
- r = []
- while key=l.shift
- if key == '-compound'
- l.shift
- else
- r.push [key[1..-1], l.shift]
- end
- end
- r
+ l = tk_split_simplelist(tk_call('font', 'configure', font))
+ r = []
+ while key=l.shift
+ if key == '-compound'
+ l.shift
+ else
+ r.push [key[1..-1], l.shift]
+ end
+ end
+ r
end
else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
current_configinfo_core_tk8x(font, option)
@@ -827,11 +827,11 @@ class TkFont
l = tk_split_simplelist(tk_call('font', 'configure', font))
r = {}
while key=l.shift
- if key == '-compound'
- l.shift
- else
- r[key[1..-1]] = l.shift
- end
+ if key == '-compound'
+ l.shift
+ else
+ r[key[1..-1]] = l.shift
+ end
end
r
end
@@ -865,28 +865,28 @@ class TkFont
@fontslot['font'] = @latinfont
Tk_FontUseTBL.dup.each{|w, fobj|
if self == fobj
- begin
- if w.include?(';')
- win, tag, optkey = w.split(';')
- optkey = 'font' if optkey == nil || optkey == ''
- winobj = tk_tcl2ruby(win)
-# winobj.tagfont_configure(tag, {'font'=>@latinfont})
- if winobj.kind_of? TkText
- tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont)
- elsif winobj.kind_of? TkCanvas
- tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont)
- elsif winobj.kind_of? TkMenu
- tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
- else
- raise RuntimeError, "unknown widget type"
- end
- else
-# tk_tcl2ruby(w).font_configure('font'=>@latinfont)
- tk_call(w, 'configure', '-font', @latinfont)
- end
- rescue
- Tk_FontUseTBL.delete(w)
- end
+ begin
+ if w.include?(';')
+ win, tag, optkey = w.split(';')
+ optkey = 'font' if optkey == nil || optkey == ''
+ winobj = tk_tcl2ruby(win)
+# winobj.tagfont_configure(tag, {'font'=>@latinfont})
+ if winobj.kind_of? TkText
+ tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont)
+ elsif winobj.kind_of? TkCanvas
+ tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont)
+ elsif winobj.kind_of? TkMenu
+ tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
+ else
+ raise RuntimeError, "unknown widget type"
+ end
+ else
+# tk_tcl2ruby(w).font_configure('font'=>@latinfont)
+ tk_call(w, 'configure', '-font', @latinfont)
+ end
+ rescue
+ Tk_FontUseTBL.delete(w)
+ end
end
}
self
@@ -900,28 +900,28 @@ class TkFont
@fontslot['kanjifont'] = @kanjifont
Tk_FontUseTBL.dup.each{|w, fobj|
if self == fobj
- begin
- if w.include?(';')
- win, tag, optkey = w.split(';')
- optkey = 'kanjifont' unless optkey
- winobj = tk_tcl2ruby(win)
-# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont})
- if winobj.kind_of? TkText
- tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont)
- elsif winobj.kind_of? TkCanvas
- tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont)
- elsif winobj.kind_of? TkMenu
- tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
- else
- raise RuntimeError, "unknown widget type"
- end
- else
-# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont)
- tk_call(w, 'configure', '-kanjifont', @kanjifont)
- end
- rescue
- Tk_FontUseTBL.delete(w)
- end
+ begin
+ if w.include?(';')
+ win, tag, optkey = w.split(';')
+ optkey = 'kanjifont' unless optkey
+ winobj = tk_tcl2ruby(win)
+# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont})
+ if winobj.kind_of? TkText
+ tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont)
+ elsif winobj.kind_of? TkCanvas
+ tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont)
+ elsif winobj.kind_of? TkMenu
+ tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
+ else
+ raise RuntimeError, "unknown widget type"
+ end
+ else
+# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont)
+ tk_call(w, 'configure', '-kanjifont', @kanjifont)
+ end
+ rescue
+ Tk_FontUseTBL.delete(w)
+ end
end
}
self
@@ -930,14 +930,14 @@ class TkFont
def latin_replace_core_tk8x(ltn)
if JAPANIZED_TK
begin
- tk_call('font', 'delete', '@font_tmp')
+ tk_call('font', 'delete', '@font_tmp')
rescue
end
begin
- fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont)
+ fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont)
rescue
- #fnt_bup = ''
- fnt_bup = DEFAULT_LATIN_FONT_NAME
+ #fnt_bup = ''
+ fnt_bup = DEFAULT_LATIN_FONT_NAME
end
end
@@ -951,40 +951,40 @@ class TkFont
keys = self.configinfo
tk_call('font', 'delete', @compoundfont)
begin
- tk_call('font', 'create', @compoundfont,
- '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
=begin
- latinkeys = {}
- begin
- actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
- rescue
- latinkeys {}
- end
- if latinkeys != {}
- tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
- end
+ latinkeys = {}
+ begin
+ actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
+ rescue
+ latinkeys {}
+ end
+ if latinkeys != {}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ end
=end
rescue RuntimeError => e
- tk_call('font', 'delete', @latinfont)
- if fnt_bup && fnt_bup != ''
- tk_call('font', 'create', @latinfont, '-copy', fnt_bup)
- tk_call('font', 'create', @compoundfont,
- '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
- tk_call('font', 'delete', fnt_bup)
- else
- fail e
- end
+ tk_call('font', 'delete', @latinfont)
+ if fnt_bup && fnt_bup != ''
+ tk_call('font', 'create', @latinfont, '-copy', fnt_bup)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ tk_call('font', 'delete', fnt_bup)
+ else
+ fail e
+ end
end
else
latinkeys = {}
begin
- actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
+ actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
rescue
- latinkeys {}
+ latinkeys {}
end
if latinkeys != {}
- tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
end
end
self
@@ -993,14 +993,14 @@ class TkFont
def kanji_replace_core_tk8x(knj)
if JAPANIZED_TK
begin
- tk_call('font', 'delete', '@font_tmp')
+ tk_call('font', 'delete', '@font_tmp')
rescue
end
begin
- fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont)
+ fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont)
rescue
- #fnt_bup = ''
- fnt_bup = DEFAULT_KANJI_FONT_NAME
+ #fnt_bup = ''
+ fnt_bup = DEFAULT_KANJI_FONT_NAME
end
end
@@ -1014,18 +1014,18 @@ class TkFont
keys = self.configinfo
tk_call('font', 'delete', @compoundfont)
begin
- tk_call('font', 'create', @compoundfont,
- '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
rescue RuntimeError => e
- tk_call('font', 'delete', @kanjifont)
- if fnt_bup && fnt_bup != ''
- tk_call('font', 'create', @kanjifont, '-copy', fnt_bup)
- tk_call('font', 'create', @compoundfont,
- '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
- tk_call('font', 'delete', fnt_bup)
- else
- fail e
- end
+ tk_call('font', 'delete', @kanjifont)
+ if fnt_bup && fnt_bup != ''
+ tk_call('font', 'create', @kanjifont, '-copy', fnt_bup)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ tk_call('font', 'delete', fnt_bup)
+ else
+ fail e
+ end
end
end
self
@@ -1038,7 +1038,7 @@ class TkFont
def measure_core_tk8x(window, text)
if window
number(tk_call('font', 'measure', @compoundfont,
- '-displayof', window, text))
+ '-displayof', window, text))
else
number(tk_call('font', 'measure', @compoundfont, text))
end
@@ -1056,20 +1056,20 @@ class TkFont
def metrics_core_tk8x(font, window, option=nil)
if option
if window
- number(tk_call('font', 'metrics', font,
- "-displayof", window, "-#{option}"))
+ number(tk_call('font', 'metrics', font,
+ "-displayof", window, "-#{option}"))
else
- number(tk_call('font', 'metrics', font, "-#{option}"))
+ number(tk_call('font', 'metrics', font, "-#{option}"))
end
else
l = tk_split_list(if window
- tk_call('font','metrics',font,"-displayof",window)
- else
- tk_call('font','metrics',font)
- end)
+ tk_call('font','metrics',font,"-displayof",window)
+ else
+ tk_call('font','metrics',font)
+ end)
r = []
while key=l.shift
- r.push [key[1..-1], l.shift.to_i]
+ r.push [key[1..-1], l.shift.to_i]
end
r
end
@@ -1133,9 +1133,9 @@ class TkFont
configure name, args[0]
when 0
begin
- configinfo name
+ configinfo name
rescue
- fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at
+ fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at
end
else
fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
@@ -1171,49 +1171,49 @@ class TkFont
Tk_FontUseTBL.each{|key,value|
next unless self == value
if key.include?(';')
- win, tag, optkey = key.split(';')
- winobj = tk_tcl2ruby(win)
- if winobj.kind_of? TkText
- if optkey
- ret.push([winobj, winobj.tagid2obj(tag), optkey])
- else
- ret.push([winobj, winobj.tagid2obj(tag)])
- end
- elsif winobj.kind_of? TkCanvas
- if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag
- if optkey
- ret.push([winobj, tagobj, optkey])
- else
- ret.push([winobj, tagobj])
- end
- elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem
- if optkey
- ret.push([winobj, tagobj, optkey])
- else
- ret.push([winobj, tagobj])
- end
- else
- if optkey
- ret.push([winobj, tag, optkey])
- else
- ret.push([winobj, tag])
- end
- end
- elsif winobj.kind_of? TkMenu
- if optkey
- ret.push([winobj, tag, optkey])
- else
- ret.push([winobj, tag])
- end
- else
- if optkey
- ret.push([win, tag, optkey])
- else
- ret.push([win, tag])
- end
- end
+ win, tag, optkey = key.split(';')
+ winobj = tk_tcl2ruby(win)
+ if winobj.kind_of? TkText
+ if optkey
+ ret.push([winobj, winobj.tagid2obj(tag), optkey])
+ else
+ ret.push([winobj, winobj.tagid2obj(tag)])
+ end
+ elsif winobj.kind_of? TkCanvas
+ if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag
+ if optkey
+ ret.push([winobj, tagobj, optkey])
+ else
+ ret.push([winobj, tagobj])
+ end
+ elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem
+ if optkey
+ ret.push([winobj, tagobj, optkey])
+ else
+ ret.push([winobj, tagobj])
+ end
+ else
+ if optkey
+ ret.push([winobj, tag, optkey])
+ else
+ ret.push([winobj, tag])
+ end
+ end
+ elsif winobj.kind_of? TkMenu
+ if optkey
+ ret.push([winobj, tag, optkey])
+ else
+ ret.push([winobj, tag])
+ end
+ else
+ if optkey
+ ret.push([win, tag, optkey])
+ else
+ ret.push([win, tag])
+ end
+ end
else
- ret.push(tk_tcl2ruby(key))
+ ret.push(tk_tcl2ruby(key))
end
}
ret
diff --git a/ext/tk/lib/tk/grid.rb b/ext/tk/lib/tk/grid.rb
index c591eea187b..74287d43bd1 100644
--- a/ext/tk/lib/tk/grid.rb
+++ b/ext/tk/lib/tk/grid.rb
@@ -33,9 +33,9 @@ module TkGrid
args.each{|win|
case win
when '-', 'x', '^' # RELATIVE PLACEMENT
- params.push(win)
+ params.push(win)
else
- params.push(_epath(win))
+ params.push(_epath(win))
end
}
opts.each{|k, v|
@@ -50,7 +50,7 @@ module TkGrid
# master = master.epath if master.kind_of?(TkObject)
master = _epath(master)
tk_call_without_enc("grid", 'columnconfigure',
- master, index, *hash_kv(args))
+ master, index, *hash_kv(args))
end
def rowconfigure(master, index, args)
@@ -65,24 +65,24 @@ module TkGrid
if slot
case slot
when 'uniform', :uniform
- tk_call_without_enc('grid', 'columnconfigure',
- master, index, "-#{slot}")
+ tk_call_without_enc('grid', 'columnconfigure',
+ master, index, "-#{slot}")
else
- num_or_str(tk_call_without_enc('grid', 'columnconfigure',
- master, index, "-#{slot}"))
+ num_or_str(tk_call_without_enc('grid', 'columnconfigure',
+ master, index, "-#{slot}"))
end
else
#ilist = list(tk_call_without_enc('grid','columnconfigure',master,index))
ilist = simplelist(tk_call_without_enc('grid', 'columnconfigure',
- master, index))
+ master, index))
info = {}
while key = ilist.shift
- case key
- when 'uniform'
- info[key[1..-1]] = ilist.shift
- else
- info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
- end
+ case key
+ when 'uniform'
+ info[key[1..-1]] = ilist.shift
+ else
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
end
info
end
@@ -94,24 +94,24 @@ module TkGrid
if slot
case slot
when 'uniform', :uniform
- tk_call_without_enc('grid', 'rowconfigure',
- master, index, "-#{slot}")
+ tk_call_without_enc('grid', 'rowconfigure',
+ master, index, "-#{slot}")
else
- num_or_str(tk_call_without_enc('grid', 'rowconfigure',
- master, index, "-#{slot}"))
+ num_or_str(tk_call_without_enc('grid', 'rowconfigure',
+ master, index, "-#{slot}"))
end
else
#ilist = list(tk_call_without_enc('grid', 'rowconfigure', master, index))
ilist = simplelist(tk_call_without_enc('grid', 'rowconfigure',
- master, index))
+ master, index))
info = {}
while key = ilist.shift
- case key
- when 'uniform'
- info[key[1..-1]] = ilist.shift
- else
- info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
- end
+ case key
+ when 'uniform'
+ info[key[1..-1]] = ilist.shift
+ else
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
end
info
end
diff --git a/ext/tk/lib/tk/image.rb b/ext/tk/lib/tk/image.rb
index 7868ed0c8f1..7fd61eff5d0 100644
--- a/ext/tk/lib/tk/image.rb
+++ b/ext/tk/lib/tk/image.rb
@@ -65,9 +65,9 @@ class TkPhotoImage<TkImage
keys = _symbolkey2str(keys)
NullArgOptionKeys.collect{|opt|
if keys[opt]
- keys[opt] = None
+ keys[opt] = None
else
- keys.delete(opt)
+ keys.delete(opt)
end
}
hash_kv(keys).flatten
@@ -101,11 +101,11 @@ class TkPhotoImage<TkImage
else
# for backward compatibility
args = opts.collect{|term|
- if term.kind_of?(String) && term.include?(?\s)
- term.split
- else
- term
- end
+ if term.kind_of?(String) && term.include?(?\s)
+ term.split
+ else
+ term
+ end
}.flatten
tk_send('copy', src, *args)
end
@@ -141,11 +141,11 @@ class TkPhotoImage<TkImage
else
# for backward compatibility
args = opts.collect{|term|
- if term.kind_of?(String) && term.include?(?\s)
- term.split
- else
- term
- end
+ if term.kind_of?(String) && term.include?(?\s)
+ term.split
+ else
+ term
+ end
}.flatten
tk_send('read', file, *args)
end
@@ -173,11 +173,11 @@ class TkPhotoImage<TkImage
else
# for backward compatibility
args = opts.collect{|term|
- if term.kind_of?(String) && term.include?(?\s)
- term.split
- else
- term
- end
+ if term.kind_of?(String) && term.include?(?\s)
+ term.split
+ else
+ term
+ end
}.flatten
tk_send('write', file, *args)
end
diff --git a/ext/tk/lib/tk/itemconfig.rb b/ext/tk/lib/tk/itemconfig.rb
index 27145004190..34c64adb2c5 100644
--- a/ext/tk/lib/tk/itemconfig.rb
+++ b/ext/tk/lib/tk/itemconfig.rb
@@ -61,14 +61,14 @@ module TkItemConfigOptkeys
keys.each{|k, v|
optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s}
if optkey
- defkey, undefkey = optkey
- if v
- keys2[defkey.to_s] = None
- else
- keys2[undefkey.to_s] = None
- end
+ defkey, undefkey = optkey
+ if v
+ keys2[defkey.to_s] = None
+ else
+ keys2[undefkey.to_s] = None
+ end
else
- keys2[k.to_s] = v
+ keys2[k.to_s] = v
end
}
keys2
@@ -122,9 +122,9 @@ module TkItemConfigMethod
case option
when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
begin
- number(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+ number(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
rescue
- nil
+ nil
end
when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
@@ -132,9 +132,9 @@ module TkItemConfigMethod
when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
begin
- bool(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+ bool(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
rescue
- nil
+ nil
end
when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
@@ -143,9 +143,9 @@ module TkItemConfigMethod
when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
conf = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
if conf =~ /^[0-9]/
- list(conf)
+ list(conf)
else
- conf
+ conf
end
when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
@@ -156,13 +156,13 @@ module TkItemConfigMethod
fontkey = $2
fnt = tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{fontkey}")), true)
unless fnt.kind_of?(TkFont)
- fnt = tagfontobj(tagid(tagOrId), fontkey)
+ fnt = tagfontobj(tagid(tagOrId), fontkey)
end
if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
- # obsolete; just for compatibility
- fnt.kanji_font
+ # obsolete; just for compatibility
+ fnt.kanji_font
else
- fnt
+ fnt
end
else
tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")), true)
@@ -174,48 +174,48 @@ module TkItemConfigMethod
slot = _symbolkey2str(slot)
__item_methodcall_optkeys(tagid(tagOrId)).each{|key, method|
- value = slot.delete(key.to_s)
- self.__send__(method, tagOrId, value) if value
+ value = slot.delete(key.to_s)
+ self.__send__(method, tagOrId, value) if value
}
__item_keyonly_optkeys(tagid(tagOrId)).each{|defkey, undefkey|
- conf = slot.find{|kk, vv| kk == defkey.to_s}
- if conf
- k, v = conf
- if v
- slot[k] = None
- else
- slot[undefkey.to_s] = None if undefkey
- slot.delete(k)
- end
- end
+ conf = slot.find{|kk, vv| kk == defkey.to_s}
+ if conf
+ k, v = conf
+ if v
+ slot[k] = None
+ else
+ slot[undefkey.to_s] = None if undefkey
+ slot.delete(k)
+ end
+ end
}
if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/})
- tagfont_configure(tagid(tagOrId), slot)
+ tagfont_configure(tagid(tagOrId), slot)
elsif slot.size > 0
- tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot))))
+ tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot))))
end
else
slot = slot.to_s
if ( conf = __item_keyonly_optkeys(tagid(tagOrId)).find{|k, v| k.to_s == slot } )
- defkey, undefkey = conf
- if value
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{defkey}"))
- elsif undefkey
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}"))
- end
+ defkey, undefkey = conf
+ if value
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{defkey}"))
+ elsif undefkey
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}"))
+ end
elsif ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] )
- self.__send__(method, tagOrId, value)
+ self.__send__(method, tagOrId, value)
elsif (slot =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
- if value == None
- tagfontobj(tagid(tagOrId), $2)
- else
- tagfont_configure(tagid(tagOrId), {slot=>value})
- end
+ if value == None
+ tagfontobj(tagid(tagOrId), $2)
+ else
+ tagfont_configure(tagid(tagOrId), {slot=>value})
+ end
else
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << value))
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << value))
end
end
self
@@ -224,531 +224,531 @@ module TkItemConfigMethod
def itemconfiginfo(tagOrId, slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
- fontkey = $2
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
- if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
- || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey)
- elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
- && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
- end
- conf
+ fontkey = $2
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey)
+ elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ conf
else
- if slot
- slot = slot.to_s
- case slot
- when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
- method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
- return [slot, '', '', '', self.__send__(method, tagOrId)]
-
- when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
- end
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
- end
- end
-
- when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
- end
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
- end
- end
-
- when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- else
- conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
- end
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
- && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
- end
-
- conf
-
- else
- ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
-
- case conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
- when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
- # do nothing
-
- when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
- end
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
- end
- end
-
- when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
- end
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
- end
- end
-
- when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- else
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- else
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- end
- if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
- if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- else
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
- end
- end
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
- && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
- end
-
- conf
- }
-
- __item_font_optkeys(tagid(tagOrId)).each{|optkey|
- optkey = optkey.to_s
- fontconf = ret.assoc(optkey)
- if fontconf && fontconf.size > 2
- ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
- fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
- ret.push(fontconf)
- end
- }
-
- __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
- ret << [optkey.to_s, '', '', '', self.__send__(method, tagOrId)]
- }
-
- ret
- end
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return [slot, '', '', '', self.__send__(method, tagOrId)]
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ else
+ conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+
+ conf
+
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ case conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ else
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ end
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+ end
+ end
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+
+ conf
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret.assoc(optkey)
+ if fontconf && fontconf.size > 2
+ ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
+ fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
+ ret.push(fontconf)
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret << [optkey.to_s, '', '', '', self.__send__(method, tagOrId)]
+ }
+
+ ret
+ end
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
- fontkey = $2
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
-
- if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
- || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = fontobj(tagid(tagOrId), fontkey)
- { conf.shift => conf }
- elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
- && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
- end
- { conf[0] => conf[1] }
- else
- { conf.shift => conf }
- end
+ fontkey = $2
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = fontobj(tagid(tagOrId), fontkey)
+ { conf.shift => conf }
+ elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
else
- if slot
- slot = slot.to_s
- case slot
- when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
- method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
- return {slot => ['', '', '', self.__send__(method, tagOrId)]}
-
- when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
- end
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
- end
- end
-
- when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
- end
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
- end
- end
-
- when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
- conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
-
- else
- conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
- end
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
- && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
- end
- { conf[0] => conf[1] }
- else
- { conf.shift => conf }
- end
-
- else
- ret = {}
- tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).each{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
-
- case conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
- when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
- # do nothing
-
- when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
- end
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
- end
- end
-
- when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
- end
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- begin
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- rescue
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
- end
- end
-
- when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
-
- else
- if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
- && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
- if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- else
- conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
- tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
- end
- end
- if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
- if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- else
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
- tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
- end
- end
- end
-
- if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
- && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
- conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
- end
- ret[conf[0]] = conf[1]
- else
- ret[conf.shift] = conf
- end
- }
-
- __item_font_optkeys(tagid(tagOrId)).each{|optkey|
- optkey = optkey.to_s
- fontconf = ret[optkey]
- if fontconf.kind_of?(Array)
- ret.delete(optkey)
- ret.delete('latin' << optkey)
- ret.delete('ascii' << optkey)
- ret.delete('kanji' << optkey)
- fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
- ret[optkey] = fontconf
- end
- }
-
- __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
- ret[optkey.to_s] = ['', '', '', self.__send__(method, tagOrId)]
- }
-
- ret
- end
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return {slot => ['', '', '', self.__send__(method, tagOrId)]}
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ else
+ conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
+
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ case conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ else
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ end
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+ end
+ end
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ ret[conf[0]] = conf[1]
+ else
+ ret[conf.shift] = conf
+ end
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret[optkey]
+ if fontconf.kind_of?(Array)
+ ret.delete(optkey)
+ ret.delete('latin' << optkey)
+ ret.delete('ascii' << optkey)
+ ret.delete('kanji' << optkey)
+ fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
+ ret[optkey] = fontconf
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret[optkey.to_s] = ['', '', '', self.__send__(method, tagOrId)]
+ }
+
+ ret
+ end
end
end
end
@@ -756,31 +756,31 @@ module TkItemConfigMethod
def current_itemconfiginfo(tagOrId, slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if slot
- org_slot = slot
- begin
- conf = itemconfiginfo(tagOrId, slot)
- if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
- || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- return {conf[0] => conf[-1]}
- end
- slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]]
- end while(org_slot != slot)
- fail RuntimeError,
- "there is a configure alias loop about '#{org_slot}'"
+ org_slot = slot
+ begin
+ conf = itemconfiginfo(tagOrId, slot)
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ return {conf[0] => conf[-1]}
+ end
+ slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]]
+ end while(org_slot != slot)
+ fail RuntimeError,
+ "there is a configure alias loop about '#{org_slot}'"
else
- ret = {}
- itemconfiginfo(tagOrId).each{|conf|
- if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
- || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- ret[conf[0]] = conf[-1]
- end
- }
- ret
+ ret = {}
+ itemconfiginfo(tagOrId).each{|conf|
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ ret[conf[0]] = conf[-1]
+ end
+ }
+ ret
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
ret = {}
- itemconfiginfo(slot).each{|key, conf|
- ret[key] = conf[-1] if conf.kind_of?(Array)
+ itemconfiginfo(slot).each{|key, conf|
+ ret[key] = conf[-1] if conf.kind_of?(Array)
}
ret
end
diff --git a/ext/tk/lib/tk/itemfont.rb b/ext/tk/lib/tk/itemfont.rb
index f194595d574..1f77ad11e7e 100644
--- a/ext/tk/lib/tk/itemfont.rb
+++ b/ext/tk/lib/tk/itemfont.rb
@@ -33,19 +33,19 @@ module TkTreatItemFont
if key
pathname = [win, tag, key].join(';')
TkFont.used_on(pathname) ||
- TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
+ TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
elsif optkeys.size == 1
pathname = [win, tag, optkeys[0]].join(';')
TkFont.used_on(pathname) ||
- TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
+ TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
else
fonts = {}
optkeys.each{|key|
- key = key.to_s
- pathname = [win, tag, key].join(';')
- fonts[key] =
- TkFont.used_on(pathname) ||
- TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
+ key = key.to_s
+ pathname = [win, tag, key].join(';')
+ fonts[key] =
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId))))
}
fonts
end
@@ -64,38 +64,38 @@ module TkTreatItemFont
k_optkey = 'kanji' << optkey
if slot.key?(optkey)
- fnt = slot.delete(optkey)
- if fnt.kind_of?(TkFont)
- slot.delete(l_optkey)
- slot.delete(a_optkey)
- slot.delete(k_optkey)
-
- fnt.call_font_configure([pathname, optkey],
- *(__item_config_cmd(tagid(tagOrId)) << {}))
- next
- else
- if fnt
- if (slot.key?(l_optkey) ||
- slot.key?(a_optkey) ||
- slot.key?(k_optkey))
- fnt = TkFont.new(fnt)
-
- lfnt = slot.delete(l_optkey)
- lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
- kfnt = slot.delete(k_optkey)
-
- fnt.latin_replace(lfnt) if lfnt
- fnt.kanji_replace(kfnt) if kfnt
-
- fnt.call_font_configure([pathname, optkey],
- *(__item_config_cmd(tagid(tagOrId)) << {}))
- next
- else
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
- end
- end
- next
- end
+ fnt = slot.delete(optkey)
+ if fnt.kind_of?(TkFont)
+ slot.delete(l_optkey)
+ slot.delete(a_optkey)
+ slot.delete(k_optkey)
+
+ fnt.call_font_configure([pathname, optkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ next
+ else
+ if fnt
+ if (slot.key?(l_optkey) ||
+ slot.key?(a_optkey) ||
+ slot.key?(k_optkey))
+ fnt = TkFont.new(fnt)
+
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ fnt.latin_replace(lfnt) if lfnt
+ fnt.kanji_replace(kfnt) if kfnt
+
+ fnt.call_font_configure([pathname, optkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ next
+ else
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
+ end
+ end
+ next
+ end
end
lfnt = slot.delete(l_optkey)
@@ -103,12 +103,12 @@ module TkTreatItemFont
kfnt = slot.delete(k_optkey)
if lfnt && kfnt
- TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
- *(__item_config_cmd(tagid(tagOrId)) << {}))
+ TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
elsif lfnt
- latintagfont_configure([lfnt, optkey])
+ latintagfont_configure([lfnt, optkey])
elsif kfnt
- kanjitagfont_configure([kfnt, optkey])
+ kanjitagfont_configure([kfnt, optkey])
end
}
@@ -140,26 +140,26 @@ module TkTreatItemFont
pathname = [win, tag, optkey].join(';')
if (fobj = TkFont.used_on(pathname))
- fobj = TkFont.new(fobj) # create a new TkFont object
+ fobj = TkFont.new(fobj) # create a new TkFont object
elsif Tk::JAPANIZED_TK
- fobj = fontobj # create a new TkFont object
+ fobj = fontobj # create a new TkFont object
else
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
- next
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
+ next
end
if fobj.kind_of?(TkFont)
- if ltn.kind_of?(TkFont)
- conf = {}
- ltn.latin_configinfo.each{|key,val| conf[key] = val}
- if keys
- fobj.latin_configure(conf.update(keys))
- else
- fobj.latin_configure(conf)
- end
- else
- fobj.latin_replace(ltn)
- end
+ if ltn.kind_of?(TkFont)
+ conf = {}
+ ltn.latin_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.latin_configure(conf.update(keys))
+ else
+ fobj.latin_configure(conf)
+ end
+ else
+ fobj.latin_replace(ltn)
+ end
end
fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {}))
@@ -191,26 +191,26 @@ module TkTreatItemFont
pathname = [win, tag, optkey].join(';')
if (fobj = TkFont.used_on(pathname))
- fobj = TkFont.new(fobj) # create a new TkFont object
+ fobj = TkFont.new(fobj) # create a new TkFont object
elsif Tk::JAPANIZED_TK
- fobj = fontobj # create a new TkFont object
+ fobj = fontobj # create a new TkFont object
else
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
- next
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
+ next
end
if fobj.kind_of?(TkFont)
- if knj.kind_of?(TkFont)
- conf = {}
- knj.kanji_configinfo.each{|key,val| conf[key] = val}
- if keys
- fobj.kanji_configure(conf.update(keys))
- else
- fobj.kanji_configure(conf)
- end
- else
- fobj.kanji_replace(knj)
- end
+ if knj.kind_of?(TkFont)
+ conf = {}
+ knj.kanji_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.kanji_configure(conf.update(keys))
+ else
+ fobj.kanji_configure(conf)
+ end
+ else
+ fobj.kanji_replace(knj)
+ end
end
fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {}))
@@ -221,24 +221,24 @@ module TkTreatItemFont
def tagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
if wintag
if winkey
- fnt = window.tagfontobj(wintag, winkey).dup
+ fnt = window.tagfontobj(wintag, winkey).dup
else
- fnt = window.tagfontobj(wintag).dup
+ fnt = window.tagfontobj(wintag).dup
end
else
if winkey
- fnt = window.fontobj(winkey).dup
+ fnt = window.fontobj(winkey).dup
else
- fnt = window.fontobj.dup
+ fnt = window.fontobj.dup
end
end
if targetkey
fnt.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
- *(__item_config_cmd(tagid(tagOrId)) << {}))
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
else
fnt.call_font_configure(__item_pathname(tagid(tagOrId)),
- *(__item_config_cmd(tagid(tagOrId)) << {}))
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
end
self
end
@@ -247,23 +247,23 @@ module TkTreatItemFont
def latintagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
if targetkey
fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
- *(__item_config_cmd(tagid(tagOrId)) << {}))
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
else
fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
- *(__item_config_cmd(tagid(tagOrId)) << {}))
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
end
if wintag
if winkey
- fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
+ fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
else
- fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
+ fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
end
else
if winkey
- fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
+ fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
else
- fontobj.latin_replace(window.fontobj.latin_font_id)
+ fontobj.latin_replace(window.fontobj.latin_font_id)
end
end
self
@@ -273,23 +273,23 @@ module TkTreatItemFont
def kanjifont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
if targetkey
fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
- *(__item_config_cmd(tagid(tagOrId)) << {}))
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
else
- fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
- *(__item_config_cmd(tagid(tagOrId)) << {}))
+ fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
end
if wintag
if winkey
- fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
+ fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
else
- fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
+ fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
end
else
if winkey
- fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
+ fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
else
- fontobj.kanji_replace(window.fontobj.kanji_font_id)
+ fontobj.kanji_replace(window.fontobj.kanji_font_id)
end
end
self
diff --git a/ext/tk/lib/tk/kinput.rb b/ext/tk/lib/tk/kinput.rb
index 418b3aec478..fc731b65696 100644
--- a/ext/tk/lib/tk/kinput.rb
+++ b/ext/tk/lib/tk/kinput.rb
@@ -48,13 +48,13 @@ module TkKinput
def TkKinput.attribute_info(window, slot=nil)
if slot
conf = tk_split_list(tk_call('kanjiInput', 'attribute',
- window, "-#{slot}"))
+ window, "-#{slot}"))
conf[0] = conf[0][1..-1]
conf
else
tk_split_list(tk_call('kanjiInput', 'attribute', window)).collect{|conf|
- conf[0] = conf[0][1..-1]
- conf
+ conf[0] = conf[0][1..-1]
+ conf
}
end
end
diff --git a/ext/tk/lib/tk/listbox.rb b/ext/tk/lib/tk/listbox.rb
index d642ba2f097..f00db19239f 100644
--- a/ext/tk/lib/tk/listbox.rb
+++ b/ext/tk/lib/tk/listbox.rb
@@ -105,15 +105,15 @@ class TkListbox<TkTextWin
when 'font', 'kanjifont'
#fnt = tk_tcl2ruby(tk_send('itemcget', index, "-#{key}"))
fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index,
- '-font')))
+ '-font')))
unless fnt.kind_of?(TkFont)
- fnt = tagfontobj(index, fnt)
+ fnt = tagfontobj(index, fnt)
end
if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
- # obsolete; just for compatibility
- fnt.kanji_font
+ # obsolete; just for compatibility
+ fnt.kanji_font
else
- fnt
+ fnt
end
else
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}")))
@@ -123,25 +123,25 @@ class TkListbox<TkTextWin
if key.kind_of? Hash
if (key['font'] || key[:font] ||
key['kanjifont'] || key[:kanjifont] ||
- key['latinfont'] || key[:latinfont] ||
+ key['latinfont'] || key[:latinfont] ||
key['asciifont'] || key[:asciifont] )
- tagfont_configure(index, _symbolkey2str(key))
+ tagfont_configure(index, _symbolkey2str(key))
else
- tk_send_without_enc('itemconfigure', index, *hash_kv(key, true))
+ tk_send_without_enc('itemconfigure', index, *hash_kv(key, true))
end
else
if (key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont ||
- key == 'latinfont' || key == :latinfont ||
+ key == 'latinfont' || key == :latinfont ||
key == 'asciifont' || key == :asciifont )
- if val == None
- tagfontobj(index)
- else
- tagfont_configure(index, {key=>val})
- end
+ if val == None
+ tagfontobj(index)
+ else
+ tagfont_configure(index, {key=>val})
+ end
else
- tk_call('itemconfigure', index, "-#{key}", val)
+ tk_call('itemconfigure', index, "-#{key}", val)
end
end
self
@@ -150,101 +150,101 @@ class TkListbox<TkTextWin
def itemconfiginfo(index, key=nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if key
- case key.to_s
- when 'text', 'label', 'show'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
- when 'font', 'kanjifont'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
- conf[4] = tagfont_configinfo(index, conf[4])
- else
- conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
- end
- conf[0] = conf[0][1..-1]
- conf
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
else
- ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show'
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
- conf
- }
- fontconf = ret.assoc('font')
- if fontconf
- ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
- fontconf[4] = tagfont_configinfo(index, fontconf[4])
- ret.push(fontconf)
- else
- ret
- end
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ fontconf = ret.assoc('font')
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(index, fontconf[4])
+ ret.push(fontconf)
+ else
+ ret
+ end
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
if key
- case key.to_s
- when 'text', 'label', 'show'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
- when 'font', 'kanjifont'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
- conf[4] = tagfont_configinfo(index, conf[4])
- else
- conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
- end
- key = conf.shift[1..-1]
- { key => conf }
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
else
- ret = {}
- tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).each{|conflist|
- conf = tk_split_simplelist(conflist)
- key = conf.shift[1..-1]
- case key
- when 'text', 'label', 'show'
- else
- if conf[2]
- if conf[2].index('{')
- conf[2] = tk_split_list(conf[2])
- else
- conf[2] = tk_tcl2ruby(conf[2])
- end
- end
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- end
- if conf.size == 1
- ret[key] = conf[0][1..-1] # alias info
- else
- ret[key] = conf
- end
- }
- fontconf = ret['font']
- if fontconf
- ret.delete('font')
- ret.delete('kanjifont')
- fontconf[3] = tagfont_configinfo(index, fontconf[3])
- ret['font'] = fontconf
- end
- ret
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(index, fontconf[3])
+ ret['font'] = fontconf
+ end
+ ret
end
end
end
@@ -252,19 +252,19 @@ class TkListbox<TkTextWin
def current_itemconfiginfo(index, key=nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if key
- conf = itemconfiginfo(index, key)
- {conf[0] => conf[4]}
+ conf = itemconfiginfo(index, key)
+ {conf[0] => conf[4]}
else
- ret = {}
- itemconfiginfo(index).each{|conf|
- ret[conf[0]] = conf[4] if conf.size > 2
- }
- ret
+ ret = {}
+ itemconfiginfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
ret = {}
itemconfiginfo(index, key).each{|k, conf|
- ret[k] = conf[-1] if conf.kind_of?(Array)
+ ret[k] = conf[-1] if conf.kind_of?(Array)
}
ret
end
diff --git a/ext/tk/lib/tk/menu.rb b/ext/tk/lib/tk/menu.rb
index f13a7c5a68a..5014dea6035 100644
--- a/ext/tk/lib/tk/menu.rb
+++ b/ext/tk/lib/tk/menu.rb
@@ -84,13 +84,13 @@ class TkMenu<TkWindow
end
def insert(index, type, keys=nil)
tk_send_without_enc('insert', _get_eval_enc_str(index),
- type, *hash_kv(keys, true))
+ type, *hash_kv(keys, true))
self
end
def delete(first, last=nil)
if last
tk_send_without_enc('delete', _get_eval_enc_str(first),
- _get_eval_enc_str(last))
+ _get_eval_enc_str(last))
else
tk_send_without_enc('delete', _get_eval_enc_str(first))
end
@@ -99,7 +99,7 @@ class TkMenu<TkWindow
def popup(x, y, index=nil)
if index
tk_call_without_enc('tk_popup', path, x, y,
- _get_eval_enc_str(index))
+ _get_eval_enc_str(index))
else
tk_call_without_enc('tk_popup', path, x, y)
end
@@ -140,18 +140,18 @@ class TkMenu<TkWindow
case key.to_s
when 'text', 'label', 'show'
_fromUTF8(tk_send_without_enc('entrycget',
- _get_eval_enc_str(index), "-#{key}"))
+ _get_eval_enc_str(index), "-#{key}"))
when 'font', 'kanjifont'
#fnt = tk_tcl2ruby(tk_send('entrycget', index, "-#{key}"))
fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), '-font')))
unless fnt.kind_of?(TkFont)
- fnt = tagfontobj(index, fnt)
+ fnt = tagfontobj(index, fnt)
end
if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
- # obsolete; just for compatibility
- fnt.kanji_font
+ # obsolete; just for compatibility
+ fnt.kanji_font
else
- fnt
+ fnt
end
else
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), "-#{key}")))
@@ -161,26 +161,26 @@ class TkMenu<TkWindow
if key.kind_of? Hash
if (key['font'] || key[:font] ||
key['kanjifont'] || key[:kanjifont] ||
- key['latinfont'] || key[:latinfont] ||
+ key['latinfont'] || key[:latinfont] ||
key['asciifont'] || key[:asciifont])
- tagfont_configure(index, _symbolkey2str(key))
+ tagfont_configure(index, _symbolkey2str(key))
else
- tk_send_without_enc('entryconfigure', _get_eval_enc_str(index),
- *hash_kv(key, true))
+ tk_send_without_enc('entryconfigure', _get_eval_enc_str(index),
+ *hash_kv(key, true))
end
else
if (key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont ||
- key == 'latinfont' || key == :latinfont ||
+ key == 'latinfont' || key == :latinfont ||
key == 'asciifont' || key == :asciifont )
- if val == None
- tagfontobj(index)
- else
- tagfont_configure(index, {key=>val})
- end
+ if val == None
+ tagfontobj(index)
+ else
+ tagfont_configure(index, {key=>val})
+ end
else
- tk_call('entryconfigure', index, "-#{key}", val)
+ tk_call('entryconfigure', index, "-#{key}", val)
end
end
self
@@ -189,100 +189,100 @@ class TkMenu<TkWindow
def entryconfiginfo(index, key=nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if key
- case key.to_s
- when 'text', 'label', 'show'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
- when 'font', 'kanjifont'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
- conf[4] = tagfont_configinfo(index, conf[4])
- else
- conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
- end
- conf[0] = conf[0][1..-1]
- conf
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
else
- ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show'
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
- conf
- }
- if fontconf
- ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
- fontconf[4] = tagfont_configinfo(index, fontconf[4])
- ret.push(fontconf)
- else
- ret
- end
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(index, fontconf[4])
+ ret.push(fontconf)
+ else
+ ret
+ end
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
if key
- case key.to_s
- when 'text', 'label', 'show'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
- when 'font', 'kanjifont'
- conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
- conf[4] = tagfont_configinfo(index, conf[4])
- else
- conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
- end
- key = conf.shift[1..-1]
- { key => conf }
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
else
- ret = {}
- tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist|
- conf = tk_split_simplelist(conflist)
- key = conf.shift[1..-1]
- case key
- when 'text', 'label', 'show'
- else
- if conf[2]
- if conf[2].index('{')
- conf[2] = tk_split_list(conf[2])
- else
- conf[2] = tk_tcl2ruby(conf[2])
- end
- end
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- end
- if conf.size == 1
- ret[key] = conf[0][1..-1] # alias info
- else
- ret[key] = conf
- end
- }
- fontconf = ret['font']
- if fontconf
- ret.delete('font')
- ret.delete('kanjifont')
- fontconf[3] = tagfont_configinfo(index, fontconf[3])
- ret['font'] = fontconf
- end
- ret
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(index, fontconf[3])
+ ret['font'] = fontconf
+ end
+ ret
end
end
end
@@ -290,19 +290,19 @@ class TkMenu<TkWindow
def current_entryconfiginfo(index, key=nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if key
- conf = entryconfiginfo(index, key)
- {conf[0] => conf[4]}
+ conf = entryconfiginfo(index, key)
+ {conf[0] => conf[4]}
else
- ret = {}
- entryconfiginfo(index).each{|conf|
- ret[conf[0]] = conf[4] if conf.size > 2
- }
- ret
+ ret = {}
+ entryconfiginfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
ret = {}
entryconfiginfo(index, key).each{|k, conf|
- ret[k] = conf[-1] if conf.kind_of?(Array)
+ ret[k] = conf[-1] if conf.kind_of?(Array)
}
ret
end
@@ -422,7 +422,7 @@ class TkOptionMenubutton<TkMenubutton
@variable.value = firstval
install_win(if parent then parent.path end)
@menu = OptionMenu.new(tk_call('tk_optionMenu', @path, @variable.id,
- firstval, *vals))
+ firstval, *vals))
end
def value
@@ -435,7 +435,7 @@ class TkOptionMenubutton<TkMenubutton
end
def add(value)
@menu.add('radiobutton', 'variable'=>@variable,
- 'label'=>value, 'value'=>value)
+ 'label'=>value, 'value'=>value)
self
end
def index(index)
@@ -446,7 +446,7 @@ class TkOptionMenubutton<TkMenubutton
end
def insert(index, value)
@menu.insert(index, 'radiobutton', 'variable'=>@variable,
- 'label'=>value, 'value'=>value)
+ 'label'=>value, 'value'=>value)
self
end
def delete(index, last=None)
diff --git a/ext/tk/lib/tk/menubar.rb b/ext/tk/lib/tk/menubar.rb
index f29c40ff38a..392b6fbd4ed 100644
--- a/ext/tk/lib/tk/menubar.rb
+++ b/ext/tk/lib/tk/menubar.rb
@@ -18,10 +18,10 @@
# ['Paste', proc{puts('Paste clicked')}, 0]]
# ]
# menubar = TkMenubar.new(nil, menu_spec,
-# 'tearoff'=>false,
-# 'foreground'=>'grey40',
-# 'activeforeground'=>'red',
-# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1')
+# 'tearoff'=>false,
+# 'foreground'=>'grey40',
+# 'activeforeground'=>'red',
+# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1')
# menubar.pack('side'=>'top', 'fill'=>'x')
#
#
@@ -30,13 +30,13 @@
#
# menubar = TkMenubar.new
# menubar.add_menu([['File', 0],
-# ['Open', proc{puts('Open clicked')}, 0],
-# '---',
-# ['Quit', proc{exit}, 0]])
+# ['Open', proc{puts('Open clicked')}, 0],
+# '---',
+# ['Quit', proc{exit}, 0]])
# menubar.add_menu([['Edit', 0],
-# ['Cut', proc{puts('Cut clicked')}, 2],
-# ['Copy', proc{puts('Copy clicked')}, 0],
-# ['Paste', proc{puts('Paste clicked')}, 0]])
+# ['Cut', proc{puts('Cut clicked')}, 2],
+# ['Copy', proc{puts('Copy clicked')}, 0],
+# ['Paste', proc{puts('Paste clicked')}, 0]])
# menubar.configure('tearoff', false)
# menubar.configure('foreground', 'grey40')
# menubar.configure('activeforeground', 'red')
diff --git a/ext/tk/lib/tk/menuspec.rb b/ext/tk/lib/tk/menuspec.rb
index dfc1871ba9d..c8819f8e418 100644
--- a/ext/tk/lib/tk/menuspec.rb
+++ b/ext/tk/lib/tk/menuspec.rb
@@ -36,7 +36,7 @@
module TkMenuSpec
def _create_menu(parent, menu_info, menu_name = nil,
- tearoff = false, default_opts = nil)
+ tearoff = false, default_opts = nil)
if tearoff.kind_of?(Hash)
default_opts = tearoff
tearoff = false
@@ -64,79 +64,79 @@ module TkMenuSpec
for item_info in menu_info
if item_info.kind_of?(Hash)
- options = orig_opts.dup
- options.update(_symbolkey2str(item_info))
- item_type = (options.delete('type') || 'command').to_s
- menu_name = options.delete('menu_name')
- menu_opts = orig_opts.dup
- menu_opts.update(_symbolkey2str(options.delete('menu_config') || {}))
- if item_type == 'cascade' && options['menu'].kind_of?(Array)
- # create cascade menu
- submenu = _create_menu(menu, options['menu'], menu_name,
- tearoff, menu_opts)
- options['menu'] = submenu
- end
- menu.add(item_type, options)
+ options = orig_opts.dup
+ options.update(_symbolkey2str(item_info))
+ item_type = (options.delete('type') || 'command').to_s
+ menu_name = options.delete('menu_name')
+ menu_opts = orig_opts.dup
+ menu_opts.update(_symbolkey2str(options.delete('menu_config') || {}))
+ if item_type == 'cascade' && options['menu'].kind_of?(Array)
+ # create cascade menu
+ submenu = _create_menu(menu, options['menu'], menu_name,
+ tearoff, menu_opts)
+ options['menu'] = submenu
+ end
+ menu.add(item_type, options)
elsif item_info.kind_of?(Array)
- options = orig_opts.dup
-
- options['label'] = item_info[0] if item_info[0]
-
- case item_info[1]
- when TkVariable
- # checkbutton
- item_type = 'checkbutton'
- options['variable'] = item_info[1]
- options['onvalue'] = true
- options['offvalue'] = false
-
- when Array
- # radiobutton or cascade
- if item_info[1][0].kind_of?(TkVariable)
- # radiobutton
- item_type = 'radiobutton'
- options['variable'] = item_info[1][0]
- options['value'] = item_info[1][1] if item_info[1][1]
-
- else
- # cascade
- item_type = 'cascade'
- menu_opts = orig_opts.dup
- if item_info[4] && item_info[4].kind_of?(Hash)
- opts = _symbolkey2str(item_info[4])
- menu_name = opts.delete('menu_name')
- menu_config = opts.delete('menu_config') || {}
- menu_opts.update(_symbolkey2str(menu_config))
- end
- submenu = _create_menu(menu, item_info[1], menu_name,
- tearoff, menu_opts)
- options['menu'] = submenu
- end
-
- else
- # command
- item_type = 'command'
- options['command'] = item_info[1] if item_info[1]
- end
-
- options['underline'] = item_info[2] if item_info[2]
- options['accelerator'] = item_info[3] if item_info[3]
- if item_info[4] && item_info[4].kind_of?(Hash)
- opts = _symbolkey2str(item_info[4])
- if item_type == 'cascade'
- opts.delete('menu_name')
- opts.delete('menu_config')
- end
- options.update(opts)
- end
- menu.add(item_type, options)
+ options = orig_opts.dup
+
+ options['label'] = item_info[0] if item_info[0]
+
+ case item_info[1]
+ when TkVariable
+ # checkbutton
+ item_type = 'checkbutton'
+ options['variable'] = item_info[1]
+ options['onvalue'] = true
+ options['offvalue'] = false
+
+ when Array
+ # radiobutton or cascade
+ if item_info[1][0].kind_of?(TkVariable)
+ # radiobutton
+ item_type = 'radiobutton'
+ options['variable'] = item_info[1][0]
+ options['value'] = item_info[1][1] if item_info[1][1]
+
+ else
+ # cascade
+ item_type = 'cascade'
+ menu_opts = orig_opts.dup
+ if item_info[4] && item_info[4].kind_of?(Hash)
+ opts = _symbolkey2str(item_info[4])
+ menu_name = opts.delete('menu_name')
+ menu_config = opts.delete('menu_config') || {}
+ menu_opts.update(_symbolkey2str(menu_config))
+ end
+ submenu = _create_menu(menu, item_info[1], menu_name,
+ tearoff, menu_opts)
+ options['menu'] = submenu
+ end
+
+ else
+ # command
+ item_type = 'command'
+ options['command'] = item_info[1] if item_info[1]
+ end
+
+ options['underline'] = item_info[2] if item_info[2]
+ options['accelerator'] = item_info[3] if item_info[3]
+ if item_info[4] && item_info[4].kind_of?(Hash)
+ opts = _symbolkey2str(item_info[4])
+ if item_type == 'cascade'
+ opts.delete('menu_name')
+ opts.delete('menu_config')
+ end
+ options.update(opts)
+ end
+ menu.add(item_type, options)
elsif /^-+$/ =~ item_info
- menu.add('separator')
+ menu.add('separator')
else
- menu.add('command', 'label' => item_info)
+ menu.add('command', 'label' => item_info)
end
end
@@ -150,8 +150,8 @@ module TkMenuSpec
return true
else
begin
- parent.cget('menu')
- return true
+ parent.cget('menu')
+ return true
rescue
end
end
@@ -192,22 +192,22 @@ module TkMenuSpec
menu_name = nil
if btn_info.kind_of?(Hash)
- keys.update(_symbolkey2str(btn_info))
- menu_name = keys.delete('menu_name')
- keys['label'] = keys.delete('text') if keys.key?('text')
+ keys.update(_symbolkey2str(btn_info))
+ menu_name = keys.delete('menu_name')
+ keys['label'] = keys.delete('text') if keys.key?('text')
elsif btn_info.kind_of?(Array)
- keys['label'] = btn_info[0] if btn_info[0]
- keys['underline'] = btn_info[1] if btn_info[1]
- if btn_info[2]&&btn_info[2].kind_of?(Hash)
- keys.update(_symbolkey2str(btn_info[2]))
- menu_name = keys.delete('menu_name')
- end
+ keys['label'] = btn_info[0] if btn_info[0]
+ keys['underline'] = btn_info[1] if btn_info[1]
+ if btn_info[2]&&btn_info[2].kind_of?(Hash)
+ keys.update(_symbolkey2str(btn_info[2]))
+ menu_name = keys.delete('menu_name')
+ end
else
- keys = {:label=>btn_info}
+ keys = {:label=>btn_info}
end
menu = _create_menu(mbar, menu_info[1..-1], menu_name,
- tearoff, default_opts)
+ tearoff, default_opts)
menu.tearoff(tearoff)
keys['menu'] = menu
@@ -222,27 +222,27 @@ module TkMenuSpec
menu_name = nil
if btn_info.kind_of?(Hash)
- keys.update(_symbolkey2str(btn_info))
- menu_name = keys.delete('menu_name')
- keys['text'] = keys.delete('label') if keys.key?('label')
- mbtn.configure(keys)
+ keys.update(_symbolkey2str(btn_info))
+ menu_name = keys.delete('menu_name')
+ keys['text'] = keys.delete('label') if keys.key?('label')
+ mbtn.configure(keys)
elsif btn_info.kind_of?(Array)
- mbtn.configure('text', btn_info[0]) if btn_info[0]