From 56d2e1160f7c9912e9baa9f2857d629e92a35ffc Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Thu, 22 Jun 2017 22:27:57 +0000 Subject: [PATCH] refactoring --- far/PluginA.cpp | 45 ++++++++++++++++++----------------- far/changelog | 4 ++++ far/cmdline.cpp | 20 ++++------------ far/config.cpp | 2 +- far/config.hpp | 4 ++-- far/configdb.cpp | 58 +++++++++++++++++++++++----------------------- far/configdb.hpp | 42 ++++++++++++++++----------------- far/copy.cpp | 4 ++-- far/delete.cpp | 3 +-- far/dialog.cpp | 30 +++++++++++------------- far/editor.cpp | 2 +- far/farexcpt.cpp | 4 ++-- far/farwinapi.hpp | 22 ++++++++++++++---- far/filefilter.cpp | 13 +++++++---- far/filelist.cpp | 18 +++++--------- far/filelist.hpp | 2 +- far/fileowner.cpp | 2 +- far/findfile.cpp | 9 ++++--- far/headers.hpp | 2 ++ far/hilight.cpp | 4 ++-- far/hilight.hpp | 2 +- far/history.cpp | 12 ++++++---- far/history.hpp | 4 ++-- far/interf.cpp | 2 +- far/keyboard.cpp | 10 ++++---- far/main.cpp | 5 ++++ far/panel.hpp | 2 +- far/plclass.cpp | 36 ++++++++++++++-------------- far/plugapi.cpp | 2 +- far/plugins.cpp | 22 ++++++++---------- far/sqlitedb.cpp | 16 ++++++------- far/vbuild.m4 | 2 +- 32 files changed, 207 insertions(+), 198 deletions(-) diff --git a/far/PluginA.cpp b/far/PluginA.cpp index e542286c4a..750fa0af7c 100644 --- a/far/PluginA.cpp +++ b/far/PluginA.cpp @@ -457,7 +457,7 @@ static DWORD OldKeyToKey(DWORD dOldKey) if (CleanKey>0x80 && CleanKey<0x100) { - char OemChar = static_cast(CleanKey); + const auto OemChar = static_cast(CleanKey); wchar_t WideChar = 0; if (encoding::oem::get_chars(&OemChar, 1, &WideChar, 1)) dOldKey = (dOldKey^CleanKey) | WideChar; @@ -483,7 +483,7 @@ static DWORD KeyToOldKey(DWORD dKey) if (CleanKey>0x80 && CleanKey<0x10000) { - wchar_t WideChar = static_cast(CleanKey); + const auto WideChar = static_cast(CleanKey); char OemChar = 0; if (encoding::oem::get_bytes(&WideChar, 1, &OemChar, 1)) dKey = (dKey^CleanKey) | OemChar; @@ -4708,15 +4708,17 @@ static int WINAPI FarViewerControlA(int Command, void* Param) noexcept const auto vspA = static_cast(Param); ViewerSetPosition vsp={sizeof(ViewerSetPosition)}; - vsp.Flags = 0; - if (vspA->Flags&oldfar::VSP_NOREDRAW) vsp.Flags|=VSP_NOREDRAW; - - if (vspA->Flags&oldfar::VSP_PERCENT) vsp.Flags|=VSP_PERCENT; - - if (vspA->Flags&oldfar::VSP_RELATIVE) vsp.Flags|=VSP_RELATIVE; + static const std::pair PluginFlagsMap[] = + { + OLDFAR_TO_FAR_MAP(VSP_NOREDRAW), + OLDFAR_TO_FAR_MAP(VSP_PERCENT), + OLDFAR_TO_FAR_MAP(VSP_RELATIVE), + OLDFAR_TO_FAR_MAP(VSP_NORETNEWPOS), + }; - if (vspA->Flags&oldfar::VSP_NORETNEWPOS) vsp.Flags|=VSP_NORETNEWPOS; + vsp.Flags = VSP_NONE; + FirstFlagsToSecond(vspA->Flags, vsp.Flags, PluginFlagsMap); vsp.StartPos = vspA->StartPos; vsp.LeftPos = vspA->LeftPos; @@ -4809,10 +4811,10 @@ static int WINAPI FarCharTableA(int Command, char *Buffer, int BufferSize) noexc encoding::oem::get_bytes(sTableName, TableSet->TableName); std::unique_ptr us(AnsiToUnicodeBin(reinterpret_cast(TableSet->DecodeTable), std::size(TableSet->DecodeTable), nCP)); - CharLowerBuff(us.get(), static_cast(std::size(TableSet->DecodeTable))); + lower(us.get(), std::size(TableSet->DecodeTable)); encoding::get_bytes(nCP, us.get(), std::size(TableSet->DecodeTable), reinterpret_cast(TableSet->LowerTable), std::size(TableSet->DecodeTable)); - CharUpperBuff(us.get(), static_cast(std::size(TableSet->DecodeTable))); + upper(us.get(), std::size(TableSet->DecodeTable)); encoding::get_bytes(nCP, us.get(), std::size(TableSet->DecodeTable), reinterpret_cast(TableSet->UpperTable), std::size(TableSet->DecodeTable)); MultiByteRecode(static_cast(nCP), CP_OEMCP, reinterpret_cast(TableSet->DecodeTable), std::size(TableSet->DecodeTable)); @@ -4837,19 +4839,16 @@ char* WINAPI XlatA( { try { - DWORD NewFlags = 0; - - if (Flags&oldfar::XLAT_SWITCHKEYBLAYOUT) - NewFlags |= XLAT_SWITCHKEYBLAYOUT; - - if (Flags&oldfar::XLAT_SWITCHKEYBBEEP) - NewFlags |= XLAT_SWITCHKEYBBEEP; - - if (Flags&oldfar::XLAT_USEKEYBLAYOUTNAME) - NewFlags |= XLAT_USEKEYBLAYOUTNAME; + static const std::pair PluginFlagsMap[] = + { + OLDFAR_TO_FAR_MAP(XLAT_SWITCHKEYBLAYOUT), + OLDFAR_TO_FAR_MAP(XLAT_SWITCHKEYBBEEP), + OLDFAR_TO_FAR_MAP(XLAT_USEKEYBLAYOUTNAME), + OLDFAR_TO_FAR_MAP(XLAT_CONVERTALLCMDLINE), + }; - if (Flags&oldfar::XLAT_CONVERTALLCMDLINE) - NewFlags |= XLAT_CONVERTALLCMDLINE; + auto NewFlags = XLAT_NONE; + FirstFlagsToSecond(Flags, NewFlags, PluginFlagsMap); const auto strLine = encoding::oem::get_chars(Line); // XLat expects null-terminated string diff --git a/far/changelog b/far/changelog index 756435150b..188bee7603 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,7 @@ +drkns 22.06.2017 23:26:01 +0000 - build 4977 + +1. Рефакторинг. + drkns 21.06.2017 07:30:17 +0000 - build 4976 1. В некоторых случаях плагин мог вызвать исключение в меню со включенным фильтром. diff --git a/far/cmdline.cpp b/far/cmdline.cpp index 2581a8fa9b..79575d4e5e 100644 --- a/far/cmdline.cpp +++ b/far/cmdline.cpp @@ -254,21 +254,11 @@ bool CommandLine::ProcessKey(const Manager::Key& Key) m_CurCmdStr = CmdStr.GetString(); } - string strStr; - if (LocalKey() == KEY_CTRLE || LocalKey() == KEY_RCTRLE) - { - Global->CtrlObject->CmdHistory->GetPrev(strStr); - } - else - { - Global->CtrlObject->CmdHistory->GetNext(strStr); - } - - { - SCOPED_ACTION(SetAutocomplete)(&CmdStr); - SetString(Global->CtrlObject->CmdHistory->IsOnTop()? m_CurCmdStr : strStr, true); - } - + SCOPED_ACTION(SetAutocomplete)(&CmdStr); + const auto strStr = LocalKey() == KEY_CTRLE || LocalKey() == KEY_RCTRLE? + Global->CtrlObject->CmdHistory->GetPrev() : + Global->CtrlObject->CmdHistory->GetNext(); + SetString(Global->CtrlObject->CmdHistory->IsOnTop()? m_CurCmdStr : strStr, true); } return true; diff --git a/far/config.cpp b/far/config.cpp index 63d372cd6a..78a135d08d 100644 --- a/far/config.cpp +++ b/far/config.cpp @@ -1425,7 +1425,7 @@ static bool ParseIntValue(const string& sValue, long long& iValue) template -bool detail::OptionImpl::ReceiveValue(GeneralConfig* Storage, const string& KeyName, const string& ValueName, const any& Default) +bool detail::OptionImpl::ReceiveValue(const GeneralConfig* Storage, const string& KeyName, const string& ValueName, const any& Default) { base_type CfgValue; const auto Result = Storage->GetValue(KeyName, ValueName, CfgValue, any_cast(Default)); diff --git a/far/config.hpp b/far/config.hpp index ec352684a5..65de88ff77 100644 --- a/far/config.hpp +++ b/far/config.hpp @@ -133,7 +133,7 @@ class Option friend class Options; virtual bool StoreValue(GeneralConfig* Storage, const string& KeyName, const string& ValueName, bool always) const = 0; - virtual bool ReceiveValue(GeneralConfig* Storage, const string& KeyName, const string& ValueName, const any& Default) = 0; + virtual bool ReceiveValue(const GeneralConfig* Storage, const string& KeyName, const string& ValueName, const any& Default) = 0; void MakeUnchanged() { m_Value.forget(); } @@ -171,7 +171,7 @@ namespace detail virtual bool IsDefault(const any& Default) const override { return Get() == any_cast(Default); } virtual void SetDefault(const any& Default) override { Set(any_cast(Default)); } - virtual bool ReceiveValue(GeneralConfig* Storage, const string& KeyName, const string& ValueName, const any& Default) override; + virtual bool ReceiveValue(const GeneralConfig* Storage, const string& KeyName, const string& ValueName, const any& Default) override; virtual bool StoreValue(GeneralConfig* Storage, const string& KeyName, const string& ValueName, bool always) const override; //operator const base_type&() const { return Get(); } diff --git a/far/configdb.cpp b/far/configdb.cpp index 110c606875..1eb808105e 100644 --- a/far/configdb.cpp +++ b/far/configdb.cpp @@ -198,7 +198,7 @@ class iGeneralConfigDb: public GeneralConfig, public SQLiteDb return SetValueT(Key, Name, Value); } - virtual bool GetValue(const string& Key, const string& Name, bool& Value, bool Default) override + virtual bool GetValue(const string& Key, const string& Name, bool& Value, bool Default) const override { long long Data = Default; const auto Result = GetValue(Key, Name, Data, Data); @@ -206,17 +206,17 @@ class iGeneralConfigDb: public GeneralConfig, public SQLiteDb return Result; } - virtual bool GetValue(const string& Key, const string& Name, long long& Value, long long Default) override + virtual bool GetValue(const string& Key, const string& Name, long long& Value, long long Default) const override { return GetValueT(Key, Name, Value, Default, &SQLiteStmt::GetColInt64); } - virtual bool GetValue(const string& Key, const string& Name, string& Value, const wchar_t* Default) override + virtual bool GetValue(const string& Key, const string& Name, string& Value, const wchar_t* Default) const override { return GetValueT(Key, Name, Value, Default, &SQLiteStmt::GetColText); } - virtual bool GetValue(const string& Key, const string& Name, string& Value, const string& Default) override + virtual bool GetValue(const string& Key, const string& Name, string& Value, const string& Default) const override { return GetValueT(Key, Name, Value, Default, &SQLiteStmt::GetColText); } @@ -226,17 +226,17 @@ class iGeneralConfigDb: public GeneralConfig, public SQLiteDb return ExecuteStatement(stmtDelValue, Key, Name); } - virtual bool EnumValues(const string& Key, DWORD Index, string &Name, string &Value) override + virtual bool EnumValues(const string& Key, DWORD Index, string &Name, string &Value) const override { return EnumValuesT(Key, Index, Name, Value, &SQLiteStmt::GetColText); } - virtual bool EnumValues(const string& Key, DWORD Index, string &Name, long long& Value) override + virtual bool EnumValues(const string& Key, DWORD Index, string &Name, long long& Value) const override { return EnumValuesT(Key, Index, Name, Value, &SQLiteStmt::GetColInt64); } - virtual void Export(representation_destination& Representation) override + virtual void Export(representation_destination& Representation) const override { auto& root = CreateChild(Representation.GetRoot(), GetKeyName()); @@ -312,7 +312,7 @@ class iGeneralConfigDb: public GeneralConfig, public SQLiteDb virtual const char* GetKeyName() const = 0; template - bool GetValueT(const string& Key, const string& Name, T& Value, const DT& Default, getter_t Getter) + bool GetValueT(const string& Key, const string& Name, T& Value, const DT& Default, getter_t Getter) const { const auto Stmt = AutoStatement(stmtGetValue); if (!Stmt->Bind(Key, Name).Step() || Stmt->GetColType(0) != TypeId) @@ -335,7 +335,7 @@ class iGeneralConfigDb: public GeneralConfig, public SQLiteDb } template - bool EnumValuesT(const string& Key, DWORD Index, string& Name, T& Value, getter_t Getter) + bool EnumValuesT(const string& Key, DWORD Index, string& Name, T& Value, getter_t Getter) const { auto Stmt = AutoStatement(stmtEnumValues); if (Index == 0) @@ -453,7 +453,7 @@ class HierarchicalConfigDb: public HierarchicalConfig, public SQLiteDb return Key; } - virtual key FindByName(const key& Root, const string& Name) override + virtual key FindByName(const key& Root, const string& Name) const override { const auto Stmt = AutoStatement(stmtFindKey); if (!Stmt->Bind(Root.get(), Name).Step()) @@ -487,17 +487,17 @@ class HierarchicalConfigDb: public HierarchicalConfig, public SQLiteDb return SetValueT(Root, Name, Value); } - virtual bool GetValue(const key& Root, const string& Name, unsigned long long& Value) override + virtual bool GetValue(const key& Root, const string& Name, unsigned long long& Value) const override { return GetValueT(Root, Name, Value, &SQLiteStmt::GetColInt64); } - virtual bool GetValue(const key& Root, const string& Name, string &Value) override + virtual bool GetValue(const key& Root, const string& Name, string &Value) const override { return GetValueT(Root, Name, Value, &SQLiteStmt::GetColText); } - virtual bool GetValue(const key& Root, const string& Name, writable_blob_view& Value) override + virtual bool GetValue(const key& Root, const string& Name, writable_blob_view& Value) const override { return GetValueT(Root, Name, Value, &SQLiteStmt::GetColBlob); } @@ -513,7 +513,7 @@ class HierarchicalConfigDb: public HierarchicalConfig, public SQLiteDb return ExecuteStatement(stmtDelValue, Root.get(), Name); } - virtual bool EnumKeys(const key& Root, DWORD Index, string& Name) override + virtual bool EnumKeys(const key& Root, DWORD Index, string& Name) const override { auto Stmt = AutoStatement(stmtEnumKeys); if (Index == 0) @@ -527,7 +527,7 @@ class HierarchicalConfigDb: public HierarchicalConfig, public SQLiteDb return true; } - virtual bool EnumValues(const key& Root, DWORD Index, string& Name, int& Type) override + virtual bool EnumValues(const key& Root, DWORD Index, string& Name, int& Type) const override { auto Stmt = AutoStatement(stmtEnumValues); if (Index == 0) @@ -542,18 +542,18 @@ class HierarchicalConfigDb: public HierarchicalConfig, public SQLiteDb return true; } - virtual void SerializeBlob(const char* Name, const void* Blob, size_t Size, tinyxml::XMLElement& e) + virtual void SerializeBlob(const char* Name, const void* Blob, size_t Size, tinyxml::XMLElement& e) const { e.SetAttribute("type", "hex"); e.SetAttribute("value", BlobToHexString(Blob, Size).data()); } - virtual void Export(representation_destination& Representation) override + virtual void Export(representation_destination& Representation) const override { Export(Representation, root_key(), CreateChild(Representation.GetRoot(), "hierarchicalconfig")); } - virtual std::vector DeserializeBlob(const char* Name, const char* Type, const char* Value, const tinyxml::XMLElement& e) + virtual std::vector DeserializeBlob(const char* Name, const char* Type, const char* Value, const tinyxml::XMLElement& e) const { return HexStringToBlob(Value); } @@ -567,7 +567,7 @@ class HierarchicalConfigDb: public HierarchicalConfig, public SQLiteDb } } - void Export(representation_destination& Representation, const key& Key, tinyxml::XMLElement& XmlKey) + void Export(representation_destination& Representation, const key& Key, tinyxml::XMLElement& XmlKey) const { { const auto Stmt = AutoStatement(stmtEnumValues); @@ -672,7 +672,7 @@ class HierarchicalConfigDb: public HierarchicalConfig, public SQLiteDb } template - bool GetValueT(const key& Root, const string& Name, T& Value, getter_t Getter) + bool GetValueT(const key& Root, const string& Name, T& Value, getter_t Getter) const { const auto Stmt = AutoStatement(stmtGetValue); if (!Stmt->Bind(Root.get(), Name).Step()) @@ -721,7 +721,7 @@ class HighlightHierarchicalConfigDb: public HierarchicalConfigDb using HierarchicalConfigDb::HierarchicalConfigDb; private: - virtual void SerializeBlob(const char* Name, const void* Blob, size_t Size, tinyxml::XMLElement& e) override + virtual void SerializeBlob(const char* Name, const void* Blob, size_t Size, tinyxml::XMLElement& e) const override { static const char* ColorKeys[] = { @@ -745,7 +745,7 @@ class HighlightHierarchicalConfigDb: public HierarchicalConfigDb } } - virtual std::vector DeserializeBlob(const char* Name, const char* Type, const char* Value, const tinyxml::XMLElement& e) override + virtual std::vector DeserializeBlob(const char* Name, const char* Type, const char* Value, const tinyxml::XMLElement& e) const override { if(!strcmp(Type, "color")) { @@ -807,7 +807,7 @@ class ColorsConfigDb: public ColorsConfig, public SQLiteDb return b; } - virtual bool GetValue(const string& Name, FarColor& Value) override + virtual bool GetValue(const string& Name, FarColor& Value) const override { const auto Stmt = AutoStatement(stmtGetValue); if (!Stmt->Bind(Name).Step()) @@ -820,7 +820,7 @@ class ColorsConfigDb: public ColorsConfig, public SQLiteDb return true; } - virtual void Export(representation_destination& Representation) override + virtual void Export(representation_destination& Representation) const override { auto& root = CreateChild(Representation.GetRoot(), "colors"); @@ -1020,7 +1020,7 @@ class AssociationsConfigDb: public AssociationsConfig, public SQLiteDb return ExecuteStatement(stmtDelType, id); } - virtual void Export(representation_destination& Representation) override + virtual void Export(representation_destination& Representation) const override { auto& root = CreateChild(Representation.GetRoot(), "associations"); @@ -1200,7 +1200,7 @@ class PluginsCacheConfigDb: public PluginsCacheConfig, public SQLiteDb } virtual void Import(const representation_source&) override {} - virtual void Export(representation_destination&) override {} + virtual void Export(representation_destination&) const override {} virtual unsigned long long CreateCache(const string& CacheName) override { @@ -1518,7 +1518,7 @@ class PluginsHotkeysConfigDb: public PluginsHotkeysConfig, public SQLiteDb return ExecuteStatement(stmtDelHotkey, PluginKey, GuidToStr(MenuGuid), as_underlying_type(HotKeyType)); } - virtual void Export(representation_destination& Representation) override + virtual void Export(representation_destination& Representation) const override { auto& root = CreateChild(Representation.GetRoot(), "pluginhotkeys"); @@ -2104,7 +2104,7 @@ class HistoryConfigDb: public HistoryConfigCustom // TODO: log // TODO: implementation virtual void Import(const representation_source&) override {} - virtual void Export(representation_destination&) override {} + virtual void Export(representation_destination&) const override {} }; class HistoryConfigMemory: public HistoryConfigCustom @@ -2117,7 +2117,7 @@ class HistoryConfigMemory: public HistoryConfigCustom private: virtual void Import(const representation_source&) override {} - virtual void Export(representation_destination&) override {} + virtual void Export(representation_destination&) const override {} }; static const std::wregex& uuid_regex() diff --git a/far/configdb.hpp b/far/configdb.hpp index 74ef2d9654..a19c1e8971 100644 --- a/far/configdb.hpp +++ b/far/configdb.hpp @@ -50,7 +50,7 @@ class representable: noncopyable { public: virtual ~representable() = default; - virtual void Export(representation_destination& Representation) = 0; + virtual void Export(representation_destination& Representation) const = 0; virtual void Import(const representation_source& Representation) = 0; }; @@ -70,19 +70,19 @@ class GeneralConfig: public representable, virtual public transactional return SetValue(Key, Name, &Value, sizeof(Value)); } - virtual bool GetValue(const string& Key, const string& Name, bool& Value, bool Default) = 0; - virtual bool GetValue(const string& Key, const string& Name, long long& Value, long long Default) = 0; - virtual bool GetValue(const string& Key, const string& Name, string& Value, const string& Default) = 0; - virtual bool GetValue(const string& Key, const string& Name, string& Value, const wchar_t *Default) = 0; + virtual bool GetValue(const string& Key, const string& Name, bool& Value, bool Default) const = 0; + virtual bool GetValue(const string& Key, const string& Name, long long& Value, long long Default) const = 0; + virtual bool GetValue(const string& Key, const string& Name, string& Value, const string& Default) const = 0; + virtual bool GetValue(const string& Key, const string& Name, string& Value, const wchar_t *Default) const = 0; virtual bool DeleteValue(const string& Key, const string& Name) = 0; - virtual bool EnumValues(const string& Key, DWORD Index, string &strName, string &strValue) = 0; - virtual bool EnumValues(const string& Key, DWORD Index, string &strName, long long& Value) = 0; + virtual bool EnumValues(const string& Key, DWORD Index, string &strName, string &strValue) const = 0; + virtual bool EnumValues(const string& Key, DWORD Index, string &strName, long long& Value) const = 0; template - auto ValuesEnumerator(const string&&) = delete; + auto ValuesEnumerator(const string&&) const = delete; template - auto ValuesEnumerator(const string& Key) + auto ValuesEnumerator(const string& Key) const { using value_type = std::pair; return make_inline_enumerator([this, &Key](size_t Index, value_type& Value) @@ -115,7 +115,7 @@ class HierarchicalConfig: public representable, virtual public transactional, pu virtual void AsyncFinish() = 0; virtual key CreateKey(const key& Root, const string& Name, const string* Description = nullptr) = 0; - virtual key FindByName(const key& Root, const string& Name) = 0; + virtual key FindByName(const key& Root, const string& Name) const = 0; virtual bool SetKeyDescription(const key& Root, const string& Description) = 0; virtual bool SetValue(const key& Root, const string& Name, const string& Value) = 0; @@ -128,11 +128,11 @@ class HierarchicalConfig: public representable, virtual public transactional, pu return SetValue(Root, Name, make_blob_view(Value)); } - virtual bool GetValue(const key& Root, const string& Name, unsigned long long& Value) = 0; - virtual bool GetValue(const key& Root, const string& Name, string &strValue) = 0; - virtual bool GetValue(const key& Root, const string& Name, writable_blob_view& Value) = 0; + virtual bool GetValue(const key& Root, const string& Name, unsigned long long& Value) const = 0; + virtual bool GetValue(const key& Root, const string& Name, string &strValue) const = 0; + virtual bool GetValue(const key& Root, const string& Name, writable_blob_view& Value) const = 0; template::value && !std::is_integral::value)> - bool GetValue(const key& Root, const string& Name, T& Value) + bool GetValue(const key& Root, const string& Name, T& Value) const { static_assert(std::is_pod::value); writable_blob_view Blob(&Value, sizeof(Value)); @@ -141,12 +141,12 @@ class HierarchicalConfig: public representable, virtual public transactional, pu virtual bool DeleteKeyTree(const key& Key) = 0; virtual bool DeleteValue(const key& Root, const string& Name) = 0; - virtual bool EnumKeys(const key& Root, DWORD Index, string &strName) = 0; - virtual bool EnumValues(const key& Root, DWORD Index, string &strName, int& Type) = 0; + virtual bool EnumKeys(const key& Root, DWORD Index, string &strName) const = 0; + virtual bool EnumValues(const key& Root, DWORD Index, string &strName, int& Type) const = 0; virtual bool Flush() = 0; - void KeysEnumerator(const key&&) = delete; - auto KeysEnumerator(const key& Root) + void KeysEnumerator(const key&&) const = delete; + auto KeysEnumerator(const key& Root) const { using value_type = string; return make_inline_enumerator([this, &Root](size_t Index, value_type& Value) @@ -155,8 +155,8 @@ class HierarchicalConfig: public representable, virtual public transactional, pu }); } - void ValuesEnumerator(const key&&) = delete; - auto ValuesEnumerator(const key& Root) + void ValuesEnumerator(const key&&) const = delete; + auto ValuesEnumerator(const key& Root) const { using value_type = std::pair; return make_inline_enumerator([this, &Root](size_t Index, value_type& Value) @@ -187,7 +187,7 @@ class ColorsConfig: public representable, virtual public transactional public: virtual ~ColorsConfig() override = default; virtual bool SetValue(const string& Name, const FarColor& Value) = 0; - virtual bool GetValue(const string& Name, FarColor& Value) = 0; + virtual bool GetValue(const string& Name, FarColor& Value) const = 0; protected: ColorsConfig() = default; diff --git a/far/copy.cpp b/far/copy.cpp index 13409e2e44..83c38f3fa8 100644 --- a/far/copy.cpp +++ b/far/copy.cpp @@ -3207,8 +3207,8 @@ intptr_t ShellCopy::WarnDlgProc(Dialog* Dlg,intptr_t Msg,intptr_t Param1,void* P { if (Param1==WDLG_FILENAME) { - FarColor Color=colors::PaletteColorToFarColor(COL_WARNDIALOGTEXT); - FarDialogItemColors* Colors = static_cast(Param2); + const auto Color = colors::PaletteColorToFarColor(COL_WARNDIALOGTEXT); + const auto Colors = static_cast(Param2); Colors->Colors[0] = Color; Colors->Colors[2] = Color; } diff --git a/far/delete.cpp b/far/delete.cpp index 8fac268f75..f4384c861e 100644 --- a/far/delete.cpp +++ b/far/delete.cpp @@ -335,7 +335,6 @@ ShellDelete::ShellDelete(panel_ptr SrcPanel, bool Wipe): string strDeleteFilesMsg; string strSelName; string strSelShortName; - string strDizName; int DizPresent; int Ret; bool NeedUpdate = true, NeedSetUpADir = false; @@ -544,7 +543,7 @@ ShellDelete::ShellDelete(panel_ptr SrcPanel, bool Wipe): if (UpdateDiz) SrcPanel->ReadDiz(); - SrcPanel->GetDizName(strDizName); + const auto strDizName = SrcPanel->GetDizName(); DizPresent=(!strDizName.empty() && os::fs::exists(strDizName)); NeedSetUpADir = CheckUpdateAnotherPanel(SrcPanel, strSelName); diff --git a/far/dialog.cpp b/far/dialog.cpp index 545f051f55..31bd580b38 100644 --- a/far/dialog.cpp +++ b/far/dialog.cpp @@ -2352,14 +2352,10 @@ long long Dialog::VMProcess(int OpCode,void *vParam,long long iParam) } case MCODE_V_DLGINFOOWNER: // Dlg->Info.Owner { - static string strOwner; - GUID Owner = FarGuid; - if (PluginOwner) - { - Owner = PluginOwner->GetGUID(); - } - strOwner = GuidToStr(Owner); - return reinterpret_cast(UNSAFE_CSTR(strOwner)); + const auto OwnerId = PluginOwner? PluginOwner->GetGUID() : FarGuid; + static string strOwnerId; + strOwnerId = GuidToStr(OwnerId); + return reinterpret_cast(UNSAFE_CSTR(strOwnerId)); } case MCODE_V_ITEMCOUNT: case MCODE_V_CURPOS: @@ -4850,8 +4846,8 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2) { case DM_LISTINFO:// Param1=ID Param2=FarListInfo { - FarListInfo* li=static_cast(Param2); - return CheckStructSize(li)&&ListBox->GetVMenuInfo(li); + const auto li = static_cast(Param2); + return CheckStructSize(li) && ListBox->GetVMenuInfo(li); } case DM_LISTSORT: // Param1=ID Param=Direct {0|1} { @@ -4880,7 +4876,7 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2) } case DM_LISTDELETE: // Param1=ID Param2=FarListDelete: StartIndex=BeginIndex, Count=количество (<=0 - все!) { - FarListDelete *ListItems=(FarListDelete *)Param2; + const auto ListItems = static_cast(Param2); if(CheckNullOrStructSize(ListItems)) { int Count; @@ -4895,15 +4891,15 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2) } case DM_LISTINSERT: // Param1=ID Param2=FarListInsert { - FarListInsert* li=static_cast(Param2); - if (!CheckStructSize(li) || (Ret=ListBox->InsertItem((FarListInsert *)Param2)) == -1) + const auto li = static_cast(Param2); + if (!CheckStructSize(li) || (Ret = ListBox->InsertItem(li)) == -1) return -1; break; } case DM_LISTUPDATE: // Param1=ID Param2=FarListUpdate: Index=Index, Items=Src { - FarListUpdate* lu=static_cast(Param2); + const auto lu = static_cast(Param2); if (CheckStructSize(lu) && ListBox->UpdateItem(lu)) break; @@ -5021,12 +5017,12 @@ intptr_t Dialog::SendMessage(intptr_t Msg,intptr_t Param1,void* Param2) } case DM_LISTGETCURPOS: // Param1=ID Param2=FarListPos { - FarListPos* lp=static_cast(Param2); - return CheckStructSize(lp)?ListBox->GetSelectPos(lp):ListBox->GetSelectPos(); + const auto lp = static_cast(Param2); + return CheckStructSize(lp)? ListBox->GetSelectPos(lp) : ListBox->GetSelectPos(); } case DM_LISTSETCURPOS: // Param1=ID Param2=FarListPos Ret: RealPos { - FarListPos* lp=static_cast(Param2); + const auto lp = static_cast(Param2); if(CheckStructSize(lp)) { /* 26.06.2001 KM Подадим перед изменением позиции об этом сообщение */ diff --git a/far/editor.cpp b/far/editor.cpp index 3d1565d72a..45f22bc088 100644 --- a/far/editor.cpp +++ b/far/editor.cpp @@ -5559,7 +5559,7 @@ int Editor::EditorControl(int Command, intptr_t Param1, void *Param2) } case ECTL_SETPOSITION: { - auto Pos=static_cast(Param2); + auto Pos = static_cast(Param2); if (CheckStructSize(Pos)) { _ECTLLOG(SysLog(L"EditorSetPosition{")); diff --git a/far/farexcpt.cpp b/far/farexcpt.cpp index 8707514168..8236142d8f 100644 --- a/far/farexcpt.cpp +++ b/far/farexcpt.cpp @@ -55,7 +55,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tracer.hpp" #include "string_utils.hpp" -void CreatePluginStartupInfo(const Plugin *pPlugin, PluginStartupInfo *PSI, FarStandardFunctions *FSF); +void CreatePluginStartupInfo(PluginStartupInfo *PSI, FarStandardFunctions *FSF); #define EXCEPTION_MICROSOFT_CPLUSPLUS ((NTSTATUS)0xE06D7363) @@ -327,7 +327,7 @@ static bool ProcessGenericException(const exception_context& Context, const wcha LocalStartupInfo = {}; static FarStandardFunctions LocalStandardFunctions; LocalStandardFunctions = {}; - CreatePluginStartupInfo(nullptr, &LocalStartupInfo, &LocalStandardFunctions); + CreatePluginStartupInfo(&LocalStartupInfo, &LocalStandardFunctions); LocalStartupInfo.ModuleName = Global->Opt->strExceptEventSvc.data(); static PLUGINRECORD PlugRec; diff --git a/far/farwinapi.hpp b/far/farwinapi.hpp index 6c4abe22ff..9da97487c2 100644 --- a/far/farwinapi.hpp +++ b/far/farwinapi.hpp @@ -426,7 +426,10 @@ namespace os } template - bool GetValue(const key& Key, const string& Name, T& Value) { static_assert(detail::is_supported_type::value); return GetValue(Key, Name.data(), Value); } + bool GetValue(const key& Key, const string& Name, T& Value) + { + static_assert(detail::is_supported_type::value); return GetValue(Key, Name.data(), Value); + } template bool GetValue(HKEY RootKey, const wchar_t* SubKey, const wchar_t* Name, T& Value, REGSAM Sam = 0) @@ -437,11 +440,22 @@ namespace os } template - bool GetValue(HKEY RootKey, const string& SubKey, const wchar_t* Name, T& Value, REGSAM Sam = 0) { static_assert(detail::is_supported_type::value); return GetValue(RootKey, SubKey.data(), Name, Value, Sam); } + bool GetValue(HKEY RootKey, const string& SubKey, const wchar_t* Name, T& Value, REGSAM Sam = 0) + { + static_assert(detail::is_supported_type::value); return GetValue(RootKey, SubKey.data(), Name, Value, Sam); + } + template - bool GetValue(HKEY RootKey, const wchar_t* SubKey, const string& Name, T& Value, REGSAM Sam = 0) { static_assert(detail::is_supported_type::value); return GetValue(RootKey, SubKey, Name.data(), Value, Sam); } + bool GetValue(HKEY RootKey, const wchar_t* SubKey, const string& Name, T& Value, REGSAM Sam = 0) + { + static_assert(detail::is_supported_type::value); return GetValue(RootKey, SubKey, Name.data(), Value, Sam); + } + template - bool GetValue(HKEY RootKey, const string& SubKey, const string& Name, T& Value, REGSAM Sam = 0) { static_assert(detail::is_supported_type::value); return GetValue(RootKey, SubKey.data(), Name.data(), Value, Sam); } + bool GetValue(HKEY RootKey, const string& SubKey, const string& Name, T& Value, REGSAM Sam = 0) + { + static_assert(detail::is_supported_type::value); return GetValue(RootKey, SubKey.data(), Name.data(), Value, Sam); + } class enum_key: noncopyable, public enumerator { diff --git a/far/filefilter.cpp b/far/filefilter.cpp index 0301b39cb7..fbe044e0b2 100644 --- a/far/filefilter.cpp +++ b/far/filefilter.cpp @@ -948,16 +948,19 @@ int FileFilter::ParseAndAddMasks(std::list>& Extensions, if (FileName == L"." || TestParentFolderName(FileName) || (FileAttr & FILE_ATTRIBUTE_DIRECTORY)) return -1; - size_t DotPos = FileName.rfind(L'.'); + const auto DotPos = FileName.rfind(L'.'); string strMask; - // Если маска содержит разделитель (',' или ';'), то возьмем ее в кавычки if (DotPos == string::npos) + { strMask = L"*."; - else if (FileName.find_first_of(L",;", DotPos) != string::npos) - strMask.assign(L"\"*", 2).append(FileName, DotPos, string::npos).append(1, '"'); + } else - strMask.assign(1, L'*').append(FileName, DotPos, string::npos); + { + const auto Ext = make_string_view(FileName, DotPos); + // Если маска содержит разделитель (',' или ';'), то возьмем ее в кавычки + strMask = FileName.find_first_of(L",;", DotPos) != string::npos? concat(L"\"*"_sv, Ext, L'"') : concat(L'*', Ext); + } if (std::any_of(CONST_RANGE(Extensions, i) { return equal_icase(i.first, strMask); })) return -1; diff --git a/far/filelist.cpp b/far/filelist.cpp index 741208ca35..90b222dbd9 100644 --- a/far/filelist.cpp +++ b/far/filelist.cpp @@ -203,7 +203,7 @@ static bool CanSort(int SortMode) FileListItem::FileListItem() { - m_Owner.assign(1, values::uninitialised(wchar_t())); + m_Owner = values::uninitialised(wchar_t()); } static string GetItemFullName(const FileListItem& Item, const FileList* Owner) @@ -3462,9 +3462,7 @@ bool FileList::IsSelected(const string& Name) bool FileList::IsSelected(size_t idxItem) { - if (idxItem < m_ListData.size()) // BUGBUG - return m_ListData[idxItem].Selected; // || (Sel!FileCount && idxItem==CurFile) ??? - return false; + return idxItem < m_ListData.size() && m_ListData[idxItem].Selected; // || (Sel!FileCount && idxItem==CurFile) ??? } bool FileList::FilterIsEnabled() @@ -3474,9 +3472,7 @@ bool FileList::FilterIsEnabled() bool FileList::FileInFilter(size_t idxItem) { - if ( ( idxItem < m_ListData.size() ) && ( !m_Filter || !m_Filter->IsEnabledOnPanel() || m_Filter->FileInFilter(&m_ListData[idxItem]) ) ) // BUGBUG, cast - return true; - return false; + return (idxItem < m_ListData.size()) && (!m_Filter || !m_Filter->IsEnabledOnPanel() || m_Filter->FileInFilter(&m_ListData[idxItem])); // BUGBUG, cast } // $ 02.08.2000 IG Wish.Mix #21 - при нажатии '/' или '\' в QuickSerach переходим на директорию @@ -4805,13 +4801,11 @@ void FileList::FlushDiz() } -void FileList::GetDizName(string &strDizName) const +string FileList::GetDizName() const { - if (m_PanelMode == panel_mode::NORMAL_PANEL) - strDizName = Diz.GetDizName(); + return m_PanelMode == panel_mode::NORMAL_PANEL? Diz.GetDizName() : string(); } - void FileList::CopyDiz(const string& Name, const string& ShortName,const string& DestName, const string& DestShortName,DizList *DestDiz) { @@ -5358,7 +5352,7 @@ bool FileList::PopPlugin(int EnableRestoreViewMode) return false; } - const PluginsListItem CurPlugin = std::move(PluginsList.back()); + const auto CurPlugin = std::move(PluginsList.back()); PluginsList.pop_back(); --Global->PluginPanelsCount; diff --git a/far/filelist.hpp b/far/filelist.hpp index 23357e97c8..a5f690ed38 100644 --- a/far/filelist.hpp +++ b/far/filelist.hpp @@ -212,7 +212,7 @@ class FileList:public Panel virtual void ReadDiz(PluginPanelItem *ItemList = nullptr, int ItemLength = 0, DWORD dwFlags = 0) override; virtual void DeleteDiz(const string& Name, const string& ShortName) override; virtual void FlushDiz() override; - virtual void GetDizName(string &strDizName) const override; + virtual string GetDizName() const override; virtual void CopyDiz(const string& Name, const string& ShortName, const string& DestName, const string& DestShortName, DizList *DestDiz) override; virtual bool IsDizDisplayed() const override; virtual bool IsColumnDisplayed(int Type) const override; diff --git a/far/fileowner.cpp b/far/fileowner.cpp index 98455950a3..5a979b42c1 100644 --- a/far/fileowner.cpp +++ b/far/fileowner.cpp @@ -56,7 +56,7 @@ static bool SidToName(PSID Sid, string& Name, const string& Computer) Name.clear(); if (DomainLength) { - Name.assign(DomainName.get(), DomainLength).append(1, L'\\'); + Name = concat(string_view(DomainName.get(), DomainLength), L'\\'); } Name.append(AccountName.get(), AccountLength); return true; diff --git a/far/findfile.cpp b/far/findfile.cpp index a6fdc274e7..ca06582c4b 100644 --- a/far/findfile.cpp +++ b/far/findfile.cpp @@ -145,10 +145,10 @@ class InterThreadData return FindList.size(); } - void GetFindMessage(string& To) const + string GetFindMessage() const { SCOPED_ACTION(os::critical_section_lock)(DataCS); - To=strFindMessage; + return strFindMessage; } void SetFindMessage(const string& From) @@ -1008,7 +1008,7 @@ bool background_searcher::LookForString(const string& Name) // Основной цикл чтения из файла while (!Stopped() && File.Read(readBufferA.data(), (!SearchInFirst || alreadyRead + readBufferA.size() <= SearchInFirst)? readBufferA.size() : SearchInFirst - alreadyRead, readBlockSize)) { - UINT Percents=static_cast(FileSize?alreadyRead*100/FileSize:0); + const auto Percents = static_cast(FileSize? alreadyRead * 100 / FileSize : 0); if (Percents!=LastPercents) { @@ -1362,8 +1362,7 @@ intptr_t FindFiles::FindDlgProc(Dialog* Dlg, intptr_t Msg, intptr_t Param1, void strSearchStr = format(lng::MFindSearchingIn, concat(L'"', strFStr + L'"')); } - string strFM; - itd->GetFindMessage(strFM); + auto strFM = itd->GetFindMessage(); SMALL_RECT Rect; Dlg->SendMessage(DM_GETITEMPOSITION, FD_TEXT_STATUS, &Rect); diff --git a/far/headers.hpp b/far/headers.hpp index 360645a61e..748d01c91f 100644 --- a/far/headers.hpp +++ b/far/headers.hpp @@ -86,6 +86,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include +#include #include #include diff --git a/far/hilight.cpp b/far/hilight.cpp index ae5a38cd02..ec462b9c30 100644 --- a/far/hilight.cpp +++ b/far/hilight.cpp @@ -204,7 +204,7 @@ highlight::configuration::configuration() UpdateCurrentTime(); } -static void LoadFilter(HierarchicalConfig *cfg, const HierarchicalConfig::key& key, FileFilterParams& HData, const string& Mask, int SortGroup, bool bSortGroup) +static void LoadFilter(const HierarchicalConfig* cfg, const HierarchicalConfig::key& key, FileFilterParams& HData, const string& Mask, int SortGroup, bool bSortGroup) { //Дефолтные значения выбраны так чтоб как можно правильней загрузить //настройки старых версий фара. @@ -295,7 +295,7 @@ static void LoadFilter(HierarchicalConfig *cfg, const HierarchicalConfig::key& k HData.SetContinueProcessing(ContinueProcessing!=0); } -void highlight::configuration::InitHighlightFiles(HierarchicalConfig* cfg) +void highlight::configuration::InitHighlightFiles(const HierarchicalConfig* cfg) { const struct { diff --git a/far/hilight.hpp b/far/hilight.hpp index a7a66b0ba9..4bf1a4f67d 100644 --- a/far/hilight.hpp +++ b/far/hilight.hpp @@ -107,7 +107,7 @@ namespace highlight static void ApplyFinalColor(element::colors_array::value_type& Colors, size_t PaletteIndex); private: - void InitHighlightFiles(HierarchicalConfig* cfg); + void InitHighlightFiles(const HierarchicalConfig* cfg); void ClearData(); int MenuPosToRealPos(int MenuPos, int*& Count, bool Insert = false); void FillMenu(VMenu2 *HiMenu, int MenuPos); diff --git a/far/history.cpp b/far/history.cpp index 481f02c97f..6ad287b7ad 100644 --- a/far/history.cpp +++ b/far/history.cpp @@ -552,15 +552,19 @@ history_return_type History::ProcessMenu(string &strStr, GUID* Guid, string *pst return RetCode; } -void History::GetPrev(string &strStr) +string History::GetPrev() { - m_CurrentItem = HistoryCfgRef()->GetPrev(m_TypeHistory, m_HistoryName, m_CurrentItem, strStr); + string Result; + m_CurrentItem = HistoryCfgRef()->GetPrev(m_TypeHistory, m_HistoryName, m_CurrentItem, Result); + return Result; } -void History::GetNext(string &strStr) +string History::GetNext() { - m_CurrentItem = HistoryCfgRef()->GetNext(m_TypeHistory, m_HistoryName, m_CurrentItem, strStr); + string Result; + m_CurrentItem = HistoryCfgRef()->GetNext(m_TypeHistory, m_HistoryName, m_CurrentItem, Result); + return Result; } diff --git a/far/history.hpp b/far/history.hpp index 6490e6b9f5..bc8638ac81 100644 --- a/far/history.hpp +++ b/far/history.hpp @@ -79,8 +79,8 @@ class History: noncopyable void AddToHistory(const string& Str, history_record_type Type = HR_DEFAULT, const GUID* Guid=nullptr, const wchar_t *File=nullptr, const wchar_t *Data=nullptr, bool SaveForbid=false); history_return_type Select(const string& Title, const wchar_t *HelpTopic, string &strStr, history_record_type &Type, GUID* Guid=nullptr, string *File=nullptr, string *Data=nullptr); history_return_type Select(VMenu2 &HistoryMenu, int Height, Dialog *Dlg, string &strStr); - void GetPrev(string &strStr); - void GetNext(string &strStr); + string GetPrev(); + string GetNext(); bool GetSimilar(string &strStr, int LastCmdPartLength, bool bAppend=false); std::vector> GetAllSimilar(const string& Str) const; void SetAddMode(bool EnableAdd, int RemoveDups, bool KeepSelectedPos); diff --git a/far/interf.cpp b/far/interf.cpp index 07cbce0616..f15988f0ea 100644 --- a/far/interf.cpp +++ b/far/interf.cpp @@ -839,7 +839,7 @@ void HiText(const string& Str,const FarColor& HiColor,int isVertText) { const auto SaveColor = CurColor; SetColor(HiColor); - TextFunc(string(1, c)); + TextFunc({ c }); SetColor(SaveColor); }); } diff --git a/far/keyboard.cpp b/far/keyboard.cpp index 87043b373f..22bcdfdb14 100644 --- a/far/keyboard.cpp +++ b/far/keyboard.cpp @@ -1210,7 +1210,7 @@ bool CheckForEsc() using tfkey_to_text = string_view(const TFKey*); using add_separator = void(string&); -static void GetShiftKeyName(string& strName, DWORD Key, tfkey_to_text ToText, add_separator AddSeparator) +static string GetShiftKeyName(DWORD Key, tfkey_to_text ToText, add_separator AddSeparator) { static const std::pair Mapping[] = { @@ -1223,14 +1223,16 @@ static void GetShiftKeyName(string& strName, DWORD Key, tfkey_to_text ToText, ad { KEY_M_OEM, m_oem }, }; + string Result; for (const auto& i: Mapping) { if (Key & i.first) { - AddSeparator(strName); - append(strName, ToText(ModifKeyName + i.second)); + AddSeparator(Result); + append(Result, ToText(ModifKeyName + i.second)); } } + return Result; } @@ -1361,7 +1363,7 @@ bool KeyToTextImpl(int Key0, string& strKeyText, tfkey_to_text ToText, add_separ DWORD Key=(DWORD)Key0, FKey=(DWORD)Key0&0xFFFFFF; - GetShiftKeyName(strKeyText, Key, ToText, AddSeparator); + strKeyText = GetShiftKeyName(Key, ToText, AddSeparator); const auto FKeys1Iterator = std::find(ALL_CONST_RANGE(FKeys1), FKey); if (FKeys1Iterator != std::cend(FKeys1)) diff --git a/far/main.cpp b/far/main.cpp index 4c345b4cd9..1c4c1070db 100644 --- a/far/main.cpp +++ b/far/main.cpp @@ -477,6 +477,11 @@ static int mainImpl(const range& Args) { setlocale(LC_ALL, ""); +#ifdef _MSC_VER + _setmode(_fileno(stdout), _O_U16TEXT); + _setmode(_fileno(stderr), _O_U16TEXT); +#endif + // Must be static - dependent static objects exist static SCOPED_ACTION(os::com::co_initialize); diff --git a/far/panel.hpp b/far/panel.hpp index 562402cfe9..5f4e74bfe2 100644 --- a/far/panel.hpp +++ b/far/panel.hpp @@ -154,7 +154,7 @@ class Panel: public ScreenObject, public std::enable_shared_from_this virtual bool FilterIsEnabled() {return false;} virtual void ReadDiz(PluginPanelItem *ItemList=nullptr,int ItemLength=0, DWORD dwFlags=0) {} virtual void DeleteDiz(const string& Name,const string& ShortName) {} - virtual void GetDizName(string &strDizName) const {} + virtual string GetDizName() const { return {}; } virtual void FlushDiz() {} virtual void CopyDiz(const string& Name,const string& ShortName,const string& DestName, const string& DestShortName,DizList *DestDiz) {} virtual bool IsDizDisplayed() const { return false; } diff --git a/far/plclass.cpp b/far/plclass.cpp index a900864571..7c8b3aec56 100644 --- a/far/plclass.cpp +++ b/far/plclass.cpp @@ -383,27 +383,29 @@ static MacroPrivateInfo MacroInfo = pluginapi::apiCallFar, }; +void CreatePluginStartupInfo(PluginStartupInfo *PSI, FarStandardFunctions *FSF) +{ + *PSI = NativeInfo; + *FSF = NativeFSF; + PSI->FSF = FSF; +} + void CreatePluginStartupInfo(const Plugin* pPlugin, PluginStartupInfo *PSI, FarStandardFunctions *FSF) { - *PSI=NativeInfo; - *FSF=NativeFSF; - PSI->FSF=FSF; + CreatePluginStartupInfo(PSI, FSF); - if (pPlugin) + PSI->ModuleName = pPlugin->GetModuleName().data(); + if (pPlugin->GetGUID() == Global->Opt->KnownIDs.Arclite.Id) { - PSI->ModuleName = pPlugin->GetModuleName().data(); - if (pPlugin->GetGUID() == Global->Opt->KnownIDs.Arclite.Id) - { - PSI->Private = &ArcliteInfo; - } - else if (pPlugin->GetGUID() == Global->Opt->KnownIDs.Netbox.Id) - { - PSI->Private = &NetBoxInfo; - } - else if (pPlugin->GetGUID() == Global->Opt->KnownIDs.Luamacro.Id) - { - PSI->Private = &MacroInfo; - } + PSI->Private = &ArcliteInfo; + } + else if (pPlugin->GetGUID() == Global->Opt->KnownIDs.Netbox.Id) + { + PSI->Private = &NetBoxInfo; + } + else if (pPlugin->GetGUID() == Global->Opt->KnownIDs.Luamacro.Id) + { + PSI->Private = &MacroInfo; } } diff --git a/far/plugapi.cpp b/far/plugapi.cpp index 862fbcbde7..a3b1d0173f 100644 --- a/far/plugapi.cpp +++ b/far/plugapi.cpp @@ -898,7 +898,7 @@ intptr_t WINAPI apiMenuFn( if (Msg!=DN_INPUT || !BreakKeys) return 0; - INPUT_RECORD *ReadRec=static_cast(param); + const auto ReadRec = static_cast(param); int ReadKey=InputRecordToKey(ReadRec); if (ReadKey==KEY_NONE) diff --git a/far/plugins.cpp b/far/plugins.cpp index 054908a716..357d399c66 100644 --- a/far/plugins.cpp +++ b/far/plugins.cpp @@ -84,7 +84,7 @@ static void ReadUserBackgound(SaveScreen *SaveScr) } } -static void GetHotKeyPluginKey(Plugin *pPlugin, string &strPluginKey) +static string GetHotKeyPluginKey(Plugin *pPlugin) { /* FarPath @@ -96,18 +96,17 @@ static void GetHotKeyPluginKey(Plugin *pPlugin, string &strPluginKey) C:\MultiArc\MULTIARC.DLL -> C:\MultiArc\MULTIARC.DLL --------------------------------------------------------------------------------------- */ - strPluginKey = pPlugin->GetHotkeyName(); + auto PluginKey = pPlugin->GetHotkeyName(); #ifndef NO_WRAPPER if (pPlugin->IsOemPlugin() && starts_with_icase(pPlugin->GetModuleName(), Global->g_strFarPath)) - strPluginKey.erase(0, Global->g_strFarPath.size()); + PluginKey.erase(0, Global->g_strFarPath.size()); #endif // NO_WRAPPER + return PluginKey; } static wchar_t GetPluginHotKey(Plugin *pPlugin, const GUID& Guid, hotkey_type HotKeyType) { - string strPluginKey; - GetHotKeyPluginKey(pPlugin, strPluginKey); - const auto strHotKey = ConfigProvider().PlHotkeyCfg()->GetHotkey(strPluginKey, Guid, HotKeyType); + const auto strHotKey = ConfigProvider().PlHotkeyCfg()->GetHotkey(GetHotKeyPluginKey(pPlugin), Guid, HotKeyType); return strHotKey.empty()? L'\0' : strHotKey.front(); } @@ -143,7 +142,7 @@ PluginManager::~PluginManager() std::for_each(CONST_RANGE(SortedPlugins, i) { - if (i->GetGUID() == Global->Opt->KnownIDs.Luamacro.Id) + if (!Luamacro && i->GetGUID() == Global->Opt->KnownIDs.Luamacro.Id) { Luamacro=i; } @@ -1570,9 +1569,8 @@ int PluginManager::CommandsMenu(int ModalType,int StartPos,const wchar_t *Histor bool PluginManager::SetHotKeyDialog(Plugin *pPlugin, const GUID& Guid, hotkey_type HotKeyType, const string& DlgPluginTitle) { - string strPluginKey; - GetHotKeyPluginKey(pPlugin, strPluginKey); - string strHotKey = ConfigProvider().PlHotkeyCfg()->GetHotkey(strPluginKey, Guid, HotKeyType); + const auto strPluginKey = GetHotKeyPluginKey(pPlugin); + auto strHotKey = ConfigProvider().PlHotkeyCfg()->GetHotkey(strPluginKey, Guid, HotKeyType); DialogBuilder Builder(lng::MPluginHotKeyTitle, L"SetHotKeyDialog"); Builder.AddText(lng::MPluginHotKey); @@ -1591,8 +1589,8 @@ bool PluginManager::SetHotKeyDialog(Plugin *pPlugin, const GUID& Guid, hotkey_ty void PluginManager::ShowPluginInfo(Plugin *pPlugin, const GUID& Guid) { - string strPluginGuid = GuidToStr(pPlugin->GetGUID()); - string strItemGuid = GuidToStr(Guid); + const auto strPluginGuid = GuidToStr(pPlugin->GetGUID()); + const auto strItemGuid = GuidToStr(Guid); string strPluginPrefix; if (pPlugin->CheckWorkFlags(PIWF_CACHED)) { diff --git a/far/sqlitedb.cpp b/far/sqlitedb.cpp index 82d4ef7c13..56097f258e 100644 --- a/far/sqlitedb.cpp +++ b/far/sqlitedb.cpp @@ -54,18 +54,16 @@ namespace return components::component::info{ L"SQLite Unicode extension"s, sqlite_unicode::SQLite_Unicode_Version }; }); - static void GetDatabasePath(const string& FileName, string &strOut, bool Local) + static string GetDatabasePath(const string& FileName, bool Local) { if (FileName != L":memory:") { - strOut = Local? Global->Opt->LocalProfilePath : Global->Opt->ProfilePath; - AddEndSlash(strOut); - strOut += FileName; - } - else - { - strOut = FileName; + auto Result = Local? Global->Opt->LocalProfilePath : Global->Opt->ProfilePath; + AddEndSlash(Result); + return Result + FileName; } + + return FileName; } } @@ -207,7 +205,7 @@ bool SQLiteDb::Open(const string& DbFile, bool Local, bool WAL) return sqlite::sqlite3_open_v2(encoding::utf8::get_bytes(Name).data(), &ptr_setter(Db), WAL? SQLITE_OPEN_READWRITE : SQLITE_OPEN_READONLY, nullptr) == SQLITE_OK; }; - GetDatabasePath(DbFile, m_Path, Local); + m_Path = GetDatabasePath(DbFile, Local); const auto mem_db = DbFile == L":memory:"; if (!Global->Opt->ReadOnlyConfig || mem_db) diff --git a/far/vbuild.m4 b/far/vbuild.m4 index 09afa2e8a5..b31fb59a58 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -m4_define(BUILD,4976)m4_dnl +m4_define(BUILD,4977)m4_dnl