当前位置: 首页>>代码示例>>C++>>正文


C++ IEditor::GetLength方法代码示例

本文整理汇总了C++中IEditor::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ IEditor::GetLength方法的具体用法?C++ IEditor::GetLength怎么用?C++ IEditor::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEditor的用法示例。


在下文中一共展示了IEditor::GetLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnGenerateSettersGetters

void PHPEditorContextMenu::OnGenerateSettersGetters(wxCommandEvent& e)
{
    // CHeck the current context
    IEditor* editor = m_manager->GetActiveEditor();
    if(editor) {

        // determine the scope name at the current position
        // Parse until the current position
        wxString text = editor->GetTextRange(0, editor->GetCurrentPosition());
        PHPSourceFile sourceFile(text);
        sourceFile.SetParseFunctionBody(true);
        sourceFile.SetFilename(editor->GetFileName());
        sourceFile.Parse();

        const PHPEntityClass* scopeAtPoint = sourceFile.Class()->Cast<PHPEntityClass>();
        if(!scopeAtPoint) {
            // Could not determine the scope at the give location
            return;
        }

        // get the class name
        wxString className = scopeAtPoint->GetShortName();

        // generate the code to generate
        wxString textToAdd;
        PHPSettersGettersDialog dlg(EventNotifier::Get()->TopFrame(), editor, m_manager);
        if(dlg.ShowModal() == wxID_OK) {
            PHPSetterGetterEntry::Vec_t members = dlg.GetMembers();
            for(size_t i = 0; i < members.size(); ++i) {
                textToAdd << members.at(i).GetSetter(dlg.GetScope(), dlg.GetFlags()) << "\n";
                textToAdd << members.at(i).GetGetter(dlg.GetFlags()) << "\n";
            }

            if(!textToAdd.IsEmpty()) {
                int line = PHPCodeCompletion::Instance()->GetLocationForSettersGetters(
                    editor->GetTextRange(0, editor->GetLength()), className);

                if(!textToAdd.IsEmpty() && line != wxNOT_FOUND) {
                    editor->GetCtrl()->InsertText(editor->PosFromLine(line), textToAdd);
                }
            }
        }
    }
}
开发者ID:GaganJotSingh,项目名称:codelite,代码行数:44,代码来源:php_editor_context_menu.cpp

示例2: OnInsertDoxyBlock

void PHPCodeCompletion::OnInsertDoxyBlock(clCodeCompletionEvent& e)
{
    e.Skip();

    // Do we have a workspace open?
    CHECK_COND_RET(PHPWorkspace::Get()->IsOpen());

    // Sanity
    IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor());
    CHECK_PTR_RET(editor);

    // Is this a PHP editor?
    CHECK_COND_RET(IsPHPFile(editor));

    // Get the text from the caret current position
    // until the end of file
    wxString unsavedBuffer = editor->GetTextRange(editor->GetCurrentPosition(), editor->GetLength());
    unsavedBuffer.Trim().Trim(false);
    PHPSourceFile source("<?php " + unsavedBuffer);
    source.SetParseFunctionBody(false);
    source.Parse();

    PHPEntityBase::Ptr_t ns = source.Namespace();
    if(ns) {
        const PHPEntityBase::List_t& children = ns->GetChildren();
        for(PHPEntityBase::List_t::const_iterator iter = children.begin(); iter != children.end(); ++iter) {
            PHPEntityBase::Ptr_t match = *iter;
            if(match->GetLine() == 0 && match->Is(kEntityTypeFunction)) {
                e.Skip(false); // notify codelite to stop processing this event
                wxString phpdoc = match->FormatPhpDoc();
                phpdoc.Trim();
                e.SetTooltip(phpdoc);
            }
        }
    }
}
开发者ID:anatooly,项目名称:codelite,代码行数:36,代码来源:php_code_completion.cpp

示例3: DoAddFileWithContent

void PHPWorkspaceView::DoAddFileWithContent(const wxTreeItemId& folderId,
                                            const wxFileName& filename,
                                            const wxString& content)
{
    // file can only be added to a folder
    ItemData* data = DoGetItemData(folderId);
    if(!data || !data->IsFolder()) {
        return;
    }

    if(filename.FileExists()) {
        // a file with this name already exists
        wxMessageBox(_("A file with same name already exists!"), wxT("CodeLite"), wxOK | wxCENTER | wxICON_WARNING);
        return;
    }

    FileExtManager::FileType type = FileExtManager::GetType(filename.GetFullName());

    // Create the file
    const wxString __EOL__ = EditorConfigST::Get()->GetOptions()->GetEOLAsString();

    // Make sure that the path exists
    filename.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);

    wxFFile fp;
    if(fp.Open(filename.GetFullPath(), wxT("w+"))) {

        // if its is a PHP file, write the php tag at to the top of the file
        if(type == FileExtManager::TypePhp) {
            fp.Write(wxString() << "<?php " << __EOL__ << __EOL__ << content);
        }
        fp.Close();
    }

    // add the new file
    wxString project_name = DoGetSelectedProject();
    wxString folder_name = data->GetFolderPath();

    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project_name);
    CHECK_PTR_RET(pProject);

    PHPFolder::Ptr_t pFolder = pProject->Folder(folder_name);
    CHECK_PTR_RET(pFolder);

    if(PHPWorkspace::Get()->AddFile(project_name, folder_name, filename.GetFullPath())) {
        wxArrayString filesToAdd;
        filesToAdd.Add(filename.GetFullPath());
        DoAddFilesToTreeView(folderId, pProject, pFolder, filesToAdd);
    }

    // Open the newly added file
    m_mgr->OpenFile(filename.GetFullPath());

    IEditor* editor = m_mgr->GetActiveEditor();
    if(editor) {
        editor->SetCaretAt(editor->GetLength());
    }

    // Notify plugins about new files was added to workspace
    wxArrayString files;
    files.Add(filename.GetFullPath());

    // Notify the plugins
    clCommandEvent evtFilesAdded(wxEVT_PROJ_FILE_ADDED);
    evtFilesAdded.SetStrings(files);
    EventNotifier::Get()->AddPendingEvent(evtFilesAdded);
}
开发者ID:raresp,项目名称:codelite,代码行数:67,代码来源:php_workspace_view.cpp

示例4: OnTimer

void WebTools::OnTimer(wxTimerEvent& event)
{
    event.Skip();

    time_t curtime = time(NULL);
    if((curtime - m_lastColourUpdate) < 5) return;
    IEditor* editor = m_mgr->GetActiveEditor();

    // Sanity
    CHECK_PTR_RET(editor);
    CHECK_PTR_RET(editor->IsModified());
    if(!IsJavaScriptFile(editor->GetFileName())) return;

    // This file is a modified JS file
    m_lastColourUpdate = time(NULL);
    m_jsColourThread->QueueBuffer(editor->GetFileName().GetFullPath(), editor->GetTextRange(0, editor->GetLength()));
}
开发者ID:capturePointer,项目名称:codelite,代码行数:17,代码来源:webtools.cpp


注:本文中的IEditor::GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。