Skip to content

Commit

Permalink
LuaMacro: remove MacroData, add mf.GetPersistent instead
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed Sep 20, 2023
1 parent 53225aa commit a8f5778
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion luafar/lua_share/far2/luacheck_generate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ local function Generate (outname)

self:Insert("\n\n")
self:Insert("local luamacro = {")
self:Insert("globals = { [[MacroData]] };")
self:Insert("read_globals = {")
table.sort(globals_luamacro, NoCaseCmp)
for _,name in ipairs(globals_luamacro) do
Expand Down
Binary file modified luafar/manuals/macroapi_manual_linux.chm
Binary file not shown.
13 changes: 11 additions & 2 deletions luamacro/src/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -675,14 +675,23 @@ function mf.printconsole(...)
far.WriteConsole(text)
end
end

local Persistent = {}
function mf.GetPersistent(field)
assert(type(field)=="string", "arg #1 must be a string")
local t = Persistent[field]
if t == nil then
t = {}
Persistent[field] = t
end
return t
end
--------------------------------------------------------------------------------

_G.band, _G.bnot, _G.bor, _G.bxor, _G.lshift, _G.rshift =
bit64.band, bit64.bnot, bit64.bor, bit64.bxor, bit64.lshift, bit64.rshift

_G.eval, _G.msgbox, _G.prompt = mf.eval, mf.msgbox, mf.prompt

_G.MacroData = {} -- a global table for scripts' data

mf.Keys, mf.exit, mf.print = _G.Keys, _G.exit, _G.print
--------------------------------------------------------------------------------

0 comments on commit a8f5778

Please sign in to comment.