Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Toggle comment

<< < (3/4) > >>

sethjackson:
Umm killerbot why doesn't this work (Yeah I know it has to do with Unicode)? The watches dialog shows square boxes for the Unicode characters. I think this problem happens in main.cpp around line 2205.......

killerbot:
I have done some debugging once, and I felt like it was going wrong at :
               stc->ReplaceTarget( strLine );
(during uncomment).
Should check my notes again. I kind of had the impression it could be a wxScintilla problem...

sethjackson:

--- Quote from: killerbot on June 26, 2006, 09:56:18 pm ---I have done some debugging once, and I felt like it was going wrong at :
               stc->ReplaceTarget( strLine );
(during uncomment).
Should check my notes again. I kind of had the impression it could be a wxScintilla problem...

--- End quote ---

Hmm maybe wxScintilla has a problem with Unicode....... :(

killerbot:
for those interested, attached zip file contains a simple main.cpp.
Put your cursor at the start of the (first) line and select the uncomment command --> you can see the problem ;-)

Here's a little modified part of the codfe from (the CB source that is) main.cpp::MainFrame::OnEditUncommentSelected()
In comments I have put the values from the debugger in the above example :


--- Code: ---int commentPos = strLine.Strip( wxString::leading ).Find( Comment );
if( commentPos ==0 )
{
// Uncomment
strLine.Replace( Comment, _T( "" ), false );

// Update
int start = stc->PositionFromLine( startLine );       // 0
stc->SetTargetStart( start );
// adjust for the '//' we erased
int x = strLine.Length();                                    // 18
int y = Comment.Length();                                // 2
stc->SetTargetEnd( start + strLine.Length() + Comment.Length() );  // 20
stc->ReplaceTarget( strLine );
}

--- End code ---

These values seems correct, but after the stc->ReplaceTarget the damage is done.

I'll try to test if it works with the new wxScintilla, but I have already a workaround in mind which I am gonna try out first.

Note that "commenting" the line works, for that purpose stc->InsertText was used, and that seems to work well.

[attachment deleted by admin]

killerbot:
allright my workaround works this is the same part of code, but with the fix : I will commit later this evening.
If you see troubles in the solution, feel free to post.


--- Code: ---int commentPos = strLine.Strip( wxString::leading ).Find( Comment );
if( commentPos ==0 )
{      // we know the comment is there (maybe preceded by white space)
int Pos = strLine.Find(Comment);
int start = stc->PositionFromLine( startLine ) + Pos;
int end = start + Comment.Length();
stc->SetTargetStart( start );
stc->SetTargetEnd( end );
stc->ReplaceTarget( wxEmptyString );
}

--- End code ---

 :D :D :D :D :D :D


[EDIT] : And I will do the same thing in OnEditToggleCommentSelected ;-)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version