Page 1 of 1

C++ syntax highligting in posts

Posted: Fri Feb 17, 2012 11:36 am
by PB
Am I the only one who misses the code highlighting in the "code" section of forum posts? I think it improves a code readability a lot and IIRC you could also click on a wxWidgets' function or type to get the official documentation for it. I know that the feature was removed during the forum upgrade last summer but I'm not sure why:
1. Was the custom highlighter source code (written by UpCase AFAIK) lost?
2. It couldn't be used (or easily ported to) with newer phpBB and there's also no other (good enough) generic phpBB C++ syntax highlighter?
3. Is it considered not being worth the hassle installing such forum extension?

Thank you for your answer and of course also for hosting/administrating the forum.

Re: C++ syntax highligting in posts

Posted: Sat Feb 18, 2012 1:36 am
by Auria
Yeah I miss it too but for some weird reason PHPBB 3 only provides PHP highlighting and I can't find an add--on that works :( the older PHPBB 2 forum used the genshi extension but it hasn't been ported to PHPBB3 as far as I know. If someone knows of a good syntax highlight extension that I can install without fuss...

Here's an example what the PHP highlighter does. It's not that bad even for C++ actually, but the "code" button in the toolbar does not configure it for php by default

Code: Select all

#include "wx/wx.h"
#include "wx/sizer.h"
class BasicDrawPane : public wxPanel
    BasicDrawPane(wxFrame* parent);
    void paintEvent(wxPaintEvent & evt);
    void paintNow();
    void render(wxDC& dc);
    // some useful events
     void mouseMoved(wxMouseEvent& event);
     void mouseDown(wxMouseEvent& event);
     void mouseWheelMoved(wxMouseEvent& event);
     void mouseReleased(wxMouseEvent& event);
     void rightClick(wxMouseEvent& event);
     void mouseLeftWindow(wxMouseEvent& event);
     void keyPressed(wxKeyEvent& event);
     void keyReleased(wxKeyEvent& event);
class MyApp: public wxApp
    bool OnInit();
    wxFrame *frame;
    BasicDrawPane * drawPane;
bool MyApp::OnInit()
    wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
    frame = new wxFrame((wxFrame *)NULL, -1,  wxT("Hello wxDC"), wxPoint(50,50), wxSize(800,600));
    drawPane = new BasicDrawPane( (wxFrame*) frame );
    sizer->Add(drawPane, 1, wxEXPAND);
    return true;
BEGIN_EVENT_TABLE(BasicDrawPane, wxPanel)
// some useful events
// catch paint events
// some useful events
 void BasicDrawPane::mouseMoved(wxMouseEvent& event) {}
 void BasicDrawPane::mouseDown(wxMouseEvent& event) {}
 void BasicDrawPane::mouseWheelMoved(wxMouseEvent& event) {}
 void BasicDrawPane::mouseReleased(wxMouseEvent& event) {}
 void BasicDrawPane::rightClick(wxMouseEvent& event) {}
 void BasicDrawPane::mouseLeftWindow(wxMouseEvent& event) {}
 void BasicDrawPane::keyPressed(wxKeyEvent& event) {}
 void BasicDrawPane::keyReleased(wxKeyEvent& event) {}
BasicDrawPane::BasicDrawPane(wxFrame* parent) :
 * Called by the system of by wxWidgets when the panel needs
 * to be redrawn. You can also trigger this call by
 * calling Refresh()/Update().
void BasicDrawPane::paintEvent(wxPaintEvent & evt)
    wxPaintDC dc(this);
 * Alternatively, you can use a clientDC to paint on the panel
 * at any time. Using this generally does not free you from
 * catching paint events, since it is possible that e.g. the window
 * manager throws away your drawing when the window comes to the
 * background, and expects you will redraw it when the window comes
 * back (by sending a paint event).
 * In most cases, this will not be needed at all; simply handling
 * paint events and calling Refresh() when a refresh is needed
 * will do the job.
void BasicDrawPane::paintNow()
    wxClientDC dc(this);
 * Here we do the actual rendering. I put it in a separate
 * method so that it can work no matter what type of DC
 * (e.g. wxPaintDC or wxClientDC) is used.
void BasicDrawPane::render(wxDC&  dc)
    // draw some text
    dc.DrawText(wxT("Testing"), 40, 60); 
    // draw a circle
    dc.SetBrush(*wxGREEN_BRUSH); // green filling
    dc.SetPen( wxPen( wxColor(255,0,0), 5 ) ); // 5-pixels-thick red outline
    dc.DrawCircle( wxPoint(200,100), 25 /* radius */ );
    // draw a rectangle
    dc.SetBrush(*wxBLUE_BRUSH); // blue filling
    dc.SetPen( wxPen( wxColor(255,175,175), 10 ) ); // 10-pixels-thick pink outline
    dc.DrawRectangle( 300, 100, 400, 200 );
    // draw a line
    dc.SetPen( wxPen( wxColor(0,0,0), 3 ) ); // black line, 3 pixels thick
    dc.DrawLine( 300, 100, 700, 300 ); // draw line across the rectangle
    // Look at the wxDC docs to learn how to draw other stuff

Re: C++ syntax highligting in posts

Posted: Sat Feb 18, 2012 1:45 am
by Auria
Oh and also... I have admins right to the control panel but I don't have access to the server where the forum is installed so I can't do installations that can't be done 100% through the control panel

Re: C++ syntax highligting in posts

Posted: Sat Feb 18, 2012 10:31 pm
by PB
Thanks for the explanation. Too bad then, I didn't think that getting a decent C++ syntax highlighter for phpBB was difficult. My fault, if it was easy it would be already here, I suppose.

[off-topic]By the way, I also noticed that the forum site lacks favicon, not that it is important.
And one more observation, also not important: while it's good that people can mark their own post as "SOLVED" (assuming it's possible only in the threads they started), I don't think that it should count towards their total "credit". I find it somewhat odd that one can easily obtain a "rank" just by marking his own threads.[/off-topic]

Re: C++ syntax highligting in posts

Posted: Mon Aug 27, 2012 8:44 pm
by Hossein
I dont know if these still work : ... &t=2096992 ... &t=1697035
but in case they dont, you can always use this site to highlight your C++ sourcecodes.maybe adding a link to this site would be a good idea when an addon is not available yet.