summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk/text.rb
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-29 15:54:32 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-29 15:54:32 +0000
commitffb051a4ec199b9e90f5e4496d3b8bc312fe018a (patch)
treec5f5cf3df2d4627cc1f5d3aa69ae0fcc53a4f57c /ext/tk/lib/tk/text.rb
parent29343350862ac83f94dcab6016d6dc73c666be5a (diff)
* ext/tcltklib/tcltklib.c (ip_init): bug fix
* ext/tk/tkutil.c (get_eval_string_core): accept a Regexp object * ext/tk/lib/multi-tk.rb: fix bug on 'exit' operation * ext/tk/lib/tk/text.rb: 'tksearch' accepts a Regexp object as a matting pattern argument git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tk/text.rb')
-rw-r--r--ext/tk/lib/tk/text.rb34
1 files changed, 31 insertions, 3 deletions
diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb
index c05e3f03ad..123f49af03 100644
--- a/ext/tk/lib/tk/text.rb
+++ b/ext/tk/lib/tk/text.rb
@@ -971,12 +971,25 @@ class TkText<TkTextWin
# call 'search' subcommand of text widget
# args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
# If <pattern> is regexp, then it must be a regular expression of Tcl
+ nocase = false
if args[0].kind_of?(Array)
- opts = args.shift.collect{|opt| '-' + opt.to_s }
+ opts = args.shift.collect{|opt|
+ s_opt = opt.to_s
+ nocase = true if s_opt == 'nocase'
+ '-' + s_opt
+ }
else
opts = []
end
+ if args[0].kind_of?(Regexp)
+ regexp = args.shift
+ if !nocase && (regexp.options & Regexp::IGNORECASE) != 0
+ opts << '-nocase'
+ end
+ args.unshift(regexp.source)
+ end
+
opts << '--'
ret = tk_send('search', *(opts + args))
@@ -991,13 +1004,28 @@ class TkText<TkTextWin
# call 'search' subcommand of text widget
# args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
# If <pattern> is regexp, then it must be a regular expression of Tcl
+ nocase = false
if args[0].kind_of?(Array)
- opts = args.shift.collect{|opt| '-' + opt.to_s }
+ opts = args.shift.collect{|opt|
+ s_opt = opt.to_s
+ nocase = true if s_opt == 'nocase'
+ '-' + s_opt
+ }
else
opts = []
end
- opts << '-count' << args.shift << '--'
+ opts << '-count' << args.shift
+
+ if args[0].kind_of?(Regexp)
+ regexp = args.shift
+ if !nocase && (regexp.options & Regexp::IGNORECASE) != 0
+ opts << '-nocase'
+ end
+ args.unshift(regexp.source)
+ end
+
+ opts << '--'
ret = tk_send('search', *(opts + args))
if ret == ""