Skip to content

Commit b4128d4

Browse files
committed
Added Lua script function utils.infotypes
1 parent e362b37 commit b4128d4

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

scripting/lua_utils.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// utils.functionlist
1717
// utils.getfontfamilies
1818
// utils.info
19+
// utils.infotypes
1920
// utils.inputbox
2021
// utils.listbox
2122
// utils.metaphone
@@ -50,6 +51,7 @@
5051
#include <direct.h>
5152

5253
extern char working_dir [_MAX_PATH];
54+
extern tInfoTypeMapping InfoTypes [];
5355

5456
// recursive node outputter
5557
static void xmlOuputNode (lua_State *L, CXMLelement & node)
@@ -894,7 +896,7 @@ CDC dc;
894896
return 1; // one table
895897
} // end of fontpicker
896898

897-
int edit_distance (lua_State *L)
899+
static int edit_distance (lua_State *L)
898900
{
899901
lua_pushinteger (L, EditDistance (luaL_checkstring (L, 1), luaL_checkstring (L, 2)));
900902
return 1;
@@ -1607,7 +1609,7 @@ static int shell_execute (lua_State *L)
16071609
// arg4 is "no sort" boolean
16081610
// arg5 is filter function
16091611

1610-
int filterpicker (lua_State *L)
1612+
static int filterpicker (lua_State *L)
16111613
{
16121614
const char * filtertitle = luaL_optstring (L, 2, "Filter");
16131615
const char * initialfilter = luaL_optstring (L, 3, "");
@@ -1691,7 +1693,7 @@ CFunctionListDlg dlg;
16911693

16921694
} // end of filterpicker
16931695

1694-
int timer (lua_State *L)
1696+
static int timer (lua_State *L)
16951697
{
16961698
if (App.m_iCounterFrequency)
16971699
{
@@ -1707,7 +1709,23 @@ int timer (lua_State *L)
17071709
}
17081710

17091711
return 1; // 1 result
1710-
}
1712+
} // end timer
1713+
1714+
1715+
// returns table of GetInfo selectors and their descriptions
1716+
static int infotypes (lua_State *L)
1717+
{
1718+
lua_newtable(L);
1719+
1720+
for (int iCount = 0; InfoTypes [iCount].iInfoType; iCount++)
1721+
{
1722+
lua_pushstring (L, InfoTypes [iCount].sDescription);
1723+
lua_rawseti(L, -2, InfoTypes [iCount].iInfoType);
1724+
}
1725+
1726+
return 1; // 1 table
1727+
} // end of infotypes
1728+
17111729

17121730
// table of operations
17131731
static const struct luaL_reg xmllib [] =
@@ -1727,6 +1745,7 @@ static const struct luaL_reg xmllib [] =
17271745
{"functionlist", functionlist},
17281746
{"getfontfamilies", getfontfamilies},
17291747
{"info", info},
1748+
{"infotypes", infotypes},
17301749
{"inputbox", inputbox},
17311750
{"listbox", listbox},
17321751
{"metaphone", metaphone},

0 commit comments

Comments
 (0)