C++ syntax highligting in posts  [SOLVED]

The Forum Rules, general FAQ and questions or comments about the forum are posted here.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 1684
Joined: Sun Jan 03, 2010 5:45 pm

C++ syntax highligting in posts

Postby PB » Fri Feb 17, 2012 11:36 am

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.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: C++ syntax highligting in posts  [SOLVED]

Postby Auria » Sat Feb 18, 2012 1:36 am

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
{
    
public:
    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);
     */
    
    DECLARE_EVENT_TABLE
()
};
 
 
class MyApp
: public wxApp
{
    bool OnInit();
    
    wxFrame 
*frame;
    BasicDrawPane * drawPane;
public:
        
};
 
IMPLEMENT_APP
(MyApp)
 
 
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);
    
    frame
->SetSizer(sizer);
    frame->SetAutoLayout(true);
    
    frame
->Show();
    return true;
}
 
 
BEGIN_EVENT_TABLE
(BasicDrawPane, wxPanel)
// some useful events
/*
 EVT_MOTION(BasicDrawPane::mouseMoved)
 EVT_LEFT_DOWN(BasicDrawPane::mouseDown)
 EVT_LEFT_UP(BasicDrawPane::mouseReleased)
 EVT_RIGHT_DOWN(BasicDrawPane::rightClick)
 EVT_LEAVE_WINDOW(BasicDrawPane::mouseLeftWindow)
 EVT_KEY_DOWN(BasicDrawPane::keyPressed)
 EVT_KEY_UP(BasicDrawPane::keyReleased)
 EVT_MOUSEWHEEL(BasicDrawPane::mouseWheelMoved)
 */
 
// catch paint events
EVT_PAINT(BasicDrawPane::paintEvent)
 
END_EVENT_TABLE
()
 
 
// 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) :
wxPanel(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);
    render(dc);
}
 
/*
 * 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);
    render(dc);
}
 
/*
 * 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
}
 
"Keyboard not detected. Press F1 to continue"
-- Windows

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: C++ syntax highligting in posts

Postby Auria » Sat Feb 18, 2012 1:45 am

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
"Keyboard not detected. Press F1 to continue"

-- Windows

PB
Part Of The Furniture
Part Of The Furniture
Posts: 1684
Joined: Sun Jan 03, 2010 5:45 pm

Re: C++ syntax highligting in posts

Postby PB » Sat Feb 18, 2012 10:31 pm

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]

Hossein
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Sep 21, 2008 7:23 am
Location: Somwhere nearby...
Contact:

Re: C++ syntax highligting in posts

Postby Hossein » Mon Aug 27, 2012 8:44 pm

I dont know if these still work :
https://www.phpbb.com/community/viewtop ... &t=2096992
https://www.phpbb.com/community/viewtop ... &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.
:http://dwks.theprogrammingsite.com/myprogs/cfonline.htm
Add-on Components (90)
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)

http://www.wxcommunity.com/


Return to “General Forum Issues”

Who is online

Users browsing this forum: No registered users and 1 guest