Fossil SCM
Add the ability to search by NoCase, RegExp, or WholeWord.
Commit
2a5de7ea2e119a66b92cc6103325a8285eb4d09b
Parent
cea60811508f85a…
1 file changed
+14
-4
+14
-4
| --- src/diff.tcl | ||
| +++ src/diff.tcl | ||
| @@ -389,11 +389,15 @@ | ||
| 389 | 389 | pack .bb.sframe.e -side left -fill y -expand 1 |
| 390 | 390 | ::ttk::button .bb.sframe.nx -text \u2193 -width 1 \ |
| 391 | 391 | -command {searchNext -forwards +1 1.0 end} |
| 392 | 392 | ::ttk::button .bb.sframe.pv -text \u2191 -width 1 \ |
| 393 | 393 | -command {searchNext -backwards -1 end 1.0} |
| 394 | - pack .bb.sframe.nx .bb.sframe.pv -side left | |
| 394 | + tk_optionMenu .bb.sframe.typ ::search_type \ | |
| 395 | + Exact {No Case} {RegExp} {Whole Word} | |
| 396 | + .bb.sframe.typ config -width 10 | |
| 397 | + set ::search_type Exact | |
| 398 | + pack .bb.sframe.nx .bb.sframe.pv .bb.sframe.typ -side left | |
| 395 | 399 | } |
| 396 | 400 | pack .bb.sframe -side left |
| 397 | 401 | } |
| 398 | 402 | } |
| 399 | 403 | proc searchNext {direction incr start stop} { |
| @@ -402,22 +406,28 @@ | ||
| 402 | 406 | set w $::search |
| 403 | 407 | if {"$w"==".txtA"} {set other .txtB} {set other .txtA} |
| 404 | 408 | if {[lsearch [$w mark names] search]<0} { |
| 405 | 409 | $w mark set search $start |
| 406 | 410 | } |
| 407 | - set idx [$w search -count count $direction -- \ | |
| 411 | + switch $::search_type { | |
| 412 | + Exact {set st -exact} | |
| 413 | + {No Case} {set st -nocase} | |
| 414 | + {RegExp} {set st -regexp} | |
| 415 | + {Whole Word} {set st -regexp; set pattern \\y$pattern\\y} | |
| 416 | + } | |
| 417 | + set idx [$w search -count count $direction $st -- \ | |
| 408 | 418 | $pattern "search $incr chars" $stop] |
| 409 | 419 | if {"$idx"==""} { |
| 410 | 420 | set this $w |
| 411 | 421 | set w $other |
| 412 | 422 | set other $this |
| 413 | - set idx [$w search -count count $direction -- $pattern $start $stop] | |
| 423 | + set idx [$w search -count count $direction $st -- $pattern $start $stop] | |
| 414 | 424 | if {"$idx"==""} { |
| 415 | 425 | set this $w |
| 416 | 426 | set w $other |
| 417 | 427 | set other $this |
| 418 | - set idx [$w search -count count $direction -- $pattern $start $stop] | |
| 428 | + set idx [$w search -count count $direction $st -- $pattern $start $stop] | |
| 419 | 429 | } |
| 420 | 430 | } |
| 421 | 431 | $w tag remove search 1.0 end |
| 422 | 432 | $w mark unset search |
| 423 | 433 | $other tag remove search 1.0 end |
| 424 | 434 |
| --- src/diff.tcl | |
| +++ src/diff.tcl | |
| @@ -389,11 +389,15 @@ | |
| 389 | pack .bb.sframe.e -side left -fill y -expand 1 |
| 390 | ::ttk::button .bb.sframe.nx -text \u2193 -width 1 \ |
| 391 | -command {searchNext -forwards +1 1.0 end} |
| 392 | ::ttk::button .bb.sframe.pv -text \u2191 -width 1 \ |
| 393 | -command {searchNext -backwards -1 end 1.0} |
| 394 | pack .bb.sframe.nx .bb.sframe.pv -side left |
| 395 | } |
| 396 | pack .bb.sframe -side left |
| 397 | } |
| 398 | } |
| 399 | proc searchNext {direction incr start stop} { |
| @@ -402,22 +406,28 @@ | |
| 402 | set w $::search |
| 403 | if {"$w"==".txtA"} {set other .txtB} {set other .txtA} |
| 404 | if {[lsearch [$w mark names] search]<0} { |
| 405 | $w mark set search $start |
| 406 | } |
| 407 | set idx [$w search -count count $direction -- \ |
| 408 | $pattern "search $incr chars" $stop] |
| 409 | if {"$idx"==""} { |
| 410 | set this $w |
| 411 | set w $other |
| 412 | set other $this |
| 413 | set idx [$w search -count count $direction -- $pattern $start $stop] |
| 414 | if {"$idx"==""} { |
| 415 | set this $w |
| 416 | set w $other |
| 417 | set other $this |
| 418 | set idx [$w search -count count $direction -- $pattern $start $stop] |
| 419 | } |
| 420 | } |
| 421 | $w tag remove search 1.0 end |
| 422 | $w mark unset search |
| 423 | $other tag remove search 1.0 end |
| 424 |
| --- src/diff.tcl | |
| +++ src/diff.tcl | |
| @@ -389,11 +389,15 @@ | |
| 389 | pack .bb.sframe.e -side left -fill y -expand 1 |
| 390 | ::ttk::button .bb.sframe.nx -text \u2193 -width 1 \ |
| 391 | -command {searchNext -forwards +1 1.0 end} |
| 392 | ::ttk::button .bb.sframe.pv -text \u2191 -width 1 \ |
| 393 | -command {searchNext -backwards -1 end 1.0} |
| 394 | tk_optionMenu .bb.sframe.typ ::search_type \ |
| 395 | Exact {No Case} {RegExp} {Whole Word} |
| 396 | .bb.sframe.typ config -width 10 |
| 397 | set ::search_type Exact |
| 398 | pack .bb.sframe.nx .bb.sframe.pv .bb.sframe.typ -side left |
| 399 | } |
| 400 | pack .bb.sframe -side left |
| 401 | } |
| 402 | } |
| 403 | proc searchNext {direction incr start stop} { |
| @@ -402,22 +406,28 @@ | |
| 406 | set w $::search |
| 407 | if {"$w"==".txtA"} {set other .txtB} {set other .txtA} |
| 408 | if {[lsearch [$w mark names] search]<0} { |
| 409 | $w mark set search $start |
| 410 | } |
| 411 | switch $::search_type { |
| 412 | Exact {set st -exact} |
| 413 | {No Case} {set st -nocase} |
| 414 | {RegExp} {set st -regexp} |
| 415 | {Whole Word} {set st -regexp; set pattern \\y$pattern\\y} |
| 416 | } |
| 417 | set idx [$w search -count count $direction $st -- \ |
| 418 | $pattern "search $incr chars" $stop] |
| 419 | if {"$idx"==""} { |
| 420 | set this $w |
| 421 | set w $other |
| 422 | set other $this |
| 423 | set idx [$w search -count count $direction $st -- $pattern $start $stop] |
| 424 | if {"$idx"==""} { |
| 425 | set this $w |
| 426 | set w $other |
| 427 | set other $this |
| 428 | set idx [$w search -count count $direction $st -- $pattern $start $stop] |
| 429 | } |
| 430 | } |
| 431 | $w tag remove search 1.0 end |
| 432 | $w mark unset search |
| 433 | $other tag remove search 1.0 end |
| 434 |