Discussion:
SCI_GETSTYLEAT is making problems at end of file
Charly Dante
2014-01-25 13:45:17 UTC
Permalink
Hi,

I have a question regarding the SCI_GETSTYLEAT message in scintilla. I need
this message because I don't wan't to show the autocomplete list inside of
strings or comments. It is working fine, however at the end of the document
it doesn't work as I expect it.

If I have the following code in myx scintilla control:

void myfunction()
{
string s = "

The caret is now at the very last position in the document, namely after
the " char. If I now use SCI_GETSTYLEAT from the current position, it
returns the default value as if there would be normal text - but as the
string isn't closed yet, the last position should be also marked as string,
otherwise my method will bug at the end of the document.

Its also not possible to look at the second last char, because even if it
is a " char, its not possible to say whether it is the string opening char
or the string closing char.

Is it possible to tell Scintilla to detect the style at the end correctly?
Btw, I'm using the standard LUA lexer, if this is important.

Best,
CD
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2014-01-25 22:04:12 UTC
Permalink
The caret is now at the very last position in the document, namely after the " char. If I now use SCI_GETSTYLEAT from the current position, it returns the default value as if there would be normal text - but as the string isn't closed yet, the last position should be also marked as string, otherwise my method will bug at the end of the document.
Style data is only generated for the document and there is no style data after the end of the document.

Simplify your example to the 3 characters
s="
The style data is [11,10,12] which is [IDENTIFIER, OPERATOR, STRINGEOL].

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Charly Dante
2014-01-25 22:18:45 UTC
Permalink
Hi,

the thing is that its not only STRINGEOL which causes problems here. The
same happens with, for example BlockComments. If I have the following code
for example:

s=/**/

and I am at the end of the document, then I wont be able to detect whether
the current position is inside a Block-Comment or not, because it always
returns zero. But I don't want to show the AutoComplete List inside of
Comments, so I need to detect it.

Of course I could just look back one position more, but that wont work
neither in all cases because it could be something like this:

s=/*comment*/

or

s=/*comment

and so on. So I would basically have to iterate backwards over the text and
perfrom reverse lexing just to determine whether the very last position in
the document will also be a comment or a default identifier.

What I would need is just something that tells me whether the last style of
the document is "closed" and will be followed by the default style or not.
Otherwise the Autocomplete List will behave different at the end of the
document :(
Post by Charly Dante
Post by Charly Dante
The caret is now at the very last position in the document, namely after
the " char. If I now use SCI_GETSTYLEAT from the current position, it
returns the default value as if there would be normal text - but as the
string isn't closed yet, the last position should be also marked as string,
otherwise my method will bug at the end of the document.
Style data is only generated for the document and there is no style
data after the end of the document.
Simplify your example to the 3 characters
s="
The style data is [11,10,12] which is [IDENTIFIER, OPERATOR, STRINGEOL].
Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...