Skip to content

Commit

Permalink
1. LuaFAR: fix far.AdvControl("ACTL_GETARRAYCOLOR").
Browse files Browse the repository at this point in the history
2. More tests.
  • Loading branch information
shmuz committed Mar 13, 2015
1 parent 13c11b3 commit c40fae3
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 19 deletions.
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 1, 0, 0, 490 },
Version = { 1, 0, 0, 491 },
MinFarVersion = { 3, 0, 0, 4276 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Expand Down
6 changes: 5 additions & 1 deletion plugins/luamacro/changelog
@@ -1,4 +1,8 @@
zg 08.03.2015 02:30:10 +0200 - build 490
shmuel 13.03.2015 16:38:56 +0200 - build 491

1. LuaFAR: неправильно работал far.AdvControl("ACTL_GETARRAYCOLOR").

zg 08.03.2015 02:30:10 +0200 - build 490

1. moonscript 0.3.1.

Expand Down
7 changes: 3 additions & 4 deletions plugins/luamacro/luafar/service.c
Expand Up @@ -4417,10 +4417,9 @@ static int far_AdvControl(lua_State *L)
}
case ACTL_GETARRAYCOLOR:
{
intptr_t size = Info->AdvControl(PluginId, Command, 0, NULL), i;
intptr_t len = size / sizeof(struct FarColor);
struct FarColor *arr = (struct FarColor*) lua_newuserdata(L, size);
Info->AdvControl(PluginId, Command, 0, arr);
intptr_t len = Info->AdvControl(PluginId, Command, 0, NULL), i;
struct FarColor *arr = (struct FarColor*) lua_newuserdata(L, len*sizeof(struct FarColor));
Info->AdvControl(PluginId, Command, len, arr);
lua_createtable(L, (int)len, 0);

for(i=0; i < len; i++)
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luamacro.rc
@@ -1,6 +1,6 @@
#include <farversion.hpp>

#define PLUGIN_BUILD 490
#define PLUGIN_BUILD 491
#define PLUGIN_DESC "Lua Macros for Far Manager"
#define PLUGIN_NAME "LuaMacro"
#define PLUGIN_FILENAME "luamacro.dll"
Expand Down
59 changes: 47 additions & 12 deletions plugins/luamacro/macrotest.lua
Expand Up @@ -1374,44 +1374,79 @@ function MT.test_mantis_1722()
assert(Dlg[1][10] == "W123")
end
local function test_AdvControl()
---------------------------------------------------------------------------------------------------
-- ACTL_GETWINDOWCOUNT, ACTL_GETWINDOWTYPE, ACTL_GETWINDOWINFO, ACTL_SETCURRENTWINDOW, ACTL_COMMIT
---------------------------------------------------------------------------------------------------
local function test_AdvControl_Window()
local num, t
num = far.AdvControl("ACTL_GETWINDOWCOUNT")
assert(num == 2)
mf.acall(far.Show); mf.acall(far.Show)
assert(far.AdvControl("ACTL_GETWINDOWTYPE").Type == F.WTYPE_VMENU)
assert(num+2 == far.AdvControl("ACTL_GETWINDOWCOUNT"))
Keys("Esc Esc")
assert(num == far.AdvControl("ACTL_GETWINDOWCOUNT"))
-- Get information about 2 available windows
t = assert(far.AdvControl("ACTL_GETWINDOWINFO", 1))
assert(t.Type==F.WTYPE_DESKTOP and t.Id==0 and t.Pos==1 and t.Flags==0 and t.TypeName=="Desktop" and
t.Name=="")
t = assert(far.AdvControl("ACTL_GETWINDOWINFO", 2))
assert(t.Type==F.WTYPE_PANELS and t.Id==0 and t.Pos==2 and t.Flags==F.WIF_CURRENT and
t.TypeName=="Panels" and #t.Name>0)
assert(far.AdvControl("ACTL_GETWINDOWTYPE").Type == F.WTYPE_PANELS)
-- Set "Desktop" as the current window
assert(0 < far.AdvControl("ACTL_SETCURRENTWINDOW", 1))
assert(0 < far.AdvControl("ACTL_COMMIT"))
t = assert(far.AdvControl("ACTL_GETWINDOWINFO", 2)) -- "z-order": the window that was #1 is now #2
assert(t.Type==0 and t.Id==0 and t.Pos==2 and t.Flags==F.WIF_CURRENT and t.TypeName=="Desktop" and
t.Name=="")
assert(far.AdvControl("ACTL_GETWINDOWTYPE").Type == F.WTYPE_DESKTOP)
t = assert(far.AdvControl("ACTL_GETWINDOWINFO", 1))
assert(t.Type==F.WTYPE_PANELS and t.Id==0 and t.Pos==1 and t.Flags==0 and t.TypeName=="Panels" and
#t.Name>0)
-- Restore "Panels" as the current window
assert(0 < far.AdvControl("ACTL_SETCURRENTWINDOW", 1))
assert(0 < far.AdvControl("ACTL_COMMIT"))
assert(far.AdvControl("ACTL_GETWINDOWTYPE").Type == F.WTYPE_PANELS)
end
local function test_AdvControl_Misc()
local t
assert(type(far.AdvControl("ACTL_GETFARHWND"))=="userdata")
t = far.AdvControl("ACTL_GETCOLOR",0)
t = assert(far.AdvControl("ACTL_GETCOLOR",0))
assert(t.Flags and t.ForegroundColor and t.BackgroundColor)
t = far.AdvControl("ACTL_GETARRAYCOLOR")[1]
assert(t.Flags and t.ForegroundColor and t.BackgroundColor)
t = assert(far.AdvControl("ACTL_GETARRAYCOLOR"))
assert(#t == 146)
assert(t[1].Flags and t[1].ForegroundColor and t[1].BackgroundColor)
assert(far.AdvControl("ACTL_GETFARMANAGERVERSION"):sub(1,1)=="3")
assert(far.AdvControl("ACTL_GETFARMANAGERVERSION",true)==3)
t = far.AdvControl("ACTL_GETWINDOWINFO")
assert(t.Type and t.Id and t.Pos and t.Flags and t.TypeName and t.Name)
t = far.AdvControl("ACTL_GETFARRECT")
assert(t.Left and t.Top and t.Right and t.Bottom)
t = far.AdvControl("ACTL_GETCURSORPOS")
assert(t.X and t.Y)
t = far.AdvControl("ACTL_GETWINDOWTYPE")
assert(t.Type)
mf.acall(far.AdvControl, "ACTL_WAITKEY", nil, "F1")
assert(true == mf.acall(far.AdvControl, "ACTL_WAITKEY", nil, "F1"))
Keys("F1")
mf.acall(far.AdvControl, "ACTL_WAITKEY")
assert(true == mf.acall(far.AdvControl, "ACTL_WAITKEY"))
Keys("F2")
end
local function test_AdvControl()
test_AdvControl_Window()
test_AdvControl_Misc()
end
local function test_far_GetMsg()
assert(type(far.GetMsg(0))=="string")
end
Expand Down

0 comments on commit c40fae3

Please sign in to comment.