Page 1 of 3

Pascal/Delphi

Posted: Sat 13 Dec, 2008 23:53
by WARP ItSelf
Are there any Far plugin writers, who use Pascal/Delphi to write Far plugins? We need your help.

Re: Pascal/Delphi

Posted: Mon 15 Dec, 2008 09:16
by gamma
What kind of help do you need?
Gammatester

Re: Pascal/Delphi

Posted: Tue 16 Dec, 2008 01:37
by WARP ItSelf
We need a few plugin writers, who can test "plugin.pas" for Far 1.75, using it with a real plugin.

Re: Pascal/Delphi

Posted: Tue 16 Dec, 2008 09:46
by gamma
WARP ItSelf wrote:We need a few plugin writers, who can test "plugin.pas" for Far 1.75, using it with a real plugin.
What is Far 1.75? It would be a good start to publish the plugins.pas in the Alpha versions not only the C headers. I could test it with my CRC/Hash plugin if the whole system (Manager + Plugin system) runs under Win98.

Gammatester

Re: Pascal/Delphi

Posted: Tue 16 Dec, 2008 09:51
by t-rex
gamma
Far 1.75 is the relese version of what you know as 1.71. Warp will let you know when the pas files are ready.

Re: Pascal/Delphi

Posted: Wed 17 Dec, 2008 00:45
by WARP ItSelf
First attempt. x64 (FreePascal) and Delphi 2009 (new meaning of Char keyword) are currently not supported (suggestions welcome).

Re: Pascal/Delphi

Posted: Wed 17 Dec, 2008 20:49
by gamma
I tested your plugins.pas out of the box with my CRC/Hash-Plugin V1.17 (using $define USE_BOOL) with these compilers:

Virtual Pascal 2.1.279
Delphi 3
Delphi 10 aka Delphi 2006
FreePascal 2.2.2

and the FAR builds:

1.70 build 2087
1.71 alpha 4 build 2470

under Win98 and Win2000 without problems. But please note:

1. CRC/Hash does not use Viewer/Editor-API, it exports only
GetMinFarVersion,
SetStartupInfo,
GetPluginInfo,
Configure,
OpenPlugin;

2. Once I had a error message during FAR startup "Cannot load plugin..." which disappeared after calling ClearPluginsCache.bat

3. VirtualPascal was not able to write changed configuration to Win2000 registry,but this is most probably a bug/feature of CRC/HAsh and not one of the Plugins API.

4. Your plugins.pas does not test for FreePascal, so USE_DELPHI4 is not defined. I think you could define this symbol for FPC because it seems to be related to int64 only and FPC supports this data type.

Wolfgang (Gammatester)

Re: Pascal/Delphi

Posted: Sun 21 Dec, 2008 21:15
by gamma
HashCRC plugin was justed tested successfully under 1.75 RC0 build 2479.

Gammatester

FAR2 and Pascal/Delphi

Posted: Mon 10 Aug, 2009 15:26
by gamma
A few days agao I received an request for updating my HashCRC plugin for Far2. After installing FAR2 I noticed that the plugin works OK except for the 'A' marks in the plugin/config dialogs.

The issue seems to be that the 'A' version cannot process files with Unicode file names.

Unfortunately there are no more files in the PluginSDK\Headers.pas directory of the latest stable build Far20b981.x86.20090606.7z. It looks like, that there is no Pascal/Delphi support for FAR2?!

Therefore I browsed the http://farmanager.com/svn/trunk/unicode_far/ and found PluginW.pas. Unfortunately this is no real help because the Encyclopedia for Developers from the stable build is for V 1.75 SR2537 and does not reflect the changed structures in PluginW.pas. The comments in the C source code are Russian and no help either.


Any help or hint for Pascal/Delphi programming wth FAR2 ? Otherwise I must put the development on hold until semi-official support files are available.

Wolfgang

Re: FAR2 and Pascal/Delphi

Posted: Mon 10 Aug, 2009 15:29
by Px

Re: FAR2 and Pascal/Delphi

Posted: Mon 10 Aug, 2009 15:34
by t-rex
The PAS files are included with the newer builds. Regarding documentation on the new API - there isn't one at the moment :( And even when such will appear it will take time for it to appear in english. Anyway, most of the API's didn't change drastically and you can ask questions regarding the other ones. You can start by first of all getting to the point were your code compiles for Far2, then it will be easier to continue.

Re: FAR2 and Pascal/Delphi

Posted: Mon 10 Aug, 2009 15:39
by Max Rusov

Re: FAR2 and Pascal/Delphi

Posted: Mon 10 Aug, 2009 19:15
by gamma
Thank you very much to all who answered. Max: I already had downloaded your plugins and found a few sources in FarHints. But I will have a look at the promising http://far-plugins.googlecode.com/svn/trunk/.

I have just crippled my code in order to compile. Here are the four main problems (besides many type casts to PFarChar, which compile but will probably not to what they should):

1. No Dialog: TFarApiDialog in TPluginStartupInfo, there are three (undocumented) DialogXXX types and may be these function can be used?

Code: Select all

  DialogInit : TFarApiDialogInit;
  DialogRun  : TFarApiDialogRun;
  DialogFree : TFarApiDialogFree;
2. No Data.Data buffer in TFarDialogItem. This would a be a minor problem with static data, but is annoying with dynamical language dependent data obtained with GetMsg. Since in former versions this Data.Data was a variant record (a union in C), is it OK to overlay Data.Data with a pointer? I guess not, because in V2.0 there is an additional MaxLen DWORD.

3. Changed TFarApiControl structure: Can I assume Param <-> Param2? What is Param1?

Code: Select all

  TFarApiControl = function (   //FAR 1.7
        hPlugin : THandle;
        Command : Integer;
        Param : Pointer
        ) : Integer;

  TFarApiControl = function (   //FAR 2.0
    hPlugin :THandle;
    Command :Integer;
    Param1 :Integer;
    Param2 :Pointer
  ) :Integer;
4. And the most annoying and confusing issue: No SelectedItems and PanelItems in TPanelInfo!? How do I get these essential infos, ie the filenames to process?

Wolfgang

Re: FAR2 and Pascal/Delphi

Posted: Mon 10 Aug, 2009 20:30
by t-rex
1+2. The dialog api has changed considerably, there is no longer a 512 limit on strings and the dialog structure provided by the user is used for initialization only, it is not changed/updated by Far in any way.
Instead of Data.Data there is now a const pointer PtrData which you set to point to the string you need (you can assign the return value of GetMsg to it). MaxLen is not very important, setting it to 0 is what everybody will use most of the time - what it means is how much text should Far allow the user to enter in a edit control for example.
So to work with dialogs you:
define the structure as before, call DialogInit which will initialize an internal object in Far to represent the dialog
call DialogRun, passing it the return value of DialogInit, DialogRun will return the exitcode of the dialog (as the Dialog function in 1.7)
now the main change - as your structure is not updated with the changes, to get the values/states of items in the dialog you call SendDlgMessage to get the needed values (use DM_GETCONSTTEXTPTR to get a const pointer to string values, the GETDLG and similar DM's now require you to provide a buffer which will hold the data - call with 0 to get the buffer size).
when you are finished call DialogFree

3. First of all the hPlugin should now be PANEL_ACTIVE or PANEL_PASSIVE. In most cases old Param == Param2, but some of the FCTL commands were changes and new ones added and they require more input.

4. FCTL_GETSELECTEDPANELITEM, FCTL_GETCURRENTPANELITEM. FCTL_GETSELECTEDPANELITEM returns one item at a time. Both require you to provide a buffer for the data.

It would best to follow the code in Max's plugins to get a better understanding.

Re: FAR2 and Pascal/Delphi

Posted: Mon 10 Aug, 2009 21:24
by gamma
t-rex, thank you for the detailed answer. Although it looks like a frustrating amount of work in order to be able to just handle Unicode file names, I think I will start slowly using Max' sources as a guide.