Skip to content

Commit 830c457

Browse files
committed
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 <[email protected]>
1 parent 83a2de9 commit 830c457

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

gitk

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11861,6 +11861,23 @@ proc choose_extdiff {} {
1186111861
}
1186211862
}
1186311863
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+
1186411881
proc choosecolor {v vi prefspage x} {
1186511882
global $v
1186611883
@@ -12742,7 +12759,10 @@ set nullid2 "0000000000000000000000000000000000000001"
1274212759
set nullfile "/dev/null"
1274312760
1274412761
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+
}
1274612766
}
1274712767
1274812768
set appname "gitk"

0 commit comments

Comments
 (0)