git-gui: use a tristate to control the case mode in the searchbar

The config is now called gui.search.case and can have the three values: no/yes/smart. yes is the default. It also resets the case detection in smart mode, when the entry field was cleared by the use. Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>

Bert Wesarg committed Oct 20, 2011 at 21:27 UTC f9ace9e63d1ea0ce55b8239971b3c99d32dd4692
1 file changed +17 -7
lib/search.tcl
+17 -7
@@ -26,11 +26,20 @@ constructor new {i_w i_text args} {
26 set ctext $i_text
27
28 set default_regexpsearch [is_config_true gui.search.regexp]
29 - set smartcase [is_config_true gui.search.smartcase]
30 - if {$smartcase} {
29 + switch -- [get_config gui.search.case] {
30 + no {
31 set default_casesensitive 0
32 - } else {
32 + set smartcase 0
33 + }
34 + smart {
35 + set default_casesensitive 0
36 + set smartcase 1
37 + }
38 + yes -
39 + default {
40 set default_casesensitive 1
41 + set smartcase 0
42 + }
43 }
44
45 set history [list]
@@ -157,12 +166,10 @@ method _incrsearch {} {
166 if {[catch {$ctext index anchor}]} {
167 $ctext mark set anchor [_get_new_anchor $this]
168 }
160 - if {$smartcase} {
161 - if {[regexp {[[:upper:]]} $searchstring]} {
169 + if {$searchstring ne {}} {
170 + if {$smartcase && [regexp {[[:upper:]]} $searchstring]} {
171 set casesensitive 1
172 }
164 - }
165 - if {$searchstring ne {}} {
173 set here [_do_search $this anchor mlen]
174 if {$here ne {}} {
175 $ctext see $here
@@ -175,6 +182,9 @@ method _incrsearch {} {
182 #$w.ent configure -background lightpink
183 $w.ent state pressed
184 }
185 + } elseif {$smartcase} {
186 + # clearing the field resets the smart case detection
187 + set casesensitive 0
188 }
189 }
190