Feature #170 I did a small patch that allows SPACE to trigger autocompletion on any space (Thanassis Tsiodras)

This commit is contained in:
Zane U. Ji 2014-10-12 20:49:08 +08:00
parent 0065a8054c
commit 0a5c83adfd
2 changed files with 22 additions and 4 deletions

View File

@ -622,9 +622,9 @@ void XmlCtrl::handleSpace ( wxKeyEvent& event )
return;
}
int style = getLexerStyleAt ( pos - 1 );
char c = GetCharAt ( pos - 1 );
int prevPos;
char c = getPrevNonSpaceChar ( pos, &prevPos );
int style = getLexerStyleAt ( prevPos );
bool proceed = false;
// space pressed after element name
@ -641,7 +641,7 @@ void XmlCtrl::handleSpace ( wxKeyEvent& event )
( style == wxSTC_H_DOUBLESTRING ||
style == wxSTC_H_SINGLESTRING ) &&
( c == '\'' || c == '"' ) &&
GetCharAt ( pos - 2 ) != '=' )
getPrevNonSpaceChar ( prevPos - 1, NULL ) != '=' )
{
proceed = true;
}
@ -2403,3 +2403,20 @@ void XmlCtrl::OnKillFocus ( wxFocusEvent &event )
AutoCompCancel();
event.Skip();
}
int XmlCtrl::getPrevNonSpaceChar ( int curPos, int *charPos )
{
int c = 0;
int pos = curPos;
while ( pos-- > 0 )
{
c = GetCharAt ( pos );
if ( !wxIsspace ( c ) )
break;
}
if ( charPos )
*charPos = pos;
return c;
}

View File

@ -162,6 +162,7 @@ class XmlCtrl: public wxStyledTextCtrl
bool selectCurrentElement();
void toggleComment();
wxString getCurrentXPath();
int getPrevNonSpaceChar ( int curPos, int *charPos );
private:
ValidationThread *validationThread; // used for background validation
XmlPromptGenerator *mPromptGeneratorThread;