[UPDATE] Build-in FunctionList in progress.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1027 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
9df4ec6b51
commit
f98e5fd8ad
@ -5171,11 +5171,8 @@ void Notepad_plus::launchFunctionList()
|
||||
|
||||
::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data);
|
||||
}
|
||||
|
||||
//_pDocMap->initWrapMap();
|
||||
//_pDocMap->wrapMap();
|
||||
_pFuncList->display();
|
||||
|
||||
_pFuncList->reload();
|
||||
_pEditView->getFocus();
|
||||
}
|
||||
|
||||
|
@ -194,10 +194,12 @@ void FunctionListPanel::reload()
|
||||
vector<foundInfo> fi;
|
||||
|
||||
const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName();
|
||||
|
||||
LangType langID = ((*_ppEditView)->getCurrentBuffer())->getLangType();
|
||||
TCHAR *ext = ::PathFindExtension(fn);
|
||||
if (_funcParserMgr.parse(fi, ext))
|
||||
if (_funcParserMgr.parse(fi, langID) || _funcParserMgr.parse(fi, ext))
|
||||
{
|
||||
_treeView.addItem(fn, NULL, INDEX_ROOT, TEXT("-1"));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < fi.size(); i++)
|
||||
{
|
||||
@ -244,6 +246,33 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp
|
||||
_funcParserMgr.init(funcListXmlPath, ppEditView);
|
||||
}
|
||||
|
||||
bool FunctionListPanel::openSelection()
|
||||
{
|
||||
TVITEM tvItem;
|
||||
tvItem.mask = TVIF_IMAGE | TVIF_PARAM;
|
||||
tvItem.hItem = _treeView.getSelection();
|
||||
::SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem);
|
||||
|
||||
if (tvItem.iImage == INDEX_ROOT || tvItem.iImage == INDEX_NODE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
generic_string *posStr = (generic_string *)tvItem.lParam;
|
||||
if (!posStr)
|
||||
return false;
|
||||
|
||||
int pos = generic_atoi(posStr->c_str());
|
||||
if (pos == -1)
|
||||
return false;
|
||||
|
||||
int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, pos);
|
||||
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
|
||||
(*_ppEditView)->execute(SCI_GOTOPOS, pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FunctionListPanel::notified(LPNMHDR notification)
|
||||
{
|
||||
if((notification->hwndFrom == _treeView.getHSelf()))
|
||||
@ -252,25 +281,27 @@ void FunctionListPanel::notified(LPNMHDR notification)
|
||||
{
|
||||
case NM_DBLCLK:
|
||||
{
|
||||
TVITEM tvItem;
|
||||
tvItem.mask = TVIF_PARAM;
|
||||
tvItem.hItem = _treeView.getSelection();
|
||||
::SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem);
|
||||
|
||||
//NodeType nType = getNodeType(tvItem.hItem);
|
||||
generic_string *posStr = (generic_string *)tvItem.lParam;
|
||||
if (posStr)
|
||||
openSelection();
|
||||
}
|
||||
break;
|
||||
|
||||
case TVN_KEYDOWN:
|
||||
{
|
||||
//tvItem.hItem = _treeView.getSelection();
|
||||
//::SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem);
|
||||
LPNMTVKEYDOWN ptvkd = (LPNMTVKEYDOWN)notification;
|
||||
|
||||
if (ptvkd->wVKey == VK_RETURN)
|
||||
{
|
||||
int pos = generic_atoi(posStr->c_str());
|
||||
if (pos != -1)
|
||||
if (!openSelection())
|
||||
{
|
||||
int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, pos);
|
||||
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
|
||||
(*_ppEditView)->execute(SCI_GOTOPOS, pos);
|
||||
HTREEITEM hItem = _treeView.getSelection();
|
||||
_treeView.toggleExpandCollapse(hItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,5 +109,6 @@ private:
|
||||
void addInTreeStateArray(TreeStateNode tree2Update);
|
||||
TreeStateNode* getFromTreeStateArray(generic_string fullFilePath);
|
||||
BOOL setImageList(int root_id, int node_id, int leaf_id);
|
||||
bool openSelection();
|
||||
};
|
||||
#endif // FUNCLISTPANEL_H
|
||||
|
@ -195,15 +195,17 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
||||
childNode;
|
||||
childNode = childNode->NextSibling(TEXT("association")) )
|
||||
{
|
||||
const TCHAR *ext = (childNode->ToElement())->Attribute(TEXT("ext"));
|
||||
int langID;
|
||||
const TCHAR *langIDStr = (childNode->ToElement())->Attribute(TEXT("langID"), &langID);
|
||||
const TCHAR *exts = (childNode->ToElement())->Attribute(TEXT("ext"));
|
||||
const TCHAR *id = (childNode->ToElement())->Attribute(TEXT("id"));
|
||||
if (ext && ext[0] && id && id[0])
|
||||
if ((langIDStr || (exts && exts[0])) && (id && id[0]))
|
||||
{
|
||||
for (size_t i = 0; i < _parsers.size(); i++)
|
||||
{
|
||||
if (_parsers[i]->_id == id)
|
||||
{
|
||||
_associationMap.push_back(std::pair<generic_string, size_t>(ext, i));
|
||||
_associationMap.push_back(AssociationInfo(i, langID, exts?exts:TEXT("")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -214,12 +216,22 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
||||
return (_parsers.size() != 0);
|
||||
}
|
||||
|
||||
FunctionParser * FunctionParsersManager::getParser(int langID)
|
||||
{
|
||||
for (size_t i = 0; i < _associationMap.size(); i++)
|
||||
{
|
||||
if (langID == _associationMap[i]._langID)
|
||||
return _parsers[_associationMap[i]._id];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FunctionParser * FunctionParsersManager::getParser(generic_string ext)
|
||||
{
|
||||
for (size_t i = 0; i < _associationMap.size(); i++)
|
||||
{
|
||||
if (ext == _associationMap[i].first)
|
||||
return _parsers[_associationMap[i].second];
|
||||
if (ext == _associationMap[i]._ext)
|
||||
return _parsers[_associationMap[i]._id];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -331,6 +343,23 @@ generic_string FunctionParser::parseSubLevel(size_t begin, size_t end, std::vect
|
||||
}
|
||||
}
|
||||
|
||||
bool FunctionParsersManager::parse(std::vector<foundInfo> & foundInfos, int langID)
|
||||
{
|
||||
if (!_pXmlFuncListDoc)
|
||||
return false;
|
||||
|
||||
// Serch the right parser from the given ext in the map
|
||||
FunctionParser *fp = getParser(langID);
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
// parse
|
||||
int docLen = (*_ppEditView)->getCurrentDocLen();
|
||||
fp->parse(foundInfos, 0, docLen, _ppEditView);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FunctionParsersManager::parse(std::vector<foundInfo> & foundInfos, generic_string ext)
|
||||
{
|
||||
if (!_pXmlFuncListDoc)
|
||||
|
@ -91,20 +91,30 @@ public:
|
||||
|
||||
};
|
||||
|
||||
struct AssociationInfo {
|
||||
int _id;
|
||||
int _langID;
|
||||
generic_string _ext;
|
||||
|
||||
AssociationInfo(int id, int langID, const TCHAR *ext): _id(id), _langID(langID), _ext(ext){};
|
||||
};
|
||||
|
||||
class FunctionParsersManager {
|
||||
public:
|
||||
FunctionParsersManager() : _ppEditView(NULL), _pXmlFuncListDoc(NULL){};
|
||||
bool init(generic_string xmlPath, ScintillaEditView ** ppEditView);
|
||||
bool parse(std::vector<foundInfo> & foundInfos, int langID);
|
||||
bool parse(std::vector<foundInfo> & foundInfos, generic_string ext);
|
||||
|
||||
private:
|
||||
ScintillaEditView **_ppEditView;
|
||||
std::vector<FunctionParser *> _parsers;
|
||||
std::vector<std::pair<generic_string, size_t>> _associationMap;
|
||||
std::vector<AssociationInfo> _associationMap;
|
||||
TiXmlDocument *_pXmlFuncListDoc;
|
||||
|
||||
bool getFuncListFromXmlTree();
|
||||
FunctionParser * getParser(generic_string ext);
|
||||
FunctionParser * getParser(int langID);
|
||||
};
|
||||
|
||||
#endif //FUNCTIONPARSER_H
|
||||
|
Loading…
Reference in New Issue
Block a user