2011-10-18 20 views

Respuesta

4

Biblioteca muy interesante, pero difícil decir qué es exactamente lo que quieres que hagas con ella. Aquí, por ejemplo, está el ejemplo con algunas configuraciones de color básicas para el resaltador de sintaxis Pascal. Tenga en cuenta que necesita tener la biblioteca SciLexer.dll en su carpeta de proyecto (o la que la busca).

Este envoltorio de biblioteca proporciona muchas características con nombres significativos, así que lo mejor que creo es que las explore por su cuenta.

uses 
    DScintillaTypes, DScintilla; 

procedure TForm1.Button1Click(Sender: TObject); 
var 
    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); 
end; 
3

Nunca hice eso, pero parece que tienes que configurar el lexer y luego enviar las palabras clave a través del mensaje SCI_SETKEYWORDS (es solo una cadena de cadenas separada con un solo espacio).

Aquí se muestra un ejemplo en C++:

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

veo que tiene que dScintilla envuelto en TDScintilla.SetKeyWords(), así que supongo que debería funcionar de la misma manera.

En cualquier caso, estoy de acuerdo en que será muy útil encontrar una demostración más completa sobre cómo usar DScintilla.

+1

+1 para el enlace de ejemplo cpp, tuve dos buenas respuestas, pero desafortunadamente solo una puede ser aceptada. Gracias – beerwin

Cuestiones relacionadas