Example #1
0
bool MainBook::DoSelectPage(wxWindow* win)
{
    LEditor* editor = dynamic_cast<LEditor*>(win);
    if(editor) {
        editor->SetActive();
        m_quickFindBar->SetEditor(editor);

    } else {
        m_quickFindBar->ShowForPlugins();
    }

    // Remove context menu if needed
    DoHandleFrameMenu(editor);

    if(!editor) {
        clMainFrame::Get()->SetFrameTitle(NULL);
        clMainFrame::Get()->GetStatusBar()->SetLinePosColumn(wxEmptyString);
        UpdateNavBar(NULL);
        SendCmdEvent(wxEVT_CMD_PAGE_CHANGED, win);

    } else {
        // if(editor->GetContext()->GetName() == wxT("C++")) {
        //     if(clMainFrame::Get()->GetMenuBar()->FindMenu(wxT("C++")) == wxNOT_FOUND) {
        //         clMainFrame::Get()->GetMenuBar()->Append(wxXmlResource::Get()->LoadMenu(wxT("editor_right_click")),
        //                                                  wxT("C++"));
        //     }
        // }
        wxCommandEvent event(wxEVT_ACTIVE_EDITOR_CHANGED);
        EventNotifier::Get()->AddPendingEvent(event);
    }

    return true;
}
Example #2
0
bool FindInFilesDialog::Show()
{
    bool res = IsShown() || wxFrame::Show();
    if(res) {

        // update the combobox
        m_findString->Clear();
        m_findString->Append(m_data.GetFindStringArr());
        DoSetFileMask();
        m_findString->SetValue(m_data.GetFindString());

        LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
        if(editor) {
            // if we have an open editor, and a selected text, make this text the search string
            wxString selText = editor->GetSelectedText();
            if(!selText.IsEmpty()) {
                m_findString->SetValue(selText);
            }
        }

        m_findString->SetSelection(-1, -1); // select all
        m_findString->SetFocus();
    }
    return res;
}
Example #3
0
void EditHandler::ProcessUpdateUIEvent(wxWindow *owner, wxUpdateUIEvent &event)
{
    LEditor *editor = dynamic_cast<LEditor*>(owner);

    if (event.GetId() == wxID_COPY || event.GetId() == XRCID("trim_trailing") || event.GetId() == XRCID("to_lower") || event.GetId() == XRCID("to_upper")) {
        event.Enable(editor);

    } else if (event.GetId() == wxID_CUT) {
        event.Enable(editor);

    } else if (event.GetId() == wxID_PASTE) {
#ifdef __WXGTK__
        event.Enable(editor);
#else
        event.Enable(editor && editor->CanPaste());
#endif
    } else if (event.GetId() == wxID_UNDO) {
        event.Enable(editor && editor->CanUndo());
    } else if (event.GetId() == wxID_REDO) {
        event.Enable(editor && editor->CanRedo());
    } else if (event.GetId() == wxID_SELECTALL) {
        event.Enable(editor && editor->GetLength() > 0);
    } else if (event.GetId() == wxID_DUPLICATE || event.GetId() == wxID_DELETE) {
        event.Enable(true);
    } else {
        event.Enable(false);
    }
    event.Skip(false);
}
Example #4
0
void QuickFindBar::OnHighlightMatchesUI(wxUpdateUIEvent& event)
{
    if(ManagerST::Get()->IsShutdownInProgress()) {
        event.Enable(false);

    } else if(!m_sci) {
        event.Enable(false);

    } else if(m_findWhat->GetValue().IsEmpty()) {
        event.Enable(false);

    } else {
        LEditor* editor = dynamic_cast<LEditor*>(m_sci);
        if(!editor) {
            event.Enable(false);

        } else {
            // Check to see if there are any markers
            int nLine = editor->LineFromPosition(0);
            int nFoundLine = editor->MarkerNext(nLine, mmt_find_bookmark);

            event.Enable(true);
            event.Check(nFoundLine != wxNOT_FOUND);
        }
    }
}
Example #5
0
LEditor* MainBook::NewEditor()
{
    static int fileCounter = 0;

    wxString fileNameStr(_("Untitled"));
    fileNameStr << ++fileCounter;
    wxFileName fileName(fileNameStr);

    // A Nice trick: hide the notebook, open the editor
    // and then show it
    bool hidden(false);
    if(m_book->GetPageCount() == 0) hidden = GetSizer()->Hide(m_book);

    LEditor* editor = new LEditor(m_book);
    editor->SetFileName(fileName);
    AddPage(editor, fileName.GetFullName(), fileName.GetFullPath(), wxNullBitmap, true);

#ifdef __WXMAC__
    m_book->GetSizer()->Layout();
#endif

    // SHow the notebook
    if(hidden) GetSizer()->Show(m_book);

    editor->SetActive();
    return editor;
}
Example #6
0
TagEntryPtr PluginManager::GetTagAtCaret(bool scoped, bool impl)
{
    LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    if(!editor)
        return NULL;
    return editor->GetContext()->GetTagAtCaret(scoped, impl);
}
Example #7
0
bool MainBook::DoSelectPage(wxWindow* win)
{
    LEditor *editor = dynamic_cast<LEditor*>(win);
    if ( editor ) {
        editor->SetActive();
        m_quickFindBar->SetEditor( editor );
        
    } else {
        m_quickFindBar->ShowForPlugins();
    }

    // Remove context menu if needed
    DoHandleFrameMenu(editor);

    if (!editor) {
        clMainFrame::Get()->SetFrameTitle(NULL);
        clMainFrame::Get()->SetStatusMessage(wxEmptyString, 1); // clear line & column indicator
        UpdateNavBar(NULL);
        SendCmdEvent(wxEVT_CMD_PAGE_CHANGED, win);

    } else {
        if (editor->GetContext()->GetName() == wxT("C++")) {
            if (clMainFrame::Get()->GetMenuBar()->FindMenu(wxT("C++")) == wxNOT_FOUND) {
                clMainFrame::Get()->GetMenuBar()->Append(wxXmlResource::Get()->LoadMenu(wxT("editor_right_click")), wxT("C++"));
            }
        }
        SendCmdEvent(wxEVT_ACTIVE_EDITOR_CHANGED, (IEditor*)editor);
    }

    return true;
}
Example #8
0
void PluginManager::ProcessEditEvent(wxCommandEvent& e, IEditor* editor)
{
    LEditor* lEditor = dynamic_cast<LEditor*>(editor);
    if(lEditor) {
        lEditor->OnMenuCommand(e);
    }
}
Example #9
0
void PluginManager::FindAndSelect(const wxString& pattern, const wxString& name, int pos)
{
    LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    if(editor) {
        editor->FindAndSelectV(pattern, name, pos, NavMgr::Get());
        editor->SetActive();
    }
}
Example #10
0
void NewBuildTab::OnOpenInEditor(wxCommandEvent& e)
{
    wxString content = this->GetBuildContent();
    LEditor *editor = clMainFrame::Get()->GetMainBook()->NewEditor();
    if ( editor ) {
        editor->SetText(content);
    }
}
Example #11
0
void BuildTabTopPanel::OnPaste(wxCommandEvent& event)
{
    wxString content = m_buildTab->GetBuildContent();
    LEditor *editor = clMainFrame::Get()->GetMainBook()->NewEditor();
    if ( editor ) {
        editor->SetText(content);
    }
}
Example #12
0
wxFileName NavBar::DoGetCurFileName() const
{
    LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    if(!editor) return wxFileName();

    const wxFileName& fn = editor->GetFileName();
    return fn;
}
Example #13
0
void SyntaxHighlightDlg::LoadLexers(const wxString& theme)
{
#ifdef __WXMSW__
    wxWindowUpdateLocker locker(this);
#endif

    // get the current open editor's lexer name
    wxString currentLexer;
    LEditor *editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    if(editor) {
        currentLexer = editor->GetContext()->GetName();
        currentLexer.MakeLower();
    }

    //remove old lexers
    if (m_lexersBook->GetPageCount() > 0) {
        m_lexersBook->DeleteAllPages();
    }

    //update the theme name
    EditorConfigST::Get()->SaveStringValue(wxT("LexerTheme"), theme);

    //load all lexers
    EditorConfigST::Get()->LoadLexers(false);

    std::map<wxString, LexerConfPtr>::const_iterator iter = EditorConfigST::Get()->LexerBegin();
    for (; iter != EditorConfigST::Get()->LexerEnd(); iter++) {
        LexerConfPtr lexer = iter->second;

        wxString lexName = lexer->GetName();
        lexName.Trim().Trim(false);
        if(lexName.IsEmpty())
            continue;

        // get the parent node for this lexer
        wxString firstChar = lexName.Mid(0, 1).MakeUpper();
        size_t parentIndex(wxString::npos);
        for(size_t i=0; i<m_lexersBook->GetPageCount(); i++) {
            wxString pageText = m_lexersBook->GetPageText(i);
            pageText.MakeUpper();
            if( pageText.StartsWith(firstChar) ) {
                parentIndex = i;
                break;
            }
        }

        if(parentIndex == wxString::npos) {
            // add parent node
            m_lexersBook->AddPage(CreateLexerPage(m_lexersBook, lexer), lexer->GetName(), currentLexer == iter->second->GetName());

        } else {
            m_lexersBook->InsertPage(parentIndex, CreateLexerPage(m_lexersBook, lexer), lexer->GetName(), currentLexer == iter->second->GetName());
        }
    }
    // The outputview colours are global to all a theme's lexors, so are dealt with separately
    m_colourPickerOutputPanesFgColour->SetColour(wxColour(EditorConfigST::Get()->GetCurrentOutputviewFgColour()));
    m_colourPickerOutputPanesBgColour->SetColour(wxColour(EditorConfigST::Get()->GetCurrentOutputviewBgColour()));
}
Example #14
0
void WordWrapHandler::ProcessCommandEvent(wxWindow *owner, wxCommandEvent &event)
{
    LEditor *editor = dynamic_cast<LEditor*>(owner);
    if ( !editor ) {
        return;
    }

    editor->SetWrapMode(event.IsChecked() ? wxSTC_WRAP_WORD : wxSTC_WRAP_NONE);
}
Example #15
0
void GotoDefinitionHandler::ProcessUpdateUIEvent(wxWindow *owner, wxUpdateUIEvent &event)
{
    LEditor *editor = dynamic_cast<LEditor*>(owner);
    if (event.GetId() == XRCID("goto_previous_definition")) {
        event.Enable(editor && editor->CanGotoPreviousDefintion());
    } else {
        event.Enable(editor != NULL);
    }
}
Example #16
0
void WorkspaceTab::OnShowFile(wxCommandEvent& e)
{
    LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    if(editor && !editor->GetProject().IsEmpty()) {
        m_fileView->ExpandToPath(editor->GetProject(), editor->GetFileName());
        ManagerST::Get()->ShowWorkspacePane(m_caption);
    }
    e.Skip();
}
Example #17
0
void ClangDriver::DoGotoDefinition(ClangThreadReply* reply)
{
    CHECK_CLANG_ENABLED();
    LEditor* editor = clMainFrame::Get()->GetMainBook()->OpenFile(reply->filename, wxEmptyString, reply->line);
    if(editor) {
        int pos = editor->PositionFromLine(reply->line - 1);
        editor->FindAndSelectV(reply->filterWord, reply->filterWord, pos, NULL);
    }
}
Example #18
0
//------------------------------------
// Go to definition
//------------------------------------
void GotoDefinitionHandler::ProcessCommandEvent(wxWindow *owner, wxCommandEvent &event)
{
    LEditor *editor = dynamic_cast<LEditor*>(owner);
    if ( !editor ) {
        return;
    }
    if (event.GetId() == XRCID("goto_definition")) {
        editor->GotoDefinition();
    }
}
Example #19
0
void FileExplorer::OnShowFile(wxCommandEvent& e)
{
    LEditor *editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    if (editor && editor->GetFileName().FileExists()) {
        m_fileTree->ClearSelections();
        m_fileTree->Tree()->ExpandPath(editor->GetFileName().GetFullPath());
        ManagerST::Get()->ShowWorkspacePane(m_caption);
    }
    e.Skip();
}
 EditorDimmerDisabler(LEditor* editor)
     : m_editor(editor)
 {
     if(m_editor) {
         m_editor->SetPreProcessorsWords("");
         m_editor->GetCtrl()->SetProperty(wxT("lexer.cpp.track.preprocessor"), wxT("0"));
         m_editor->GetCtrl()->SetProperty(wxT("lexer.cpp.update.preprocessor"), wxT("0"));
         m_editor->GetCtrl()->Colourise(0, wxSTC_INVALID_POSITION);
     }
 }
Example #21
0
OptionsConfigPtr PluginManager::GetEditorSettings()
{
    // First try to use LEditor::GetOptions, as it takes account of local preferences
    LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    if(editor) {
        return editor->GetOptions();
    }
    // Failing that...
    return EditorConfigST::Get()->GetOptions();
}
Example #22
0
void MainBook::OnPageChanging(wxBookCtrlEvent& e)
{
    LEditor* editor = GetActiveEditor();
    if(editor) {
        editor->CallTipCancel();
    }
#if HAS_LIBCLANG
    ClangCodeCompletion::Instance()->CancelCodeComplete();
#endif
    e.Skip();
}
Example #23
0
void WordWrapHandler::ProcessUpdateUIEvent(wxWindow *owner, wxUpdateUIEvent &event)
{
    LEditor *editor = dynamic_cast<LEditor*>(owner);
    if ( !editor ) {
        event.Enable(false);
        return;
    }

    event.Enable(true);
    event.Check(editor->GetWrapMode() != wxSTC_WRAP_NONE);
}
Example #24
0
void MainBook::OnProjectFileRemoved(clCommandEvent& e)
{
    e.Skip();
    const wxArrayString& files = e.GetStrings();
    for(size_t i = 0; i < files.GetCount(); ++i) {
        LEditor* editor = FindEditor(files.Item(i));
        if(editor && files.Index(editor->GetFileName().GetFullPath()) != wxNOT_FOUND) {
            editor->SetProject(wxEmptyString);
        }
    }
}
Example #25
0
bool PluginManager::OpenFile(const wxString& fileName, const wxString& projectName, int lineno)
{
    if(clMainFrame::Get()->GetMainBook()->OpenFile(fileName, projectName, lineno)) {
        LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
        if(editor) {
            editor->SetActive();
        }
        return true;
    }
    return false;
}
Example #26
0
void FindUsageTab::DoOpenResult(const CppToken& token)
{
    if(!token.getFilename().empty()) {
        LEditor* editor =
            clMainFrame::Get()->GetMainBook()->OpenFile(token.getFilename(), wxEmptyString, token.getLineNumber());
        if(editor) {
            editor->SetLineVisible(token.getLineNumber());
            editor->ScrollToColumn(0);
            editor->SetSelection(token.getOffset(), token.getOffset() + token.getName().length());
        }
    }
}
Example #27
0
void ViewAsHandler::ProcessCommandEvent(wxWindow *owner, wxCommandEvent &event)
{
    LEditor *editor = dynamic_cast<LEditor*>(owner);
    if ( !editor ) {
        return;
    }

    wxString lexName = clMainFrame::Get()->GetViewAsLanguageById(event.GetInt());
    if (lexName.IsEmpty() == false) {
        editor->SetSyntaxHighlight(lexName);
    }
}
Example #28
0
wxWindow* MainBook::FindPage(const wxString& text)
{
    for(size_t i = 0; i < m_book->GetPageCount(); i++) {
        LEditor* editor = dynamic_cast<LEditor*>(m_book->GetPage(i));
        if(editor && editor->GetFileName().GetFullPath().CmpNoCase(text) == 0) {
            return editor;
        }

        if(m_book->GetPageText(i) == text) return m_book->GetPage(i);
    }
    return NULL;
}
Example #29
0
//------------------------------------
// brace matching
//------------------------------------
void BraceMatchHandler::ProcessCommandEvent(wxWindow *owner, wxCommandEvent &event)
{
    LEditor *editor = dynamic_cast<LEditor*>(owner);
    if ( !editor ) {
        return;
    }

    if (event.GetId() == XRCID("select_to_brace")) {
        editor->MatchBraceAndSelect(true);
    } else {
        editor->MatchBraceAndSelect(false);
    }
}
Example #30
0
void FoldHandler::ProcessCommandEvent(wxWindow *owner, wxCommandEvent &event)
{
    wxUnusedVar(event);
    LEditor *editor = dynamic_cast<LEditor*>(owner);
    if ( !editor ) {
        return;
    }

    if (event.GetId() == XRCID("toggle_fold")) editor->ToggleCurrentFold();
     else if (event.GetId() == XRCID("fold_all_in_selection")) editor->ToggleAllFoldsInSelection();
     else if (event.GetId() == XRCID("fold_topmost_in_selection")) editor->ToggleTopmostFoldsInSelection();
     else editor->FoldAll();
}