Author Topic: source insight plugin  (Read 11090 times)

Offline zyjjingle

  • Multiple posting newcomer
  • *
  • Posts: 11
source insight plugin
« 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);
}   }
}


« Last Edit: September 25, 2010, 11:36:08 am by zyjjingle »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: source insight plugin
« Reply #1 on: September 24, 2010, 05:33:40 pm »
source insight plugin:
...what is this?! :shock:
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline zyjjingle

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: source insight plugin
« Reply #2 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: source insight plugin
« Reply #3 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5247
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: source insight plugin
« Reply #4 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?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: source insight plugin
« Reply #5 on: September 25, 2010, 09:40:05 am »
And please use code-tags if you post code, your post is nearly unreadable.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: source insight plugin
« Reply #6 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ