mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-26 15:24:35 +02:00
[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);
|
::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//_pDocMap->initWrapMap();
|
|
||||||
//_pDocMap->wrapMap();
|
|
||||||
_pFuncList->display();
|
_pFuncList->display();
|
||||||
|
_pFuncList->reload();
|
||||||
_pEditView->getFocus();
|
_pEditView->getFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,10 +194,12 @@ void FunctionListPanel::reload()
|
|||||||
vector<foundInfo> fi;
|
vector<foundInfo> fi;
|
||||||
|
|
||||||
const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName();
|
const TCHAR *fn = ((*_ppEditView)->getCurrentBuffer())->getFileName();
|
||||||
|
LangType langID = ((*_ppEditView)->getCurrentBuffer())->getLangType();
|
||||||
TCHAR *ext = ::PathFindExtension(fn);
|
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"));
|
_treeView.addItem(fn, NULL, INDEX_ROOT, TEXT("-1"));
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < fi.size(); i++)
|
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);
|
_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)
|
void FunctionListPanel::notified(LPNMHDR notification)
|
||||||
{
|
{
|
||||||
if((notification->hwndFrom == _treeView.getHSelf()))
|
if((notification->hwndFrom == _treeView.getHSelf()))
|
||||||
@ -252,25 +281,27 @@ void FunctionListPanel::notified(LPNMHDR notification)
|
|||||||
{
|
{
|
||||||
case NM_DBLCLK:
|
case NM_DBLCLK:
|
||||||
{
|
{
|
||||||
TVITEM tvItem;
|
openSelection();
|
||||||
tvItem.mask = TVIF_PARAM;
|
}
|
||||||
tvItem.hItem = _treeView.getSelection();
|
break;
|
||||||
::SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem);
|
|
||||||
|
case TVN_KEYDOWN:
|
||||||
//NodeType nType = getNodeType(tvItem.hItem);
|
{
|
||||||
generic_string *posStr = (generic_string *)tvItem.lParam;
|
//tvItem.hItem = _treeView.getSelection();
|
||||||
if (posStr)
|
//::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 (!openSelection())
|
||||||
if (pos != -1)
|
|
||||||
{
|
{
|
||||||
int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, pos);
|
HTREEITEM hItem = _treeView.getSelection();
|
||||||
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
|
_treeView.toggleExpandCollapse(hItem);
|
||||||
(*_ppEditView)->execute(SCI_GOTOPOS, pos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,5 +109,6 @@ private:
|
|||||||
void addInTreeStateArray(TreeStateNode tree2Update);
|
void addInTreeStateArray(TreeStateNode tree2Update);
|
||||||
TreeStateNode* getFromTreeStateArray(generic_string fullFilePath);
|
TreeStateNode* getFromTreeStateArray(generic_string fullFilePath);
|
||||||
BOOL setImageList(int root_id, int node_id, int leaf_id);
|
BOOL setImageList(int root_id, int node_id, int leaf_id);
|
||||||
|
bool openSelection();
|
||||||
};
|
};
|
||||||
#endif // FUNCLISTPANEL_H
|
#endif // FUNCLISTPANEL_H
|
||||||
|
@ -195,15 +195,17 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
childNode;
|
childNode;
|
||||||
childNode = childNode->NextSibling(TEXT("association")) )
|
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"));
|
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++)
|
for (size_t i = 0; i < _parsers.size(); i++)
|
||||||
{
|
{
|
||||||
if (_parsers[i]->_id == id)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,12 +216,22 @@ bool FunctionParsersManager::getFuncListFromXmlTree()
|
|||||||
return (_parsers.size() != 0);
|
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)
|
FunctionParser * FunctionParsersManager::getParser(generic_string ext)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < _associationMap.size(); i++)
|
for (size_t i = 0; i < _associationMap.size(); i++)
|
||||||
{
|
{
|
||||||
if (ext == _associationMap[i].first)
|
if (ext == _associationMap[i]._ext)
|
||||||
return _parsers[_associationMap[i].second];
|
return _parsers[_associationMap[i]._id];
|
||||||
}
|
}
|
||||||
return NULL;
|
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)
|
bool FunctionParsersManager::parse(std::vector<foundInfo> & foundInfos, generic_string ext)
|
||||||
{
|
{
|
||||||
if (!_pXmlFuncListDoc)
|
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 {
|
class FunctionParsersManager {
|
||||||
public:
|
public:
|
||||||
FunctionParsersManager() : _ppEditView(NULL), _pXmlFuncListDoc(NULL){};
|
FunctionParsersManager() : _ppEditView(NULL), _pXmlFuncListDoc(NULL){};
|
||||||
bool init(generic_string xmlPath, ScintillaEditView ** ppEditView);
|
bool init(generic_string xmlPath, ScintillaEditView ** ppEditView);
|
||||||
|
bool parse(std::vector<foundInfo> & foundInfos, int langID);
|
||||||
bool parse(std::vector<foundInfo> & foundInfos, generic_string ext);
|
bool parse(std::vector<foundInfo> & foundInfos, generic_string ext);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScintillaEditView **_ppEditView;
|
ScintillaEditView **_ppEditView;
|
||||||
std::vector<FunctionParser *> _parsers;
|
std::vector<FunctionParser *> _parsers;
|
||||||
std::vector<std::pair<generic_string, size_t>> _associationMap;
|
std::vector<AssociationInfo> _associationMap;
|
||||||
TiXmlDocument *_pXmlFuncListDoc;
|
TiXmlDocument *_pXmlFuncListDoc;
|
||||||
|
|
||||||
bool getFuncListFromXmlTree();
|
bool getFuncListFromXmlTree();
|
||||||
FunctionParser * getParser(generic_string ext);
|
FunctionParser * getParser(generic_string ext);
|
||||||
|
FunctionParser * getParser(int langID);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FUNCTIONPARSER_H
|
#endif //FUNCTIONPARSER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user