Discussion:
Counting fold-points only possible after scrolling - bug?
Charly Dante
2014-01-15 12:53:41 UTC
Permalink
*Sorry for the double post, I accidentaly deleted my original question*

Hi,

I have again a question about some scintilla behaviour. The thing is, I
want to count the number of fold-points (the plus/minus points which are
used to open or close a code-folding section) in the current Scintilla edit
control.

For this porpuse, I use the following function:

unsigned int getSciFoldCount(HWND sciHwnd)
{
unsigned int lineCount = SendMessage(sciHwnd, SCI_GETLINECOUNT, 0, 0);
unsigned int foldCounter = 0;

for (unsigned int i = 0; i < lineCount; i++)
{
if ((SendMessage(sciHwnd, SCI_GETFOLDLEVEL, i, 0) &
SC_FOLDLEVELHEADERFLAG) > 0)
{
if (SendMessage(sciHwnd, SCI_GETFOLDEXPANDED, i, 0) == 1)
foldCounter++;
}
}
return foldCounter;
}


This works and delivers the correct amount of fold-points of the document,
but *only if I first scrolled down to the bottom* of the edit control. If
the text of the edit-control is too long to fit in the visible area (so
that scrolling is required) and I don't scroll down one time, the function
above only counts the visible fold-points. If I once scrolled down, I can
scroll up again and the function will return the correct amount of
fold-points. However I want it to return the correct value regardless of
the users scrolling behaviour, even if he didn't scroll yet at all.

How is it possible to achieve this?

Best regards,
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-16 09:09:41 UTC
Permalink
This works and delivers the correct amount of fold-points of the document, but only if I first scrolled down to the bottom of the edit control. If the text of the edit-control is too long to fit in the visible area (so that scrolling is required) and I don't scroll down one time, the function above only counts the visible fold-points.
Lexing and folding are lazy and are not performed until the text becomes visible or the following API is called:
http://www.scintilla.org/ScintillaDoc.html#SCI_COLOURISE

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-16 17:43:17 UTC
Permalink
Great, with a SCI_COLORISE before the loop everything works fine.

Thanks again for the fast reply,
CD
Post by Charly Dante
This works and delivers the correct amount of fold-points of the document,
but *only if I first scrolled down to the bottom* of the edit control. If
the text of the edit-control is too long to fit in the visible area (so
that scrolling is required) and I don't scroll down one time, the function
above only counts the visible fold-points.
Lexing and folding are lazy and are not performed until the text
http://www.scintilla.org/ScintillaDoc.html#SCI_COLOURISE
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.
Continue reading on narkive:
Loading...