Fossil SCM

Make the dark mode also available for the diff HTML output (--webpage, -b[y]).

danield 2023-12-07 10:39 tk-diff-darkmode
Commit 6b7fe7fa9573174bdb99dbc88973d519b8e5082b41cffd25ce20ed4132f3e1ef
2 files changed +2 +110 -5
+2
--- src/diff.c
+++ src/diff.c
@@ -48,10 +48,11 @@
4848
#define DIFF_DEBUG 0x00020000 /* Debugging diff output */
4949
#define DIFF_RAW 0x00040000 /* Raw triples - for debugging */
5050
#define DIFF_TCL 0x00080000 /* For the --tk option */
5151
#define DIFF_INCBINARY 0x00100000 /* The --diff-binary option */
5252
#define DIFF_SHOW_VERS 0x00200000 /* Show compared versions */
53
+#define DIFF_DARKMODE 0x00400000 /* Use dark mode for HTML */
5354
5455
/*
5556
** These error messages are shared in multiple locations. They are defined
5657
** here for consistency.
5758
*/
@@ -3160,10 +3161,11 @@
31603161
}
31613162
if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
31623163
if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
31633164
if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT;
31643165
if( find_option("versions","h",0)!=0 ) diffFlags |= DIFF_SHOW_VERS;
3166
+ if( find_option("dark",0,0)!=0 ) diffFlags |= DIFF_DARKMODE;
31653167
if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
31663168
if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
31673169
if( find_option("internal","i",0)==0
31683170
&& (diffFlags & (DIFF_HTML|DIFF_TCL|DIFF_DEBUG|DIFF_JSON))==0
31693171
){
31703172
--- src/diff.c
+++ src/diff.c
@@ -48,10 +48,11 @@
48 #define DIFF_DEBUG 0x00020000 /* Debugging diff output */
49 #define DIFF_RAW 0x00040000 /* Raw triples - for debugging */
50 #define DIFF_TCL 0x00080000 /* For the --tk option */
51 #define DIFF_INCBINARY 0x00100000 /* The --diff-binary option */
52 #define DIFF_SHOW_VERS 0x00200000 /* Show compared versions */
 
53
54 /*
55 ** These error messages are shared in multiple locations. They are defined
56 ** here for consistency.
57 */
@@ -3160,10 +3161,11 @@
3160 }
3161 if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
3162 if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
3163 if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT;
3164 if( find_option("versions","h",0)!=0 ) diffFlags |= DIFF_SHOW_VERS;
 
3165 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
3166 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
3167 if( find_option("internal","i",0)==0
3168 && (diffFlags & (DIFF_HTML|DIFF_TCL|DIFF_DEBUG|DIFF_JSON))==0
3169 ){
3170
--- src/diff.c
+++ src/diff.c
@@ -48,10 +48,11 @@
48 #define DIFF_DEBUG 0x00020000 /* Debugging diff output */
49 #define DIFF_RAW 0x00040000 /* Raw triples - for debugging */
50 #define DIFF_TCL 0x00080000 /* For the --tk option */
51 #define DIFF_INCBINARY 0x00100000 /* The --diff-binary option */
52 #define DIFF_SHOW_VERS 0x00200000 /* Show compared versions */
53 #define DIFF_DARKMODE 0x00400000 /* Use dark mode for HTML */
54
55 /*
56 ** These error messages are shared in multiple locations. They are defined
57 ** here for consistency.
58 */
@@ -3160,10 +3161,11 @@
3161 }
3162 if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
3163 if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
3164 if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT;
3165 if( find_option("versions","h",0)!=0 ) diffFlags |= DIFF_SHOW_VERS;
3166 if( find_option("dark",0,0)!=0 ) diffFlags |= DIFF_DARKMODE;
3167 if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
3168 if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
3169 if( find_option("internal","i",0)==0
3170 && (diffFlags & (DIFF_HTML|DIFF_TCL|DIFF_DEBUG|DIFF_JSON))==0
3171 ){
3172
+110 -5
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -213,11 +213,11 @@
213213
}
214214
}
215215
216216
217217
/*
218
-** Default header text for diff with --webpage
218
+** Default header texts for diff with --webpage
219219
*/
220220
static const char zWebpageHdr[] =
221221
@ <!DOCTYPE html>
222222
@ <html>
223223
@ <head>
@@ -314,10 +314,116 @@
314314
@ }
315315
@
316316
@ </style>
317317
@ </head>
318318
@ <body>
319
+;
320
+static const char zWebpageHdrDark[] =
321
+@ <!DOCTYPE html>
322
+@ <html>
323
+@ <head>
324
+@ <meta charset="UTF-8">
325
+@ <style>
326
+@ body {
327
+@ background-color: #353535;
328
+@ color: #ffffff;
329
+@ }
330
+@ h1 {
331
+@ font-size: 150%;
332
+@ }
333
+@
334
+@ table.diff {
335
+@ width: 100%;
336
+@ border-spacing: 0;
337
+@ border: 1px solid black;
338
+@ line-height: inherit;
339
+@ font-size: inherit;
340
+@ }
341
+@ table.diff td {
342
+@ vertical-align: top;
343
+@ line-height: inherit;
344
+@ font-size: inherit;
345
+@ }
346
+@ table.diff pre {
347
+@ margin: 0 0 0 0;
348
+@ line-height: inherit;
349
+@ font-size: inherit;
350
+@ }
351
+@ td.diffln {
352
+@ width: 1px;
353
+@ text-align: right;
354
+@ padding: 0 1em 0 0;
355
+@ }
356
+@ td.difflne {
357
+@ padding-bottom: 0.4em;
358
+@ }
359
+@ td.diffsep {
360
+@ width: 1px;
361
+@ padding: 0 0.3em 0 1em;
362
+@ line-height: inherit;
363
+@ font-size: inherit;
364
+@ }
365
+@ td.diffsep pre {
366
+@ line-height: inherit;
367
+@ font-size: inherit;
368
+@ }
369
+@ td.difftxt pre {
370
+@ overflow-x: auto;
371
+@ }
372
+@ td.diffln ins {
373
+@ background-color: #559855;
374
+@ color: #000000;
375
+@ text-decoration: none;
376
+@ line-height: inherit;
377
+@ font-size: inherit;
378
+@ }
379
+@ td.diffln del {
380
+@ background-color: #cc5555;
381
+@ color: #000000;
382
+@ text-decoration: none;
383
+@ line-height: inherit;
384
+@ font-size: inherit;
385
+@ }
386
+@ td.difftxt del {
387
+@ background-color: #f9cfcf;
388
+@ color: #000000;
389
+@ text-decoration: none;
390
+@ line-height: inherit;
391
+@ font-size: inherit;
392
+@ }
393
+@ td.difftxt del > del {
394
+@ background-color: #cc5555;
395
+@ color: #000000;
396
+@ text-decoration: none;
397
+@ font-weight: bold;
398
+@ }
399
+@ td.difftxt del > del.edit {
400
+@ background-color: #c0c0ff;
401
+@ text-decoration: none;
402
+@ font-weight: bold;
403
+@ }
404
+@ td.difftxt ins {
405
+@ background-color: #a2dbb2;
406
+@ color: #000000;
407
+@ text-decoration: none;
408
+@ line-height: inherit;
409
+@ font-size: inherit;
410
+@ }
411
+@ td.difftxt ins > ins {
412
+@ background-color: #559855;
413
+@ text-decoration: none;
414
+@ font-weight: bold;
415
+@ }
416
+@ td.difftxt ins > ins.edit {
417
+@ background-color: #c0c0ff;
418
+@ text-decoration: none;
419
+@ font-weight: bold;
420
+@ }
421
+@
422
+@ </style>
423
+@ </head>
424
+@ <body>
319425
;
320426
const char zWebpageEnd[] =
321427
@ </body>
322428
@ </html>
323429
;
@@ -378,11 +484,12 @@
378484
#else
379485
SetConsoleCtrlHandler(diff_console_ctrl_handler, TRUE);
380486
#endif
381487
}
382488
if( (pCfg->diffFlags & DIFF_WEBPAGE)!=0 ){
383
- fossil_print("%s",zWebpageHdr);
489
+ fossil_print("%s",(pCfg->diffFlags & DIFF_DARKMODE)!=0 ? zWebpageHdrDark :
490
+ zWebpageHdr);
384491
fflush(stdout);
385492
}
386493
}
387494
388495
/* Do any final output required by a diff and complete the diff
@@ -1080,11 +1187,11 @@
10801187
** --by Shorthand for "--browser -y"
10811188
** -ci|--checkin VERSION Show diff of all changes in VERSION
10821189
** --command PROG External diff program. Overrides "diff-command"
10831190
** -c|--context N Show N lines of context around each change, with
10841191
** negative N meaning show all content
1085
-** --dark Use dark mode for the TCL/TK-based GUI
1192
+** --dark Use dark mode for the TCL/TK-based GUI and HTML
10861193
** --diff-binary BOOL Include binary files with external commands
10871194
** --exec-abs-paths Force absolute path names on external commands
10881195
** --exec-rel-paths Force relative path names on external commands
10891196
** -r|--from VERSION Select VERSION as source for the diff
10901197
** -w|--ignore-all-space Ignore white space when comparing lines
@@ -1117,12 +1224,10 @@
11171224
DiffConfig DCfg; /* Diff configuration object */
11181225
11191226
if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
11201227
diff_tk("diff", 2);
11211228
return;
1122
- }else{
1123
- find_option("dark", 0, 0);
11241229
}
11251230
isGDiff = g.argv[1][0]=='g';
11261231
zFrom = find_option("from", "r", 1);
11271232
zTo = find_option("to", 0, 1);
11281233
zCheckin = find_option("checkin", "ci", 1);
11291234
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -213,11 +213,11 @@
213 }
214 }
215
216
217 /*
218 ** Default header text for diff with --webpage
219 */
220 static const char zWebpageHdr[] =
221 @ <!DOCTYPE html>
222 @ <html>
223 @ <head>
@@ -314,10 +314,116 @@
314 @ }
315 @
316 @ </style>
317 @ </head>
318 @ <body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319 ;
320 const char zWebpageEnd[] =
321 @ </body>
322 @ </html>
323 ;
@@ -378,11 +484,12 @@
378 #else
379 SetConsoleCtrlHandler(diff_console_ctrl_handler, TRUE);
380 #endif
381 }
382 if( (pCfg->diffFlags & DIFF_WEBPAGE)!=0 ){
383 fossil_print("%s",zWebpageHdr);
 
384 fflush(stdout);
385 }
386 }
387
388 /* Do any final output required by a diff and complete the diff
@@ -1080,11 +1187,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
@@ -1117,12 +1224,10 @@
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
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -213,11 +213,11 @@
213 }
214 }
215
216
217 /*
218 ** Default header texts for diff with --webpage
219 */
220 static const char zWebpageHdr[] =
221 @ <!DOCTYPE html>
222 @ <html>
223 @ <head>
@@ -314,10 +314,116 @@
314 @ }
315 @
316 @ </style>
317 @ </head>
318 @ <body>
319 ;
320 static const char zWebpageHdrDark[] =
321 @ <!DOCTYPE html>
322 @ <html>
323 @ <head>
324 @ <meta charset="UTF-8">
325 @ <style>
326 @ body {
327 @ background-color: #353535;
328 @ color: #ffffff;
329 @ }
330 @ h1 {
331 @ font-size: 150%;
332 @ }
333 @
334 @ table.diff {
335 @ width: 100%;
336 @ border-spacing: 0;
337 @ border: 1px solid black;
338 @ line-height: inherit;
339 @ font-size: inherit;
340 @ }
341 @ table.diff td {
342 @ vertical-align: top;
343 @ line-height: inherit;
344 @ font-size: inherit;
345 @ }
346 @ table.diff pre {
347 @ margin: 0 0 0 0;
348 @ line-height: inherit;
349 @ font-size: inherit;
350 @ }
351 @ td.diffln {
352 @ width: 1px;
353 @ text-align: right;
354 @ padding: 0 1em 0 0;
355 @ }
356 @ td.difflne {
357 @ padding-bottom: 0.4em;
358 @ }
359 @ td.diffsep {
360 @ width: 1px;
361 @ padding: 0 0.3em 0 1em;
362 @ line-height: inherit;
363 @ font-size: inherit;
364 @ }
365 @ td.diffsep pre {
366 @ line-height: inherit;
367 @ font-size: inherit;
368 @ }
369 @ td.difftxt pre {
370 @ overflow-x: auto;
371 @ }
372 @ td.diffln ins {
373 @ background-color: #559855;
374 @ color: #000000;
375 @ text-decoration: none;
376 @ line-height: inherit;
377 @ font-size: inherit;
378 @ }
379 @ td.diffln del {
380 @ background-color: #cc5555;
381 @ color: #000000;
382 @ text-decoration: none;
383 @ line-height: inherit;
384 @ font-size: inherit;
385 @ }
386 @ td.difftxt del {
387 @ background-color: #f9cfcf;
388 @ color: #000000;
389 @ text-decoration: none;
390 @ line-height: inherit;
391 @ font-size: inherit;
392 @ }
393 @ td.difftxt del > del {
394 @ background-color: #cc5555;
395 @ color: #000000;
396 @ text-decoration: none;
397 @ font-weight: bold;
398 @ }
399 @ td.difftxt del > del.edit {
400 @ background-color: #c0c0ff;
401 @ text-decoration: none;
402 @ font-weight: bold;
403 @ }
404 @ td.difftxt ins {
405 @ background-color: #a2dbb2;
406 @ color: #000000;
407 @ text-decoration: none;
408 @ line-height: inherit;
409 @ font-size: inherit;
410 @ }
411 @ td.difftxt ins > ins {
412 @ background-color: #559855;
413 @ text-decoration: none;
414 @ font-weight: bold;
415 @ }
416 @ td.difftxt ins > ins.edit {
417 @ background-color: #c0c0ff;
418 @ text-decoration: none;
419 @ font-weight: bold;
420 @ }
421 @
422 @ </style>
423 @ </head>
424 @ <body>
425 ;
426 const char zWebpageEnd[] =
427 @ </body>
428 @ </html>
429 ;
@@ -378,11 +484,12 @@
484 #else
485 SetConsoleCtrlHandler(diff_console_ctrl_handler, TRUE);
486 #endif
487 }
488 if( (pCfg->diffFlags & DIFF_WEBPAGE)!=0 ){
489 fossil_print("%s",(pCfg->diffFlags & DIFF_DARKMODE)!=0 ? zWebpageHdrDark :
490 zWebpageHdr);
491 fflush(stdout);
492 }
493 }
494
495 /* Do any final output required by a diff and complete the diff
@@ -1080,11 +1187,11 @@
1187 ** --by Shorthand for "--browser -y"
1188 ** -ci|--checkin VERSION Show diff of all changes in VERSION
1189 ** --command PROG External diff program. Overrides "diff-command"
1190 ** -c|--context N Show N lines of context around each change, with
1191 ** negative N meaning show all content
1192 ** --dark Use dark mode for the TCL/TK-based GUI and HTML
1193 ** --diff-binary BOOL Include binary files with external commands
1194 ** --exec-abs-paths Force absolute path names on external commands
1195 ** --exec-rel-paths Force relative path names on external commands
1196 ** -r|--from VERSION Select VERSION as source for the diff
1197 ** -w|--ignore-all-space Ignore white space when comparing lines
@@ -1117,12 +1224,10 @@
1224 DiffConfig DCfg; /* Diff configuration object */
1225
1226 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
1227 diff_tk("diff", 2);
1228 return;
 
 
1229 }
1230 isGDiff = g.argv[1][0]=='g';
1231 zFrom = find_option("from", "r", 1);
1232 zTo = find_option("to", 0, 1);
1233 zCheckin = find_option("checkin", "ci", 1);
1234

Keyboard Shortcuts

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