X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/b4c3562f57c924866314d0f80f46dddecd4ce61a..d67cc7f9d556650438e421cdcda37bc52710bffd:/ui-tree.c
diff --git a/ui-tree.c b/ui-tree.c
index 61fcf5a..f64e6e0 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -15,26 +15,43 @@ char *curr_rev;
char *match_path;
int header = 0;
-static void print_text_buffer(char *buf, unsigned long size)
+static void print_text_buffer(const char *name, char *buf, unsigned long size)
{
unsigned long lineno, idx;
const char *numberfmt =
"%1$d\n";
html("
\n");
- html("");
- 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("");
+ 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(" | \n");
+ }
+ else {
+ html(" \n");
+ }
+
+ if (ctx.repo->source_filter) {
+ html("");
+ ctx.repo->source_filter->argv[1] = xstrdup(name);
+ cgit_open_filter(ctx.repo->source_filter);
+ write(STDOUT_FILENO, buf, size);
+ cgit_close_filter(ctx.repo->source_filter);
+ html("
| |
\n");
+ return;
}
- html("\n");
+
html("");
html_txt(buf);
html("
| \n");
@@ -65,7 +82,7 @@ static void print_binary_buffer(char *buf, unsigned long size)
html("\n");
}
-static void print_object(const unsigned char *sha1, char *path)
+static void print_object(const unsigned char *sha1, char *path, const char *basename)
{
enum object_type type;
char *buf;
@@ -93,7 +110,7 @@ static void print_object(const unsigned char *sha1, char *path)
if (buffer_is_binary(buf, size))
print_binary_buffer(buf, size);
else
- print_text_buffer(buf, size);
+ print_text_buffer(basename, buf, size);
}
@@ -219,7 +236,7 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
ls_head();
return READ_TREE_RECURSIVE;
} else {
- print_object(sha1, buffer);
+ print_object(sha1, buffer, pathname);
return 0;
}
}