~ubuntu-branches/debian/wheezy/codelite/wheezy

« back to all changes in this revision

Viewing changes to LiteEditor/context_cpp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-04-30 02:46:27 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090430024627-7xp71gerfvw00xtt
Tags: 1.0.2822+dfsg-0ubuntu1
* New upstream release (LP: #369466)
* debian/copyright:
  + Added Files section for sdk/wxpropgrid
  + Made license text RFC compliant (add . for empty lines)
* debian/control:
  + Bump Standards-Version to 3.8.1
* debian/patches/02_fix-desktop.patch,
  + Refreshed to patch cleanly
* debian/*.install,
  debian/codelite.dirs,
  debian/codelite.links,
  debian/patches/03_fix-sh.patch,
  debian/patches/04_change-installpath.patch,
  + Updated for new upstream directory structure
  + Patches dropped, no longer needed.
* debian/patches/03_cstdio-include.patch,
  + Include cstdio for C++ and stdio.h for C, since it seems to be missing
* debian/codelite.menu,
  debian/*.1,
  debian/codelite.manpages:
  + Updated to reflect change in command names
    - CodeLite    => codelite
    - le_exec     => codelite_exec
    - le_dos2unix => codelite_fix_files
    - le_killproc => codelite_kill_children
* debian/README.source,
  debian/rules,
  debian/copyright:
  + Remove sdk/curl from the list of excluded files, since it doesn't exist
    any more

Show diffs side-by-side

added added

removed removed

Lines of Context:
783
783
                GetCtrl().RegisterImageForKind(wxT("FileHeader"), m_hFileBmp  );
784
784
                std::vector<TagEntryPtr> tags;
785
785
 
786
 
                for (size_t i=0; i<files.size(); i++){
 
786
                for (size_t i=0; i<files.size(); i++) {
787
787
                        TagEntryPtr t(new TagEntry());
788
788
                        t->SetName(files.at(i).GetFullName());
789
789
                        t->SetKind(IsSource(files.at(i).GetExt()) ? wxT("FileCpp") : wxT("FileHeader"));
1711
1711
 
1712
1712
bool ContextCpp::OpenFileAndAppend ( const wxString &fileName, const wxString &text )
1713
1713
{
1714
 
    LEditor *editor = Frame::Get()->GetMainBook()->OpenFile(fileName, wxEmptyString, 0);
1715
 
    if (!editor)
1716
 
        return false;
 
1714
        LEditor *editor = Frame::Get()->GetMainBook()->OpenFile(fileName, wxEmptyString, 0);
 
1715
        if (!editor)
 
1716
                return false;
1717
1717
 
1718
 
    // if needed, append EOL
1719
 
    // in an ideal world, we would like that the file will be terminated with 2xEOL
1720
 
    if(editor->GetText().EndsWith(editor->GetEolString()) == false) {
1721
 
        editor->AppendText(editor->GetEolString());
1722
 
    }
1723
 
    if(editor->GetText().EndsWith(editor->GetEolString() + editor->GetEolString()) == false){
1724
 
        editor->AppendText(editor->GetEolString());
1725
 
    }
1726
 
    int lineNum = editor->GetLineCount();
1727
 
    editor->GotoLine ( lineNum-1 );
1728
 
    editor->AppendText ( text );
1729
 
    return true;
 
1718
        // if needed, append EOL
 
1719
        // in an ideal world, we would like that the file will be terminated with 2xEOL
 
1720
        if (editor->GetText().EndsWith(editor->GetEolString()) == false) {
 
1721
                editor->AppendText(editor->GetEolString());
 
1722
        }
 
1723
        if (editor->GetText().EndsWith(editor->GetEolString() + editor->GetEolString()) == false) {
 
1724
                editor->AppendText(editor->GetEolString());
 
1725
        }
 
1726
        int lineNum = editor->GetLineCount();
 
1727
        editor->GotoLine ( lineNum-1 );
 
1728
        editor->AppendText ( text );
 
1729
        return true;
1730
1730
}
1731
1731
 
1732
1732
void ContextCpp::OnFileSaved()
2134
2134
 
2135
2135
        for ( std::list<CppToken>::iterator iter = li.begin(); iter != li.end(); iter++ ) {
2136
2136
                CppToken &token = *iter;
2137
 
        if ( file_name == token.getFilename() ) {
2138
 
            // update next token offset in case we are still in the same file
2139
 
            token.setOffset ( token.getOffset() + off );
2140
 
        } else {
2141
 
            // switched file
2142
 
            off = 0;
2143
 
            file_name = token.getFilename();
2144
 
        }
2145
 
        LEditor *editor = Frame::Get()->GetMainBook()->OpenFile(token.getFilename(), wxEmptyString, 0);
 
2137
                if ( file_name == token.getFilename() ) {
 
2138
                        // update next token offset in case we are still in the same file
 
2139
                        token.setOffset ( token.getOffset() + off );
 
2140
                } else {
 
2141
                        // switched file
 
2142
                        off = 0;
 
2143
                        file_name = token.getFilename();
 
2144
                }
 
2145
                LEditor *editor = Frame::Get()->GetMainBook()->OpenFile(token.getFilename(), wxEmptyString, 0);
2146
2146
                if (editor != NULL && editor->GetFileName().GetFullPath() == wxFileName(token.getFilename()).GetFullPath()) {
2147
 
            editor->SetSelection ( token.getOffset(), token.getOffset()+token.getName().Len() );
2148
 
            if ( editor->GetSelectionStart() != editor->GetSelectionEnd() ) {
2149
 
                editor->ReplaceSelection ( word );
2150
 
                off += word.Len() - token.getName().Len();
2151
 
            }
 
2147
                        editor->SetSelection ( token.getOffset(), token.getOffset()+token.getName().Len() );
 
2148
                        if ( editor->GetSelectionStart() != editor->GetSelectionEnd() ) {
 
2149
                                editor->ReplaceSelection ( word );
 
2150
                                off += word.Len() - token.getName().Len();
 
2151
                        }
2152
2152
                }
2153
2153
        }
2154
2154
}
2374
2374
 
2375
2375
        //get expression
2376
2376
        wxString expr = GetExpression(currentPosition, false);
 
2377
 
2377
2378
        // get the scope
2378
 
        //Optimize the text for large files
 
2379
        // Optimize the text for large files
2379
2380
        int line = rCtrl.LineFromPosition(rCtrl.GetCurrentPosition())+1;
2380
2381
        int startPos(0);
2381
 
        TagEntryPtr t = TagsManagerST::Get()->FunctionFromFileLine(rCtrl.GetFileName(), line);
2382
 
        if ( t ) {
2383
 
                startPos = rCtrl.PositionFromLine( t->GetLine() - 1);
2384
 
                if ( startPos > currentPosition ) {
2385
 
                        startPos = 0;
 
2382
 
 
2383
        // enable faster scope name resolving if needed
 
2384
        if ( !(TagsManagerST::Get()->GetCtagsOptions().GetFlags() & CC_ACCURATE_SCOPE_RESOLVING) ) {
 
2385
                TagEntryPtr t = TagsManagerST::Get()->FunctionFromFileLine(rCtrl.GetFileName(), line);
 
2386
                if ( t ) {
 
2387
                        startPos = rCtrl.PositionFromLine( t->GetLine() - 1);
 
2388
                        if ( startPos > currentPosition ) {
 
2389
                                startPos = 0;
 
2390
                        }
2386
2391
                }
2387
2392
        }
2388
2393
 
2389
2394
        wxString text = rCtrl.GetTextRange(startPos, currentPosition);
2390
 
        //hack #2
2391
 
        //collect all text from 0 - first scope found
2392
 
        //this will help us detect statements like 'using namespace foo;'
 
2395
 
 
2396
        // collect all text from 0 - first scope found
 
2397
        // this will help us detect statements like 'using namespace foo;'
2393
2398
        if (startPos) { //> 0
2394
2399
                //get the first function on this file
2395
2400
                int endPos(0);
2656
2661
        return index;
2657
2662
}
2658
2663
 
2659
 
void ContextCpp::DoUpdateCalltipHighlight()
 
2664
void ContextCpp::DoUpdateCalltipHighlight()
2660
2665
{
2661
2666
        LEditor &ctrl = GetCtrl();
2662
2667
        if (ctrl.CallTipActive() && m_ct && m_ct->Count() && ctrl.GetCalltipType() == ct_function_proto) {
2667
2672
                        m_ct->GetHighlightPos(index, start, len);
2668
2673
                        ctrl.CallTipSetHighlight(start, start + len);
2669
2674
                }
2670
 
        }
2671
 
}
 
2675
        }
 
2676
}