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; return;
} }
int style = getLexerStyleAt ( pos - 1 ); int prevPos;
char c = getPrevNonSpaceChar ( pos, &prevPos );
char c = GetCharAt ( pos - 1 ); int style = getLexerStyleAt ( prevPos );
bool proceed = false; bool proceed = false;
// space pressed after element name // space pressed after element name
@ -641,7 +641,7 @@ void XmlCtrl::handleSpace ( wxKeyEvent& event )
( style == wxSTC_H_DOUBLESTRING || ( style == wxSTC_H_DOUBLESTRING ||
style == wxSTC_H_SINGLESTRING ) && style == wxSTC_H_SINGLESTRING ) &&
( c == '\'' || c == '"' ) && ( c == '\'' || c == '"' ) &&
GetCharAt ( pos - 2 ) != '=' ) getPrevNonSpaceChar ( prevPos - 1, NULL ) != '=' )
{ {
proceed = true; proceed = true;
} }
@ -2403,3 +2403,20 @@ void XmlCtrl::OnKillFocus ( wxFocusEvent &event )
AutoCompCancel(); AutoCompCancel();
event.Skip(); 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(); bool selectCurrentElement();
void toggleComment(); void toggleComment();
wxString getCurrentXPath(); wxString getCurrentXPath();
int getPrevNonSpaceChar ( int curPos, int *charPos );
private: private:
ValidationThread *validationThread; // used for background validation ValidationThread *validationThread; // used for background validation
XmlPromptGenerator *mPromptGeneratorThread; XmlPromptGenerator *mPromptGeneratorThread;