diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-07-30 12:47:36 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2024-07-30 14:55:07 -0400 |
commit | e3097bf92c9fc74ed3b724caf338dd24d7f21621 (patch) | |
tree | a35143bc929914630258467cca20880e732ad147 /apps/plugins/lua/rocklua.c | |
parent | ef9490f68329821fc36b2ef9d3c19dc6d7698c55 (diff) | |
download | rockbox-e3097bf92c9fc74ed3b724caf338dd24d7f21621.tar.gz rockbox-e3097bf92c9fc74ed3b724caf338dd24d7f21621.zip |
[Feature] File Picker Plugin
allows viewers to pop a file browser to let the user pick a relevant file
which then gets run by the viewer
(only lua so far)
Change-Id: I7e6b4c2827fab5e9f596d336f546100636c4b871
Diffstat (limited to 'apps/plugins/lua/rocklua.c')
-rw-r--r-- | apps/plugins/lua/rocklua.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/plugins/lua/rocklua.c b/apps/plugins/lua/rocklua.c index 3cf0fce945..650c4d6dae 100644 --- a/apps/plugins/lua/rocklua.c +++ b/apps/plugins/lua/rocklua.c | |||
@@ -241,6 +241,20 @@ static void display_traceback(const char *errstr) | |||
241 | rb->splash(10 * HZ, errstr); | 241 | rb->splash(10 * HZ, errstr); |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | |||
245 | int browse_scripts(void) | ||
246 | { | ||
247 | static char buf[MAX_PATH]; | ||
248 | const char *fname = rb->plugin_get_current_filename(); | ||
249 | /* strip plugin dir to save space in the param buffer */ | ||
250 | if (rb->strncmp(fname, PLUGIN_DIR, sizeof(PLUGIN_DIR) - 1) == 0) | ||
251 | fname += sizeof(PLUGIN_DIR) - 1; /* leave slash */ | ||
252 | /* -r return to this plugin, -f looking for lua files, | ||
253 | -s start in lua_scripts, -d lock to that directory */ | ||
254 | snprintf(buf, sizeof(buf), "-r'%s'-f'.lua'-s'%s'-d", | ||
255 | fname, PLUGIN_DEMOS_DIR"/lua_scripts/"); | ||
256 | return rb->plugin_open(VIEWERS_DIR "/file_picker.rock", buf); | ||
257 | } | ||
244 | /***************** Plugin Entry Point *****************/ | 258 | /***************** Plugin Entry Point *****************/ |
245 | enum plugin_status plugin_start(const void* parameter) | 259 | enum plugin_status plugin_start(const void* parameter) |
246 | { | 260 | { |
@@ -249,7 +263,10 @@ enum plugin_status plugin_start(const void* parameter) | |||
249 | if (parameter == NULL) | 263 | if (parameter == NULL) |
250 | { | 264 | { |
251 | if (!Ls) | 265 | if (!Ls) |
266 | { | ||
252 | rb->splash(HZ, "Play a .lua file!"); | 267 | rb->splash(HZ, "Play a .lua file!"); |
268 | return browse_scripts(); | ||
269 | } | ||
253 | } | 270 | } |
254 | else | 271 | else |
255 | { | 272 | { |