Hello. It has long been written on Delphi, and decided to warm up a little ... And the very first thing that occurred to me was to write a text editor. But I decided to complicate my goal a bit, to add the highlight of my native Pascal to this editor. SynEdit (SynMemo) and SynPasSyn came to the rescue. Well, in order to get a better look at SynEdit, I decided to use demos, namely HighlighterDemo.
This demo presents a component (TSynCustomHighlighter) with its own highlighting of the words hello , synEdit and world :
TSynSampleSyn = class(TSynCustomHighlighter) private fRange: TRangeState; fTokenID: TtkTokenKind; fIdentFuncTable: array[0..3] of TIdentFuncTableFunc; ... KeyWords: array[0..3] of UnicodeString = ( 'hello', 'synedit', 'world', 'highlighter' ); KeyIndices: array[0..3] of Integer = ( 0, 2, 1, 3 ); procedure TSynSampleSyn.InitIdent; var i: Integer; begin for i := Low(fIdentFuncTable) to High(fIdentFuncTable) do if KeyIndices[i] = -1 then fIdentFuncTable[i] := AltFunc; fIdentFuncTable[0] := FuncHello; fIdentFuncTable[2] := FuncWorld; fIdentFuncTable[1] := FuncSynedit; fIdentFuncTable[3] := FuncHightLight; ... function TSynSampleSyn.FuncHightLight(Index: Integer): TtkTokenKind; begin if IsCurrentToken(KeyWords[Index]) then Result := tkKey else Result := tkIdentifier; end; But to make it so that the highlighter is highlighted also doesn’t work out ...
UPDATE Updated indexes, but still the highlighter not highlighted
helloandhighlighter? In my opinion, this is exactly the problem. Give the new keyword a new index. - zed