コード例 #1
0
ファイル: mainbook.cpp プロジェクト: fmestrone/codelite
void MainBook::DetachActiveEditor()
{
    if(GetActiveEditor()) {
        LEditor* editor = GetActiveEditor();
        m_book->RemovePage(m_book->GetSelection(), true);
        EditorFrame* frame = new EditorFrame(clMainFrame::Get(), editor);
        frame->Show();
        m_detachedEditors.push_back(frame);
    }
}
コード例 #2
0
ファイル: mainbook.cpp プロジェクト: fmestrone/codelite
void MainBook::CreateSession(SessionEntry& session, wxArrayInt* excludeArr)
{
    std::vector<LEditor*> editors;
    GetAllEditors(editors, kGetAll_RetainOrder);

    session.SetSelectedTab(0);
    std::vector<TabInfo> vTabInfoArr;
    for(size_t i = 0; i < editors.size(); i++) {

        if(excludeArr && (excludeArr->GetCount() > i) && (!excludeArr->Item(i))) {
            // If we're saving only selected editors, and this isn't one of them...
            continue;
        }

        if(editors[i] == GetActiveEditor()) {
            session.SetSelectedTab(vTabInfoArr.size());
        }
        TabInfo oTabInfo;
        oTabInfo.SetFileName(editors[i]->GetFileName().GetFullPath());
        oTabInfo.SetFirstVisibleLine(editors[i]->GetFirstVisibleLine());
        oTabInfo.SetCurrentLine(editors[i]->GetCurrentLine());

        wxArrayString astrBookmarks;
        editors[i]->StoreMarkersToArray(astrBookmarks);
        oTabInfo.SetBookmarks(astrBookmarks);

        std::vector<int> folds;
        editors[i]->StoreCollapsedFoldsToArray(folds);
        oTabInfo.SetCollapsedFolds(folds);

        vTabInfoArr.push_back(oTabInfo);
    }
    session.SetTabInfoArr(vTabInfoArr);
}
コード例 #3
0
ファイル: mainbook.cpp プロジェクト: fmestrone/codelite
void MainBook::DoUpdateNotebookTheme()
{
    size_t initialStyle = m_book->GetStyle();
    size_t style = m_book->GetStyle();
    if(EditorConfigST::Get()->GetOptions()->IsTabColourMatchesTheme()) {
        // Update theme
        IEditor* editor = GetActiveEditor();
        if(editor) {
            wxColour bgColour = editor->GetCtrl()->StyleGetBackground(0);
            if(DrawingUtils::IsDark(bgColour) && !(m_book->GetStyle() & kNotebook_DarkTabs)) {
                style &= ~kNotebook_LightTabs;
                style |= kNotebook_DarkTabs;
            } else if(!DrawingUtils::IsDark(bgColour) && !(m_book->GetStyle() & kNotebook_LightTabs)) {
                style &= ~kNotebook_DarkTabs;
                style |= kNotebook_LightTabs;
            }
        } else {
            style &= ~kNotebook_DarkTabs;
            style |= kNotebook_LightTabs;
        }
    } else {
        style &= ~kNotebook_DarkTabs;
        style |= kNotebook_LightTabs;
    }

    if(!EditorConfigST::Get()->GetOptions()->IsTabHasXButton()) {
        style &= ~(kNotebook_CloseButtonOnActiveTab | kNotebook_CloseButtonOnActiveTabFireEvent);
    } else {
        style |= (kNotebook_CloseButtonOnActiveTab | kNotebook_CloseButtonOnActiveTabFireEvent);
    }
    if(initialStyle != style) {
        m_book->SetStyle(style);
    }
}
コード例 #4
0
void CommandCopyPasteHeightmap::UpdateLandscapeTilemap(DAVA::Image *image)
{
	Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(), image->GetWidth(), image->GetHeight(), false);
	texture->relativePathname = tilemapSavedPathname;
	texture->GenerateMipmaps();
	texture->SetWrapMode(Texture::WRAP_REPEAT, Texture::WRAP_REPEAT);

	LandscapeEditorBase* editor = GetActiveEditor();
	if (editor)
	{
		editor->UpdateLandscapeTilemap(texture);
	}
	else
	{
		SceneEditorScreenMain *screen = dynamic_cast<SceneEditorScreenMain *>(UIScreenManager::Instance()->GetScreen());
		EditorScene* scene = screen->FindCurrentBody()->bodyControl->GetScene();
		Landscape* landscape = scene->GetLandscape(scene);

		landscape->SetTexture(Landscape::TEXTURE_TILE_MASK, texture);
		landscape->UpdateFullTiledTexture();
		ImageLoader::Save(image, tilemapSavedPathname);
	}

	SafeRelease(texture);
}
コード例 #5
0
int ProjectFrame::CloseFile()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		return CloseEditor(vw->GetItem());
	return 0;
}
コード例 #6
0
ファイル: mainbook.cpp プロジェクト: fmestrone/codelite
void MainBook::OnPageChanging(wxBookCtrlEvent& e)
{
    LEditor* editor = GetActiveEditor();
    if(editor) {
        editor->CallTipCancel();
    }
#if HAS_LIBCLANG
    ClangCodeCompletion::Instance()->CancelCodeComplete();
#endif
    e.Skip();
}
コード例 #7
0
int ProjectFrame::SaveFile()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
	{
		ProjectItem *itm = vw->GetItem();
		if (itm)
			return itm->SaveItem();
	}
	return 0;
}
コード例 #8
0
ファイル: mainbook.cpp プロジェクト: qioixiy/codelite
void MainBook::OnPageClosed(NotebookEvent &e)
{
    SelectPage(m_book->GetCurrentPage());
    m_quickFindBar->SetEditor(GetActiveEditor());

    // any editors left open?
    LEditor *editor = NULL;
    for (size_t i = 0; i < m_book->GetPageCount() && editor == NULL; i++) {
        editor = dynamic_cast<LEditor*>(m_book->GetPage(i));
    }

    if (m_book->GetPageCount() == 0) {
        SendCmdEvent(wxEVT_ALL_EDITORS_CLOSED);
        ShowQuickBar(false);
    }
}
コード例 #9
0
void CommandDrawTilemap::UpdateLandscapeTilemap(DAVA::Image *image)
{
	Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(), image->GetWidth(), image->GetHeight(), false);
	texture->relativePathname = savedPathname;
	texture->SetWrapMode(Texture::WRAP_REPEAT, Texture::WRAP_REPEAT);

	LandscapeEditorBase* editor = GetActiveEditor();
	if (editor)
	{
		editor->UpdateLandscapeTilemap(texture);
	}
	else if (landscape)
	{
		landscape->SetTexture(Landscape::TEXTURE_TILE_MASK, texture);
		landscape->UpdateFullTiledTexture();
		ImageLoader::Save(image, savedPathname);
	}

	SafeRelease(texture);
}
コード例 #10
0
ファイル: mainbook.cpp プロジェクト: fmestrone/codelite
LEditor* MainBook::OpenFile(const wxString& file_name,
    const wxString& projectName,
    int lineno,
    long position,
    OF_extra extra /*=OF_AddJump*/,
    bool preserveSelection /*=true*/)
{
    wxFileName fileName(file_name);
    fileName.MakeAbsolute();

#ifdef __WXMSW__
    // Handle cygwin paths
    wxString curpath = fileName.GetFullPath();
    static wxRegEx reCygdrive("/cygdrive/([A-Za-z])");
    if(reCygdrive.Matches(curpath)) {
        // Replace the /cygdrive/c with volume C:
        wxString volume = reCygdrive.GetMatch(curpath, 1);
        volume << ":";
        reCygdrive.Replace(&curpath, volume);
        fileName = curpath;
    }
#endif

    if(!IsFileExists(fileName)) {
        wxLogMessage(wxT("Failed to open: %s: No such file or directory"), fileName.GetFullPath().c_str());
        return NULL;
    }

    if(FileExtManager::GetType(fileName.GetFullName()) == FileExtManager::TypeBmp) {
        // a bitmap file, open it using an image viewer
        DoOpenImageViewer(fileName);
        return NULL;
    }

    wxString projName = projectName;
    if(projName.IsEmpty()) {
        // try to match a project name to the file. otherwise, CC may not work
        projName = ManagerST::Get()->GetProjectNameByFile(fileName.GetFullPath());
    }

    LEditor* editor = GetActiveEditor(true);
    BrowseRecord jumpfrom = editor ? editor->CreateBrowseRecord() : BrowseRecord();

    editor = FindEditor(fileName.GetFullPath());
    if(editor) {
        editor->SetProject(projName);
    } else if(fileName.IsOk() == false) {
        wxLogMessage(wxT("Invalid file name: ") + fileName.GetFullPath());
        return NULL;

    } else if(!fileName.FileExists()) {
        wxLogMessage(wxT("File: ") + fileName.GetFullPath() + wxT(" does not exist!"));
        return NULL;

    } else {

        // 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);

        editor = new LEditor(m_book);
        editor->Create(projName, fileName);

        int sel = m_book->GetSelection();
        if((extra & OF_PlaceNextToCurrent) && (sel != wxNOT_FOUND)) {
            AddPage(editor, fileName.GetFullName(), fileName.GetFullPath(), wxNullBitmap, false, sel + 1);
        } else {
            AddPage(editor, fileName.GetFullName(), fileName.GetFullPath());
        }
        editor->SetSyntaxHighlight();

        // mark the editor as read only if neede
        MarkEditorReadOnly(editor);

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

        if(position == wxNOT_FOUND && lineno == wxNOT_FOUND && editor->GetContext()->GetName() == wxT("C++")) {
            // try to find something interesting in the file to put the caret at
            // for now, just skip past initial blank lines and comments
            for(lineno = 0; lineno < editor->GetLineCount(); lineno++) {
                switch(editor->GetStyleAt(editor->PositionFromLine(lineno))) {
                case wxSTC_C_DEFAULT:
                case wxSTC_C_COMMENT:
                case wxSTC_C_COMMENTDOC:
                case wxSTC_C_COMMENTLINE:
                case wxSTC_C_COMMENTLINEDOC:
                    continue;
                }
                // if we got here, it's a line to stop on
                break;
            }
            if(lineno == editor->GetLineCount()) {
                lineno = 1; // makes sure a navigation record gets saved
            }
        }
    }

    if(position != wxNOT_FOUND) {
        editor->SetEnsureCaretIsVisible(position, preserveSelection);
        editor->SetLineVisible(editor->LineFromPosition(position));

    } else if(lineno != wxNOT_FOUND) {
        editor->CenterLine(lineno);
    }

    if(m_reloadingDoRaise) {
        if(GetActiveEditor() == editor) {
            editor->SetActive();
        } else {
            SelectPage(editor);
        }
    }

    // Add this file to the history. Don't check for uniqueness:
    // if it's already on the list, wxFileHistory will move it to the top
    // Also, sync between the history object and the configuration file
    m_recentFiles.AddFileToHistory(fileName.GetFullPath());
    clConfig::Get().AddRecentFile(fileName.GetFullPath());

    if(extra & OF_AddJump) {
        BrowseRecord jumpto = editor->CreateBrowseRecord();
        NavMgr::Get()->AddJump(jumpfrom, jumpto);
    }
#if !CL_USE_NATIVEBOOK
    if(m_book->GetPageCount() == 1) {
        m_book->GetSizer()->Layout();
    }
#endif
    return editor;
}
コード例 #11
0
void ProjectFrame::MarkerPrev()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		vw->PrevMarker();
}
コード例 #12
0
void ProjectFrame::MarkerClear()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		vw->ClearMarkers();
}
コード例 #13
0
void ProjectFrame::EditGoto()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		vw->GotoLine(-1);
}
コード例 #14
0
void ProjectFrame::MarkerNext()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		vw->NextMarker();
}
コード例 #15
0
void ProjectFrame::EditSelectAll()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		vw->SelectAll();
}
コード例 #16
0
void ProjectFrame::EditFindNext()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		vw->FindNext();
}
コード例 #17
0
void ProjectFrame::EditPaste()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		vw->Paste();
}
コード例 #18
0
ファイル: mainbook.cpp プロジェクト: qioixiy/codelite
LEditor *MainBook::OpenFile(const wxString &file_name, const wxString &projectName, int lineno, long position, OF_extra extra/*=OF_AddJump*/, bool preserveSelection /*=true*/)
{
    wxFileName fileName(file_name);
    fileName.MakeAbsolute();

    if(IsFileExists(fileName) == false) {
        wxLogMessage(wxT("Failed to open: %s: No such file or directory"), fileName.GetFullPath().c_str());
        return NULL;
    }

    wxString projName = projectName;
    if (projName.IsEmpty()) {
        // try to match a project name to the file. otherwise, CC may not work
        projName = ManagerST::Get()->GetProjectNameByFile(fileName.GetFullPath());
    }

    LEditor* editor = GetActiveEditor(true);
    BrowseRecord jumpfrom = editor ? editor->CreateBrowseRecord() : BrowseRecord();

    editor = FindEditor(fileName.GetFullPath());
    if (editor) {
        editor->SetProject(projName);
    } else if (fileName.IsOk() == false) {
        wxLogMessage(wxT("Invalid file name: ") + fileName.GetFullPath());
        return NULL;

    } else if (!fileName.FileExists()) {
        wxLogMessage(wxT("File: ") + fileName.GetFullPath() + wxT(" does not exist!"));
        return NULL;

    } else {

        // 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);

        editor = new LEditor(m_book);
        editor->Create(projName, fileName);

        // If we're here from 'Swap Header/Implementation file', insert the new page next door
#if !CL_USE_NATIVEBOOK
        size_t sel = m_book->GetVisibleEditorIndex();
#else
        size_t sel = (size_t)m_book->GetSelection();
#endif

        if ((extra & OF_PlaceNextToCurrent) && (sel != Notebook::npos)) {
            AddPage(editor, fileName.GetFullName(), wxNullBitmap, false, sel+1);
        } else {
            AddPage(editor, fileName.GetFullName());
        }
        editor->SetSyntaxHighlight();

        // mark the editor as read only if needed
        MarkEditorReadOnly(editor, IsFileReadOnly(editor->GetFileName()));

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

        if (position == wxNOT_FOUND && lineno == wxNOT_FOUND && editor->GetContext()->GetName() == wxT("C++")) {
            // try to find something interesting in the file to put the caret at
            // for now, just skip past initial blank lines and comments
            for (lineno = 0; lineno < editor->GetLineCount(); lineno++) {
                switch (editor->GetStyleAt(editor->PositionFromLine(lineno))) {
                case wxSTC_C_DEFAULT:
                case wxSTC_C_COMMENT:
                case wxSTC_C_COMMENTDOC:
                case wxSTC_C_COMMENTLINE:
                case wxSTC_C_COMMENTLINEDOC:
                    continue;
                }
                // if we got here, it's a line to stop on
                break;
            }
            if (lineno == editor->GetLineCount()) {
                lineno = 1; // makes sure a navigation record gets saved
            }
        }
    }

    if (position != wxNOT_FOUND) {
        editor->SetEnsureCaretIsVisible(position, preserveSelection);

    } else if (lineno != wxNOT_FOUND) {
        editor->SetEnsureCaretIsVisible(editor->PositionFromLine(lineno), preserveSelection);

    }

    if (m_reloadingDoRaise) {
        if (GetActiveEditor() == editor) {
            editor->SetActive();
        } else {
            SelectPage(editor);
        }
    }

    // Add this file to the history. Don't check for uniqueness:
    // if it's already on the list, wxFileHistory will move it to the top
    // Also, sync between the history object and the configuration file
    m_recentFiles.AddFileToHistory ( fileName.GetFullPath() );
    wxArrayString files;
    m_recentFiles.GetFiles ( files );
    EditorConfigST::Get()->SetRecentItems( files, wxT("RecentFiles") );

    if (extra & OF_AddJump) {
        BrowseRecord jumpto = editor->CreateBrowseRecord();
        NavMgr::Get()->AddJump(jumpfrom, jumpto);
    }
#if !CL_USE_NATIVEBOOK
    if(m_book->GetPageCount() == 1) {
        m_book->GetSizer()->Layout();
    }
#endif
    return editor;
}
コード例 #19
0
ファイル: mainbook.cpp プロジェクト: fmestrone/codelite
void MainBook::ShowNavBar(bool s)
{
    m_navBar->DoShow(s);
    UpdateNavBar(GetActiveEditor());
}
コード例 #20
0
void ProjectFrame::EditUndo()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		vw->Undo();
}
コード例 #21
0
void ProjectFrame::EditCut()
{
	EditorView *vw = GetActiveEditor();
	if (vw)
		vw->Cut();
}