Mega Code Archive

 
Categories / Delphi / Examples
 

Use a Syntax Highlighter

Title: use a Syntax Highlighter? * Question: I want to create my own highlighter rising from Pascal (C++,...) How can I highlight keywords? * Answer: Have a look at the SynEdit component at Synedit.Sourceforge SynEdit is a multi-line edit control, for Borland Delphi and C++Builder. SynEdit is packaged together with highlighter classes which are used to syntax highlight many programming languages source code such as: C++, Fortran, Java, Pascal, Visual Basic, Cascading Style Sheets, HTML, JavaScript, PHP (Apache), VBScript, Perl, TCL/Tk, SQL, x86 Assembler, Inno Setup Scripts, Python etc. (currently over 30 languages) There's also a demo that shows you how to create your own highlighter using a grammar file and the SynGen utility. * Some further Features: TSynExporterHTML: Allows you to export a Code to HTML. TSynExporterRTF: Allows you to export a Code to RTF. TSynCompletionProposal: Code Completion TSynMultiSyn: Allows you to syntax highlight documents with many highlighters based on schemes that you define. (HTML documents with Cascading Style Sheets and JavaScript) TSynMacroRecorder: Record Macros TSynEditPrint: Print Control TSynEditPrintPreview: Print preview {*******************************************************} * Frage: Ich mchte einen eigenen Syntax Highligter schreiben, um bestimmte Schlsselwrter hervorzuheben (Z.B so wie in der Delphi-IDE) Wie kann ich das realisieren? * Antwort: Es gibt eine Komponente TSynEdit um fr einen Quelltext Syntaxhervorhebung zu realisieren. Die TSynEdit Komponente findet man hier: Synedit.Sourceforge und ist sowohl fr Delphi als auch fr den C++Builder. Das SynEdit Package enthlt viele verschiedene Syntaxhighlighter. Z.B fr C++, Fortran, Java, Pascal, Visual Basic, Cascading Style Sheets, HTML, JavaScript, PHP (Apache), VBScript, Perl, TCL/Tk, SQL, x86 Assembler, Inno Setup Scripts, Python usw. (momentan ber 30 Sprachen) Es besteht auch die Mglichkeit fr seine eigene Script-Sprache Syntaxhervorhebung zu realisieren. * Einige weitere Mglichkeiten des SynEdit Packages: TSynExporterHTML: Damit kann man einen Quelltext in ein HTML Format exportieren TSynExporterRTF: Damit kann man einen Quelltext in ein RTF Format exportieren TSynCompletionProposal: Ermglicht Code Vervollstndigung TSynMultiSyn: Damit kann man mehrere Sprachen in einem SynEdit highlighten. (Z.B HTML Dokumente mit JavaScript usw.) TSynMacroRecorder: Damit kann man Makros auzeichnen TSynEditPrint: Drucker Kontrolle TSynEditPrintPreview: Ermglicht eine Druck-Vorschau