无法在Scintilla中使折叠工作

时间:2017-10-22 17:18:12

标签: c++ text-editor scintilla

您好我正在关注scintilla文档,但我不能让scintilla折叠与任何词法分析器一起工作,obviosuly我做错了但我无法看到哪里。我尝试了不同的组合,但似乎什么都没有用,那么我有发现一些代码并适应我的需求,一切正常但折叠,这里是我用来初始scintilla的代码链接:

void CScintillaWnd::Init() {
SendMessage(SCI_SETLEXER, SCLEX_HTML, 0);
// clear all text styles
SendMessage(SCI_CLEARDOCUMENTSTYLE, 0, 0);
// set the number of styling bits to 7 - the asp/html views need a lot of styling - default is 5
// If you leave the default you will see twiggle lines instead of ASP code
// set the display for indetation guides to on - this displays virtical dotted lines from the beginning of 
// a code block to the end of the block
SendMessage(SCI_SETINDENTATIONGUIDES, TRUE, 0);
// set tabwidth to 3
SendMessage(SCI_SETTABWIDTH, 3, 0);
// set indention to 3
SendMessage(SCI_SETINDENT, 3, 0);
// set the caret blinking time to 400 milliseconds
SendMessage(SCI_SETCARETPERIOD, 400, 0);
// source folding section
// tell the lexer that we want folding information - the lexer supplies "folding levels"
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("fold"), (LPARAM)_T("1"));
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("fold.html"), (LPARAM)_T("1"));
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("fold.html.preprocessor"), (LPARAM)_T("1"));
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("fold.comment"), (LPARAM)_T("1"));
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("fold.at.else"), (LPARAM)_T("1"));
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("fold.flags"), (LPARAM)_T("1"));
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("fold.preprocessor"), (LPARAM)_T("1"));
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("styling.within.preprocessor"), (LPARAM)_T("1"));
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("asp.default.language"), (LPARAM)_T("1"));
// Tell scintilla to draw folding lines UNDER the folded line
SendMessage(SCI_SETFOLDFLAGS, 16, 0);
// Set margin 2 = folding margin to display folding symbols
SendMessage(SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS);
// allow notifications for folding actions
SendMessage(SCI_SETMODEVENTMASK, SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT, 0);
//   SendMessage(SCI_SETMODEVENTMASK, SC_MOD_CHANGEFOLD|SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT, 0);
// make the folding margin sensitive to folding events = if you click into the margin you get a notification event
SendMessage(SCI_SETMARGINSENSITIVEN, 2, TRUE);
// define a set of markers to displa folding symbols
SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS);
SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDER, SC_MARK_PLUS);
SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY);
SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY);
SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY);
SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY);
SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY);
// set the forground color for some styles
SendMessage(SCI_STYLESETFORE, 0, RGB(0, 0, 0));
SendMessage(SCI_STYLESETFORE, 2, RGB(0, 64, 0));
SendMessage(SCI_STYLESETFORE, 5, RGB(0, 0, 255));
SendMessage(SCI_STYLESETFORE, 6, RGB(200, 20, 0));
SendMessage(SCI_STYLESETFORE, 9, RGB(0, 0, 255));
SendMessage(SCI_STYLESETFORE, 10, RGB(255, 0, 64));
SendMessage(SCI_STYLESETFORE, 11, RGB(0, 0, 0));
// set the backgroundcolor of brace highlights
SendMessage(SCI_STYLESETBACK, STYLE_BRACELIGHT, RGB(0, 255, 0));
// set end of line mode to CRLF
SendMessage(SCI_CONVERTEOLS, 2, 0);
SendMessage(SCI_SETEOLMODE, 2, 0);
//   SendMessage(SCI_SETVIEWEOL, TRUE, 0);
// set markersymbol for marker type 0 - bookmark
SendMessage(SCI_MARKERDEFINE, 0, SC_MARK_CIRCLE);
// display all margins
SetDisplayLinenumbers(TRUE);
SetDisplayFolding(TRUE);
SetDisplaySelection(TRUE);}

感谢您的帮助

0 个答案:

没有答案