OpenEditorsWidget::OpenEditorsWidget() { m_ui.setupUi(this); setWindowTitle(tr("Open Documents")); setWindowIcon(QIcon(QLatin1String(Constants::ICON_DIR))); setFocusProxy(m_ui.editorList); m_ui.editorList->viewport()->setAttribute(Qt::WA_Hover); m_ui.editorList->setItemDelegate((m_delegate = new OpenEditorsDelegate(this))); m_ui.editorList->header()->hide(); m_ui.editorList->setIndentation(0); m_ui.editorList->setTextElideMode(Qt::ElideMiddle); m_ui.editorList->setFrameStyle(QFrame::NoFrame); m_ui.editorList->setAttribute(Qt::WA_MacShowFocusRect, false); EditorManager *em = EditorManager::instance(); m_ui.editorList->setModel(em->openedEditorsModel()); m_ui.editorList->setSelectionMode(QAbstractItemView::SingleSelection); m_ui.editorList->setSelectionBehavior(QAbstractItemView::SelectRows); m_ui.editorList->header()->setStretchLastSection(false); m_ui.editorList->header()->setResizeMode(0, QHeaderView::Stretch); m_ui.editorList->header()->setResizeMode(1, QHeaderView::Fixed); m_ui.editorList->header()->resizeSection(1, 16); m_ui.editorList->setContextMenuPolicy(Qt::CustomContextMenu); m_ui.editorList->installEventFilter(this); connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(updateCurrentItem(Core::IEditor*))); connect(m_ui.editorList, SIGNAL(clicked(QModelIndex)), this, SLOT(handleClicked(QModelIndex))); connect(m_ui.editorList, SIGNAL(pressed(QModelIndex)), this, SLOT(handlePressed(QModelIndex))); connect(m_ui.editorList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); }
void ClangDiagnostics::OnGotoPrevDiagnostic(wxCommandEvent& WXUNUSED(event)) { EditorManager* edMgr = Manager::Get()->GetEditorManager(); cbEditor* ed = edMgr->GetBuiltinActiveEditor(); if (!ed) { return; } cbStyledTextCtrl* stc = ed->GetControl(); int prevLine = -1; for (std::vector<ClDiagnostic>::const_iterator it = m_Diagnostics.begin(); it != m_Diagnostics.end(); ++it) { if ((it->line - 1) < stc->GetCurrentLine()) { prevLine = it->line - 1; } else break; } if (prevLine >= 0) { if (prevLine < stc->GetFirstVisibleLine()) { stc->GotoLine( prevLine ); stc->ScrollLines(-stc->LinesOnScreen() / 2); } else { stc->GotoLine(prevLine); stc->MakeNearbyLinesVisible(prevLine); } } }
void EmbeddedLinker::initTitle() { EditorManager* editorManager = dynamic_cast<EditorViewScene*>(scene())->mainWindow()->manager(); QString edgeTypeFriendly = editorManager->friendlyName(Id::loadFromString("qrm:/"+master->uuid().editor()+"/"+master->uuid().diagram()+"/"+edgeType.element())); float textWidth = edgeTypeFriendly.size()*10; float rectWidth = master->boundingRect().right() - master->boundingRect().left(); float rectHeight = master->boundingRect().bottom() - master->boundingRect().top(); int x = 0; int y = 0; if (scenePos().y() < master->scenePos().y() + rectHeight/3) y = -boundingRect().height() - 10; else if (scenePos().y() > master->scenePos().y() + 2*rectHeight/3) y = +boundingRect().height() - 10; if (scenePos().x() < master->scenePos().x() + rectWidth/3) x = -boundingRect().width() - textWidth + 20; else if (scenePos().x() > master->scenePos().x() + 2*rectWidth/3) x = +boundingRect().width() - 10; title = new ElementTitle(x,y,edgeTypeFriendly); title->setTextWidth(textWidth); title->setParentItem(this); }
void EditorView::closeView() { EditorManager *em = ICore::editorManager(); IEditor *editor = currentEditor(); if (editor) em->closeEditor(editor); }
void ClangCodeCompletion::OnCodeCompleteFinished( ClangEvent& event ) { //fprintf(stdout,"%s\n", __PRETTY_FUNCTION__ ); if( event.GetTranslationUnitId() != m_TranslUnitId ) { return; } if (m_CCOutstanding > 0) { EditorManager* edMgr = Manager::Get()->GetEditorManager(); cbEditor* ed = edMgr->GetBuiltinActiveEditor(); if (ed) { if (ed->GetControl()->GetCurrentPos() == m_CCOutstandingPos) { m_CCOutstandingResults = event.GetCodeCompletionResults(); if ( m_CCOutstandingResults.size() > 0 ) { CodeBlocksEvent evt(cbEVT_COMPLETE_CODE); evt.SetInt(1); Manager::Get()->ProcessEvent(evt); return; } } } m_CCOutstanding--; } }
int copystrings::Execute() { //do your magic ;) EditorManager* man = Manager::Get()->GetEditorManager(); if(!man) return -1; cbEditor* myeditor = man->GetBuiltinActiveEditor(); if(!myeditor) return -1; if(cbStyledTextCtrl* ctrl = myeditor->GetControl()) { wxString result(_T("")); wxString input(_T("")); input = ctrl->GetText(); GetStrings(input, result); if (wxTheClipboard->Open()) { wxTheClipboard->SetData( new wxTextDataObject(result)); wxTheClipboard->Close(); } cbMessageBox(_T("Literal strings copied to clipboard.")); } return -1; }
void ClangPlugin::OnCreateTranslationUnit( wxCommandEvent& event ) { if ( m_TranslUnitId != wxNOT_FOUND ) { return; } wxString filename = event.GetString(); if (filename.Length() == 0) return; EditorManager* edMgr = Manager::Get()->GetEditorManager(); cbEditor* ed = edMgr->GetBuiltinActiveEditor(); if (ed) { if (filename != ed->GetFilename()) return; std::map<wxString, wxString> unsavedFiles; for (int i = 0; i < edMgr->GetEditorsCount(); ++i) { ed = edMgr->GetBuiltinEditor(i); if (ed && ed->GetModified()) unsavedFiles.insert(std::make_pair(ed->GetFilename(), ed->GetControl()->GetText())); } ClangProxy::CreateTranslationUnitJob job( cbEVT_CLANG_ASYNCTASK_FINISHED, idClangCreateTU, filename, m_CompileCommand, unsavedFiles ); m_Proxy.AppendPendingJob(job); } }
void OpenFilesListPlugin::RebuildOpenFilesTree() { if (Manager::IsAppShuttingDown()) return; EditorManager* mgr = Manager::Get()->GetEditorManager(); m_pTree->Freeze(); m_pTree->DeleteChildren(m_pTree->GetRootItem()); if (!mgr->GetEditorsCount()) { m_pTree->Thaw(); return; } // loop all open editors for (int i = 0; i < mgr->GetEditorsCount(); ++i) { EditorBase* ed = mgr->GetEditor(i); if (!ed || !ed->VisibleToTree()) continue; wxString shortname = ed->GetShortName(); int mod = GetOpenFilesListIcon(ed); wxTreeItemId item = m_pTree->AppendItem(m_pTree->GetRootItem(), shortname, mod, mod, new OpenFilesListData(ed)); if (mgr->GetActiveEditor() == ed) m_pTree->SelectItem(item); } m_pTree->SortChildren(m_pTree->GetRootItem()); m_pTree->Expand(m_pTree->GetRootItem()); m_pTree->Thaw(); }
wxString wxsCoder::GetFullCode(const wxString& FileName,wxFontEncoding& Encoding,bool &UseBOM) { wxMutexLocker Lock(DataMutex); wxString FixedFileName = NormalizeFileName(FileName); FlushFile(FixedFileName); // Checking if editor is opened EditorManager* EM = Manager::Get()->GetEditorManager(); assert ( EM != 0 ); cbEditor* Editor = EM->GetBuiltinEditor(FixedFileName); if ( Editor ) { Encoding = Editor->GetEncoding(); UseBOM = Editor->GetUseBom(); cbStyledTextCtrl* Ctrl = Editor->GetControl(); return Ctrl->GetText(); } else { EncodingDetector Detector(FixedFileName); Encoding = Detector.GetFontEncoding(); UseBOM = Detector.GetBOMSizeInBytes() > 0; return Detector.IsOK() ? Detector.GetWxStr() : _T(""); } }
void ClangPlugin::OnEditorSave(CodeBlocksEvent& event) { event.Skip(); #ifdef CLANGPLUGIN_TRACE_FUNCTIONS fprintf(stdout,"%s\n", __PRETTY_FUNCTION__); #endif EditorManager* edMgr = Manager::Get()->GetEditorManager(); cbEditor* ed = edMgr->GetBuiltinEditor(event.GetEditor()); if (!ed) { return; } if ( m_TranslUnitId == -1 ) return; std::map<wxString, wxString> unsavedFiles; // Our saved file is not yet known to all translation units since it's no longer in the unsaved files. We update them here unsavedFiles.insert(std::make_pair(ed->GetFilename(), ed->GetControl()->GetText())); for (int i = 0; i < edMgr->GetEditorsCount(); ++i) { cbEditor* editor = edMgr->GetBuiltinEditor(i); if (editor && editor->GetModified()) unsavedFiles.insert(std::make_pair(editor->GetFilename(), editor->GetControl()->GetText())); } ClangProxy::ReparseJob job( cbEVT_CLANG_ASYNCTASK_FINISHED, idClangReparse, m_TranslUnitId, m_CompileCommand, ed->GetFilename(), unsavedFiles, true); m_Proxy.AppendPendingJob(job); }
void ClangPlugin::OnEditorClose(CodeBlocksEvent& event) { event.Skip(); #ifdef CLANGPLUGIN_TRACE_FUNCTIONS fprintf(stdout,"%s\n", __PRETTY_FUNCTION__); #endif int translId = m_TranslUnitId; EditorManager* edm = Manager::Get()->GetEditorManager(); if (!edm) { event.Skip(); return; } cbEditor* ed = edm->GetBuiltinEditor(event.GetEditor()); if (ed) { if (ed != m_pLastEditor) { translId = m_Proxy.GetTranslationUnitId(m_TranslUnitId, event.GetEditor()->GetFilename()); } } ClangProxy::RemoveTranslationUnitJob job( cbEVT_CLANG_ASYNCTASK_FINISHED, idClangRemoveTU, translId); m_Proxy.AppendPendingJob(job); if (translId == m_TranslUnitId) { m_TranslUnitId = wxNOT_FOUND; m_ReparseNeeded = 0; } }
void Exporter::ExportFile(BaseExporter *exp, const wxString &default_extension, const wxString &wildcard) { if (!IsAttached()) { return; } EditorManager* em = Manager::Get()->GetEditorManager(); cbEditor* cb = em->GetBuiltinActiveEditor(); wxString filename = wxFileSelector(_("Choose the filename"), _T(""), wxFileName(cb->GetFilename()).GetName() + _T(".") + default_extension, default_extension, wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (filename.IsEmpty()) { return; } cbStyledTextCtrl* stc = cb->GetControl(); if (!stc) return; int lineCount = -1; if (wxMessageBox(_("Would you like to have the line numbers printed in the exported file?"), _("Export line numbers"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION) == wxYES) { lineCount = stc->GetLineCount(); } exp->Export(filename, cb->GetFilename(), stc->GetStyledText(0, stc->GetLength() - 1), cb->GetColourSet(), lineCount, stc->GetTabWidth()); }
void ClangPlugin::RequestReparse(const ClTranslUnitId translUnitId, const wxString& filename) { EditorManager* edMgr = Manager::Get()->GetEditorManager(); cbEditor* ed = edMgr->GetBuiltinActiveEditor(); if (!ed) { return; } if (translUnitId == wxNOT_FOUND) { std::cout<<"Translation unit not found: "<<translUnitId<<" file="<<(const char*)ed->GetFilename().c_str()<<std::endl; return; } if ( translUnitId == m_TranslUnitId ) { m_ReparseNeeded = 0; } std::map<wxString, wxString> unsavedFiles; for (int i = 0; i < edMgr->GetEditorsCount(); ++i) { ed = edMgr->GetBuiltinEditor(i); if (ed && ed->GetModified()) unsavedFiles.insert(std::make_pair(ed->GetFilename(), ed->GetControl()->GetText())); } ClangProxy::ReparseJob job( cbEVT_CLANG_ASYNCTASK_FINISHED, idClangReparse, translUnitId, m_CompileCommand, filename, unsavedFiles); m_Proxy.AppendPendingJob(job); }
void NassiPlugin::OnInsertCFromDiagram(wxCommandEvent &event) { // check if user can isert an opened diagram unsigned idx = 0; for ( int i = 0 ; i < Manager::Get()->GetEditorManager()->GetEditorsCount() ; i++ ) { EditorBase *ed = Manager::Get()->GetEditorManager()->GetEditor( i ); if ( NassiEditorPanel::IsNassiEditor( ed ) ) { NassiEditorPanel *ned = (NassiEditorPanel *)ed; if ( event.GetId() == insertCFromDiagram[idx] ) { EditorManager* emngr = Manager::Get()->GetEditorManager(); if ( !emngr ) return; EditorBase *edb = emngr->GetActiveEditor(); if ( !edb || !edb->IsBuiltinEditor() ) return; unsigned int indent = ((cbEditor*)edb)->GetLineIndentInSpaces(); // from current line cbStyledTextCtrl *stc = ((cbEditor*)edb)->GetControl(); if ( !stc ) return; wxStringOutputStream ostrstream; wxTextOutputStream text_stream(ostrstream); if ( !ned ) return; ned->GetCSource(text_stream, indent); stc->InsertText(wxSCI_INVALID_POSITION, ostrstream.GetString()); } //some comment idx++; } } }
void WorkspaceBrowserF::OnTreeItemSelected(wxTreeEvent& event) { if (Manager::IsAppShuttingDown()) return; if (m_pBrowserBuilder) { if (!m_pBrowserBuilder->SelectNode(event.GetItem())) return; } event.Allow(); EditorManager* edMan = Manager::Get()->GetEditorManager(); if (!edMan) return; cbEditor* ed = edMan->GetBuiltinActiveEditor(); if (!ed) return; cbStyledTextCtrl* control = ed->GetControl(); int currentLine = control->GetCurrentLine() + 1; wxString activeFilename = ed->GetFilename(); if (activeFilename.IsEmpty()) return; MarkSymbol(UnixFilename(activeFilename), currentLine); }
void CscopePlugin::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* /*data*/) { if ( !IsAttached() || m_pProcess) return; if(type != mtEditorManager || !menu ) return; EditorManager* emngr = Manager::Get()->GetEditorManager(); if ( !emngr ) return; EditorBase *edb = emngr->GetActiveEditor(); if ( !edb || !edb->IsBuiltinEditor() ) return; cbStyledTextCtrl* stc = ((cbEditor*)edb)->GetControl(); if ( !stc ) return; if ( stc->GetLexer() != wxSCI_LEX_CPP) return; wxString word = GetWordAtCaret(); if ( word.IsEmpty() ) return; PluginManager *pluginManager = Manager::Get()->GetPluginManager(); int idximp = pluginManager->GetFindMenuItemFirst() + pluginManager->GetFindMenuItemCount(); menu->Insert(idximp++, idOnFindFunctionsCalledByThisFuncion, _("Find functions called by '") + word + _T("'")); menu->Insert(idximp++, idOnFindFunctionsCallingThisFunction, _("Find functions calling '") + word + _T("'")); pluginManager->RegisterFindMenuItems(false, 2); }
void NassiPlugin::ParseC(wxCommandEvent & /*event*/) { EditorManager* emngr = Manager::Get()->GetEditorManager(); if ( !emngr ) return; EditorBase *edb = emngr->GetActiveEditor(); if ( !edb || !edb->IsBuiltinEditor() ) return; cbStyledTextCtrl* stc = ((cbEditor*)edb)->GetControl(); if ( !stc ) return; NassiEditorPanel *panel = new NassiEditorPanel(_T(""), _T("")); switch ( stc->GetLexer() ) { case wxSCI_LEX_CPP: { const wxString str = stc->GetSelectedText(); if ( !panel->ParseC(str) ) { panel->Close(); wxMessageBox(_("unable to parse input"), _("Error!")); } //else stc->SetReadOnly(true); } break; default: break; } }
void OccurrencesHighlighting::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data) { // Some library module is ready to display a pop-up menu. // Check the parameter \"type\" and see which module it is // and append any items you need in the menu... // TIP: for consistency, add a separator as the first item... if ( !IsAttached() ) return; if (type != mtEditorManager || !menu) return; EditorManager* emngr = Manager::Get()->GetEditorManager(); if ( !emngr ) return; EditorBase *edb = emngr->GetActiveEditor(); if ( !edb || !edb->IsBuiltinEditor() ) return; cbStyledTextCtrl* stc = ((cbEditor*)edb)->GetControl(); if ( !stc ) return; wxString word = GetWordAtCaret(); if ( word.IsEmpty() ) return; menu->AppendSeparator(); if ( m_texts.find(word) == m_texts.end() ) menu->Append(idMenuEntryPermanent, _("Permanently Highlight '") + word + _T("'")); else menu->Append(idMenuEntryRemove, _("Don't Highlight '") + word + _T("'")); }
void CodeRefactoring::DoRenameSymbols(const wxString& targetText, const wxString& replaceText) { EditorManager* edMan = Manager::Get()->GetEditorManager(); cbEditor* editor = edMan->GetBuiltinActiveEditor(); if (!editor) return; cbProject* project = m_NativeParser.GetProjectByEditor(editor); for (SearchDataMap::iterator it = m_SearchDataMap.begin(); it != m_SearchDataMap.end(); ++it) { // check if the file is already opened in built-in editor and do search in it cbEditor* ed = edMan->IsBuiltinOpen(it->first); if (!ed) { ProjectFile* pf = project ? project->GetFileByFilename(it->first) : 0; ed = edMan->Open(it->first, it->second.front().pos, pf); } cbStyledTextCtrl* control = ed->GetControl(); control->BeginUndoAction(); for (SearchDataList::reverse_iterator rIter = it->second.rbegin(); rIter != it->second.rend(); ++rIter) { control->SetTargetStart(rIter->pos); control->SetTargetEnd(rIter->pos + targetText.Len()); control->ReplaceTarget(replaceText); // for find references rIter->text.Replace(targetText, replaceText); } control->EndUndoAction(); } }
wxString CodeRefactoring::GetSymbolUnderCursor() { EditorManager* edMan = Manager::Get()->GetEditorManager(); cbEditor* editor = edMan->GetBuiltinActiveEditor(); if (!editor) return wxEmptyString; cbStyledTextCtrl* control = editor->GetControl(); const int style = control->GetStyleAt(control->GetCurrentPos()); if (control->IsString(style) || control->IsComment(style)) return wxEmptyString; if (!m_NativeParser.GetParser().Done()) { wxString msg(_("The Parser is still parsing files.")); cbMessageBox(msg, _("Code Refactoring"), wxOK | wxICON_WARNING); msg += m_NativeParser.GetParser().NotDoneReason(); CCLogger::Get()->DebugLog(msg); return wxEmptyString; } const int pos = editor->GetControl()->GetCurrentPos(); const int start = editor->GetControl()->WordStartPosition(pos, true); const int end = editor->GetControl()->WordEndPosition(pos, true); return editor->GetControl()->GetTextRange(start, end); }
void EditorTweaks::OnRelease(bool /*appShutDown*/) { m_tweakmenu = 0; // EditorHooks::UnregisterHook(m_EditorHookId, true); EditorManager* em = Manager::Get()->GetEditorManager(); for (int i=0;i<em->GetEditorsCount();i++) { cbEditor* ed=em->GetBuiltinEditor(i); if (ed && ed->GetControl()) { ed->GetControl()->Disconnect(wxEVT_NULL,(wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction)&EditorTweaks::OnKeyPress); ed->GetControl()->Disconnect(wxEVT_NULL,(wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction)&EditorTweaks::OnChar); } } AlignerMenuEntry e; ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("EditorTweaks")); std::sort (AlignerMenuEntries.begin(), AlignerMenuEntries.end(),CompareAlignerMenuEntryObject); std::reverse( AlignerMenuEntries.begin(), AlignerMenuEntries.end()); int i = 0; for (; i < cfg->ReadInt(_T("/aligner/max_saved_entries"),defaultStoredAlignerEntries) && i < static_cast<int>(AlignerMenuEntries.size()) ; ++i) { cfg->Write(wxString::Format(_T("/aligner/first_name_%d"),i),AlignerMenuEntries[i].MenuName); cfg->Write(wxString::Format(_T("/aligner/first_argument_string_%d"),i) ,AlignerMenuEntries[i].ArgumentString); Disconnect(AlignerMenuEntries[i].id, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(EditorTweaks::OnAlign) ); } cfg->Write(_T("/aligner/saved_entries"),i); for (; i < static_cast<int>(AlignerMenuEntries.size()) ; ++i) Disconnect(AlignerMenuEntries[i].id, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(EditorTweaks::OnAlign) ); cfg->Write(wxT("/suppress_insert_key"), m_suppress_insert); cfg->Write(wxT("/convert_braces"), m_convert_braces); }
void ReopenEditorListView::DoOpen(wxString fname) { EditorManager* em = Manager::Get()->GetEditorManager(); if(!fname.IsEmpty() && !em->IsOpen(fname)) { em->Open(fname); } }
cbDebuggerPlugin::SyncEditorResult cbDebuggerPlugin::SyncEditor(const wxString& filename, int line, bool setMarker) { if (setMarker) { EditorManager* edMan = Manager::Get()->GetEditorManager(); for (int i = 0; i < edMan->GetEditorsCount(); ++i) { cbEditor* ed = edMan->GetBuiltinEditor(i); if (ed) ed->SetDebugLine(-1); } } FileType ft = FileTypeOf(filename); if (ft != ftSource && ft != ftHeader && ft != ftResource) { // if the line is >= 0 and ft == ftOther assume, that we are in header without extension if (line < 0 || ft != ftOther) { ShowLog(false); Log(_("Unknown file: ") + filename, Logger::error); InfoWindow::Display(_("Unknown file"), _("File: ") + filename, 5000); return SyncFileUnknown; // don't try to open unknown files } } cbProject* project = Manager::Get()->GetProjectManager()->GetActiveProject(); ProjectFile* f = project ? project->GetFileByFilename(filename, false, true) : nullptr; wxString unixfilename = UnixFilename(filename); wxFileName fname(unixfilename); if (project && fname.IsRelative()) fname.MakeAbsolute(project->GetBasePath()); // gdb can't work with spaces in filenames, so we have passed it the shorthand form (C:\MYDOCU~1 etc) // revert this change now so the file can be located and opened... // we do this by calling GetLongPath() cbEditor* ed = Manager::Get()->GetEditorManager()->Open(fname.GetLongPath()); if (ed) { ed->Show(true); if (f && !ed->GetProjectFile()) ed->SetProjectFile(f); ed->GotoLine(line - 1, false); if (setMarker) ed->SetDebugLine(line - 1); return SyncOk; } else { ShowLog(false); Log(_("Cannot open file: ") + filename, Logger::error); InfoWindow::Display(_("Cannot open file"), _("File: ") + filename, 5000); return SyncFileNotFound; } }
bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags, const QList<MemoryMarkup> &ml, const QPoint &pos, QString title, QWidget *parent) { const bool readOnly = (flags & DebuggerEngine::MemoryReadOnly) != 0; if (title.isEmpty()) title = tr("Memory at 0x%1").arg(addr, 0, 16); // Separate view? if (flags & DebuggerEngine::MemoryView) { // Ask BIN editor plugin for factory service and have it create a bin editor widget. QWidget *binEditor = 0; if (QObject *factory = ExtensionSystem::PluginManager::instance()->getObjectByClassName(QLatin1String("BINEditor::BinEditorWidgetFactory"))) binEditor = ExtensionSystem::invoke<QWidget *>(factory, "createWidget", (QWidget *)0); if (!binEditor) return false; connectBinEditorWidget(binEditor); MemoryView::setBinEditorReadOnly(binEditor, readOnly); MemoryView::setBinEditorNewWindowRequestAllowed(binEditor, true); MemoryView *topLevel = 0; // Memory view tracking register value, providing its own updating mechanism. if (flags & DebuggerEngine::MemoryTrackRegister) { RegisterMemoryView *rmv = new RegisterMemoryView(binEditor, parent); rmv->init(m_engine->registerHandler(), int(addr)); topLevel = rmv; } else { // Ordinary memory view MemoryView::setBinEditorMarkup(binEditor, ml); MemoryView::setBinEditorRange(binEditor, addr, MemoryAgent::DataRange, MemoryAgent::BinBlockSize); topLevel = new MemoryView(binEditor, parent); topLevel->setWindowTitle(title); } m_views << topLevel; topLevel->move(pos); topLevel->show(); return true; } // Editor: Register tracking not supported. QTC_ASSERT(!(flags & DebuggerEngine::MemoryTrackRegister), return false); EditorManager *editorManager = EditorManager::instance(); if (!title.endsWith(QLatin1Char('$'))) title.append(QLatin1String(" $")); IEditor *editor = editorManager->openEditorWithContents( Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title); if (!editor) return false; editor->setProperty(Constants::OPENED_BY_DEBUGGER, QVariant(true)); editor->setProperty(Constants::OPENED_WITH_MEMORY, QVariant(true)); QWidget *editorBinEditor = editor->widget(); connectBinEditorWidget(editorBinEditor); MemoryView::setBinEditorReadOnly(editorBinEditor, readOnly); MemoryView::setBinEditorNewWindowRequestAllowed(editorBinEditor, true); MemoryView::setBinEditorRange(editorBinEditor, addr, MemoryAgent::DataRange, MemoryAgent::BinBlockSize); MemoryView::setBinEditorMarkup(editorBinEditor, ml); m_editors << editor; editorManager->activateEditor(editor); return true; }
void CodeRefactoring::GetOpenedFiles(wxArrayString& files) { EditorManager* edMan = Manager::Get()->GetEditorManager(); if (edMan) { for (int i = 0; i < edMan->GetEditorsCount(); ++i) files.Add(edMan->GetEditor(i)->GetFilename()); } }
inline void CrashHandlerSaveEditorFiles(wxString& buf) { wxString path; //get the "My Files" folder HRESULT result = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, wxStringBuffer(path, MAX_PATH)); if (FAILED(result)) { //get at least the profiles folder path = ConfigManager::GetHomeFolder(); } path << _T("\\cb-crash-recover"); if (!wxDirExists(path)) wxMkdir(path); //make a sub-directory of the current date & time wxDateTime now = wxDateTime::Now(); path << now.Format(_T("\\%Y%m%d-%H%M%S")); EditorManager* em = Manager::Get()->GetEditorManager(); if (em) { bool AnyFileSaved = false; if (wxMkdir(path) && wxDirExists(path)) { for (int i = 0; i < em->GetEditorsCount(); ++i) { cbEditor* ed = em->GetBuiltinEditor(em->GetEditor(i)); if (ed) { wxFileName fn(ed->GetFilename()); wxString fnpath = path + _T("/") + fn.GetFullName(); wxString newfnpath = fnpath; // add number if filename already exists e.g. main.cpp.001, main.cpp.002, ... int j = 1; while (wxFileExists(newfnpath)) newfnpath = fnpath + wxString::Format(wxT(".%03d"),j); if (cbSaveToFile(newfnpath, ed->GetControl()->GetText(), ed->GetEncoding(), ed->GetUseBom() ) ) { AnyFileSaved = true; } } } if (AnyFileSaved) { buf << _("The currently opened files have been saved to the directory\n"); buf << path; buf << _("\nHopefully, this will prevent you from losing recent modifications.\n\n"); } else wxRmdir(path); } } }
// ---------------------------------------------------------------------------- void JumpTracker::OnMenuJumpNext(wxCommandEvent &event) // ---------------------------------------------------------------------------- { #if defined(LOGGING) //LOGIT( _T("JT [%s]"), _T("OnMenuJumpNext")); #endif m_bJumpInProgress = true; do { int count = m_ArrayOfJumpData.GetCount(); if (not count) break; if ( count > 1 ) m_Cursor += 1; if (m_Cursor > (int)count-1) m_Cursor = 0; EditorManager* edmgr = Manager::Get()->GetEditorManager(); int cursor = m_Cursor; wxString edFilename; long edPosn; bool found = false; for (int i = 0; i<count; ++i, ++cursor) { if (cursor > count-1) cursor = 0; JumpData& jumpNext = m_ArrayOfJumpData.Item(cursor); edFilename = jumpNext.GetFilename(); edPosn = jumpNext.GetPosition(); if (not edmgr->IsOpen(edFilename)) continue; found = true; break; } if (not found) break; m_Cursor = cursor; #if defined(LOGGING) LOGIT( _T("JT OnMenuJumpNext [%s][%ld]curs[%d]"), edFilename.c_str(), edPosn, m_Cursor); #endif // activate editor EditorBase* eb = edmgr->GetEditor(edFilename); if (not eb) break; edmgr->SetActiveEditor(eb); // position to editor line cbEditor* cbed = edmgr->GetBuiltinEditor(eb); if (not cbed) break; cbed->GotoLine(cbed->GetControl()->LineFromPosition(edPosn)); //center on scrn cbed->GetControl()->GotoPos(edPosn); }while(0); m_bJumpInProgress = false; return; }
void cbDebuggerPlugin::ClearActiveMarkFromAllEditors() { EditorManager* edMan = Manager::Get()->GetEditorManager(); for (int i = 0; i < edMan->GetEditorsCount(); ++i) { cbEditor* ed = edMan->GetBuiltinEditor(i); if (ed) ed->SetDebugLine(-1); } }
void CompilerErrors::DoClearErrorMarkFromAllEditors() { EditorManager* edMan = Manager::Get()->GetEditorManager(); for (int i = 0; i < edMan->GetEditorsCount(); ++i) { cbEditor* ed = edMan->GetBuiltinEditor(i); if (ed) ed->SetErrorLine(-1); } }
void Highlighter::ClearAllIndications()const { EditorManager *edm = Manager::Get()->GetEditorManager(); for ( int i = 0 ; i < edm->GetEditorsCount() ; ++i) { cbEditor *ed = edm->GetBuiltinEditor( i ); if ( ed ) ClearAllIndications(ed->GetControl()); } }