gitk: add proc run_themeloader
gitk currently accepts a single themeloader file via the config file, and will source this with errors reported to the console. This is fine for simple configuration, but will not support interactive theme exploration from the gui. In particular, a themeloader file must be sourced only once as the themes defined cannot be re-defined. Also, errors must be handled rather than just aborting while printing to the console. So, add a proc to handle the above, supporting expansion of the gui config pages. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Mark Levedahl committed
Sep 28, 2025 at 23:04 UTC
830c4578cdc4478e3e74286bb1d007e184700ae1
1 file changed
+21
-1
gitk
+21
-1
@@ -11861,6 +11861,23 @@ proc choose_extdiff {} {
11861
}
11862
}
11863
11864
+proc run_themeloader {f} {
11865
+ if {![info exists ::_themefiles_seen]} {
11866
+ set ::_themefiles_seen [dict create]
11867
+ }
11868
+
11869
+ set fn [file normalize $f]
11870
+ if {![dict exists $::_themefiles_seen $fn]} {
11871
+ if {[catch {source $fn} err]} {
11872
+ error_popup "could not interpret: $fn\n$err"
11873
+ dict set ::_themefiles_seen $fn 0
11874
+ } else {
11875
+ dict set ::_themefiles_seen $fn 1
11876
+ }
11877
+ }
11878
+ return [dict get $::_themefiles_seen $fn]
11879
+}
11880
+
11881
proc choosecolor {v vi prefspage x} {
11882
global $v
11883
@@ -12742,7 +12759,10 @@ set nullid2 "0000000000000000000000000000000000000001"
12759
set nullfile "/dev/null"
12760
12761
if {[file exists $themeloader]} {
12745
- source $themeloader
12762
+ if {[run_themeloader $themeloader] == 0} {
12763
+ puts stderr "Could not interpret themeloader: $themeloader"
12764
+ exit 1
12765
+ }
12766
}
12767
12768
set appname "gitk"