diff --git a/far/changelog b/far/changelog index a4099b8a74..e6aea0855d 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,8 @@ +-------------------------------------------------------------------------------- +shmuel 2023-11-21 20:32:53+02:00 - build 6214 + +1. Far.GetConfig() is implemented entirely in Far.exe (was: Far + LuaMacro). + -------------------------------------------------------------------------------- drkns 2023-11-19 21:55:10+00:00 - build 6213 diff --git a/far/macro.cpp b/far/macro.cpp index d8cb6ee208..e35b598c89 100644 --- a/far/macro.cpp +++ b/far/macro.cpp @@ -3515,43 +3515,52 @@ void FarMacroApi::farcfggetFunc() const return option? PassValue(option->toString()) : PassBoolean(false); } -// V=Far.GetConfig(Key,Name) +// V=Far.GetConfig(Key.Name) void FarMacroApi::fargetconfigFunc() const { - if (mData->Count >= 2 && mData->Values[0].Type==FMVT_STRING && mData->Values[1].Type==FMVT_STRING) + const wchar_t *Keyname = (mData->Count >= 1 && mData->Values[0].Type==FMVT_STRING) ? + mData->Values[0].String : L""; + + auto Dot = wcsrchr(Keyname, L'.'); + if (Dot) { - if (const auto option = Global->Opt->GetConfigValue(mData->Values[0].String, mData->Values[1].String)) + string Key(Keyname, Dot - Keyname); + + if (const auto option = Global->Opt->GetConfigValue(Key.c_str(), Dot+1)) { if (const auto Opt = dynamic_cast(option)) { - PassValue(1); PassBoolean(Opt->Get()); - return; + PassValue(L"boolean"); } - - if (const auto Opt = dynamic_cast(option)) + else if (const auto Opt = dynamic_cast(option)) { - PassValue(2); - PassValue(Opt->Get()); - return; - } + auto Val = Opt->Get(); + if (Val == 0 || Val == 1) + PassBoolean(Val == 1); + else + PassValue(L"other"); - if (const auto Opt = dynamic_cast(option)) + PassValue(L"3-state"); + } + else if (const auto Opt = dynamic_cast(option)) { - PassValue(3); PassValue(Opt->Get()); - return; + PassValue(L"integer"); } - - if (const auto Opt = dynamic_cast(option)) + else if (const auto Opt = dynamic_cast(option)) { - PassValue(4); PassValue(Opt->Get()); - return; + PassValue(L"string"); } + else + PassError(L"unknown option type"); } + else + PassError(L"setting doesn't exist"); } - PassBoolean(false); + else + PassError(L"invalid argument #1"); } // V=Dlg->GetValue([Pos[,InfoID]]) diff --git a/far/vbuild.m4 b/far/vbuild.m4 index e36377c6be..5aecb7d325 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -6213 +6214 diff --git a/plugins/luamacro/_globalinfo.lua b/plugins/luamacro/_globalinfo.lua index d98874b632..dba13eba80 100644 --- a/plugins/luamacro/_globalinfo.lua +++ b/plugins/luamacro/_globalinfo.lua @@ -1,6 +1,6 @@ function export.GetGlobalInfo() return { - Version = { 3, 0, 0, 788 }, + Version = { 3, 0, 0, 789 }, MinFarVersion = { 3, 0, 0, 5171 }, Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"), Title = "LuaMacro", diff --git a/plugins/luamacro/api.lua b/plugins/luamacro/api.lua index 8bf8fb3a0d..68e2ceaee2 100644 --- a/plugins/luamacro/api.lua +++ b/plugins/luamacro/api.lua @@ -4,7 +4,6 @@ local Shared = ... local checkarg, utils, yieldcall = Shared.checkarg, Shared.utils, Shared.yieldcall local MCODE_F_USERMENU = 0x80C66 -local MCODE_F_FAR_GETCONFIG = 0x80C69 local F=far.Flags local band,bor = bit64.band,bit64.bor local MacroCallFar = Shared.MacroCallFar @@ -292,28 +291,12 @@ SetProperties(Menu, { Far = { Cfg_Get = function(...) return MacroCallFar(0x80C58, ...) end, DisableHistory = function(...) return Shared.keymacro.DisableHistory(...) end, + GetConfig = function(...) return MacroCallFar(0x80C69, ...) end, KbdLayout = function(...) return MacroCallFar(0x80C49, ...) end, KeyBar_Show = function(...) return MacroCallFar(0x80C4B, ...) end, Window_Scroll = function(...) return MacroCallFar(0x80C4A, ...) end, } -function Far.GetConfig (keyname) - checkarg(keyname, 1, "string") - local key, name = keyname:match("^(.+)%.([^.]+)$") - if not key then - error("invalid format of arg. #1", 2) - end - local tp,val = MacroCallFar(MCODE_F_FAR_GETCONFIG, key, name) - if not tp then - error("cannot get setting '"..keyname.."'", 2) - end - tp = ({"boolean","3-state","integer","string"})[tp] - if tp == "3-state" then - if val==0 or val==1 then val=(val==1) else val="other" end - end - return val,tp -end - SetProperties(Far, { FullScreen = function() return MacroCallFar(0x80411) end, Height = function() return MacroCallFar(0x80801) end, diff --git a/plugins/luamacro/changelog b/plugins/luamacro/changelog index 2a3d74dc19..bd48c28433 100644 --- a/plugins/luamacro/changelog +++ b/plugins/luamacro/changelog @@ -1,3 +1,7 @@ +shmuel 2023-11-21 20:39:31+02:00 - build 789 + +1. Far.GetConfig() is implemented entirely in Far.exe (was: Far + LuaMacro). + shmuel 2023-11-16 19:03:27+02:00 - build 788 1. LuaFAR: add functions far.CheckMask, far.CmpName, far.CmpNameList, far.GenerateName. diff --git a/plugins/luamacro/luafar/version.h b/plugins/luamacro/luafar/version.h index 50cd2a1e1b..4d8f898fa3 100644 --- a/plugins/luamacro/luafar/version.h +++ b/plugins/luamacro/luafar/version.h @@ -1,3 +1,3 @@ #include -#define PLUGIN_BUILD 788 +#define PLUGIN_BUILD 789