aboutsummaryrefslogtreecommitdiffstats
path: root/ui-diff.c
diff options
context:
space:
mode:
authorLars Hjemli2011-05-23 23:29:24 +0200
committerLars Hjemli2011-05-23 23:29:24 +0200
commit2ffeecb7a6827dcf0f81cf543ed312155f6e8f83 (patch)
tree328117f4fe71862b7432359b4d6a7237affd42fe /ui-diff.c
parentab350a77b1d3b0e251cc28329f2e16f0566e521e (diff)
parent1b5c336cc99f01a0f8d6668cbfc9273f49a6be25 (diff)
downloadcgit-2ffeecb7a6827dcf0f81cf543ed312155f6e8f83.tar.gz
cgit-2ffeecb7a6827dcf0f81cf543ed312155f6e8f83.tar.bz2
cgit-2ffeecb7a6827dcf0f81cf543ed312155f6e8f83.zip
Merge branch 'lh/panel'
Diffstat (limited to 'ui-diff.c')
-rw-r--r--ui-diff.c83
1 files changed, 54 insertions, 29 deletions
diff --git a/ui-diff.c b/ui-diff.c
index d21541b..868ceec 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -167,7 +167,7 @@ static void inspect_filepair(struct diff_filepair *pair)
167void cgit_print_diffstat(const unsigned char *old_sha1, 167void cgit_print_diffstat(const unsigned char *old_sha1,
168 const unsigned char *new_sha1, const char *prefix) 168 const unsigned char *new_sha1, const char *prefix)
169{ 169{
170 int i, save_context = ctx.qry.context; 170 int i;
171 171
172 html("<div class='diffstat-header'>"); 172 html("<div class='diffstat-header'>");
173 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, 173 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
@@ -177,19 +177,6 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
177 html_txt(prefix); 177 html_txt(prefix);
178 html("')"); 178 html("')");
179 } 179 }
180 html(" (");
181 ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
182 cgit_self_link("more", NULL, NULL, &ctx);
183 html("/");
184 ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
185 cgit_self_link("less", NULL, NULL, &ctx);
186 ctx.qry.context = save_context;
187 html(" context)");
188 html(" (");
189 ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
190 cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx);
191 ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
192 html(" whitespace changes)");
193 html("</div>"); 180 html("</div>");
194 html("<table summary='diffstat' class='diffstat'>"); 181 html("<table summary='diffstat' class='diffstat'>");
195 max_changes = 0; 182 max_changes = 0;
@@ -278,19 +265,6 @@ static void header(unsigned char *sha1, char *path1, int mode1,
278 html("</div>"); 265 html("</div>");
279} 266}
280 267
281static void print_ssdiff_link()
282{
283 if (!strcmp(ctx.qry.page, "diff")) {
284 if (use_ssdiff)
285 cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head,
286 ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1);
287 else
288 cgit_diff_link("Side-by-side diff", NULL, NULL,
289 ctx.qry.head, ctx.qry.sha1,
290 ctx.qry.sha2, ctx.qry.path, 1);
291 }
292}
293
294static void filepair_cb(struct diff_filepair *pair) 268static void filepair_cb(struct diff_filepair *pair)
295{ 269{
296 unsigned long old_size = 0; 270 unsigned long old_size = 0;
@@ -330,7 +304,56 @@ static void filepair_cb(struct diff_filepair *pair)
330 cgit_ssdiff_footer(); 304 cgit_ssdiff_footer();
331} 305}
332 306
333void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) 307void cgit_print_diff_ctrls()
308{
309 int i, curr;
310
311 html("<div class='cgit-panel'>");
312 html("<b>diff options</b>");
313 html("<form method='get' action='.'>");
314 cgit_add_hidden_formfields(1, 0, ctx.qry.page);
315 html("<table>");
316 html("<tr><td colspan='2'/></tr>");
317 html("<tr>");
318 html("<td class='label'>context:</td>");
319 html("<td class='ctrl'>");
320 html("<select name='context' onchange='this.form.submit();'>");
321 curr = ctx.qry.context;
322 if (!curr)
323 curr = 3;
324 for (i = 1; i <= 10; i++)
325 html_intoption(i, fmt("%d", i), curr);
326 for (i = 15; i <= 40; i += 5)
327 html_intoption(i, fmt("%d", i), curr);
328 html("</select>");
329 html("</td>");
330 html("</tr><tr>");
331 html("<td class='label'>space:</td>");
332 html("<td class='ctrl'>");
333 html("<select name='ignorews' onchange='this.form.submit();'>");
334 html_intoption(0, "include", ctx.qry.ignorews);
335 html_intoption(1, "ignore", ctx.qry.ignorews);
336 html("</select>");
337 html("</td>");
338 html("</tr><tr>");
339 html("<td class='label'>mode:</td>");
340 html("<td class='ctrl'>");
341 html("<select name='ss' onchange='this.form.submit();'>");
342 curr = ctx.qry.ssdiff;
343 if (!curr && ctx.cfg.ssdiff)
344 curr = 1;
345 html_intoption(0, "unified", curr);
346 html_intoption(1, "ssdiff", curr);
347 html("</select></td></tr>");
348 html("<tr><td/><td class='ctrl'>");
349 html("<noscript><input type='submit' value='reload'/></noscript>");
350 html("</td></tr></table>");
351 html("</form>");
352 html("</div>");
353}
354
355void cgit_print_diff(const char *new_rev, const char *old_rev,
356 const char *prefix, int show_ctrls)
334{ 357{
335 enum object_type type; 358 enum object_type type;
336 unsigned long size; 359 unsigned long size;
@@ -373,7 +396,9 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
373 if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) 396 if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
374 use_ssdiff = 1; 397 use_ssdiff = 1;
375 398
376 print_ssdiff_link(); 399 if (show_ctrls)
400 cgit_print_diff_ctrls();
401
377 cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix); 402 cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);
378 403
379 if (use_ssdiff) { 404 if (use_ssdiff) {