Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of git://repo.or.cz/git-gui

* 'master' of git://repo.or.cz/git-gui: (28 commits)
  git-gui 0.16
  git-gui: handle shell script text filters when loading for blame.
  git-gui: Set both 16x16 and 32x32 icons on X to pacify Xming.
  git-gui: added config gui.gcwarning to disable the gc hint message
  git-gui: set whitespace warnings appropriate to this project
  git-gui: don't warn for detached head when rebasing
  git-gui: make config gui.warndetachedcommit a boolean
  git-gui: add config value gui.diffopts for passing additional diff options
  git-gui: sort the numeric ansi codes
  git-gui: support underline style when parsing diff output
  git-gui: fix spelling error in sshkey.tcl
  git-gui: include the file path in guitools confirmation dialog
  git-gui: span widgets over the full file output area in the blame view
  git-gui: use a tristate to control the case mode in the searchbar
  git-gui: set suitable extended window manager hints.
  git-gui: fix display of path in browser title
  git-gui: enable the smart case sensitive search only if gui.search.smartcase is true
  git-gui: catch invalid or complete regular expressions and treat as no match.
  git-gui: theme the search and line-number entry fields on blame screen
  git-gui: include the number of untracked files to stage when asking the user
  ...
  • Loading branch information...
commit 73c6b3575bc638b7096ec913bd91193707e2265d 2 parents 57526fd + 942e6ba
Junio C Hamano authored December 13, 2011
1  git-gui/.gitattributes
... ...
@@ -1,3 +1,4 @@
  1
+*           whitespace=indent-with-non-tab,trailing-space,space-before-tab,tabwidth=4
1 2
 *           encoding=US-ASCII
2 3
 git-gui.sh  encoding=UTF-8
3 4
 /po/*.po    encoding=UTF-8
2  git-gui/GIT-VERSION-GEN
... ...
@@ -1,7 +1,7 @@
1 1
 #!/bin/sh
2 2
 
3 3
 GVF=GIT-VERSION-FILE
4  
-DEF_VER=0.13.GITGUI
  4
+DEF_VER=0.16.GITGUI
5 5
 
6 6
 LF='
7 7
 '
56  git-gui/git-gui.sh
@@ -299,7 +299,9 @@ proc is_config_true {name} {
299 299
 	global repo_config
300 300
 	if {[catch {set v $repo_config($name)}]} {
301 301
 		return 0
302  
-	} elseif {$v eq {true} || $v eq {1} || $v eq {yes}} {
  302
+	}
  303
+	set v [string tolower $v]
  304
+	if {$v eq {} || $v eq {true} || $v eq {1} || $v eq {yes} || $v eq {on}} {
303 305
 		return 1
304 306
 	} else {
305 307
 		return 0
@@ -310,7 +312,9 @@ proc is_config_false {name} {
310 312
 	global repo_config
311 313
 	if {[catch {set v $repo_config($name)}]} {
312 314
 		return 0
313  
-	} elseif {$v eq {false} || $v eq {0} || $v eq {no}} {
  315
+	}
  316
+	set v [string tolower $v]
  317
+	if {$v eq {false} || $v eq {0} || $v eq {no} || $v eq {off}} {
314 318
 		return 1
315 319
 	} else {
316 320
 		return 0
@@ -460,6 +464,35 @@ proc _which {what args} {
460 464
 	return {}
461 465
 }
462 466
 
  467
+# Test a file for a hashbang to identify executable scripts on Windows.
  468
+proc is_shellscript {filename} {
  469
+	if {![file exists $filename]} {return 0}
  470
+	set f [open $filename r]
  471
+	fconfigure $f -encoding binary
  472
+	set magic [read $f 2]
  473
+	close $f
  474
+	return [expr {$magic eq "#!"}]
  475
+}
  476
+
  477
+# Run a command connected via pipes on stdout.
  478
+# This is for use with textconv filters and uses sh -c "..." to allow it to
  479
+# contain a command with arguments. On windows we must check for shell
  480
+# scripts specifically otherwise just call the filter command.
  481
+proc open_cmd_pipe {cmd path} {
  482
+	global env
  483
+	if {![file executable [shellpath]]} {
  484
+		set exe [auto_execok [lindex $cmd 0]]
  485
+		if {[is_shellscript [lindex $exe 0]]} {
  486
+			set run [linsert [auto_execok sh] end -c "$cmd \"\$0\"" $path]
  487
+		} else {
  488
+			set run [concat $exe [lrange $cmd 1 end] $path]
  489
+		}
  490
+	} else {
  491
+		set run [list [shellpath] -c "$cmd \"\$0\"" $path]
  492
+	}
  493
+	return [open |$run r]
  494
+}
  495
+
463 496
 proc _lappend_nice {cmd_var} {
464 497
 	global _nice
465 498
 	upvar $cmd_var cmd
@@ -725,7 +758,10 @@ if {[is_Windows]} {
725 758
 		gitlogo put gray26  -to  5 15 11 16
726 759
 		gitlogo redither
727 760
 
728  
-		wm iconphoto . -default gitlogo
  761
+		image create photo gitlogo32 -width 32 -height 32
  762
+		gitlogo32 copy gitlogo -zoom 2 2
  763
+
  764
+		wm iconphoto . -default gitlogo gitlogo32
729 765
 	}
730 766
 }
731 767
 
@@ -846,6 +882,7 @@ set default_config(gui.fastcopyblame) false
846 882
 set default_config(gui.copyblamethreshold) 40
847 883
 set default_config(gui.blamehistoryctx) 7
848 884
 set default_config(gui.diffcontext) 5
  885
+set default_config(gui.diffopts) {}
849 886
 set default_config(gui.commitmsgwidth) 75
850 887
 set default_config(gui.newbranchtemplate) {}
851 888
 set default_config(gui.spellingdictionary) {}
@@ -859,6 +896,7 @@ set font_descs {
859 896
 	{fontui   font_ui   {mc "Main Font"}}
860 897
 	{fontdiff font_diff {mc "Diff/Console Font"}}
861 898
 }
  899
+set default_config(gui.stageuntracked) ask
862 900
 
863 901
 ######################################################################
864 902
 ##
@@ -1060,6 +1098,10 @@ git-version proc _parse_config {arr_name args} {
1060 1098
 				} else {
1061 1099
 					set arr($name) $value
1062 1100
 				}
  1101
+			} elseif {[regexp {^([^\n]+)$} $line line name]} {
  1102
+				# no value given, but interpreting them as
  1103
+				# boolean will be handled as true
  1104
+				set arr($name) {}
1063 1105
 			}
1064 1106
 		}
1065 1107
 	}
@@ -1075,6 +1117,10 @@ git-version proc _parse_config {arr_name args} {
1075 1117
 					} else {
1076 1118
 						set arr($name) $value
1077 1119
 					}
  1120
+				} elseif {[regexp {^([^=]+)$} $line line name]} {
  1121
+					# no value given, but interpreting them as
  1122
+					# boolean will be handled as true
  1123
+					set arr($name) {}
1078 1124
 				}
1079 1125
 			}
1080 1126
 			close $fd_rc
@@ -2474,6 +2520,7 @@ proc toggle_or_diff {w x y} {
2474 2520
 				[concat $after [list ui_ready]]
2475 2521
 		}
2476 2522
 	} else {
  2523
+		set selected_paths($path) 1
2477 2524
 		show_diff $path $w $lno
2478 2525
 	}
2479 2526
 }
@@ -3362,6 +3409,7 @@ foreach {n c} {0 black 1 red4 2 green4 3 yellow4 4 blue4 5 magenta4 6 cyan4 7 gr
3362 3409
 	$ui_diff tag configure clri3$n -background $c
3363 3410
 }
3364 3411
 $ui_diff tag configure clr1 -font font_diffbold
  3412
+$ui_diff tag configure clr4 -underline 1
3365 3413
 
3366 3414
 $ui_diff tag conf d_info -foreground blue -font font_diffbold
3367 3415
 
@@ -3878,7 +3926,7 @@ after 1 {
3878 3926
 		$ui_comm configure -state disabled -background gray
3879 3927
 	}
3880 3928
 }
3881  
-if {[is_enabled multicommit]} {
  3929
+if {[is_enabled multicommit] && ![is_config_false gui.gcwarning]} {
3882 3930
 	after 1000 hint_gc
3883 3931
 }
3884 3932
 if {[is_enabled retcode]} {
29  git-gui/lib/blame.tcl
@@ -219,7 +219,8 @@ constructor new {i_commit i_path i_jump} {
219 219
 	eval grid $w_columns $w.file_pane.out.sby -sticky nsew
220 220
 	grid conf \
221 221
 		$w.file_pane.out.sbx \
222  
-		-column [expr {[llength $w_columns] - 1}] \
  222
+		-column 0 \
  223
+		-columnspan [expr {[llength $w_columns] + 1}] \
223 224
 		-sticky we
224 225
 	grid columnconfigure \
225 226
 		$w.file_pane.out \
@@ -229,12 +230,14 @@ constructor new {i_commit i_path i_jump} {
229 230
 
230 231
 	set finder [::searchbar::new \
231 232
 		$w.file_pane.out.ff $w_file \
232  
-		-column [expr {[llength $w_columns] - 1}] \
  233
+		-column 0 \
  234
+		-columnspan [expr {[llength $w_columns] + 1}] \
233 235
 		]
234 236
 
235 237
 	set gotoline [::linebar::new \
236 238
 		$w.file_pane.out.lf $w_file \
237  
-		-column [expr {[llength $w_columns] - 1}] \
  239
+		-column 0 \
  240
+		-columnspan [expr {[llength $w_columns] + 1}] \
238 241
 		]
239 242
 
240 243
 	set w_cviewer $w.file_pane.cm.t
@@ -473,14 +476,7 @@ method _load {jump} {
473 476
 	}
474 477
 	if {$commit eq {}} {
475 478
 		if {$do_textconv ne 0} {
476  
-			# Run textconv with sh -c "..." to allow it to
477  
-			# contain command + arguments. On windows, just
478  
-			# call the filter command.
479  
-			if {![file executable [shellpath]]} {
480  
-				set fd [open |[linsert $textconv end $path] r]
481  
-			} else {
482  
-				set fd [open |[list [shellpath] -c "$textconv \"\$0\"" $path] r]
483  
-			}
  479
+			set fd [open_cmd_pipe $textconv $path]
484 480
 		} else {
485 481
 			set fd [open $path r]
486 482
 		}
@@ -572,7 +568,11 @@ method _read_file {fd jump} {
572 568
 	foreach i $w_columns {$i conf -state disabled}
573 569
 
574 570
 	if {[eof $fd]} {
575  
-		close $fd
  571
+		fconfigure $fd -blocking 1; # enable error reporting on close
  572
+		if {[catch {close $fd} err]} {
  573
+			tk_messageBox -icon error -title [mc Error] \
  574
+				-message $err
  575
+		}
576 576
 
577 577
 		# If we don't force Tk to update the widgets *right now*
578 578
 		# none of our jump commands will cause a change in the UI.
@@ -1062,7 +1062,7 @@ method _gitkcommit {} {
1062 1062
 		set radius [get_config gui.blamehistoryctx]
1063 1063
 		set cmdline [list --select-commit=$cmit]
1064 1064
 
1065  
-                if {$radius > 0} {
  1065
+		if {$radius > 0} {
1066 1066
 			set author_time {}
1067 1067
 			set committer_time {}
1068 1068
 
@@ -1170,7 +1170,7 @@ method _read_diff_load_commit {fd cparent new_path tline} {
1170 1170
 	}
1171 1171
 
1172 1172
 	if {[eof $fd]} {
1173  
-		close $fd;
  1173
+		close $fd
1174 1174
 		set current_fd {}
1175 1175
 
1176 1176
 		_load_new_commit $this  \
@@ -1201,6 +1201,7 @@ method _open_tooltip {cur_w} {
1201 1201
 		_hide_tooltip $this
1202 1202
 
1203 1203
 		set tooltip_wm [toplevel $cur_w.tooltip -borderwidth 1]
  1204
+		catch {wm attributes $tooltip_wm -type tooltip}
1204 1205
 		wm overrideredirect $tooltip_wm 1
1205 1206
 		wm transient $tooltip_wm [winfo toplevel $cur_w]
1206 1207
 		set tooltip_t $tooltip_wm.label
8  git-gui/lib/browser.tcl
@@ -26,8 +26,14 @@ constructor new {commit {path {}}} {
26 26
 	wm withdraw $top
27 27
 	wm title $top [append "[appname] ([reponame]): " [mc "File Browser"]]
28 28
 
  29
+	if {$path ne {}} {
  30
+		if {[string index $path end] ne {/}} {
  31
+			append path /
  32
+		}
  33
+	}
  34
+
29 35
 	set browser_commit $commit
30  
-	set browser_path $browser_commit:$path
  36
+	set browser_path "$browser_commit:[escape_path $path]"
31 37
 
32 38
 	${NS}::label $w.path \
33 39
 		-textvariable @browser_path \
1  git-gui/lib/choose_rev.tcl
@@ -497,6 +497,7 @@ method _open_tooltip {} {
497 497
 
498 498
 	if {$tooltip_wm eq {}} {
499 499
 		set tooltip_wm [toplevel $w_list.tooltip -borderwidth 1]
  500
+		catch {wm attributes $tooltip_wm -type tooltip}
500 501
 		wm overrideredirect $tooltip_wm 1
501 502
 		wm transient $tooltip_wm [winfo toplevel $w_list]
502 503
 		set tooltip_t $tooltip_wm.label
1  git-gui/lib/class.tcl
@@ -138,6 +138,7 @@ proc make_dialog {t w args} {
138 138
 	upvar $t top $w pfx this this
139 139
 	global use_ttk
140 140
 	uplevel [linsert $args 0 make_toplevel $t $w]
  141
+	catch {wm attributes $top -type dialog}
141 142
 	pave_toplevel $pfx
142 143
 }
143 144
 
4  git-gui/lib/commit.tcl
@@ -263,7 +263,9 @@ proc commit_commitmsg {curHEAD msg_p} {
263 263
 	global is_detached repo_config
264 264
 	global pch_error
265 265
 
266  
-	if {$is_detached && $repo_config(gui.warndetachedcommit)} {
  266
+	if {$is_detached
  267
+	    && ![file exists [gitdir rebase-merge head-name]]
  268
+	    && 	[is_config_true gui.warndetachedcommit]} {
267 269
 		set msg [mc "You are about to commit on a detached head.\
268 270
 This is a potentially dangerous thing to do because if you switch\
269 271
 to another branch you will loose your changes and it can be difficult\
5  git-gui/lib/diff.tcl
@@ -309,6 +309,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
309 309
 
310 310
 	lappend cmd -p
311 311
 	lappend cmd --color
  312
+	set cmd [concat $cmd $repo_config(gui.diffopts)]
312 313
 	if {$repo_config(gui.diffcontext) >= 1} {
313 314
 		lappend cmd "-U$repo_config(gui.diffcontext)"
314 315
 	}
@@ -502,9 +503,9 @@ proc read_diff {fd conflict_size cont_info} {
502 503
 
503 504
 		foreach {posbegin colbegin posend colend} $markup {
504 505
 			set prefix clr
505  
-			foreach style [split $colbegin ";"] {
  506
+			foreach style [lsort -integer [split $colbegin ";"]] {
506 507
 				if {$style eq "7"} {append prefix i; continue}
507  
-				if {$style < 30 || $style > 47} {continue}
  508
+				if {$style != 4 && ($style < 30 || $style > 47)} {continue}
508 509
 				set a "$mark linestart + $posbegin chars"
509 510
 				set b "$mark linestart + $posend chars"
510 511
 				catch {$ui_diff tag add $prefix$style $a $b}
24  git-gui/lib/index.tcl
@@ -356,21 +356,33 @@ proc do_add_all {} {
356 356
 	global file_states
357 357
 
358 358
 	set paths [list]
359  
-	set unknown_paths [list]
  359
+	set untracked_paths [list]
360 360
 	foreach path [array names file_states] {
361 361
 		switch -glob -- [lindex $file_states($path) 0] {
362 362
 		U? {continue}
363 363
 		?M -
364 364
 		?T -
365 365
 		?D {lappend paths $path}
366  
-		?O {lappend unknown_paths $path}
  366
+		?O {lappend untracked_paths $path}
367 367
 		}
368 368
 	}
369  
-	if {[llength $unknown_paths]} {
370  
-		set reply [ask_popup [mc "There are unknown files do you also want
371  
-to stage those?"]]
  369
+	if {[llength $untracked_paths]} {
  370
+		set reply 0
  371
+		switch -- [get_config gui.stageuntracked] {
  372
+		no {
  373
+			set reply 0
  374
+		}
  375
+		yes {
  376
+			set reply 1
  377
+		}
  378
+		ask -
  379
+		default {
  380
+			set reply [ask_popup [mc "Stage %d untracked files?" \
  381
+									  [llength $untracked_paths]]]
  382
+		}
  383
+		}
372 384
 		if {$reply} {
373  
-			set paths [concat $paths $unknown_paths]
  385
+			set paths [concat $paths $untracked_paths]
374 386
 		}
375 387
 	}
376 388
 	add_helper {Adding all changed files} $paths
2  git-gui/lib/line.tcl
@@ -15,7 +15,7 @@ constructor new {i_w i_text args} {
15 15
 
16 16
 	${NS}::frame  $w
17 17
 	${NS}::label  $w.l       -text [mc "Goto Line:"]
18  
-	entry  $w.ent \
  18
+	tentry  $w.ent \
19 19
 		-textvariable ${__this}::linenum \
20 20
 		-background lightgreen \
21 21
 		-validate key \
20  git-gui/lib/option.tcl
@@ -153,9 +153,12 @@ proc do_options {} {
153 153
 		{i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}}
154 154
 		{i-0..300 gui.blamehistoryctx {mc "Blame History Context Radius (days)"}}
155 155
 		{i-1..99 gui.diffcontext {mc "Number of Diff Context Lines"}}
  156
+		{t gui.diffopts {mc "Additional Diff Parameters"}}
156 157
 		{i-0..99 gui.commitmsgwidth {mc "Commit Message Text Width"}}
157 158
 		{t gui.newbranchtemplate {mc "New Branch Name Template"}}
158 159
 		{c gui.encoding {mc "Default File Contents Encoding"}}
  160
+		{b gui.warndetachedcommit {mc "Warn before committing to a detached head"}}
  161
+		{s gui.stageuntracked {mc "Staging of untracked files"} {list "yes" "no" "ask"}}
159 162
 		} {
160 163
 		set type [lindex $option 0]
161 164
 		set name [lindex $option 1]
@@ -208,6 +211,23 @@ proc do_options {} {
208 211
 				}
209 212
 				pack $w.$f.$optid -side top -anchor w -fill x
210 213
 			}
  214
+			s {
  215
+				set opts [eval [lindex $option 3]]
  216
+				${NS}::frame $w.$f.$optid
  217
+				${NS}::label $w.$f.$optid.l -text "$text:"
  218
+				if {$use_ttk} {
  219
+					ttk::combobox $w.$f.$optid.v \
  220
+						-textvariable ${f}_config_new($name) \
  221
+						-values $opts -state readonly
  222
+				} else {
  223
+					eval tk_optionMenu $w.$f.$optid.v \
  224
+						${f}_config_new($name) \
  225
+						$opts
  226
+				}
  227
+				pack $w.$f.$optid.l -side left -anchor w -fill x
  228
+				pack $w.$f.$optid.v -side right -anchor e -padx 5
  229
+				pack $w.$f.$optid -side top -anchor w -fill x
  230
+			}
211 231
 			}
212 232
 		}
213 233
 	}
123  git-gui/lib/search.tcl
@@ -7,9 +7,16 @@ field w
7 7
 field ctext
8 8
 
9 9
 field searchstring   {}
10  
-field casesensitive  1
  10
+field regexpsearch
  11
+field default_regexpsearch
  12
+field casesensitive
  13
+field default_casesensitive
  14
+field smartcase
11 15
 field searchdirn     -forwards
12 16
 
  17
+field history
  18
+field history_index
  19
+
13 20
 field smarktop
14 21
 field smarkbot
15 22
 
@@ -18,15 +25,37 @@ constructor new {i_w i_text args} {
18 25
 	set w      $i_w
19 26
 	set ctext  $i_text
20 27
 
  28
+	set default_regexpsearch [is_config_true gui.search.regexp]
  29
+	switch -- [get_config gui.search.case] {
  30
+	no {
  31
+		set default_casesensitive 0
  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]
  46
+
21 47
 	${NS}::frame  $w
22 48
 	${NS}::label  $w.l       -text [mc Find:]
23  
-	entry  $w.ent -textvariable ${__this}::searchstring -background lightgreen
  49
+	tentry  $w.ent -textvariable ${__this}::searchstring -background lightgreen
24 50
 	${NS}::button $w.bn      -text [mc Next] -command [cb find_next]
25 51
 	${NS}::button $w.bp      -text [mc Prev] -command [cb find_prev]
26  
-	${NS}::checkbutton $w.cs -text [mc Case-Sensitive] \
  52
+	${NS}::checkbutton $w.re -text [mc RegExp] \
  53
+		-variable ${__this}::regexpsearch -command [cb _incrsearch]
  54
+	${NS}::checkbutton $w.cs -text [mc Case] \
27 55
 		-variable ${__this}::casesensitive -command [cb _incrsearch]
28 56
 	pack   $w.l   -side left
29 57
 	pack   $w.cs  -side right
  58
+	pack   $w.re  -side right
30 59
 	pack   $w.bp  -side right
31 60
 	pack   $w.bn  -side right
32 61
 	pack   $w.ent -side left -expand 1 -fill x
@@ -37,6 +66,8 @@ constructor new {i_w i_text args} {
37 66
 	trace add variable searchstring write [cb _incrsearch_cb]
38 67
 	bind $w.ent <Return> [cb find_next]
39 68
 	bind $w.ent <Shift-Return> [cb find_prev]
  69
+	bind $w.ent <Key-Up>   [cb _prev_search]
  70
+	bind $w.ent <Key-Down> [cb _next_search]
40 71
 	
41 72
 	bind $w <Destroy> [list delete_this $this]
42 73
 	return $this
@@ -45,6 +76,10 @@ constructor new {i_w i_text args} {
45 76
 method show {} {
46 77
 	if {![visible $this]} {
47 78
 		grid $w
  79
+		$w.ent delete 0 end
  80
+		set regexpsearch  $default_regexpsearch
  81
+		set casesensitive $default_casesensitive
  82
+		set history_index [llength $history]
48 83
 	}
49 84
 	focus -force $w.ent
50 85
 }
@@ -53,6 +88,7 @@ method hide {} {
53 88
 	if {[visible $this]} {
54 89
 		focus $ctext
55 90
 		grid remove $w
  91
+		_save_search $this
56 92
 	}
57 93
 }
58 94
 
@@ -98,6 +134,9 @@ method _do_search {start {mlenvar {}} {dir {}} {endbound {}}} {
98 134
 		upvar $mlenvar mlen
99 135
 		lappend cmd -count mlen
100 136
 	}
  137
+	if {$regexpsearch} {
  138
+		lappend cmd -regexp
  139
+	}
101 140
 	if {!$casesensitive} {
102 141
 		lappend cmd -nocase
103 142
 	}
@@ -105,14 +144,16 @@ method _do_search {start {mlenvar {}} {dir {}} {endbound {}}} {
105 144
 		set dir $searchdirn
106 145
 	}
107 146
 	lappend cmd $dir -- $searchstring
108  
-	if {$endbound ne {}} {
109  
-		set here [eval $cmd [list $start] [list $endbound]]
110  
-	} else {
111  
-		set here [eval $cmd [list $start]]
112  
-		if {$here eq {}} {
113  
-			set here [eval $cmd [_get_wrap_anchor $this $dir]]
  147
+	if {[catch {
  148
+		if {$endbound ne {}} {
  149
+			set here [eval $cmd [list $start] [list $endbound]]
  150
+		} else {
  151
+			set here [eval $cmd [list $start]]
  152
+			if {$here eq {}} {
  153
+				set here [eval $cmd [_get_wrap_anchor $this $dir]]
  154
+			}
114 155
 		}
115  
-	}
  156
+	} err]} { set here {} }
116 157
 	return $here
117 158
 }
118 159
 
@@ -126,17 +167,74 @@ method _incrsearch {} {
126 167
 		$ctext mark set anchor [_get_new_anchor $this]
127 168
 	}
128 169
 	if {$searchstring ne {}} {
  170
+		if {$smartcase && [regexp {[[:upper:]]} $searchstring]} {
  171
+			set casesensitive 1
  172
+		}
129 173
 		set here [_do_search $this anchor mlen]
130 174
 		if {$here ne {}} {
131 175
 			$ctext see $here
132 176
 			$ctext tag remove sel 1.0 end
133 177
 			$ctext tag add sel $here "$here + $mlen c"
134  
-			$w.ent configure -background lightgreen
  178
+			#$w.ent configure -background lightgreen
  179
+			$w.ent state !pressed
135 180
 			_set_marks $this 1
136 181
 		} else {
137  
-			$w.ent configure -background lightpink
  182
+			#$w.ent configure -background lightpink
  183
+			$w.ent state pressed
138 184
 		}
  185
+	} elseif {$smartcase} {
  186
+		# clearing the field resets the smart case detection
  187
+		set casesensitive 0
  188
+	}
  189
+}
  190
+
  191
+method _save_search {} {
  192
+	if {$searchstring eq {}} {
  193
+		return
  194
+	}
  195
+	if {[llength $history] > 0} {
  196
+		foreach {s_regexp s_case s_expr} [lindex $history end] break
  197
+	} else {
  198
+		set s_regexp $regexpsearch
  199
+		set s_case   $casesensitive
  200
+		set s_expr   ""
  201
+	}
  202
+	if {$searchstring eq $s_expr} {
  203
+		# update modes
  204
+		set history [lreplace $history end end \
  205
+				[list $regexpsearch $casesensitive $searchstring]]
  206
+	} else {
  207
+		lappend history [list $regexpsearch $casesensitive $searchstring]
  208
+	}
  209
+	set history_index [llength $history]
  210
+}
  211
+
  212
+method _prev_search {} {
  213
+	if {$history_index > 0} {
  214
+		incr history_index -1
  215
+		foreach {s_regexp s_case s_expr} [lindex $history $history_index] break
  216
+		$w.ent delete 0 end
  217
+		$w.ent insert 0 $s_expr
  218
+		set regexpsearch $s_regexp
  219
+		set casesensitive $s_case
  220
+	}
  221
+}
  222
+
  223
+method _next_search {} {
  224
+	if {$history_index < [llength $history]} {
  225
+		incr history_index
  226
+	}
  227
+	if {$history_index < [llength $history]} {
  228
+		foreach {s_regexp s_case s_expr} [lindex $history $history_index] break
  229
+	} else {
  230
+		set s_regexp $default_regexpsearch
  231
+		set s_case   $default_casesensitive
  232
+		set s_expr   ""
139 233
 	}
  234
+	$w.ent delete 0 end
  235
+	$w.ent insert 0 $s_expr
  236
+	set regexpsearch $s_regexp
  237
+	set casesensitive $s_case
140 238
 }
141 239
 
142 240
 method find_prev {} {
@@ -149,6 +247,7 @@ method find_next {{dir -forwards}} {
149 247
 	set searchdirn $dir
150 248
 	$ctext mark unset anchor
151 249
 	if {$searchstring ne {}} {
  250
+		_save_search $this
152 251
 		set start [_get_new_anchor $this]
153 252
 		if {$dir eq "-forwards"} {
154 253
 			set start "$start + 1c"
2  git-gui/lib/sshkey.tcl
@@ -117,7 +117,7 @@ proc read_sshkey_output {fd w} {
117 117
 	} else {
118 118
 		set finfo [find_ssh_key]
119 119
 		if {$finfo eq {}} {
120  
-			set sshkey_title [mc "Generation succeded, but no keys found."]
  120
+			set sshkey_title [mc "Generation succeeded, but no keys found."]
121 121
 			$w.contents insert end $sshkey_output
122 122
 		} else {
123 123
 			set sshkey_title [mc "Your key is in: %s" [lindex $finfo 0]]
99  git-gui/lib/themed.tcl
@@ -23,10 +23,59 @@ proc InitTheme {} {
23 23
 	ttk::style configure Gold.TFrame -background gold -relief flat
24 24
 	# listboxes should have a theme border so embed in ttk::frame
25 25
 	ttk::style layout SListbox.TFrame {
26  
-        SListbox.Frame.Entry.field -sticky news -border true -children {
27  
-            SListbox.Frame.padding -sticky news
28  
-        }
29  
-    }
  26
+		SListbox.Frame.Entry.field -sticky news -border true -children {
  27
+			SListbox.Frame.padding -sticky news
  28
+		}
  29
+	}
  30
+
  31
+	# Handle either current Tk or older versions of 8.5
  32
+	if {[catch {set theme [ttk::style theme use]}]} {
  33
+		set theme  $::ttk::currentTheme
  34
+	}
  35
+
  36
+	if {[lsearch -exact {default alt classic clam} $theme] != -1} {
  37
+		# Simple override of standard ttk::entry to change the field
  38
+		# packground according to a state flag. We should use 'user1'
  39
+		# but not all versions of 8.5 support that so make use of 'pressed'
  40
+		# which is not normally in use for entry widgets.
  41
+		ttk::style layout Edged.Entry [ttk::style layout TEntry]
  42
+		ttk::style map Edged.Entry {*}[ttk::style map TEntry]
  43
+		ttk::style configure Edged.Entry {*}[ttk::style configure TEntry] \
  44
+			-fieldbackground lightgreen
  45
+		ttk::style map Edged.Entry -fieldbackground {
  46
+			{pressed !disabled} lightpink
  47
+		}
  48
+	} else {
  49
+		# For fancier themes, in particular the Windows ones, the field
  50
+		# element may not support changing the background color. So instead
  51
+		# override the fill using the default fill element. If we overrode
  52
+		# the vista theme field element we would loose the themed border
  53
+		# of the widget.
  54
+		catch {
  55
+			ttk::style element create color.fill from default
  56
+		}
  57
+
  58
+		ttk::style layout Edged.Entry {
  59
+			Edged.Entry.field -sticky nswe -border 0 -children {
  60
+				Edged.Entry.border -sticky nswe -border 1 -children {
  61
+					Edged.Entry.padding -sticky nswe -children {
  62
+						Edged.Entry.color.fill -sticky nswe -children {
  63
+							Edged.Entry.textarea -sticky nswe
  64
+						}
  65
+					}
  66
+				}
  67
+			}
  68
+		}
  69
+
  70
+		ttk::style configure Edged.Entry {*}[ttk::style configure TEntry] \
  71
+			-background lightgreen -padding 0 -borderwidth 0
  72
+		ttk::style map Edged.Entry {*}[ttk::style map TEntry] \
  73
+			-background {{pressed !disabled} lightpink}
  74
+	}
  75
+
  76
+	if {[lsearch [bind . <<ThemeChanged>>] InitTheme] == -1} {
  77
+		bind . <<ThemeChanged>> +[namespace code [list InitTheme]]
  78
+	}
30 79
 }
31 80
 
32 81
 proc gold_frame {w args} {
@@ -74,6 +123,7 @@ proc paddedlabel {w args} {
74 123
 # place a themed frame over the surface.
75 124
 proc Dialog {w args} {
76 125
 	eval [linsert $args 0 toplevel $w -class Dialog]
  126
+	catch {wm attributes $w -type dialog}	
77 127
 	pave_toplevel $w
78 128
 	return $w
79 129
 }
@@ -143,6 +193,47 @@ proc tspinbox {w args} {
143 193
 	}
144 194
 }
145 195
 
  196
+proc tentry {w args} {
  197
+	global use_ttk
  198
+	if {$use_ttk} {
  199
+		InitTheme
  200
+		ttk::entry $w -style Edged.Entry
  201
+	} else {
  202
+		entry $w
  203
+	}
  204
+
  205
+	rename $w _$w
  206
+	interp alias {} $w {} tentry_widgetproc $w
  207
+	eval [linsert $args 0 tentry_widgetproc $w configure]
  208
+	return $w
  209
+}
  210
+proc tentry_widgetproc {w cmd args} {
  211
+	global use_ttk
  212
+	switch -- $cmd {
  213
+		state {
  214
+			if {$use_ttk} {
  215
+				return [uplevel 1 [list _$w $cmd] $args]
  216
+			} else {
  217
+				if {[lsearch -exact $args pressed] != -1} {
  218
+					_$w configure -background lightpink
  219
+				} else {
  220
+					_$w configure -background lightgreen
  221
+				}
  222
+			}
  223
+		}
  224
+		configure {
  225
+			if {$use_ttk} {
  226
+				if {[set n [lsearch -exact $args -background]] != -1} {
  227
+					set args [lreplace $args $n [incr n]]
  228
+					if {[llength $args] == 0} {return}
  229
+				}
  230
+			}
  231
+			return [uplevel 1 [list _$w $cmd] $args]
  232
+		}
  233
+		default { return [uplevel 1 [list _$w $cmd] $args] }
  234
+	}
  235
+}
  236
+
146 237
 # Tk 8.6 provides a standard font selection dialog. This uses the native
147 238
 # dialogs on Windows and MacOSX or a standard Tk dialog on X11.
148 239
 proc tchoosefont {w title familyvar sizevar} {
10  git-gui/lib/tools.tcl
@@ -87,8 +87,14 @@ proc tools_exec {fullname} {
87 87
 			return
88 88
 		}
89 89
 	} elseif {[is_config_true "guitool.$fullname.confirm"]} {
90  
-		if {[ask_popup [mc "Are you sure you want to run %s?" $fullname]] ne {yes}} {
91  
-			return
  90
+		if {[is_config_true "guitool.$fullname.needsfile"]} {
  91
+			if {[ask_popup [mc "Are you sure you want to run %1\$s on file \"%2\$s\"?" $fullname $current_diff_path]] ne {yes}} {
  92
+				return
  93
+			}
  94
+		} else {
  95
+			if {[ask_popup [mc "Are you sure you want to run %s?" $fullname]] ne {yes}} {
  96
+				return
  97
+			}
92 98
 		}
93 99
 	}
94 100
 
1  git-gui/lib/transport.tcl
@@ -124,6 +124,7 @@ proc do_push_anywhere {} {
124 124
 
125 125
 	set w .push_setup
126 126
 	toplevel $w
  127
+	catch {wm attributes $w -type dialog}
127 128
 	wm withdraw $w
128 129
 	wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
129 130
 	pave_toplevel $w

0 notes on commit 73c6b35

Please sign in to comment.
Something went wrong with that request. Please try again.