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/sayings.rb

102 lines
2.9 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-25 03:29:39 +00:00
# -*- coding: euc-jp -*-
#
# listbox widget demo 'sayings' (called by 'widget')
#
# toplevel widget <20><>¸<EFBFBD>ߤ<EFBFBD><DFA4><EFBFBD><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if defined?($sayings_demo) && $sayings_demo
$sayings_demo.destroy
$sayings_demo = nil
end
# demo <20>Ѥ<EFBFBD> toplevel widget <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$sayings_demo = TkToplevel.new {|w|
title("Listbox Demonstration (well-known sayings)")
iconname("sayings")
positionWindow(w)
}
# label <20><><EFBFBD><EFBFBD>
msg = TkLabel.new($sayings_demo) {
font $font
wraplength '4i'
justify 'left'
text "<EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD>ȥܥå<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤϤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʳʸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>äƤ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ򥹥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τϥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD>Ǥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥܥå<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǥޥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υܥ<EFBFBD><EFBFBD><EFBFBD>2(<28><><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD>)<29>򲡤<EFBFBD><F2B2A1A4><EFBFBD><EFBFBD>ޤޥɥ<DEA5><C9A5>å<EFBFBD><C3A5><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD>"
}
msg.pack('side'=>'top')
# frame <20><><EFBFBD><EFBFBD>
TkFrame.new($sayings_demo) {|frame|
TkButton.new(frame) {
#text 'λ<><CEBB>'
text '<27>Ĥ<EFBFBD><C4A4><EFBFBD>'
command proc{
tmppath = $sayings_demo
$sayings_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text '<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>'
command proc{showCode 'sayings'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame <20><><EFBFBD><EFBFBD>
sayings_lbox = nil
TkFrame.new($sayings_demo, 'borderwidth'=>10) {|w|
sv = TkScrollbar.new(w)
sh = TkScrollbar.new(w, 'orient'=>'horizontal')
sayings_lbox = TkListbox.new(w) {
setgrid 1
width 20
height 10
yscrollcommand proc{|first,last| sv.set first,last}
xscrollcommand proc{|first,last| sh.set first,last}
}
sv.command(proc{|*args| sayings_lbox.yview(*args)})
sh.command(proc{|*args| sayings_lbox.xview(*args)})
if $tk_version =~ /^4\.[01]/
sv.pack('side'=>'right', 'fill'=>'y')
sh.pack('side'=>'bottom', 'fill'=>'x')
sayings_lbox.pack('expand'=>'yes', 'fill'=>'y')
else
sayings_lbox.grid('row'=>0, 'column'=>0,
'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
sv.grid('row'=>0, 'column'=>1,
'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
sh.grid('row'=>1, 'column'=>0,
'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
TkGrid.rowconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
TkGrid.columnconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
end
}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
sayings_lbox.insert(0,
"Waste not, want not",
"Early to bed and early to rise makes a man healthy, wealthy, and wise",
"Ask not what your country can do for you, ask what you can do for your country",
"I shall return",
"NOT",
"A picture is worth a thousand words",
"User interfaces are hard to build",
"Thou shalt not steal",
"A penny for your thoughts",
"Fool me once, shame on you; fool me twice, shame on me",
"Every cloud has a silver lining",
"Where there's smoke there's fire",
"It takes one to know one",
"Curiosity killed the cat",
"Take this job and shove it",
"Up a creek without a paddle",
"I'm mad as hell and I'm not going to take it any more",
"An apple a day keeps the doctor away",
"Don't look a gift horse in the mouth"
)