Пример #1
0
void NodeJSWorkspace::Close()
{
    if(!IsOpen()) return;

    // Store the session
    clGetManager()->StoreWorkspaceSession(m_filename);

    Save();
    DoClear();

    // disable clang for NodeJS
    clGetManager()->EnableClangCodeCompletion(m_clangOldFlag);

    // Clear the UI
    GetView()->Clear();

    // Notify workspace closed event
    wxCommandEvent event(wxEVT_WORKSPACE_CLOSED);
    EventNotifier::Get()->ProcessEvent(event);

    m_debugger.Reset(NULL);

    // notify codelite to close the currently opened workspace
    wxCommandEvent eventClose(wxEVT_MENU, wxID_CLOSE_ALL);
    eventClose.SetEventObject(EventNotifier::Get()->TopFrame());
    EventNotifier::Get()->TopFrame()->GetEventHandler()->ProcessEvent(eventClose);
    m_showWelcomePage = true;
}
Пример #2
0
void SFTPTreeView::DoCloseSession()
{
    // Check if we have unmodified files belonged to this session
    // Load the session name
    IEditor::List_t editors;
    IEditor::List_t modeditors;
    clGetManager()->GetAllEditors(editors);

    // Create a session
    SFTPSessionInfo sess;
    wxArrayString remoteFiles;
    std::for_each(editors.begin(), editors.end(), [&](IEditor* editor) {
        SFTPClientData* pcd = dynamic_cast<SFTPClientData*>(editor->GetClientData("sftp"));
        if(pcd) {
            sess.GetFiles().push_back(pcd->GetRemotePath());
            if(!clGetManager()->CloseEditor(editor)) { modeditors.push_back(editor); }
        }
    });

    // User cancel to close request, so dont close the session just yet
    if(!modeditors.empty()) { return; }

    // Set the session name
    if(m_sftp) {
        sess.SetAccount(m_sftp->GetAccount());
        sess.SetRootFolder(m_textCtrlQuickJump->GetValue()); // Keep the root folder
        m_sessions.Load().SetSession(sess).Save();
    }

    m_sftp.reset(NULL);
    m_treeCtrl->DeleteAllItems();
}
Пример #3
0
void clTreeCtrlPanel::OnActiveEditorChanged(wxCommandEvent& event)
{
    event.Skip();
    if(clGetManager()->GetActiveEditor()) {
        ExpandToFile(clGetManager()->GetActiveEditor()->GetFileName());
    }
}
Пример #4
0
void clTabTogglerHelper::OnToggleWorkspaceTab(clCommandEvent& event)
{
    if(event.GetString() != m_workspaceTabName) {
        event.Skip();
        return;
    }

    Notebook* book = clGetManager()->GetWorkspacePaneNotebook();
    if(event.IsSelected()) {
        // show it
        int where = IsTabInNotebook(book, m_workspaceTabName);
        if(where == wxNOT_FOUND) {
            // Only show it if it does not exists in the notebook
            clGetManager()->GetWorkspacePaneNotebook()->AddPage(m_workspaceTab, m_workspaceTabName, false,
                                                                m_workspaceTabBmp);
        } else {
            // The tab already in the notebook, just select it
            clGetManager()->GetWorkspacePaneNotebook()->SetSelection(where);
        }
    } else {
        int where = clGetManager()->GetWorkspacePaneNotebook()->GetPageIndex(m_workspaceTabName);
        if(where != wxNOT_FOUND) {
            clGetManager()->GetWorkspacePaneNotebook()->RemovePage(where);
        }
    }
}
Пример #5
0
OpenWindowsPanel::OpenWindowsPanel(wxWindow* parent, const wxString& caption)
    : OpenWindowsPanelBase(parent)
    , m_caption(caption)
    , m_mgr(PluginManager::Get())
    , m_initDone(false)
    , m_workspaceClosing(false)
    , m_workspaceOpened(false)
{
    // Disable the built in sorting, this control will take care of it
    m_dvListCtrl->SetSortFunction(nullptr);
    m_dvListCtrl->SetBitmaps(clGetManager()->GetStdIcons()->GetStandardMimeBitmapListPtr());
    m_toolbar = new clToolBar(this);
    m_toolbar->AddTool(wxID_SORT_ASCENDING, _("Sort"), clGetManager()->GetStdIcons()->LoadBitmap("sort"), "",
                       wxITEM_CHECK);
    m_toolbar->Realize();
    GetSizer()->Insert(0, m_toolbar, 0, wxEXPAND);

    m_toolbar->Bind(wxEVT_TOOL, &OpenWindowsPanel::OnSortItems, this, wxID_SORT_ASCENDING);
    m_toolbar->Bind(wxEVT_UPDATE_UI, &OpenWindowsPanel::OnSortItemsUpdateUI, this, wxID_SORT_ASCENDING);

    clConfig cfg;
    m_toolbar->ToggleTool(XRCID("TabsSortTool"), cfg.Read(kConfigTabsPaneSortAlphabetically, true));

    EventNotifier::Get()->Connect(wxEVT_INIT_DONE, wxCommandEventHandler(OpenWindowsPanel::OnInitDone), NULL, this);
    Bind(wxEVT_IDLE, &OpenWindowsPanel::OnIdle, this);
}
Пример #6
0
void WebTools::OnNodeJSDebuggerStarted(clDebugEvent& event)
{
    event.Skip();
    m_savePerspective = clGetManager()->GetDockingManager()->SavePerspective();

    // Show the debugger pane
    if(!m_nodejsDebuggerPane) {
        m_nodejsDebuggerPane = new NodeJSDebuggerPane(EventNotifier::Get()->TopFrame());
        clGetManager()->GetDockingManager()->AddPane(m_nodejsDebuggerPane,
                                                     wxAuiPaneInfo()
                                                         .Layer(5)
                                                         .Name("nodejs_debugger")
                                                         .Caption("Node.js Debugger")
                                                         .CloseButton(false)
                                                         .MaximizeButton()
                                                         .Bottom()
                                                         .Position(0));
    }

    wxString layout;
    wxFileName fnNodeJSLayout(clStandardPaths::Get().GetUserDataDir(), "nodejs.layout");
    fnNodeJSLayout.AppendDir("config");
    if(FileUtils::ReadFileContent(fnNodeJSLayout, layout)) {
        m_mgr->GetDockingManager()->LoadPerspective(layout);
    }
    EnsureAuiPaneIsVisible("nodejs_debugger", true);

    m_hideToolBarOnDebugStop = false;
    if(!m_mgr->AllowToolbar()) {
        // Using native toolbar
        m_hideToolBarOnDebugStop = !m_mgr->IsToolBarShown();
        m_mgr->ShowToolBar(true);
    }
}
Пример #7
0
void LanguageServerCluster::OnCompletionReady(LSPEvent& event)
{
    const LSP::CompletionItem::Vec_t& items = event.GetCompletions();

    IEditor* editor = clGetManager()->GetActiveEditor();
    CHECK_PTR_RET(editor);

    wxCodeCompletionBoxManager::Get().ShowCompletionBox(clGetManager()->GetActiveEditor()->GetCtrl(), items);
}
Пример #8
0
void clAuiDockArt::DrawSash(wxDC& dc, wxWindow* window, int orientation, const wxRect& rect)
{
    wxColour sashColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
#if 0
    if(clGetManager() && clGetManager()->GetStatusBar() && clGetManager()->GetStatusBar()->GetArt()) {
        sashColour = clGetManager()->GetStatusBar()->GetArt()->GetBgColour();
    }
#endif
    wxUnusedVar(window);
    wxUnusedVar(orientation);
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(sashColour);
    dc.DrawRectangle(rect);
}
void CodeCompletionManager::OnBlockCommentWordComplete(clCodeCompletionEvent& event)
{
    event.Skip();
    wxStyledTextCtrl* ctrl = clGetManager()->GetActiveEditor()->GetCtrl();
    CHECK_PTR_RET(ctrl);

    wxCodeCompletionBoxEntry::Vec_t entries;
    if(CreateBlockCommentKeywordsList(entries) == 0) { return; }
    wxCodeCompletionBox::BmpVec_t bitmaps;
    bitmaps.push_back(clGetManager()->GetStdIcons()->LoadBitmap("cpp_keyword"));

    int startPos = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
    wxCodeCompletionBoxManager::Get().ShowCompletionBox(ctrl, entries, bitmaps, wxCodeCompletionBox::kRefreshOnKeyType,
                                                        startPos);
}
Пример #10
0
void DatabaseExplorer::OnToggleTab(clCommandEvent& event)
{
    if(event.GetString() != _("DbExplorer")) {
        event.Skip();
        return;
    }

    if(event.IsSelected()) {
        // show it
        clGetManager()->GetWorkspacePaneNotebook()->AddPage(m_dbViewerPanel, _("DbExplorer"), true);
    } else {
        int where = m_mgr->GetWorkspacePaneNotebook()->GetPageIndex(_("DbExplorer"));
        if(where != wxNOT_FOUND) { clGetManager()->GetWorkspacePaneNotebook()->RemovePage(where); }
    }
}
Пример #11
0
void NodeJSDebugger::OnToggleBreakpoint(clDebugEvent& event)
{
    event.Skip();
    if(NodeJSWorkspace::Get()->IsOpen()) {
        event.Skip(false);
        IEditor* editor = clGetManager()->GetActiveEditor();
        if(editor && (editor->GetFileName().GetFullPath() == event.GetFileName())) {
            // Correct editor
            // add marker
            NodeJSBreakpoint bp = m_bptManager.GetBreakpoint(event.GetFileName(), event.GetInt());
            if(bp.IsOk()) {
                if(bp.IsApplied() && IsConnected()) {
                    // Tell NodeJS to delete this breakpoint
                    DeleteBreakpoint(bp);
                }
                m_bptManager.DeleteBreakpoint(event.GetFileName(), event.GetInt());
            } else {
                // We have no breakpoint on this file/line (yet)
                m_bptManager.AddBreakpoint(event.GetFileName(), event.GetInt());
                bp = m_bptManager.GetBreakpoint(event.GetFileName(), event.GetInt());
                if(IsConnected()) {
                    SetBreakpoint(bp);
                }
            }

            // Update the UI
            m_bptManager.SetBreakpoints(editor);
            clDebugEvent event(wxEVT_NODEJS_DEBUGGER_UPDATE_BREAKPOINTS_VIEW);
            EventNotifier::Get()->AddPendingEvent(event);
        }
    }
}
Пример #12
0
void NodeJSDebugger::OnEditorChanged(wxCommandEvent& event)
{
    event.Skip();
    IEditor::List_t editors;
    clGetManager()->GetAllEditors(editors);

    wxStringSet_t tmpFiles = m_tempFiles;
    wxStringSet_t closedTempEditors;
    // Loop over the temp files list
    std::for_each(tmpFiles.begin(), tmpFiles.end(), [&](const wxString& filename) {
        // If the temp file does not match one of the editors, assume it was closed and delete
        // the temporary file
        IEditor::List_t::iterator iter = std::find_if(editors.begin(), editors.end(), [&](IEditor* editor) {
            if(editor->GetFileName().GetFullPath() == filename) return true;
            return false;
        });
        if(iter == editors.end()) {
            closedTempEditors.insert(filename);
            m_tempFiles.erase(filename);
        }
    });

    if(!closedTempEditors.empty()) {
        DoDeleteTempFiles(closedTempEditors);
    }
}
Пример #13
0
void NodeJSDebugger::DoHighlightLine(const wxString& filename, int lineNo)
{
    IEditor* activeEditor = clGetManager()->OpenFile(filename, "", lineNo - 1);
    if(activeEditor) {
        SetDebuggerMarker(activeEditor, lineNo - 1);
    }
}
Пример #14
0
void ZoomText::UpdateLexer(IEditor* editor)
{
    if(!editor) {
        editor = clGetManager()->GetActiveEditor();
    }
    if(!editor) {
        DoClear();
        return;
    }

    znConfigItem data;
    clConfig conf("zoom-navigator.conf");
    conf.ReadItem(&data);

    m_filename = editor->GetFileName().GetFullPath();
    LexerConf::Ptr_t lexer = EditorConfigST::Get()->GetLexerForFile(m_filename);
    if(!lexer) {
        lexer = EditorConfigST::Get()->GetLexer("Text");
    }
    lexer->Apply(this, true);

    if(lexer->IsDark()) {
        MarkerSetAlpha(1, 10);
    } else {
        MarkerSetAlpha(1, 20);
    }

    SetZoom(m_zoomFactor);
    SetEditable(false);
    SetUseHorizontalScrollBar(false);
    SetUseVerticalScrollBar(data.IsUseScrollbar());
    HideSelection(true);
    MarkerSetBackground(1, m_colour);
}
Пример #15
0
clTabTogglerHelper::clTabTogglerHelper(const wxString& outputTabName, wxWindow* outputTab,
                                       const wxString& workspaceTabName, wxWindow* workspaceTab)
    : m_outputTabName(outputTabName)
    , m_outputTab(outputTab)
    , m_workspaceTabName(workspaceTabName)
    , m_workspaceTab(workspaceTab)
{
    if(m_workspaceTab && !m_workspaceTabName.IsEmpty()) {
        EventNotifier::Get()->Bind(wxEVT_SHOW_WORKSPACE_TAB, &clTabTogglerHelper::OnToggleWorkspaceTab, this);
        clGetManager()->AddWorkspaceTab(m_workspaceTabName);
    }
    if(m_outputTab && !m_outputTabName.IsEmpty()) {
        EventNotifier::Get()->Bind(wxEVT_SHOW_OUTPUT_TAB, &clTabTogglerHelper::OnToggleOutputTab, this);
        clGetManager()->AddOutputTab(m_outputTabName);
    }
}
Пример #16
0
void NodeJSDebugger::ClearDebuggerMarker()
{
    IEditor::List_t editors;
    clGetManager()->GetAllEditors(editors);
    std::for_each(
        editors.begin(), editors.end(), [&](IEditor* editor) { editor->GetCtrl()->MarkerDeleteAll(smt_indicator); });
}
Пример #17
0
void LanguageServerCluster::OnSymbolFound(LSPEvent& event)
{
    const LSP::Location& location = event.GetLocation();
    wxFileName fn(location.GetUri());
    clDEBUG() << "LSP: Opening file:" << fn << "(" << location.GetRange().GetStart().GetLine() << ":"
              << location.GetRange().GetStart().GetCharacter() << ")";

    // Manage the browser (BACK and FORWARD) ourself
    BrowseRecord from;
    IEditor* oldEditor = clGetManager()->GetActiveEditor();
    if(oldEditor) { from = oldEditor->CreateBrowseRecord(); }
    IEditor* editor = clGetManager()->OpenFile(fn.GetFullPath(), "", wxNOT_FOUND, OF_None);
    if(editor) {
        editor->SelectRange(location.GetRange());
        if(oldEditor) { NavMgr::Get()->AddJump(from, editor->CreateBrowseRecord()); }
    }
}
Пример #18
0
void clTreeCtrlPanel::OnFindInFilesFolder(wxCommandEvent& event)
{
    wxArrayString folders, files;
    GetSelections(folders, files);

    if(folders.IsEmpty()) return;
    clGetManager()->OpenFindInFileForPaths(folders);
}
Пример #19
0
void LanguageServerCluster::OnClearDiagnostics(LSPEvent& event)
{
    event.Skip();
    wxString uri = event.GetLocation().GetUri();
    wxFileName fn(uri);
    IEditor* editor = clGetManager()->FindEditor(fn.GetFullPath());
    if(editor) { editor->DelAllCompilerMarkers(); }
}
Пример #20
0
void LanguageServerCluster::ClearAllDiagnostics()
{
    IEditor::List_t editors;
    clGetManager()->GetAllEditors(editors);
    for(IEditor* editor : editors) {
        editor->DelAllCompilerMarkers();
    }
}
Пример #21
0
void NodeJSWorkspace::OnSaveSession(clCommandEvent& event)
{
    event.Skip();
    if(IsOpen()) {
        // Call event.Skip(false) so no other session are kept beside ours
        event.Skip(false);
        clGetManager()->StoreWorkspaceSession(m_filename);
    }
}
Пример #22
0
void LanguageServerCluster::OnLSPInitialized(LSPEvent& event)
{
    wxUnusedVar(event); // Now that the workspace is loaded, parse the active file
    IEditor* editor = clGetManager()->GetActiveEditor();
    CHECK_PTR_RET(editor);

    LanguageServerProtocol::Ptr_t lsp = GetServerForFile(editor->GetFileName());
    if(lsp) { lsp->OpenEditor(editor); }
}
void MainBook::OnWorkspaceClosed(wxCommandEvent& e)
{
    e.Skip();
    CloseAll(false); // make sure no unsaved files
    clStatusBar* sb = clGetManager()->GetStatusBar();
    if(sb) {
        sb->SetSourceControlBitmap(wxNullBitmap, "", "");
    }
}
Пример #24
0
void clTreeCtrlPanel::OnOpenFile(wxCommandEvent& event)
{
    wxArrayString folders, files;
    GetSelections(folders, files);

    for(size_t i = 0; i < files.size(); ++i) {
        clGetManager()->OpenFile(files.Item(i));
    }
}
Пример #25
0
void XMLCodeCompletion::OnCodeCompleted(clCodeCompletionEvent& event)
{
    event.Skip();
    if(event.GetEventObject() != this) {
        return;
    }

    // sanity
    IEditor* editor = clGetManager()->GetActiveEditor();
    if(!editor) return;

    // HTML triggered the code complete?
    if(m_completeReason == kHtmlOpenSequence) {
        event.Skip(false);
        const wxString& selection = event.GetWord();
        if(XMLBuffer::IsEmptyHtmlTag(selection) && !HasSpecialInsertPattern(selection)) {

            // an empty html tag, just complete it
            wxString textToInsert = selection;
            textToInsert << ">";

            int selStart = GetWordStartPos(editor);
            int selEnd = editor->GetCurrentPosition();
            if((selEnd - selStart) >= 0) {
                editor->SelectText(selStart, selEnd - selStart);
                editor->ReplaceSelection(textToInsert);
                editor->SetCaretAt(selStart + textToInsert.length());
            }
        } else {
            wxString completePattern = GetCompletePattern(selection);
            int caretPos = completePattern.Find("|");
            completePattern.Replace("|", "");
            int selStart = GetWordStartPos(editor);

            int selEnd = editor->GetCurrentPosition();
            if((selEnd - selStart) >= 0) {
                editor->SelectText(selStart, selEnd - selStart);
                editor->ReplaceSelection(completePattern);
                editor->SetCaretAt(selStart + caretPos);
            }
        }
    } else if(m_completeReason == kCloseSequence) {
        // User typed "</"
        event.Skip(false);
        const wxString& selection = event.GetWord();
        int selStart = GetWordStartPos(editor);
        int selEnd = editor->GetCurrentPosition();
        if((selEnd - selStart) >= 0) {
            editor->SelectText(selStart, selEnd - selStart);
            editor->ReplaceSelection(selection);
            editor->SetCaretAt(selStart + selection.length());
        }
    } else {
        event.Skip();
    }
}
Пример #26
0
wxVariant OpenWindowsPanel::PrepareValue(const clTab& tab)
{
    wxString title;
    wxStyledTextCtrl* editor(NULL);
    if(tab.isFile) {
        title = tab.filename.GetFullName();
        IEditor* i_editor = clGetManager()->FindEditor(tab.filename.GetFullPath());
        if(i_editor) { editor = i_editor->GetCtrl(); }
    } else {
        title = tab.text;
    }

    FileExtManager::FileType ft = FileExtManager::GetType(title, FileExtManager::TypeText);
    int imgId = clGetManager()->GetStdIcons()->GetMimeImageId(ft);
    if(editor && editor->GetModify()) { title.Prepend("*"); }

    wxVariant value = ::MakeBitmapIndexText(title, imgId);
    return value;
}
Пример #27
0
bool NodeJSWorkspace::DoOpen(const wxFileName& filename)
{
    NodeJSWorkspaceConfiguration conf;
    conf.Load(m_filename);
    if(!conf.IsOk()) {
        DoClear();
        return false;
    }

    m_folders = conf.GetFolders();
    GetView()->Clear();
    GetView()->ShowHiddenFiles(conf.IsShowHiddenFiles());

    const wxArrayString& folders = GetFolders();
    for(size_t i = 0; i < folders.size(); ++i) {
        GetView()->AddFolder(folders.Item(i));
    }

    // Notify codelite that NodeJS workspace is opened
    clGetManager()->GetWorkspaceView()->SelectPage(GetWorkspaceType());
    clWorkspaceManager::Get().SetWorkspace(this);

    // Keep the old clang state before we disable it
    const TagsOptionsData& options = TagsManagerST::Get()->GetCtagsOptions();
    m_clangOldFlag = (options.GetClangOptions() & CC_CLANG_ENABLED);

    clGetManager()->EnableClangCodeCompletion(false);

    // Notify that the a new workspace is loaded
    wxCommandEvent event(wxEVT_WORKSPACE_LOADED);
    event.SetString(filename.GetFullPath());
    EventNotifier::Get()->AddPendingEvent(event);

    // and finally, request codelite to keep this workspace in the recently opened workspace list
    clGetManager()->AddWorkspaceToRecentlyUsedList(m_filename);

    // Load the workspace session (if any)
    CallAfter(&NodeJSWorkspace::RestoreSession);

    // Create new debugger for this workspace
    m_debugger.Reset(new NodeJSDebugger());
    return true;
}
Пример #28
0
void LanguageServerCluster::OnReparseNeeded(LSPEvent& event)
{
    LanguageServerProtocol::Ptr_t server = GetServerByName(event.GetServerName());
    if(!server) { return; }

    IEditor* editor = clGetManager()->GetActiveEditor();
    CHECK_PTR_RET(editor);

    server->CloseEditor(editor);
    server->OpenEditor(editor);
}
Пример #29
0
ReconcileProjectDlg::ReconcileProjectDlg(wxWindow* parent, const wxString& projname)
    : ReconcileProjectDlgBaseClass(parent)
    , m_projname(projname)
    , m_projectModified(false)
{
    m_bitmaps = clGetManager()->GetStdIcons()->MakeStandardMimeMap();

    m_dvListCtrl1Unassigned->Bind(
        wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler(ReconcileProjectDlg::OnDVLCContextMenu), this);

    SetName("ReconcileProjectDlg");
    WindowAttrManager::Load(this);
}
Пример #30
0
NodeJSWorkspace::NodeJSWorkspace()
    : m_clangOldFlag(false)
    , m_showWelcomePage(false)
{
    SetWorkspaceType("Node.js");
    m_debugger.Reset(new NodeJSDebugger());

    m_view = new NodeJSWorkspaceView(clGetManager()->GetWorkspaceView()->GetBook(), GetWorkspaceType());
    clGetManager()->GetWorkspaceView()->AddPage(m_view, GetWorkspaceType());

    EventNotifier::Get()->Bind(wxEVT_CMD_CLOSE_WORKSPACE, &NodeJSWorkspace::OnCloseWorkspace, this);
    EventNotifier::Get()->Bind(wxEVT_CMD_CREATE_NEW_WORKSPACE, &NodeJSWorkspace::OnNewWorkspace, this);
    EventNotifier::Get()->Bind(wxEVT_CMD_OPEN_WORKSPACE, &NodeJSWorkspace::OnOpenWorkspace, this);
    EventNotifier::Get()->Bind(wxEVT_ALL_EDITORS_CLOSED, &NodeJSWorkspace::OnAllEditorsClosed, this);
    EventNotifier::Get()->Bind(wxEVT_SAVE_SESSION_NEEDED, &NodeJSWorkspace::OnSaveSession, this);
    EventNotifier::Get()->Bind(wxEVT_CMD_EXECUTE_ACTIVE_PROJECT, &NodeJSWorkspace::OnExecute, this);
    EventNotifier::Get()->Bind(wxEVT_CMD_STOP_EXECUTED_PROGRAM, &NodeJSWorkspace::OnStopExecute, this);
    EventNotifier::Get()->Bind(wxEVT_CMD_IS_PROGRAM_RUNNING, &NodeJSWorkspace::OnIsExecuteInProgress, this);

    m_terminal.Bind(wxEVT_TERMINAL_COMMAND_EXIT, &NodeJSWorkspace::OnProcessTerminated, this);
    m_terminal.Bind(wxEVT_TERMINAL_COMMAND_OUTPUT, &NodeJSWorkspace::OnProcessOutput, this);
}