Recent

Author Topic: SynEdit for PHP  (Read 7373 times)

M[a]nny

  • Full Member
  • ***
  • Posts: 130
  • Dreamer
SynEdit for PHP
« on: November 18, 2010, 07:37:31 am »
Hi all,

I really love SynEdit in Lazarus, it works perfectly and for me it is the best syntax editor I have ever seen in my life. Beacause I code in PHP, too, I'd like to know if there is any way to make PHP editor (only for syntax without full support of IDE - like checking syntax errors etc) with this component with all features in Lazarus's SynEdit.

Thanks for responses.
Bad news: Time flies.
Good news: You are the pilot.

Don't try to be perfect, just be unique.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit for PHP
« Reply #1 on: November 18, 2010, 09:49:28 am »
Well, yes, but it depends what exctly you expect...

SynEdit is available on the component palette, and so is a php-highlighter for SynEdit.

So drop those 2 on a new Form, add a main menu, write code to load, save, to call a printer....
So there is the first bit of work you will have to do yourself.

Then what do you get?
1) If you edited pascal in the IDE, and now go for php you'll note some differences (if you used the IDE for php already the you know.
The difference is in the quality of highlighting, obviously most of the work went into the pascal highlighter.

And SynEdit only has folding for pascal, lfm, diff, html, and xml.

2) The functionality you get in the IDE comes from three different sources:
- SynEdit
- SourceEditor
- IDE/Codetools

If you need more than just SynEdit, you need to dive into code, since SourcEditor is not a component, you could just drop on your code (together with the IDE, it handles the notebook/pages, windows, search/replace dialogs (actual search is in synedit), ....)

All of SourceEditor and IDE is GPL so you can use it, if you whish. It's not LGPL though, but SynEdit is GPL (or MPL at your choice) too.


M[a]nny

  • Full Member
  • ***
  • Posts: 130
  • Dreamer
Re: SynEdit for PHP
« Reply #2 on: November 18, 2010, 12:45:45 pm »
Thanks for reply, Martin. I don't expect so much. My requirements are:
  • Ctrl+Space for possible commands like in Lazarus
  • if you select some text in Lazarus Code Editor, there is shown small pencil icon on the left side. If you click it, it switches to replacement mode - i'd like to have it too
  • As you said, I'd like to use search

That's all. Is it possible to make? Or is it really hard? I don't know if my experiences are enough for this but I really love this component - it's excelent :-)
Bad news: Time flies.
Good news: You are the pilot.

Don't try to be perfect, just be unique.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit for PHP
« Reply #3 on: November 18, 2010, 01:03:47 pm »
* ctrl-space:
Have a look in the example folder. how auto-completion works. The drop down is part of synedit, but must be created in code. (You can also look in SourceEditor, for how it is used)
In the IDE the list of possible values is calculated for pascal, by codetools. So you need your own provider for the content of the dropdown.

* Syncro-edit (select / replacement mode)
Part of synEdit, again must be created in code.
Have a look at the file ide/SourceSynEdit.pp, It shows how to add the correct module to SynEdit. (search "syncro")

* search
You need to provide a user interface. e.g a dialog that asks what to search.
Once you have sometyhing to search/replace call
  SynEdit.SearchReplaceEx
Example in ide/SourceEditor

M[a]nny

  • Full Member
  • ***
  • Posts: 130
  • Dreamer
Re: SynEdit for PHP
« Reply #4 on: November 18, 2010, 01:21:48 pm »
Thank you very much for explanation, although it is beyond my power :D I can make search function at least but it is all I can do. Thanks anyway for your time.
Bad news: Time flies.
Good news: You are the pilot.

Don't try to be perfect, just be unique.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit for PHP
« Reply #5 on: November 18, 2010, 01:48:01 pm »
It is behind your power, to open a source file, and copy two lines of code?

syncro edit:
  uses SynPluginSyncroEdit;
  TSynPluginSyncroEdit.Create(TheSynEdit);

it's destroyed by synedit, so no worries there...

--
completion:

yes there are a few more lines to copy => but the example has all you need for a hardcoded list of words.

Write some code to scan the entire file, and create a unique list of words. Should not be that hard...

--
btw, 2 synedits, editing one file together
  SynEdit1.ShareTextBufferFrom(SynEdit2);


 

TinyPortal © 2005-2018