{"thread":{"id":"50469","subject":"[PATCH] git-gui: Implement color configuration","startedAt":"2019-02-11T21:51:08Z","lastAt":"2019-02-11T21:51:08Z","messageCount":1,"participants":["Ismael Luceno"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"369045","messageId":"20190211214213.32501-1-ismael@iodev.co.uk","threadId":"50469","inReplyTo":null,"subject":"[PATCH] git-gui: Implement color configuration","fromName":"Ismael Luceno","fromEmail":"ismael@iodev.co.uk","sentAt":"2019-02-11T21:42:13Z","receivedAt":"2019-02-11T21:51:08Z","isPatch":true,"sender":{"key":"ismael@iodev.co.uk","avatar":"https://avatars.githubusercontent.com/u/426980?v=4"},"body":"Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>\n---\n git-gui.sh     | 33 ++++++++++++++++++++++-----------\n lib/option.tcl | 16 ++++++++++++++++\n 2 files changed, 38 insertions(+), 11 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex e00d9a345294..01e5462dc70e 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -903,6 +903,8 @@ set font_descs {\n }\n set default_config(gui.stageuntracked) ask\n set default_config(gui.displayuntracked) true\n+set default_config(gui.foreground) black\n+set default_config(gui.background) white\n \n ######################################################################\n ##\n@@ -2004,7 +2006,7 @@ static unsigned char mask_bits[] = {\n    0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};\n }\n \n-image create bitmap file_plain -background white -foreground black -data {\n+image create bitmap file_plain -background [get_config gui.background white] -foreground black -data {\n #define plain_width 14\n #define plain_height 15\n static unsigned char plain_bits[] = {\n@@ -2013,7 +2015,7 @@ static unsigned char plain_bits[] = {\n    0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};\n } -maskdata $filemask\n \n-image create bitmap file_mod -background white -foreground blue -data {\n+image create bitmap file_mod -background [get_config gui.background] -foreground blue -data {\n #define mod_width 14\n #define mod_height 15\n static unsigned char mod_bits[] = {\n@@ -2022,7 +2024,7 @@ static unsigned char mod_bits[] = {\n    0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};\n } -maskdata $filemask\n \n-image create bitmap file_fulltick -background white -foreground \"#007000\" -data {\n+image create bitmap file_fulltick -background [get_config gui.background] -foreground \"#007000\" -data {\n #define file_fulltick_width 14\n #define file_fulltick_height 15\n static unsigned char file_fulltick_bits[] = {\n@@ -2031,7 +2033,7 @@ static unsigned char file_fulltick_bits[] = {\n    0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};\n } -maskdata $filemask\n \n-image create bitmap file_question -background white -foreground black -data {\n+image create bitmap file_question -background [get_config gui.background] -foreground black -data {\n #define file_question_width 14\n #define file_question_height 15\n static unsigned char file_question_bits[] = {\n@@ -2040,7 +2042,7 @@ static unsigned char file_question_bits[] = {\n    0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};\n } -maskdata $filemask\n \n-image create bitmap file_removed -background white -foreground red -data {\n+image create bitmap file_removed -background [get_config gui.background] -foreground red -data {\n #define file_removed_width 14\n #define file_removed_height 15\n static unsigned char file_removed_bits[] = {\n@@ -2049,7 +2051,7 @@ static unsigned char file_removed_bits[] = {\n    0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};\n } -maskdata $filemask\n \n-image create bitmap file_merge -background white -foreground blue -data {\n+image create bitmap file_merge -background [get_config gui.background] -foreground blue -data {\n #define file_merge_width 14\n #define file_merge_height 15\n static unsigned char file_merge_bits[] = {\n@@ -2058,7 +2060,7 @@ static unsigned char file_merge_bits[] = {\n    0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};\n } -maskdata $filemask\n \n-image create bitmap file_statechange -background white -foreground green -data {\n+image create bitmap file_statechange -background [get_config gui.background] -foreground green -data {\n #define file_statechange_width 14\n #define file_statechange_height 15\n static unsigned char file_statechange_bits[] = {\n@@ -3187,7 +3189,9 @@ pack .vpane -anchor n -side top -fill both -expand 1\n textframe .vpane.files.workdir -height 100 -width 200\n tlabel .vpane.files.workdir.title -text [mc \"Unstaged Changes\"] \\\n \t-background lightsalmon -foreground black\n-ttext $ui_workdir -background white -foreground black \\\n+ttext $ui_workdir \\\n+\t-background [get_config gui.background] \\\n+\t-foreground [get_config gui.foreground] \\\n \t-borderwidth 0 \\\n \t-width 20 -height 10 \\\n \t-wrap none \\\n@@ -3209,7 +3213,9 @@ textframe .vpane.files.index -height 100 -width 200\n tlabel .vpane.files.index.title \\\n \t-text [mc \"Staged Changes (Will Commit)\"] \\\n \t-background lightgreen -foreground black\n-ttext $ui_index -background white -foreground black \\\n+ttext $ui_index \\\n+\t-background [get_config gui.background] \\\n+\t-foreground [get_config gui.foreground] \\\n \t-borderwidth 0 \\\n \t-width 20 -height 10 \\\n \t-wrap none \\\n@@ -3353,7 +3359,10 @@ if {![is_enabled nocommit]} {\n }\n \n textframe .vpane.lower.commarea.buffer.frame\n-ttext $ui_comm -background white -foreground black \\\n+ttext $ui_comm \\\n+\t-background [get_config gui.background] \\\n+\t-foreground [get_config gui.foreground] \\\n+\t-insertbackground [get_config gui.foreground] \\\n \t-borderwidth 1 \\\n \t-undo true \\\n \t-maxundo 20 \\\n@@ -3470,7 +3479,9 @@ bind_button3 .vpane.lower.diff.header.path \"tk_popup $ctxm %X %Y\"\n #\n textframe .vpane.lower.diff.body\n set ui_diff .vpane.lower.diff.body.t\n-ttext $ui_diff -background white -foreground black \\\n+ttext $ui_diff \\\n+\t-background [get_config gui.background] \\\n+\t-foreground [get_config gui.foreground] \\\n \t-borderwidth 0 \\\n \t-width 80 -height 5 -wrap none \\\n \t-font font_diff \\\ndiff --git a/lib/option.tcl b/lib/option.tcl\nindex e43971bfa3e0..fd7ac1c4f3d9 100644\n--- a/lib/option.tcl\n+++ b/lib/option.tcl\n@@ -88,6 +88,14 @@ proc save_config {} {\n \t}\n }\n \n+proc choose_color {title varname} {\n+\tupvar 1 $varname var\n+\tset color [tk_chooseColor -title $title -initialcolor $var]\n+\tif {$color ne \"\"} {\n+\t\tset var $color\n+\t}\n+}\n+\n proc do_options {} {\n \tglobal repo_config global_config font_descs\n \tglobal repo_config_new global_config_new\n@@ -162,6 +170,8 @@ proc do_options {} {\n \t\t{s gui.stageuntracked {mc \"Staging of untracked files\"} {list \"yes\" \"no\" \"ask\"}}\n \t\t{b gui.displayuntracked {mc \"Show untracked files\"}}\n \t\t{i-1..99 gui.tabsize {mc \"Tab spacing\"}}\n+\t\t{C gui.foreground {mc \"Foreground Color\"}}\n+\t\t{C gui.background {mc \"Background Color\"}}\n \t\t} {\n \t\tset type [lindex $option 0]\n \t\tset name [lindex $option 1]\n@@ -192,6 +202,7 @@ proc do_options {} {\n \t\t\t\tpack $w.$f.$optid -side top -anchor w -fill x\n \t\t\t}\n \t\t\tc -\n+\t\t\tC -\n \t\t\tt {\n \t\t\t\t${NS}::frame $w.$f.$optid\n \t\t\t\t${NS}::label $w.$f.$optid.l -text [mc \"%s:\" $text]\n@@ -211,6 +222,11 @@ proc do_options {} {\n \t\t\t\t\t\t-command [list popup_btn_menu \\\n \t\t\t\t\t\t\t$w.$f.$optid.m $w.$f.$optid.b]\n \t\t\t\t\tpack $w.$f.$optid.b -side left -anchor w\n+\t\t\t\t} elseif {$type eq {C}} {\n+\t\t\t\t\t${NS}::button $w.$f.$optid.b \\\n+\t\t\t\t\t\t-text [mc \"Change\"] \\\n+\t\t\t\t\t\t-command [list choose_color $text ${f}_config_new($name)]\n+\t\t\t\t\tpack $w.$f.$optid.b -side left -anchor w\n \t\t\t\t}\n \t\t\t\tpack $w.$f.$optid -side top -anchor w -fill x\n \t\t\t}\n-- \n2.20.1\n\n"}]}