Fossil

Check-in [598d7736e7]
Login

Check-in [598d7736e7]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tweaks to diff formatting.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | diff-color-enhancements
Files: files | file ages | folders
SHA3-256: 598d7736e75b438b6d1471f301107677b9cd7fbbf3f84b6b1ab2f73ff90f4eb0
User & Date: drh 2021-08-31 22:43:46.584
Context
2021-09-01
15:38
Further improvements to unified diff. Simplified CSS that can be used in common with split diff. Separate columns for each line number and the change mark. ... (check-in: ce856a8614 user: drh tags: diff-color-enhancements)
2021-08-31
22:43
Tweaks to diff formatting. ... (check-in: 598d7736e7 user: drh tags: diff-color-enhancements)
13:33
Improvements to the new unified diff algorithm. ... (check-in: 2a256a4cce user: drh tags: diff-color-enhancements)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/default.css.
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
}
ul.filelist li {
  padding-top: 1px;
}
table.sbsdiffcols {
  width: 90%;
  border-spacing: 0;
  font-size: small;
}
table.sbsdiffcols td {
  padding: 0;
  vertical-align: top;
}
table.sbsdiffcols pre {
  margin: 0;







<







530
531
532
533
534
535
536

537
538
539
540
541
542
543
}
ul.filelist li {
  padding-top: 1px;
}
table.sbsdiffcols {
  width: 90%;
  border-spacing: 0;

}
table.sbsdiffcols td {
  padding: 0;
  vertical-align: top;
}
table.sbsdiffcols pre {
  margin: 0;
558
559
560
561
562
563
564

565
566
567

568
569
570

571
572
573
574
575
576
577
  overflow-x: auto;
}
div.diffmkrcol {
  padding: 0 1em;
}
span.diffchng {
  background-color: #c0c0ff;

}
span.diffadd {
  background-color: #c0ffc0;

}
span.diffrm {
  background-color: #ffc8c8;

}
span.diffhr {
  display: inline-block;
  margin: .5em 0 1em;
  color: #0000ff;
}
span.diffln {







>



>



>







557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
  overflow-x: auto;
}
div.diffmkrcol {
  padding: 0 1em;
}
span.diffchng {
  background-color: #c0c0ff;
  font-weight: bold;
}
span.diffadd {
  background-color: #c0ffc0;
  font-weight: bold;
}
span.diffrm {
  background-color: #ffc8c8;
  font-weight: bold;
}
span.diffhr {
  display: inline-block;
  margin: .5em 0 1em;
  color: #0000ff;
}
span.diffln {
595
596
597
598
599
600
601

602
603
604
605

606
607
608
609
610
611
612
pre.udifftxt del {
  background-color: #ffe8e8;
  text-decoration: none;
}
pre.udifftxt ins mark {
  background-color: #a0e4b2;
  text-decoration: none;

}
pre.udifftxt del mark {
  background-color: #ffc0c0;
  text-decoration: none;

}

span.modpending {
  color: #b03800;
  font-style: italic;
}
pre.th1result {







>




>







597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
pre.udifftxt del {
  background-color: #ffe8e8;
  text-decoration: none;
}
pre.udifftxt ins mark {
  background-color: #a0e4b2;
  text-decoration: none;
  font-weight: bold;
}
pre.udifftxt del mark {
  background-color: #ffc0c0;
  text-decoration: none;
  font-weight: bold;
}

span.modpending {
  color: #b03800;
  font-style: italic;
}
pre.th1result {
Changes to src/diff.c.
1896
1897
1898
1899
1900
1901
1902

1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
}
static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){
  int iCol = 0;
  dfunifiedEmitInsert(p);
  p->lnLeft++;
  p->lnRight++;
  blob_appendf(p->pOut,"%6d  %6d  \n", p->lnLeft, p->lnRight);

  jsonize_to_blob(&p->aCol[0], pLine->z, (int)pLine->n, &iCol);
  blob_append_char(&p->aCol[0], '\n');
}
static void dfunifiedInsert(DiffBuilder *p, const DLine *pLine){
  int iCol = 0;
  p->lnRight++;
  blob_appendf(&p->aCol[1],"<ins>        %6d  </ins>\n", p->lnRight);
  blob_append(&p->aCol[2],"<ins><mark>",-1);
  jsonize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n, &iCol);
  blob_append(&p->aCol[2], "</mark></ins>\n", -1);
}
static void dfunifiedDelete(DiffBuilder *p, const DLine *pLine){
  int iCol = 0;
  p->lnLeft++;
  blob_appendf(p->pOut,"<del>%6d          </del>\n", p->lnLeft);
  blob_append(&p->aCol[0],"<del><mark>",-1);
  jsonize_to_blob(&p->aCol[0], pLine->z, (int)pLine->n, &iCol);
  blob_append(&p->aCol[0], "</mark></del>\n", -1);
}
static void dfunifiedEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
  int i;
  int x;
  int iCol;
  ChangeSpan span;
  oneLineChange(pX, pY, &span);
  p->lnLeft++;
  p->lnRight++;
  blob_appendf(p->pOut,"<del>%6d          </del>\n", p->lnLeft);
  blob_append(&p->aCol[0], "<del>", -1);
  for(i=x=iCol=0; i<span.n; i++){
    int ofst = span.a[i].iStart1;
    int len = span.a[i].iLen1;
    if( len ){
      jsonize_to_blob(&p->aCol[0], pX->z+x, ofst - x, &iCol);
      x = ofst;
      blob_append(&p->aCol[0], "<mark>", 6);
      jsonize_to_blob(&p->aCol[0], pX->z+x, len, &iCol);
      x += len;
      blob_append(&p->aCol[0], "</mark>", 7);
    }
  }
  if( x<pX->n ) jsonize_to_blob(&p->aCol[0], pX->z+x,  pX->n - x, &iCol);
  blob_append(&p->aCol[0], "</del>\n", -1);
  blob_appendf(&p->aCol[1],"<ins>        %6d  </ins>\n", p->lnRight);
  blob_append(&p->aCol[2], "<ins>", -1);
  for(i=x=iCol=0; i<span.n; i++){
    int ofst = span.a[i].iStart2;
    int len = span.a[i].iLen2;
    if( len ){
      jsonize_to_blob(&p->aCol[2], pY->z+x, ofst - x, &iCol);
      x = ofst;
      blob_append(&p->aCol[2], "<mark>", 6);







>







|







|












|















|







1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
}
static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){
  int iCol = 0;
  dfunifiedEmitInsert(p);
  p->lnLeft++;
  p->lnRight++;
  blob_appendf(p->pOut,"%6d  %6d  \n", p->lnLeft, p->lnRight);
  blob_append(&p->aCol[0], "  ", 2);
  jsonize_to_blob(&p->aCol[0], pLine->z, (int)pLine->n, &iCol);
  blob_append_char(&p->aCol[0], '\n');
}
static void dfunifiedInsert(DiffBuilder *p, const DLine *pLine){
  int iCol = 0;
  p->lnRight++;
  blob_appendf(&p->aCol[1],"<ins>        %6d  </ins>\n", p->lnRight);
  blob_append(&p->aCol[2],"<ins>+ <mark>",-1);
  jsonize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n, &iCol);
  blob_append(&p->aCol[2], "</mark></ins>\n", -1);
}
static void dfunifiedDelete(DiffBuilder *p, const DLine *pLine){
  int iCol = 0;
  p->lnLeft++;
  blob_appendf(p->pOut,"<del>%6d          </del>\n", p->lnLeft);
  blob_append(&p->aCol[0],"<del>- <mark>",-1);
  jsonize_to_blob(&p->aCol[0], pLine->z, (int)pLine->n, &iCol);
  blob_append(&p->aCol[0], "</mark></del>\n", -1);
}
static void dfunifiedEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
  int i;
  int x;
  int iCol;
  ChangeSpan span;
  oneLineChange(pX, pY, &span);
  p->lnLeft++;
  p->lnRight++;
  blob_appendf(p->pOut,"<del>%6d          </del>\n", p->lnLeft);
  blob_append(&p->aCol[0], "<del>- ", -1);
  for(i=x=iCol=0; i<span.n; i++){
    int ofst = span.a[i].iStart1;
    int len = span.a[i].iLen1;
    if( len ){
      jsonize_to_blob(&p->aCol[0], pX->z+x, ofst - x, &iCol);
      x = ofst;
      blob_append(&p->aCol[0], "<mark>", 6);
      jsonize_to_blob(&p->aCol[0], pX->z+x, len, &iCol);
      x += len;
      blob_append(&p->aCol[0], "</mark>", 7);
    }
  }
  if( x<pX->n ) jsonize_to_blob(&p->aCol[0], pX->z+x,  pX->n - x, &iCol);
  blob_append(&p->aCol[0], "</del>\n", -1);
  blob_appendf(&p->aCol[1],"<ins>        %6d  </ins>\n", p->lnRight);
  blob_append(&p->aCol[2], "<ins>+ ", -1);
  for(i=x=iCol=0; i<span.n; i++){
    int ofst = span.a[i].iStart2;
    int len = span.a[i].iLen2;
    if( len ){
      jsonize_to_blob(&p->aCol[2], pY->z+x, ofst - x, &iCol);
      x = ofst;
      blob_append(&p->aCol[2], "<mark>", 6);
Changes to src/diffcmd.c.
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
@ <html>
@ <head>
@ <meta charset="UTF-8">
@ <style>
@ table.sbsdiffcols {
@   width: 90%%;
@   border-spacing: 0;
@   font-size: small;
@ }
@ table.sbsdiffcols td {
@   padding: 0;
@   vertical-align: top;
@ }
@ table.sbsdiffcols pre {
@   margin: 0;







<







186
187
188
189
190
191
192

193
194
195
196
197
198
199
@ <html>
@ <head>
@ <meta charset="UTF-8">
@ <style>
@ table.sbsdiffcols {
@   width: 90%%;
@   border-spacing: 0;

@ }
@ table.sbsdiffcols td {
@   padding: 0;
@   vertical-align: top;
@ }
@ table.sbsdiffcols pre {
@   margin: 0;
211
212
213
214
215
216
217

218
219
220

221
222
223

224
225
226
227
228
229
230
@   overflow-x: auto;
@ }
@ div.diffmkrcol {
@   padding: 0 1em;
@ }
@ span.diffchng {
@   background-color: #c0c0ff;

@ }
@ span.diffadd {
@   background-color: #c0ffc0;

@ }
@ span.diffrm {
@   background-color: #ffc8c8;

@ }
@ span.diffhr {
@   display: inline-block;
@   margin: .5em 0 1em;
@   color: #0000ff;
@ }
@ span.diffln {







>



>



>







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
@   overflow-x: auto;
@ }
@ div.diffmkrcol {
@   padding: 0 1em;
@ }
@ span.diffchng {
@   background-color: #c0c0ff;
@   text-weight: bold;
@ }
@ span.diffadd {
@   background-color: #c0ffc0;
@   text-weight: bold;
@ }
@ span.diffrm {
@   background-color: #ffc8c8;
@   text-weight: bold;
@ }
@ span.diffhr {
@   display: inline-block;
@   margin: .5em 0 1em;
@   color: #0000ff;
@ }
@ span.diffln {
252
253
254
255
256
257
258

259
260
261
262

263
264
265
266
267
268
269
@ pre.udifftxt del {
@   background-color: #ffe8e8;
@   text-decoration: none;
@ }
@ pre.udifftxt ins mark {
@   background-color: #a0e4b2;
@   text-decoration: none;

@ }
@ pre.udifftxt del mark {
@   background-color: #ffc0c0;
@   text-decoration: none;

@ }
@ h1 {
@   font-size: 150%%;
@ }
@ </style>
@ </head>
@ <body>







>




>







254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
@ pre.udifftxt del {
@   background-color: #ffe8e8;
@   text-decoration: none;
@ }
@ pre.udifftxt ins mark {
@   background-color: #a0e4b2;
@   text-decoration: none;
@   text-weight: bold;
@ }
@ pre.udifftxt del mark {
@   background-color: #ffc0c0;
@   text-decoration: none;
@   text-weight: bold;
@ }
@ h1 {
@   font-size: 150%%;
@ }
@ </style>
@ </head>
@ <body>