diff options
author | Bert Wesarg <bert.wesarg@googlemail.com> | 2011-10-20 21:27:27 +0200 |
---|---|---|
committer | Pat Thoyts <patthoyts@users.sourceforge.net> | 2011-10-21 22:28:23 +0100 |
commit | f9ace9e63d1ea0ce55b8239971b3c99d32dd4692 (patch) | |
tree | d5e6df563385e0164cb13f84e1f5c71c127fbc44 | |
parent | git-gui: set suitable extended window manager hints. (diff) | |
download | tgif-f9ace9e63d1ea0ce55b8239971b3c99d32dd4692.tar.xz |
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>
-rw-r--r-- | lib/search.tcl | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/search.tcl b/lib/search.tcl index 04a316bbb2..ef1e55521d 100644 --- a/lib/search.tcl +++ b/lib/search.tcl @@ -26,11 +26,20 @@ constructor new {i_w i_text args} { set ctext $i_text set default_regexpsearch [is_config_true gui.search.regexp] - set smartcase [is_config_true gui.search.smartcase] - if {$smartcase} { + switch -- [get_config gui.search.case] { + no { set default_casesensitive 0 - } else { + set smartcase 0 + } + smart { + set default_casesensitive 0 + set smartcase 1 + } + yes - + default { set default_casesensitive 1 + set smartcase 0 + } } set history [list] @@ -157,12 +166,10 @@ method _incrsearch {} { if {[catch {$ctext index anchor}]} { $ctext mark set anchor [_get_new_anchor $this] } - if {$smartcase} { - if {[regexp {[[:upper:]]} $searchstring]} { + if {$searchstring ne {}} { + if {$smartcase && [regexp {[[:upper:]]} $searchstring]} { set casesensitive 1 } - } - if {$searchstring ne {}} { set here [_do_search $this anchor mlen] if {$here ne {}} { $ctext see $here @@ -175,6 +182,9 @@ method _incrsearch {} { #$w.ent configure -background lightpink $w.ent state pressed } + } elseif {$smartcase} { + # clearing the field resets the smart case detection + set casesensitive 0 } } |