Fossil SCM
Attempt to get the CSS grid view in place for merge-info --html. It can't be tested until we fill out with content, though.
Commit
5eac2b1ba16fea470df548cbf68cc6fce4787b3ce651cf3c60c7e24e13d6ab17
Parent
ca7eceb92cb7915…
2 files changed
+21
-4
+66
-1
+21
-4
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -453,14 +453,31 @@ | ||
| 453 | 453 | @ |
| 454 | 454 | @ </style> |
| 455 | 455 | @ </head> |
| 456 | 456 | @ <body> |
| 457 | 457 | ; |
| 458 | -const char zWebpageEnd[] = | |
| 458 | +static const char zWebpageEnd[] = | |
| 459 | 459 | @ </body> |
| 460 | 460 | @ </html> |
| 461 | 461 | ; |
| 462 | + | |
| 463 | +/* | |
| 464 | +** Returns the diff webpage header, which includes the whole page | |
| 465 | +** prefix up to and including the BODY tag. If bDark is true, a | |
| 466 | +** dark-mode version is returned. The non-dark impl relies on browser | |
| 467 | +** preferences to determine whether to use dark mode. | |
| 468 | +*/ | |
| 469 | +const char * diff_webpage_header(int bDark){ | |
| 470 | + return bDark ? zWebpageHdrDark : zWebpageHdr; | |
| 471 | +} | |
| 472 | +/* | |
| 473 | +** Returns the diff webpage footer, which closes the body tag and | |
| 474 | +** page. | |
| 475 | +*/ | |
| 476 | +const char * diff_webpage_footer(void){ | |
| 477 | + return zWebpageEnd; | |
| 478 | +} | |
| 462 | 479 | |
| 463 | 480 | /* |
| 464 | 481 | ** State variables used by the --browser option for diff. These must |
| 465 | 482 | ** be static variables, not elements of DiffConfig, since they are |
| 466 | 483 | ** used by the interrupt handler. |
| @@ -516,12 +533,12 @@ | ||
| 516 | 533 | #else |
| 517 | 534 | SetConsoleCtrlHandler(diff_console_ctrl_handler, TRUE); |
| 518 | 535 | #endif |
| 519 | 536 | } |
| 520 | 537 | if( (pCfg->diffFlags & DIFF_WEBPAGE)!=0 ){ |
| 521 | - fossil_print("%s",(pCfg->diffFlags & DIFF_DARKMODE)!=0 ? zWebpageHdrDark : | |
| 522 | - zWebpageHdr); | |
| 538 | + fossil_print("%s",diff_webpage_header( | |
| 539 | + (pCfg->diffFlags & DIFF_DARKMODE)!=0)); | |
| 523 | 540 | fflush(stdout); |
| 524 | 541 | } |
| 525 | 542 | } |
| 526 | 543 | |
| 527 | 544 | /* Do any final output required by a diff and complete the diff |
| @@ -538,11 +555,11 @@ | ||
| 538 | 555 | if( (pCfg->diffFlags & DIFF_WEBPAGE)!=0 ){ |
| 539 | 556 | if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){ |
| 540 | 557 | const unsigned char *zJs = builtin_file("diff.js", 0); |
| 541 | 558 | fossil_print("<script>\n%s</script>\n", zJs); |
| 542 | 559 | } |
| 543 | - fossil_print("%s", zWebpageEnd); | |
| 560 | + fossil_print("%s", diff_webpage_footer()); | |
| 544 | 561 | } |
| 545 | 562 | if( (pCfg->diffFlags & DIFF_BROWSER)!=0 && nErr==0 ){ |
| 546 | 563 | char *zCmd = mprintf("%s %$", fossil_web_browser(), tempDiffFilename); |
| 547 | 564 | fclose(diffOut); |
| 548 | 565 | diffOut = fossil_freopen(NULL_DEVICE, "wb", stdout); |
| 549 | 566 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -453,14 +453,31 @@ | |
| 453 | @ |
| 454 | @ </style> |
| 455 | @ </head> |
| 456 | @ <body> |
| 457 | ; |
| 458 | const char zWebpageEnd[] = |
| 459 | @ </body> |
| 460 | @ </html> |
| 461 | ; |
| 462 | |
| 463 | /* |
| 464 | ** State variables used by the --browser option for diff. These must |
| 465 | ** be static variables, not elements of DiffConfig, since they are |
| 466 | ** used by the interrupt handler. |
| @@ -516,12 +533,12 @@ | |
| 516 | #else |
| 517 | SetConsoleCtrlHandler(diff_console_ctrl_handler, TRUE); |
| 518 | #endif |
| 519 | } |
| 520 | if( (pCfg->diffFlags & DIFF_WEBPAGE)!=0 ){ |
| 521 | fossil_print("%s",(pCfg->diffFlags & DIFF_DARKMODE)!=0 ? zWebpageHdrDark : |
| 522 | zWebpageHdr); |
| 523 | fflush(stdout); |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | /* Do any final output required by a diff and complete the diff |
| @@ -538,11 +555,11 @@ | |
| 538 | if( (pCfg->diffFlags & DIFF_WEBPAGE)!=0 ){ |
| 539 | if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){ |
| 540 | const unsigned char *zJs = builtin_file("diff.js", 0); |
| 541 | fossil_print("<script>\n%s</script>\n", zJs); |
| 542 | } |
| 543 | fossil_print("%s", zWebpageEnd); |
| 544 | } |
| 545 | if( (pCfg->diffFlags & DIFF_BROWSER)!=0 && nErr==0 ){ |
| 546 | char *zCmd = mprintf("%s %$", fossil_web_browser(), tempDiffFilename); |
| 547 | fclose(diffOut); |
| 548 | diffOut = fossil_freopen(NULL_DEVICE, "wb", stdout); |
| 549 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -453,14 +453,31 @@ | |
| 453 | @ |
| 454 | @ </style> |
| 455 | @ </head> |
| 456 | @ <body> |
| 457 | ; |
| 458 | static const char zWebpageEnd[] = |
| 459 | @ </body> |
| 460 | @ </html> |
| 461 | ; |
| 462 | |
| 463 | /* |
| 464 | ** Returns the diff webpage header, which includes the whole page |
| 465 | ** prefix up to and including the BODY tag. If bDark is true, a |
| 466 | ** dark-mode version is returned. The non-dark impl relies on browser |
| 467 | ** preferences to determine whether to use dark mode. |
| 468 | */ |
| 469 | const char * diff_webpage_header(int bDark){ |
| 470 | return bDark ? zWebpageHdrDark : zWebpageHdr; |
| 471 | } |
| 472 | /* |
| 473 | ** Returns the diff webpage footer, which closes the body tag and |
| 474 | ** page. |
| 475 | */ |
| 476 | const char * diff_webpage_footer(void){ |
| 477 | return zWebpageEnd; |
| 478 | } |
| 479 | |
| 480 | /* |
| 481 | ** State variables used by the --browser option for diff. These must |
| 482 | ** be static variables, not elements of DiffConfig, since they are |
| 483 | ** used by the interrupt handler. |
| @@ -516,12 +533,12 @@ | |
| 533 | #else |
| 534 | SetConsoleCtrlHandler(diff_console_ctrl_handler, TRUE); |
| 535 | #endif |
| 536 | } |
| 537 | if( (pCfg->diffFlags & DIFF_WEBPAGE)!=0 ){ |
| 538 | fossil_print("%s",diff_webpage_header( |
| 539 | (pCfg->diffFlags & DIFF_DARKMODE)!=0)); |
| 540 | fflush(stdout); |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | /* Do any final output required by a diff and complete the diff |
| @@ -538,11 +555,11 @@ | |
| 555 | if( (pCfg->diffFlags & DIFF_WEBPAGE)!=0 ){ |
| 556 | if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){ |
| 557 | const unsigned char *zJs = builtin_file("diff.js", 0); |
| 558 | fossil_print("<script>\n%s</script>\n", zJs); |
| 559 | } |
| 560 | fossil_print("%s", diff_webpage_footer()); |
| 561 | } |
| 562 | if( (pCfg->diffFlags & DIFF_BROWSER)!=0 && nErr==0 ){ |
| 563 | char *zCmd = mprintf("%s %$", fossil_web_browser(), tempDiffFilename); |
| 564 | fclose(diffOut); |
| 565 | diffOut = fossil_freopen(NULL_DEVICE, "wb", stdout); |
| 566 |
+66
-1
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -232,15 +232,80 @@ | ||
| 232 | 232 | blob_reset(&v2); |
| 233 | 233 | blob_reset(&out); |
| 234 | 234 | db_finalize(&q); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | +/* | |
| 238 | +** Append STYLE tag for (merge-info --html) to p. | |
| 239 | +** | |
| 240 | +** Design notes... | |
| 241 | +** | |
| 242 | +** Layout is based on the /vdiff view, with 4 main content columns: | |
| 243 | +** | |
| 244 | +** baseline | local | merged-in | merge-result | |
| 245 | +** | |
| 246 | +** With columns between each to mark the line numbers (here "#") and | |
| 247 | +** the change-type indicators (here "C"): | |
| 248 | +** | |
| 249 | +** # baseline C # local C # merged-in C # merge-result | |
| 250 | +** | |
| 251 | +** == 11 columns | |
| 252 | +** | |
| 253 | +** The C columns are, the context of a merge, initially only | |
| 254 | +** for spacing between an LHS and its RHS's line numbers, but | |
| 255 | +** we should probably apply change status markers like the | |
| 256 | +** diff view does. | |
| 257 | +*/ | |
| 258 | +static void merge_info_html_css(Blob *p){ | |
| 259 | + blob_append(p, "<style>\n", -1); | |
| 260 | + blob_append(p, "tr.diffchunk {\n" | |
| 261 | + "display: grid; gap: 0px 0px;\n" | |
| 262 | + "grid-template-rows: 1fr;\n" | |
| 263 | + "grid-template-columns: " | |
| 264 | + "auto 1fr auto " /* # baseline sep */ | |
| 265 | + "auto 1fr auto " /* # local sep */ | |
| 266 | + "auto 1fr auto " /* # merged-in sep */ | |
| 267 | + "auto 1fr" /* # merge-result */ | |
| 268 | + ";\n" | |
| 269 | + "grid-template-areas: \"" | |
| 270 | + "mrgBaseLn mrgBase mrgBaseSep " | |
| 271 | + "mrgLocalLn mrgLocal mrgLocalSep " | |
| 272 | + "mrgMILn mrgMI mrgMISep " | |
| 273 | + "mrgResLn mrgRes\";\n" | |
| 274 | + "}\n", -1); | |
| 275 | +#define DA(N) blob_append(p,"td." # N " {grid-area: " # N "}\n", -1) | |
| 276 | + DA(mrgBaseLn); | |
| 277 | + DA(mrgBase); | |
| 278 | + DA(mrgBaseSep); | |
| 279 | + DA(mrgLocalLn); | |
| 280 | + DA(mrgLocal); | |
| 281 | + DA(mrgLocalSep); | |
| 282 | + DA(mrgMILn); | |
| 283 | + DA(mrgMI); | |
| 284 | + DA(mrgMISep); | |
| 285 | + DA(mrgResLn); | |
| 286 | + DA(mrgRes); | |
| 287 | +#undef DA | |
| 288 | + blob_append(p, "</style>\n", -1); | |
| 289 | +} | |
| 290 | + | |
| 291 | +/* | |
| 292 | +** The HTML counterpart of merge_info_tk(). | |
| 293 | +*/ | |
| 237 | 294 | static void merge_info_html(int bBrowser, /* 0=HTML only, no browser */ |
| 238 | 295 | int bDark, /* use dark mode */ |
| 239 | 296 | int bAll, /* All changes, not just merged content */ |
| 240 | 297 | int nContext /* Diff context lines */){ |
| 241 | - /* TODO */ | |
| 298 | + Blob out = empty_blob; | |
| 299 | + | |
| 300 | + blob_append(&out, diff_webpage_header(bDark), -1); | |
| 301 | + merge_info_html_css(&out); | |
| 302 | + | |
| 303 | + blob_append(&out, diff_webpage_footer(), -1); | |
| 304 | + blob_append_char(&out, '\n'); | |
| 305 | + blob_write_to_file(&out, "-"); | |
| 306 | + blob_reset(&out); | |
| 242 | 307 | } |
| 243 | 308 | |
| 244 | 309 | /* |
| 245 | 310 | ** COMMAND: merge-info |
| 246 | 311 | ** |
| 247 | 312 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -232,15 +232,80 @@ | |
| 232 | blob_reset(&v2); |
| 233 | blob_reset(&out); |
| 234 | db_finalize(&q); |
| 235 | } |
| 236 | |
| 237 | static void merge_info_html(int bBrowser, /* 0=HTML only, no browser */ |
| 238 | int bDark, /* use dark mode */ |
| 239 | int bAll, /* All changes, not just merged content */ |
| 240 | int nContext /* Diff context lines */){ |
| 241 | /* TODO */ |
| 242 | } |
| 243 | |
| 244 | /* |
| 245 | ** COMMAND: merge-info |
| 246 | ** |
| 247 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -232,15 +232,80 @@ | |
| 232 | blob_reset(&v2); |
| 233 | blob_reset(&out); |
| 234 | db_finalize(&q); |
| 235 | } |
| 236 | |
| 237 | /* |
| 238 | ** Append STYLE tag for (merge-info --html) to p. |
| 239 | ** |
| 240 | ** Design notes... |
| 241 | ** |
| 242 | ** Layout is based on the /vdiff view, with 4 main content columns: |
| 243 | ** |
| 244 | ** baseline | local | merged-in | merge-result |
| 245 | ** |
| 246 | ** With columns between each to mark the line numbers (here "#") and |
| 247 | ** the change-type indicators (here "C"): |
| 248 | ** |
| 249 | ** # baseline C # local C # merged-in C # merge-result |
| 250 | ** |
| 251 | ** == 11 columns |
| 252 | ** |
| 253 | ** The C columns are, the context of a merge, initially only |
| 254 | ** for spacing between an LHS and its RHS's line numbers, but |
| 255 | ** we should probably apply change status markers like the |
| 256 | ** diff view does. |
| 257 | */ |
| 258 | static void merge_info_html_css(Blob *p){ |
| 259 | blob_append(p, "<style>\n", -1); |
| 260 | blob_append(p, "tr.diffchunk {\n" |
| 261 | "display: grid; gap: 0px 0px;\n" |
| 262 | "grid-template-rows: 1fr;\n" |
| 263 | "grid-template-columns: " |
| 264 | "auto 1fr auto " /* # baseline sep */ |
| 265 | "auto 1fr auto " /* # local sep */ |
| 266 | "auto 1fr auto " /* # merged-in sep */ |
| 267 | "auto 1fr" /* # merge-result */ |
| 268 | ";\n" |
| 269 | "grid-template-areas: \"" |
| 270 | "mrgBaseLn mrgBase mrgBaseSep " |
| 271 | "mrgLocalLn mrgLocal mrgLocalSep " |
| 272 | "mrgMILn mrgMI mrgMISep " |
| 273 | "mrgResLn mrgRes\";\n" |
| 274 | "}\n", -1); |
| 275 | #define DA(N) blob_append(p,"td." # N " {grid-area: " # N "}\n", -1) |
| 276 | DA(mrgBaseLn); |
| 277 | DA(mrgBase); |
| 278 | DA(mrgBaseSep); |
| 279 | DA(mrgLocalLn); |
| 280 | DA(mrgLocal); |
| 281 | DA(mrgLocalSep); |
| 282 | DA(mrgMILn); |
| 283 | DA(mrgMI); |
| 284 | DA(mrgMISep); |
| 285 | DA(mrgResLn); |
| 286 | DA(mrgRes); |
| 287 | #undef DA |
| 288 | blob_append(p, "</style>\n", -1); |
| 289 | } |
| 290 | |
| 291 | /* |
| 292 | ** The HTML counterpart of merge_info_tk(). |
| 293 | */ |
| 294 | static void merge_info_html(int bBrowser, /* 0=HTML only, no browser */ |
| 295 | int bDark, /* use dark mode */ |
| 296 | int bAll, /* All changes, not just merged content */ |
| 297 | int nContext /* Diff context lines */){ |
| 298 | Blob out = empty_blob; |
| 299 | |
| 300 | blob_append(&out, diff_webpage_header(bDark), -1); |
| 301 | merge_info_html_css(&out); |
| 302 | |
| 303 | blob_append(&out, diff_webpage_footer(), -1); |
| 304 | blob_append_char(&out, '\n'); |
| 305 | blob_write_to_file(&out, "-"); |
| 306 | blob_reset(&out); |
| 307 | } |
| 308 | |
| 309 | /* |
| 310 | ** COMMAND: merge-info |
| 311 | ** |
| 312 |