-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 4 | ||||
-rw-r--r-- | ui-tree.c | 27 |
4 files changed, 23 insertions, 11 deletions
@@ -68,2 +68,4 @@ void config_cb(const char *name, const char *value) | |||
68 | ctx.cfg.logo_link = xstrdup(value); | 68 | ctx.cfg.logo_link = xstrdup(value); |
69 | else if (!strcmp(name, "linenumbers")) | ||
70 | ctx.cfg.linenumbers = atoi(value); | ||
69 | else if (!strcmp(name, "module-link")) | 71 | else if (!strcmp(name, "module-link")) |
@@ -176,2 +176,3 @@ struct cgit_config { | |||
176 | int local_time; | 176 | int local_time; |
177 | int linenumbers; | ||
177 | int max_repo_count; | 178 | int max_repo_count; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 3c35b02..a762ccc 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -148,2 +148,6 @@ logo-link:: | |||
148 | 148 | ||
149 | linenumbers:: | ||
150 | If set to "1" lines in tree view will have numbers. | ||
151 | Default value: "0". | ||
152 | |||
149 | max-commit-count:: | 153 | max-commit-count:: |
@@ -25,15 +25,20 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) | |||
25 | 25 | ||
26 | html("<tr><td class='linenumbers'><pre>"); | 26 | if (ctx.cfg.linenumbers) { |
27 | idx = 0; | 27 | html("<tr><td class='linenumbers'><pre>"); |
28 | lineno = 0; | 28 | idx = 0; |
29 | 29 | lineno = 0; | |
30 | if (size) { | 30 | |
31 | htmlf(numberfmt, ++lineno); | 31 | if (size) { |
32 | while(idx < size - 1) { // skip absolute last newline | 32 | htmlf(numberfmt, ++lineno); |
33 | if (buf[idx] == '\n') | 33 | while(idx < size - 1) { // skip absolute last newline |
34 | htmlf(numberfmt, ++lineno); | 34 | if (buf[idx] == '\n') |
35 | idx++; | 35 | htmlf(numberfmt, ++lineno); |
36 | idx++; | ||
37 | } | ||
36 | } | 38 | } |
39 | html("</pre></td>\n"); | ||
40 | } | ||
41 | else { | ||
42 | html("<tr>\n"); | ||
37 | } | 43 | } |
38 | html("</pre></td>\n"); | ||
39 | 44 | ||