【发布时间】:2018-09-30 19:39:56
【问题描述】:
几天前,我偶然发现了这张带有深色主题的 git gui 的图片。
我浏览了文档,搜索了它的菜单并询问了 DuckDuckGo,但到目前为止我还没有弄清楚如何更改主题。怎么办?
编辑:我使用深色主题的 Ubuntu 16.04。 Git gui 完成忽略了我的 DE 的主题设置,因此我无法想象它可能是相关的,as kowsky suggests below。
【问题讨论】:
几天前,我偶然发现了这张带有深色主题的 git gui 的图片。
我浏览了文档,搜索了它的菜单并询问了 DuckDuckGo,但到目前为止我还没有弄清楚如何更改主题。怎么办?
编辑:我使用深色主题的 Ubuntu 16.04。 Git gui 完成忽略了我的 DE 的主题设置,因此我无法想象它可能是相关的,as kowsky suggests below。
【问题讨论】:
我猜你是从here那里拍的?
发布屏幕截图的用户声明
[...] 我正在为我的 Windows 使用深色主题,[...]
和
Git-GUI(主窗口)必须使用 Windows 原生颜色 [...]
因此,我怀疑他通过相应地设置他的默认窗口颜色主题来实现这个“黑暗主题”。
【讨论】:
颜色是硬编码的,在名为choose_repository.tcl 的文件中定义。不确定 Ubuntu,但在 Windows 中它位于C:\Program Files\Git\mingw64\share\git-gui\lib\choose_repository.tcl。将颜色更改为您喜欢的颜色。我的这个补丁看起来像这样:
@@ -91,17 +91,18 @@ constructor pick {} {
${NS}::frame $w_body
text $opts \
-cursor $::cursor_ptr \
-relief flat \
-background [get_bg_color $w_body] \
+ -foreground lime \
-wrap none \
-spacing1 5 \
-width 50 \
-height 3
pack $opts -anchor w -fill x
- $opts tag conf link_new -foreground blue -underline 1
+ $opts tag conf link_new -underline 1
$opts tag bind link_new <1> [cb _next new]
$opts insert end [mc "Create New Repository"] link_new
$opts insert end "\n"
if {$m_repo ne {}} {
$m_repo add command \
@@ -110,11 +111,11 @@ constructor pick {} {
-label [mc "New..."]
bind $top <$M1B-n> [cb _next new]
bind $top <$M1B-N> [cb _next new]
}
- $opts tag conf link_clone -foreground blue -underline 1
+ $opts tag conf link_clone -underline 1
$opts tag bind link_clone <1> [cb _next clone]
$opts insert end [mc "Clone Existing Repository"] link_clone
$opts insert end "\n"
if {$m_repo ne {}} {
if {[tk windowingsystem] eq "win32"} {
@@ -128,11 +129,11 @@ constructor pick {} {
-label [mc "Clone..."]
bind $top <$M1B-[string tolower $key]> [cb _next clone]
bind $top <$M1B-[string toupper $key]> [cb _next clone]
}
- $opts tag conf link_open -foreground blue -underline 1
+ $opts tag conf link_open -underline 1
$opts tag bind link_open <1> [cb _next open]
$opts insert end [mc "Open Existing Repository"] link_open
$opts insert end "\n"
if {$m_repo ne {}} {
$m_repo add command \
@@ -169,12 +170,12 @@ constructor pick {} {
-background [get_bg_color $w_body.recentlabel] \
-wrap none \
-width 50 \
-height $lenrecent
$w_recentlist tag conf link \
- -foreground blue \
- -underline 1
+ -foreground yellow \
+ -underline 0
set home $::env(HOME)
if {[is_Cygwin]} {
set home [exec cygpath --windows --absolute $home]
}
set home "[file normalize $home]/"
【讨论】:
/usr/share/git-gui/lib/choose_repository.tcl。至少,这是我的猜测。
choose_repository.tcl 失败了。此文件可能因版本而异(我使用的是 2.17.1)。你能提供更通用的东西吗?
上面 Plakhoy 的回答显示了如何设置 choose_repository 页面的样式。要将应用程序的其余部分更改为暗模式,请遵循以下我的建议。我没有足够的声誉来发布图片,但您可以更改几行代码来为 Git Gui 启用暗模式。
这将创建一个带有浅色(几乎是白色)文本的黑色背景。
文件位置:C:\Program Files\Git\mingw64\share\git-gui\lib\themed.tcl
themed.tcl 第 14-20 行原始设置(灯光模式)。
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]
在themed.tcl 中将第14-20 行更改如下(暗模式)。
proc sync_with_theme {} {
set base_bg #282a36
set base_fg #f8f8f2
set text_bg #282a36
set text_fg #f8f8f2
set select_bg #f8f8f2
set select_fg #282a36
【讨论】: