PDA

View Full Version : Syntax Highlighting (is it possible?)



Xorcist
12-11-2002, 01:27 AM
Is there anyway we could add syntax highlighting to the
sections?

BlueCat
12-11-2002, 01:43 PM
No you can't....yet

Give me a few days and I'll see what can be done :)

While you're waiting, here's something to play with!

Use Your text here to add a glow to your text

Use Your text here to add a shadow

It's not syntax highlighting but at the moment it's all I've got for you :shock:

Xorcist
15-11-2002, 04:26 AM
I found this (http://www.phpbb.com/mods/downloads/uploads/phpbbcode.txt) PHP code that might be of use. Currently it is set up to highlight PHP code sections (i.e. |php||/php|) in a C like fasion. We might be able to modify it so it handles |code||/code| sections and highlights itin a Pascal fashion.

P.S. I also found this (http://www.fubonis.com/phpbb2/MODS/VBBBCode.txt) one for VB style highlighting. Now if I could just find one for Pascal!!!!

P.P.S. Maybe I'll sit down and see if I can convert it myself.

BlueCat
15-11-2002, 08:49 AM
Thanks, I'm still looking too. If you could write one yourself I'd be very grateful. If you go over to phpbbhacks.com (http://www.phpbbhacks.com) there's plenty of info on making a mod. Then I can just install it here :twisted:

If not, I'm sure between us we can work out how to replace the bit that formats [code].

BlueCat
15-11-2002, 01:42 PM
I've started on a Pascal highlighter based on that VB one. So far I've put ALL the reserved words in to it. Having a bit of trouble with comments at the moment. Let you know when it's done.

Xorcist
16-11-2002, 12:54 AM
I started working on the original C style one and was blown away at the amount of PHP code I couldn't decipher. Let me know how work goes on the VB one. I'll be trolling around the PHP tutorial sites trying to gain a bit of insight on it all.

BlueCat
17-11-2002, 11:11 AM
I've got a working version now, it just highlights reserved words, comments and strings. A lot of work to do yet. And it's only working for the DarkEQ style so try it at your own risk!!

If anyone can help, I'm having a little problem :D

When I set the font colour, it changes the text to a different font. It should be a nice source code font like courier, but any text I put <font color=#xxxxxx></font> changes the font face. Is there a way in HTML to force a font to be applied, I'm not so good at this sort of thing. I'd guess the style sheet settings are overriding mine :?:

This is how it looks now:


procedure test; //This is a comment
begin
string := 'And here is a string';
number := 12345; // That was a number
end;

Marty
17-11-2002, 02:18 PM
well, maybe this is a provisional solution for the problem. when I want to have syntax-highlighting in my code in other forums I use JAPP (just another pretty printer) which converts delphi- (and other code) into html. then you can insert the conversion into the post.

BlueCat
17-11-2002, 10:00 PM
Thanks, but I think it's nearly done now :lol:

Xorcist
17-11-2002, 10:07 PM
Yeah that DarkEQ style is kinda ugly (no offense). As for the font, can't you just use:

<font face="Arial, Courier New, Time New Roman" color="#xxxxxx">Text goes here</font>

to specify the order in which fonts should be used if they are available? I'm pretty sure this would first use Arial, then Courier New, then Times New Roman then default to whatever the HTML page is set to use (given the availability of each).

Xorcist
17-11-2002, 10:24 PM
Testing...


TestVar := 1;


Hmmm, that should have been:

TestVar &#58;= 1;

it seems that have gotten rid of everything before the first number.


TestVar1 := 1;
TestVar2 := 2;


Yeah looks like everything before the first number, that should have been:

TestVar1 &#58;= 1;
TestVar2 &#58;= 2;


Let's try this:

var
TestVar1 := 1;
TestVar2 := 2;


Hmmm, if you could post a link to the file you're using maybe I can help in someway. Two heads are better than one.

BlueCat
17-11-2002, 10:26 PM
Yeah that DarkEQ style is kinda ugly (no offense). As for the font, can't you just use:

<font face="Arial, Courier New, Time New Roman" color="#xxxxxx">Text goes here</font>

to specify the order in which fonts should be used if they are available? I'm pretty sure this would first use Arial, then Courier New, then Times New Roman then default to whatever the HTML page is set to use (given the availability of each).

No, no effect. I'm using the <span> tag now and it works fine.

There are a few 'bugs' but we're getting there :twisted:

Xorcist
17-11-2002, 10:36 PM
Yeah, I just noticed. :) I was running a couple "beta tests", the post above the last one has what I found.

P.S. Once it is up and running, we might want to have a vote on the syntax colors (and background, that blue makes my head hurt). :)

BlueCat
17-11-2002, 10:51 PM
Those tests you did look OK to me, except that the 1 in TestVar1 shouldn't really be highlighted. The file with all the stuff is here (http://terraqueous.f2o.org/dgdev/includes/bbcode.txt). It's not the actual file, it's a copy with a .txt extension.

Xorcist
18-11-2002, 12:32 AM
Hmm... that's weird, everything looks fine now, but it was messed up before, maybe it was just my machine.

BlueCat
18-11-2002, 09:39 AM
I've fixed the 'number thing', it's still acting a bit weird but I haven't enough time to work on it all day 8) It's highlighting reserved words, numbers, strings and comments, are there any others I need to add?

Useless Hacker
18-11-2002, 10:16 AM
Couldn't you get it to format it like Delphi does, rather than just highlighting things in different colours. Something like this:

[Dammit I give up - basically, I meant use the same font as Delphi (Courier New) and put keywords in bold.]

{MSX}
18-11-2002, 12:52 PM
It seems to work fine! good job :D
So when you have spare time you could put it on subSilver too.. It shouldn't be difficoult once you've done for darkeq..

PS once you've completed it you could post the hack to http://www.phpbbhacks.com/ to share it if others need..

Here's some test, just to look how it looks..

function parola(s:string):boolean;
var i:integer;
begin
for i:=0 to form1.listbox1.items.count-1 do
if lowercase(form1.listbox1.items[i])=lowercase(s) then
begin
result:=true;
exit;
end;
result:=false;
end;


(added)
Umm it seems like he don't hilight internal begin/end blocks..
let's see:

begin
begin
begin
if a=b then
begin
begin
end;
end;
end;
end;
end;

There is a little problem here :D

BlueCat
18-11-2002, 01:46 PM
Thanks, how's that?

I'd messed up the search string, whitespace is a strange thing :oops:

{MSX}
18-11-2002, 01:54 PM
It works now! Well done! :)

BlueCat
18-11-2002, 03:29 PM
It seems to work fine! good job :D
So when you have spare time you could put it on subSilver too.. It shouldn't be difficoult once you've done for darkeq..


OK subSilver should work for you now. I know the colours won't be everyone's favourite but they're easy to change.

BlueCat
18-11-2002, 05:48 PM
Until further notice, the pascal tag won't work. I'll let you know when :shock:

And it's back :P

Useless Hacker
19-11-2002, 09:14 AM
Very nice! :D

Xorcist
19-11-2002, 09:00 PM
Testing...

{Syntax Highlighting}
Procedure TForm.ButtonClick(Sender TObject);
var
Number: Integer;
begin
Number := 123456;
Caption := 'The number is: ' + IntToStr(Number);
end;


Noticed the first single quote in the string is highlighted, but not the last.

Alimonster
19-11-2002, 09:07 PM
Testing:

program Project1;

{$APPTYPE CONSOLE}

var
Loop: Integer;

begin
for Loop := 0 to 1000 do begin
Write('Hung Up'+#9#8#8#8#8#8#8);
end;
end.

8)

Xorcist
19-11-2002, 09:16 PM
Any chance we could come up with a couple color combinations and hold a poll on it? The dark background with the neon foreground makes it a little rough on the eyes to read (at least for me anyways). Maybe something on the old grey background, like this:

http://www.eden.rutgers.edu/~xorcist/Images/Highlight1.png

or maybe this as an alternate (seeing as how I'm not sure hard the black standard text would be):

http://www.eden.rutgers.edu/~xorcist/Images/Highlight2.png

BlueCat
19-11-2002, 10:11 PM
Noticed the first single quote in the string is highlighted, but not the last.

Thanks, fixed that 8)


Any chance we could come up with a couple color combinations and hold a poll on it?

Yeah go for it! You know we'll NEVER find colors that suit everyone, maybe we could add it to the 'Profile' options :wink:

Xorcist
19-11-2002, 11:07 PM
I was going to started a poll over in the general forum, however for the life of me I can't figure out how to start a "poll". Do I have to be a moderator or something?

iLLUNis
19-11-2002, 11:24 PM
I was going to started a poll over in the general forum, however for the life of me I can't figure out how to start a "poll". Do I have to be a moderator or something?
As far as i know with the current settings you have to be a moderator to start a poll.....if you want it i could start it for you...

iLLUNis
19-11-2002, 11:32 PM
I was going to started a poll over in the general forum, however for the life of me I can't figure out how to start a "poll". Do I have to be a moderator or something?
As far as i know with the current settings you have to be a moderator to start a poll.....if you want it i could start it for you...

:oops: Now that i look closely i dont seem to be able to start a poll either. It looks like that you cannot start a poll on a thread that is already in use....we will have to start a new thread with the same topic for the poll. On the other hand like BlueCat said we will never be able to satisfy everybody.... :shock: up to U guys

Xorcist
19-11-2002, 11:43 PM
Cat hooked me up, the poll is not running in the general forum. It's open to other suggestions so people can post other variants if they don't like mine. Whatever the majority rules on I'll be happy with, even if it's the current style.