1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/tk/sample/demos-jp/bind.rb

121 lines
3.8 KiB
Ruby
Raw Normal View History

* encoding.c: provide basic features for M17N. * parse.y: encoding aware parsing. * parse.y (pragma_encoding): encoding specification pragma. * parse.y (rb_intern3): encoding specified symbols. * string.c (rb_str_length): length based on characters. for older behavior, bytesize method added. * string.c (rb_str_index_m): index based on characters. rindex as well. * string.c (succ_char): encoding aware succeeding string. * string.c (rb_str_reverse): reverse based on characters. * string.c (rb_str_inspect): encoding aware string description. * string.c (rb_str_upcase_bang): encoding aware case conversion. downcase, capitalize, swapcase as well. * string.c (rb_str_tr_bang): tr based on characters. delete, squeeze, tr_s, count as well. * string.c (rb_str_split_m): split based on characters. * string.c (rb_str_each_line): encoding aware each_line. * string.c (rb_str_each_char): added. iteration based on characters. * string.c (rb_str_strip_bang): encoding aware whitespace stripping. lstrip, rstrip as well. * string.c (rb_str_justify): encoding aware justifying (ljust, rjust, center). * string.c (str_encoding): get encoding attribute from a string. * re.c (rb_reg_initialize): encoding aware regular expression * sprintf.c (rb_str_format): formatting (i.e. length count) based on characters. * io.c (rb_io_getc): getc to return one-character string. for older behavior, getbyte method added. * ext/stringio/stringio.c (strio_getc): ditto. * io.c (rb_io_ungetc): allow pushing arbitrary string at the current reading point. * ext/stringio/stringio.c (strio_ungetc): ditto. * ext/strscan/strscan.c: encoding support. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 23:29:39 -04:00
# -*- coding: euc-jp -*-
#
# text (tag bindings) widget demo (called by 'widget')
#
# toplevel widget <20><>¸<EFBFBD>ߤ<EFBFBD><DFA4><EFBFBD><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if defined?($bind_demo) && $bind_demo
$bind_demo.destroy
$bind_demo = nil
end
# demo <20>Ѥ<EFBFBD> toplevel widget <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$bind_demo = TkToplevel.new {|w|
title("Text Demonstration - Tag Bindings")
iconname("bind")
positionWindow(w)
}
# frame <20><><EFBFBD><EFBFBD>
TkFrame.new($bind_demo) {|frame|
TkButton.new(frame) {
#text 'λ<><CEBB>'
text '<27>Ĥ<EFBFBD><C4A4><EFBFBD>'
command proc{
tmppath = $bind_demo
$bind_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text '<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>'
command proc{showCode 'bind'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# bind <20>ѥ᥽<D1A5>å<EFBFBD>
def tag_binding_for_bind_demo(tag, enter_style, leave_style)
tag.bind('Any-Enter', proc{tag.configure enter_style})
tag.bind('Any-Leave', proc{tag.configure leave_style})
end
# text <20><><EFBFBD><EFBFBD>
TkText.new($bind_demo){|t|
# <20><><EFBFBD><EFBFBD>
setgrid 'true'
width 60
height 24
font $font
wrap 'word'
TkScrollbar.new($bind_demo) {|s|
pack('side'=>'right', 'fill'=>'y')
command proc{|*args| t.yview(*args)}
t.yscrollcommand proc{|first,last| s.set first,last}
}
pack('expand'=>'yes', 'fill'=>'both')
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if TkWinfo.depth($root).to_i > 1
tagstyle_bold = {'background'=>'#43ce80', 'relief'=>'raised',
'borderwidth'=>1}
tagstyle_normal = {'background'=>'', 'relief'=>'flat'}
else
tagstyle_bold = {'foreground'=>'white', 'background'=>'black'}
tagstyle_normal = {'foreground'=>'', 'background'=>''}
end
# <20>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
insert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FBD><EBA5B5><EFBFBD>ץ롣', (d1 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end', '2. <20><>ñ<EFBFBD><C3B1> 2<><32><EFBFBD><EFBFBD><EFBFBD>Υץ<CEA5><D7A5>åȡ<C3A5><C8A1>ǡ<EFBFBD><C7A1><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ư<EFBFBD><C6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>롣', (d2 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end', '3. <20>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>Υ<EFBFBD><CEA5>󥫡<EFBFBD><F3A5ABA1>ȹ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>',
(d3 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end', '4. <20><EFBFBD>󥢥<EFBFBD><F3A5A2A5>ƥ<EFBFBD><C6A5>Τ<EFBFBD><CEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭ<EFBFBD>η<EFBFBD><CEB7>Υ<EFBFBD><CEA5>ǥ<EFBFBD><C7A5><EFBFBD><EFBFBD><EFBFBD>',
(d4 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end', '5. <20><><EFBFBD>֥<EFBFBD><D6A5>ȥåפ<C3A5><D7A4>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>뤿<EFBFBD><EBA4BF><EFBFBD>ε<EFBFBD>ǽ<EFBFBD>Ĥ<EFBFBD><C4A4>Υ<CEA5><EFBFBD><E9A1BC>',
(d5 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end',
'6. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Х<EFBFBD><D0A5><EFBFBD><EFBFBD>ɤ<EFBFBD><C9A4><EFBFBD><EFBFBD>äƥ<C3A4><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBA4B9><EFBFBD>Τ<EFBFBD><CEA4>򼨤<EFBFBD><F2BCA8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åɡ<C3A5>',
(d6 = TkTextTag.new(t)) )
# binding
[d1, d2, d3, d4, d5, d6].each{|tag|
tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal)
}
d1.bind('1',
proc{
eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`)
})
d2.bind('1',
proc{
eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`)
})
d3.bind('1',
proc{
eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`)
})
d4.bind('1',
proc{
eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`)
})
d5.bind('1',
proc{
eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`)
})
d6.bind('1',
proc{
eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`)
})
TkTextMarkInsert.new(t, '0.0')
configure('state','disabled')
}