Skip to content

Commit f4d8e19

Browse files
committed
* https://github.com/prati0100/git-gui: git-gui: use gray background for inactive text widgets git-gui: Fix selected text colors Makefile: conditionally include GIT-VERSION-FILE git-gui: fix colored label backgrounds when using themed widgets git-gui: ssh-askpass: add a checkbox to show the input text git-gui: update Russian translation git-gui: use commit message template git-gui: Only touch GITGUI_MSG when needed
2 parents ba2aa15 + 7b0cfe1 commit f4d8e19

File tree

6 files changed

+1845
-1531
lines changed

6 files changed

+1845
-1531
lines changed

git-gui/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ all::
99

1010
GIT-VERSION-FILE: FORCE
1111
@$(SHELL_PATH) ./GIT-VERSION-GEN
12+
ifneq ($(MAKECMDGOALS),clean)
1213
-include GIT-VERSION-FILE
14+
endif
1315

1416
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
1517
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')

git-gui/git-gui--askpass

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,21 @@ pack .m -side top -fill x -padx 20 -pady 20 -expand 1
2626
entry .e -textvariable answer -width 50
2727
pack .e -side top -fill x -padx 10 -pady 10
2828

29+
proc on_show_input_changed {args} {
30+
global show_input
31+
if {$show_input} {
32+
.e configure -show ""
33+
} else {
34+
.e configure -show "*"
35+
}
36+
}
37+
trace add variable show_input write "on_show_input_changed"
38+
39+
set show_input 0
40+
2941
if {!$yesno} {
30-
.e configure -show "*"
42+
checkbutton .cb_show -text "Show input" -variable show_input
43+
pack .cb_show -side top -anchor nw
3144
}
3245

3346
frame .b

git-gui/git-gui.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,6 @@ proc rmsel_tag {text} {
720720
-background [$text cget -background] \
721721
-foreground [$text cget -foreground] \
722722
-borderwidth 0
723-
$text tag conf in_sel\
724-
-background $color::select_bg \
725-
-foreground $color::select_fg
726723
bind $text <Motion> break
727724
return $text
728725
}
@@ -1482,6 +1479,7 @@ proc rescan {after {honor_trustmtime 1}} {
14821479
} elseif {[run_prepare_commit_msg_hook]} {
14831480
} elseif {[load_message MERGE_MSG]} {
14841481
} elseif {[load_message SQUASH_MSG]} {
1482+
} elseif {[load_message [get_config commit.template]]} {
14851483
}
14861484
$ui_comm edit reset
14871485
$ui_comm edit modified false
@@ -1616,6 +1614,12 @@ proc run_prepare_commit_msg_hook {} {
16161614
fconfigure $fd_sm -encoding utf-8
16171615
puts -nonewline $fd_pcm [read $fd_sm]
16181616
close $fd_sm
1617+
} elseif {[file isfile [get_config commit.template]]} {
1618+
set pcm_source "template"
1619+
set fd_sm [open [get_config commit.template] r]
1620+
fconfigure $fd_sm -encoding utf-8
1621+
puts -nonewline $fd_pcm [read $fd_sm]
1622+
close $fd_sm
16191623
} else {
16201624
set pcm_source ""
16211625
}
@@ -2305,11 +2309,10 @@ proc do_quit {{rc {1}}} {
23052309
if {$GITGUI_BCK_exists && ![$ui_comm edit modified]} {
23062310
file rename -force [gitdir GITGUI_BCK] $save
23072311
set GITGUI_BCK_exists 0
2308-
} else {
2312+
} elseif {[$ui_comm edit modified]} {
23092313
set msg [string trim [$ui_comm get 0.0 end]]
23102314
regsub -all -line {[ \r\t]+$} $msg {} msg
2311-
if {(![string match amend* $commit_type]
2312-
|| [$ui_comm edit modified])
2315+
if {![string match amend* $commit_type]
23132316
&& $msg ne {}} {
23142317
catch {
23152318
set fd [open $save w]
@@ -3322,11 +3325,20 @@ if {!$use_ttk} {
33223325
.vpane.files paneconfigure .vpane.files.index -sticky news
33233326
}
33243327
3328+
proc set_selection_colors {w has_focus} {
3329+
foreach tag [list in_diff in_sel] {
3330+
$w tag conf $tag \
3331+
-background [expr {$has_focus ? $color::select_bg : $color::inactive_select_bg}] \
3332+
-foreground [expr {$has_focus ? $color::select_fg : $color::inactive_select_fg}]
3333+
}
3334+
}
3335+
33253336
foreach i [list $ui_index $ui_workdir] {
33263337
rmsel_tag $i
3327-
$i tag conf in_diff \
3328-
-background $color::select_bg \
3329-
-foreground $color::select_fg
3338+
3339+
set_selection_colors $i 0
3340+
bind $i <FocusIn> { set_selection_colors %W 1 }
3341+
bind $i <FocusOut> { set_selection_colors %W 0 }
33303342
}
33313343
unset i
33323344

git-gui/lib/commit.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ A rescan will be automatically started now.
456456
}
457457

458458
$ui_comm delete 0.0 end
459+
load_message [get_config commit.template]
459460
$ui_comm edit reset
460461
$ui_comm edit modified false
461462
if {$::GITGUI_BCK_exists} {

git-gui/lib/themed.tcl

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@ namespace eval color {
66
# Variable colors
77
# Preffered way to set widget colors is using add_option.
88
# In some cases, like with tags in_diff/in_sel, we use these colors.
9-
variable select_bg lightgray
10-
variable select_fg black
9+
variable select_bg lightgray
10+
variable select_fg black
11+
variable inactive_select_bg lightgray
12+
variable inactive_select_fg black
1113

1214
proc sync_with_theme {} {
13-
set base_bg [ttk::style lookup . -background]
14-
set base_fg [ttk::style lookup . -foreground]
15-
set text_bg [ttk::style lookup Treeview -background]
16-
set text_fg [ttk::style lookup Treeview -foreground]
17-
set select_bg [ttk::style lookup Default -selectbackground]
18-
set select_fg [ttk::style lookup Default -selectforeground]
15+
set base_bg [ttk::style lookup . -background]
16+
set base_fg [ttk::style lookup . -foreground]
17+
set text_bg [ttk::style lookup Treeview -background]
18+
set text_fg [ttk::style lookup Treeview -foreground]
19+
set select_bg [ttk::style lookup Default -selectbackground]
20+
set select_fg [ttk::style lookup Default -selectforeground]
21+
set inactive_select_bg [convert_rgb_to_gray $select_bg]
22+
set inactive_select_fg $select_fg
1923

2024
set color::select_bg $select_bg
2125
set color::select_fg $select_fg
26+
set color::inactive_select_bg $inactive_select_bg
27+
set color::inactive_select_fg $inactive_select_fg
2228

2329
proc add_option {key val} {
2430
option add $key $val widgetDefault
@@ -34,11 +40,22 @@ namespace eval color {
3440
}
3541
add_option *Text.Background $text_bg
3642
add_option *Text.Foreground $text_fg
37-
add_option *Text.HighlightBackground $base_bg
38-
add_option *Text.HighlightColor $select_bg
43+
add_option *Text.selectBackground $select_bg
44+
add_option *Text.selectForeground $select_fg
45+
add_option *Text.inactiveSelectBackground $inactive_select_bg
46+
add_option *Text.inactiveSelectForeground $inactive_select_fg
3947
}
4048
}
4149

50+
proc convert_rgb_to_gray {rgb} {
51+
# Simply take the average of red, green and blue. This wouldn't be good
52+
# enough for, say, converting a photo to grayscale, but for this simple
53+
# purpose of approximating the brightness of a color it's good enough.
54+
lassign [winfo rgb . $rgb] r g b
55+
set gray [expr {($r / 256 + $g / 256 + $b / 256) / 3}]
56+
return [format "#%2.2X%2.2X%2.2X" $gray $gray $gray]
57+
}
58+
4259
proc ttk_get_current_theme {} {
4360
# Handle either current Tk or older versions of 8.5
4461
if {[catch {set theme [ttk::style theme use]}]} {
@@ -174,7 +191,7 @@ proc InitEntryFrame {} {
174191

175192
proc gold_frame {w args} {
176193
global use_ttk
177-
if {$use_ttk} {
194+
if {$use_ttk && ![is_MacOSX]} {
178195
eval [linsert $args 0 ttk::frame $w -style Gold.TFrame]
179196
} else {
180197
eval [linsert $args 0 frame $w -background gold]
@@ -183,7 +200,7 @@ proc gold_frame {w args} {
183200

184201
proc tlabel {w args} {
185202
global use_ttk
186-
if {$use_ttk} {
203+
if {$use_ttk && ![is_MacOSX]} {
187204
set cmd [list ttk::label $w -style Color.TLabel]
188205
foreach {k v} $args {
189206
switch -glob -- $k {

0 commit comments

Comments
 (0)