JBoolean CBCommand::Add ( const JPtrArray<JString>& cmdArgs, const JPtrArray<JString>& fullNameList, const JArray<JIndex>& lineIndexList, CBFunctionStack* fnStack ) { const JString* firstArg = cmdArgs.FirstElement(); if (firstArg->GetFirstCharacter() == '&') { assert( fnStack != NULL ); // check for re-used command name const JCharacter* cmdName = firstArg->GetCString()+1; const JSize cmdCount = fnStack->GetElementCount(); for (JIndex j=1; j<=cmdCount; j++) { if (strcmp(cmdName, fnStack->Peek(j)) == 0) { ReportInfiniteLoop(*fnStack, j); return kJFalse; } } // prepare cmd for execution later fnStack->Push(cmdName); CBCommandManager* mgr = (itsProjDoc != NULL ? itsProjDoc->GetCommandManager() : CBGetCommandManager()); CBCommand* cmdObj; CBCommandManager::CmdInfo* cmdInfo; if (mgr->Prepare(cmdName, itsProjDoc, fullNameList, lineIndexList, &cmdObj, &cmdInfo, fnStack)) { cmdObj->SetParent(this); itsCmdList->AppendElement(CmdInfo(NULL, cmdObj, cmdInfo, kJFalse)); } else { return kJFalse; } fnStack->Pop(); } else { JPtrArray<JString>* args = jnew JPtrArray<JString>(JPtrArrayT::kDeleteAll); assert( args != NULL ); args->CopyObjects(cmdArgs, JPtrArrayT::kDeleteAll, kJFalse); itsCmdList->AppendElement(CmdInfo(args, NULL, NULL, kJFalse)); } return kJTrue; }
void CommandOrderDlg::updateOrderMap() { typedef std::map<size_t, wxString> SortedCmds; size_t listIdx = 0; m_normKeyCount = 0; { //add "normal"-keys first (do not show normal keys when user clicked an ANY-key) if ( !this->m_key.StartsWith( wxT("Any+") ) ) { SortedCmds tmp; for ( CmdSet::const_iterator iter = m_cmds.begin(); iter != m_cmds.end(); ++iter ) { for( int i = 0; i < (*iter)->GetShortcutCount(); ++i ) { const wxKeyBind* pKb = (*iter)->GetShortcut( i ); if ( !pKb->HasAnyModifier() && pKb->Match(this->m_key ) ) { tmp[pKb->GetOrderIndex()] = (*iter)->GetName(); ++m_normKeyCount; } } } for( SortedCmds::const_iterator iter = tmp.begin(); iter != tmp.end(); ++iter ) { this->m_prioCmdMap[listIdx++] = CmdInfo( iter->second, false, iter->first ); } } } { //add "any"-keys SortedCmds tmp; for ( CmdSet::const_iterator iter = m_cmds.begin(); iter != m_cmds.end(); ++iter ) { for( int i = 0; i < (*iter)->GetShortcutCount(); ++i ) { const wxKeyBind* pKb = (*iter)->GetShortcut( i ); if ( pKb->HasAnyModifier() && pKb->Match( this->m_key ) ) { tmp[pKb->GetOrderIndex()] = (*iter)->GetName(); } } } for( SortedCmds::const_iterator iter = tmp.begin(); iter != tmp.end(); ++iter ) { this->m_prioCmdMap[listIdx++] = CmdInfo( iter->second, true, iter->first ); } } }
void CBCommand::Add ( CBCommand* subCmd, const CBCommandManager::CmdInfo& cmdInfo ) { subCmd->SetParent(this); CBCommandManager::CmdInfo* info = jnew CBCommandManager::CmdInfo; assert( info != NULL ); *info = cmdInfo.Copy(); itsCmdList->AppendElement(CmdInfo(NULL, subCmd, info, kJFalse)); }
JBoolean CBCommand::Start ( const CBCommandManager::CmdInfo& info ) { CBCommandManager* mgr = (itsProjDoc != NULL ? itsProjDoc->GetCommandManager() : CBGetCommandManager()); if (info.isMake) { itsUpdateSymbolDatabaseFlag = kJTrue; CBCommand* p = itsParent; while (p != NULL) { if (p->itsBuildOutputDoc != NULL) { itsOutputDoc = p->itsBuildOutputDoc; break; } p = p->itsParent; } if (itsOutputDoc == NULL) { itsOutputDoc = mgr->GetCompileDoc(itsProjDoc); itsOutputDoc->IncrementUseCount(); } SetCompileDocStrings(); itsBuildOutputDoc = itsOutputDoc; } else if (info.useWindow) { CBCommand* p = itsParent; while (p != NULL) { if (p->itsRunOutputDoc != NULL) { itsOutputDoc = p->itsRunOutputDoc; break; } p = p->itsParent; } if (itsOutputDoc == NULL) { itsOutputDoc = mgr->GetOutputDoc(); itsOutputDoc->IncrementUseCount(); } itsDontCloseMsg = JGetString("RunCloseMsg::CBCommand"); itsWindowTitle = JGetString("RunWindowTitlePrefix::CBCommand"); if (!(info.menuText)->IsEmpty()) { itsWindowTitle += *(info.menuText); } else { itsWindowTitle += *(info.cmd); } itsRunOutputDoc = itsOutputDoc; } if (info.saveAll) // ok, now that we have decided that command can be executed { (CBGetDocumentManager())->SaveTextDocuments(kJFalse); } if (info.isVCS) { itsUpdateSymbolDatabaseFlag = kJTrue; } if (itsUpdateSymbolDatabaseFlag) { (CBGetDocumentManager())->CancelUpdateSymbolDatabases(); } // after saving all files, update Makefile JBoolean waitForMakeDepend = kJFalse; if (info.isMake && itsProjDoc != NULL) { waitForMakeDepend = (itsProjDoc->GetBuildManager())->UpdateMakefile(itsOutputDoc, &itsMakeDependCmd); } if (waitForMakeDepend) { if (itsMakeDependCmd != NULL) { itsCmdList->PrependElement(CmdInfo(NULL, itsMakeDependCmd, NULL, kJTrue)); ListenTo(itsMakeDependCmd); // many may need to hear; can't use SetParent() return kJTrue; } else { DeleteThis(); return kJFalse; } } else if (StartProcess()) { if (itsOutputDoc != NULL && info.raiseWindowWhenStart) { itsOutputDoc->Activate(); } return kJTrue; } else // we have been deleted { return kJFalse; } }