Add 'linenumbers' config option Signed-off-by: Florian Pritz <bluewind@xssn.at> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Florian Pritz bluewind@xssn.at
Sun, 09 Aug 2009 20:42:45 +0000
4 files changed,
23 insertions(+),
11 deletions(-)
M
cgit.c
→
cgit.c
@@ -66,6 +66,8 @@ else if (!strcmp(name, "index-info"))
ctx.cfg.index_info = xstrdup(value); else if (!strcmp(name, "logo-link")) ctx.cfg.logo_link = xstrdup(value); + else if (!strcmp(name, "linenumbers")) + ctx.cfg.linenumbers = atoi(value); else if (!strcmp(name, "module-link")) ctx.cfg.module_link = xstrdup(value); else if (!strcmp(name, "virtual-root")) {
M
cgitrc.5.txt
→
cgitrc.5.txt
@@ -146,6 +146,10 @@ Url loaded when clicking on the cgit logo image. If unspecified the
calculated url of the repository index page will be used. Default value: none. +linenumbers:: + If set to "1" lines in tree view will have numbers. + Default value: "0". + max-commit-count:: Specifies the number of entries to list per page in "log" view. Default value: "50".
M
ui-tree.c
→
ui-tree.c
@@ -23,19 +23,24 @@ "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n";
html("<table summary='blob content' class='blob'>\n"); - html("<tr><td class='linenumbers'><pre>"); - idx = 0; - lineno = 0; - - if (size) { - htmlf(numberfmt, ++lineno); - while(idx < size - 1) { // skip absolute last newline - if (buf[idx] == '\n') - htmlf(numberfmt, ++lineno); - idx++; + if (ctx.cfg.linenumbers) { + html("<tr><td class='linenumbers'><pre>"); + idx = 0; + lineno = 0; + + if (size) { + htmlf(numberfmt, ++lineno); + while(idx < size - 1) { // skip absolute last newline + if (buf[idx] == '\n') + htmlf(numberfmt, ++lineno); + idx++; + } } + html("</pre></td>\n"); } - html("</pre></td>\n"); + else { + html("<tr>\n"); + } if (ctx.repo->source_filter) { html("<td class='lines'><pre><code>");