Skip to content

Commit 875e7cf

Browse files
committed
new diff style
1 parent da6a75c commit 875e7cf

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

GLFileView.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,17 @@ - (NSString *) parseHTML:(NSString *)txt
226226
- (NSString *) parseDiff:(NSString *)txt
227227
{
228228
txt=[self parseHTML:txt];
229-
229+
230230
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
231231
NSString *line;
232232
NSMutableString *res=[NSMutableString string];
233233

234-
[res appendString:@"<table class='diff'>"];
234+
[res appendString:@"<table class='diff'><thead><tr><td colspan='3'>"];
235235
int i=0;
236236
while(i<[lines count]){
237237
line=[lines objectAtIndex:i];
238238
if([[line substringToIndex:2] isEqualToString:@"@@"]){
239+
[res appendString:@"</td></tr></thead><tbody>"];
239240

240241
int l_int,l_count,l_line;
241242
int r_int,r_count,r_line;
@@ -252,12 +253,11 @@ - (NSString *) parseDiff:(NSString *)txt
252253
r_line=r_int=[[pos_r objectAtIndex:0]integerValue];
253254
r_count=[[pos_r objectAtIndex:1]integerValue];
254255

255-
[res appendString:[NSString stringWithFormat:@"<tr class='header'><td colspan=3>%@</td></tr>",line]];
256+
[res appendString:[NSString stringWithFormat:@"<tr class='header'><td colspan='3'>%@</td></tr>",line]];
256257

257258
do{
258259
line=[lines objectAtIndex:++i];
259260
NSString *s=[line substringToIndex:1];
260-
line=[line substringFromIndex:1];
261261

262262
if([s isEqualToString:@" "]){
263263
[res appendString:[NSString stringWithFormat:@"<tr><td class='l'>%d</td><td class='r'>%d</td>",l_line++,r_line++]];
@@ -269,10 +269,12 @@ - (NSString *) parseDiff:(NSString *)txt
269269
[res appendString:[NSString stringWithFormat:@"<td class='code'>%@</td></tr>",line]];
270270
}while(l_line<(l_int+l_count) && r_line<(r_int+r_count));
271271

272+
}else{
273+
[res appendString:[NSString stringWithFormat:@"<p>%@</p>",line]];
272274
}
273275
i++;
274276
}
275-
[res appendString:@"</table>"];
277+
[res appendString:@"</tbody></table>"];
276278
return res;
277279
}
278280

html/views/diff/diffWindow.css

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,64 @@
1-
table.diff{
1+
table.diff {
2+
font-family: Menlo, Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;
23
border: 1px solid #8f8f8f;
34
width: 100%;
45
border-collapse: collapse;
5-
margin-left: 5px;
66
margin-right: 5px;
7+
margin-left: 5px;
78
}
8-
table.diff tr td{
9-
font-family: Menlo, Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;
9+
10+
table.diff tr td {
1011
font-size: 11px;
1112
white-space: pre;
1213
padding-left: 5px;
1314
padding-right: 5px;
1415
}
1516

16-
table.diff td.code{
17+
table.diff td.code {
1718
width: 100%;
1819
border-left: 2px solid #d0d0d0;
1920
}
2021

21-
table.diff tr.header td{
22+
table.diff tr.header td {
2223
border: 1px solid #8f8f8f;
2324
padding: 5px;
2425
}
2526

26-
table.diff tr td.r{
27+
table.diff tr td.r {
2728
border-left: 1px solid #909090;
2829
}
2930

30-
table.diff tr.r{
31+
table.diff tr.r {
3132
background-color: rgba(0,255,0,0.1);
3233
}
3334

34-
table.diff tr.l{
35+
table.diff tr.l {
3536
background-color: rgba(255,0,0,0.1);
3637
}
3738

38-
table.diff tr.r td.code{
39+
table.diff tr.r td.code {
3940
border-left-color: rgba(0,255,0,0.2);
4041
}
4142

42-
table.diff tr.l td.code{
43+
table.diff tr.l td.code {
4344
border-left-color: rgba(255,0,0,0.2);
4445
}
4546

47+
table.diff thead tr td p {
48+
margin: 0;
49+
}
50+
51+
#diff table.diff thead {
52+
background-image: -webkit-gradient(linear,left top,left bottom, color-stop(0, rgba(244, 244, 244,1)), color-stop(1, rgba(215,215,215,1)));
53+
}
54+
55+
#diff table.diff thead tr td {
56+
padding: 5px;
57+
}
58+
59+
#diff table.diff tbody tr.header {
60+
background-image: -webkit-gradient(linear,left top,left bottom, color-stop(0, rgba(206,206,206,1)), color-stop(1, rgba(166,166,166,1)));
61+
/* Saf4
62+
63+
+, Chrome */
64+
}

0 commit comments

Comments
 (0)