Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-11-01 Thread Fred van Stappen
> Isn't "han" in use by a source-page?

Yes. But only the active page.

The name+path of the active-page is stored into variable "theactivepage",  same 
for "han" the handle and "thesdef" the name+path of the sdef  ).

So there is everything needed to recognize a active-page and only load, if 
needed, the custom-choice of sdef.

Fre;D
--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-31 Thread Martin Schreiber
On Monday 31 October 2016 19:35:16 Fred van Stappen wrote:
> > Although if there is enough RAM it is no harm to store the same file.
>
> Does readdeffile() need lot of ram ?
>
It depends on the complexity.

> Because only one global variable han will be used.
> Each time that a direct-layout will be loaded there will be:
>
> freedeffile(han);

Isn't "han" in use by a source-page?

Martin

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-31 Thread Fred van Stappen
Oops, sorry for previous mail, it was sent too fast.


> Do you consider that a selection can be empty, for example depending on the 
> selection settings by clicking in an empty cell?

Ok, you are right, if you do a filter in listfileview.onselectionchanged with 
if assigned(listfileview.selectednames), the developer miss the info that a 
empty cell was selected.

Sorry for the noise (and I will use if assigned(selectednames) in my code).

Fre;D

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-31 Thread Fred van Stappen


On Monday 31 October 2016 18:34:39 Fred van Stappen wrote:
>
> Hum, if the MSEfilelistview is still open and your hands already full of
> grease, there is a other little detail...
>
> If a empty row is selected (see attachment),

Do you consider that a selection can be empty, for example depending on the
selection settings by clicking in an empty cell?

Martin

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
[http://dap.xeonphi.com/images/fullimage4.jpg]

Developer Access Program (DAP) for Intel® Xeon Xeon Phi(tm) Processor Codenamed 
Knights Landing
sdm.link
Intel is bringing to market, in anticipation of general availability of the 
Intel® Xeon Phi(tm) Processor (codenamed Knights Landing), the Developer Access 
Program (DAP). DAP is an early access program for developers worldwide to 
purchase an Intel Xeon Phi Processor based system. This is a stand-alone box 
that has a single bootable Knights Landing processor for developers to start 
developing codes, optimizing applications, and getting to see the performance.



___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mseide-msegui-talk Info Page - 
SourceForge
lists.sourceforge.net
To see the collection of prior postings to the list, visit the 
mseide-msegui-talk Archives. Using mseide-msegui-talk: To post a message to all 
the ...



--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-31 Thread Fred van Stappen
> Although if there is enough RAM it is no harm to store the same file.


Does readdeffile() need lot of ram ?

Because only one global variable han will be used.
Each time that a direct-layout will be loaded there will be:

freedeffile(han);
han := readdeffile(layoutfile);

In fine, there will be only one more readdeffile() loaded.
But if it uses lot of ram...

Thanks

Fre;D


--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-31 Thread Fred van Stappen
 > Do you consider that a selection can be empty, for example depending on the

>   selection settings by clicking in an empty cell?

To get the selected filename I use that code:
selected_file.text := list_files.selectednames[0] ;


And if clicking on a empty row raise a error if not using if assigned():

if assigned(list_files.selectednames) and (tag = 0) then
 begin
 if han <> -1 then sourcefo.syntaxpainter.freedeffile(han);
 selected_file.text := list_files.selectednames[0] ;
 han := sourcefo.syntaxpainter.readdeffile(list_files.directory+
 directoryseparator +selected_file.text);
sourcefo.activepage.edit.setsyntaxdef(han);
sourcefo.activepage.updatestatvalues;
end;

Fre;D


--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-31 Thread Martin Schreiber
On Monday 31 October 2016 18:34:39 Fred van Stappen wrote:
>
> Hum, if the MSEfilelistview is still open and your hands already full of
> grease, there is a other little detail...
>
> If a empty row is selected (see attachment),

Do you consider that a selection can be empty, for example depending on the 
selection settings by clicking in an empty cell?

Martin

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-31 Thread Fred van Stappen
> Please try again with git master 40cbea289f1f2a698ab23b043cc758959e9ca2c5,

Yep, perfect, it works, many thanks.

Hum, if the MSEfilelistview is still open and your hands already full of 
grease, there is a other little detail...

If a empty row is selected (see attachment), filelistview.onselectionchanged 
raise a error.
It is fixed with:

if assigned(filelistview.selectednames) then
begin
...

Maybe this could be added in filelistview.onselectionchanged code.
(and maybe you have already fixed with last commit, then sorry for the noise.)

Fre;D

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-31 Thread Martin Schreiber
On Sunday 30 October 2016 20:27:22 Fred van Stappen wrote:
> > Yes, but a single global "han" variable probably is not sufficient.
>
> Sorry, I do not understand this. What do you mean with single global "han"
> variable ?
>
> What do you propose, what other variable must I use ?
>
I assume you need to maintain a list of *.sdef filepaths and associated 
handles. Although if there is enough RAM it is no harm to store the same file 
multiple times. ;-)

Martin

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-30 Thread Fred van Stappen
> Thanks, I see the image. I asked for a simple example project which shows the 
> problem.


OK, see mse simple project in attachment.

Fre;D



msefilelist.tar.xz
Description: msefilelist.tar.xz
--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-30 Thread Fred van Stappen
> Yes, but a single global "han" variable probably is not sufficient.

Sorry, I do not understand this. What do you mean with single global "han" 
variable ?

What do you propose, what other variable must I use ?

Thanks.

Fre;D
--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-30 Thread Fred van Stappen
> Thanks, I see the image. I asked for a simple example project which shows the 
> problem.

Hum, here https://github.com/fredvs/ideU []

In Menu, click on Layout or Syntax.

Or, on a form, add a Tfilelistview : afilelistview, without changing any 
parameters. =>

afilelistview.path := '/usr/lib';

If you click on one row, the icon will be partly masked.

Fre;D

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-29 Thread Martin Schreiber
On Saturday 29 October 2016 22:32:04 Fred van Stappen wrote:
> Re-hello Martin.
>
> Huh, and with freedeffile(), something like this ?:
>
> var
> han : integer = -1;
> ...
> procedure sdefload(sdeffile : msestring);
> begin
> if han <> -1 then sourcefo.syntaxpainter.freedeffile(han);
>  han := sourcefo.syntaxpainter.readdeffile(sdeffile);
>  sourcefo.activepage.edit.setsyntaxdef(han);
>  sourcefo.activepage.updatestatvalues;
> end;

Yes, but a single global "han" variable probably is not sufficient.

Martin

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-29 Thread Fred van Stappen
Re-hello Martin.

Huh, and with freedeffile(), something like this ?:

var
han : integer = -1;
...
procedure sdefload(sdeffile : msestring);
begin
if han <> -1 then sourcefo.syntaxpainter.freedeffile(han);
 han := sourcefo.syntaxpainter.readdeffile(sdeffile);
 sourcefo.activepage.edit.setsyntaxdef(han);
 sourcefo.activepage.updatestatvalues;
end;

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-29 Thread Fred van Stappen
>> Every time you do

>> han := sourcefo.syntaxpainter.readdeffile(openfile.controller.filename);

> Ha, ok => freeandnil(han) is it enough?

Ooops, han is a integer, freeandnil() has no sense here.

So, the question is: how to remove the block created ?
Is the existing block not erased by the new one ?

> What is this ([cid:...])

Huh, the new feature of hotmail.com to insert a image at cursor...

Ok, it is in attachment now.

Fre;D
--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-29 Thread Fred van Stappen
> Every time you do

> han := sourcefo.syntaxpainter.readdeffile(openfile.controller.filename);

Ha, ok => freeandnil(han) is it enough?

> What is this ([cid:...])

Huh, the new feature of hotmail.com to insert a image at cursor...

Ok, it is in attachment now.

Fre;D
--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-29 Thread Martin Schreiber
On Saturday 29 October 2016 14:41:57 Fred van Stappen wrote:
> > Please don't forget to release the loaded *.sdef files if they are not
> > used anymore.
>
> Huh, with pleasure, but what do you mean with "release the loaded *sdef" ?
>
Every time you do
"
han := sourcefo.syntaxpainter.readdeffile(openfile.controller.filename);
"
there will be a new definition block in syntaxpainter.
MSEide on the other hand uses for every entry in 'Project'-'Options'-'Syntax 
definition file' a single instance wnen a file with the according extension 
has been loaded. 

> Other (very little) detail.
>
> In tfilelistview, in the selected row, the icon is partly masked by the
> text.
>

> [cid:59fdc292-6ce5-4425-8fc1-f7c89d901492]
>
What is this ([cid:...])

> Is it possible to fix this ?
>
Probably. Can you send a simple example?

Martin

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-29 Thread Fred van Stappen
> Please don't forget to release the loaded *.sdef files if they are not used 
> anymore.

Huh, with pleasure, but what do you mean with "release the loaded *sdef" ?

Other (very little) detail.

In tfilelistview, in the selected row, the icon is partly masked by the text.

[cid:59fdc292-6ce5-4425-8fc1-f7c89d901492]

Is it possible to fix this ?

Thanks.

Fre;D
--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-28 Thread Martin Schreiber
On Saturday 29 October 2016 04:13:09 Fred van Stappen wrote:
> Hello Martin.
>
> OK, it works live (sdef and layout files) =>
>
> https://sites.google.com/site/fredvsbinaries/ideu_sdef.mp4
>
Please don't forget to release the loaded *.sdef files if they are not used 
anymore.

Martin

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-28 Thread Fred van Stappen
Hello Martin.

OK, it works live (sdef and layout files) =>

https://sites.google.com/site/fredvsbinaries/ideu_sdef.mp4

Thanks.

Fre;d
--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-28 Thread Fred van Stappen
>
> Is it possible, when the openfile dialog is show, to have the same result
> that openfile.execute but when select a file in the grid ?
> That way, selecting a row, will load the sdef file without to click on OK.
>
>>Instantaneous selection and closing the dialog occurs by double click or
>> pressing enter.

Ok, thanks (but I knew that). I was taking about live-selection when the 
dialog-box is open.
I have checked in MSEgui code and it seems that it is not possible with a 
dialog-component.
So I think that I must create a custom dialog box and use the 
onselected-properties of string-grid.

A other solution is to use a timer who will check if dialog.controller.filename 
has changed.

>
> And how to work with openfile.controller.filterlist, a for example:
> openfile.controller.filterlist := '*.sdef, *.*' ?
>
>> Please set the list to:

OK, thanks Martin.

Fre;D

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-27 Thread Martin Schreiber
On Thursday 27 October 2016 22:06:00 Fred van Stappen wrote:
>
> Is it possible, when the openfile dialog is show, to have the same result
> that openfile.execute but when select a file in the grid ?
> That way, selecting a row, will load the sdef file without to click on OK.
>
Instantaneous selection and closing the dialog occurs by double click or 
pressing enter.
>
> And how to work with openfile.controller.filterlist, a for example:
> openfile.controller.filterlist := '*.sdef, *.*' ?
>
Please set the list to:
a b
--
Syntax definition files   *.sdef
All files with extension  *.*

Martin

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-27 Thread Fred van Stappen

Hello Martin.


Thanks for answer.


I will try to understand and make it work.


Write you later.


Fre;D


De : Martin Schreiber <mse00...@gmail.com>
Envoyé : jeudi 27 octobre 2016 07:12
À : mseide-msegui-talk@lists.sourceforge.net
Objet : Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

On Thursday 27 October 2016 02:55:07 Fred van Stappen wrote:
> Hello Martin.
>
>
> In tmainfo I want to add a SyntaxDef menu-item.
> OnExecute will call a openfile dialog to choose the syntaxdef file.
>
MSEide loads syntax definition files on demand. The call stack is:
"
procedure tsourcepage.loadfile(value: filenamety);
begin
 inc(ffileloading);
 try
  edit.loadfromfile(value);
  ismoduletext:= ismoduletext or (fileext(value) = formfileext);
  finitialfilepath:= edit.filename;
  setsyntaxdef(value);
"
"
procedure tsourcepage.setsyntaxdef(const value: filenamety);
begin
 try
  edit.setsyntaxdef(value);
"
"
procedure tsyntaxedit.setsyntaxdef(const sourcefilename: filenamety);
begin
 if fsyntaxpainter <> nil then begin
  if sourcefilename = '' then begin
   unregistersyntaxpainter;
  end
  else begin
   setsyntaxdef(fsyntaxpainter.linkdeffile(sourcefilename));
"
"
function tsyntaxpainter.linkdeffile(const sourcefilename: filenamety):
integer;
var
 int1,int2: integer;
 strar1: msestringarty;
 stream: ttextstream;
 str1: filenamety;

begin
 result:= -1;
 for int1:= 0 to fdefdefs.count - 1 do begin
  strar1:= nil;
  splitstringquoted(defdefs[int1].a,strar1);
  for int2:= 0 to high(strar1) do begin
   if checkfilename(sourcefilename,strar1[int2],true) then begin
result:= int1;
break;
   end;
  end;
  if result >= 0 then begin
   break;
  end;
 end;
 if result >= 0 then begin
  int2:= result;
  result:= -1;
  for int1:= 0 to high(fsyntaxdefs) do begin
   with fsyntaxdefs[int1] do begin
if (charstyles <> nil) and (defdefsnr = int2) then begin
 result:= int1;
 break;
end;
   end;
  end;
  if result < 0 then begin
   str1:= fdefdefs[int2].b;
   str1:= filepath(fdefsdir,str1);
   stream:= ttextstream.create(str1,fm_read);
   try
try
 result:= readdeffile(stream);
"
"
function tsyntaxpainter.readdeffile(stream: ttextstream): integer;
type
 tokennrty = (tn_styles,tn_caseinsensitive,tn_keywordchars,tn_addkeywordchars,
  tn_colors,tn_pairwords,tn_keyworddefs,
  tn_scope,tn_endtokens,tn_keywords,tn_jumptokens,tn_calltokens,
  tn_return);
const
 tn_canmultiple = [tn_keyworddefs{,tn_jumptokens,tn_calltokens,tn_endtokens}];

 nonetoken = 'NONE';
 tokens: array[tokennrty] of string = (
   'STYLES','CASEINSENSITIVE','KEYWORDCHARS','ADDKEYWORDCHARS',
   'COLORS','PAIRWORDS','KEYWORDDEFS',
   'SCOPE','ENDTOKENS','KEYWORDS','JUMPTOKENS','CALLTOKENS',
   'RETURN');
 tn_localstart = tn_scope;
...
"
later:
"
procedure tsyntaxedit.setsyntaxdef(const handle: integer);
begin
 if fsyntaxpainter <> nil then begin
  unregistersyntaxpainter;
  if handle >= 0 then begin
   fsyntaxpainterhandle:= fsyntaxpainter.registerclient(self,flines,
   {$ifdef FPC}@{$endif}syntaxchanged,handle);
   initsyntaxparams();
   refreshsyntax(0,bigint);
  end;
 end;
end;
"
> I try with this procedure without succes:
>
> procedure tmainfo.LoadSyntaxDef(const sender: TObject);
> var
> int1 : integer;
> begin
>   openfile.controller.lastdir :=
> IncludeTrailingBackslash(ExtractFilePath(ParamStr(0))) + '/syntaxdefs';
>
> if openfile.execute = mr_ok then
> begin
> with sourcefo.syntaxpainter do begin
>   sourcefo.syntaxpainter.clear;
>  try
>   for int1:= 0 to sourcefo.count - 1 do begin
>
> sourcefo.items[int1].edit.setsyntaxdef(openfile.controller.filename); end;

This is wrong. In "edit.setsyntaxdef()"  should not be the syntax
definition file but the source file. The appropriate *.sdef-file will be
guessed by file extension of .
You need to call
"
 tsyntaxedit.setsyntaxdef(const handle: integer)
"
with a handle you get by
"
function tsyntaxpainter.readdeffile(stream: ttextstream): integer;
"
"stream" supplies the *.sdef file.
I suggest to load a given *.sdef file only once and to cache the handle for
future use.

Martin

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
--
The Command Line: Reinve

Re: [MSEide-MSEgui-talk] How to load a syntaxdef file ?

2016-10-26 Thread Martin Schreiber
On Thursday 27 October 2016 02:55:07 Fred van Stappen wrote:
> Hello Martin.
>
>
> In tmainfo I want to add a SyntaxDef menu-item.
> OnExecute will call a openfile dialog to choose the syntaxdef file.
>
MSEide loads syntax definition files on demand. The call stack is:
"
procedure tsourcepage.loadfile(value: filenamety);
begin
 inc(ffileloading);
 try
  edit.loadfromfile(value);
  ismoduletext:= ismoduletext or (fileext(value) = formfileext);
  finitialfilepath:= edit.filename;
  setsyntaxdef(value);
"
"
procedure tsourcepage.setsyntaxdef(const value: filenamety);
begin
 try
  edit.setsyntaxdef(value);
"
"
procedure tsyntaxedit.setsyntaxdef(const sourcefilename: filenamety);
begin
 if fsyntaxpainter <> nil then begin
  if sourcefilename = '' then begin
   unregistersyntaxpainter;
  end
  else begin
   setsyntaxdef(fsyntaxpainter.linkdeffile(sourcefilename));
"
"
function tsyntaxpainter.linkdeffile(const sourcefilename: filenamety): 
integer;
var
 int1,int2: integer;
 strar1: msestringarty;
 stream: ttextstream;
 str1: filenamety;

begin
 result:= -1;
 for int1:= 0 to fdefdefs.count - 1 do begin
  strar1:= nil;
  splitstringquoted(defdefs[int1].a,strar1);
  for int2:= 0 to high(strar1) do begin
   if checkfilename(sourcefilename,strar1[int2],true) then begin
result:= int1;
break;
   end;
  end;
  if result >= 0 then begin
   break;
  end;
 end;
 if result >= 0 then begin
  int2:= result;
  result:= -1;
  for int1:= 0 to high(fsyntaxdefs) do begin
   with fsyntaxdefs[int1] do begin
if (charstyles <> nil) and (defdefsnr = int2) then begin
 result:= int1;
 break;
end;
   end;
  end;
  if result < 0 then begin
   str1:= fdefdefs[int2].b;
   str1:= filepath(fdefsdir,str1);
   stream:= ttextstream.create(str1,fm_read);
   try
try
 result:= readdeffile(stream);
"
"
function tsyntaxpainter.readdeffile(stream: ttextstream): integer;
type
 tokennrty = (tn_styles,tn_caseinsensitive,tn_keywordchars,tn_addkeywordchars,
  tn_colors,tn_pairwords,tn_keyworddefs,
  tn_scope,tn_endtokens,tn_keywords,tn_jumptokens,tn_calltokens,
  tn_return);
const
 tn_canmultiple = [tn_keyworddefs{,tn_jumptokens,tn_calltokens,tn_endtokens}];

 nonetoken = 'NONE';
 tokens: array[tokennrty] of string = (
   'STYLES','CASEINSENSITIVE','KEYWORDCHARS','ADDKEYWORDCHARS',
   'COLORS','PAIRWORDS','KEYWORDDEFS',
   'SCOPE','ENDTOKENS','KEYWORDS','JUMPTOKENS','CALLTOKENS',
   'RETURN');
 tn_localstart = tn_scope;
...
"
later:
"
procedure tsyntaxedit.setsyntaxdef(const handle: integer);
begin
 if fsyntaxpainter <> nil then begin
  unregistersyntaxpainter;
  if handle >= 0 then begin
   fsyntaxpainterhandle:= fsyntaxpainter.registerclient(self,flines,
   {$ifdef FPC}@{$endif}syntaxchanged,handle);
   initsyntaxparams();
   refreshsyntax(0,bigint);
  end;
 end;
end;
"
> I try with this procedure without succes:
>
> procedure tmainfo.LoadSyntaxDef(const sender: TObject);
> var
> int1 : integer;
> begin
>   openfile.controller.lastdir :=
> IncludeTrailingBackslash(ExtractFilePath(ParamStr(0))) + '/syntaxdefs';
>
> if openfile.execute = mr_ok then
> begin
> with sourcefo.syntaxpainter do begin
>   sourcefo.syntaxpainter.clear;
>  try
>   for int1:= 0 to sourcefo.count - 1 do begin
>   
> sourcefo.items[int1].edit.setsyntaxdef(openfile.controller.filename); end;

This is wrong. In "edit.setsyntaxdef()"  should not be the syntax 
definition file but the source file. The appropriate *.sdef-file will be 
guessed by file extension of .
You need to call
"
 tsyntaxedit.setsyntaxdef(const handle: integer)
"
with a handle you get by 
"
function tsyntaxpainter.readdeffile(stream: ttextstream): integer;
"
"stream" supplies the *.sdef file.
I suggest to load a given *.sdef file only once and to cache the handle for 
future use.

Martin

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk