diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-23 00:54:35 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-23 00:54:35 +0000 |
commit | 1fde0dd8e4524a60e72419bcb732e8a96d94c3e5 (patch) | |
tree | bd4966589036feecf24f40280dbb5177bc0dd0f5 /apps/plugins | |
parent | 07a6aac401ab28c4beb066072d7e6786148fd57a (diff) | |
download | rockbox-1fde0dd8e4524a60e72419bcb732e8a96d94c3e5.tar.gz rockbox-1fde0dd8e4524a60e72419bcb732e8a96d94c3e5.zip |
Lua: return nil when kbd_input() gets aborted and make it possible to preset the input string (based on FS#10455 by Christophe Gragnic)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22008 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index d6159e0ad3..c6b399c8a5 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -394,12 +394,22 @@ RB_WRAP(kbd_input) | |||
394 | luaL_Buffer b; | 394 | luaL_Buffer b; |
395 | luaL_buffinit(L, &b); | 395 | luaL_buffinit(L, &b); |
396 | 396 | ||
397 | const char *input = luaL_optstring(L, 1, NULL); | ||
397 | char *buffer = luaL_prepbuffer(&b); | 398 | char *buffer = luaL_prepbuffer(&b); |
398 | buffer[0] = '\0'; | ||
399 | rb->kbd_input(buffer, LUAL_BUFFERSIZE); | ||
400 | luaL_addsize(&b, strlen(buffer)); | ||
401 | 399 | ||
402 | luaL_pushresult(&b); | 400 | if(input != NULL) |
401 | rb->strlcpy(buffer, input, LUAL_BUFFERSIZE); | ||
402 | else | ||
403 | buffer[0] = '\0'; | ||
404 | |||
405 | if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE)) | ||
406 | { | ||
407 | luaL_addsize(&b, strlen(buffer)); | ||
408 | luaL_pushresult(&b); | ||
409 | } | ||
410 | else | ||
411 | lua_pushnil(L); | ||
412 | |||
403 | return 1; | 413 | return 1; |
404 | } | 414 | } |
405 | 415 | ||