[imp] [patch] MIME_Viewer_source

Daniel Eckl daniel.eckl at gmx.de
Thu Dec 18 06:18:15 PST 2003


> Another problem with the enscript viewer is the line numbers if long lines
> are
> wrapped by the browser. Since the line numbers are in another table data and
> only seperated by <br />, they don't compensate the fact, that one line is
> broken in two or more. But I have got no solution for that at the moment...

Here is my first suggestion to that problem as attachement.

What do you think?

Greets,
Daniel
-------------- next part --------------
--- MIME/MIME/Viewer/source.php.orig    Thu Dec 18 14:39:00 2003
+++ MIME/MIME/Viewer/source.php Thu Dec 18 15:14:16 2003
@@ -24,14 +24,15 @@
      */
     function lineNumber($code, $linebreak = "\n")
     {
-        $lines = substr_count($code, $linebreak) + 1;
+        $lines = split($linebreak, $code);
         $html  = '<table style="border: 1px solid black" cellspacing="0" cellpadding="0" 
width="100%">';
-        $html .= '<tr><td valign="top" style="background-color:#e9e9e9; padding-left:10px; 
padding-right:10px; text-align:right;">';
-        for ($l = 1; $l <= $lines; $l++) {
-            $html .= sprintf('<a style="font-family:monospace;" name="%s" href="#%s">%s</a><br />', 
$l, $l, $l) . "\n";
+        foreach ($lines as $key => $thisline)
+        {
+          $nr = $key + 1;
+          $html .= '<tr><td valign="top" style="background-color:#e9e9e9; padding-left:10px; 
padding-right:10px; text-align:right;">' . $nr . '</td>';
+          $html .= '<td width="100%" valign="top" style="background-color:white; padding-left:10px; 
font-family:monospace;">' . $thisline . '</td></tr>';
         }
-        $html .= '</td><td width="100%" valign="top" style="background-color:white; 
padding-left:10px; font-family:monospace;">' . $code . '</td>';
-        return $html . '</tr></table>';
+        return $html . '</table>';
     }

 }



More information about the imp mailing list