From 5c1b391307b3a17eb859ef8716761ccc0bc54cba Mon Sep 17 00:00:00 2001 From: Serg Tereshchenko Date: Sun, 23 Aug 2020 01:24:31 +0300 Subject: git-gui: fix mixed tabs and spaces; prefer tabs Spaces are replaced with tabs when possible. In some cases just replacing spaces with tabs would break readability, so it was left as it is. Signed-off-by: Serg Tereshchenko Signed-off-by: Pratyush Yadav --- git-gui.sh | 86 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 49bd86e635..d18b902189 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -947,15 +947,15 @@ if {![regsub {^git version } $_git_version {} _git_version]} { } proc get_trimmed_version {s} { - set r {} - foreach x [split $s -._] { - if {[string is integer -strict $x]} { - lappend r $x - } else { - break - } - } - return [join $r .] + set r {} + foreach x [split $s -._] { + if {[string is integer -strict $x]} { + lappend r $x + } else { + break + } + } + return [join $r .] } set _real_git_version $_git_version set _git_version [get_trimmed_version $_git_version] @@ -967,7 +967,7 @@ if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} { -type yesno \ -default no \ -title "[appname]: warning" \ - -message [mc "Git version cannot be determined. + -message [mc "Git version cannot be determined. %s claims it is version '%s'. @@ -1653,7 +1653,7 @@ proc prepare_commit_msg_hook_wait {fd_ph} { set pch_error {} catch {file delete [gitdir PREPARE_COMMIT_MSG]} return - } + } fconfigure $fd_ph -blocking 0 catch {file delete [gitdir PREPARE_COMMIT_MSG]} } @@ -2001,72 +2001,72 @@ set filemask { #define mask_width 14 #define mask_height 15 static unsigned char mask_bits[] = { - 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, - 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, - 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f}; + 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, + 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, + 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f}; } image create bitmap file_plain -background white -foreground black -data { #define plain_width 14 #define plain_height 15 static unsigned char plain_bits[] = { - 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10, - 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, - 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f}; + 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10, + 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, + 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask image create bitmap file_mod -background white -foreground blue -data { #define mod_width 14 #define mod_height 15 static unsigned char mod_bits[] = { - 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10, - 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, - 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f}; + 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10, + 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, + 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask image create bitmap file_fulltick -background white -foreground "#007000" -data { #define file_fulltick_width 14 #define file_fulltick_height 15 static unsigned char file_fulltick_bits[] = { - 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16, - 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10, - 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f}; + 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16, + 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10, + 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask image create bitmap file_question -background white -foreground black -data { #define file_question_width 14 #define file_question_height 15 static unsigned char file_question_bits[] = { - 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13, - 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10, - 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f}; + 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13, + 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10, + 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask image create bitmap file_removed -background white -foreground red -data { #define file_removed_width 14 #define file_removed_height 15 static unsigned char file_removed_bits[] = { - 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10, - 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13, - 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f}; + 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10, + 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13, + 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask image create bitmap file_merge -background white -foreground blue -data { #define file_merge_width 14 #define file_merge_height 15 static unsigned char file_merge_bits[] = { - 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10, - 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, - 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f}; + 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10, + 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, + 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask image create bitmap file_statechange -background white -foreground green -data { #define file_statechange_width 14 #define file_statechange_height 15 static unsigned char file_statechange_bits[] = { - 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x62, 0x10, - 0x62, 0x10, 0xba, 0x11, 0xba, 0x11, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, - 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f}; + 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x62, 0x10, + 0x62, 0x10, 0xba, 0x11, 0xba, 0x11, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, + 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask set ui_index .vpane.files.index.list @@ -3878,18 +3878,18 @@ proc on_application_mapped {} { set gm $repo_config(gui.geometry) if {$use_ttk} { bind .vpane \ - [list on_ttk_pane_mapped %W 0 [lindex $gm 1]] + [list on_ttk_pane_mapped %W 0 [lindex $gm 1]] bind .vpane.files \ - [list on_ttk_pane_mapped %W 0 [lindex $gm 2]] + [list on_ttk_pane_mapped %W 0 [lindex $gm 2]] } else { bind .vpane \ - [list on_tk_pane_mapped %W 0 \ - [lindex $gm 1] \ - [lindex [.vpane sash coord 0] 1]] + [list on_tk_pane_mapped %W 0 \ + [lindex $gm 1] \ + [lindex [.vpane sash coord 0] 1]] bind .vpane.files \ - [list on_tk_pane_mapped %W 0 \ - [lindex [.vpane.files sash coord 0] 0] \ - [lindex $gm 2]] + [list on_tk_pane_mapped %W 0 \ + [lindex [.vpane.files sash coord 0] 0] \ + [lindex $gm 2]] } wm geometry . [lindex $gm 0] } -- cgit v1.2.3 From c02efc13638447f9af0be6cb158a6c1a8dd4c727 Mon Sep 17 00:00:00 2001 From: Serg Tereshchenko Date: Sat, 26 Sep 2020 17:54:43 +0300 Subject: git-gui: improve dark mode support The colors of some ttext widgets are hard-coded. These hard-coded colors are okay with a light theme but with a dark theme some widgets are dark colored and the hard-coded ones are still light. This defeats the purpose of applying the theme and makes the UI look very awkward. Remove the hard-coded colors in ttext calls and use colors from the theme for those widgets via Text.Background and Text.Foreground from the option database. Similarly, the highlighting for the currently selected file(s) in the "Staged Files" and "Unstaged Files" sections is also hard-coded. Pull the colors for that from the current theme to make sure it is in line Signed-off-by: Serg Tereshchenko Signed-off-by: Pratyush Yadav --- git-gui.sh | 17 +++++++++++------ lib/themed.tcl | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index d18b902189..867b8cea46 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -720,7 +720,9 @@ proc rmsel_tag {text} { -background [$text cget -background] \ -foreground [$text cget -foreground] \ -borderwidth 0 - $text tag conf in_sel -background lightgray + $text tag conf in_sel\ + -background $color::select_bg \ + -foreground $color::select_fg bind $text break return $text } @@ -863,6 +865,7 @@ proc apply_config {} { set NS ttk bind [winfo class .] <> [list InitTheme] pave_toplevel . + color::sync_with_theme } } } @@ -3272,7 +3275,7 @@ pack .vpane -anchor n -side top -fill both -expand 1 textframe .vpane.files.workdir -height 100 -width 200 tlabel .vpane.files.workdir.title -text [mc "Unstaged Changes"] \ -background lightsalmon -foreground black -ttext $ui_workdir -background white -foreground black \ +ttext $ui_workdir \ -borderwidth 0 \ -width 20 -height 10 \ -wrap none \ @@ -3294,7 +3297,7 @@ textframe .vpane.files.index -height 100 -width 200 tlabel .vpane.files.index.title \ -text [mc "Staged Changes (Will Commit)"] \ -background lightgreen -foreground black -ttext $ui_index -background white -foreground black \ +ttext $ui_index \ -borderwidth 0 \ -width 20 -height 10 \ -wrap none \ @@ -3321,7 +3324,9 @@ if {!$use_ttk} { foreach i [list $ui_index $ui_workdir] { rmsel_tag $i - $i tag conf in_diff -background [$i tag cget in_sel -background] + $i tag conf in_diff \ + -background $color::select_bg \ + -foreground $color::select_fg } unset i @@ -3429,7 +3434,7 @@ if {![is_enabled nocommit]} { } textframe .vpane.lower.commarea.buffer.frame -ttext $ui_comm -background white -foreground black \ +ttext $ui_comm \ -borderwidth 1 \ -undo true \ -maxundo 20 \ @@ -3558,7 +3563,7 @@ bind .vpane.lower.diff.header.path {do_file_open $current_diff_path} # textframe .vpane.lower.diff.body set ui_diff .vpane.lower.diff.body.t -ttext $ui_diff -background white -foreground black \ +ttext $ui_diff \ -borderwidth 0 \ -width 80 -height 5 -wrap none \ -font font_diff \ diff --git a/lib/themed.tcl b/lib/themed.tcl index 88b3119a75..83e3ac795f 100644 --- a/lib/themed.tcl +++ b/lib/themed.tcl @@ -1,6 +1,44 @@ # Functions for supporting the use of themed Tk widgets in git-gui. # Copyright (C) 2009 Pat Thoyts + +namespace eval color { + # Variable colors + # Preffered way to set widget colors is using add_option. + # In some cases, like with tags in_diff/in_sel, we use these colors. + variable select_bg lightgray + variable select_fg black + + proc sync_with_theme {} { + set base_bg [ttk::style lookup . -background] + set base_fg [ttk::style lookup . -foreground] + set text_bg [ttk::style lookup Treeview -background] + set text_fg [ttk::style lookup Treeview -foreground] + set select_bg [ttk::style lookup Default -selectbackground] + set select_fg [ttk::style lookup Default -selectforeground] + + set color::select_bg $select_bg + set color::select_fg $select_fg + + proc add_option {key val} { + option add $key $val widgetDefault + } + # Add options for plain Tk widgets + # Using `option add` instead of tk_setPalette to avoid unintended + # consequences. + if {![is_MacOSX]} { + add_option *Menu.Background $base_bg + add_option *Menu.Foreground $base_fg + add_option *Menu.activeBackground $select_bg + add_option *Menu.activeForeground $select_fg + } + add_option *Text.Background $text_bg + add_option *Text.Foreground $text_fg + add_option *Text.HighlightBackground $base_bg + add_option *Text.HighlightColor $select_bg + } +} + proc ttk_get_current_theme {} { # Handle either current Tk or older versions of 8.5 if {[catch {set theme [ttk::style theme use]}]} { -- cgit v1.2.3 From b297e03c6320a673264e9d4b15a086cee83239af Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 13 Oct 2020 15:26:43 +0200 Subject: git-gui: blame: prevent tool tips from sticking around after Command-Tab On Mac, tooltips are not automatically removed when a window loses focus. Furthermore, mouse-move events are only dispatched to the active window, which means that if we Command-tab to another application while a tool tip is showing, the tool tip will stay there forever (in front of other applications). So we must hide it manually when we lose focus. Do this unconditionally here (i.e. without if {[is_MacOSX]}); it shouldn't hurt on other platforms, even though they don't seem to have this problem. Signed-off-by: Stefan Haller Signed-off-by: Pratyush Yadav --- lib/blame.tcl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blame.tcl b/lib/blame.tcl index 62ec083667..8441e109be 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -328,6 +328,7 @@ constructor new {i_commit i_path i_jump} { bind $i [cb _show_tooltip $i @%x,%y] bind $i [cb _hide_tooltip] bind $i [cb _hide_tooltip] + bind $i [cb _hide_tooltip] bind_button3 $i " [cb _hide_tooltip] set cursorX %x -- cgit v1.2.3