2012-04-15 16:54:38 +00:00
// this file is part of Notepad++
// Copyright (C)2008 Harry Bruin <harrybharry@users.sourceforge.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the
// following:
// 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield.
// 3. Links to a library or executes a program that does any of the above.
2009-04-24 23:34:47 +00:00
//
2012-04-15 16:54:38 +00:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2009-04-24 23:34:47 +00:00
# ifndef FUNCTIONCALLTIP_H
# define FUNCTIONCALLTIP_H
2009-09-04 00:10:01 +00:00
# ifndef SCINTILLA_EDIT_VIEW_H
2009-04-24 23:34:47 +00:00
# include "ScintillaEditView.h"
2009-09-04 00:10:01 +00:00
# endif //SCINTILLA_EDIT_VIEW_H
2009-04-24 23:34:47 +00:00
typedef std : : vector < const TCHAR * > stringVec ;
class FunctionCallTip {
friend class AutoCompletion ;
public :
2016-07-18 00:08:29 +00:00
explicit FunctionCallTip ( ScintillaEditView * pEditView ) : _pEditView ( pEditView ) { } ;
2009-04-24 23:34:47 +00:00
~ FunctionCallTip ( ) { /* cleanup(); */ } ;
void setLanguageXML ( TiXmlElement * pXmlKeyword ) ; //set calltip keyword node
bool updateCalltip ( int ch , bool needShown = false ) ; //Ch is character typed, or 0 if another event occured. NeedShown is true if calltip should be attempted to displayed. Return true if calltip was made visible
void showNextOverload ( ) ; //show next overlaoded parameters
void showPrevOverload ( ) ; //show prev overlaoded parameters
bool isVisible ( ) { return _pEditView ? _pEditView - > execute ( SCI_CALLTIPACTIVE ) = = TRUE : false ; } ; //true if calltip visible
void close ( ) ; //Close calltip if visible
private :
2016-07-18 00:08:29 +00:00
ScintillaEditView * _pEditView = nullptr ; //Scintilla to display calltip in
TiXmlElement * _pXmlKeyword = nullptr ; //current keyword node (first one)
2009-04-24 23:34:47 +00:00
2016-07-18 00:08:29 +00:00
int _curPos = 0 ; //cursor position
int _startPos = 0 ; //display start position
2009-04-24 23:34:47 +00:00
2016-07-18 00:08:29 +00:00
TiXmlElement * _curFunction = nullptr ; //current function element
2009-04-24 23:34:47 +00:00
//cache some XML values n stuff
2016-07-18 00:08:29 +00:00
TCHAR * _funcName = nullptr ; //name of function
2009-04-24 23:34:47 +00:00
stringVec _retVals ; //vector of overload return values/types
2015-05-31 20:40:07 +00:00
std : : vector < stringVec > _overloads ; //vector of overload params (=vector)
2009-04-24 23:34:47 +00:00
stringVec _descriptions ; //vecotr of function descriptions
2017-07-27 08:30:53 +00:00
size_t _currentNbOverloads = 0 ; //current amount of overloads
2016-07-23 09:37:58 +00:00
size_t _currentOverload = 0 ; //current chosen overload
2016-07-18 00:08:29 +00:00
int _currentParam = 0 ; //current highlighted param
2009-04-24 23:34:47 +00:00
2016-07-18 00:08:29 +00:00
TCHAR _start = ' ( ' ;
TCHAR _stop = ' ) ' ;
TCHAR _param = ' , ' ;
TCHAR _terminal = ' ; ' ;
generic_string _additionalWordChar = TEXT ( " " ) ;
bool _ignoreCase = true ;
bool _selfActivated = false ;
2009-04-24 23:34:47 +00:00
bool getCursorFunction ( ) ; //retrieve data about function at cursor. Returns true if a function was found. Calls loaddata if needed
bool loadFunction ( ) ; //returns true if the function can be found
void showCalltip ( ) ; //display calltip based on current variables
void reset ( ) ; //reset all vars in case function is invalidated
void cleanup ( ) ; //delete any leftovers
2009-11-05 01:44:40 +00:00
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 ( ) ;
2013-07-08 00:12:50 +00:00
for ( size_t i = 0 ; i < len ; + + i )
2009-11-05 01:44:40 +00:00
if ( ch = = addChars [ i ] )
return true ;
return false ;
} ;
2009-04-24 23:34:47 +00:00
} ;
# endif // FUNCTIONCALLTIP_H