void _HYConsoleWindow::DoEcho (void) { _List menuChoices; if (!echoFileRef) { menuChoices && & startEchoing; } else { menuChoices && & stopEchoing; if (echoStatus == 0) // paused menuChoices && & resumeEchoing; else menuChoices && & pauseEchoing; } int h,v; _HYButtonBar * bb = (_HYButtonBar*)GetObject (2); bb->GetButtonLoc(2,h,v,true); _String choice = HandlePullDown (menuChoices,h,v,0); if (choice.Equal (&startEchoing)) { _String saveDP (dialogPrompt), fileName; dialogPrompt = "Echo HyPhy console to:"; fileName = WriteFileDialogInput (); if (fileName.sLength) { echoFileRef = doFileOpen (fileName.sData,"w"); if (!echoFileRef) { fileName = _String ("File '")&fileName& "' couldn't be opened for writing."; ProblemReport (fileName); } } dialogPrompt = saveDP; echoStatus = 1; } else if (choice.Equal (&stopEchoing)) { fclose (echoFileRef); echoFileRef = nil; echoStatus = 0; } else if (choice.Equal (&pauseEchoing)) echoStatus = 0; else if (choice.Equal (&resumeEchoing)) echoStatus = 1; bb->_UnpushButton(); _PaintStatusBar(); }
long HandlePullDownWithFont (_List& menuOptions, long l, long t,long startPos,_String fName,long fSize) { _String selRes = HandlePullDown (menuOptions, l, t, startPos); return menuOptions.Find (&selRes); }
bool _HYConsoleWindow::ProcessEvent (_HYEvent* e) { bool done = false; _String firstArg; long i,f,k; if (e->EventClass().Equal(&_hyButtonPushEvent)) { firstArg = e->EventCode().Cut (0,(f=e->EventCode().Find(','))-1); k = firstArg.toNum(); for (i=0;i<components.lLength;i++) { if (((_HYGuiObject*)components(i))->MatchID(k)) break; } if (i==2) { firstArg = e->EventCode().Cut (f+1,-1); k = firstArg.toNum(); _HYButtonBar * bb = (_HYButtonBar*)GetObject (2); switch (k) { case 0: case 1: { _List menuChoices; if (k==0) for (long k=0; k<userHookins.lLength; k++) { _String *dName = (_String*)userHookins(k), aName (*dName, dName->FindBackwards ( #ifdef __MAC__ ':' #else #ifdef __WINDOZE__ '\\' #else '/' #endif #endif ,0,-1)+1,-1); menuChoices && & aName; } else { firstArg = "Search Commands"; menuChoices && & firstArg; firstArg = "Search Descriptions"; menuChoices && & firstArg; firstArg = "Search Notes"; menuChoices && & firstArg; firstArg = "Export to LaTeX by name"; menuChoices && & firstArg; firstArg = menuSeparator; menuChoices && & firstArg; firstArg = "Open in a window"; menuChoices && & firstArg; } int h,v; bb->GetButtonLoc(k,h,v,true); _String userAction = HandlePullDown (menuChoices,h,v,0); bb->_UnpushButton(); i = menuChoices.Find (&userAction); if (i>=0) { _ExecutionList uxl; if (k==0) { userAction = ((_String*)userHookins(i))->getStr(); } else userAction = baseDirectory&"Help"&baseDirectory.sData[baseDirectory.sLength-1]&"Commands"&baseDirectory.sData[baseDirectory.sLength-1]&"query.bf"; h = PushFilePath (userAction); ReadBatchFile (userAction, uxl); if (k==1) { _String addin; switch (i) { case 0: addin = "Command"; break; case 1: addin = "Description"; break; case 2: addin = "Notes"; break; case 3: addin = "Export"; break; case 5: addin = "Window"; break; } firstArg = ((_HYTextBox*)GetObject (1))->GetText(); _FString qf = _FString (addin,false), qt = _FString (firstArg,false); firstArg = "QUERY_FIELD"; setParameter (firstArg,&qf); firstArg = "QUERY_TERM"; setParameter (firstArg,&qt); } uxl.Execute(); terminateExecution = false; if (h) PopFilePath (); /*} else { userAction = userAction & " could not be found. Perhaps the file was recently moved or deleted."; ProblemReport (userAction, (Ptr)this); }*/ } } break; case 2: DoEcho(); break; case 3: { _String webUpdate = baseDirectory&"TemplateBatchFiles"&baseDirectory.sData[baseDirectory.sLength-1]&"WebUpdate.bf"; _ExecutionList wbl; k = PushFilePath (webUpdate); ReadBatchFile (webUpdate, wbl); wbl.Execute(); terminateExecution = false; if (k) PopFilePath (); } } done = true; } } else if (e->EventClass().Equal(&_hyTextEditChange)) { firstArg = e->EventCode().Cut (0,(f=e->EventCode().Find(','))-1); k = firstArg.toNum(); for (i=0;i<components.lLength;i++) { if (((_HYGuiObject*)components(i))->MatchID(k)) break; } if (i==0) // out box { _UpdateEditMenu(); done = true; } else if (i==1) // in box { firstArg = e->EventCode().Cut (f+1,-1); k = firstArg.toNum(); _HYTextBox * ib = (_HYTextBox*)GetObject (1); if (k==2) { if (inputStatus == 1) inputStatus = 2; } else { if (k==3) // down arrow { if (inputLocation<recentInputs.lLength-1) ib->SetText (*(_String*)recentInputs(++inputLocation), false); } else if (k==4) // up arrow { if (inputLocation>0) ib->SetText (*(_String*)recentInputs(--inputLocation), false); } else { if (inputStatus == 1) inputLocation = recentInputs.lLength; _HYButtonBar * bb = (_HYButtonBar*)GetObject (2); bool onOff = ! ib->_IsEmpty(); bb->EnableButton (1,onOff); } } done = true; } } if (done) { DeleteObject (e); return true; } return _HYTWindow::ProcessEvent(e); }