git-gui: add regexp search mode to the searchbar
It's off by default, but can be enabled via the config gui.search.regexp. Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Bert Wesarg committed
Oct 14, 2011 at 10:14 UTC
e9144d5555133a76addb4829dca0e7a9684e1ed4
1 file changed
+11
-1
lib/search.tcl
+11
-1
@@ -7,6 +7,8 @@ field w
7
field ctext
8
9
field searchstring {}
10
+field regexpsearch
11
+field default_regexpsearch
12
field casesensitive
13
field default_casesensitive
14
field searchdirn -forwards
@@ -19,6 +21,7 @@ constructor new {i_w i_text args} {
21
set w $i_w
22
set ctext $i_text
23
24
+ set default_regexpsearch [is_config_true gui.search.regexp]
25
if {[is_config_true gui.search.smartcase]} {
26
set default_casesensitive 0
27
} else {
@@ -30,10 +33,13 @@ constructor new {i_w i_text args} {
33
entry $w.ent -textvariable ${__this}::searchstring -background lightgreen
34
${NS}::button $w.bn -text [mc Next] -command [cb find_next]
35
${NS}::button $w.bp -text [mc Prev] -command [cb find_prev]
33
- ${NS}::checkbutton $w.cs -text [mc Case-Sensitive] \
36
+ ${NS}::checkbutton $w.re -text [mc RegExp] \
37
+ -variable ${__this}::regexpsearch -command [cb _incrsearch]
38
+ ${NS}::checkbutton $w.cs -text [mc Case] \
39
-variable ${__this}::casesensitive -command [cb _incrsearch]
40
pack $w.l -side left
41
pack $w.cs -side right
42
+ pack $w.re -side right
43
pack $w.bp -side right
44
pack $w.bn -side right
45
pack $w.ent -side left -expand 1 -fill x
@@ -52,6 +58,7 @@ constructor new {i_w i_text args} {
58
method show {} {
59
if {![visible $this]} {
60
grid $w
61
+ set regexpsearch $default_regexpsearch
62
set casesensitive $default_casesensitive
63
}
64
focus -force $w.ent
@@ -106,6 +113,9 @@ method _do_search {start {mlenvar {}} {dir {}} {endbound {}}} {
113
upvar $mlenvar mlen
114
lappend cmd -count mlen
115
}
116
+ if {$regexpsearch} {
117
+ lappend cmd -regexp
118
+ }
119
if {!$casesensitive} {
120
lappend cmd -nocase
121
}