I'm also having trouble understanding how the remarks work in each section
of the highlighter.
Thanks,
Jeff
Use google groups or google advanced group search (and
search the students group IIRC). There's a help file out
the somewhere that I think was authored by Pete Frazer
(spelling?).
~ JD
I've dug around on Google Groups and wasn't able to find much of anything
and most of the web results are in Russian.
I did a google advance group search and found it in less that
a minute (sorry that I didn't do that for you but I assumed
that you knew how):
http://groups.google.com/advanced_group_search
with all of the words: synedit help
Return only messages from the group at this location: borland.public.cppbuilder.students
which resulted in this link (and it's still valid!):
www.frasersoft.net/synedithelp.zip
(note that I did indeed spell the name wrong BUT i had the
right name! <g>).
~ JD
Thanks a lot for the great information on SynEdit, but my issues are with
UniHighlighter. It's a third-party component that provides custom syntax
highlighting to SynEdit. Has anyone had any luck working with the
UniHighlighter component?
> Thanks a lot for the great information on SynEdit, but my
> issues are with UniHighlighter. It's a third-party component
> that provides custom syntax highlighting to SynEdit. Has
> anyone had any luck working with the UniHighlighter
> component?
Have you tried contacting the component's author yet?
Gambit
> Has anyone had any success getting the UniHighlighter
> (http://www.delphist.com/UniHighlighter.html)
> component to work?
That version of UniHighligher hasn't been updated in 4 years. SynEdit is
still actively developed, so I doubt UniHighlighter has all of the latest
changes needed to work properly anymore.
I do notice that a slightly newer project was created for UniHighlighter on
SourceForge (http://sourceforge.net/projects/unihighlighter/) 3 years ago,
but it doesn't have any files on it.
Gambit
Yes, he says "Unfortunately, I do not support this project any more. I have
started it, but right now it is developing and supporting by other guys."
The website still lists him as the author
(http://www.delphist.com/About.html).
Do you perhaps know of a better way to have custom syntax highlighters?
> Do you perhaps know of a better way to
> have custom syntax highlighters?
I don't think there is any other way, other than to write your own set of
highlighter classes.
Gambit
> Has anyone used the SynGen application in order to build
> their own highlighter? I can't seem to figure out how to
> use the .pas file that's generated in my BCB6 project?
You should be able to just add it to the project, then compile the .pas file
to generate a .hpp file, then #include that file into your C++ code, then
instantiate the class at runtime, and assign it to the SynEdit component you
are using. Are you having a particular problem with that?
Gambit
I can add the SynHighlighterSample.pas file to my project and compile it and
it generates the hpp file, but when I include it I get error E2352 (Cannot
create instance of abstract class 'TSynSampleSyn') on line 1 below.
Here's the instantiation code:
//Instantiate the highlighter and assign it
1 TSynSampleSyn hlSample = new TSynSampleSyn;
2
3 SynEdit->Highlighter = hlSample;
4 SynEdit->ClearAll;
5 SynEdit->Text = hlSample->SampleSource;
> I can add the SynHighlighterSample.pas file to my project and
> compile it and it generates the hpp file, but when I include it
> I get error E2352 (Cannot create instance of abstract class
> 'TSynSampleSyn') on line 1 below.
The compiler tells you why it is abstract exactly.
> 1 TSynSampleSyn hlSample = new TSynSampleSyn;
I assume you meant to declare a pointer variable instead. Also, don't
forget that it is a component, so you have to pass an Owner parameter to the
constructor:
TSynSampleSyn *hlSample = new TSynSampleSyn(this);
Gambit
Here's what the compiler states:
Class 'TSynSampleSyn' is abstract because of '_fastcall
TSynCustomHighlighter::GetEol() = 0'
What does this mean?
> Here's what the compiler states:
> Class 'TSynSampleSyn' is abstract because of '_fastcall
> TSynCustomHighlighter::GetEol() = 0'
>
> What does this mean?
It means that the TSynCustomHighlighter class has an abstract method named
GetEol() that descendant classes must implement, but your TSynSampleSyn
class does not actually have an implementation for it.
Gambit
SynHighlighterSample.pas has an implementation for it:
function TSynSampleSyn.GetEol: Boolean;
begin
Result := fTokenID = tkNull;
end;
> SynHighlighterSample.pas has an implementation for it:
Then either your implementation's signature does not match the signature in
TSynCustomHighlighter, or your implementation does not include the
'override' specifier. Those are the only two ways an abstract method would
not be overriden correctly.
The exact signature of TSynCustomHighlighter is declared as follows:
function GetEol: Boolean; virtual; abstract;
The signature in your class must look like this:
function GetEol: Boolean; override;
Gambit
SynHighlighterSample.pas contains this signature:
function GetEol: Boolean; override;
Any thoughts? I've emailed the SynEdit group but haven't seen a response
yet.
> SynHighlighterSample.pas contains this signature:
>
> function GetEol: Boolean; override;
>
> Any thoughts?
What does it look like in your HPP file?
Gambit
I am using the syntax highlighting components that are part of the SynEdit
package without issue (i.e. TSynMultiSyn, TSynHTMLSyn, TSynVBScriptSyn,
TSynJScriptSyn, etc.)
Mark
I've used those as well and they work fine, I'm trying to build a custom
highlighter for a proprietary script format.
SynHighlighterSample.hpp:
// Borland C++ Builder
// Copyright (c) 1995, 2002 by Borland Software Corporation
// All rights reserved
// (DO NOT EDIT: machine generated header) 'SynHighlighterSample.pas' rev:
6.00
#ifndef SynHighlighterSampleHPP
#define SynHighlighterSampleHPP
#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <SynEditHighlighter.hpp> // Pascal unit
#include <SynEditTypes.hpp> // Pascal unit
#include <Graphics.hpp> // Pascal unit
#include <Controls.hpp> // Pascal unit
#include <Windows.hpp> // Pascal unit
#include <Classes.hpp> // Pascal unit
#include <SysUtils.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit
//-- user
supplied -----------------------------------------------------------
namespace Synhighlightersample
{
//-- type
declarations -------------------------------------------------------
#pragma option push -b-
enum TtkTokenKind { tkComment, tkIdentifier, tkKey, tkNull, tkSpace,
tkString, tkTest, tkUnknown };
#pragma option pop
#pragma option push -b-
enum TRangeState { rsUnKnown, rsBraceComment, rsCStyleComment, rsString };
#pragma option pop
typedef void __fastcall (__closure *TProcTableProc)(void);
typedef TtkTokenKind __fastcall (__closure *TIdentFuncTableFunc)(void);
typedef TIdentFuncTableFunc *PIdentFuncTableFunc;
class DELPHICLASS TSynSampleSyn;
class PASCALIMPLEMENTATION TSynSampleSyn : public
Synedithighlighter::TSynCustomHighlighter
{
typedef Synedithighlighter::TSynCustomHighlighter inherited;
private:
char *fLine;
int fLineNumber;
TProcTableProc fProcTable[256];
TRangeState fRange;
int Run;
int fStringLen;
char *fToIdent;
int fTokenPos;
TtkTokenKind fTokenID;
TIdentFuncTableFunc fIdentFuncTable[97];
Synedithighlighter::TSynHighlighterAttributes* fCommentAttri;
Synedithighlighter::TSynHighlighterAttributes* fIdentifierAttri;
Synedithighlighter::TSynHighlighterAttributes* fKeyAttri;
Synedithighlighter::TSynHighlighterAttributes* fSpaceAttri;
Synedithighlighter::TSynHighlighterAttributes* fStringAttri;
Synedithighlighter::TSynHighlighterAttributes* fTestAttri;
int __fastcall KeyHash(char * ToHash);
bool __fastcall KeyComp(const AnsiString aKey);
TtkTokenKind __fastcall Func52(void);
TtkTokenKind __fastcall Func72(void);
TtkTokenKind __fastcall Func96(void);
void __fastcall IdentProc(void);
void __fastcall UnknownProc(void);
TtkTokenKind __fastcall AltFunc(void);
void __fastcall InitIdent(void);
TtkTokenKind __fastcall IdentKind(char * MayBe);
void __fastcall MakeMethodTables(void);
void __fastcall NullProc(void);
void __fastcall SpaceProc(void);
void __fastcall CRProc(void);
void __fastcall LFProc(void);
void __fastcall BraceCommentOpenProc(void);
void __fastcall BraceCommentProc(void);
void __fastcall CStyleCommentOpenProc(void);
void __fastcall CStyleCommentProc(void);
void __fastcall StringOpenProc(void);
void __fastcall StringProc(void);
protected:
virtual Synedittypes::TSynIdentChars __fastcall GetIdentChars();
virtual AnsiString __fastcall GetSampleSource();
virtual bool __fastcall IsFilterStored(void);
public:
__fastcall virtual TSynSampleSyn(Classes::TComponent* AOwner);
/* virtual class method */ virtual AnsiString __fastcall
GetLanguageName(TMetaClass* vmt);
virtual void * __fastcall GetRange(void);
virtual void __fastcall ResetRange(void);
virtual void __fastcall SetRange(void * Value);
virtual Synedithighlighter::TSynHighlighterAttributes* __fastcall
GetDefaultAttribute(int Index);
virtual bool __fastcall GetEOL(void);
AnsiString __fastcall GetKeyWords();
TtkTokenKind __fastcall GetTokenID(void);
virtual void __fastcall SetLine(AnsiString NewValue, int LineNumber);
virtual AnsiString __fastcall GetToken();
virtual Synedithighlighter::TSynHighlighterAttributes* __fastcall
GetTokenAttribute(void);
virtual int __fastcall GetTokenKind(void);
virtual int __fastcall GetTokenPos(void);
virtual void __fastcall Next(void);
__published:
__property Synedithighlighter::TSynHighlighterAttributes* CommentAttri =
{read=fCommentAttri, write=fCommentAttri};
__property Synedithighlighter::TSynHighlighterAttributes* IdentifierAttri =
{read=fIdentifierAttri, write=fIdentifierAttri};
__property Synedithighlighter::TSynHighlighterAttributes* KeyAttri =
{read=fKeyAttri, write=fKeyAttri};
__property Synedithighlighter::TSynHighlighterAttributes* SpaceAttri =
{read=fSpaceAttri, write=fSpaceAttri};
__property Synedithighlighter::TSynHighlighterAttributes* StringAttri =
{read=fStringAttri, write=fStringAttri};
__property Synedithighlighter::TSynHighlighterAttributes* TestAttri =
{read=fTestAttri, write=fTestAttri};
public:
#pragma option push -w-inl
/* TSynCustomHighlighter.Destroy */ inline __fastcall virtual
~TSynSampleSyn(void) { }
#pragma option pop
};
//-- var, const,
procedure ---------------------------------------------------
static const Shortint MaxKey = 0x60;
} /* namespace Synhighlightersample */
using namespace Synhighlightersample;
#pragma option pop // -w-
#pragma option pop // -Vx
#pragma delphiheader end.
//-- end
unit ----------------------------------------------------------------
#endif // SynHighlighterSample
> virtual bool __fastcall GetEOL(void);
Look very carefully at that signaure. Now look at the signature in
SynEditHighligher.hpp:
virtual bool __fastcall GetEol(void) = 0 ;
Notice anything different? The compiler is looking for a method named
"GetEol" but your method is named "GetEOL" instead. C++ is case-sensitive.
Gambit
I made sure that both files SynEditHighlighter.hpp and
SynHighlighterSample.hpp both contain the same case: virtual bool __fastcall
GetEol(void); and I still get the same compilation error.
Any thoughts?
> I made sure that both files SynEditHighlighter.hpp and
> SynHighlighterSample.hpp both contain the same case:
> virtual bool __fastcall GetEol(void); and I still get the
> same compilation error.
You can't be getting the same error if they match exactly now.
Do keep in mind that your .hpp file may be getting regenerated each time you
compile the project, though. You have to make sure that the original .pas
file for your class is producing the proper .HPP code so that you don't have
to manually re-patch it each time.
Gambit