syntax highlighting using geshi

Discussion about the website and the forum goes here.
User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

syntax highlighting using geshi

Post by Sektor » 10 Nov 2011, 22:03

Code: Select all

[mis]DO_NOWT[/mis]
[syntax=mis]// MultiSlayer Cage by BenMillard

// Railway Stations
SET_STATION_INFO (trak00, 3, 0, 1) // 3 carriages, 1 box car


// Radio Stations
RADIO_STATION industrial = STATION_INDUSTRIAL (128.0,128.0)
RADIO_STATION residential = STATION_RESIDENTIAL (128.0,128.0)
RADIO_STATION downtown = STATION_DOWNTOWN (128.0,128.0)


// Weapons
GENERATOR health1 = (54.0,145.0,1.0) 0 collect_30 120 120


// Automatic rockets like PZA
COUNTER loop = 1


// Footballs
OBJ_DATA ball1 = (066.0,152.0,255.0) 0 FOOTY // new
OBJ_DATA ball2 = (064.0,148.8,255.0) 0 FOOTY
OBJ_DATA ball3 = (064.5,148.8,255.0) 0 FOOTY


// Towers
OBJ_DATA tower_12 = (059.8,149.2,255.0) 000 TOWER
OBJ_DATA tower_13 = (066.2,148.8,255.0) 000 TOWER
OBJ_DATA tower_14 = (072.2,148.8,255.0) 000 TOWER
OBJ_DATA tower_15 = (059.8,154.2,255.0) 000 TOWER
OBJ_DATA tower_16 = (072.2,154.8,255.0) 000 TOWER
OBJ_DATA tower_17 = (065.2,144.8,255.0) 000 TOWER


// Sounds
SOUND crane3 = (050.5,148.5,2.0) GENERATOR_RUMBLE PLAY_FOREVER
SOUND bugs8 = (036.5,147.0,3.0) CRICKETS PLAY_FOREVER
SOUND bugs9 = (044.5,140.0,3.0) CRICKETS PLAY_FOREVER
SOUND bugs10 = (045.5,148.5,5.0) CRICKETS PLAY_FOREVER
SOUND bugs11 = (050.5,153.5,4.0) CRICKETS PLAY_FOREVER
SOUND bugs12 = (047.5,159.5,3.0) CRICKETS PLAY_FOREVER
SOUND bugs13 = (044.5,167.5,3.0) CRICKETS PLAY_FOREVER
SOUND bugs14 = (076.0,154.5,2.0) CRICKETS PLAY_FOREVER


// Normal Parked Vehicles:
PARKED_CAR_DATA firetruck1 = (061.0,144.5) -1 090 FIRETRUK // football


// Players:
// 2 3
// 4 6
// 1 5
PLAYER_PED p1 = (53.7,147.7,1.0) 10 180 // Red
PLAYER_PED p2 = (52.3,142.3,1.0) 09 000 // Orange
PLAYER_PED p3 = (56.3,142.3,1.0) 07 315 // Yellow
PLAYER_PED p4 = (55.5,145.5,1.0) 11 270 // Green
PLAYER_PED p5 = (57.3,147.7,1.0) 13 270 // Dark Blue
PLAYER_PED p6 = (57.3,143.3,1.0) 08 315 // Black



LEVELSTART


// Environment
SET_AMBIENT_LEVEL (0.33,0)
SET_SHADING_LEVEL (20)
SET_DIR_OF_TV_VANS (130.5,120.0)
DECLARE_POLICELEVEL (4) // SWAT


// Weapons
SWITCH_GENERATOR (health1, ON)


// Automatic Rockets
WHILE (loop=1)
IF (CHECK_CHARACTER_HEALTH(p1, 0))
GIVE_WEAPON (p1, ROCKET_LAUNCHER, 99)
ENDIF

IF (CHECK_CHARACTER_HEALTH(p2, 0))
GIVE_WEAPON (p2, ROCKET_LAUNCHER, 99)
ENDIF

IF (CHECK_CHARACTER_HEALTH(p3, 0))
GIVE_WEAPON (p3, ROCKET_LAUNCHER, 99)
ENDIF

IF (CHECK_CHARACTER_HEALTH(p4, 0))
GIVE_WEAPON (p4, ROCKET_LAUNCHER, 99)
ENDIF

IF (CHECK_CHARACTER_HEALTH(p5, 0))
GIVE_WEAPON (p5, ROCKET_LAUNCHER, 99)
ENDIF

IF (CHECK_CHARACTER_HEALTH(p6, 0))
GIVE_WEAPON (p6, ROCKET_LAUNCHER, 99)
ENDIF
ENDWHILE

LEVELEND[/syntax]

User avatar
Pyro
Immortal
Posts: 414
Joined: 17 Mar 2010, 04:07
GH nick: Pyro
Location: Wales, UK

Re: code/syntax highlighting

Post by Pyro » 18 Nov 2011, 17:56

That looks really cool 8-)

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: code/syntax highlighting

Post by Sektor » 18 Nov 2011, 17:59

Yes, I like it, T.M. did most of it. [syntax=mis] is a bit long. I'd prefer [mis] or even

Code: Select all

 with auto detection of language. I also want show/hide line numbers button.

I know the contracted size is too small and expand should only be displayed if the script is large but I haven't worked out how to fix that just yet.

BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: code/syntax highlighting

Post by BenMillard » 18 Nov 2011, 18:07

Numbers with a leading zero are given a different colour. It probably thinks they are octal numbers, per convention. Should be able to set octal numbers to have the same colour as other numbers.

I sometimes give floats a leading zero to help alignment, so it won't just be integers that are affected. In particularly dense lists of coordinates, I've started to use a leading space instead of a leading zero.

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: code/syntax highlighting

Post by Sektor » 18 Nov 2011, 18:20

Added this to mis.php:

[syntax=php]'NUMBERS' => GESHI_NUMBER_INT_BASIC | GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_FLT_SCI_ZERO,[/syntax]
That fixed the numbers with leading zeroes.

Hide is pointless. "Using GTA2 Script Syntax Highlighting" isn't really needed or could just be reduced to "MIS" in the header. The word "Syntax:" needs to be removed from the header and the footer isn't needed either. The left margin could be reduced.

BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: syntax highlighting

Post by BenMillard » 20 Nov 2011, 00:59

The .mis highlighter has one too many </div> tags at the end. That causes the message content container to be closed prematurely, so any subsequent text in that message is made tiny.

Not quite sure when it happens but here's an example. (I've seen it happen to TM as well...)

[syntax=c]Example of C highlighting.[/syntax]
This text is fine.

[mis]Example of .mis highlighting[/mis]
This text is small. (At least, it is in the example!)

[mis]Example of .mis highlighting[/mis]
Other syntax samples are fine, at least in the subsilver theme. Please don't call it syntax because I always, always typo it first time!

(EDIT) Oh, zomg, there's a <script> doing a document.write to add an extra </div> - that seems rather funky!
Last edited by BenMillard on 21 Nov 2011, 21:28, edited 1 time in total.

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Collection of gta scripting and map weirdness

Post by Sektor » 20 Nov 2011, 01:25

Prosilver theme doesn't even have the expand/contract buttons and I update it much less often than Subsilver2. I've seen the small text bug on Prosilver. With Subsilver2, it looks ok in FF8 and IE8 but the code still needs fixing.

User avatar
Pyro
Immortal
Posts: 414
Joined: 17 Mar 2010, 04:07
GH nick: Pyro
Location: Wales, UK

Re: Collection of gta scripting and map weirdness

Post by Pyro » 20 Nov 2011, 01:37

Yup, I'm using Prosilver and get the small text bug. It also puts the username below the signature. If you're seeing it too then I don't need to send you screenshot unless you want me to.

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: syntax highlighting

Post by T.M. » 20 Nov 2011, 14:03

BenMillard wrote:Please don't call it syntax because I always, always typo it first time!
lol yeah, i typed [source] instead :-)

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: syntax highlighting

Post by Sektor » 21 Nov 2011, 17:23

[mis] [cpp] [c] [vb] [php] and over 200 other language tags work. You can still use [syntax] if you are a masochist.

I added the Expand/Contract button to Prosilver theme. If you don't see it then try pushing ctrl+f5 to refresh browser cache.

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: syntax highlighting

Post by T.M. » 21 Nov 2011, 19:00

Sektor wrote:[mis] [cpp] [c] [vb] [php] and over 200 other language tags work. You can still use [syntax] if you are a masochist.
I thought i told you [mis] tag was bugged, or did you fix that?

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: syntax highlighting

Post by Sektor » 21 Nov 2011, 19:38

It's fixed now. I added it using the recommended way instead of thinking I could do it without RTFM.

User avatar
Pyro
Immortal
Posts: 414
Joined: 17 Mar 2010, 04:07
GH nick: Pyro
Location: Wales, UK

Re: syntax highlighting

Post by Pyro » 21 Nov 2011, 21:53

Looks good now on Prosilver! 8-)

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: syntax highlighting

Post by T.M. » 22 Nov 2011, 15:50

Im not sure the gray for enums is so good, how about these colors? (changed functions to brighter red too)
syntaxcolors3.png
syntaxcolors3.png (9.51 KiB) Viewed 26944 times
I also noticed the enum list i made was bugged: some of them had space in the end! fixing it as soon as Sektor comes online.

I ALSO noticed that the syntax highlighter expand button doesnt come visible until the WHOLE page has been fully loaded! super annoying.

User avatar
Pyro
Immortal
Posts: 414
Joined: 17 Mar 2010, 04:07
GH nick: Pyro
Location: Wales, UK

Re: syntax highlighting

Post by Pyro » 22 Nov 2011, 23:59

Those colours are too bright, especially the bright orange which is even harder to read than the grey.

The dark-ish red on syntax highlighter is good as well as other dark-ish colours (blue, green), but I agree the grey could be a little darker. Maybe use purple in there somewhere?

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: syntax highlighting

Post by T.M. » 23 Nov 2011, 00:41

I thought it would be too bright indeed... its just hard to please everyone on a white background based syntax colors.

I cant use purple or everything is so damn blueish there. i chose yellowish because that wasnt used yet.

Black is so much easier background for syntax colors :(

BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: syntax highlighting

Post by BenMillard » 23 Nov 2011, 09:12

Might I suggest the Mozilla style syntax colours, as applied for GTA2? Only 200 languages to go, after that! :D

Or just pick the "friendly colours" mode from Mis Pad. Everyone can cope with that.

Red in a code view only makes sense when that bit is an error.

Giving every slightly different thing a completely different, bright colour prevents anything from standing out. It's just noise. That defeats the whole purpose of having colours.

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: syntax highlighting

Post by Sektor » 23 Nov 2011, 09:19

Some ADD_SCORE lines are missing ) on http://projectcerbera.com/gta/2/tutorials/multiplayer

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: syntax highlighting

Post by T.M. » 23 Nov 2011, 12:18

BenMillard wrote:Giving every slightly different thing a completely different, bright colour prevents anything from standing out. It's just noise. That defeats the whole purpose of having colours.
What the hell? By looking at your syntax highlighter, it has everything you whined about here: red as a color and almost same amount of colors as ours have.

BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: syntax highlighting

Post by BenMillard » 23 Nov 2011, 18:55

That's ironic, TM. :roll:

Sektor, CSS can fix long unwrappable lines of code in CSS layouts, such as ProSilver.

Code: Select all

.content .syntax { /* ul_syntax_highlighter.css */
    background-color: #FFFFFF;
    border: 1px solid #D0D0D0;
    color: #444444;
    display: block;
    font-family: Courier,'Courier New',sans-serif;
    font-size: 1em;
    line-height: 1.2em;
    margin: 0;
    white-space: pre-wrap; /* new, supports old Firefox and anything better */
    word-wrap: break-word; /* new, supports IE6 and anything better */
}
I use this for HTML code samples, since URLs are sometimes unwrappable.

Sadly the SubSilver2 theme uses layout table. With a lot of changes you can make the table cells resize more predictably, somewhat like a CSS layout.

Code: Select all

.tablebg { /* stylesheet.css, line 336 */
    background-color: #A9B8C2;
}
.tablebg table { /* new */
    table-layout: fixed; /* topic entry and that entry's content will size a bit more normally */
}
.tablebg td { /* new */
    width: auto; /* nuclear option!! */
}
.tablebg .row1 td + td,
.tablebg .row2 td + td { /* new, supports IE7 and anything better */
    width: 80%; /* 2nd column has <td width="100%"> which squashes 1st column in fixed layout mode */
}
.content .syntax { /* ul_syntax_highlighter.css */
    background-color: #FFFFFF;
    border: 1px solid #D0D0D0;
    color: #444444;
    display: block;
    font-family: Courier,'Courier New',sans-serif;
    font-size: 1em;
    line-height: 1.2em;
    margin: 0;
    white-space: pre-wrap; /* new, supports old Firefox and anything better */
    word-wrap: break-word; /* new, supports IE6 and anything better */
}
I mocked this up in Firebug so it might not actually work! This probably breaks compatibility with IE6. Editing the HTML would mean changing PHP which probably makes updating the forum impossible.

If you try this out, I might get a chance to debug it some more next week. Now I have to go wash those dirty layout tables off my hands.

Post Reply