John Vella | 3 Jul 2012 05:20
Picon

How can I can overlay a "temporary" styling with what a lexer has already done?

I'm using the lexers that come with Scintilla(eg C++, Verilog, VHDL, etc). I have a need to "overlay" a style temporarily and when done with it I need the style that the lexer had applied to reappear. For example, say the C++ lexer applied style 10 for a range of text. I then create my own custom style and apply it to that same range of text(via SCI_SETSTYLING). How do I then remove my custom styling so the original style 10 will once again be used? 

A small code snippet would really help me out.

Thanks in advance,
-John

--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To view this discussion on the web visit https://groups.google.com/d/msg/scintilla-interest/-/AtN8HXzx2GQJ.
To post to this group, send email to scintilla-interest <at> googlegroups.com.
To unsubscribe from this group, send email to scintilla-interest+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scintilla-interest?hl=en.
Neil Hodgson | 3 Jul 2012 15:45

Re: How can I can overlay a "temporary" styling with what a lexer has already done?

John Vella:

I'm using the lexers that come with Scintilla(eg C++, Verilog, VHDL, etc). I have a need to "overlay" a style temporarily and when done with it I need the style that the lexer had applied to reappear.

   This is somewhat dangerous as lexers may assume they are the only writers to the document styles. For example they may seek backward to determine the start of some construct and use the styles to guide their way. For example, the Python lexer looks back for backslash continuations in string styles.

   An alternative for some cases is to use indicators although these can not change the styles appearance as much.

For example, say the C++ lexer applied style 10 for a range of text. I then create my own custom style and apply it to that same range of text(via SCI_SETSTYLING). How do I then remove my custom styling so the original style 10 will once again be used? 

   The safest way is to allow the lexer to restyle those characters by resetting the end of valid styling to the start of the line with the temporary styles with SCI_STARTSTYLING.

   Neil

--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To post to this group, send email to scintilla-interest <at> googlegroups.com.
To unsubscribe from this group, send email to scintilla-interest+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scintilla-interest?hl=en.
John Vella | 3 Jul 2012 15:49
Picon

Re: How can I can overlay a "temporary" styling with what a lexer has already done?

So what else do I need to call after SCI_STARTSTYLING? And also what would the mask value be?

Thanks,
-John


On Tue, Jul 3, 2012 at 6:45 AM, Neil Hodgson <nyamatongwe <at> me.com> wrote:
John Vella:

I'm using the lexers that come with Scintilla(eg C++, Verilog, VHDL, etc). I have a need to "overlay" a style temporarily and when done with it I need the style that the lexer had applied to reappear.

   This is somewhat dangerous as lexers may assume they are the only writers to the document styles. For example they may seek backward to determine the start of some construct and use the styles to guide their way. For example, the Python lexer looks back for backslash continuations in string styles.

   An alternative for some cases is to use indicators although these can not change the styles appearance as much.


For example, say the C++ lexer applied style 10 for a range of text. I then create my own custom style and apply it to that same range of text(via SCI_SETSTYLING). How do I then remove my custom styling so the original style 10 will once again be used? 

   The safest way is to allow the lexer to restyle those characters by resetting the end of valid styling to the start of the line with the temporary styles with SCI_STARTSTYLING.

   Neil

--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To post to this group, send email to scintilla-interest <at> googlegroups.com.
To unsubscribe from this group, send email to scintilla-interest+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scintilla-interest?hl=en.

--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To post to this group, send email to scintilla-interest <at> googlegroups.com.
To unsubscribe from this group, send email to scintilla-interest+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scintilla-interest?hl=en.
John Vella | 3 Jul 2012 18:16
Picon

Re: How can I can overlay a "temporary" styling with what a lexer has already done?

Neil, here's a little more info. I would like to create a set of styles which is independent from those used by the lexers(so they all have IDs > STYLE_MAX). The purpose of these styles would be for things like flagging "places of interest" within the text. I would like to assign these "auxiliary" styles to arbitrary ranges of text, overwriting temporarily what the lexer has assigned. Then when I remove the auxiliary style, I will need to have the lexer's style reapplied.

Could you tell me if what I want to do is even possible with Scintilla? I'm hoping "yes" and that I'm just missing some step I need to follow.

It seems not since the mask value in SCI_STARTSTYLING is documented to be only 8-bits, which would only cover the styles defined by lexers.

Thanks a lot for the help,
-John


On Tue, Jul 3, 2012 at 6:45 AM, Neil Hodgson <nyamatongwe <at> me.com> wrote:
John Vella:

I'm using the lexers that come with Scintilla(eg C++, Verilog, VHDL, etc). I have a need to "overlay" a style temporarily and when done with it I need the style that the lexer had applied to reappear.

   This is somewhat dangerous as lexers may assume they are the only writers to the document styles. For example they may seek backward to determine the start of some construct and use the styles to guide their way. For example, the Python lexer looks back for backslash continuations in string styles.

   An alternative for some cases is to use indicators although these can not change the styles appearance as much.


For example, say the C++ lexer applied style 10 for a range of text. I then create my own custom style and apply it to that same range of text(via SCI_SETSTYLING). How do I then remove my custom styling so the original style 10 will once again be used? 

   The safest way is to allow the lexer to restyle those characters by resetting the end of valid styling to the start of the line with the temporary styles with SCI_STARTSTYLING.

   Neil

--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To post to this group, send email to scintilla-interest <at> googlegroups.com.
To unsubscribe from this group, send email to scintilla-interest+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scintilla-interest?hl=en.

--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To post to this group, send email to scintilla-interest <at> googlegroups.com.
To unsubscribe from this group, send email to scintilla-interest+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scintilla-interest?hl=en.
Neil Hodgson | 4 Jul 2012 00:41

Re: How can I can overlay a "temporary" styling with what a lexer has already done?

John Vella:

Neil, here's a little more info. I would like to create a set of styles which is independent from those used by the lexers(so they all have IDs > STYLE_MAX).

   The styling information is only 8-bits wide. It is not possible to use IDs > STYLE_MAX for document styles.

Could you tell me if what I want to do is even possible with Scintilla? I'm hoping "yes" and that I'm just missing some step I need to follow.

   This is not supported by Scintilla currently.

   Neil

--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To post to this group, send email to scintilla-interest <at> googlegroups.com.
To unsubscribe from this group, send email to scintilla-interest+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scintilla-interest?hl=en.
Dave Brotherstone | 4 Jul 2012 07:53
Picon
Favicon

Re: How can I can overlay a "temporary" styling with what a lexer has already done?



On Tue, Jul 3, 2012 at 6:16 PM, John Vella <jvella23 <at> gmail.com> wrote:
Neil, here's a little more info. I would like to create a set of styles which is independent from those used by the lexers(so they all have IDs > STYLE_MAX). The purpose of these styles would be for things like flagging "places of interest" within the text. I would like to assign these "auxiliary" styles to arbitrary ranges of text, overwriting temporarily what the lexer has assigned. Then when I remove the auxiliary style, I will need to have the lexer's style reapplied.

Could you tell me if what I want to do is even possible with Scintilla? I'm hoping "yes" and that I'm just missing some step I need to follow.



Although as Neil says, you can't really do this with lexer styles, you should look at indicators - http://www.scintilla.org/ScintillaDoc.html#Indicators
It sounds like that will do what you need, even though the implementation is different to what you describe, and doesn't allow as much flexibility as with styles.

Cheers,
Dave.

--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To post to this group, send email to scintilla-interest <at> googlegroups.com.
To unsubscribe from this group, send email to scintilla-interest+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scintilla-interest?hl=en.

Gmane