Changeset 1587


Ignore:
Timestamp:
01/20/12 09:10:22 (16 months ago)
Author:
philmoz
Message:

Rework of textbox module interface & charmap handling (for review). Includes ability to call text box from Lua along with test script.

Location:
branches/tbox_test
Files:
3 added
14 edited

Legend:

Unmodified
Added
Removed
  • branches/tbox_test/CHDK/LANG/english.lng

    r1574 r1587  
    587587473 "Options" 
    588588 
    589 474 "Select keyboard profile" 
    590 475 "Load keyboard profile" 
     589474 "Text Box settings" 
     590475 "Select textbox charmap" 
    591591476 "More ->" 
    592592477 "Make dir" 
  • branches/tbox_test/core/action_stack.h

    r1359 r1587  
    2323    AS_SCRIPT_WRITE_USB_MSG, // params: timeout, msg 
    2424    AS_FILE_BROWSER, 
     25    AS_TEXTBOX, 
    2526}; 
    2627 
  • branches/tbox_test/core/conf.c

    r1576 r1587  
    404404        CONF_INFO(249, conf.remote_control_mode,  CONF_DEF_VALUE, i:0, NULL), 
    405405 
    406     // Text Box char map file 
    407     CONF_INFO(250, conf.charmap_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
    408  
    409406   }; 
    410407#define CONF_NUM (sizeof(conf_info)/sizeof(conf_info[0])) 
  • branches/tbox_test/core/gui.c

    r1572 r1587  
    157157static void gui_draw_calendar(int arg); 
    158158#endif 
    159 static void gui_load_charmap(int arg); 
    160159static void gui_draw_load_lang(int arg); 
    161160static void gui_menuproc_mkbootdisk(int arg); 
     
    588587    MENU_ITEM(0x35,LANG_MENU_VIS_MENU_FONT,           MENUITEM_PROC,      gui_draw_load_menu_rbf, 0 ), 
    589588    MENU_ITEM(0x35,LANG_MENU_VIS_MENU_SYMBOL_FONT,    MENUITEM_PROC,      gui_draw_load_symbol_rbf, 0 ), 
    590     MENU_ITEM(0x35,LANG_MENU_VIS_CHARMAP,             MENUITEM_PROC,      gui_load_charmap, 0 ), 
    591     MENU_ITEM(0x80,LANG_MENU_RESET_FILES                 ,         MENUITEM_PROC,          gui_menuproc_reset_files, 0 ), 
    592     MENU_ITEM(0x0,LANG_MENU_VIS_COLORS,              MENUITEM_SEPARATOR, 0, 0 ), 
     589    MENU_ITEM(0x35,LANG_STR_TEXTBOX_SETTINGS,         MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "_tbox.flt" ), 
     590    MENU_ITEM(0x80,LANG_MENU_RESET_FILES,             MENUITEM_PROC,       gui_menuproc_reset_files, 0 ), 
     591    MENU_ITEM(0x0,LANG_MENU_VIS_COLORS,               MENUITEM_SEPARATOR, 0, 0 ), 
    593592    MENU_ITEM(0x65,LANG_MENU_VIS_OSD_TEXT,            MENUITEM_COLOR_FG,  &conf.osd_color, 0 ), 
    594593    MENU_ITEM(0x65,LANG_MENU_VIS_OSD_BKG,             MENUITEM_COLOR_BG,  &conf.osd_color, 0 ), 
     
    14091408conf.menu_symbol_rbf_file[0] = 0; 
    14101409conf.menu_rbf_file[0] = 0; 
    1411 conf.charmap_file[0] = 0; 
    14121410conf_save(); 
    14131411gui_mbox_init(LANG_INFORMATION, LANG_MENU_RESTART_CAMERA, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
     
    25872585} 
    25882586 
    2589 static void gui_charmap_selected(const char *fn) { 
    2590     if (fn) 
    2591         strcpy(conf.charmap_file, fn); 
    2592 } 
    2593 static void gui_load_charmap(int arg) { 
    2594     module_fselect_init(LANG_STR_SELECT_CHARMAP_FILE, conf.charmap_file, "A/CHDK", gui_charmap_selected); 
    2595 } 
    2596  
    25972587CMenuItem* find_mnu(CMenu *curr_menu, int itemid ) 
    25982588{ 
  • branches/tbox_test/core/gui_fselect.c

    r1574 r1587  
    11051105} 
    11061106 
    1107 static void mkdir_cb(char* name) 
     1107static void mkdir_cb(const char* name) 
    11081108{ 
    11091109        if (name) { 
     
    11151115} 
    11161116 
    1117 static void rename_cb(char* name) 
     1117static void rename_cb(const char* name) 
    11181118{ 
    11191119        if (name) { 
     
    11311131    switch (actn) { 
    11321132            case MPOPUP_MKDIR: 
    1133                         module_tbox_run( LANG_POPUP_MKDIR, LANG_PROMPT_MKDIR, "", 15, mkdir_cb); 
     1133            if (module_tbox_load()) 
     1134                module_tbox_load()->textbox_init(LANG_POPUP_MKDIR, LANG_PROMPT_MKDIR, "", 15, mkdir_cb); 
    11341135            break; 
    11351136        case MPOPUP_RMDIR: 
     
    11371138            break; 
    11381139        case MPOPUP_RENAME: 
    1139                         module_tbox_run( LANG_POPUP_RENAME, LANG_PROMPT_RENAME, selected->name, 15, rename_cb); 
     1140            if (module_tbox_load()) 
     1141                module_tbox_load()->textbox_init(LANG_POPUP_RENAME, LANG_PROMPT_RENAME, selected->name, 15, rename_cb); 
    11401142            break; 
    11411143        } 
     
    12931295        case KEY_LEFT: 
    12941296            if (selected && selected->attr != 0xFF) { 
    1295                 i=MPOPUP_CUT|MPOPUP_COPY|MPOPUP_SELINV; 
    1296                                 mpopup_rawop_flag=0; 
     1297                i=MPOPUP_CUT|MPOPUP_COPY|MPOPUP_SELINV|MPOPUP_MORE; 
     1298                mpopup_rawop_flag=0; 
    12971299                if (fselect_marked_count() > 0) { 
    12981300                    i |= MPOPUP_DELETE; 
     
    13041306                } 
    13051307 
    1306                                 if ( API_VERSION_MATCH_REQUIREMENT( module_tbox_get_version(), 1, 0 ) )  
    1307                                                 i |= MPOPUP_MORE; 
    1308  
    13091308                if (marked_operation == MARKED_OP_CUT || marked_operation == MARKED_OP_COPY) 
    13101309                    i |= MPOPUP_PASTE; 
    13111310                if (!(selected->attr & DOS_ATTR_DIRECTORY) || !(selected->name[0] == '.' && selected->name[1] == '.' && selected->name[2] == 0) ||//If item is not a folder or UpDir 
    1312                      (selected->name[0] == 'D' && selected->name[1] == 'C' && selected->name[2] == 'I' && selected->name[3] == 'M') ||//If item is DCIM folder 
    1313                      (selected->name[3] == 'C'))//If item is a DCIM sub folder 
     1311                    (selected->name[0] == 'D' && selected->name[1] == 'C' && selected->name[2] == 'I' && selected->name[3] == 'M') ||//If item is DCIM folder 
     1312                    (selected->name[3] == 'C'))//If item is a DCIM sub folder 
    13141313                    i |= MPOPUP_PURGE;//Display PURGE RAW function in popup menu 
    13151314                if(selected->size == hook_raw_size()) 
    13161315                    mpopup_rawop_flag |= MPOPUP_RAW_DEVELOP; 
    13171316 
    1318                                 if ( module_convert_dng_to_chdk_raw(0) )        // if dng module exist 
    1319                 if((fselect_marked_count()>1)||(selected->size > hook_raw_size())) 
    1320                         mpopup_rawop_flag |= MPOPUP_DNG_TO_CRW; 
    1321  
    1322                 if (selected->name[9] == 'B' && selected->name[10] == 'I' && selected->name[11] == 'N') //If item is DCIM folder 
     1317                if ( module_convert_dng_to_chdk_raw(0) )        // if dng module exist 
     1318                    if((fselect_marked_count()>1)||(selected->size > hook_raw_size())) 
     1319                        mpopup_rawop_flag |= MPOPUP_DNG_TO_CRW; 
     1320 
     1321                if (selected->name[9] == 'B' && selected->name[10] == 'I' && selected->name[11] == 'N') //If item is DCIM folder 
    13231322                    i |= MPOPUP_CHDK_REPLACE; 
    13241323 
    1325                                 if ( mpopup_rawop_flag ) 
    1326                                         i |= MPOPUP_RAWOPS; 
    1327  
    1328  
    1329                                 mpopup_more_flag = MPOPUP_MKDIR; 
    1330                                 if (selected->attr & DOS_ATTR_DIRECTORY) 
    1331                         mpopup_more_flag |=MPOPUP_RMDIR; 
     1324                if ( mpopup_rawop_flag ) 
     1325                    i |= MPOPUP_RAWOPS; 
     1326 
     1327 
     1328                mpopup_more_flag = MPOPUP_MKDIR; 
     1329                if (selected->attr & DOS_ATTR_DIRECTORY) 
     1330                    mpopup_more_flag |=MPOPUP_RMDIR; 
    13321331                if ( !(selected->name[0] == '.' && selected->name[1] == '.' && selected->name[2] == 0) ) //If item is not UpDir 
    1333                         mpopup_more_flag |=MPOPUP_RENAME; 
     1332                    mpopup_more_flag |=MPOPUP_RENAME; 
    13341333 
    13351334                module_mpopup_init( popup, i, fselect_mpopup_cb, 0); 
     
    14551454  module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
    14561455 
    1457   if ( argn == 5 ) { 
    1458   gui_fselect_init( arguments[0], (const char*) arguments[1], (const char*) arguments[2], (void*)arguments[3]); 
    1459   gui_fselect_set_key_redraw(arguments[4]); 
     1456  if ( argn == 5 ) 
     1457  { 
     1458      gui_fselect_init( arguments[0], (const char*) arguments[1], (const char*) arguments[2], (void*)arguments[3]); 
     1459      gui_fselect_set_key_redraw(arguments[4]); 
    14601460  } 
    14611461  else 
    1462     gui_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 
     1462      gui_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 
    14631463 
    14641464  return 0; 
  • branches/tbox_test/core/gui_lang.h

    r1574 r1587  
    594594#define LANG_MENU_REMOTE_OPTIONS 473 
    595595 
    596 #define LANG_STR_SELECT_CHARMAP_FILE  474 
     596#define LANG_STR_TEXTBOX_SETTINGS   474 
    597597#define LANG_MENU_VIS_CHARMAP           475 
    598598#define LANG_POPUP_MORE                         476 
  • branches/tbox_test/core/gui_tbox.c

    r1569 r1587  
    88#include "gui_draw.h" 
    99#include "gui_lang.h" 
     10#include "gui_menu.h" 
    1011#include "gui_mbox.h" 
     12#include "gui_tbox.h" 
    1113 
    1214#include "module_load.h" 
    1315 
     16//------------------------------------------------------------------- 
     17// Zebra config settings 
     18 
     19typedef struct 
     20{ 
     21    int char_map; 
     22} TextBoxConf; 
     23 
     24TextBoxConf tconf; 
     25 
     26static ConfInfo conf_info[] = { 
     27    CONF_INFO( 1, tconf.char_map,               CONF_DEF_VALUE, i:0, NULL), 
     28}; 
     29 
     30//------------------------------------------------------------------- 
    1431extern void gui_tbox_kbd_process(); 
    1532extern void gui_tbox_draw(int enforce_redraw); 
     
    5370#define MAX_MSG_LENGH           20  //max length of hardcoded messages (>navigate cursor<, text limit reached) 
    5471 
    55 typedef void (*tbox_on_select_t)(char* newstr); 
     72typedef void (*tbox_on_select_t)(const char* newstr); 
    5673tbox_on_select_t tbox_on_select = 0; 
    5774 
    5875static coord    tbox_buttons_x, tbox_buttons_y; 
    5976 
    60 // 
    61 const char *tbox_chars_default[] = {"ABCDEF|GHIJKL|MNOPQRS|TUVWXYZ", 
    62                             "abcdef|ghijkl|mnopqrs|tuvwxyz", 
    63                             "123|456|789|0+-=/", 
    64                             ".,:;?!|@#$%^&|()[]{}|<>\"'`~", 
    65                             0 }; 
    66  
    67 const char *tbox_chars[MAX_CHARSET+1]; // current char map (array of string. separator of groups is '|') 
    68 int lines = 0;                         // num of valid lines in tbox_chars 
    69 int subgroup_offs[4];                  // offsets of subgroups in currently selected line of tbox_chars 
     77// Char maps 
     78const char *tbox_chars_default[] =  
     79    { 
     80        "ABCDEF|GHIJKL|MNOPQRS|TUVWXYZ", 
     81        "abcdef|ghijkl|mnopqrs|tuvwxyz", 
     82        "123|456|789|0+-=/", 
     83        ".,:;?!|@#$%^&|()[]{}|<>\"'`~", 
     84        0 
     85    }; 
     86const char *tbox_chars_russian[] = 
     87    { 
     88        "ABCDEF|GKLHIJ|MNOPQRS|TUVWXYZ", 
     89        "abcdef|ghijkl|mnopqrs|tuvwxyz", 
     90        "ÀÁÂÃÄÅÆ|ÇÈÉÊËÌÍ|ÎÏÐÑÒÓÔ|ÕÖרÙÛÜÝÞß", 
     91        "àáâãäåæ|çèéêëìí|îïðñòóô|õö÷øùûüýþÿ", 
     92        "123|456|789|0+-=", 
     93        " .:,|;/\\|'\"*|#%&", 
     94        0 
     95    }; 
     96 
     97const char **charmaps[] = { tbox_chars_default, tbox_chars_russian }; 
     98 
     99const char **tbox_chars;    // current char map (array of string. separator of groups is '|') 
     100int lines = 0;              // num of valid lines in tbox_chars 
     101int subgroup_offs[4];       // offsets of subgroups in currently selected line of tbox_chars 
    70102 
    71103 
     
    81113 
    82114//------------------------------------------------------- 
    83 static void tbox_charmap_init( char* buffer, int buffer_size) 
    84 { 
    85   int i, size; 
    86  
    87   lines=0; 
    88   memset( tbox_chars, 0, sizeof(tbox_chars) ); 
    89  
    90   lines = 0; 
    91   for ( i=0; i<buffer_size && lines<MAX_CHARSET;) 
     115static void tbox_charmap_init( const char** buffer ) 
     116{ 
     117  max_keyboard_lenght = 0; 
     118  tbox_chars = buffer; 
     119 
     120  for (lines=0; tbox_chars[lines] && lines<MAX_CHARSET; lines++) 
    92121  { 
    93      size = strlen(buffer+i); 
    94      if ( size > 0 ) 
    95         tbox_chars[lines++]=(buffer+i); 
    96         if (max_keyboard_lenght<size) max_keyboard_lenght=size; 
    97      i+=size+1; 
    98   } 
    99  
    100   if ( lines>0 ) 
    101     return; 
    102  
    103  
    104   for (lines=0;lines<MAX_CHARSET;lines++) { 
    105     tbox_chars[lines] = tbox_chars_default[lines]; 
    106     if ( tbox_chars[lines]==0 ) 
    107       break; 
    108     if (max_keyboard_lenght<strlen(tbox_chars[lines])) max_keyboard_lenght=strlen(tbox_chars[lines]); 
     122    if (max_keyboard_lenght < strlen(tbox_chars[lines]))  
     123        max_keyboard_lenght = strlen(tbox_chars[lines]); 
    109124  } 
    110125} 
     
    125140 
    126141 
    127  
    128 void gui_tbox_init(int title, int msg, char* defaultstr, unsigned int maxsize, void (*on_select)(char* newstr)) { 
     142int textbox_init(int title, int msg, char* defaultstr, unsigned int maxsize, void (*on_select)(const char* newstr)) { 
     143 
    129144    text = malloc(sizeof(char)*(maxsize+1)); 
    130145    if ( text==0 ) { 
     
    133148            tbox_on_select(0);    // notify callback about exit as cancel 
    134149        module_async_unload(module_idx); 
    135         return; 
    136     } 
     150        return 0; 
     151    } 
     152 
     153    tbox_charmap_init( charmaps[tconf.char_map] ); 
    137154 
    138155    memset(text, '\0', sizeof(char)*(maxsize+1)); 
     
    146163    tbox_msg = lang_str(msg); 
    147164    tbox_on_select = on_select; 
    148     gui_tbox_mode_old = gui_set_mode( &GUI_MODE_TBOX ); 
    149165 
    150166    Mode = 'K'; 
     
    157173 
    158174    gui_tbox_redraw = 2; 
     175    gui_tbox_mode_old = gui_set_mode( &GUI_MODE_TBOX ); 
     176 
     177    return 1; 
    159178} 
    160179 
     
    521540                    else { 
    522541                        free(text); 
     542                        text = 0; 
    523543                        tbox_on_select(0); // cancel 
    524544                    } 
     
    536556 
    537557 
    538 // DEBUG TEST CALLBACK 
    539 void test_callback(char* txt ) 
    540 { 
    541     if ( txt==0 )    // cancel 
    542     { 
    543         gui_mbox_init(139, 139, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
    544     } 
    545     else        //ok 
    546     { 
    547         gui_mbox_init(138, (int)txt, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
    548         // should be free in real callback but here should be kept to correct mbox 
    549     } 
    550 } 
     558//------------------------------------------------------------------- 
     559 
     560static const char* gui_text_box_charmap[] = { "Default", "Russian" }; 
     561static CMenuItem zebra_submenu_items[] = { 
     562    MENU_ENUM2(0x5f,LANG_MENU_VIS_CHARMAP,              &tconf.char_map, gui_text_box_charmap ), 
     563    MENU_ITEM(0x51,LANG_MENU_BACK,                      MENUITEM_UP, 0, 0 ), 
     564    {0} 
     565}; 
     566static CMenu textbox_submenu = {0x26,LANG_STR_TEXTBOX_SETTINGS, NULL, zebra_submenu_items }; 
    551567 
    552568 
    553569//================================================== 
     570 
     571struct libtextbox_sym libtextbox = { 
     572    MAKE_API_VERSION(1,0),              // apiver: increase major if incompatible changes made in module,  
     573                                                            // increase minor if compatible changes made(including extending this struct) 
     574    textbox_init, 
     575}; 
     576 
     577 
     578void* MODULE_EXPORT_LIST[] = { 
     579        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     580        /* 1 */ (void*)1, 
     581 
     582                        &libtextbox 
     583                }; 
    554584 
    555585 
     
    568598      return 1; 
    569599 
     600  config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/_tbox.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 
    570601  cl_greygrey = MAKE_COLOR(COLOR_GREY, COLOR_GREY); 
    571602 
    572603  return 0; 
    573604} 
    574  
    575605 
    576606 
     
    581611int _module_unloader() 
    582612{ 
     613    config_save(&conf_info[0], "A/CHDK/MODULES/CFG/_tbox.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 
     614 
    583615    // clean allocated resource 
    584     if ( text!=0 ) { 
     616    if ( text!=0 ) 
     617    { 
    585618        free(text); 
    586         if (tbox_on_select) 
    587             tbox_on_select(0);    // notify callback about exit as cancel 
    588     } 
    589  
     619        text = 0; 
     620    } 
    590621 
    591622    //sanity clean to prevent accidentaly assign/restore guimode to unloaded module 
     
    604635  module_idx=moduleidx; 
    605636 
    606  
    607   // DEBUG CASE 
    608   if ( argn==0 ) { 
    609       tbox_charmap_init( 0,0 ); 
    610  
    611         gui_tbox_init( 137 /*title*/, 137 /*msg*/, (char*)NULL /*defaultstr*/, 
    612                  50 /*maxsize*/, test_callback /* on_select */); 
    613     return 0; 
    614  
    615   } 
    616  
    617   // "Run scenario #1" - no arguments request for keyboard API version 
    618   if ( argn!=7 || arguments==0 || arguments[6]==0) 
    619   { 
    620     module_async_unload(moduleidx); 
    621     return MAKE_API_VERSION(1,0); 
    622   } 
    623  
    624   // Autounloading is unsafe because it should exists to catch finalization of mpopup 
    625   //module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
    626  
    627   tbox_charmap_init( (char*)arguments[0] /*charmap_buffer*/, arguments[1] /*charmap_size*/); 
    628  
    629   gui_tbox_init( arguments[2] /*title*/, arguments[3] /*msg*/, (char*)arguments[4] /*defaultstr*/, 
    630                  arguments[5] /*maxsize*/, (tbox_on_select_t) arguments[6] /* on_select */); 
     637  gui_activate_sub_menu(&textbox_submenu, module_idx); 
    631638 
    632639  return 0; 
     
    639646                                    sizeof(struct ModuleInfo), 
    640647 
    641                                     ANY_CHDK_BRANCH, 0,            // Requirements of CHDK version 
    642                                     ANY_PLATFORM_ALLOWED,        // Specify platform dependency 
    643                                     0,    // MODULEINFO_FLAG_SYSTEM,            // flag 
     648                                    ANY_CHDK_BRANCH, 0,             // Requirements of CHDK version 
     649                                    ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     650                                    MODULEINFO_FLAG_SYSTEM,         // flag 
    644651                                    (int32_t)"Virtual keyboard",    // Module name 
    645                                     1, 0,                        // Module version 
     652                                    1, 0,                           // Module version 
    646653                                    0 
    647654                                 }; 
  • branches/tbox_test/core/luascript.c

    r1570 r1587  
    817817} 
    818818 
    819 static void file_browser_selected(const char *fn) { 
     819static void return_string_selected(const char *str) { 
    820820    // Reconnect button input to script - will also signal action stack 
    821     // that file browser is finished and return last selected file 
     821    // that file browser / textbox is finished and return last selected file 
    822822    // to script caller 
    823823    state_kbd_script_run = 1; 
    824824    // Clear the Func/Set key so that when the script exits, pressing 
    825     // the Func/Set key again will enter the Script menu, not the File Browser 
     825    // the Func/Set key again will enter the Script menu, not the File Browser / Textbox 
    826826    kbd_reset_autoclicked_key(); 
    827827 
    828828    // Push selected file as script return value 
    829         lua_pushstring( Lt, (fn && fn[0])? fn : NULL ); 
     829        lua_pushstring( Lt, (str && str[0])? str : NULL ); 
    830830} 
    831831 
     
    836836    action_push(AS_FILE_BROWSER); 
    837837    // Switch to file browser gui mode. Path can be supplied in call or defaults to "A" (root directory). 
    838     module_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", file_browser_selected); 
     838    module_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", return_string_selected); 
    839839    // Yield the script so that the action stack will process the AS_FILE_BROWSER action 
     840    return lua_yield(L, 0); 
     841} 
     842 
     843static int luaCB_textbox( lua_State* L ) { 
     844    // Disconnect button input from script so buttons will work in the textbox 
     845    state_kbd_script_run = 0; 
     846    if (module_tbox_load()) 
     847    { 
     848        // Push textbox action onto stack - will loop doing nothing until textbox exits 
     849        action_push(AS_TEXTBOX); 
     850        // Switch to textbox gui mode. Text box prompt should be passed as param. 
     851        module_tbox_load()->textbox_init((int)luaL_optstring( L, 1, "A" ), (int)luaL_optstring( L, 1, "A" ), "", 30, return_string_selected); 
     852    } 
     853    else 
     854        return_string_selected(0); 
     855 
     856    // Yield the script so that the action stack will process the AS_TEXTBOX action 
    840857    return lua_yield(L, 0); 
    841858} 
     
    21312148 
    21322149    if(strcmp(heapname,"system") == 0) { 
    2133 #if defined(CAM_FIRMWARE_MEMINFO) 
    21342150        GetMemInfo(&meminfo); 
    2135 #else 
    2136         memset(&meminfo,0xFF,sizeof(cam_meminfo)); 
    2137         meminfo.free_block_max_size = core_get_free_memory(); 
    2138 #endif 
    21392151    } 
    21402152#if defined(OPT_EXMEM_MALLOC) && !defined(OPT_EXMEM_TESTING) 
     
    23522364 
    23532365   FUNC(file_browser) 
     2366   FUNC(textbox) 
    23542367    
    23552368   FUNC(draw_pixel) 
  • branches/tbox_test/core/module_exportlist.c

    r1572 r1587  
    317317                        &COLOR__EXPORTEDSYM_HISTO_RG_PLAY, 
    318318 
    319                         module_tbox_get_version, 
    320                         module_tbox_run, 
     319            module_tbox_load, 
    321320 
    322321            config_save, 
  • branches/tbox_test/core/module_load.c

    r1569 r1587  
    474474int module_check_is_exist(char* name) 
    475475{ 
    476   char path[60]; 
    477   flat_module_path_make(path, name); 
    478  
    479    module_fd = open( path, O_RDONLY, 0777 ); 
    480    if ( module_fd >0 ) 
    481      close (module_fd); 
    482  
    483    return (module_fd>=0)?1:0; 
     476    char path[60]; 
     477    flat_module_path_make(path, name); 
     478 
     479    struct stat st; 
     480    if (stat(path,&st) != 0) return 0;  // file does not exist 
     481 
     482    return 1; 
    484483} 
    485484 
  • branches/tbox_test/core/modules.c

    r1569 r1587  
    328328/************* MODULE TBOX ******/ 
    329329 
    330 static char* tbox_file_buffer = 0; 
    331 static char* tbox_file_buffer_default = "_tbox.flt"; 
    332 static int   tbox_file_buffer_size = 0; 
    333 static char* charmap_buffer = 0; 
    334 static int   charmap_buffer_size = 0; 
    335  
    336 // Auxilary function - Parse loaded keymap, ask module for its API version 
    337 // Input values: tbox_file_buffer, tbox_file_buffer_size 
    338 // Return value: 0-error, otherwise API version 
    339 //----------------------------------------------------- 
    340 static int module_tbox_charmap_preprocess()  
    341 { 
    342         charmap_buffer = 0; 
    343         charmap_buffer_size = 0; 
    344  
    345         //-- input checks 
    346         if ( tbox_file_buffer==0 || tbox_file_buffer_size<=0 ) 
    347                 return 0; 
    348  
    349         int i, ver; 
    350  
    351         //-- Parse: split to lines 
    352         for( i=0; i<tbox_file_buffer_size; i++ ) 
    353            if ( tbox_file_buffer[i] == 0x0d || tbox_file_buffer[i] == 0x0a) 
    354                   tbox_file_buffer[i]=0; 
    355  
    356         //-- First line is name of tbox module 
    357         i = strlen(tbox_file_buffer);           // size 
    358         if ( i==0 ) 
    359                 return 0; 
    360  
    361         // tbox "run scenario #1" - argc=1, argv=0 - mean "say your API version" 
    362         ver = module_run(tbox_file_buffer, 0,  1,0, UNLOAD_ALWAYS ); 
    363  
    364         // if mistake on load 
    365         if ( ver<=0 )  
    366                 return 0; 
    367  
    368         charmap_buffer=tbox_file_buffer+i+1; 
    369         charmap_buffer_size= tbox_file_buffer_size - (i+1); 
    370  
    371         return ver; 
    372 } 
    373  
    374 // Check version and existance and tbox api version 
    375 // return: 0 if no module exists at all, otherwise version of API of current tbox module 
    376 //----------------------------------------------------- 
    377 int module_tbox_get_version() 
    378 { 
    379   static int last_loaded_tbox_hash = 0; 
    380   static int cur_tbox_api_version = 0; 
    381  
    382   // -- If keymap is loaded and not changed - return stored value 
    383  
    384   if ( lang_strhash31((int)conf.charmap_file) == last_loaded_tbox_hash ) 
    385     return cur_tbox_api_version; 
    386  
    387   // -- Free resources 
    388  
    389   last_loaded_tbox_hash = 0; 
    390   if ( tbox_file_buffer && tbox_file_buffer!=tbox_file_buffer_default ) 
    391     ufree( tbox_file_buffer ); 
    392  
    393   // -- Try to load keymap file 
    394  
    395   tbox_file_buffer = load_file( conf.charmap_file, &tbox_file_buffer_size ); 
    396  
    397   // Check is module available, otherwise try default one 
    398  
    399   cur_tbox_api_version = module_tbox_charmap_preprocess(); 
    400  
    401  
    402   // if keymap wrong/module can't be loaded - try default 
    403   if ( cur_tbox_api_version==0 ) { 
    404          if ( tbox_file_buffer ) 
    405         ufree(tbox_file_buffer); 
    406  
    407          tbox_file_buffer = tbox_file_buffer_default; 
    408          tbox_file_buffer_size = strlen(tbox_file_buffer); 
    409          cur_tbox_api_version = module_tbox_charmap_preprocess(); 
    410   } 
    411  
    412   if ( cur_tbox_api_version ) 
    413         last_loaded_tbox_hash = lang_strhash31((int)conf.charmap_file); 
    414  
    415   return cur_tbox_api_version; 
    416 } 
    417  
    418  
    419 //----------------------------------------------------- 
    420 void module_tbox_run( int title, int msg, char* defaultvalue, unsigned int maxsize, void (*on_select)(char* newstr)) 
    421 { 
    422         int ver = module_tbox_get_version(); 
    423  
    424         if ( API_VERSION_MATCH_REQUIREMENT( ver, 1, 0 ) ) { 
    425  
    426                 // Main "run scenario" - 7 argument, raise textbox 
    427                 unsigned int argv[] = { (int)charmap_buffer, 
    428                                                                 charmap_buffer_size, 
    429                                                                 title, 
    430                                                                 msg, 
    431                                                                 (unsigned int)defaultvalue, 
    432                                                                 maxsize, 
    433                                                                 (unsigned int)on_select, 
    434                                                          }; 
    435             module_run(tbox_file_buffer, 0,  sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR); 
    436                  
    437         } 
    438 } 
     330#define MODULE_NAME_TBOX "_tbox.flt" 
     331 
     332struct libtextbox_sym* libtextbox; 
     333 
     334static int bind_module_tbox( void** export_list ) 
     335{ 
     336    return bind_module_generic(export_list, (void**)&libtextbox, 1, 1, 0); 
     337} 
     338 
     339// Return: 0-fail, addr-ok 
     340struct libtextbox_sym* module_tbox_load() 
     341{ 
     342    return module_load_generic((void**)&libtextbox, MODULE_NAME_TBOX, bind_module_tbox, 0); 
     343} 
  • branches/tbox_test/core/modules.h

    r1569 r1587  
    4444// MODULE "TBOX" 
    4545//-------------------------- 
    46 int module_tbox_get_version(); 
    47 void module_tbox_run( int title, int msg, char* defaultvalue, unsigned int maxsize, void (*on_select)(char* newstr)); 
     46#include "gui_tbox.h" 
    4847 
    4948#endif 
  • branches/tbox_test/core/script.c

    r1569 r1587  
    580580                action_pop(); 
    581581            break; 
     582        case AS_TEXTBOX: 
    582583        case AS_FILE_BROWSER: 
    583584            // state_kbd_script_run is set to 0 when the file browser is started from a Lua script 
  • branches/tbox_test/include/conf.h

    r1569 r1587  
    318318        int remote_control_mode ; 
    319319 
    320     // Text Box char map file 
    321     char charmap_file[100]; 
    322  
    323320} Conf; 
    324321 
Note: See TracChangeset for help on using the changeset viewer.