Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
indent/unindent plugin
danselmi:
Hi
Do you really think it is too specific to be able to implement indent for an additional
language in a plugin? So you do not have to change the core for every
language someone wants to use?
Should I send a patch for the indent of the two HD languages?
Daniel
dje:
--- Quote from: danselmi on June 09, 2008, 02:12:10 pm ---Do you really think it is too specific to be able to implement indent for an additional
language in a plugin?
--- End quote ---
No, you can do whatever you want in a plugin, I said it is too specific to be implemented in the core.
--- Quote from: danselmi on June 09, 2008, 02:12:10 pm ---Should I send a patch for the indent of the two HD languages?
--- End quote ---
You can, but I am a plugin developer and I don't take any decision concerning the core or patches.
When you tell
--- Quote ---extend the plugin architecture
--- End quote ---
, do you mean a change in the API (what I understood) or to propose a new plugin ?
Dje
danselmi:
Hi
As you mentioned in your first answer:
--- Quote ---With current plugin architecture, you can add items to menu, contextual menu and editors.
I don't understand why you could succeed in implementing a plugin that match your need.
--- End quote ---
And in the previous post:
--- Quote ---No, you can do whatever you want in a plugin,...
--- End quote ---
How is it possible to implement indent/unindent in a plugin? Isn't it needed to extend the plugin
architecture (I mean a change in the API) to be able to do this?
Daniel
dje:
I don't remember in details the API of the editor, check the events you can register in C::B source code.
Maybe the one you need already exist.
Otherwise, you may trigger editor open event to play with its dynamic event table, but it begins beeing a little tricky.
Do you know AStyle plugin ?
It is a plugin that only does indentation, but it works on files, not on open editors.
It is also the most simple way to work, unless you just add a menu entry with the appropriate shortcut to indent when you want.
I think it would be better to tell exactly what you need, you won't get help with
--- Quote ---How is it possible to implement indent/unindent in a plugin?
--- End quote ---
or
--- Quote ---Isn't it needed to extend the plugin
architecture (I mean a change in the API) to be able to do this?
--- End quote ---
With those quotes, I guess you need something but I can't figure out what :shock:
Dje
danselmi:
Hi
Thanks for your patience!
I'd like to do auto indent/unindent for another language (VHDL and
Verilog in addition to c/c++, which is implemented in the core).
indent:
* check if the user entered a '\n' (OnCharAdded)
* check the last non comment word/character
* if the last word is a "begin" (example for Verilog) indent the new line
unindent:
* If the added character was not a '\n'
* check if the current line contains only "end" and spaces
* search the corresponding "begin"
* indent the current line to the same value as the line containing the "begin"
This is near the same mechanism as for C/C++, only the '{' is replaced with "begin"
and the '}' is replaced with "end". For VHDL it is a bit more complicated because we
have to check for more different words/characters but basically it remains
the same mechanism.
As you could see in my first post, I have implemented these things (and the
mechanism which replaces ,, .. ;; with <= => := if they get typed fast enough) in the core.
Now i'd like to share this work (and do some more if needed) with other people.
Because VHDL and Verilog are not that widely used i think it is not realistic to get
these changes in the core.
If I have to implement these features in a plugin, I am not sure which event to
register to cbEVT_EDITOR_MODIFIED? And will this be fast enough?
Daniel
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version