FAR2 and Pascal/Delphi

A place where plug-in developers can share their knowledge and experience.
Post Reply
gamma
Posts: 19
Joined: Wed 16 Apr, 2008 17:06

FAR2 and Pascal/Delphi

Post by gamma » Mon 10 Aug, 2009 15:26

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

User avatar
Px
Posts: 826
Joined: Fri 08 Sep, 2006 15:52
Location: Вишнёвый (под Киевом)
Contact:

Re: FAR2 and Pascal/Delphi

Post by Px » Mon 10 Aug, 2009 15:29


User avatar
t-rex
Страшный и ужасный
Posts: 4871
Joined: Tue 15 Mar, 2005 16:17
Location: Tel-Aviv
Contact:

Re: FAR2 and Pascal/Delphi

Post by t-rex » Mon 10 Aug, 2009 15:34

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.

User avatar
Max Rusov
Posts: 3599
Joined: Wed 23 Nov, 2005 11:11
Location: Москва-Питер
Been thanked: 6 times
Contact:

Re: FAR2 and Pascal/Delphi

Post by Max Rusov » Mon 10 Aug, 2009 15:39


gamma
Posts: 19
Joined: Wed 16 Apr, 2008 17:06

Re: FAR2 and Pascal/Delphi

Post by gamma » Mon 10 Aug, 2009 19:15

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

User avatar
t-rex
Страшный и ужасный
Posts: 4871
Joined: Tue 15 Mar, 2005 16:17
Location: Tel-Aviv
Contact:

Re: FAR2 and Pascal/Delphi

Post by t-rex » Mon 10 Aug, 2009 20:30

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.

gamma
Posts: 19
Joined: Wed 16 Apr, 2008 17:06

Re: FAR2 and Pascal/Delphi

Post by gamma » Mon 10 Aug, 2009 21:24

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.

Post Reply

Return to “Plug-In Developers”

Who is online

Users browsing this forum: No registered users and 1 guest