int EView::ViewRoutines(ExState &/*State*/) { //int rc = 1; //RoutineView *routines; EModel *M; EBuffer *Buffer; M = Model; if (M->GetContext() != CONTEXT_FILE) return 0; Buffer = (EBuffer *)M; if (Buffer->Routines == 0) { if (BFS(Buffer, BFS_RoutineRegexp) == 0) { MView->Win->Choice(GPC_ERROR, "Error", 1, "O&K", "No routine regexp."); return 0; } Buffer->Routines = new RoutineView(0, &ActiveModel, Buffer); if (Buffer->Routines == 0) return 0; } else { Buffer->Routines->UpdateList(); } SwitchToModel(Buffer->Routines); return 1; }
int EView::OpenDir(char *Path) { char XPath[MAXPATH]; EDirectory *dir = 0; if (ExpandPath(Path, XPath, sizeof(XPath)) == -1) return 0; { EModel *x = Model; while (x) { if (x->GetContext() == CONTEXT_DIRECTORY) { if (filecmp(((EDirectory *)x)->Path, XPath) == 0) { dir = (EDirectory *)x; break; } } x = x->Next; if (x == Model) break; } } if (dir == 0) dir = new EDirectory(0, &ActiveModel, XPath); SelectModel(dir); return 1; }
void demoEMod(uint64_t s, PRNG* rng) { using KBase::EModel; printf("Using PRNG seed: %020llu \n", s); rng->setSeed(s); printf("Creating EModel objects ... \n"); string n2D = "EModel-TwoDPoint"; auto em2D = new EModel<TwoDPoint>(rng, n2D); cout << "Populating " << n2D << endl; em2D->enumOptions = theta2D; em2D->setOptions(); cout << "Now have " << em2D->numOptions() << endl; string nBV = "EModel-BVec"; EModel<BVec>* emBV = new EModel<BVec>(rng, nBV); cout << "Populating " << nBV << endl; emBV->enumOptions = tbv(17, 3, rng); // thetaBV(4); emBV->setOptions(); cout << "Now have " << emBV->numOptions() << endl; printf("Deleting EModel objects ... \n"); delete em2D; delete emBV; return; }
void BufferView::UpdateList() { EModel *B = ActiveModel; int No; char s[512] = ""; if (BList) { for (int i = 0; i < BCount; i++) if (BList[i]) free(BList[i]); free(BList); } BList = 0; BCount = 0; while (B) { BCount++; B = B->Next; if (B == ActiveModel) break; } BList = (char **) malloc(sizeof(char *) * BCount); assert(BList != 0); B = ActiveModel; No = 0; while (B) { B->GetInfo(s, sizeof(s) - 1); BList[No++] = strdup(s); B = B->Next; if (B == ActiveModel) break; if (No >= BCount) break; } Count = BCount; NeedsUpdate = 1; }
int EView::FileLast() { if (Model) { EModel *n = Model->Next; if (IgnoreBufferList && n && n->GetContext() == CONTEXT_BUFFERS) n = n->Next; SwitchToModel(n); return 1; } return 0; }
int EView::FilePrev() { if (Model) { EModel *n = Model->Prev; if (IgnoreBufferList && n && n->GetContext() == CONTEXT_BUFFERS) n = n->Prev; SelectModel(n); return 1; } return 0; }
int EView::FileSaveAll() { EModel *M = Model; while (M) { if (M->GetContext() == CONTEXT_FILE) { EBuffer *B = (EBuffer *)M; if (B->Modified) { SwitchToModel(B); if (B->Save() == 0) return 0; } } M = M->Next; if (M == Model) break; } return 1; }
EBuffer *FindFile(char *FileName) { EModel *M; EBuffer *B; M = ActiveModel; while (M) { if (M->GetContext() == CONTEXT_FILE) { B = (EBuffer *)M; if (filecmp(B->FileName, FileName) == 0) { return B; } } M = M->Next; if (M == ActiveModel) break; } return 0; }
int SaveDesktop(char *FileName) { FILE *fp; EModel *M; fp = fopen(FileName, "w"); if (fp == 0) return 0; setvbuf(fp, FileBuffer, _IOFBF, sizeof(FileBuffer)); fprintf(fp, DESKTOP_VER); M = ActiveModel; while (M) { switch (M->GetContext()) { case CONTEXT_FILE: if (M != CvsLogView) { EBuffer *B = (EBuffer *)M; fprintf(fp, "F|%d|%s\n", B->ModelNo, B->FileName); } break; case CONTEXT_DIRECTORY: { EDirectory *D = (EDirectory *)M; fprintf(fp, "D|%d|%s\n", D->ModelNo, D->Path); } break; } M = M->Next; if (M == ActiveModel) break; } TagsSave(fp); markIndex.SaveToDesktop(fp); fclose(fp); return 1; }
int BufferView::ExecCommand(int Command, ExState &State) { switch (Command) { case ExCloseActivate: { EModel *B; CancelSearch(); B = GetBufferById(Row); if (B && B != this) { View->SwitchToModel(B); delete this; return ErOK; } } return ErFAIL; case ExBufListFileClose: { EModel *B = GetBufferById(Row); CancelSearch(); if (B && B != this && Count > 1) { if (B->ConfQuit(View->MView->Win)) { View->DeleteModel(B); } UpdateList(); return ErOK; } } return ErFAIL; case ExBufListFileSave: { EModel *B = GetBufferById(Row); if (B && B->GetContext() == CONTEXT_FILE) if (((EBuffer *)B)->Save()) return ErOK; } return ErFAIL; case ExActivateInOtherWindow: { EModel *B = GetBufferById(Row); CancelSearch(); if (B) { View->Next->SwitchToModel(B); return ErOK; } } return ErFAIL; case ExBufListSearchCancel: CancelSearch(); return ErOK; case ExBufListSearchNext: // Find next matching line if (SearchLen) { int i = Row + 1; i = GetMatchingLine(i == BCount ? 0 : i, 1); // Never returns -1 since something already found before call Row = SearchPos[SearchLen] = i; } return ErOK; case ExBufListSearchPrev: // Find prev matching line if (SearchLen) { int i = Row - 1; i = GetMatchingLine(i == -1 ? BCount - 1 : i, -1); // Never returns -1 since something already found before call Row = SearchPos[SearchLen] = i; } return ErOK; } return EList::ExecCommand(Command, State); }