#include "Precompiled.h"
#include "SharedIncludes.h"
//==================================================================================================

PluginStartupInfo Info;
FarStandardFunctions FSF;

//==================================================================================================

void WINAPI GetGlobalInfoW(GlobalInfo *pInfo)
{
   $DBG_PRINT_IN_FUNCTION();

   pInfo->StructSize    = sizeof( GlobalInfo );
   pInfo->MinFarVersion = MAKEFARVERSION( FARMANAGERVERSION_MAJOR, FARMANAGERVERSION_MINOR,
                                          0, 0, VS_RELEASE );
   pInfo->Version       = PLUGIN_VERSION;
   pInfo->Guid          = MainGuid;
   pInfo->Title         = PLUGIN_NAME;
   pInfo->Description   = L"Automatic switching to OEM-CP/UFT-8 in editor for .CMD/.BAT";
   pInfo->Author        = L"Sergei Y.Kitáev";
}

//--------------------------------------------------------------------------------------------------

void WINAPI SetStartupInfoW(const PluginStartupInfo *pcInfo)
{
   $DBG_PRINT_IN_FUNCTION();

   if ( pcInfo->StructSize >= sizeof(PluginStartupInfo) )
   {
      ::Info = *pcInfo; ::FSF = *pcInfo->FSF; ::Info.FSF = &::FSF;
   }
}

//--------------------------------------------------------------------------------------------------

void WINAPI GetPluginInfoW(PluginInfo *pInfo)
{
   $DBG_PRINT_IN_FUNCTION();

   static const WCHAR *pluginMenuStrings[ 1 ];
   pluginMenuStrings[ 0 ] = $IsNullOrEmptySubstitution(
      ::Info.GetMsg( &MainGuid, PLUGIN_MENU_L_TITLE ), PLUGIN_NAME );

   pInfo->StructSize          = sizeof( PluginInfo );
   pInfo->Flags               = PF_DISABLEPANELS | PF_EDITOR;
   pInfo->PluginMenu.Guids    = &MenuGuid;
   pInfo->PluginMenu.Strings  = pluginMenuStrings;
   pInfo->PluginMenu.Count    = $COUNT_OF( pluginMenuStrings );
   pInfo->PluginConfig.Guids  = &MenuGuid;
   pInfo->PluginConfig.Strings= pluginMenuStrings;
   pInfo->PluginConfig.Count  = $COUNT_OF( pluginMenuStrings );
}

//--------------------------------------------------------------------------------------------------

intptr_t WINAPI ProcessEditorEventW(const ProcessEditorEventInfo *pcInfo)
{
   $DBG_PRINT_IN_FUNCTION();

   if ( pcInfo->StructSize < sizeof(ProcessEditorEventInfo) )
      return NULL;

   if ( pcInfo->Event == EE_READ )
      SwitchToCodePage();

   return NULL;
}

//--------------------------------------------------------------------------------------------------

HANDLE WINAPI OpenW(const OpenInfo *pcInfo)
{
   $DBG_PRINT_IN_FUNCTION();
   SwitchToCodePage();
   return NULL;
}

//--------------------------------------------------------------------------------------------------

void WINAPI ExitFARW(const struct ExitInfo *Info)
{
   $DBG_PRINT_IN_FUNCTION();
}

//==================================================================================================
