PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Syntactic Keyword Coloring online.

The PocketMatrix forums now provide C / C++ syntactic keyword coloring for source code wrapped with the [ code ] tags.

If you see any problems, or have suggestions, please post them to this thread.

There are a few known limitations to this script:

Precompiler directives are not properly recognized if the pound sign (#) is not immediately in front of the directive name.

Filename strings for #include directives that specify a search path are not colored as a string.

Tabs are currently replaced with 4 spaces. That will cause alignment problems when the tabs are not the first characters on the line. This problem already existed with the [ code ] tags before the new script.

I am also considering not displaying line numbers if there are less than a predefined number of lines. Same with the source code stats. Give some suggestions on what you feel the cutoff number of lines should be (probably 3 or 4).

Finally, the CODE blocks are now C / C++ specific. If you use them to post other languages, the coloring will not properly match.

Here's a sample showing the above issues:
Code:

#define SOMETHING //works properly
# define SOMETHING_ELSE //# and define should be blue

#include "stdio.h" //works
#include <stdio.h> //doesn't work

/*The following 3 numbers should all be aligned*/
#define AN_ITEM 1
#define ANOTHER_ITEM 2
#define THIRD_ITEM 3


Dan East
This is VERY cool Dan. I was pleasantly suprised this morning when I saw the first post on my forum with this new feature (actually, it was an old post). Great work!
Way cool...thanks Dan.
EXTREMELY cool, Dan. You're awesome. I'd suggest 5-7 lines as the cut-off for line numbering.
Perhaps there should be a some more tags for the [ code ] header such as these:
[ code ] defaults to C++ style syntaxing
[ code=cpp ] for C/C++/C# style syntaxing
[ code=bas ] bas for BASIC
[ code=vb ] vb for visual basic
[ code=nosyn ] for no coloring
[ code=nonum ] for no numbering
[ code=nons ] for no "no nonsense" like line Numbers or Syntax (ns: number and syntaxt, or nonsense, whichever people start saying more :))
Working on the tab alignment should be a top priority. Should it work though if you just < pre everything inside the code box? or is it already < pre >ed ?
Code:

MissleFire(x,y,a) {
bufferspr( "missle.bmp", plr_m );
while( y, y>0, y-a ) {
displayspr( plr_m, x, y);
if (y == en_y) {
KillEnem(x,y); Explosion(x,y); y=0; end }
}
return(0);
Awsome job, Dan, as usual!
I wonder if you could add a button to the lower right corner that copies the whole code to the clipboard...?
Dan you're awesome. This [code] thingy ROCKS! Pocketmatrix is the best programming forum atm I guess.
Thanks to Chris, Dan and everyone else that was involved!:)
Thanks for the feedback everyone! I'm so used to looking at source code in that way that it's spoiled me. I couldn't do without the color any longer! :) Shape - that's a good idea, but it's more up Chris' alley. ;)

Dan East
Chris Edwards · 09 Feb 2002, 06:49 UTC
Hmm, that's a good idea shape.. I'll try to do it tomorrow... Matt and I are starting to get organized here, we have some reviews that needs to be written, so we're gonna start setting tasks/due dates now :)...

Anyways.. As I said, I'll work on that soon.... Here's what's coming with the forums when I have some time:

- Re-do templates, use valid HTML 4 code everywhere... Optimize for file size for quick forum browsing
- Create Pocket PC compatible template
- Update forum to phpBB CVS (should fix a few bugs)
- Integrate FAQ into forum
- Rebuild News/Multimedia/FAQ system so that they can be set as sticky
- Fix scripting w/permissions for News/Multimedia/FAQ so that people in the news team can actually post news ;)
- Build a better new-post tracking system...
- Fix tabbing on Dan's syntax colouring script
- Add PHP to syntax colouring (and allow user to select which script they are writing in)

And the site:

- Developers section (integrated with forums... articles, tutorials, etc.. Any volunteers that want to help out with this?)
- Still some pages that need to be fixed up since server move
- Integrate guides/reviews with forum
- Remove downloads section (unless anyone wants us to keep it up there :)... well.. anyone except Mike - pocketgamer.org)
- Integrate latest forum posts into front page
It's beautiful stuff, but I have some trouble into the display with the Opera browser. The frame with the code it's bigger than the page and override other messages and the code it's in white color with a white background, not very simple to read :?
I know opera doesn't handle some stuff (style sheet) like MSIE do, but if it's possible to do something, it's great.

Thank you
Hiya.

I thought maybe I should've posted:

<a href="http://forums.pocketmatrix.com/viewtopic.php?t=5987">this "bug"</a> here.

:)

Cheers,

Refractor
It doesn't work properly in Mozilla either (similar symptoms to what the Opera guy suggested). As a Moz evangelist/web developer type of guy, I'd be glad to help you guys get this working in Moz/Opera.

Cheers

Jon
I can barely view this thread, everytime I come to it, a white window comes up, and says 1, 2 ,3 syntact coloring, and it won't go away.
well, I know you wanted to exibit it, but I can't see anypost except the first one from Dan East, becuase he posted it.
actually just forget it, I was an idiot.
That white box thing is a bug in non-IE browsers, but whatever.
exactly, I'm not using IE, I'm using opera, and I can't use IE anyway