Opened 21 years ago
Closed 21 years ago
#579 closed enhancement (duplicate)
Line Numbers in File Browser
| Reported by: | Owned by: | Jonas Borgström | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | version control/browser | Version: | devel |
| Severity: | normal | Keywords: | numbers |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
This would be a very helpful option.
Attachments (0)
Change History (4)
comment:1 by , 21 years ago
| Component: | general → browser |
|---|---|
| Severity: | normal → enhancement |
| Summary: | Line Numbers on Diff Displays and File Browser → Line Numbers in File Browser |
comment:2 by , 21 years ago
| Keywords: | numbers added |
|---|
The solution is quite simple, however my null knowledge of python makes it impossible for me to suppy a fix :(
We need to add the following CSS:
pre.line-numbers {
width: 42px;
float: left;
background: #eee;
border-right: #ccc;
margin-top: 0;
}
pre.code-block {
margin-top: 0;
margin-left: 42px;
}
In pre.line-numbers we should put the same font and size as the one used in pre.code-block!
Then when generating the file-viewing page we need to generate the line numbers. For this we need to find out the number of lines of the file wich I'll call $numLines in the following PHP code
$out = '<pre>';
for ($i=1; $i<=$numLines; $i++) {
//this add spaces at the beggining to make the string of a fixed length of 4
//This allows to for a max. of 9999 lines
$out .= str_pad( $i, 4, " ", STR_PAD_LEFT );
$out .= "\n"; //since it's a <pre> a simple \n works
}
$out .= '</pre>';
This method allows to keep the line numbers separated from the code, so multiple lines code selection is possible. I've tested it in IE, Firefox and Opera.
ciao, Ivan
comment:3 by , 21 years ago
| Version: | 0.7.1 → devel |
|---|
It would be great to have these be anchor tags, so I can have a link like:
http://..../browser/trunk/filname.txt?rev=1#line43
Then I could have a script that turns my java stack traces in my ticket into hyperlinks into the src browser.
comment:4 by , 21 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
This is a duplicate of #520.



Diffs include line numbers in the current development version (which will be 0.8).
Line numbers for file viewing is harder, because we rely on external tools/libraries for embedding the file contents in the HTML page.
Changing component and summary to reflect that this ticket only apples to the browser module.