summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk/text.rb
diff options
context:
space:
mode:
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 == ""