Fossil SCM

Provide a dark mode for the TCL/TK-based diff GUI.

danield 2023-12-05 16:02 trunk
Commit b59a42f1f6489389874253739c49e3af2e3b25519e294c9585aff013b5a4573d
2 files changed +32 -1 +6 -1
+32 -1
--- src/diff.tcl
+++ src/diff.tcl
@@ -8,11 +8,11 @@
88
# This header comment is stripped off by the "mkbuiltin.c" program.
99
#
1010
set prog {
1111
package require Tk
1212
13
-array set CFG {
13
+array set CFG_light {
1414
TITLE {Fossil Diff}
1515
LN_COL_BG #dddddd
1616
LN_COL_FG #444444
1717
TXT_COL_BG #ffffff
1818
TXT_COL_FG #000000
@@ -32,10 +32,41 @@
3232
WIDTH 80
3333
HEIGHT 45
3434
LB_HEIGHT 25
3535
}
3636
37
+array set CFG_dark {
38
+ TITLE {Fossil Diff}
39
+ LN_COL_BG #dddddd
40
+ LN_COL_FG #444444
41
+ TXT_COL_BG #3f3f3f
42
+ TXT_COL_FG #dcdccc
43
+ MKR_COL_BG #444444
44
+ MKR_COL_FG #dddddd
45
+ CHNG_BG #6a6afc
46
+ ADD_BG #57934c
47
+ RM_BG #ef6767
48
+ HR_FG #444444
49
+ HR_PAD_TOP 4
50
+ HR_PAD_BTM 8
51
+ FN_BG #5e5e5e
52
+ FN_FG #ffffff
53
+ FN_PAD 5
54
+ ERR_FG #ee0000
55
+ PADX 5
56
+ WIDTH 80
57
+ HEIGHT 45
58
+ LB_HEIGHT 25
59
+}
60
+
61
+array set CFG_arr {
62
+ 0 CFG_light
63
+ 1 CFG_dark
64
+}
65
+
66
+array set CFG [array get $CFG_arr($darkmode)]
67
+
3768
if {![namespace exists ttk]} {
3869
interp alias {} ::ttk::scrollbar {} ::scrollbar
3970
interp alias {} ::ttk::menubutton {} ::menubutton
4071
}
4172
4273
--- src/diff.tcl
+++ src/diff.tcl
@@ -8,11 +8,11 @@
8 # This header comment is stripped off by the "mkbuiltin.c" program.
9 #
10 set prog {
11 package require Tk
12
13 array set CFG {
14 TITLE {Fossil Diff}
15 LN_COL_BG #dddddd
16 LN_COL_FG #444444
17 TXT_COL_BG #ffffff
18 TXT_COL_FG #000000
@@ -32,10 +32,41 @@
32 WIDTH 80
33 HEIGHT 45
34 LB_HEIGHT 25
35 }
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37 if {![namespace exists ttk]} {
38 interp alias {} ::ttk::scrollbar {} ::scrollbar
39 interp alias {} ::ttk::menubutton {} ::menubutton
40 }
41
42
--- src/diff.tcl
+++ src/diff.tcl
@@ -8,11 +8,11 @@
8 # This header comment is stripped off by the "mkbuiltin.c" program.
9 #
10 set prog {
11 package require Tk
12
13 array set CFG_light {
14 TITLE {Fossil Diff}
15 LN_COL_BG #dddddd
16 LN_COL_FG #444444
17 TXT_COL_BG #ffffff
18 TXT_COL_FG #000000
@@ -32,10 +32,41 @@
32 WIDTH 80
33 HEIGHT 45
34 LB_HEIGHT 25
35 }
36
37 array set CFG_dark {
38 TITLE {Fossil Diff}
39 LN_COL_BG #dddddd
40 LN_COL_FG #444444
41 TXT_COL_BG #3f3f3f
42 TXT_COL_FG #dcdccc
43 MKR_COL_BG #444444
44 MKR_COL_FG #dddddd
45 CHNG_BG #6a6afc
46 ADD_BG #57934c
47 RM_BG #ef6767
48 HR_FG #444444
49 HR_PAD_TOP 4
50 HR_PAD_BTM 8
51 FN_BG #5e5e5e
52 FN_FG #ffffff
53 FN_PAD 5
54 ERR_FG #ee0000
55 PADX 5
56 WIDTH 80
57 HEIGHT 45
58 LB_HEIGHT 25
59 }
60
61 array set CFG_arr {
62 0 CFG_light
63 1 CFG_dark
64 }
65
66 array set CFG [array get $CFG_arr($darkmode)]
67
68 if {![namespace exists ttk]} {
69 interp alias {} ::ttk::scrollbar {} ::scrollbar
70 interp alias {} ::ttk::menubutton {} ::menubutton
71 }
72
73
+6 -1
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -956,10 +956,11 @@
956956
int i;
957957
Blob script;
958958
const char *zTempFile = 0;
959959
char *zCmd;
960960
const char *zTclsh;
961
+ int bDarkMode = find_option("dark",0,0)!=0;
961962
blob_zero(&script);
962963
blob_appendf(&script, "set fossilcmd {| \"%/\" %s -tcl -i -v",
963964
g.nameOfExe, zSubCmd);
964965
find_option("tcl",0,0);
965966
find_option("html",0,0);
@@ -982,11 +983,12 @@
982983
int j;
983984
blob_append(&script, " ", 1);
984985
for(j=0; z[j]; j++) blob_appendf(&script, "\\%03o", (unsigned char)z[j]);
985986
}
986987
}
987
- blob_appendf(&script, "}\n%s", builtin_file("diff.tcl", 0));
988
+ blob_appendf(&script, "}\nset darkmode %d\n", bDarkMode);
989
+ blob_appendf(&script, "%s", builtin_file("diff.tcl", 0));
988990
if( zTempFile ){
989991
blob_write_to_file(&script, zTempFile);
990992
fossil_print("To see diff, run: %s \"%s\"\n", zTclsh, zTempFile);
991993
}else{
992994
#if defined(FOSSIL_ENABLE_TCL)
@@ -1078,10 +1080,11 @@
10781080
** --by Shorthand for "--browser -y"
10791081
** -ci|--checkin VERSION Show diff of all changes in VERSION
10801082
** --command PROG External diff program. Overrides "diff-command"
10811083
** -c|--context N Show N lines of context around each change, with
10821084
** negative N meaning show all content
1085
+** --dark Use dark mode for the TCL/TK-based GUI
10831086
** --diff-binary BOOL Include binary files with external commands
10841087
** --exec-abs-paths Force absolute path names on external commands
10851088
** --exec-rel-paths Force relative path names on external commands
10861089
** -r|--from VERSION Select VERSION as source for the diff
10871090
** -w|--ignore-all-space Ignore white space when comparing lines
@@ -1114,10 +1117,12 @@
11141117
DiffConfig DCfg; /* Diff configuration object */
11151118
11161119
if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
11171120
diff_tk("diff", 2);
11181121
return;
1122
+ }else{
1123
+ find_option("dark", 0, 0);
11191124
}
11201125
isGDiff = g.argv[1][0]=='g';
11211126
zFrom = find_option("from", "r", 1);
11221127
zTo = find_option("to", 0, 1);
11231128
zCheckin = find_option("checkin", "ci", 1);
11241129
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -956,10 +956,11 @@
956 int i;
957 Blob script;
958 const char *zTempFile = 0;
959 char *zCmd;
960 const char *zTclsh;
 
961 blob_zero(&script);
962 blob_appendf(&script, "set fossilcmd {| \"%/\" %s -tcl -i -v",
963 g.nameOfExe, zSubCmd);
964 find_option("tcl",0,0);
965 find_option("html",0,0);
@@ -982,11 +983,12 @@
982 int j;
983 blob_append(&script, " ", 1);
984 for(j=0; z[j]; j++) blob_appendf(&script, "\\%03o", (unsigned char)z[j]);
985 }
986 }
987 blob_appendf(&script, "}\n%s", builtin_file("diff.tcl", 0));
 
988 if( zTempFile ){
989 blob_write_to_file(&script, zTempFile);
990 fossil_print("To see diff, run: %s \"%s\"\n", zTclsh, zTempFile);
991 }else{
992 #if defined(FOSSIL_ENABLE_TCL)
@@ -1078,10 +1080,11 @@
1078 ** --by Shorthand for "--browser -y"
1079 ** -ci|--checkin VERSION Show diff of all changes in VERSION
1080 ** --command PROG External diff program. Overrides "diff-command"
1081 ** -c|--context N Show N lines of context around each change, with
1082 ** negative N meaning show all content
 
1083 ** --diff-binary BOOL Include binary files with external commands
1084 ** --exec-abs-paths Force absolute path names on external commands
1085 ** --exec-rel-paths Force relative path names on external commands
1086 ** -r|--from VERSION Select VERSION as source for the diff
1087 ** -w|--ignore-all-space Ignore white space when comparing lines
@@ -1114,10 +1117,12 @@
1114 DiffConfig DCfg; /* Diff configuration object */
1115
1116 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
1117 diff_tk("diff", 2);
1118 return;
 
 
1119 }
1120 isGDiff = g.argv[1][0]=='g';
1121 zFrom = find_option("from", "r", 1);
1122 zTo = find_option("to", 0, 1);
1123 zCheckin = find_option("checkin", "ci", 1);
1124
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -956,10 +956,11 @@
956 int i;
957 Blob script;
958 const char *zTempFile = 0;
959 char *zCmd;
960 const char *zTclsh;
961 int bDarkMode = find_option("dark",0,0)!=0;
962 blob_zero(&script);
963 blob_appendf(&script, "set fossilcmd {| \"%/\" %s -tcl -i -v",
964 g.nameOfExe, zSubCmd);
965 find_option("tcl",0,0);
966 find_option("html",0,0);
@@ -982,11 +983,12 @@
983 int j;
984 blob_append(&script, " ", 1);
985 for(j=0; z[j]; j++) blob_appendf(&script, "\\%03o", (unsigned char)z[j]);
986 }
987 }
988 blob_appendf(&script, "}\nset darkmode %d\n", bDarkMode);
989 blob_appendf(&script, "%s", builtin_file("diff.tcl", 0));
990 if( zTempFile ){
991 blob_write_to_file(&script, zTempFile);
992 fossil_print("To see diff, run: %s \"%s\"\n", zTclsh, zTempFile);
993 }else{
994 #if defined(FOSSIL_ENABLE_TCL)
@@ -1078,10 +1080,11 @@
1080 ** --by Shorthand for "--browser -y"
1081 ** -ci|--checkin VERSION Show diff of all changes in VERSION
1082 ** --command PROG External diff program. Overrides "diff-command"
1083 ** -c|--context N Show N lines of context around each change, with
1084 ** negative N meaning show all content
1085 ** --dark Use dark mode for the TCL/TK-based GUI
1086 ** --diff-binary BOOL Include binary files with external commands
1087 ** --exec-abs-paths Force absolute path names on external commands
1088 ** --exec-rel-paths Force relative path names on external commands
1089 ** -r|--from VERSION Select VERSION as source for the diff
1090 ** -w|--ignore-all-space Ignore white space when comparing lines
@@ -1114,10 +1117,12 @@
1117 DiffConfig DCfg; /* Diff configuration object */
1118
1119 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
1120 diff_tk("diff", 2);
1121 return;
1122 }else{
1123 find_option("dark", 0, 0);
1124 }
1125 isGDiff = g.argv[1][0]=='g';
1126 zFrom = find_option("from", "r", 1);
1127 zTo = find_option("to", 0, 1);
1128 zCheckin = find_option("checkin", "ci", 1);
1129

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button