Skip to content
Permalink
Browse files

1. 0003514: Возможность задать приоритет макросов, определяемым через…

… MCTL_ADDMACRO.
  • Loading branch information...
zg0 committed Oct 8, 2017
1 parent e776961 commit e214f3636a8e7b8e8d799d94188c414437464bfe
@@ -1,3 +1,7 @@
zg 08.10.2017 14:45:39 +0300 - build 5063

1. 0003514: Возможность задать приоритет макросов, определяемым через MCTL_ADDMACRO.

drkns 06.10.2017 18:12:24 +0100 - build 5062

1. И ещё.
@@ -888,7 +888,7 @@ void KeyMacro::RunStartMacro()
}
}

bool KeyMacro::AddMacro(const GUID& PluginId, const MacroAddMacro* Data)
bool KeyMacro::AddMacro(const GUID& PluginId, const MacroAddMacroV1* Data)
{
if (!(Data->Area >= 0 && (Data->Area < MACROAREA_LAST || Data->Area == MACROAREA_COMMON)))
return false;
@@ -901,6 +901,8 @@ bool KeyMacro::AddMacro(const GUID& PluginId, const MacroAddMacro* Data)
if (Data->Flags & KMFLAGS_ENABLEOUTPUT) Flags |= MFLAGS_ENABLEOUTPUT;
if (Data->Flags & KMFLAGS_NOSENDKEYSTOPLUGINS) Flags |= MFLAGS_NOSENDKEYSTOPLUGINS;

intptr_t Priority = 50;
if (Data->StructSize >= sizeof(MacroAddMacro)) Priority = reinterpret_cast<const MacroAddMacro*>(Data)->Priority;
FarMacroValue values[] = {
(double)Data->Area,
strKeyText,
@@ -910,7 +912,8 @@ bool KeyMacro::AddMacro(const GUID& PluginId, const MacroAddMacro* Data)
Data->Description,
PluginId,
(void*)Data->Callback,
Data->Id
Data->Id,
Priority
};
FarMacroCall fmc = {sizeof(FarMacroCall),std::size(values),values,nullptr,nullptr};
OpenMacroPluginInfo info = {MCT_ADDMACRO,&fmc};
@@ -71,7 +71,7 @@ class KeyMacro: noncopyable
public:
KeyMacro();

static bool AddMacro(const GUID& PluginId,const MacroAddMacro* Data);
static bool AddMacro(const GUID& PluginId,const MacroAddMacroV1* Data);
static bool DelMacro(const GUID& PluginId,void* Id);
static bool ExecuteString(MacroExecuteString *Data);
static bool GetMacroKeyInfo(const string& strArea,int Pos,string &strKeyName,string &strDescription);
@@ -2286,7 +2286,7 @@ intptr_t WINAPI apiMacroControl(const GUID* PluginId, FAR_MACRO_CONTROL_COMMANDS

case MCTL_ADDMACRO:
{
const auto Data = static_cast<const MacroAddMacro*>(Param2);
const auto Data = static_cast<const MacroAddMacroV1*>(Param2);
if (CheckStructSize(Data) && Data->SequenceText && *Data->SequenceText)
{
return Macro.AddMacro(*PluginId, Data) ? 1 : 0;
@@ -1260,6 +1260,20 @@ static const FARADDKEYMACROFLAGS

typedef intptr_t (WINAPI *FARMACROCALLBACK)(void* Id,FARADDKEYMACROFLAGS Flags);

#ifdef FAR_USE_INTERNALS
struct MacroAddMacroV1
{
size_t StructSize;
void* Id;
const wchar_t *SequenceText;
const wchar_t *Description;
FARKEYMACROFLAGS Flags;
INPUT_RECORD AKey;
enum FARMACROAREA Area;
FARMACROCALLBACK Callback;
};
#endif // END FAR_USE_INTERNALS

struct MacroAddMacro
{
size_t StructSize;
@@ -1270,6 +1284,7 @@ struct MacroAddMacro
INPUT_RECORD AKey;
enum FARMACROAREA Area;
FARMACROCALLBACK Callback;
intptr_t Priority;
};

enum FARMACROVARTYPE
@@ -1 +1 @@
m4_define(BUILD,5062)m4_dnl
m4_define(BUILD,5063)m4_dnl
@@ -1,7 +1,7 @@
function export.GetGlobalInfo()
return {
Version = { 1, 0, 0, 620 },
MinFarVersion = { 3, 0, 0, 5047 },
Version = { 1, 0, 0, 621 },
MinFarVersion = { 3, 0, 0, 5063 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Description = "Far macros in Lua",
@@ -1,4 +1,8 @@
shmuel 30.09.2017 14:46:04 +0200 - build 620
zg 08.10.2017 14:46:34 +0300 - build 621

1. 0003514: Возможность задать приоритет макросов, определяемым через MCTL_ADDMACRO.

shmuel 30.09.2017 14:46:04 +0200 - build 620

1. Откат 619, т.к. не учитывается возможность вызова диалога из независимых от плагина lua_State.

@@ -4791,13 +4791,18 @@ static int far_MacroAdd(lua_State* L)
OptInputRecord(L, pd, 3, &data.AKey);
data.SequenceText = check_utf8_string(L, 4, NULL);
data.Description = opt_utf8_string(L, 5, L"");
lua_settop(L, 6);
lua_settop(L, 7);
if (lua_toboolean(L, 6))
{
luaL_checktype(L, 6, LUA_TFUNCTION);
data.Callback = MacroAddCallback;
}
data.Id = lua_newuserdata(L, sizeof(MacroAddData));
data.Priority = 50;
if (lua_isnumber(L, 7))
{
data.Priority = lua_tointeger(L, 7);
}

if (pd->Info->MacroControl(pd->PluginId, MCTL_ADDMACRO, 0, &data))
{
@@ -1,6 +1,6 @@
#include <farversion.hpp>

#define PLUGIN_BUILD 620
#define PLUGIN_BUILD 621
#define PLUGIN_DESC "Lua Macros for Far Manager"
#define PLUGIN_NAME "LuaMacro"
#define PLUGIN_FILENAME "luamacro.dll"
@@ -1061,10 +1061,10 @@ local function ProcessRecordedMacro (Mode, Key, code, flags, description)
end
end

local function AddMacroFromFAR (mode, key, lang, code, flags, description, guid, callback, callbackId)
local function AddMacroFromFAR (mode, key, lang, code, flags, description, guid, callback, callbackId, priority)
local area = GetTrueAreaName(mode)
local m = AddRegularMacro { area=area, key=key, code=code, flags=flags, description=description,
guid=guid, callback=callback, callbackId=callbackId, language=lang }
guid=guid, callback=callback, callbackId=callbackId, language=lang, priority=priority }
local action = m and m.action
if action then
local env = setmetatable({}, gmeta)

0 comments on commit e214f36

Please sign in to comment.
You can’t perform that action at this time.