Fossil SCM

Add chunk numbers to each row of the diff output for HTML diffs.

drh 2021-09-03 23:39 diff-color-enhancements
Commit 8caab6155eb40cfb2516f3eddf80cbe117705006f40f040e6c885775af8d8224
1 file changed +9 -2
+9 -2
--- src/diff.c
+++ src/diff.c
@@ -99,10 +99,15 @@
9999
/*
100100
** Length of a dline
101101
*/
102102
#define LENGTH(X) ((X)->n)
103103
104
+/*
105
+** Number of diff chunks generated
106
+*/
107
+static int nChunk = 0;
108
+
104109
/*
105110
** A context for running a raw diff.
106111
**
107112
** The aEdit[] array describes the raw diff. Each triple of integers in
108113
** aEdit[] means:
@@ -1412,11 +1417,12 @@
14121417
blob_append_xfer(p->pOut, &p->aCol[2]);
14131418
blob_append(p->pOut, "</pre></td></tr>\n", -1);
14141419
}
14151420
static void dfunifiedStartRow(DiffBuilder *p){
14161421
if( blob_size(&p->aCol[0])>0 ) return;
1417
- blob_append(p->pOut,"<tr><td class=\"diffln difflnl\"><pre>\n", -1);
1422
+ blob_appendf(p->pOut,"<tr id=\"chunk%d\">"
1423
+ "<td class=\"diffln difflnl\"><pre>\n", ++nChunk);
14181424
p->eState = 0;
14191425
p->nPending = 0;
14201426
}
14211427
static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){
14221428
dfunifiedFinishRow(p);
@@ -1624,11 +1630,12 @@
16241630
blob_append_xfer(p->pOut, &p->aCol[3]);
16251631
blob_append(p->pOut, "</pre></td></tr>\n", -1);
16261632
}
16271633
static void dfsplitStartRow(DiffBuilder *p){
16281634
if( blob_size(&p->aCol[0])>0 ) return;
1629
- blob_append(p->pOut,"<tr><td class=\"diffln difflnl\"><pre>\n", -1);
1635
+ blob_appendf(p->pOut,"<tr id=\"chunk%d\">"
1636
+ "<td class=\"diffln difflnl\"><pre>\n", ++nChunk);
16301637
p->eState = 0;
16311638
}
16321639
static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){
16331640
dfsplitFinishRow(p);
16341641
blob_append(p->pOut,
16351642
--- src/diff.c
+++ src/diff.c
@@ -99,10 +99,15 @@
99 /*
100 ** Length of a dline
101 */
102 #define LENGTH(X) ((X)->n)
103
 
 
 
 
 
104 /*
105 ** A context for running a raw diff.
106 **
107 ** The aEdit[] array describes the raw diff. Each triple of integers in
108 ** aEdit[] means:
@@ -1412,11 +1417,12 @@
1412 blob_append_xfer(p->pOut, &p->aCol[2]);
1413 blob_append(p->pOut, "</pre></td></tr>\n", -1);
1414 }
1415 static void dfunifiedStartRow(DiffBuilder *p){
1416 if( blob_size(&p->aCol[0])>0 ) return;
1417 blob_append(p->pOut,"<tr><td class=\"diffln difflnl\"><pre>\n", -1);
 
1418 p->eState = 0;
1419 p->nPending = 0;
1420 }
1421 static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){
1422 dfunifiedFinishRow(p);
@@ -1624,11 +1630,12 @@
1624 blob_append_xfer(p->pOut, &p->aCol[3]);
1625 blob_append(p->pOut, "</pre></td></tr>\n", -1);
1626 }
1627 static void dfsplitStartRow(DiffBuilder *p){
1628 if( blob_size(&p->aCol[0])>0 ) return;
1629 blob_append(p->pOut,"<tr><td class=\"diffln difflnl\"><pre>\n", -1);
 
1630 p->eState = 0;
1631 }
1632 static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){
1633 dfsplitFinishRow(p);
1634 blob_append(p->pOut,
1635
--- src/diff.c
+++ src/diff.c
@@ -99,10 +99,15 @@
99 /*
100 ** Length of a dline
101 */
102 #define LENGTH(X) ((X)->n)
103
104 /*
105 ** Number of diff chunks generated
106 */
107 static int nChunk = 0;
108
109 /*
110 ** A context for running a raw diff.
111 **
112 ** The aEdit[] array describes the raw diff. Each triple of integers in
113 ** aEdit[] means:
@@ -1412,11 +1417,12 @@
1417 blob_append_xfer(p->pOut, &p->aCol[2]);
1418 blob_append(p->pOut, "</pre></td></tr>\n", -1);
1419 }
1420 static void dfunifiedStartRow(DiffBuilder *p){
1421 if( blob_size(&p->aCol[0])>0 ) return;
1422 blob_appendf(p->pOut,"<tr id=\"chunk%d\">"
1423 "<td class=\"diffln difflnl\"><pre>\n", ++nChunk);
1424 p->eState = 0;
1425 p->nPending = 0;
1426 }
1427 static void dfunifiedSkip(DiffBuilder *p, unsigned int n, int isFinal){
1428 dfunifiedFinishRow(p);
@@ -1624,11 +1630,12 @@
1630 blob_append_xfer(p->pOut, &p->aCol[3]);
1631 blob_append(p->pOut, "</pre></td></tr>\n", -1);
1632 }
1633 static void dfsplitStartRow(DiffBuilder *p){
1634 if( blob_size(&p->aCol[0])>0 ) return;
1635 blob_appendf(p->pOut,"<tr id=\"chunk%d\">"
1636 "<td class=\"diffln difflnl\"><pre>\n", ++nChunk);
1637 p->eState = 0;
1638 }
1639 static void dfsplitSkip(DiffBuilder *p, unsigned int n, int isFinal){
1640 dfsplitFinishRow(p);
1641 blob_append(p->pOut,
1642

Keyboard Shortcuts

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