summaryrefslogtreecommitdiff
path: root/ext/tk/sample
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-21 17:56:38 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-21 17:56:38 +0000
commit6c650f35f90c902a6d3c2990206da8cef1ce48cb (patch)
tree7a73c7036d576a6468bfe23a7bf203817418a01c /ext/tk/sample
parent39c4d6928ba085665b5a02d9386091b81745e02a (diff)
* ext/tk/lib/tk.rb: temporary patch for trouble on TkAqua (> Tk8.4.9).
* ext/tk/sample/demos-jp/widget: set encoding to a demo-code string to avoid garbled text on the Code Window. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample')
-rw-r--r--ext/tk/sample/demos-jp/widget20
1 files changed, 6 insertions, 14 deletions
diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget
index dad85c2..132953f 100644
--- a/ext/tk/sample/demos-jp/widget
+++ b/ext/tk/sample/demos-jp/widget
@@ -882,18 +882,12 @@ def showCode1(demo)
$code_window.title("Demo code: #{file}")
$code_window.iconname(file)
-# fid = open(file, 'r')
- fid = open([$demo_dir, file].join(File::Separator), 'r')
+ code = open([$demo_dir, file].join(File::Separator), 'r'){|fid| fid.read }
$code_text.delete('1.0', 'end')
- #$code_text.insert('1.0', `cat #{file}`)
- $code_text.insert('1.0', fid.read)
- #$code_mark = TkTextMark.new($code_text, '1.0')
- #$code_text.set_insert('1.0')
+ code.force_encoding('EUC-JP') if defined?(::Encoding.default_external)
+ $code_text.insert('1.0', code)
TkTextMarkInsert.new($code_text,'1.0')
-
$set_linenum.call($code_text)
-
- fid.close
end
def showCode2(demo)
@@ -974,14 +968,12 @@ def showCode2(demo)
$code_window.title("Demo code: #{file}")
$code_window.iconname(file)
- fid = open([$demo_dir, file].join(File::Separator), 'r')
+ code = open([$demo_dir, file].join(File::Separator), 'r'){|fid| fid.read }
$code_text.delete('1.0', 'end')
- $code_text.insert('1.0', fid.read)
+ code.force_encoding('EUC-JP') if defined?(::Encoding.default_external)
+ $code_text.insert('1.0', code)
TkTextMarkInsert.new($code_text,'1.0')
-
$set_linenum.call($code_text)
-
- fid.close
end
if $tk_major_ver < 8