Changeset 1614
- Timestamp:
- 01/26/12 07:50:34 (16 months ago)
- Location:
- branches/tbox_test/core
- Files:
-
- 4 edited
-
gui_fselect.c (modified) (2 diffs)
-
gui_tbox.c (modified) (5 diffs)
-
gui_tbox.h (modified) (1 diff)
-
luascript.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/tbox_test/core/gui_fselect.c
r1587 r1614 1132 1132 case MPOPUP_MKDIR: 1133 1133 if (module_tbox_load()) 1134 module_tbox_load()->textbox_init(LANG_POPUP_MKDIR, LANG_PROMPT_MKDIR, "", 15, mkdir_cb );1134 module_tbox_load()->textbox_init(LANG_POPUP_MKDIR, LANG_PROMPT_MKDIR, "", 15, mkdir_cb, 0); 1135 1135 break; 1136 1136 case MPOPUP_RMDIR: … … 1139 1139 case MPOPUP_RENAME: 1140 1140 if (module_tbox_load()) 1141 module_tbox_load()->textbox_init(LANG_POPUP_RENAME, LANG_PROMPT_RENAME, selected->name, 15, rename_cb );1141 module_tbox_load()->textbox_init(LANG_POPUP_RENAME, LANG_PROMPT_RENAME, selected->name, 15, rename_cb, 0); 1142 1142 break; 1143 1143 } -
branches/tbox_test/core/gui_tbox.c
r1609 r1614 97 97 cmap *charmaps[] = { &tbox_chars_default, &tbox_chars_russian }; 98 98 99 int lines = 0; // num of valid lines in active charmap99 int lines = 0; // num of valid lines in active charmap 100 100 101 101 int tbox_button_active, line; 102 int curchar; // idx of current entered char in current tmap102 int curchar; // idx of current entered char in current tmap 103 103 int curgroup; 104 104 int cursor; 105 char lastKey; // Last pressed key (Left, Right, Up, Down) 106 char Mode; // K=keyboard, T=textnavigate, B=button 107 108 char *text = 0; // Entered text 105 char lastKey; // Last pressed key (Left, Right, Up, Down) 106 char Mode; // K=keyboard, T=textnavigate, B=button 107 108 char text_buf[MAX_TEXT_SIZE+1]; // Default buffer if not supplied by caller 109 char *text = 0; // Entered text 109 110 int maxlen, offset; 110 111 coord text_offset_x, text_offset_y, key_offset_x; … … 134 135 135 136 //------------------------------------------------------- 136 int textbox_init(int title, int msg, const char* defaultstr, unsigned int maxsize, void (*on_select)(const char* newstr)) { 137 138 text = malloc(sizeof(char)*(maxsize+1)); 139 if ( text==0 ) { 140 // fatal failure 141 if (on_select) 142 on_select(0); // notify callback about exit as cancel 143 module_async_unload(module_idx); 144 return 0; 137 int textbox_init(int title, int msg, const char* defaultstr, unsigned int maxsize, void (*on_select)(const char* newstr), char *input_buffer) 138 { 139 if (input_buffer) 140 text = input_buffer; 141 else 142 { 143 if (maxsize > MAX_TEXT_SIZE) maxsize = MAX_TEXT_SIZE; 144 text = text_buf; 145 145 } 146 146 … … 538 538 tbox_on_select(0); // cancel 539 539 } 540 free(text);541 540 text=0; 542 541 } … … 555 554 556 555 static const char* gui_text_box_charmap[] = { "Default", "Russian" }; 557 static CMenuItem zebra_submenu_items[] = {556 static CMenuItem textbox_submenu_items[] = { 558 557 MENU_ENUM2(0x5f,LANG_MENU_VIS_CHARMAP, &tconf.char_map, gui_text_box_charmap ), 559 558 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ), 560 559 {0} 561 560 }; 562 static CMenu textbox_submenu = {0x26,LANG_STR_TEXTBOX_SETTINGS, NULL, zebra_submenu_items };561 static CMenu textbox_submenu = {0x26,LANG_STR_TEXTBOX_SETTINGS, NULL, textbox_submenu_items }; 563 562 564 563 … … 610 609 611 610 // clean allocated resource 612 if ( text!=0 ) 613 { 614 free(text); 615 if (tbox_on_select) 616 tbox_on_select(0); // notify callback about exit as cancel 617 text = 0; 618 } 611 if (tbox_on_select) 612 tbox_on_select(0); // notify callback about exit as cancel 619 613 620 614 //sanity clean to prevent accidentaly assign/restore guimode to unloaded module -
branches/tbox_test/core/gui_tbox.h
r1608 r1614 2 2 #define TEXTBOX_H 3 3 4 #define MAX_TEXT_SIZE 100 5 6 // Note: if using the text box module pass in a function to the 'on_select' parameter 7 // the text box will call this function with the user entered text in 'newstr' 8 9 // If supplied the 'input_buffer' array will be used to store the user input text, 10 // this will also be the address passed to 'on_select' in 'newstr' - in this case 11 // the calling function owns the data buffer. Ensure that the size of 'input_buffer' 12 // is at least 'maxsize + 1'. 13 14 // If 'input_buffer' is null then a local buffer in the module will be used to 15 // store the text, the maximum size of this buffer is MAX_TEXT_SIZE. 16 // In this case the module owns the buffer and the contents must be copied to local 17 // storage in the 'on_select' code. 18 4 19 struct libtextbox_sym { 5 20 int version; 6 int (*textbox_init)(int title, int msg, const char* defaultstr, unsigned int maxsize, void (*on_select)(const char* newstr) );21 int (*textbox_init)(int title, int msg, const char* defaultstr, unsigned int maxsize, void (*on_select)(const char* newstr), char *input_buffer); 7 22 }; 8 23 -
branches/tbox_test/core/luascript.c
r1608 r1614 853 853 luaL_optstring( L, 3, "" ), //default string 854 854 luaL_optnumber( L, 4, 30), //max size of a text 855 return_string_selected); } 855 return_string_selected, 0); 856 } 856 857 else 857 858 return_string_selected(0);
Note: See TracChangeset
for help on using the changeset viewer.