Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch diff-word-wrap Excluding Merge-Ins
This is equivalent to a diff from 92372ce946 to 5fbb14f73a
2024-12-17
| ||
12:38 | Send the --from argument of the "fossil ui" command encoded as hexadecimal, to work around quoting problems on Windows. [forum:/forumpost/cfc22d41b19a1a96|Forum post cfc22d41b19a1a96]. ... (check-in: 593ceca27d user: drh tags: trunk) | |
06:56 | Sync with trunk. ... (Leaf check-in: 5fbb14f73a user: florian tags: diff-word-wrap) | |
06:36 | Sync with trunk. ... (Leaf check-in: 361fc76769 user: florian tags: diff-keyboard-navigation) | |
06:26 | Sync with trunk. ... (Leaf check-in: 215fc593d0 user: florian tags: timeline-keyboard-navigation) | |
06:12 | On the new /ckout UI page, output the page footer only once. ... (check-in: 92372ce946 user: florian tags: trunk) | |
2024-12-16
| ||
16:22 | Add missing word in the help text for 'merge'. ... (check-in: bdc6bb1cfb user: danield tags: trunk) | |
2024-12-13
| ||
17:11 | Sync with trunk. ... (check-in: 4d7277762f user: florian tags: diff-word-wrap) | |
Changes to src/default.css.
︙ | ︙ | |||
555 556 557 558 559 560 561 | /* Rules governing diff layout and colors */ table.diff { width: 100%; border-spacing: 0; border-radius: 5px; border: 1px solid black; | < < < < < < < < | < < < | | > > | | > | | | < < | > | > | < < | | > | | > | < < < < < | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | /* Rules governing diff layout and colors */ table.diff { width: 100%; border-spacing: 0; border-radius: 5px; border: 1px solid black; } table.diff td { vertical-align: top; text-align: left; margin: 0; padding: 0; border: 0; font-family: monospace; line-height: 1.275; text-size-adjust: none; white-space: pre-wrap; word-wrap: break-word; } table.diff td del, table.diff td ins { padding: calc((1em*1.275 - 1em)/2) 0; text-decoration: none; } table.diff td.diffln { width: 0%; text-align: right; padding: 0 0.16em 0 0.32em; } table.diff td.difflne { text-align: left; padding: 0 0.32em; } table.diff td.diffsep { width: 0%; padding: 0 0.32em 0 0.16em; } tr.diffskip.jchunk { /* jchunk gets added from JS to diffskip rows when they are plugged into the /jchunk route. */ background-color: aliceblue; padding: 0; } |
︙ | ︙ | |||
621 622 623 624 625 626 627 | text-align: left; } tr.diffskip > td.chunkctrl > div { display: flex; align-items: center; } tr.diffskip > td.chunkctrl > div > span.error { | | | 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | text-align: left; } tr.diffskip > td.chunkctrl > div { display: flex; align-items: center; } tr.diffskip > td.chunkctrl > div > span.error { padding: 2px; border-radius: 0.5em; } tr.diffskip > td.chunkctrl .jcbutton /* class name .button breaks w/ some skins! */ { min-width: 3.5ex; max-width: 3.5ex; text-align: center; |
︙ | ︙ | |||
666 667 668 669 670 671 672 | content: '⇡⇣'; } tr.diffskip > td.chunkctrl .jcbutton:hover { cursor: pointer; opacity: 1; filter: contrast(1); } | | | | | | | < < < < < < < < | < | | < < | | > > | < < | < | | | < < < | < < < | | < | < < | < < | | < | | < < | < > > > | < | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | content: '⇡⇣'; } tr.diffskip > td.chunkctrl .jcbutton:hover { cursor: pointer; opacity: 1; filter: contrast(1); } td.difftxt { max-width: 0; overflow-x: hidden; overflow-y: hidden; } td.difftxtu { width: 100%; } td.difftxtl, td.difftxtr { width: 50%; } td.diffln.nul, td.diffsep.nul, td.difftxt.nul { background-color: #f9f9f9; } td.diffln.del, td.diffsep.del, td.difftxt.del { background-color: #ffe8e8; } td.diffln.ins, td.diffsep.ins, td.difftxt.ins { background-color: #dafbe1; } td.difftxt.del del { background-color: #ffc0c0; } td.difftxt.del del.edit { background-color: #c0c0ff; } td.difftxt.ins ins { background-color: #a0e4b2; } td.difftxt.ins ins.edit { background-color: #c0c0ff; } table.diff td.diffln, table.diff td.diffsep, table.splitdiff.select_right td.difftxtl, table.splitdiff.select_left td.difftxtr { user-select: none; } body.tkt div.content li > table.udiff { margin-left: 1.5em; margin-top: 0.5em; } body.tkt div.content ol.tkt-changes > li:target > p > span { border-bottom: 3px solid gold; |
︙ | ︙ |
Changes to src/diff.c.
︙ | ︙ | |||
1030 1031 1032 1033 1034 1035 1036 | void (*xInsert)(DiffBuilder*,const DLine*); void (*xDelete)(DiffBuilder*,const DLine*); void (*xReplace)(DiffBuilder*,const DLine*,const DLine*); void (*xEdit)(DiffBuilder*,const DLine*,const DLine*); void (*xEnd)(DiffBuilder*); unsigned int lnLeft; /* Lines seen on the left (delete) side */ unsigned int lnRight; /* Lines seen on the right (insert) side */ | < | | 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 | void (*xInsert)(DiffBuilder*,const DLine*); void (*xDelete)(DiffBuilder*,const DLine*); void (*xReplace)(DiffBuilder*,const DLine*,const DLine*); void (*xEdit)(DiffBuilder*,const DLine*,const DLine*); void (*xEnd)(DiffBuilder*); unsigned int lnLeft; /* Lines seen on the left (delete) side */ unsigned int lnRight; /* Lines seen on the right (insert) side */ int eState; /* State of the output */ int width; /* Display width */ Blob *pOut; /* Output blob */ Blob bBuf2; /* Storage to hold retained lines */ DiffConfig *pCfg; /* Configuration information */ }; /************************* DiffBuilderDebug ********************************/ /* This version of DiffBuilder is used for debugging the diff and diff ** diff formatter logic. It is accessed using the (undocumented) --debug ** option to the diff command. The output is human-readable text that |
︙ | ︙ | |||
1322 1323 1324 1325 1326 1327 1328 | /************************* DiffBuilderUnified********************************/ /* This formatter generates a unified diff for HTML. ** ** The result is a <table> with four columns. The four columns hold: ** ** 1. The line numbers for the first file. ** 2. The line numbers for the second file. | | | | | < | | < < | < < < | < | | < < < | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < | < | | > | | | > | | > > > > | | > | | | < < > | | | | | > | < < < < < < < < < < < < | < < < < < < < < < < > | | | | | | | | | | | | > > > | > > | | | | | | | | | > < | | | < < < < | | > | < | > | > | | | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < | | < < > | > > | | > | | | | > < < | | | > | | > | > | < < > | | > | | | | > | < < < < < < < | < < < < < < < < > | > > | | | | | | | | | | | < | | | | | | | | > < | | < < < < < | 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 | /************************* DiffBuilderUnified********************************/ /* This formatter generates a unified diff for HTML. ** ** The result is a <table> with four columns. The four columns hold: ** ** 1. The line numbers for the first file. ** 2. The line numbers for the second file. ** 3. The "diff mark": "+", "-" or blank. ** 4. Text of the line. ** ** The table cells holding the inserted and deleted lines are assigned to CSS ** classes .nul, .ins or .del to color them accordingly. The changed parts of ** each line have additional <ins> or <del> elements. The CSS needs to be set ** up such that the <ins> or <del> intensify the background color of the .ins ** and .del CSS classes. ** ** Accumulator strategy: ** ** * Retained insert text goes to p->bBuf2 ** * Anything else goes directly to p->pOut ** ** eState is 1 if the last line was a deletion. */ static void dfunifiedFinishDelete(DiffBuilder *p){ if( p->eState==0 ) return; p->eState = 0; } static void dfunifiedFinishInsert(DiffBuilder *p){ if( blob_size(&p->bBuf2)==0 ) return; dfunifiedFinishDelete(p); blob_append_xfer(p->pOut,&p->bBuf2); } static void dfunifiedFinishRow(DiffBuilder *p){ dfunifiedFinishDelete(p); dfunifiedFinishInsert(p); } static void dfunifiedStartRow(DiffBuilder *p){ } static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){ dfunifiedFinishRow(p); if( p->pCfg && p->pCfg->zLeftHash ){ blob_appendf(p->pOut, "<tr class=\"diffskip\" data-startln=\"%d\" data-endln=\"%d\"" " id=\"skip%xh%xi%x\">\n", p->lnLeft+1, p->lnLeft+n, nChunk, p->lnLeft, n); }else{ blob_append(p->pOut, "<tr>", 4); } blob_append(p->pOut, "<td class=\"diffln difflne\" colspan=\"4\">" "︙</td></tr>\n", -1); p->lnLeft += n; p->lnRight += n; } static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){ dfunifiedStartRow(p); dfunifiedFinishDelete(p); dfunifiedFinishInsert(p); p->lnLeft++; p->lnRight++; blob_append (p->pOut, "<tr class=\"diffline\">", 21); blob_appendf(p->pOut, "<td class=\"diffln difflnl\">%d</td>", p->lnLeft); blob_appendf(p->pOut, "<td class=\"diffln difflnr\">%d</td>", p->lnRight); blob_append (p->pOut, "<td class=\"diffsep\"></td>", 25); blob_append (p->pOut, "<td class=\"difftxt difftxtu\">", 29); htmlize_to_blob(p->pOut, pLine->z, (int)pLine->n); blob_append (p->pOut, "</td>", 5); blob_append (p->pOut, "</tr>\n", 6); } static void dfunifiedInsert(DiffBuilder *p, const DLine *pLine){ dfunifiedStartRow(p); p->lnRight++; blob_append (&p->bBuf2, "<tr class=\"diffline\">", 21); blob_append (&p->bBuf2, "<td class=\"diffln difflnl ins\"></td>", 36); blob_appendf(&p->bBuf2, "<td class=\"diffln difflnr ins\">%d</td>", p->lnRight); blob_append (&p->bBuf2, "<td class=\"diffsep ins\">+</td>", 30); blob_append (&p->bBuf2, "<td class=\"difftxt difftxtu ins\"><ins>", 38); htmlize_to_blob(&p->bBuf2, pLine->z, (int)pLine->n); blob_append (&p->bBuf2, "</ins></td>", 11); blob_append (&p->bBuf2, "</tr>\n", 6); } static void dfunifiedDelete(DiffBuilder *p, const DLine *pLine){ dfunifiedStartRow(p); dfunifiedFinishInsert(p); if( p->eState==0 ){ dfunifiedFinishInsert(p); p->eState = 1; } p->lnLeft++; blob_append (p->pOut, "<tr class=\"diffline\">", 21); blob_appendf(p->pOut, "<td class=\"diffln difflnl del\">%d</td>", p->lnLeft); blob_append (p->pOut, "<td class=\"diffln difflnr del\"></td>", 36); blob_append (p->pOut, "<td class=\"diffsep del\">-</td>", 30); blob_append (p->pOut, "<td class=\"difftxt difftxtu del\"><del>", 38); htmlize_to_blob(p->pOut, pLine->z, (int)pLine->n); blob_append (p->pOut, "</del></td>", 11); blob_append (p->pOut, "</tr>\n", 6); } static void dfunifiedReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ fossil_fatal("The seemingly unused function dfunifiedReplace() was called!"); } static void dfunifiedEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ int i; int x; LineChange chng; oneLineChange(pX, pY, &chng); dfunifiedStartRow(p); if( p->eState==0 ){ dfunifiedFinishInsert(p); p->eState = 1; } p->lnLeft++; p->lnRight++; blob_append (p->pOut, "<tr class=\"diffline\">", 21); blob_appendf(p->pOut, "<td class=\"diffln difflnl del\">%d</td>", p->lnLeft); blob_append (p->pOut, "<td class=\"diffln difflnr del\"></td>", 36); blob_append (p->pOut, "<td class=\"diffsep del\">-</td>", 30); blob_append (p->pOut, "<td class=\"difftxt difftxtu del\">", 33); for( i=x=0; i<chng.n; i++ ){ int ofst = chng.a[i].iStart1; int len = chng.a[i].iLen1; if( len ){ htmlize_to_blob(p->pOut, pX->z+x, ofst - x); x = ofst; blob_append(p->pOut, "<del>", 5); htmlize_to_blob(p->pOut, pX->z+x, len); x += len; blob_append(p->pOut, "</del>", 6); } } htmlize_to_blob(p->pOut, pX->z+x, pX->n - x); blob_append (p->pOut, "</td>", 5); blob_append (p->pOut, "</tr>\n", 6); blob_append (&p->bBuf2, "<tr class=\"diffline\">", 21); blob_append (&p->bBuf2, "<td class=\"diffln difflnl ins\"></td>", 36); blob_appendf(&p->bBuf2, "<td class=\"diffln difflnr ins\">%d</td>", p->lnRight); blob_append (&p->bBuf2, "<td class=\"diffsep ins\">+</td>", 30); blob_append (&p->bBuf2, "<td class=\"difftxt difftxtu ins\">", 33); for( i=x=0; i<chng.n; i++ ){ int ofst = chng.a[i].iStart2; int len = chng.a[i].iLen2; if( len ){ htmlize_to_blob(&p->bBuf2, pY->z+x, ofst - x); x = ofst; blob_append(&p->bBuf2, "<ins>", 5); htmlize_to_blob(&p->bBuf2, pY->z+x, len); x += len; blob_append(&p->bBuf2, "</ins>", 6); } } htmlize_to_blob(&p->bBuf2, pY->z+x, pY->n - x); blob_append (&p->bBuf2, "</td>", 5); blob_append (&p->bBuf2, "</tr>\n", 6); } static void dfunifiedEnd(DiffBuilder *p){ dfunifiedFinishRow(p); blob_append(p->pOut, "</table>\n", 9); blob_reset(&p->bBuf2); fossil_free(p); } static DiffBuilder *dfunifiedNew(Blob *pOut, DiffConfig *pCfg){ DiffBuilder *p = fossil_malloc(sizeof(*p)); p->xSkip = dfunifiedSkip; p->xCommon = dfunifiedCommon; p->xInsert = dfunifiedInsert; p->xDelete = dfunifiedDelete; p->xReplace = dfunifiedReplace; p->xEdit = dfunifiedEdit; p->xEnd = dfunifiedEnd; p->lnLeft = p->lnRight = 0; p->eState = 0; p->pOut = pOut; if( pCfg->zLeftHash ){ blob_appendf(pOut, "<table class=\"diff udiff\" data-lefthash=\"%s\">\n", pCfg->zLeftHash); }else{ blob_append(pOut, "<table class=\"diff udiff\">\n", 27); } blob_init(&p->bBuf2, 0, 0); p->pCfg = pCfg; return p; } /************************* DiffBuilderSplit ******************************/ /* This formatter creates a side-by-side diff in HTML. The output is a ** <table> with 6 columns: ** ** 1. Line numbers for the first file. ** 2. First difference mark: "+", "-" or blank. ** 3. Text for the first file. ** 4. Line numbers for the second file. ** 5. Second difference mark: "+", "-" or blank. ** 6. Text for the second file. ** ** The styling approach with .nul, .ins and .del CSS classes and <ins> and ** <del> elements is the same as for the unified diffs above. In fact, the ** same CSS can be used for both. ** ** Accumulator strategy: ** ** * All output goes directly to p->pOut ** ** eState is not unused. */ static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){ if( p->pCfg && p->pCfg->zLeftHash ){ blob_appendf(p->pOut, "<tr class=\"diffskip\" data-startln=\"%d\" data-endln=\"%d\"" " id=\"skip%xh%xi%x\">\n", p->lnLeft+1, p->lnLeft+n, nChunk, p->lnLeft, n); }else{ blob_append(p->pOut, "<tr>", 4); } blob_append(p->pOut, "<td class=\"diffln difflnl difflne\" colspan=\"3\">︙</td>" "<td class=\"diffln difflnr difflne\" colspan=\"3\">︙</td>" "</tr>\n", -1); p->lnLeft += n; p->lnRight += n; } static void dfsplitCommon(DiffBuilder *p, const DLine *pLine){ p->lnLeft++; p->lnRight++; blob_append (p->pOut, "<tr class=\"diffline\">", 21); blob_appendf(p->pOut, "<td class=\"diffln difflnl\">%d</td>", p->lnLeft); blob_append (p->pOut, "<td class=\"diffsep\"></td>", 25); blob_append (p->pOut, "<td class=\"difftxt difftxtl\">", 29); htmlize_to_blob(p->pOut, pLine->z, (int)pLine->n); blob_append (p->pOut, "</td>", 5); blob_appendf(p->pOut, "<td class=\"diffln difflnr\">%d</td>", p->lnRight); blob_append (p->pOut, "<td class=\"diffsep\"></td>", 25); blob_append (p->pOut, "<td class=\"difftxt difftxtr\">", 29); htmlize_to_blob(p->pOut, pLine->z, (int)pLine->n); blob_append (p->pOut, "</td>", 5); blob_append (p->pOut, "</tr>\n", 6); } static void dfsplitInsert(DiffBuilder *p, const DLine *pLine){ p->lnRight++; blob_append (p->pOut, "<tr class=\"diffline\">", 21); blob_append (p->pOut, "<td class=\"diffln difflnl nul\"></td>", 36); blob_append (p->pOut, "<td class=\"diffsep nul\"></td>", 29); blob_append (p->pOut, "<td class=\"difftxt difftxtl nul\"></td>", 38); blob_appendf(p->pOut, "<td class=\"diffln difflnr ins\">%d</td>", p->lnRight); blob_append (p->pOut, "<td class=\"diffsep ins\">+</td>", 30); blob_append (p->pOut, "<td class=\"difftxt difftxtr ins\"><ins>", 38); htmlize_to_blob(p->pOut, pLine->z, (int)pLine->n); blob_append (p->pOut, "</ins></td>", 11); blob_append (p->pOut, "</tr>\n", 6); } static void dfsplitDelete(DiffBuilder *p, const DLine *pLine){ p->lnLeft++; blob_append (p->pOut, "<tr class=\"diffline\">", 21); blob_appendf(p->pOut, "<td class=\"diffln difflnl del\">%d</td>", p->lnLeft); blob_append (p->pOut, "<td class=\"diffsep del\">-</td>", 30); blob_append (p->pOut, "<td class=\"difftxt difftxtl del\"><del>", 38); htmlize_to_blob(p->pOut, pLine->z, (int)pLine->n); blob_append (p->pOut, "</del></td>", 11); blob_append (p->pOut, "<td class=\"diffln difflnr nul\"></td>", 36); blob_append (p->pOut, "<td class=\"diffsep nul\"></td>", 29); blob_append (p->pOut, "<td class=\"difftxt difftxtr nul\"></td>", 38); blob_append (p->pOut, "</tr>\n", 6); } static void dfsplitReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ fossil_fatal("The seemingly unused function dfsplitReplace() was called!"); } static void dfsplitEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ int i; int x; LineChange chng; oneLineChange(pX, pY, &chng); p->lnLeft++; p->lnRight++; blob_append (p->pOut, "<tr class=\"diffline\">", 21); blob_appendf(p->pOut, "<td class=\"diffln difflnl del\">%d</td>", p->lnLeft); blob_append (p->pOut, "<td class=\"diffsep del\">-</td>", 30); blob_append (p->pOut, "<td class=\"difftxt difftxtl del\">", 33); for( i=x=0; i<chng.n; i++ ){ int ofst = chng.a[i].iStart1; int len = chng.a[i].iLen1; if( len ){ htmlize_to_blob(p->pOut, pX->z+x, ofst - x); x = ofst; if( chng.a[i].iLen2 ){ blob_append(p->pOut, "<del class=\"edit\">", 18); }else{ blob_append(p->pOut, "<del>", 5); } htmlize_to_blob(p->pOut, pX->z+x, len); x += len; blob_append(p->pOut, "</del>", 6); } } htmlize_to_blob(p->pOut, pX->z+x, pX->n - x); blob_append (p->pOut, "</td>", 5); blob_appendf(p->pOut, "<td class=\"diffln difflnr ins\">%d</td>", p->lnRight); blob_append (p->pOut, "<td class=\"diffsep ins\">+</td>", 30); blob_append (p->pOut, "<td class=\"difftxt difftxtr ins\">", 33); for( i=x=0; i<chng.n; i++ ){ int ofst = chng.a[i].iStart2; int len = chng.a[i].iLen2; if( len ){ htmlize_to_blob(p->pOut, pY->z+x, ofst - x); x = ofst; if( chng.a[i].iLen1 ){ blob_append(p->pOut, "<ins class=\"edit\">", 18); }else{ blob_append(p->pOut, "<ins>", 5); } htmlize_to_blob(p->pOut, pY->z+x, len); x += len; blob_append(p->pOut, "</ins>", 6); } } htmlize_to_blob(p->pOut, pY->z+x, pY->n - x); blob_append (p->pOut, "</td>", 5); blob_append (p->pOut, "</tr>\n", 6); } static void dfsplitEnd(DiffBuilder *p){ blob_append(p->pOut, "</table>\n", 9); fossil_free(p); } static DiffBuilder *dfsplitNew(Blob *pOut, DiffConfig *pCfg){ DiffBuilder *p = fossil_malloc(sizeof(*p)); p->xSkip = dfsplitSkip; p->xCommon = dfsplitCommon; p->xInsert = dfsplitInsert; p->xDelete = dfsplitDelete; p->xReplace = dfsplitReplace; p->xEdit = dfsplitEdit; p->xEnd = dfsplitEnd; p->lnLeft = p->lnRight = 0; p->eState = 0; p->pOut = pOut; if( pCfg->zLeftHash ){ blob_appendf(pOut, "<table class=\"diff splitdiff\" data-lefthash=\"%s\">\n", pCfg->zLeftHash); }else{ blob_append(pOut, "<table class=\"diff splitdiff\">\n", 31); } p->pCfg = pCfg; return p; } /************************* DiffBuilderSbs ******************************/ /* This formatter creates a side-by-side diff in text. */ |
︙ | ︙ |
Changes to src/diff.js.
|
| | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 | /* TODO: Run tools/makemake.tcl to regenerate the makefiles and to remove this ** file from the built-in files if it remains unused. */ |
Changes to src/diffcmd.c.
︙ | ︙ | |||
228 229 230 231 232 233 234 | @ <style> @ body { @ background-color: white; @ } @ h1 { @ font-size: 150%; @ } | < > < < > > > > > | | > > | | | | | | | | > | | | | < < | | | > | | | < | < | | > > | < < < > > | < < < > > | | < < | | < < | | < < < | < < | < < > < | > > | < | | > | > | | > | < < | < | | < | < > < < > < < > > > > > | | > > | | | | | | | | > | | | | < < | | | > | | | | | < < < | > > | < < < < > > | > < < < < > > | < | < | | > | < < | | < < < < | < < | < < < | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | @ <style> @ body { @ background-color: white; @ } @ h1 { @ font-size: 150%; @ } @ table.diff { @ width: 100%; @ border-spacing: 0; @ border-radius: 5px; @ border: 1px solid black; @ } @ table.diff td { @ vertical-align: top; @ text-align: left; @ margin: 0; @ padding: 0; @ border: 0; @ font-family: monospace; @ line-height: 1.275; @ text-size-adjust: none; @ white-space: pre-wrap; @ word-wrap: break-word; @ } @ table.diff td del, @ table.diff td ins { @ padding: calc((1em*1.275 - 1em)/2) 0; @ text-decoration: none; @ } @ table.diff td.diffln { @ width: 0%; @ text-align: right; @ padding: 0 0.16em 0 0.32em; @ } @ table.diff td.difflne { @ text-align: left; @ padding: 0 0.32em; @ } @ table.diff td.diffsep { @ width: 0%; @ padding: 0 0.32em 0 0.16em; @ } @ td.difftxt { @ max-width: 0; @ overflow-x: hidden; @ overflow-y: hidden; @ } @ td.difftxtu { @ width: 100%; @ } @ td.difftxtl, @ td.difftxtr { @ width: 50%; @ } @ td.diffln.nul, @ td.diffsep.nul, @ td.difftxt.nul { @ background-color: #f9f9f9; @ } @ td.diffln.del, @ td.diffsep.del, @ td.difftxt.del { @ background-color: #ffe8e8; @ } @ td.diffln.ins, @ td.diffsep.ins, @ td.difftxt.ins { @ background-color: #dafbe1; @ } @ td.difftxt.del del { @ background-color: #ffc0c0; @ } @ td.difftxt.del del.edit { @ background-color: #c0c0ff; @ } @ td.difftxt.ins ins { @ background-color: #a0e4b2; @ } @ td.difftxt.ins ins.edit { @ background-color: #c0c0ff; @ } @ @media (prefers-color-scheme: dark) { @ body { @ color: #fff; @ background-color: #353535; @ } @ td.diffln.nul, @ td.diffsep.nul, @ td.difftxt.nul { @ background-color: #454545; @ } @ td.diffln.del, @ td.diffsep.del, @ td.difftxt.del { @ color: #000; @ background-color: #f9cfcf; @ } @ td.diffln.ins, @ td.diffsep.ins, @ td.difftxt.ins { @ color: #000; @ background-color: #a2dbb2; @ } @ td.difftxt.del del { @ background-color: #cc5555; @ } @ td.difftxt.ins ins { @ background-color: #559855; @ } @ } @ </style> @ </head> @ <body> ; static const char zWebpageHdrDark[] = @ <!DOCTYPE html> @ <html> @ <head> @ <meta charset="UTF-8"> @ <style> @ body { @ color: #fff; @ background-color: #353535; @ } @ h1 { @ font-size: 150%; @ } @ table.diff { @ width: 100%; @ border-spacing: 0; @ border-radius: 5px; @ border: 1px solid black; @ } @ table.diff td { @ vertical-align: top; @ text-align: left; @ margin: 0; @ padding: 0; @ border: 0; @ font-family: monospace; @ line-height: 1.275; @ text-size-adjust: none; @ white-space: pre-wrap; @ word-wrap: break-word; @ } @ table.diff td del, @ table.diff td ins { @ padding: calc((1em*1.275 - 1em)/2) 0; @ text-decoration: none; @ } @ table.diff td.diffln { @ width: 0%; @ text-align: right; @ padding: 0 0.16em 0 0.32em; @ } @ table.diff td.difflne { @ text-align: left; @ padding: 0 0.32em; @ } @ table.diff td.diffsep { @ width: 0%; @ padding: 0 0.32em 0 0.16em; @ } @ td.difftxt { @ max-width: 0; @ overflow-x: hidden; @ overflow-y: hidden; @ } @ td.difftxtu { @ width: 100%; @ } @ td.difftxtl, @ td.difftxtr { @ width: 50%; @ } @ td.diffln.nul, @ td.diffsep.nul, @ td.difftxt.nul { @ background-color: #454545; @ } @ td.diffln.del, @ td.diffsep.del, @ td.difftxt.del { @ color: #000; @ background-color: #f9cfcf; @ } @ td.diffln.ins, @ td.diffsep.ins, @ td.difftxt.ins { @ color: #000; @ background-color: #a2dbb2; @ } @ td.difftxt.del del { @ color: #000; @ background-color: #cc5555; @ } @ td.difftxt.del del.edit { @ background-color: #c0c0ff; @ } @ td.difftxt.ins ins { @ background-color: #559855; @ } @ td.difftxt.ins ins.edit { @ background-color: #c0c0ff; @ } @ </style> @ </head> @ <body> ; const char zWebpageEnd[] = @ </body> @ </html> |
︙ | ︙ |
Changes to src/fossil.diff.js.
︙ | ︙ | |||
159 160 161 162 163 164 165 | line-numer column in the given tr. isSplit must be true if tr represents a split diff, else false. Expects its tr to be valid: GIGO applies. Returns the starting line number if getStart, else the ending line number. Returns the line number from the LHS file if getLHS is true, else the RHS. */ const extractLineNo = function f(getLHS, getStart, tr, isSplit){ | < < < < < < < < | < < | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | line-numer column in the given tr. isSplit must be true if tr represents a split diff, else false. Expects its tr to be valid: GIGO applies. Returns the starting line number if getStart, else the ending line number. Returns the line number from the LHS file if getLHS is true, else the RHS. */ const extractLineNo = function f(getLHS, getStart, tr, isSplit){ var n = getLHS ? 0 : isSplit ? 3 : 1; return parseInt(tr.childNodes[n].innerText); }; /** Installs chunk-loading controls into TR.diffskip element tr. Each instance corresponds to a single TR.diffskip element. The goal is to base these controls roughly on github's, a good |
︙ | ︙ | |||
202 203 204 205 206 207 208 | neighboring TR blocks */ startLhs: +tr.dataset.startln, endLhs: +tr.dataset.endln }; D.clearElement(tr); this.e.td = D.addClass( /* Holder for our UI controls */ | | | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | neighboring TR blocks */ startLhs: +tr.dataset.startln, endLhs: +tr.dataset.endln }; D.clearElement(tr); this.e.td = D.addClass( /* Holder for our UI controls */ D.attr(D.td(tr), 'colspan', this.isSplit ? 6 : 4), 'chunkctrl' ); this.e.msgWidget = D.addClass(D.span(), 'hidden'); this.e.btnWrapper = D.div(); D.append(this.e.td, this.e.btnWrapper); /** Depending on various factors, we need one or more of: |
︙ | ︙ | |||
367 368 369 370 371 372 373 | lines/*response lines*/){ if(!lines.length){ /* No more data to load */ this.destroy(); return this; } this.msg(false); | | | < | | | | > | < < | < < < | > | < < | < < > | < < < < < < < < | | < > > > | < < > | > | < | < < < < | < | > | < | | < | < < < | | > > | < | < | | < < < | > | > | < < < < | | | | | | | < < < < < | > | < | < < < < < > > < < > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | lines/*response lines*/){ if(!lines.length){ /* No more data to load */ this.destroy(); return this; } this.msg(false); var startLnR = -2147483648; /* ⚠ */ switch( fetchType ){ case this.FetchType.PrevDown: startLnR = this.pos.prev.endRhs + 1; break; case this.FetchType.NextUp: startLnR = this.pos.next.startRhs - lines.length; break; case this.FetchType.FillGap: startLnR = this.pos.prev ? this.pos.prev.endRhs + 1 : this.pos.next.startRhs - lines.length; break; } const lnTo = Math.min(urlParam.to, urlParam.from + lines.length - 1/*b/c request range is inclusive*/); function createDiffCommonLine(isSplit,lnl,lnr,txt){ var tr, td; tr = document.createElement('tr'); tr.className = 'diffline'; td = document.createElement('td'); td.className = 'diffln difflnl'; td.appendChild(document.createTextNode(lnl)); tr.appendChild(td); if( isSplit ){ td = document.createElement('td'); td.className = 'diffsep'; tr.appendChild(td); td = document.createElement('td'); td.className = 'difftxt difftxtl'; td.appendChild(document.createTextNode(txt)); tr.appendChild(td); } td = document.createElement('td'); td.className = 'diffln difflnlr'; td.appendChild(document.createTextNode(lnr)); tr.appendChild(td); td = document.createElement('td'); td.className = 'diffsep'; tr.appendChild(td); td = document.createElement('td'); td.className = 'difftxt difftxt' + ( isSplit ? 'r' : 'u' ); td.appendChild(document.createTextNode(txt)); tr.appendChild(td); return tr; } if( fetchType==this.FetchType.NextUp ){ for( i=lnTo; i>=urlParam.from; i-- ){ var tr = createDiffCommonLine( this.isSplit,i,startLnR+i-urlParam.from,lines[i-urlParam.from]); this.e.tr.parentElement.insertBefore(tr,this.e.tr.nextElementSibling); } }else{ for( i=urlParam.from; i<=lnTo; i++ ){ var tr = createDiffCommonLine( this.isSplit,i,startLnR+i-urlParam.from,lines[i-urlParam.from]); this.e.tr.parentElement.insertBefore(tr,this.e.tr); } } if(this.FetchType.FillGap===fetchType){ this.destroy(); return this; }else if(this.FetchType.PrevDown===fetchType){ this.pos.startLhs += lines.length; this.pos.prev.endRhs += lines.length; this.pos.prev.endLhs += lines.length; if(lines.length < (urlParam.to - urlParam.from)){ /* No more data. */ this.destroy(); }else{ this.maybeReplaceButtons(); this.updatePosDebug(); } return this; }else if(this.FetchType.NextUp===fetchType){ this.pos.endLhs -= lines.length; this.pos.next.startRhs -= lines.length; this.pos.next.startLhs -= lines.length; if(this.pos.endLhs<1 || lines.length < (urlParam.to - urlParam.from)){ /* No more data. */ this.destroy(); }else{ this.maybeReplaceButtons(); this.updatePosDebug(); |
︙ | ︙ | |||
686 687 688 689 690 691 692 | new ChunkLoadControls(D.addClass(tr, 'jchunk')); }); }); return F; }; Diff.setupDiffContextLoad(); }); | < | > | | > | < | < < < < < < | < < < < < < < < < < < < < < < > | < < | < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < | < < < | < < < < < | < | | | > > | | < < < < < < < < | < < < < < | < < < < < < < < < < < < | < < | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | new ChunkLoadControls(D.addClass(tr, 'jchunk')); }); }); return F; }; Diff.setupDiffContextLoad(); }); /* Click-handler for side-by-side diffs to activate text selection for the most ** recently clicked side (left or right). If the click-handler target is one of ** the simple-nested <del> or <ins> elements, the parent <td> is deciding. Note ** the "pointerdown" event seems to be exactly what is desired here: activating ** the clicked side just before the selection operation starts. */ (function(){ window.addEventListener('load',function(){ var s = document.getElementsByClassName('splitdiff'); for( var i=0; i<s.length; i++ ){ s[i].addEventListener('pointerdown',splitdiff_click); } }); function splitdiff_click(e){ var n = e.target.nodeName, t = n=='DEL' || n=='INS' ? e.target.parentElement : e.target; if( /\bdifftxtl\b/.test(t.className) ){ var s = document.getElementsByClassName('splitdiff'); for( var i=0; i<s.length; i++ ){ s[i].classList.remove('select_right'); s[i].classList.add('select_left'); } }else if( /\bdifftxtr\b/.test(t.className) ){ var s = document.getElementsByClassName('splitdiff'); for( var i=0; i<s.length; i++ ){ s[i].classList.remove('select_left'); s[i].classList.add('select_right'); } } } }()); |