添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have installed DScintilla , Delphi VCL wrapper for Scintilla code editing component, but I can't find any basic example of how to use it.

Could you post some basic code example of syntax highlighting or a reference to code examples for it ?

Very interesting library but hard to say what exactly want you do with it. Here for instance is the example with some basic color settings for Pascal syntax highlighter. Note that you need to have the SciLexer.dll library in your project folder (or the one where the application looks for it).

This library wrapper provides many features with meaningful names so the best I think would be to browse them by your own.

DScintillaTypes, DScintilla; procedure TForm1.Button1Click(Sender: TObject); Scintilla: TDScintilla; begin Scintilla := TDScintilla.Create(Self); // creating it dynamically, it's also available as a component, so you don't need to do this Scintilla.DllModule := 'SciLexer.dll'; // the syntax library Scintilla.Align := alClient; // object alignment to the whole parent Scintilla.Parent := Self; // setting up the parent Scintilla.SetLexer(SCLEX_PASCAL); // and setting the syntax highlighter, see SCLEX_ types in DScintillaTypes.pas Scintilla.StyleSetBack(STYLE_DEFAULT, clBlack); // setting up the default background color Scintilla.StyleSetFore(SCE_PAS_DEFAULT, clWhite); // Pascal specific default fore color Scintilla.StyleSetBack(SCE_PAS_DEFAULT, clBlack); // Pascal specific default back color Scintilla.StyleSetFore(SCE_PAS_IDENTIFIER, clYellow); // Pascal specific identifier fore color Scintilla.StyleSetBack(SCE_PAS_IDENTIFIER, clBlack); // Pascal specific identifier back color Scintilla.StyleSetBold(SCE_PAS_IDENTIFIER, True); // Pascal specific identifier bold font style Scintilla.StyleSetUnderline(SCE_PAS_IDENTIFIER, True); // Pascal specific identifier underline font style Scintilla.StyleSetFore(SCE_PAS_COMMENT, RGB(243, 236, 255)); // etc. Scintilla.StyleSetBack(SCE_PAS_COMMENT, clBlack); Scintilla.StyleSetFore(SCE_PAS_COMMENT2, RGB(243, 236, 255)); Scintilla.StyleSetBack(SCE_PAS_COMMENT2, clBlack); Scintilla.StyleSetFore(SCE_PAS_COMMENTLINE, RGB(243, 236, 255)); Scintilla.StyleSetBack(SCE_PAS_COMMENTLINE, clBlack); Scintilla.StyleSetFore(SCE_PAS_NUMBER, RGB(243, 236, 255)); Scintilla.StyleSetBack(SCE_PAS_NUMBER, clBlack); Scintilla.StyleSetFore(SCE_PAS_HEXNUMBER, RGB(243, 236, 255)); Scintilla.StyleSetBack(SCE_PAS_HEXNUMBER, clBlack); Scintilla.StyleSetFore(SCE_PAS_WORD, RGB(243, 236, 255)); Scintilla.StyleSetBack(SCE_PAS_WORD, clBlack); Scintilla.StyleSetFore(SCE_PAS_STRING, RGB(243, 236, 255)); Scintilla.StyleSetBack(SCE_PAS_STRING, clBlack); Scintilla.StyleSetFore(SCE_PAS_STRINGEOL, RGB(243, 236, 255)); Scintilla.StyleSetBack(SCE_PAS_STRINGEOL, clBlack); Scintilla.StyleSetFore(SCE_PAS_CHARACTER, RGB(243, 236, 255)); Scintilla.StyleSetBack(SCE_PAS_CHARACTER, clBlack); Scintilla.StyleSetFore(SCE_PAS_OPERATOR, clRed); Scintilla.StyleSetBack(SCE_PAS_OPERATOR, clBlack); Scintilla.StyleSetFore(SCE_PAS_ASM, clRed); Scintilla.StyleSetBack(SCE_PAS_ASM, clBlack);

I never did that, but seems that you have to set the lexer and then send the keywords via the SCI_SETKEYWORDS message (it's just a string chain separated with a single space).

Here is an example in C++:

http://tortoisesvn.googlecode.com/svn/trunk/src/TortoiseBlame/Lexer.cpp

I see that dScintilla has that wrapped in TDScintilla.SetKeyWords(), so I guess it should work the same way.

In any case I agree that it will be very helpful to find a more complete demo on how to use DScintilla.

+1 for the cpp example link, i had two good answers, but unfortunately only one can be accepted. Thanks beerwin Oct 19, 2011 at 8:58

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .