void CBFileListTable::ScanDirectory ( const JString& origPath, const JBoolean recurse, const JPtrArray<JString>& allSuffixList, CBSymbolList* symbolList, CBCTree* cTree, CBJavaTree* javaTree, JProgressDisplay& pg ) { JString path; JDirInfo* info; if (!JGetTrueName(origPath, &path) || !JDirInfo::Create(path, &info)) { return; } const JSize count = info->GetEntryCount(); for (JIndex i=1; i<=count; i++) { const JDirEntry& entry = info->GetEntry(i); // If it's a directory, recurse. if (entry.IsDirectory() && recurse && !entry.IsLink() && !JIsVCSDirectory(entry.GetName())) { ScanDirectory(entry.GetFullName(), recurse, allSuffixList, symbolList, cTree, javaTree, pg); } // If it's a file ending in one of the suffixes, parse it. else if (entry.IsFile()) { JString trueName = entry.GetFullName(); time_t modTime = entry.GetModTime(); if (entry.IsWorkingLink()) { const JBoolean ok = JGetTrueName(entry.GetFullName(), &trueName); assert( ok ); const JError err = JGetModificationTime(trueName, &modTime); assert( err.OK() ); } ParseFile(trueName, allSuffixList, modTime, symbolList, cTree, javaTree); } pg.IncrementProgress(); } delete info; }
JBoolean CBSearchTextDialog::SearchDirectory ( const JString& path, const JRegex* fileRegex, const JRegex* pathRegex, JPtrArray<JString>* fileList, JPtrArray<JString>* nameList, JProgressDisplay& pg ) const { JDirInfo* info; if (!JDirInfo::Create(path, &info)) { return kJTrue; // user didn't cancel } info->SetWildcardFilter(const_cast<JRegex*>(fileRegex), kJFalse, itsInvertFileFilterCB->IsChecked()); JBoolean keepGoing = kJTrue; const JSize count = info->GetEntryCount(); for (JIndex i=1; i<=count; i++) { const JDirEntry& entry = info->GetEntry(i); if (entry.IsFile()) { if (!pg.IncrementProgress()) { keepGoing = kJFalse; break; } SaveFileForSearch(entry.GetFullName(), fileList, nameList); } else if (itsRecurseDirCB->IsChecked() && entry.IsDirectory() && !entry.IsLink() && !JIsVCSDirectory(entry.GetName())) { JBoolean match = kJTrue; if (pathRegex != NULL) { match = ! pathRegex->Match(entry.GetName()); } if (match && !SearchDirectory(entry.GetFullName(), fileRegex, pathRegex, fileList, nameList, pg)) { keepGoing = kJFalse; break; } } } jdelete info; return keepGoing; }
JBoolean CBFileNode::ParseFile ( const JString& fullName, CBFileListTable* parser, const JPtrArray<JString>& allSuffixList, CBSymbolList* symbolList, CBCTree* cTree, CBJavaTree* javaTree, CBPHPTree* phpTree, JProgressDisplay& pg ) const { time_t t; JGetModificationTime(fullName, &t); parser->ParseFile(fullName, allSuffixList, t, symbolList, cTree, javaTree, phpTree); return pg.IncrementProgress(); }
JBoolean CBSymbolList::UpdateFinished ( const JArray<JFAID_t>& deadFileList, JProgressDisplay& pg ) { DeleteProcess(); // reset to lenient search itsSymbolList->SetCompareFunction(CompareSymbols); // toss files that no longer exist const JSize fileCount = deadFileList.GetElementCount(); if (fileCount > 0) { pg.FixedLengthProcessBeginning(fileCount, JGetString(kCleaningUpID), kJFalse, kJTrue); for (JIndex i=1; i<=fileCount; i++) { RemoveFile(deadFileList.GetElement(i)); pg.IncrementProgress(); } pg.ProcessFinished(); } if (itsChangedDuringParseFlag && !CBInUpdateThread()) { itsReparseAllFlag = kJFalse; Broadcast(Changed()); } return itsChangedDuringParseFlag; }
void CBEditTextPrefsDialog::UpdateSettings() { CBTextEditor* te = itsDoc->GetTextEditor(); JString fontName; JSize fontSize; itsFontMenu->GetFont(&fontName, &fontSize); const JBoolean fontChanged = JI2B( fontName != te->GetDefaultFont().GetName() || fontSize != te->GetDefaultFont().GetSize() ); JFloat vScrollScale = 1.0; if (fontChanged) { const JFontManager* fontMgr = te->GetFontManager(); const JFloat h1 = te->GetDefaultFont().GetLineHeight(); const JFloat h2 = fontMgr->GetFont(fontName, fontSize).GetLineHeight(); vScrollScale = h2 / h1; } JInteger tabCharCount; JBoolean ok = itsTabCharCountInput->GetValue(&tabCharCount); assert( ok ); JInteger crmLineWidth; ok = itsCRMLineWidthInput->GetValue(&crmLineWidth); assert( ok ); JInteger undoDepth; ok = itsUndoDepthInput->GetValue(&undoDepth); assert( ok ); JInteger rightMargin; ok = itsRightMarginInput->GetValue(&rightMargin); assert( ok ); CBPrefsManager* prefsMgr = CBGetPrefsManager(); const JBoolean textColorChanged = JNegate( itsColor[ CBPrefsManager::kTextColorIndex-1 ] == prefsMgr->GetColor(CBPrefsManager::kTextColorIndex)); // set colors before RecalcStyles() so stylers update themselves prefsMgr->SetDefaultFont(fontName, fontSize); for (JIndex j=1; j<=CBPrefsManager::kColorCount; j++) { prefsMgr->SetColor(j, itsColor[j-1]); } JPtrArray<CBTextDocument>* docList = (CBGetDocumentManager())->GetTextDocList(); const JSize docCount = docList->GetElementCount(); JProgressDisplay* pg = JNewPG(); pg->FixedLengthProcessBeginning(docCount, "Updating preferences...", kJFalse, kJFalse); for (JIndex i=1; i<=docCount; i++) { CBTextDocument* doc = docList->NthElement(i); doc->ShouldMakeBackupFile(itsCreateBackupCB->IsChecked()); doc->ShouldMakeNewBackupEveryOpen(!itsOnlyBackupIfNoneCB->IsChecked()); doc->ShouldAllocateTitleSpace(itsExtraSpaceWindTitleCB->IsChecked()); doc->ShouldOpenComplFileOnTop(itsOpenComplFileOnTopCB->IsChecked()); te = doc->GetTextEditor(); if (itsEmulatorIndex != itsOrigEmulatorIndex) { JTEKeyHandler* handler; CBInstallEmulator(kMenuIndexToEmulator[ itsEmulatorIndex-1 ], te, &handler); } te->ShouldAutoIndent(itsAutoIndentCB->IsChecked()); te->CBShouldAllowDragAndDrop(itsUseDNDCB->IsChecked()); te->ShouldMoveToFrontOfText(itsLeftToFrontOfTextCB->IsChecked()); te->ShouldBalanceWhileTyping(itsBalanceWhileTypingCB->IsChecked()); te->ShouldScrollToBalance(itsScrollToBalanceCB->IsChecked()); te->ShouldBeepWhenTypeUnbalanced(itsBeepWhenTypeUnbalancedCB->IsChecked()); te->TabShouldBeSmart(itsSmartTabCB->IsChecked()); te->TabShouldInsertSpaces(itsTabToSpacesCB->IsChecked()); if (fontChanged) { JXScrollbar *hScrollbar, *vScrollbar; const JBoolean ok = te->GetScrollbars(&hScrollbar, &vScrollbar); assert( ok ); vScrollbar->PrepareForScaledMaxValue(vScrollScale); te->SetFont(fontName, fontSize, tabCharCount); } else { te->SetTabCharCount(tabCharCount); } te->SetCRMLineWidth(crmLineWidth); te->SetUndoDepth(undoDepth); te->SetRightMarginWidth(itsRightMarginCB->IsChecked(), rightMargin); te->SetDefaultFontStyle(itsColor [ CBPrefsManager::kTextColorIndex-1 ]); te->SetBackColor(itsColor [ CBPrefsManager::kBackColorIndex-1 ]); te->SetFocusColor(itsColor [ CBPrefsManager::kBackColorIndex-1 ]); te->SetCaretColor(itsColor [ CBPrefsManager::kCaretColorIndex-1 ]); te->SetSelectionColor(itsColor [ CBPrefsManager::kSelColorIndex-1 ]); te->SetSelectionOutlineColor(itsColor [ CBPrefsManager::kSelLineColorIndex-1 ]); te->SetRightMarginColor(itsColor [ CBPrefsManager::kRightMarginColorIndex-1 ]); if (textColorChanged) { te->RecalcStyles(); } // force update of insertion font JIndex caretIndex; if (te->GetCaretLocation(&caretIndex)) { te->SetCaretLocation(caretIndex); } pg->IncrementProgress(); } CBFnMenuUpdater* updater = CBGetFnMenuUpdater(); updater->ShouldSortFnNames(itsSortFnMenuCB->IsChecked()); updater->ShouldIncludeNamespace(itsNSInFnMenuCB->IsChecked()); updater->ShouldPackFnNames(itsPackFnMenuCB->IsChecked()); JXTEBase::SetPartialWordModifier( (JXTEBase::PartialWordModifier) itsPWModRG->GetSelectedItem()); JXTEBase::ShouldUseWindowsHomeEnd(itsHomeEndCB->IsChecked()); CBTextEditor::CaretShouldFollowScroll(itsScrollCaretCB->IsChecked()); JTextEditor::ShouldCopyWhenSelect(itsCopyWhenSelectCB->IsChecked()); JXTEBase::MiddleButtonShouldPaste(itsMiddleButtonPasteCB->IsChecked()); CBSearchTextDialog* dlog = CBGetSearchTextDialog(); dlog->SetFont(fontName, fontSize); itsDoc->JPrefObject::WritePrefs(); if (itsEmulatorIndex != itsOrigEmulatorIndex) { prefsMgr->SetEmulator(kMenuIndexToEmulator[ itsEmulatorIndex-1 ]); } CBMWriteSharedPrefs(kJTrue); pg->ProcessFinished(); jdelete pg; }
JBoolean JSearchSubdirs_private ( const JCharacter* startPath, const JCharacter* name, const JBoolean isFile, const JBoolean caseSensitive, JString* path, JString* newName, JProgressDisplay& pg, JBoolean* cancelled ) { // checking this way covers partial path cases like "X11/Xlib.h" const JString fullName = JCombinePathAndName(startPath, name); if (( isFile && JFileExists(fullName)) || (!isFile && JDirectoryExists(fullName))) { const JBoolean ok = JGetTrueName(startPath, path); assert( ok ); if (newName != NULL) { *newName = name; } return kJTrue; } JDirInfo* info; if (!JDirInfo::Create(startPath, &info)) { return kJFalse; } JBoolean found = kJFalse; const JSize count = info->GetEntryCount(); // check each entry (if case sensitive, the initial check is enough) if (!caseSensitive) { for (JIndex i=1; i<=count; i++) { const JDirEntry& entry = info->GetEntry(i); if ((( isFile && entry.IsFile()) || (!isFile && entry.IsDirectory())) && JStringCompare(name, entry.GetName(), caseSensitive) == 0) { const JBoolean ok = JGetTrueName(startPath, path); assert( ok ); if (newName != NULL) { *newName = entry.GetName(); } found = kJTrue; break; } if (!pg.IncrementProgress()) { *cancelled = kJTrue; break; } } } // recurse on each directory if (!found && !(*cancelled)) { for (JIndex i=1; i<=count; i++) { const JDirEntry& entry = info->GetEntry(i); if (entry.IsDirectory() && !entry.IsLink()) { const JString& newPath = entry.GetFullName(); if (JSearchSubdirs_private(newPath, name, isFile, caseSensitive, path, newName, pg, cancelled)) { found = kJTrue; break; } } if (*cancelled || (caseSensitive && !pg.IncrementProgress())) { *cancelled = kJTrue; break; } } } delete info; return found; }