git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-gui: Implement color configuration
@ 2019-02-11 21:42 Ismael Luceno
  0 siblings, 0 replies; 2+ messages in thread
From: Ismael Luceno @ 2019-02-11 21:42 UTC (permalink / raw)
  To: git; +Cc: Pat Thoyts, Ismael Luceno

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
---
 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
 			}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] git-gui: Implement color configuration
@ 2019-02-16  3:14 Ismael Luceno
  0 siblings, 0 replies; 2+ messages in thread
From: Ismael Luceno @ 2019-02-16  3:14 UTC (permalink / raw)
  To: git; +Cc: Pat Thoyts, Ismael Luceno

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
---
 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..3d7a2217f00c 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] -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
 			}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-16  3:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-11 21:42 [PATCH] git-gui: Implement color configuration Ismael Luceno
  -- strict thread matches above, loose matches on Subject: below --
2019-02-16  3:14 Ismael Luceno

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).