Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QB Express Celebrates One Year: Issue #12 Released
#11
There's no indentation in IE.

I would do this, which could work in all browsers: Create a style for div which uses a monospaced font, and the overflow = auto and stuff, and then write a little parser in fB which turns spaces into &nbsp;'s and that adds a <br> at the end of each line. That way you won't need <pre> and it will get rendered correctly in both IE and FF (gray boxes aside, which are after all a bug which will be fixed anytime soon).

The code is still usable as copying from the browser then pasting to notepad or whatever gives spaces and line feeds correctly.

I'm checking it out with FF right now from a Linux box and the code boxes look ugly 'cause it's using 8 spaces per tab and I used 4, for example, thus the indentation gets garbled. A simple program which substitutes spaces by &nbsp;'s and tabs by &nbsp;&nbsp;&nbsp;&nbsp; would work nice, I think. Most people use 3 or 4 spaces for indenting. Also, using this smaller tab jumps would solve the issue of hyper-horizontal code snippets Tongue

This seems to work. The CSS bit is something in the lines of:

Code:
#codebox {
            overflow:         auto;
            font-family:         monospace, courier;
            font-size:         12px;
            background-color:     #ccccff;
            color:             black;
            border:         1px solid black;
            margin-left:         auto;
            margin-right:         auto;
            width:            600px;
        }

And the <div> containing the code snippet looks something like this:

Code:
<div id='codebox'>For&nbsp;i&nbsp;=&nbsp;0&nbsp;To&nbsp;255<br>
&nbsp;&nbsp;&nbsp;&nbsp;Get&nbsp;#1,&nbsp;,&nbsp;myDatum<br>
&nbsp;&nbsp;&nbsp;&nbsp;myDatum&nbsp;=&nbsp;myDatum&nbsp;*&nbsp;2<br>
&nbsp;&nbsp;&nbsp;&nbsp;For&nbsp;j&nbsp;=&nbsp;0&nbsp;To&nbsp;127<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Print&nbsp;averageData&nbsp;(myDatum,&nbsp;j)<br>
Next&nbsp;j&nbsp;</div>

It's ugly but it works. And the fB program to "translate" spaces to &nbsp;'s, tabs to 4*&nbsp;'s and linefeeds as <br>'s is quite easy to code Wink
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Messages In This Thread
QB Express Celebrates One Year: Issue #12 Released - by na_th_an - 07-21-2005, 03:32 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)