Author Topic: Current status of PHP files support in Code::Blocks?  (Read 14069 times)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Current status of PHP files support in Code::Blocks?
« on: May 30, 2007, 07:07:31 pm »
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?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Current status of PHP files support in Code::Blocks?
« Reply #1 on: May 30, 2007, 07:26:35 pm »
To make it short: That's the current state of the activities:

(1) general discussion: http://forums.codeblocks.org/index.php/topic,4566.0.html
(2) latest discussion: http://forums.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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline raph

  • Almost regular
  • **
  • Posts: 242
Re: Current status of PHP files support in Code::Blocks?
« Reply #2 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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Current status of PHP files support in Code::Blocks?
« Reply #3 on: May 30, 2007, 08:51:58 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: Current status of PHP files support in Code::Blocks?
« Reply #4 on: May 30, 2007, 09:18:01 pm »
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

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Current status of PHP files support in Code::Blocks?
« Reply #5 on: May 31, 2007, 07:00:27 am »
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 +++)

Code
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]
« Last Edit: May 31, 2007, 07:02:28 am by dmoore »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Current status of PHP files support in Code::Blocks?
« Reply #6 on: May 31, 2007, 10:28:48 am »
Nice one! :D Seems to work for me, too.
Code
+++     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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Current status of PHP files support in Code::Blocks?
« Reply #7 on: May 31, 2007, 01:16:53 pm »
Mmmmh... it seems to work with:
Code
	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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Current status of PHP files support in Code::Blocks?
« Reply #8 on: May 31, 2007, 01:37:07 pm »
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?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Current status of PHP files support in Code::Blocks?
« Reply #9 on: May 31, 2007, 01:49:35 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Current status of PHP files support in Code::Blocks?
« Reply #10 on: May 31, 2007, 05:59:56 pm »
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]
« Last Edit: May 31, 2007, 07:05:23 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Current status of PHP files support in Code::Blocks?
« Reply #11 on: May 31, 2007, 06:01:32 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

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Current status of PHP files support in Code::Blocks?
« Reply #12 on: May 31, 2007, 06:27:31 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.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Code Completion for PHP?
« Reply #13 on: June 01, 2007, 05:47:19 pm »
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?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Hmm... I think I hit a bug or something.
« Reply #14 on: June 01, 2007, 05:54:51 pm »
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...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
After a while of experimenting...
« Reply #15 on: June 01, 2007, 07:12:51 pm »
I've come to the conclusion that the PHP lexers must be deleted. The HTML Lexer *ALREADY* supports PHP (who would've guessed?), and the PHP lexer can't fold contained html.

The only necessary thing is to add php extensions to the html lexer. I'll do it tonight.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Current status of PHP files support in Code::Blocks?
« Reply #16 on: June 01, 2007, 08:02:05 pm »
yes the warnings I read in the scintilla code to use the HTML lexer and not PHP lexer for PHP code should have been a giveaway :)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: After a while of experimenting...
« Reply #17 on: June 01, 2007, 08:04:54 pm »
I've come to the conclusion that the PHP lexers must be deleted. The HTML Lexer *ALREADY* supports PHP (who would've guessed?), and the PHP lexer can't fold contained html.
I guess this applies to the vbscript lexer then, too. Unless it's supposed to work with "plain" Visual Basic (VB, not VBS), too. Needs some testing, though...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ