diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-07-09 08:40:46 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-07-09 08:40:46 +0000 |
commit | 3c1d5b89c33546028fce534546b8e356369ee231 (patch) | |
tree | fb658b101bf9a045c488663f2cbc6b3a178bbd3e /lib/tktext.rb | |
parent | 528b1f5237bc4e031228a27c00cdd679319f2472 (diff) |
1.1b9_30
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/tktext.rb')
-rw-r--r-- | lib/tktext.rb | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/lib/tktext.rb b/lib/tktext.rb index 74fec8c953..7b5cea5c72 100644 --- a/lib/tktext.rb +++ b/lib/tktext.rb @@ -6,6 +6,11 @@ require 'tk.rb' class TkText<TkTextWin + WidgetClassName = 'Text'.freeze + TkClassBind::WidgetClassNameTBL[WidgetClassName] = self + def self.to_eval + WidgetClassName + end include Scrollable def create_self tk_call 'text', @path @@ -115,20 +120,36 @@ class TkText<TkTextWin tk_send 'tag', 'add', tag, index1, index2 end - def tag_bind(tag, seq, cmd=Proc.new, args=nil) - seq = context.join("><") if seq.kind_of? Array - if /,/ =~ seq - seq = seq.split(/\s*,\s*/).join("><") - end + def _tag_bind_core(mode, tag, seq, cmd=Proc.new, args=nil) id = install_bind(cmd, args) - tk_send 'tag', 'bind', tag, "<#{seq}>", id + tk_send 'tag', 'bind', tag, "<#{tk_event_sequence(seq)}>", mode + id # _addcmd cmd end + private :_tag_bind_core - def tag_bindinfo(tag) - tk_split_list(tk_send('tag', 'bind', tag)).filter{|seq| - seq.tr('<>',' ').strip.gsub(/\s+/,',') - } + def tag_bind(tag, seq, cmd=Proc.new, args=nil) + _tag_bind_core('', tag, seq, cmd=Proc.new, args=nil) + end + + def tag_bind_append(tag, seq, cmd=Proc.new, args=nil) + _tag_bind_core('+', tag, seq, cmd=Proc.new, args=nil) + end + + def tag_bindinfo(tag, context=nil) + if context + (tk_send('tag', 'bind', tag, + "<#{tk_event_sequence(context)}>")).collect{|cmdline| + if cmdline =~ /^rb_out (c\d+)\s+(.*)$/ + [Tk_CMDTBL[$1], $2] + else + cmdline + end + } + else + tk_split_list(tk_send('tag', 'bind', tag)).filter{|seq| + seq[1..-2].gsub(/></,',') + } + end end def tag_cget(tag, key) @@ -357,19 +378,26 @@ class TkTextTag<TkObject end def bind(seq, cmd=Proc.new, args=nil) - seq = context.join("><") if seq.kind_of? Array - if /,/ =~ seq - seq = seq.split(/\s*,\s*/).join("><") - end id = install_bind(cmd, args) - tk_call @t.path, 'tag', 'bind', @id, "<#{seq}>", id + tk_call @t.path, 'tag', 'bind', @id, "<#{tk_event_sequence(seq)}>", id # @t._addcmd cmd end - def bindinfo - tk_split_list(tk_call(@t.path, 'tag', 'bind', @id)).filter{|seq| - seq.tr('<>',' ').strip.gsub(/\s+/,',') - } + def bindinfo(context=nil) + if context + (tk_call(@t.path, 'tag', 'bind', @id, + "<#{tk_event_sequence(context)}>")).collect{|cmdline| + if cmdline =~ /^rb_out (c\d+)\s+(.*)$/ + [Tk_CMDTBL[$1], $2] + else + cmdline + end + } + else + tk_split_list(tk_call(@t.path, 'tag', 'bind', @id)).filter{|seq| + seq[1..-2].gsub(/></,',') + } + end end def raise(above=None) |