Code::Blocks

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: zyjjingle on September 24, 2010, 04:56:37 pm

Title: source insight plugin
Post by: zyjjingle on September 24, 2010, 04:56:37 pm
source insight plugin:

project & sanp images in:
svn://svn.code.sf.net/p/zyjcodeblocks/svn

it need some change in SDK and codecompletion.
-------------------changes in SDK:------------------------------------
1.editorbase.cpp
Code: [Select]
EditorBase::EditorBase(wxWindow* parent, const wxString& filename)
        : wxPanel(parent, -1),
        m_IsBuiltinEditor(false),
        m_Shortname(_T("")),
        m_Filename(_T("")),
        m_WinTitle(filename)
{
    m_pData = new EditorBaseInternalData(this);

    //add by nwork, if Open in output need not to add
    if( Manager::Get()->GetEditorManager()->GetInoutput()==false )
         Manager::Get()->GetEditorManager()->AddCustomEditor(this);
    
    InitFilename(filename);
    SetTitle(m_Shortname);
}
---------------------- changes in CodeCompletion ------------------------
codecompletion.cpp

Code: [Select]
void CodeCompletion::OnValueTooltip(CodeBlocksEvent& event)
{
            //add by nwork, other plugins( SourceInsight,BrowseTracker) need this event
if( event.GetExtraLong() != 0 )
return;
    event.Skip();
    if (IsAttached() && m_InitDone)
    {
        if (!Manager::Get()->GetConfigManager(_T("code_completion"))->ReadBool(_T("eval_tooltip"), true))
            return;

        EditorBase* base = event.GetEditor();
        cbEditor* ed = base && base->IsBuiltinEditor() ? static_cast<cbEditor*>(base) : 0;
        if (!ed || ed->IsContextMenuOpened())
            return;

        if (ed->GetControl()->CallTipActive())
            ed->GetControl()->CallTipCancel();
//        Manager::Get()->GetLogManager()->DebugLog(F(_T("CodeCompletion::OnValueTooltip: %p"), ed));
        /* NOTE: The following 2 lines of codes can fix [Bug #11785].
        *       The solution may not the best one and it requires the editor
        *       to have the focus (even if C::B has the focus) in order to pop-up the tooltip. */
        if (wxWindow::FindFocus() != static_cast<wxWindow*>(ed->GetControl()))
            return;

        // ignore comments, strings, preprocesor, etc
        int style = event.GetInt();
        if (   (style != wxSCI_C_DEFAULT)
            && (style != wxSCI_C_OPERATOR)
            && (style != wxSCI_C_IDENTIFIER) )
            return;

        int pos = ed->GetControl()->PositionFromPointClose(event.GetX(), event.GetY());
        if (pos < 0 || pos >= ed->GetControl()->GetLength())
            return;

int endOfWord = ed->GetControl()->WordEndPosition(pos, true);
Token* poutput_token = NULL;
        Parser* parser = m_NativeParser.GetParserPtr();
        if (parser)
        {
            TokenIdxSet result;
//          int endOfWord = ed->GetControl()->WordEndPosition(pos, true);
            if (m_NativeParser.MarkItemsByAI(result, true, true, true, endOfWord))
            {
                wxString msg;
                int count = 0;
bool flag = false;
                for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
                {
                    Token* token = parser->GetTokens()->at(*it);
                    if (token)
                    {
                        msg << token->DisplayName() << _T("\n");
                        ++count;
                        if (count > 32) // allow max 32 matches (else something is definitely wrong)
                        {
                            msg.Clear();
                            break;
                        }

if( poutput_token==NULL || token->m_ImplFileIdx )
poutput_token = token;
}
                }
                if (!msg.IsEmpty())
                {
if( msg.Find( '\r' ) >=0 )
msg.Replace( "\r", " " );
                    if( msg.Last() == '\n' )
msg.RemoveLast();
if( msg.First('\t') >=0 )
msg.Replace( "\t", "    " );
                    ed->GetControl()->CallTipShow(pos, msg);
//                  Manager::Get()->GetLogManager()->DebugLog(F(msg));
                }
            }
        }

//add by nwork for sourceinsight
if( poutput_token )
{
int line;
wxString filename = poutput_token->GetImplFilename();
wxString dispname = poutput_token->DisplayName();
line = poutput_token->m_ImplLine;
if( filename.IsEmpty() )
{
filename = poutput_token->GetFilename();
line = poutput_token->m_Line;
}

//dispname|filename
dispname += "|";
dispname += filename;
CodeBlocksEvent event(cbEVT_EDITOR_TOOLTIP);
event.SetEditor(ed);
event.SetInt(line);
event.SetString(dispname);
event.SetExtraLong(-1); //for source insight
Manager::Get()->GetPluginManager()->NotifyPlugins(event);
}   }
}


Title: Re: source insight plugin
Post by: MortenMacFly on September 24, 2010, 05:33:40 pm
source insight plugin:
...what is this?! :shock:
Title: Re: source insight plugin
Post by: zyjjingle on September 24, 2010, 05:39:50 pm
how to send snap image?

open a editor in output window, something like SourceInsight Do. Depend on CodeCompletion Plugin.
Title: Re: source insight plugin
Post by: MortenMacFly on September 24, 2010, 05:44:42 pm
how to send snap image?
Use services like ImageShack to show screen shots. But what is SouceInsight? The only reference I found was this: http://www.sourceinsight.com, but it seems to be a stand-alone commercial application. Can you please just say in a few words what this plugin shall do? What is the purpose? What are the pre-requisites? In addition, why don't you add a ZIP file as attachment to your post including all the required files (e.g. the project file, too)?!

This way it will be hard to understand what this does and even to compile it.
Title: Re: source insight plugin
Post by: ollydbg on September 25, 2010, 03:43:21 am
source insight plugin:

project & sanp images in:
svn://svn.code.sf.net/p/zyjcodeblocks/svn

it need some change in SDK and codecompletion.





interesting, but should this functionality add to Codecompletion plugin?
Title: Re: source insight plugin
Post by: jens on September 25, 2010, 09:40:05 am
And please use code-tags if you post code, your post is nearly unreadable.
Title: Re: source insight plugin
Post by: MortenMacFly on September 27, 2010, 09:04:57 pm
interesting, but should this functionality add to Codecompletion plugin?
I doubt. Because actually plugins should not depend on each other-. There should always be another solution, e.g. through an extension f the SDK.