From a90e2aa4e1bd5c3a9657ce7d675943f4a265cc9f Mon Sep 17 00:00:00 2001 From: Onne Gorter Date: Wed, 7 Jan 2009 13:56:14 +0100 Subject: changed objects are outputted, allowing for selections of code only diff --git a/cgit.css b/cgit.css index 7928c2f..068c37b 100644 --- a/cgit.css +++ b/cgit.css @@ -236,26 +236,31 @@ table.blob { border-top: solid 1px black; } -table.blob td.no { - border-right: solid 1px black; +table.blob td.lines { + margin: 0; padding: 0; + vertical-align: top; color: black; +} + +table.blob td.linenumbers { + margin: 0; padding: 0; + vertical-align: top; + border-right: 1px solid gray; background-color: #eee; - text-align: right; } -table.blob td.no a { - color: black; +table.blob pre { + padding: 0; margin: 0; } -table.blob td.no a:hover { - color: black; +table.blob a.no { + color: gray; + text-align: right; text-decoration: none; } -table.blob td.txt { - white-space: pre; - font-family: monospace; - padding-left: 0.5em; +table.blob a.no a:hover { + color: black; } table.nowrap td { diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 33f4eb0..2ce1251 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -11,11 +11,11 @@ run_test 'find file-50' 'grep -e "file-50" trash/tmp' run_test 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >trash/tmp' run_test 'find line 1' ' - grep -e "1" trash/tmp + grep -e "1" trash/tmp ' run_test 'no line 2' ' - ! grep -e "2" trash/tmp + ! grep -e "2" trash/tmp ' run_test 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp' diff --git a/ui-tree.c b/ui-tree.c index 9876c99..2a8625c 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -18,8 +18,8 @@ static void print_object(const unsigned char *sha1, char *path) { enum object_type type; char *buf; - unsigned long size, lineno, start, idx; - const char *linefmt = "%1$d"; + unsigned long size, lineno, idx; + const char *numberfmt = "%1$d\n"; type = sha1_object_info(sha1, &size); if (type == OBJ_BAD) { @@ -38,27 +38,28 @@ static void print_object(const unsigned char *sha1, char *path) html(" ("); cgit_plain_link("plain", NULL, NULL, ctx.qry.head, curr_rev, path); - htmlf(")
blob: %s", sha1_to_hex(sha1)); + htmlf(")
blob: %s\n", sha1_to_hex(sha1)); html("\n"); + html("\n"); + + html("\n"); - start = idx + 1; + htmlf(numberfmt, ++lineno); } idx++; } - if (start < idx) { - htmlf(linefmt, ++lineno); - html_txt(buf + start); - } - html("\n"); + html("\n"); + + html("\n"); + + html("\n"); html("
");
 	idx = 0;
-	start = 0;
 	lineno = 0;
-	while(idx < size) {
+	htmlf(numberfmt, ++lineno);
+	while(idx < size - 1) { // skip absolute last newline
 		if (buf[idx] == '\n') {
-			buf[idx] = '\0';
-			htmlf(linefmt, ++lineno);
-			html_txt(buf + start);
-			html("
");
+	html_txt(buf);
+	html("
\n"); } -- cgit v0.10.1