Hi,
Le 28/04/2013 13:50, RaptorX a �crit :
> First of all you are aware that the text inside the parenthesis will
> have a lexical state (string block) but that lexical state should be
> able to exit to another state (comments, escape secuences) based on
> options set at the beginning of the block right?
>
> that means that after the options each new line should be able to "know"
> which options are set and "inherit" those options until the closing
> parenthesis arrives, after that those options have no meaning... I have
> been able to do that without issues. My problem comes when I am out of
> that block and then try to add a new line to an existing block, all
> option information for that block is lost which is not intended, hence
> my question about marking arbitrary information to a line.
>
> So let me see if I understood correctly...
>
> I should attach the line state to the options line, would i have to do
> that manually for each new line until the parenthesis close? or will it
> end only when i set a new linestate?
You will have to set the line state on every line you want it to be,
it's not automatically copied to next lines.
> what would the difference be when the Lexer reads a whole file and sets
> everything up in one go and when the user is typing and going back and
> forth between lines
If your lexing function gets called with a startPos not on the first
line, you should fetch the previous line state, otherwise you know
you're (re-)lexing everything anyway:
state = sc.currentLine > 0 ? styler.GetLineState(sc.currentLine - 1) : 0
So you should set the state on each line affected by the options (the
options line and each one in the block).
> (I think the Lex function is restarted and all
> LineState information is lost, am I right?)
No, only the part that was invalidated (e.g. has to be re-styled) lost
everything; the part before still has full style and line state.
I suggest you to take a look at the PO lexer (LexPO.cxx). It is fairly
simple and uses line states.
Regards,
Colomban