I am trying to add a lexer defined in a cpp.lcf file to ATsynedit.
On a wiki page it says that TATAdapterEControl can be added to a ATsynedit.:
Adapter:= TATAdapterEControl.Create(Self);
ed.AdapterForHilite:= Adapter;
However, I assume that I have to load the definition of the highlighter. However, the method "Adapter.Lexer.LoadFromFile" cannot load *.lcf files.
I tried to follow the CudaText code:
an:=TecSyntAnalyzer.Create(self);
an.LoadFromFile('../lex/cpp.lcf');
This works but I have trouble finding a simple way to assign this "an" object to a ATsynedit. The CudaText code is more complex and works for multiple lexers, but I am looking for something simple and currently I only need one lexer.
btw. lex.lib.demo on Linux Mint 19.2 did not work for me. It fails to compile "F.edSample.Gutter[F.edSample.GutterBandBm].Visible:= false; " on line 229 in unit formlexerprop. Another issue I have is that most of the packages does not appear on the component palette. Nevertheless, CudaText compiles and works fine.
Thanks,
Rune
ATSynEdit: Assign a lexer
AFAIR, you cannot load only one .lcf file without using LexerManager TecLexerList. use LexerManager (create new one) and load .lcf files into it.
then assign LexerManager-s items to your ATSynEdit adapter.
example loads lexermanager AppManager. example from CudaText.
file formmain.pas
function procedure TfmMain.DoOps_LoadLexerLib
then assign LexerManager-s items to your ATSynEdit adapter.
example loads lexermanager AppManager. example from CudaText.
file formmain.pas
function procedure TfmMain.DoOps_LoadLexerLib
Code: Select all
for i:= 0 to ListFiles.Count-1 do
begin
an:= AppManager.AddLexer;
//an.Name:= '_lx_'+LexerFilenameToComponentName(ListFiles[i]);
an.LoadFromFile(ListFiles[i]);
//load *.cuda-lexops
fn_ops:= GetAppLexerOpsFilename(an.LexerName);
if FileExistsUTF8(fn_ops) then
DoLoadLexerStylesFromFile_JsonLexerOps(an, fn_ops, UiOps.LexerThemes);
end;