From 60513128102c9c923a1a92460aa676eec380f47c Mon Sep 17 00:00:00 2001 From: Shmuel Zeigerman Date: Wed, 27 Nov 2024 01:21:15 +0200 Subject: [PATCH] Policies are removed (Policies.DisabledOptions) --- far/far2sdk/farplug-wide.h | 28 --- far/src/cfg/ConfigOpt.cpp | 8 - far/src/cfg/config.hpp | 8 - far/src/macro/macroapi.cpp | 2 +- far/src/main.cpp | 32 ++- far/src/options.cpp | 11 - far/src/plug/plugapi.cpp | 4 - far/src/plug/plugins.cpp | 253 +++++++++++------------ luafar/lua_share/far2/test/macrotest.lua | 2 - 9 files changed, 137 insertions(+), 211 deletions(-) diff --git a/far/far2sdk/farplug-wide.h b/far/far2sdk/farplug-wide.h index e0112d234..0d7e597fe 100644 --- a/far/far2sdk/farplug-wide.h +++ b/far/far2sdk/farplug-wide.h @@ -1160,34 +1160,6 @@ enum FAR_MACRO_CONTROL_COMMANDS MCTL_EXECSTRING = 10, }; -#ifdef FAR_USE_INTERNALS -enum FarPoliciesFlags -{ - FFPOL_MAINMENUSYSTEM = 0x00000001, - FFPOL_MAINMENUPANEL = 0x00000002, - FFPOL_MAINMENUINTERFACE = 0x00000004, - FFPOL_MAINMENULANGUAGE = 0x00000008, - FFPOL_MAINMENUPLUGINS = 0x00000010, - FFPOL_MAINMENUDIALOGS = 0x00000020, - FFPOL_MAINMENUCONFIRMATIONS = 0x00000040, - FFPOL_MAINMENUPANELMODE = 0x00000080, - FFPOL_MAINMENUFILEDESCR = 0x00000100, - FFPOL_MAINMENUFOLDERDESCR = 0x00000200, - FFPOL_MAINMENUVIEWER = 0x00000800, - FFPOL_MAINMENUEDITOR = 0x00001000, - FFPOL_MAINMENUCOLORS = 0x00004000, - FFPOL_MAINMENUHILIGHT = 0x00008000, - FFPOL_MAINMENUSAVEPARAMS = 0x00020000, - - FFPOL_CREATEMACRO = 0x00040000, - FFPOL_USEPSWITCH = 0x00080000, - FFPOL_PERSONALPATH = 0x00100000, - FFPOL_KILLTASK = 0x00200000, - FFPOL_SHOWHIDDENDRIVES = 0x80000000, -}; - -#endif // END FAR_USE_INTERNALS - enum FarSystemSettings { FSS_DELETETORECYCLEBIN = 0x00000002, diff --git a/far/src/cfg/ConfigOpt.cpp b/far/src/cfg/ConfigOpt.cpp index c1d719ec1..afbc645ad 100644 --- a/far/src/cfg/ConfigOpt.cpp +++ b/far/src/cfg/ConfigOpt.cpp @@ -93,7 +93,6 @@ static const char NSecPanelTree[]="Panel/Tree"; static const char NSecLayout[]="Layout"; static const char NSecDescriptions[]="Descriptions"; static const char NSecMacros[]="Macros"; -static const char NSecPolicies[]="Policies"; static const char NSecSavedHistory[]="SavedHistory"; static const char NSecSavedViewHistory[]="SavedViewHistory"; static const char NSecSavedFolderHistory[]="SavedFolderHistory"; @@ -444,10 +443,6 @@ static struct FARConfig {1, NSecMacros, "KeyRecordCtrlDot", &Opt.Macro.strKeyMacroCtrlDot, szCtrlDot}, {1, NSecMacros, "KeyRecordCtrlShiftDot", &Opt.Macro.strKeyMacroCtrlShiftDot, szCtrlShiftDot}, - {0, NSecPolicies, "ShowHiddenDrives", &Opt.Policies.ShowHiddenDrives, 1, REG_BOOLEAN}, - {0, NSecPolicies, "DisabledOptions", &Opt.Policies.DisabledOptions, 0}, - - {0, NSecSystem, "ExcludeCmdHistory", &Opt.ExcludeCmdHistory, 0}, //AN {1, NSecCodePages, "CPMenuMode", &Opt.CPMenuMode, 0, REG_BOOLEAN}, @@ -766,9 +761,6 @@ void ConfigOptAssertLoaded() void ConfigOptSave(bool Ask) { - if (Opt.Policies.DisabledOptions&0x20000) // Bit 17 - Сохранить параметры - return; - if (Ask && Message(0,2,Msg::SaveSetupTitle,Msg::SaveSetupAsk1,Msg::SaveSetupAsk2,Msg::SaveSetup,Msg::Cancel)) return; diff --git a/far/src/cfg/config.hpp b/far/src/cfg/config.hpp index 12214519c..4e22e24ec 100644 --- a/far/src/cfg/config.hpp +++ b/far/src/cfg/config.hpp @@ -247,13 +247,6 @@ struct ViewerOptions int SearchRegexp; }; -// "Полиция" -struct PoliciesOptions -{ - int DisabledOptions; // разрешенность меню конфигурации - int ShowHiddenDrives; // показывать скрытые логические диски -}; - struct DialogsOptions { int EditBlock; // Постоянные блоки в строках ввода @@ -568,7 +561,6 @@ struct Options DialogsOptions Dialogs; VMenuOptions VMenu; CommandLineOptions CmdLine; - PoliciesOptions Policies; MacroOptions Macro; int FindCodePage; diff --git a/far/src/macro/macroapi.cpp b/far/src/macro/macroapi.cpp index fd0b0ebcc..6bd5d420b 100644 --- a/far/src/macro/macroapi.cpp +++ b/far/src/macro/macroapi.cpp @@ -70,7 +70,7 @@ static Frame* GetTopModal() Panel* SelectPanel(int Type) { - if (CtrlObject && CtrlObject->Cp()) { + if (CtrlObject->Cp()) { Panel* ActivePanel = CtrlObject->Cp()->ActivePanel; if (ActivePanel) { switch(Type) { diff --git a/far/src/main.cpp b/far/src/main.cpp index b91606319..b3f13f952 100644 --- a/far/src/main.cpp +++ b/far/src/main.cpp @@ -513,29 +513,23 @@ int FarAppMain(int argc, char **argv) Opt.SmallIcon=TRUE; break; - case L'X': - fprintf(stderr, "Unsupported in far2m\n"); - break; - case L'P': - if (!(Opt.Policies.DisabledOptions & FFPOL_USEPSWITCH)) { - bCustomPlugins = true; - if (arg_w[2]) + bCustomPlugins = true; + if (arg_w[2]) + { + UserDefinedList Udl(ULF_UNIQUE | ULF_CASESENSITIVE, L':', 0); + if (Udl.Set(arg_w.data() + 2)) { - UserDefinedList Udl(ULF_UNIQUE | ULF_CASESENSITIVE, L':', 0); - if (Udl.Set(arg_w.data() + 2)) + for (size_t i=0; i < Udl.Size(); i++) { - for (size_t i=0; i < Udl.Size(); i++) - { - FARString path = Udl.Get(i); - apiExpandEnvironmentStrings(path, path); - // Unquote(path); - ConvertNameToFull(path, path); - if (!Opt.LoadPlug.strCustomPluginsPath.IsEmpty()) { - Opt.LoadPlug.strCustomPluginsPath += L':'; - } - Opt.LoadPlug.strCustomPluginsPath += path; + FARString path = Udl.Get(i); + apiExpandEnvironmentStrings(path, path); + // Unquote(path); + ConvertNameToFull(path, path); + if (!Opt.LoadPlug.strCustomPluginsPath.IsEmpty()) { + Opt.LoadPlug.strCustomPluginsPath += L':'; } + Opt.LoadPlug.strCustomPluginsPath += path; } } } diff --git a/far/src/options.cpp b/far/src/options.cpp index 36f88f4f6..772086f56 100644 --- a/far/src/options.cpp +++ b/far/src/options.cpp @@ -342,17 +342,6 @@ void ShellOptions(int LastCommand,MOUSE_EVENT_RECORD *MouseEvent) static int LastHItem=-1,LastVItem=0; int HItem,VItem; - if (Opt.Policies.DisabledOptions) - { - for (size_t I = 0; I < ARRAYSIZE(OptionsMenu); ++I) - { - if (I >= MENU_OPTIONS_CONFIRMATIONS) - OptionsMenu[I].SetGrayed((Opt.Policies.DisabledOptions >> (I-1)) & 1); - else - OptionsMenu[I].SetGrayed((Opt.Policies.DisabledOptions >> I) & 1); - } - } - SetLeftRightMenuChecks(LeftMenu, true); SetLeftRightMenuChecks(RightMenu, false); // Навигация по меню diff --git a/far/src/plug/plugapi.cpp b/far/src/plug/plugapi.cpp index 7544a121b..e2381fb25 100644 --- a/far/src/plug/plugapi.cpp +++ b/far/src/plug/plugapi.cpp @@ -645,10 +645,6 @@ static INT_PTR WINAPI FarAdvControlSynched(INT_PTR ModuleNumber, int Command, vo return Options; } - case ACTL_GETPOLICIES: { - return Opt.Policies.DisabledOptions - | (Opt.Policies.ShowHiddenDrives ? FFPOL_SHOWHIDDENDRIVES : 0); - } case ACTL_REDRAWALL: { auto Area = CtrlObject->Macro.GetArea(); int Ret = FrameManager->ProcessKey(KEY_CONSOLE_BUFFER_RESIZE); diff --git a/far/src/plug/plugins.cpp b/far/src/plug/plugins.cpp index 9d87f7350..32601520d 100644 --- a/far/src/plug/plugins.cpp +++ b/far/src/plug/plugins.cpp @@ -465,8 +465,7 @@ void PluginManager::LoadPlugins() // ...а персональные есть? if (Opt.LoadPlug.PluginsPersonal - && !Opt.LoadPlug.strPersonalPluginsPath.IsEmpty() - && !(Opt.Policies.DisabledOptions & FFPOL_PERSONALPATH)) + && !Opt.LoadPlug.strPersonalPluginsPath.IsEmpty()) { PluginPathList.AddItem(Opt.LoadPlug.strPersonalPluginsPath); } @@ -1270,168 +1269,162 @@ bool PluginManager::CheckIfHotkeyPresent(MENUTYPE MenuType) void PluginManager::Configure(int StartPos) { - // Полиция 4 - Параметры внешних модулей - if (Opt.Policies.DisabledOptions&FFPOL_MAINMENUPLUGINS) - return; + ChangeMacroArea Cma(MACROAREA_MENU); + VMenu PluginList(Msg::PluginConfigTitle,nullptr,0,ScrY-4); + PluginList.SetFlags(VMENU_WRAPMODE); + PluginList.SetHelp(L"PluginsConfig"); + PluginList.SetId(PluginsConfigMenuId); + for (;;) { - ChangeMacroArea Cma(MACROAREA_MENU); - VMenu PluginList(Msg::PluginConfigTitle,nullptr,0,ScrY-4); - PluginList.SetFlags(VMENU_WRAPMODE); - PluginList.SetHelp(L"PluginsConfig"); - PluginList.SetId(PluginsConfigMenuId); + BOOL NeedUpdateItems=TRUE; + int MenuItemNumber=0; - for (;;) + Cma.SetPrevArea(); // for plugins: set the right macro area in GetPluginInfo() + bool HotKeysPresent = CheckIfHotkeyPresent(MTYPE_CONFIGSMENU); + Cma.SetCurArea(); + + if (NeedUpdateItems) { - BOOL NeedUpdateItems=TRUE; - int MenuItemNumber=0; + PluginList.ClearDone(); + PluginList.DeleteItems(); + PluginList.SetPosition(-1,-1,0,0); + MenuItemNumber=0; + LoadIfCacheAbsent(); + FARString strHotKey, strValue, strName; + PluginInfo Info{}; Cma.SetPrevArea(); // for plugins: set the right macro area in GetPluginInfo() - bool HotKeysPresent = CheckIfHotkeyPresent(MTYPE_CONFIGSMENU); - Cma.SetCurArea(); - - if (NeedUpdateItems) + for (int I=0; ICheckWorkFlags(PIWF_CACHED)?true:false; - Cma.SetPrevArea(); // for plugins: set the right macro area in GetPluginInfo() - for (int I=0; IGetPluginInfo(&Info)) { - Plugin *pPlugin = PluginsData[I]; - bool bCached = pPlugin->CheckWorkFlags(PIWF_CACHED)?true:false; + continue; + } - if (!bCached && !pPlugin->GetPluginInfo(&Info)) + for (int J=0; ; J++) + { + if (bCached) { - continue; - } + KeyFileReadSection kfh(PluginsIni(), pPlugin->GetSettingsName()); + const std::string &key = StrPrintf(FmtPluginConfigStringD, J); + if (!kfh.HasKey(key)) + break; - for (int J=0; ; J++) + strName = kfh.GetString(key, ""); + } + else { - if (bCached) - { - KeyFileReadSection kfh(PluginsIni(), pPlugin->GetSettingsName()); - const std::string &key = StrPrintf(FmtPluginConfigStringD, J); - if (!kfh.HasKey(key)) - break; - - strName = kfh.GetString(key, ""); - } - else - { - if (J >= Info.PluginConfigStringsNumber) - break; - - strName = Info.PluginConfigStrings[J]; - } + if (J >= Info.PluginConfigStringsNumber) + break; - const GUID *Guid = pPlugin->IsLuamacro() ? Info.PluginConfigGuids + J : nullptr; - GetPluginHotKey(pPlugin, J, Guid, MTYPE_CONFIGSMENU, strHotKey); - MenuItemEx ListItem; - ListItem.Clear(); + strName = Info.PluginConfigStrings[J]; + } - if (pPlugin->IsOemPlugin()) - ListItem.Flags=LIF_CHECKED|L'A'; + const GUID *Guid = pPlugin->IsLuamacro() ? Info.PluginConfigGuids + J : nullptr; + GetPluginHotKey(pPlugin, J, Guid, MTYPE_CONFIGSMENU, strHotKey); + MenuItemEx ListItem; + ListItem.Clear(); - if (!HotKeysPresent) - ListItem.strName = strName; - else if (!strHotKey.IsEmpty()) - ListItem.strName.Format(L"&%lc%ls %ls",strHotKey.At(0),(strHotKey.At(0)==L'&'?L"&":L""), strName.CPtr()); - else - ListItem.strName.Format(L" %ls", strName.CPtr()); + if (pPlugin->IsOemPlugin()) + ListItem.Flags=LIF_CHECKED|L'A'; - //ListItem.SetSelect(MenuItemNumber++ == StartPos); - MenuItemNumber++; - PluginMenuItemData item; - item.pPlugin = pPlugin; - item.nItem = J; - if (pPlugin->IsLuamacro() && Info.PluginConfigGuids) { - item.Guid = Info.PluginConfigGuids[J]; - } - PluginList.SetUserData(&item, sizeof(PluginMenuItemData),PluginList.AddItem(&ListItem)); + if (!HotKeysPresent) + ListItem.strName = strName; + else if (!strHotKey.IsEmpty()) + ListItem.strName.Format(L"&%lc%ls %ls",strHotKey.At(0),(strHotKey.At(0)==L'&'?L"&":L""), strName.CPtr()); + else + ListItem.strName.Format(L" %ls", strName.CPtr()); + + //ListItem.SetSelect(MenuItemNumber++ == StartPos); + MenuItemNumber++; + PluginMenuItemData item; + item.pPlugin = pPlugin; + item.nItem = J; + if (pPlugin->IsLuamacro() && Info.PluginConfigGuids) { + item.Guid = Info.PluginConfigGuids[J]; } + PluginList.SetUserData(&item, sizeof(PluginMenuItemData),PluginList.AddItem(&ListItem)); } - Cma.SetCurArea(); - - PluginList.AssignHighlights(FALSE); - PluginList.SetBottomTitle(Msg::PluginHotKeyBottom); - PluginList.ClearDone(); - PluginList.SortItems(0,HotKeysPresent?3:0); - PluginList.SetSelectPos(StartPos,1); - NeedUpdateItems=FALSE; } + Cma.SetCurArea(); - FARString strPluginModuleName; - PluginList.Show(); + PluginList.AssignHighlights(FALSE); + PluginList.SetBottomTitle(Msg::PluginHotKeyBottom); + PluginList.ClearDone(); + PluginList.SortItems(0,HotKeysPresent?3:0); + PluginList.SetSelectPos(StartPos,1); + NeedUpdateItems=FALSE; + } - while (!PluginList.Done()) - { - FarKey Key=PluginList.ReadInput(); - int SelPos=PluginList.GetSelectPos(); - PluginMenuItemData *item = (PluginMenuItemData*)PluginList.GetUserData(nullptr,0,SelPos); + FARString strPluginModuleName; + PluginList.Show(); - switch (Key) - { - case KEY_SHIFTF1: - if (item) - { - strPluginModuleName = item->pPlugin->GetModuleName(); - if (!FarShowHelp(strPluginModuleName,L"Config",FHELP_SELFHELP|FHELP_NOSHOWERROR) && - !FarShowHelp(strPluginModuleName,L"Configure",FHELP_SELFHELP|FHELP_NOSHOWERROR)) - { - FarShowHelp(strPluginModuleName,nullptr,FHELP_SELFHELP|FHELP_NOSHOWERROR); - } - } - break; + while (!PluginList.Done()) + { + FarKey Key=PluginList.ReadInput(); + int SelPos=PluginList.GetSelectPos(); + PluginMenuItemData *item = (PluginMenuItemData*)PluginList.GetUserData(nullptr,0,SelPos); - case KEY_F3: - if (item) + switch (Key) + { + case KEY_SHIFTF1: + if (item) + { + strPluginModuleName = item->pPlugin->GetModuleName(); + if (!FarShowHelp(strPluginModuleName,L"Config",FHELP_SELFHELP|FHELP_NOSHOWERROR) && + !FarShowHelp(strPluginModuleName,L"Configure",FHELP_SELFHELP|FHELP_NOSHOWERROR)) { - ShowPluginInfo(item->pPlugin); + FarShowHelp(strPluginModuleName,nullptr,FHELP_SELFHELP|FHELP_NOSHOWERROR); } - break; + } + break; - case KEY_F4: - if (item && PluginList.GetItemCount() > 0 && SelPosstrName.CPtr()+nOffset; - RemoveExternalSpaces(strName00); + case KEY_F3: + if (item) + { + ShowPluginInfo(item->pPlugin); + } + break; - if (SetHotKeyDialog(strName00, item->pPlugin, item->nItem, &item->Guid, MTYPE_CONFIGSMENU)) - { - PluginList.Hide(); - NeedUpdateItems=TRUE; - StartPos=SelPos; - PluginList.SetExitCode(SelPos); - PluginList.Show(); - } + case KEY_F4: + if (item && PluginList.GetItemCount() > 0 && SelPosstrName.CPtr()+nOffset; + RemoveExternalSpaces(strName00); + + if (SetHotKeyDialog(strName00, item->pPlugin, item->nItem, &item->Guid, MTYPE_CONFIGSMENU)) + { + PluginList.Hide(); + NeedUpdateItems=TRUE; + StartPos=SelPos; + PluginList.SetExitCode(SelPos); + PluginList.Show(); } - break; + } + break; - default: - PluginList.ProcessInput(); - break; - } + default: + PluginList.ProcessInput(); + break; } + } - if (!NeedUpdateItems) - { - StartPos=PluginList.Modal::GetExitCode(); - PluginList.Hide(); + if (!NeedUpdateItems) + { + StartPos=PluginList.Modal::GetExitCode(); + PluginList.Hide(); - if (StartPos<0) - break; + if (StartPos<0) + break; - PluginMenuItemData *item = (PluginMenuItemData*)PluginList.GetUserData(nullptr,0,StartPos); - ConfigureCurrent(item->pPlugin, item->nItem, &item->Guid); - } + PluginMenuItemData *item = (PluginMenuItemData*)PluginList.GetUserData(nullptr,0,StartPos); + ConfigureCurrent(item->pPlugin, item->nItem, &item->Guid); } } } diff --git a/luafar/lua_share/far2/test/macrotest.lua b/luafar/lua_share/far2/test/macrotest.lua index b54d4a95b..5ea5cb5c7 100644 --- a/luafar/lua_share/far2/test/macrotest.lua +++ b/luafar/lua_share/far2/test/macrotest.lua @@ -950,8 +950,6 @@ local function test_Far_GetConfig() "PluginConfirmations.Prefix", "PluginConfirmations.SetFindList", "PluginConfirmations.StandardAssociation", - "Policies.DisabledOptions", - "Policies.ShowHiddenDrives", "SavedDialogHistory.HistoryCount", "SavedFolderHistory.HistoryCount", "SavedHistory.HistoryCount",