Edgewall Software
Modify

Opened 20 years ago

Closed 20 years ago

#579 closed enhancement (duplicate)

Line Numbers in File Browser

Reported by: kspinka@… 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 Christopher Lenz, 20 years ago

Component: generalbrowser
Severity: normalenhancement
Summary: Line Numbers on Diff Displays and File BrowserLine Numbers in File Browser

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.

comment:2 by imontes@…, 20 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 mcarpenter@…, 20 years ago

Version: 0.7.1devel

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 Christopher Lenz, 20 years ago

Resolution: duplicate
Status: newclosed

This is a duplicate of #520.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.