From patchwork Mon Feb 11 21:42:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ismael Luceno X-Patchwork-Id: 10806837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B39211390 for ; Mon, 11 Feb 2019 21:51:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4F352B45E for ; Mon, 11 Feb 2019 21:51:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9970D2B45D; Mon, 11 Feb 2019 21:51:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5D7B2B2FA for ; Mon, 11 Feb 2019 21:51:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727780AbfBKVvH (ORCPT ); Mon, 11 Feb 2019 16:51:07 -0500 Received: from [193.29.56.124] ([193.29.56.124]:56844 "EHLO iodev.co.uk" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1726074AbfBKVvH (ORCPT ); Mon, 11 Feb 2019 16:51:07 -0500 X-Greylist: delayed 539 seconds by postgrey-1.27 at vger.kernel.org; Mon, 11 Feb 2019 16:51:06 EST From: Ismael Luceno To: git@vger.kernel.org Cc: Pat Thoyts , Ismael Luceno Subject: [PATCH] git-gui: Implement color configuration Date: Mon, 11 Feb 2019 22:42:13 +0100 Message-Id: <20190211214213.32501-1-ismael@iodev.co.uk> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Ismael Luceno --- git-gui.sh | 33 ++++++++++++++++++++++----------- lib/option.tcl | 16 ++++++++++++++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index e00d9a345294..01e5462dc70e 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -903,6 +903,8 @@ set font_descs { } set default_config(gui.stageuntracked) ask set default_config(gui.displayuntracked) true +set default_config(gui.foreground) black +set default_config(gui.background) white ###################################################################### ## @@ -2004,7 +2006,7 @@ static unsigned char mask_bits[] = { 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f}; } -image create bitmap file_plain -background white -foreground black -data { +image create bitmap file_plain -background [get_config gui.background white] -foreground black -data { #define plain_width 14 #define plain_height 15 static unsigned char plain_bits[] = { @@ -2013,7 +2015,7 @@ static unsigned char plain_bits[] = { 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask -image create bitmap file_mod -background white -foreground blue -data { +image create bitmap file_mod -background [get_config gui.background] -foreground blue -data { #define mod_width 14 #define mod_height 15 static unsigned char mod_bits[] = { @@ -2022,7 +2024,7 @@ static unsigned char mod_bits[] = { 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask -image create bitmap file_fulltick -background white -foreground "#007000" -data { +image create bitmap file_fulltick -background [get_config gui.background] -foreground "#007000" -data { #define file_fulltick_width 14 #define file_fulltick_height 15 static unsigned char file_fulltick_bits[] = { @@ -2031,7 +2033,7 @@ static unsigned char file_fulltick_bits[] = { 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask -image create bitmap file_question -background white -foreground black -data { +image create bitmap file_question -background [get_config gui.background] -foreground black -data { #define file_question_width 14 #define file_question_height 15 static unsigned char file_question_bits[] = { @@ -2040,7 +2042,7 @@ static unsigned char file_question_bits[] = { 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask -image create bitmap file_removed -background white -foreground red -data { +image create bitmap file_removed -background [get_config gui.background] -foreground red -data { #define file_removed_width 14 #define file_removed_height 15 static unsigned char file_removed_bits[] = { @@ -2049,7 +2051,7 @@ static unsigned char file_removed_bits[] = { 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask -image create bitmap file_merge -background white -foreground blue -data { +image create bitmap file_merge -background [get_config gui.background] -foreground blue -data { #define file_merge_width 14 #define file_merge_height 15 static unsigned char file_merge_bits[] = { @@ -2058,7 +2060,7 @@ static unsigned char file_merge_bits[] = { 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask -image create bitmap file_statechange -background white -foreground green -data { +image create bitmap file_statechange -background [get_config gui.background] -foreground green -data { #define file_statechange_width 14 #define file_statechange_height 15 static unsigned char file_statechange_bits[] = { @@ -3187,7 +3189,9 @@ 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 \ + -background [get_config gui.background] \ + -foreground [get_config gui.foreground] \ -borderwidth 0 \ -width 20 -height 10 \ -wrap none \ @@ -3209,7 +3213,9 @@ 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 \ + -background [get_config gui.background] \ + -foreground [get_config gui.foreground] \ -borderwidth 0 \ -width 20 -height 10 \ -wrap none \ @@ -3353,7 +3359,10 @@ if {![is_enabled nocommit]} { } textframe .vpane.lower.commarea.buffer.frame -ttext $ui_comm -background white -foreground black \ +ttext $ui_comm \ + -background [get_config gui.background] \ + -foreground [get_config gui.foreground] \ + -insertbackground [get_config gui.foreground] \ -borderwidth 1 \ -undo true \ -maxundo 20 \ @@ -3470,7 +3479,9 @@ bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y" # textframe .vpane.lower.diff.body set ui_diff .vpane.lower.diff.body.t -ttext $ui_diff -background white -foreground black \ +ttext $ui_diff \ + -background [get_config gui.background] \ + -foreground [get_config gui.foreground] \ -borderwidth 0 \ -width 80 -height 5 -wrap none \ -font font_diff \ diff --git a/lib/option.tcl b/lib/option.tcl index e43971bfa3e0..fd7ac1c4f3d9 100644 --- a/lib/option.tcl +++ b/lib/option.tcl @@ -88,6 +88,14 @@ proc save_config {} { } } +proc choose_color {title varname} { + upvar 1 $varname var + set color [tk_chooseColor -title $title -initialcolor $var] + if {$color ne ""} { + set var $color + } +} + proc do_options {} { global repo_config global_config font_descs global repo_config_new global_config_new @@ -162,6 +170,8 @@ proc do_options {} { {s gui.stageuntracked {mc "Staging of untracked files"} {list "yes" "no" "ask"}} {b gui.displayuntracked {mc "Show untracked files"}} {i-1..99 gui.tabsize {mc "Tab spacing"}} + {C gui.foreground {mc "Foreground Color"}} + {C gui.background {mc "Background Color"}} } { set type [lindex $option 0] set name [lindex $option 1] @@ -192,6 +202,7 @@ proc do_options {} { pack $w.$f.$optid -side top -anchor w -fill x } c - + C - t { ${NS}::frame $w.$f.$optid ${NS}::label $w.$f.$optid.l -text [mc "%s:" $text] @@ -211,6 +222,11 @@ proc do_options {} { -command [list popup_btn_menu \ $w.$f.$optid.m $w.$f.$optid.b] pack $w.$f.$optid.b -side left -anchor w + } elseif {$type eq {C}} { + ${NS}::button $w.$f.$optid.b \ + -text [mc "Change"] \ + -command [list choose_color $text ${f}_config_new($name)] + pack $w.$f.$optid.b -side left -anchor w } pack $w.$f.$optid -side top -anchor w -fill x }