Hello!
In the thread of my text editor philmoz said about the file browser:
There's a file browser already built into CHDK.
I wonder if it would be better to provide methods to call it from within uBasic / Lua scripts rather than write another one inside your editor script?
So I tried. It was very simple to change
core/luascript.c file in the chdk source to provide new function. Changes as follows:
-new includes:
#include "gui_fselect.h"
#include "gui.h"
#include "gui_lang.h"
-new functions (I placed them somewhere above register_func, near line 1950) :
static void file_browser_selected(const char *fn) {
state_kbd_script_run = 1; //browser leaves the keyboard
script_stack_start(); //continue the script
//what to do with fn?
}
static int luaCB_file_browser( lua_State* L ) {
state_kbd_script_run = 0; //script gives the keyboard for the browser
gui_fselect_init(LANG_STR_FILE_BROWSER, "A",file_browser_selected);
lua_pushstring(L, "where can I take the path from?");
return 1;
}
- anf finally new function in
chdk_funcs:
FUNC(file_browser)
I have now the problem. How can I use
lua_pushstring to push the
fn which is believed to contain the string-path of selected file? At the moment new lua command
file_browser() just loads filebrowser and doesn't return fn...