Access FAR settings from plugin

A place where plug-in developers can share their knowledge and experience.
patrikp
Posts: 5
Joined: Thu 12 May, 2016 14:53
Has thanked: 1 time

Access FAR settings from plugin

Postby patrikp » Mon 23 May, 2016 10:39

Hi, is it possible to access FAR settings from plugin? I would like to get two values: if external viewer is allowed and path to external viewer.

I made this piece of not working code

Code: Select all

   FarSettingsCreate fsc = { sizeof(FarSettingsCreate), NullGuid, INVALID_HANDLE_VALUE };

   if (g_Plugin.Info.SettingsControl(INVALID_HANDLE_VALUE, SCTL_CREATE, 0, &fsc))
   {
      FarSettingsValue value = { sizeof(FarSettingsValue), 0, L"Viewer" };

      intptr_t lvl = g_Plugin.Info.SettingsControl(fsc.Handle, SCTL_OPENSUBKEY, 0, &value);

      if (lvl)
      {
         FarSettingsItem item = { sizeof(FarSettingsItem), lvl, L"UseExternalViewer", FST_QWORD };

         if (g_Plugin.Info.SettingsControl(fsc.Handle, SCTL_GET, 0, &item))
         {
            return TRUE;
         }

         return FALSE;
      }

      g_Plugin.Info.SettingsControl(fsc.Handle, SCTL_FREE, 0, 0);
   }


In my Far3, I have external viewer allowed, but SCTL_GET command fails. Also SCTL_CREATE always returns 0x18, no matter what value is provided as a name.

Suggestions?

User avatar
DrKnS
Posts: 4434
Joined: Thu 04 Aug, 2005 06:44
Location: Kyiv
Has thanked: 2 times
Been thanked: 101 times
Contact:

Access FAR settings from plugin

Postby DrKnS » Mon 23 May, 2016 18:56

In general, you need to use a predefined constant from FARSETTINGS_SUBFOLDERS enum rather than SCTL_OPENSUBKEY to access Far settings.
But, as far as I can see, viewer settings are marked as private currently.

patrikp
Posts: 5
Joined: Thu 12 May, 2016 14:53
Has thanked: 1 time

Access FAR settings from plugin

Postby patrikp » Tue 24 May, 2016 09:28

You are right, I found it in config.cpp... :(


Return to “Plug-In Developers”

Who is online

Users browsing this forum: No registered users and 1 guest