[BUG_FIXED] Fix Calltip hint bug and add a new capacity in it.

[NEW] Add colour settings for GUI4Cli.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@556 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2009-11-05 01:44:40 +00:00
parent 7060444031
commit bb8ad920d0
6 changed files with 164 additions and 109 deletions

View File

@ -7,8 +7,14 @@
ignore any casing, start and stopFunc specify what chars a function starts and stops with.
param specifies parameter separator and terminal can be used to specify a character that stops
any function. Using the same character for different functions results in undefined behaviour.
05/11/2009
The basic word character are : A-Z a-z 0-9 and '_'
If your function name contains other characters,
add your characters in "additionalWordChar" attribute (without separator)
in order to make calltip hint work
-->
<Environment ignoreCase="no" startFunc="(" stopFunc=")" paramSeparator="," terminal=";" />
<Environment ignoreCase="no" startFunc="(" stopFunc=")" paramSeparator="," terminal=";" additionalWordChar="."/>
<!--
The following items should be alphabetically ordered.
func="yes" means the keyword should be treated as a fuction, and thus can be used in the parameter

View File

@ -235,7 +235,8 @@ bool AutoCompletion::setLanguage(LangType language) {
_funcCompletionActive = true;
}
if(_funcCompletionActive) { //try setting up environment
if(_funcCompletionActive) //try setting up environment
{
//setup defaults
_ignoreCase = true;
_funcCalltip._start = '(';
@ -243,9 +244,11 @@ bool AutoCompletion::setLanguage(LangType language) {
_funcCalltip._param = ',';
_funcCalltip._terminal = ';';
_funcCalltip._ignoreCase = true;
_funcCalltip._additionalWordChar = TEXT("");
TiXmlElement * pElem = pAutoNode->FirstChildElement(TEXT("Environment"));
if (pElem) {
if (pElem)
{
const TCHAR * val = 0;
val = pElem->Attribute(TEXT("ignoreCase"));
if (val && !lstrcmp(val, TEXT("no"))) {
@ -264,6 +267,9 @@ bool AutoCompletion::setLanguage(LangType language) {
val = pElem->Attribute(TEXT("terminal"));
if (val && val[0])
_funcCalltip._terminal = val[0];
val = pElem->Attribute(TEXT("additionalWordChar"));
if (val && val[0])
_funcCalltip._additionalWordChar = val;
}
}

View File

@ -111,7 +111,8 @@ void FunctionCallTip::close() {
_currentOverload = 0;
}
bool FunctionCallTip::getCursorFunction() {
bool FunctionCallTip::getCursorFunction()
{
int line = _pEditView->execute(SCI_LINEFROMPOSITION, _curPos);
int startpos = _pEditView->execute(SCI_POSITIONFROMLINE, line);
int endpos = _pEditView->execute(SCI_GETLINEENDPOSITION, line);
@ -135,23 +136,30 @@ bool FunctionCallTip::getCursorFunction() {
std::vector< Token > tokenVector;
int tokenLen = 0;
TCHAR ch;
for (int i = 0; i < offset; i++) { //we dont care about stuff after the offset
for (int i = 0; i < offset; i++) //we dont care about stuff after the offset
{
//tokenVector.push_back(pair(lineData+i, len));
ch = lineData[i];
if (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '_') { //part of identifier
if (isBasicWordChar(ch) || isAdditionalWordChar(ch)) //part of identifier
{
tokenLen = 0;
TCHAR * begin = lineData+i;
while ( (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '_') && i < offset) {
while ((isBasicWordChar(ch) || isAdditionalWordChar(ch)) && i < offset) {
tokenLen++;
i++;
ch = lineData[i];
}
tokenVector.push_back(Token(begin, tokenLen, true));
i--; //correct overshooting of while loop
} else {
if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') { //whitespace
}
else
{
if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') //whitespace
{
//do nothing
} else {
}
else
{
tokenLen = 1;
tokenVector.push_back(Token(lineData+i, tokenLen, false));
}
@ -255,21 +263,23 @@ bool FunctionCallTip::loadFunction() {
compVal = testNameNoCase(name, _funcName); //lstrcmpi doesnt work in this case
else
compVal = lstrcmp(name, _funcName);
if (!compVal) { //found it?
if (!compVal) //found it!
{
const TCHAR * val = funcNode->Attribute(TEXT("func"));
if (val)
{
if (!lstrcmp(val, TEXT("yes"))) {
if (!lstrcmp(val, TEXT("yes")))
{
//what we've been looking for
_curFunction = funcNode;
break;
} else {
}
else
{
//name matches, but not a function, abort the entire procedure
return false;
}
}
} else if (compVal > 0) { //too far, abort
return false;
}
}
@ -314,8 +324,10 @@ bool FunctionCallTip::loadFunction() {
return true;
}
void FunctionCallTip::showCalltip() {
if (_currentNrOverloads == 0) {
void FunctionCallTip::showCalltip()
{
if (_currentNrOverloads == 0)
{
//ASSERT
return;
}

View File

@ -30,7 +30,7 @@ public:
FunctionCallTip(ScintillaEditView * pEditView) : _pEditView(pEditView), _pXmlKeyword(NULL), _curPos(0), _startPos(0),
_curFunction(NULL), _currentNrOverloads(0), _currentOverload(0),
_currentParam(0), _funcName(NULL),
_start('('), _stop(')'), _param(','), _terminal(';'), _ignoreCase(true)
_start('('), _stop(')'), _param(','), _terminal(';'), _ignoreCase(true), _additionalWordChar(TEXT(""))
{};
~FunctionCallTip() {/* cleanup(); */};
void setLanguageXML(TiXmlElement * pXmlKeyword); //set calltip keyword node
@ -61,6 +61,7 @@ private:
TCHAR _stop;
TCHAR _param;
TCHAR _terminal;
generic_string _additionalWordChar;
bool _ignoreCase;
bool getCursorFunction(); //retrieve data about function at cursor. Returns true if a function was found. Calls loaddata if needed
@ -68,6 +69,17 @@ private:
void showCalltip(); //display calltip based on current variables
void reset(); //reset all vars in case function is invalidated
void cleanup(); //delete any leftovers
bool isBasicWordChar(TCHAR ch) const {
return (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '_');
};
bool isAdditionalWordChar(TCHAR ch) const {
const TCHAR *addChars = _additionalWordChar.c_str();
size_t len = _additionalWordChar.length();
for (size_t i = 0 ; i < len ; i++)
if (ch == addChars[i])
return true;
return false;
};
};
#endif// FUNCTIONCALLTIP_H

File diff suppressed because one or more lines are too long

View File

@ -32,7 +32,7 @@
<WordsStyle name="COMMENT LINE" styleID="10" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="ILLEGAL" styleID="11" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
</LexerType>
<LexerType name="asp" desc="asp" ext="asp">
<LexerType name="asp" desc="asp" ext="asp">
<WordsStyle name="DEFAULT" styleID="81" fgColor="8000FF" bgColor="C4F9FD" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENTLINE" styleID="82" fgColor="008000" bgColor="C4F9FD" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="NUMBER" styleID="83" fgColor="FF0000" bgColor="C4F9FD" fontName="" fontStyle="0" fontSize="" />
@ -58,7 +58,7 @@
<WordsStyle name="CHARACTER" styleID="12" fgColor="808000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="EXT INSTRUCTION" styleID="14" fgColor="804000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="type4" />
</LexerType>
<LexerType name="autoit" desc="autoIt" ext="">
<LexerType name="autoit" desc="autoIt" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENT LINE" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENT" styleID="2" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
@ -101,7 +101,7 @@
<WordsStyle name="VARIABLE" styleID="6" fgColor="FF8000" bgColor="FCFFF0" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="OPERATOR" styleID="7" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
</LexerType>
<LexerType name="c" desc="C" ext="">
<LexerType name="c" desc="C" ext="">
<WordsStyle name="PREPROCESSOR" styleID="9" fgColor="804000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="DEFAULT" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="INSTRUCTION WORD" styleID="5" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
@ -155,7 +155,7 @@
<WordsStyle name="COMMENT DOC KEYWORD" styleID="17" fgColor="008080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="COMMENT DOC KEYWORD ERROR" styleID="18" fgColor="008080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
</LexerType>
<LexerType name="caml" desc="Caml" ext="">
<LexerType name="caml" desc="Caml" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="IDENTIFIER" styleID="1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="TAGNAME" styleID="2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
@ -189,7 +189,7 @@
<WordsStyle name="STRING VARIABLE" styleID="13" fgColor="808080" bgColor="FEFCF5" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="NUMBER" styleID="14" fgColor="804040" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
</LexerType>
<LexerType name="css" desc="CSS" ext="">
<LexerType name="css" desc="CSS" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="TAG" styleID="1" fgColor="0000FF" bgColor="FFFFFF" fontName="Batang" fontStyle="0" fontSize="" />
<WordsStyle name="CLASS" styleID="2" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
@ -204,7 +204,7 @@
<WordsStyle name="IMPORTANT" styleID="11" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="DIRECTIVE" styleID="12" fgColor="0080FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
</LexerType>
<LexerType name="cobol" desc="COBOL" ext="">
<LexerType name="cobol" desc="COBOL" ext="">
<WordsStyle name="PREPROCESSOR" styleID="9" fgColor="804000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="DEFAULT" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="DECLARATION" styleID="5" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
@ -221,7 +221,7 @@
<WordsStyle name="COMMENT DOC KEYWORD" styleID="17" fgColor="008080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="COMMENT DOC KEYWORD ERROR" styleID="18" fgColor="008080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
</LexerType>
<LexerType name="d" desc="D" ext="">
<LexerType name="d" desc="D" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="IDENTIFIER" styleID="14" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="INSTRUCTION WORD" styleID="6" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
@ -252,6 +252,18 @@
<WordsStyle name="DELETED" styleID="5" fgColor="808040" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="ADDED" styleID="6" fgColor="0080FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
</LexerType>
<LexerType name="gui4cli" desc="GUI4CLI" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENT LINE" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENT" styleID="2" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="GLOBAL" styleID="5" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
<WordsStyle name="EVENT" styleID="5" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre2" />
<WordsStyle name="ATTRIBUTE" styleID="16" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" keywordClass="type1" />
<WordsStyle name="CONTROL" styleID="16" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" keywordClass="type2" />
<WordsStyle name="COMMAND" styleID="16" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" keywordClass="type3" />
<WordsStyle name="STRING" styleID="6" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="OPERATOR" styleID="10" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
</LexerType>
<LexerType name="nfo" desc="Dos Style" ext="">
<WordsStyle name="DEFAULT" styleID="32" fgColor="C0C0C0" bgColor="000000" />
</LexerType>
@ -371,7 +383,7 @@
<WordsStyle name="FUNCTION" styleID="8" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" keywordClass="type1" />
<WordsStyle name="OPERATOR" styleID="9" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
</LexerType>
<LexerType name="lisp" desc="LISP" ext="">
<LexerType name="lisp" desc="LISP" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENTLINE" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="NUMBER" styleID="2" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
@ -408,7 +420,7 @@
<WordsStyle name="TARGET" styleID="5" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="IDEOL" styleID="9" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="2" fontSize="" />
</LexerType>
<LexerType name="matlab" desc="Matlab" ext="">
<LexerType name="matlab" desc="Matlab" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENT" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMAND" styleID="2" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
@ -471,7 +483,7 @@
<WordsStyle name="NUMBER" styleID="7" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="HEX NUMBER" styleID="8" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="INSTRUCTION WORD" styleID="9" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
<WordsStyle name="STRING" styleID="10" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="STRING" styleID="10" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="CHARACTER" styleID="12" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="OPERATOR" styleID="13" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="ASM" styleID="14" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
@ -529,7 +541,7 @@
<WordsStyle name="BASE85 STRING" styleID="14" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="BAD STRING CHAR" styleID="15" fgColor="804000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
</LexerType>
<LexerType name="powershell" desc="PowerShell" ext="">
<LexerType name="powershell" desc="PowerShell" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENT" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="STRING" styleID="2" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
@ -544,7 +556,7 @@
<LexerType name="props" desc="Properties file" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENT" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="SECTION" styleID="2" fgColor="8000FF" bgColor="F2F4FF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="SECTION" styleID="2" fgColor="8000FF" bgColor="F2F4FF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="ASSIGNMENT" styleID="3" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="DEFVAL" styleID="4" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
</LexerType>
@ -563,7 +575,7 @@
<WordsStyle name="IDENTIFIER" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENTBLOCK" styleID="12" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
</LexerType>
<LexerType name="r" desc="R" ext="">
<LexerType name="r" desc="R" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENT" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="INSTRUCTION WORD" styleID="2" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
@ -616,7 +628,7 @@
<WordsStyle name="DATA SECTION" styleID="19" fgColor="600000" bgColor="FFF0D8" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="STRING Q" styleID="24" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
</LexerType>
<LexerType name="scheme" desc="Scheme" ext="">
<LexerType name="scheme" desc="Scheme" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="COMMENTLINE" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="NUMBER" styleID="2" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
@ -785,7 +797,7 @@
<WidgetStyle name="Mark Style 4" styleID="22" bgColor="8000FF" />
<WidgetStyle name="Mark Style 5" styleID="21" bgColor="008000" />
<WidgetStyle name="Incremental highlight all" styleID="28" bgColor="0080FF" />
<WidgetStyle name="Tags match highlighting" styleID="27" bgColor="8000FF" />
<WidgetStyle name="Tags match highlighting" styleID="27" bgColor="8000FF" />
<WidgetStyle name="Tags attribute" styleID="26" bgColor="FFFF00" />
<WidgetStyle name="Active tab focused indicator" styleID="0" fgColor="FAAA3C" />
<WidgetStyle name="Active tab unfocused indicator" styleID="0" fgColor="FFCAB0" />