[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

View File

@ -80,6 +80,13 @@
<Keywords name="instre2">abs achar acos acosd adjustl adjustr aimag aimax0 aimin0 aint ajmax0 ajmin0 akmax0 akmin0 all allocated alog alog10 amax0 amax1 amin0 amin1 amod anint any asin asind associated atan atan2 atan2d atand bitest bitl bitlr bitrl bjtest bit_size bktest break btest cabs ccos cdabs cdcos cdexp cdlog cdsin cdsqrt ceiling cexp char clog cmplx conjg cos cosd cosh count cpu_time cshift csin csqrt dabs dacos dacosd dasin dasind datan datan2 datan2d datand date date_and_time dble dcmplx dconjg dcos dcosd dcosh dcotan ddim dexp dfloat dflotk dfloti dflotj digits dim dimag dint dlog dlog10 dmax1 dmin1 dmod dnint dot_product dprod dreal dsign dsin dsind dsinh dsqrt dtan dtand dtanh eoshift epsilon errsns exp exponent float floati floatj floatk floor fraction free huge iabs iachar iand ibclr ibits ibset ichar idate idim idint idnint ieor ifix iiabs iiand iibclr iibits iibset iidim iidint iidnnt iieor iifix iint iior iiqint iiqnnt iishft iishftc iisign ilen imax0 imax1 imin0 imin1 imod index inint inot int int1 int2 int4 int8 iqint iqnint ior ishft ishftc isign isnan izext jiand jibclr jibits jibset jidim jidint jidnnt jieor jifix jint jior jiqint jiqnnt jishft jishftc jisign jmax0 jmax1 jmin0 jmin1 jmod jnint jnot jzext kiabs kiand kibclr kibits kibset kidim kidint kidnnt kieor kifix kind kint kior kishft kishftc kisign kmax0 kmax1 kmin0 kmin1 kmod knint knot kzext lbound leadz len len_trim lenlge lge lgt lle llt log log10 logical lshift malloc matmul max max0 max1 maxexponent maxloc maxval merge min min0 min1 minexponent minloc minval mod modulo mvbits nearest nint not nworkers number_of_processors pack popcnt poppar precision present product radix random random_number random_seed range real repeat reshape rrspacing rshift scale scan secnds selected_int_kind selected_real_kind set_exponent shape sign sin sind sinh size sizeof sngl snglq spacing spread sqrt sum system_clock tan tand tanh tiny transfer transpose trim ubound unpack verify</Keywords>
<Keywords name="type1">cdabs cdcos cdexp cdlog cdsin cdsqrt cotan cotand dcmplx dconjg dcotan dcotand decode dimag dll_export dll_import doublecomplex dreal dvchk encode find flen flush getarg getcharqq getcl getdat getenv gettim hfix ibchng identifier imag int1 int2 int4 intc intrup invalop iostat_msg isha ishc ishl jfix lacfar locking locnear map nargs nbreak ndperr ndpexc offset ovefl peekcharqq precfill prompt qabs qacos qacosd qasin qasind qatan qatand qatan2 qcmplx qconjg qcos qcosd qcosh qdim qexp qext qextd qfloat qimag qlog qlog10 qmax1 qmin1 qmod qreal qsign qsin qsind qsinh qsqrt qtan qtand qtanh ran rand randu rewrite segment setdat settim system timer undfl unlock union val virtual volatile zabs zcos zexp zlog zsin zsqrt</Keywords>
</Language>
<Language name="gui4cli" ext="">
<Keywords name="instre1"></Keywords>
<Keywords name="instre2"></Keywords>
<Keywords name="type1"></Keywords>
<Keywords name="type2"></Keywords>
<Keywords name="type3"></Keywords>
</Language>
<Language name="haskell" ext="hs lhs as las" commentLine="--">
<Keywords name="instre1">as case class data default deriving do else hiding if import in infix infixl infixr instance let module newtype of proc qualified rec then type where _</Keywords>
</Language>

View File

@ -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>