News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Current status of PHP files support in Code::Blocks?

Started by rickg22, May 30, 2007, 07:07:31 PM

Previous topic - Next topic

rickg22

Hi, as I'm back to programming, I've realized I need a more powerful editor for PHP files in my projects, and my first thought came to good ol' CB.

After all the edits / patches / improvements that have been done, what is the current support for PHP files in C::B, specifically in Lexers?

After ripping off the c++ syntax to a new php lexer, I tried to open a .inc file in Code::Blocks RC2 (yes I know, eeew  :lol: - it's the only version I have at the job), and It didn't know what to do with the file because the fortran 77 lexer already includes the .inc filetype. I had to delete the f77 lexer so it could be opened properly.

Does the SVN version know how to deal with these cases (multiple types, one extension)? I'm dying to edit my php files with CB and do all the nifty stuff (search / replace, go to function etc) I can't do with my current editor.

I really don't care if i can edit embedded html, I just want to edit my business-logic code (the html is in other files).

Any help?

MortenMacFly

To make it short: That's the current state of the activities:

(1) general discussion: http://forums.next.codeblocks.org/index.php/topic,4566.0.html
(2) latest discussion: http://forums.next.codeblocks.org/index.php/topic,5955.0.html

If you see a way to do it... that'd be great! :-)

With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

raph

But why not use an existing exactly-for-php-made editor?
There are lots of out there (e.g. see here).

Regards
raph

MortenMacFly

Quote from: raph on May 30, 2007, 08:11:16 PM
But why not use an existing exactly-for-php-made editor?
Bah! Booooooring... ;-) :lol:
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

eranif

Hi,

The company I am working for (zend) released a free PHP plugin for eclipse (PDT).
http://www.zend.com/pdt

If you find anything that we can improve - let me know  :wink:
Eran

dmoore

GOD DAMN THAT WAS A HARD BUG TO FIND!

the problem is that by default scintilla uses 5 style bits, but all the required PHP styles require 7 bits. In file sdk/editorcolourset.cpp I added the single line (marked with +++)


void EditorColourSet::Apply(HighlightLanguage lang, cbStyledTextCtrl* control)
{
...
        control->SetLexer(mset.m_Lexers);
+++     control->SetStyleBits(7);
...
}


and used the attached lexer file. Now php enclosed in "<?php" and "?>" renders fine (I haven't tested thoroughly).

I'm pretty sure you can also use a php specific lexer file with lexer code wxSCI_LEX_PHPSCRIPT (69). We can also add styles and keywords for all of the supported html embedded scripts (Javascript/Python etc) as per the html properties file in SciTE. I'm guessing a proper fix should only change the stylebits for languages that need the extra bits (obviously html and php - not sure what else).

/sleeps



[attachment deleted by admin]
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

MortenMacFly

Nice one! :D Seems to work for me, too.
Quote from: dmoore on May 31, 2007, 07:00:27 AM

+++     control->SetStyleBits(7);

[...] I'm guessing a proper fix should only change the stylebits for languages that need the extra bits (obviously html and php - not sure what else).
Maybe GetStyleBitsNeeded() can help us out here... this should actually return the bits required for the specific lexer. Not sure if it works, though... testing... ;-)
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

Mmmmh... it seems to work with:

control->SetStyleBits(control->GetStyleBitsNeeded());

This seems more "generic"... dmoore: Mind giving it a try, too for more testing?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

dmoore

thanks for the update. i new there had to be an easy way to find the style bits...

does it work on your PHP lexer html file?
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

MortenMacFly

Quote from: dmoore on May 31, 2007, 01:37:07 PM
does it work on your PHP lexer html file?
Depends on what you mean by "work". I've attached a screenshot for PHP embedded in HTML using your enhanced html lexer file. Using a "pure" *.php file looks similar. Does that look OK? (I can't remember how it was before, unfortunately...).

[attachment deleted by admin]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

dmoore

#10
based on the screenshot seems to be working fine.

from my testing: control->SetStyleBits(control->GetStyleBitsNeeded()); appears to work as described

I've attached updated lexer_html.xml and lexer_php.xml files (plus the sample code files - maybe someone could update the html one to show an example of embedded script code).
*In the html lexer file I've added all the styles and keywords supported in SciTE including embedded html (keywords set 1 in C::B, 0 in the xml), jscript (2, 1), vbscript (3, 2), python (4, 3), and php(5, 4) )
*In the php lexer file I added the php tag style to color the "<?php" and "?>". I also made the php keywords index 4 in the xml entry (since that's what it is in the html lexer code, which I think php shares)

morten: do you want to do the patch/commit after some more testing?

thanks.

[attachment deleted by admin]
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

dmoore

Quote from: MortenMacFly on May 31, 2007, 01:49:35 PM
(I can't remember how it was before, unfortunately...).

previously all of the script code was shown with a blue squiggly underline and no coloring
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

rickg22

Quote from: raph on May 30, 2007, 08:11:16 PM
But why not use an existing exactly-for-php-made editor?
There are lots of out there (e.g. see here).

Regards
raph

EEW. Sincerely, the good ones are commercial or "free trial" (ugh). And the free ones suck.
Anyway, great job with the bug fixing, I'll try it tonight when I get home.

rickg22

A few days ago I had somehow managed to use code completion with PHP files, but I forgot how. I think I fooled CB into thinking PHP files were C++, and I was delighted to find my PHP functions and classes in the class pulldown menu.

There must be a way to modify the code completion plugin to accept other filetypes as parseable, what do you think?

rickg22

I closed CodeBlocks. I opened it again, and there it was! The function list! I wonder why in the previous run that function list didn't show up. It's a mystery...