Discussion:
Folding feature doesn't work
Fan Yang
2013-08-04 12:12:33 UTC
Permalink
Hi list,

I ever use the native Win32 version before, it worked pretty well. But now
I'm use the official Qt port of scintilla.

I created a margin to display the folder symbols, then set the attributes
like:
sci->setFoldFlags(SC_FOLDFLAG_LINEAFTER_CONTRACTED );

sci->markerDefine(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS);
sci->markerDefine(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS);
sci->markerDefine(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE);
sci->markerDefine(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER);
sci->markerDefine(SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED);
sci->markerDefine(SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED);
sci->markerDefine(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER);

sci->markerSetFore(SC_MARKNUM_FOLDEROPEN, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDEROPEN, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDER, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDER, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDERSUB, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDERSUB, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDERTAIL, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDERTAIL, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDEREND, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDEREND, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDEROPENMID, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDEROPENMID, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDERMIDTAIL, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDERMIDTAIL, 0x808080);
sci->setProperty( "fold", "1");
sci->setProperty( "fold.flags", "16");
sci->setProperty( "fold.symbols", "1");
sci->setProperty( "fold.compact", "0");
sci->setProperty( "fold.at.else", "1");
sci->setProperty( "fold.preprocessor", "1");
sci->setProperty( "fold.view", "1");
sci->setProperty( "fold.comment", "1");
sci->setProperty( "fold.html", "1");
sci->setProperty( "fold.comment.python", "1");
sci->setProperty( "fold.quotes.python", "1");


When I open a C++ source file eg file.cxx, I set the lexer like:
sci->setLexerLanguage("cpp");

I think after this method call, the Scintilla control should know how to
mark the folding level of every line correctly,
but actually I find every line's folding level is the same which is known
as the default initial value 1024. So the folding
feature doesn't work totally.

Did I miss something important? Any suggestion would be appreciated.
--
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.
Matthew Brush
2013-08-04 21:08:19 UTC
Permalink
Post by Fan Yang
Hi list,
I ever use the native Win32 version before, it worked pretty well. But now
I'm use the official Qt port of scintilla.
I created a margin to display the folder symbols, then set the attributes
sci->setFoldFlags(SC_FOLDFLAG_LINEAFTER_CONTRACTED );
sci->markerDefine(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS);
sci->markerDefine(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS);
sci->markerDefine(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE);
sci->markerDefine(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER);
sci->markerDefine(SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED);
sci->markerDefine(SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED);
sci->markerDefine(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER);
sci->markerSetFore(SC_MARKNUM_FOLDEROPEN, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDEROPEN, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDER, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDER, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDERSUB, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDERSUB, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDERTAIL, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDERTAIL, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDEREND, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDEREND, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDEROPENMID, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDEROPENMID, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDERMIDTAIL, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDERMIDTAIL, 0x808080);
sci->setProperty( "fold", "1");
sci->setProperty( "fold.flags", "16");
sci->setProperty( "fold.symbols", "1");
sci->setProperty( "fold.compact", "0");
sci->setProperty( "fold.at.else", "1");
sci->setProperty( "fold.preprocessor", "1");
sci->setProperty( "fold.view", "1");
sci->setProperty( "fold.comment", "1");
sci->setProperty( "fold.html", "1");
sci->setProperty( "fold.comment.python", "1");
sci->setProperty( "fold.quotes.python", "1");
sci->setLexerLanguage("cpp");
I think after this method call, the Scintilla control should know how to
mark the folding level of every line correctly,
but actually I find every line's folding level is the same which is known
as the default initial value 1024. So the folding
feature doesn't work totally.
Did I miss something important? Any suggestion would be appreciated.
Maybe SCI_SETMARGINTYPEN and SCI_SETMARGINMASKN (amongst other missing
things). I just added folding to my Qt ScintillaEditBase subclass no
problems by following the instructions here (linked from official
Scintilla docs):

http://sphere.sourceforge.net/flik/docs/scintilla-folding.html

Cheers,
Matthew Brush
--
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.
Fan Yang
2013-08-06 01:09:40 UTC
Permalink
Thanks Matthew.
Finally, I found the root cause. It was caused by the "fold" property, once
the new lexer is set, I should set the "fold" property to be "1", that
works fine.
Post by Fan Yang
Post by Fan Yang
Hi list,
I ever use the native Win32 version before, it worked pretty well. But
now
Post by Fan Yang
I'm use the official Qt port of scintilla.
I created a margin to display the folder symbols, then set the
attributes
Post by Fan Yang
sci->setFoldFlags(SC_FOLDFLAG_LINEAFTER_CONTRACTED );
sci->markerDefine(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS);
sci->markerDefine(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS);
sci->markerDefine(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE);
sci->markerDefine(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER);
sci->markerDefine(SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED);
sci->markerDefine(SC_MARKNUM_FOLDEROPENMID,
SC_MARK_BOXMINUSCONNECTED);
Post by Fan Yang
sci->markerDefine(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER);
sci->markerSetFore(SC_MARKNUM_FOLDEROPEN, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDEROPEN, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDER, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDER, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDERSUB, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDERSUB, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDERTAIL, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDERTAIL, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDEREND, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDEREND, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDEROPENMID, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDEROPENMID, 0x808080);
sci->markerSetFore(SC_MARKNUM_FOLDERMIDTAIL, 0xFFFFFF);
sci->markerSetBack(SC_MARKNUM_FOLDERMIDTAIL, 0x808080);
sci->setProperty( "fold", "1");
sci->setProperty( "fold.flags", "16");
sci->setProperty( "fold.symbols", "1");
sci->setProperty( "fold.compact", "0");
sci->setProperty( "fold.at.else", "1");
sci->setProperty( "fold.preprocessor", "1");
sci->setProperty( "fold.view", "1");
sci->setProperty( "fold.comment", "1");
sci->setProperty( "fold.html", "1");
sci->setProperty( "fold.comment.python", "1");
sci->setProperty( "fold.quotes.python", "1");
sci->setLexerLanguage("cpp");
I think after this method call, the Scintilla control should know how to
mark the folding level of every line correctly,
but actually I find every line's folding level is the same which is
known
Post by Fan Yang
as the default initial value 1024. So the folding
feature doesn't work totally.
Did I miss something important? Any suggestion would be appreciated.
Maybe SCI_SETMARGINTYPEN and SCI_SETMARGINMASKN (amongst other missing
things). I just added folding to my Qt ScintillaEditBase subclass no
problems by following the instructions here (linked from official
http://sphere.sourceforge.net/flik/docs/scintilla-folding.html
Cheers,
Matthew Brush
--
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...