Exemplo n.º 1
0
// TerminalMenuManager
// Control routine for operating the menu.
// 
// Parameters: None
// Generate menu
// output menu
// prompt for valid selection
// do action of selection
// until done.
int Menu::TerminalMenuManager() {
  
  char* pMenuBuffer = NULL;
  boolean bDone = false;
  int iMenuResponse, iActionID;
  while (!bDone) {

    pMenuBuffer = (char*) malloc(150);
    GenerateMenu(pMenuBuffer, 150,true);
    Serial << endl << pMenuBuffer;
    free(pMenuBuffer);
    
    gBuffer[0] = GetMenuResponse( GetBuffer_P(STI_MENU_PROMPT_1000, gBuffer, ENTRY_FIELD_SIZE) ,9); 
    gBuffer[1] = '\0';
    iMenuResponse = atoi(gBuffer);
    iActionID = paMenuActions[iMenuResponse];
    
    PerformAction(iActionID);
    if (iCurrentMenu < MENU_MAIN ) {
      bDone = true;
    }
    
    
  }
}
Exemplo n.º 2
0
void SheetGenerator::Register(LPXLOPER xllName, Protocol* protocol, dictionary* ini)
{
    // Need to save a reference for commands
    g_protocol = protocol;

    LPXLOPER res = protocol->execute(AF_GET_MENU, true, 0);
    if(!res)
        return;

    char* menuName = XLMap::getNTString(res, "name");
    if(!menuName) {
        XLUtil::FreeContents(res);
        return;
    }

    LPXLOPER items = XLMap::get(res, "items");
    if(!items) {
        XLUtil::FreeContents(res);
        return;
    }

    MENU_ITEM* toplevel = GenerateMenu(xllName, menuName, NULL, items);
    XLUtil::AddMenu(xllName, toplevel, items->val.array.rows+1, "Help");

    LPXLOPER submenus = XLMap::get(res, "submenus");
    int subc = submenus->val.array.rows;
    int posCount = 1;
    for(int i = 0; i < subc; i++) {
        LPXLOPER x = &submenus->val.array.lparray[i];
        char* mn = XLMap::getNTString(x, "name");
        LPXLOPER im = XLMap::get(x, "items");
        MENU_ITEM* mis = GenerateMenu(xllName, menuName, mn, im);
        int pos = posCount;
        int p = XLMap::getInteger(x, "position");
        if(p != -1) {
            pos = p;
        } else {
            posCount++;
        }
        XLUtil::AddMenu(xllName, mis, im->val.array.rows+1, menuName, (char*) pos);
    }
}
Exemplo n.º 3
0
void MenuInstanceData::DisplayHelp() const {
  const string filename = GetHelpFileName(this);
  if (!printfile(filename, true)) {
    GenerateMenu();
  }
}