summaryrefslogtreecommitdiffabout
authorJohan Herland <johan@herland.net>2010-06-10 18:15:51 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-06-19 11:00:07 (UTC)
commitd20313e3daf855ee5d4808e050f54614c200d7b1 (patch) (side-by-side diff)
tree5c462f3ba6ec97c0b099a309dfd0fa87d03fbc72
parent6180e6169d6e87a3bea7e4da835dca17f93e5cfd (diff)
downloadcgit-d20313e3daf855ee5d4808e050f54614c200d7b1.zip
cgit-d20313e3daf855ee5d4808e050f54614c200d7b1.tar.gz
cgit-d20313e3daf855ee5d4808e050f54614c200d7b1.tar.bz2
ui-diff: Add links to increase/decrease number of context lines in diffs
Add two links to the "Diffstat" line to show more/less context lines in the generated diff. To support this, cgit_commit_link() and cgit_diff_link() has learned to preserve the ctx.qry.context variable. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-diff.c10
-rw-r--r--ui-shared.c14
2 files changed, 23 insertions, 1 deletions
diff --git a/ui-diff.c b/ui-diff.c
index d3a3b2c..e0a72f7 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -158,3 +158,3 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
{
- int i;
+ int i, save_context = ctx.qry.context;
@@ -165,2 +165,10 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
htmlf(" (limited to '%s')", prefix);
+ html(" (");
+ ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
+ cgit_self_link("more", NULL, NULL, &ctx);
+ html("/");
+ ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
+ cgit_self_link("less", NULL, NULL, &ctx);
+ ctx.qry.context = save_context;
+ html(" context)");
html("</div>");
diff --git a/ui-shared.c b/ui-shared.c
index e991799..c99bcec 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -343,2 +343,9 @@ void cgit_commit_link(char *name, const char *title, const char *class,
html("ss=1");
+ delim = "&amp;";
+ }
+ if (ctx.qry.context > 0 && ctx.qry.context != 3) {
+ html(delim);
+ html("context=");
+ htmlf("%d", ctx.qry.context);
+ delim = "&amp;";
}
@@ -384,2 +391,9 @@ void cgit_diff_link(const char *name, const char *title, const char *class,
html("ss=1");
+ delim = "&amp;";
+ }
+ if (ctx.qry.context > 0 && ctx.qry.context != 3) {
+ html(delim);
+ html("context=");
+ htmlf("%d", ctx.qry.context);
+ delim = "&amp;";
}