Skip to content

Commit

Permalink
LuaFAR: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed May 19, 2024
1 parent e409d24 commit 182f91b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 3, 0, 0, 833 },
Version = { 3, 0, 0, 834 },
MinFarVersion = { 3, 0, 0, 6327 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Expand Down
4 changes: 4 additions & 0 deletions plugins/luamacro/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
shmuel 2024-05-19 17:31:46+03:00 - build 834

1. LuaFAR: refactoring.

shmuel 2024-05-19 11:12:10+03:00 - build 833

1. LuaFAR: refactoring.
Expand Down
24 changes: 12 additions & 12 deletions plugins/luamacro/luafar/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -1702,45 +1702,45 @@ static int far_Menu(lua_State *L)
const GUID* MenuGuid = NULL;
struct FarMenuItem *Items, *pItem;
struct FarKey *pBreakKeys;
lua_settop(L, POS_BKEYS); // cut unneeded parameters; make stack predictable

luaL_checktype(L, POS_PROPS, LUA_TTABLE);
luaL_checktype(L, POS_ITEMS, LUA_TTABLE);
ItemsNumber = lua_objlen(L, POS_ITEMS);

if (!lua_isnil(L,POS_BKEYS) && !lua_istable(L,POS_BKEYS) && lua_type(L,POS_BKEYS)!=LUA_TSTRING)
return luaL_argerror(L, POS_BKEYS, "must be table, string or nil");

lua_settop(L, POS_BKEYS); // cut unneeded parameters; make stack predictable
lua_newtable(L); // temporary store; at stack position 4

// Properties
lua_pushvalue(L, POS_PROPS); //+1
lua_pushvalue(L, POS_PROPS);
X = GetOptIntFromTable(L, "X", -1);
Y = GetOptIntFromTable(L, "Y", -1);
MaxHeight = GetOptIntFromTable(L, "MaxHeight", 0);
lua_getfield(L, POS_PROPS, "Flags"); //+2

lua_getfield(L, POS_PROPS, "Flags");
if (!lua_isnil(L, -1)) Flags = CheckFlags(L, -1);

lua_getfield(L, POS_PROPS, "Title"); //+3

lua_getfield(L, POS_PROPS, "Title");
if (lua_isstring(L,-1)) Title = StoreTempString(L, POS_STORE);

lua_getfield(L, POS_PROPS, "Bottom"); //+3

lua_getfield(L, POS_PROPS, "Bottom");
if (lua_isstring(L,-1)) Bottom = StoreTempString(L, POS_STORE);

lua_getfield(L, POS_PROPS, "HelpTopic"); //+3

lua_getfield(L, POS_PROPS, "HelpTopic");
if (lua_isstring(L,-1)) HelpTopic = StoreTempString(L, POS_STORE);

lua_getfield(L, POS_PROPS, "SelectIndex"); //+3
lua_getfield(L, POS_PROPS, "SelectIndex");
if ((SelectIndex = lua_tointeger(L,-1)) > ItemsNumber)
SelectIndex = 0;

lua_getfield(L, POS_PROPS, "Id"); //+4
lua_getfield(L, POS_PROPS, "Id");
if (lua_type(L,-1)==LUA_TSTRING && lua_objlen(L,-1)==sizeof(GUID))
MenuGuid = (const GUID*)lua_tostring(L, -1);

lua_pop(L, 4);
lua_settop (L, POS_STORE);

// Items
Items = (struct FarMenuItem*)lua_newuserdata(L, ItemsNumber*sizeof(struct FarMenuItem));
memset(Items, 0, ItemsNumber*sizeof(struct FarMenuItem));
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luafar/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include <farversion.hpp>

#define PLUGIN_BUILD 833
#define PLUGIN_BUILD 834

0 comments on commit 182f91b

Please sign in to comment.