aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-10-11 15:11:02 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-10-11 15:11:02 -0400
commitfbc722360864470cfe5fc2afafd148e874f40c71 (patch)
treedc383dc98bcfa5872fa18a7e204e75531932c975 /src
parentb235c7d1e3d738d839915ba922b25acea03e182a (diff)
downloadtextadept-fbc722360864470cfe5fc2afafd148e874f40c71.tar.gz
textadept-fbc722360864470cfe5fc2afafd148e874f40c71.zip
gui.dialog() can take tables of strings as arguments.
Diffstat (limited to 'src')
-rw-r--r--src/lua_interface.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lua_interface.c b/src/lua_interface.c
index d954e06e..3c94c6fc 100644
--- a/src/lua_interface.c
+++ b/src/lua_interface.c
@@ -1130,9 +1130,19 @@ static int l_cf_view_goto_buffer(lua_State *lua) {
static int l_cf_gui_dialog(lua_State *lua) {
GCDialogType type = gcocoadialog_type(luaL_checkstring(lua, 1));
- int argc = lua_gettop(lua) - 1;
+ int i, j, k, n = lua_gettop(lua) - 1, argc = n;
+ for (i = 2; i < n + 2; i++)
+ if (lua_type(lua, i) == LUA_TTABLE) argc += lua_objlen(lua, i) - 1;
const char *argv[argc];
- for (int i = 0; i < argc; i++) argv[i] = luaL_checkstring(lua, i + 2);
+ for (i = 0, j = 2; j < n + 2; j++)
+ if (lua_type(lua, j) == LUA_TTABLE) {
+ int len = lua_objlen(lua, j);
+ for (int k = 1; k <= len; k++) {
+ lua_rawgeti(lua, j, k);
+ argv[i++] = luaL_checkstring(lua, j + 1);
+ lua_pop(lua, 1);
+ }
+ } else argv[i++] = luaL_checkstring(lua, j);
char *out = gcocoadialog(type, argc, argv);
lua_pushstring(lua, out);
free(out);