// resetChoices() // resetChoices clears all menu options. Returns immediately. int _lua_resetchoices(lua_State *L) { _talk_state *st = (_talk_state*) lua_touserdata(L, lua_upvalueindex(1)); if (st->m_iState == _STOPPED) { return luaL_error(L, "conversation is already stopped"); } menu_clear(st->m_pChoices); return 0; }
static void ex_killline() { free(ex.line); ex.line = calloc(ex.maxpos, sizeof(char*)); ex.curpos = 0; ex.curofs = 0; if (ex.ex_state == EX_CMD_STATE) menu_clear(ex.menu); ex.state = 0; }
static void ex_moveline(void *none, Keyarg *arg) { log_msg("EXCMD", "MOVELINE"); int len = arg->arg * strlen(ex.line); int pos = arg->arg * cell_len(ex.line); ex.curofs = MAX(0, len); ex.curpos = MAX(0, pos); if (arg->arg == FORWARD) menu_rebuild(ex.menu); else menu_clear(ex.menu); }
/* * Display the current menu in the context */ void menu_display(menu_context_t *context) { uint8_t i; menu_t *menu = context->menu; menu_entry_t *disp_entry; uint8_t dindex = 0; #ifndef CONFIG_TINYMENU_USE_CLEAR uint8_t j; #else menu_clear(); #endif // Display only those entries that will fit on the display for (i = 0; i < context->height; i++) { #ifndef CONFIG_TINYMENU_COMPACT // Don't display hidden menu entries do { disp_entry = &menu->entry[menu->top_entry + dindex]; if (dindex++ >= menu->num_entries - menu->top_entry) goto entries_done; } while (disp_entry->flags & MENU_FLAG_HIDDEN); #else disp_entry = &menu->entry[menu->top_entry + dindex]; if (dindex++ >= menu->num_entries - menu->top_entry) return; #endif // Go to correct x,y locations and print the entry menu_set_pos(context->x_loc, context->y_loc + i); menu_print_entry(disp_entry, context->width, (menu->current_entry == dindex - 1)); } entries_done: #ifndef CONFIG_TINYMENU_USE_CLEAR // Fill rest of menu screen space with spaces for (; i < context->height; i++) { menu_set_pos(context->x_loc, context->y_loc + i); for (j = 0; j < context->width; j++) { menu_putchar(' '); } } #endif }
void menu_touch(int xx, int yy) { if (g_menu_applet) { if (g_menu_applet(xx, yy)) menu_back_after_applet(); return; } menu_touch_y = yy; menu_touch_x = xx; //menu_update(); int old = g_item; g_item = menu_get_selected(); lcd_lock(); if (old != -1) menu_paint_cell(old); if (g_item != -1) menu_paint_cell(g_item); lcd_release(); if (xx == -1 || yy == -1 || g_item == -1) { if (old != -1) { if (g_menu[g_index][old].press_handler) { g_menu[g_index][old].press_handler(0); } void (*callback)(int) = g_menu[g_index][old].activate; g_crumbs[g_index] = old; if (g_menu[g_index][old].next && g_index < MAX_DEPTH) { g_index++; g_menu[g_index] = g_menu[g_index-1][old].next; menu_update(); } else if (g_menu[g_index][old].touch_handler) { g_menu_applet = g_menu[g_index][old].touch_handler; g_item = old; menu_clear(); } else if (strcmp(g_menu[g_index][old].text, "Back") == 0) { menu_run_callback(0); if (g_index > 0) g_index--; menu_update(); menu_run_callback(1); } // run the callback which should start the applet or update the display if (callback) { callback(1); } } return; } menu_touch_y = 0; menu_touch_x = 0; if (g_menu[g_index][g_item].press_handler) { g_menu[g_index][g_item].press_handler(1); } }
void menu_touch(int xx, int yy) { //char c[15]; vConsolePrint("Menu Touch Called\r\n"); //sprintf(c, "x %d y %d\r\n", xx, yy); //vConsolePrint(c); if (g_menu_applet) { if (g_menu_applet(xx, yy)) menu_back_after_applet(); return; } menu_touch_y = yy; menu_touch_x = xx; //menu_update(); char bb[30]; int old = g_item; if (g_incoming_command == 1) { g_item = g_command_item; } else { g_item = menu_get_selected(); } g_incoming_command=0; // sprintf(bb, "Item Selected is: %u\r\n", g_item); // vConsolePrint(bb); // fflush(stdout); lcd_lock(); if (old != -1) menu_paint_cell(old); if (g_item != -1) menu_paint_cell(g_item); lcd_release(); if (xx == -1 || yy == -1 || g_item == -1) { if (old != -1) { if (g_menu[g_index][old].press_handler) { g_menu[g_index][old].press_handler(0); } void (*callback)(int) = g_menu[g_index][old].activate; g_crumbs[g_index] = old; if (g_menu[g_index][old].next && g_index < MAX_DEPTH) { g_index++; g_menu[g_index] = g_menu[g_index-1][old].next; menu_update(); } else if (g_menu[g_index][old].touch_handler) { g_menu_applet = g_menu[g_index][old].touch_handler; g_item = old; menu_clear(); } else if (strcmp(g_menu[g_index][old].text, "Back") == 0) { menu_run_callback(0); if (g_index > 0) g_index--; menu_update(); menu_run_callback(1); } // run the callback which should start the applet or update the display if (callback) { callback(1); } } return; } menu_touch_y = 0; menu_touch_x = 0; if (g_menu[g_index][g_item].press_handler) { g_menu[g_index][g_item].press_handler(1); } }