with my last commit, i fixed the IME system to interwork cleanly with menu etc.
(see
https://bitbucket.org/hudson/magic-lantern/commits/7225666a08fe3bcb39f1bc5e23d71b31736111e8 )


the function to be called is:
extern void *ime_base_start (char *caption, char *text, int max_length, int codepage, int charset, t_ime_update_cbr update_cbr, t_ime_done_cbr done_cbr, int x, int y, int w, int h );
if a module wants to have a text enterd by the user, it can now call the ime code like that:
static char text_buffer[100];
IME_UPDATE_FUNC(ime_base_test_update)
{
//bmp_printf(FONT_MED, 30, 90, "ime_base: CBR: <%s>, %d, %d", text, caret_pos, selection_length);
return IME_OK;
}
IME_DONE_FUNC(ime_base_test_done)
{
for(int loops = 0; loops < 50; loops++)
{
bmp_printf(FONT_MED, 30, 120, "ime_base: done: <%s>, %d", text, status);
msleep(100);
}
return IME_OK;
}
static MENU_SELECT_FUNC(ime_base_test)
{
strcpy(text_buffer, "test");
ime_base_start("Enter something:", text_buffer, sizeof(text_buffer), IME_UTF8, IME_CHARSET_ANY, &ime_base_test_update, &ime_base_test_done, 0, 0, 0, 0);
}
the whole thing is running asynchronously. this means you call ime_base_start and that function immediately returns.
it captures all key events and prevents the ML menu to paint.
instead it is showing you a dialog to enter your text.
the specified
update CBR (CallBackRoutine) is called periodically with the current string. it should return IME_OK if the string is acceptable.
(as soon its implemented fully, you can check if it is an valid string, e.g. an email address etc and return a value != IME_OK to grey out the OK button)
when the user selects OK or Cancel, the
done CBR is called with the string and the status IME_OK or IME_CANCEL.
the x, y, w, h parameters are planned to specify the location where the caller code prints the text that is passed via update_cbr.
this way the caller code can care for displaying the text somewhere and the IME just cares for the character selection.
but it is not implemented yet.
the code is still very fragile

i planned to support different charsets, but not sure yet how to implement, or if it is necessary at all.
also the way the characters are displayed and the menu is drawn isnt final yet.
i think i should use canon fonts as they look better.
also the "DEL" function cuts the string at the deleted character. that can be fixed easily by using strncpy.
please test that code and improve it where it needs improvement.
Update (17.08.14)ime_baseime_rotime_stdyou can place both ime_std and ime_rot in your module dir, or one of them - which ever you prefer.
ime_base is always needed for both