[UPDATE] Build-in FunctionList in progress.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1008 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/trunk
Don Ho 2013-01-23 22:59:54 +00:00
parent 793a6665e9
commit 27b2431ad3
6 changed files with 127 additions and 16 deletions

View File

@ -30,17 +30,37 @@
#include "functionListPanel.h" #include "functionListPanel.h"
#include "ScintillaEditView.h" #include "ScintillaEditView.h"
void FunctionListPanel::addEntry(const TCHAR *displayText, size_t pos) void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos)
{ {
/*
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_GETCOUNT, 0, 0); int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_GETCOUNT, 0, 0);
::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_INSERTSTRING, index, (LPARAM)displayText); ::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_INSERTSTRING, index, (LPARAM)displayText);
::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_SETITEMDATA, index, (LPARAM)pos); ::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_SETITEMDATA, index, (LPARAM)pos);
*/
HTREEITEM itemParent = NULL;
TCHAR posStr[32];
generic_itoa(pos, posStr, 10);
HTREEITEM root = _treeView.getRoot();
if (nodeName != NULL && *nodeName != '\0')
{
itemParent = _treeView.searchSubItemByName(nodeName, root);
if (!itemParent)
itemParent = _treeView.addItem(nodeName, root, NULL, posStr);
}
else
itemParent = root;
_treeView.addItem(displayText, itemParent, NULL, posStr);
} }
void FunctionListPanel::removeAllEntries() void FunctionListPanel::removeAllEntries()
{ {
/*
while (::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_GETCOUNT, 0, 0)) while (::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_GETCOUNT, 0, 0))
::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_DELETESTRING, 0, 0); ::SendDlgItemMessage(_hSelf, IDC_LIST_FUNCLIST, LB_DELETESTRING, 0, 0);
*/
_treeView.removeAllItems();
} }
// bodyOpenSybe mbol & bodyCloseSymbol should be RE // bodyOpenSybe mbol & bodyCloseSymbol should be RE
@ -252,6 +272,7 @@ void FunctionListPanel::reload()
{ {
// clean up // clean up
removeAllEntries(); removeAllEntries();
/* /*
generic_string funcBegin = TEXT("^[\\t ]*"); generic_string funcBegin = TEXT("^[\\t ]*");
generic_string qualifier_maybe = TEXT("((static|const)[\\s]+)?"); generic_string qualifier_maybe = TEXT("((static|const)[\\s]+)?");
@ -296,21 +317,36 @@ void FunctionListPanel::reload()
*/ */
vector<foundInfo> fi; vector<foundInfo> fi;
generic_string fn = ((*_ppEditView)->getCurrentBuffer())->getFileName(); generic_string fullFilePath = ((*_ppEditView)->getCurrentBuffer())->getFileName();
TCHAR *ext = ::PathFindExtension(fn.c_str()); TCHAR *fn = ::PathFindFileName(fullFilePath.c_str());
_funcParserMgr.parse(fi, ext);
TCHAR *ext = ::PathFindExtension(fn);
if (_funcParserMgr.parse(fi, ext))
_treeView.addItem(fn, NULL, NULL, TEXT("-1"));
for (size_t i = 0; i < fi.size(); i++) for (size_t i = 0; i < fi.size(); i++)
{ {
generic_string entryName = TEXT(""); // no 2 level
if (fi[i]._pos2 != -1) bool b = false;
if (b)
{ {
entryName = fi[i]._data2; generic_string entryName = TEXT("");
entryName += TEXT("=>"); if (fi[i]._pos2 != -1)
{
entryName = fi[i]._data2;
entryName += TEXT("=>");
}
entryName += fi[i]._data;
addEntry(NULL, entryName.c_str(), fi[i]._pos);
}
else
{
addEntry(fi[i]._data2.c_str(), fi[i]._data.c_str(), fi[i]._pos);
} }
entryName += fi[i]._data;
addEntry(entryName.c_str(), fi[i]._pos);
} }
HTREEITEM root = _treeView.getRoot();
if (root)
_treeView.expand(root);
} }
void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView)
{ {
@ -321,15 +357,52 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp
/*_isValidated = */_funcParserMgr.init(funcListXmlPath, ppEditView); /*_isValidated = */_funcParserMgr.init(funcListXmlPath, ppEditView);
} }
void FunctionListPanel::notified(LPNMHDR notification)
{
if((notification->hwndFrom == _treeView.getHSelf()))
{
/*
TCHAR textBuffer[MAX_PATH];
TVITEM tvItem;
tvItem.mask = TVIF_TEXT | TVIF_PARAM;
tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH;
*/
switch (notification->code)
{
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)
{
int pos = generic_atoi(posStr->c_str());
int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, pos);
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
(*_ppEditView)->execute(SCI_GOTOPOS, pos);
}
}
break;
}
}
}
BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
{ {
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
_treeView.init(_hInst, _hSelf, IDC_LIST_FUNCLIST);
_treeView.display();
return TRUE; return TRUE;
} }
case WM_DESTROY: case WM_DESTROY:
break; break;
@ -358,11 +431,20 @@ BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
} }
break; break;
case WM_NOTIFY:
{
notified((LPNMHDR)lParam);
}
return TRUE;
case WM_SIZE: case WM_SIZE:
{ {
int width = LOWORD(lParam); int width = LOWORD(lParam);
int height = HIWORD(lParam); int height = HIWORD(lParam);
::MoveWindow(::GetDlgItem(_hSelf, IDC_LIST_FUNCLIST), 0, 0, width, height, TRUE); //::MoveWindow(::GetDlgItem(_hSelf, IDC_LIST_FUNCLIST), 0, 0, width, height, TRUE);
HWND hwnd = _treeView.getHSelf();
if (hwnd)
::MoveWindow(hwnd, 0, 0, width, height, TRUE);
break; break;
} }
/* /*

View File

@ -36,6 +36,7 @@
#include "functionListPanel_rc.h" #include "functionListPanel_rc.h"
#include "functionParser.h" #include "functionParser.h"
#include "TreeView.h"
class ScintillaEditView; class ScintillaEditView;
@ -82,7 +83,7 @@ public:
// functionalities // functionalities
void reload(); void reload();
void addEntry(const TCHAR *displayText, size_t pos); void addEntry(const TCHAR *node, const TCHAR *displayText, size_t pos);
void removeAllEntries(); void removeAllEntries();
void removeEntry(); void removeEntry();
void modifyEntry(); void modifyEntry();
@ -99,11 +100,13 @@ protected:
virtual BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
private: private:
TreeView _treeView;
ScintillaEditView **_ppEditView; ScintillaEditView **_ppEditView;
FunctionParsersManager _funcParserMgr; FunctionParsersManager _funcParserMgr;
std::vector<FuncInfo> _funcInfos; std::vector<FuncInfo> _funcInfos;
std::vector< std::pair<int, int> > _skipZones; std::vector< std::pair<int, int> > _skipZones;
generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos); generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos);
size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol); size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol);
void notified(LPNMHDR notification);
}; };
#endif // FUNCLISTPANEL_H #endif // FUNCLISTPANEL_H

View File

@ -35,5 +35,5 @@ EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
CAPTION "Function List" CAPTION "Function List"
FONT 8, "MS Sans Serif", 0, 0, 0x0 FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN BEGIN
LISTBOX IDC_LIST_FUNCLIST,50,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP //LISTBOX IDC_LIST_FUNCLIST,50,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
END END

View File

@ -145,6 +145,31 @@ void TreeView::dupTree(HTREEITEM hTree2Dup, HTREEITEM hParentItem)
} }
} }
HTREEITEM TreeView::searchSubItemByName(const TCHAR *itemName, HTREEITEM hParentItem)
{
HTREEITEM hItem = NULL;
if (hParentItem != NULL)
hItem = getChildFrom(hParentItem);
else
hItem = getRoot();
for ( ; hItem != NULL; hItem = getNextSibling(hItem))
{
TCHAR textBuffer[MAX_PATH];
TVITEM tvItem;
tvItem.hItem = hItem;
tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH;
tvItem.mask = TVIF_TEXT;
SendMessage(_hSelf, TVM_GETITEM, 0,(LPARAM)&tvItem);
if (lstrcmp(itemName, tvItem.pszText) == 0)
{
return hItem;
}
}
return NULL;
}
void TreeView::cleanSubEntries(HTREEITEM hTreeItem) void TreeView::cleanSubEntries(HTREEITEM hTreeItem)
{ {

View File

@ -39,6 +39,7 @@ public:
virtual void init(HINSTANCE hInst, HWND parent, int treeViewID); virtual void init(HINSTANCE hInst, HWND parent, int treeViewID);
virtual void destroy(); virtual void destroy();
HTREEITEM addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iImage, const TCHAR *filePath = NULL); HTREEITEM addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iImage, const TCHAR *filePath = NULL);
HTREEITEM searchSubItemByName(const TCHAR *itemName, HTREEITEM hParentItem);
void removeItem(HTREEITEM hTreeItem); void removeItem(HTREEITEM hTreeItem);
void removeAllItems(); void removeAllItems();

View File

@ -40,7 +40,7 @@
<nameExpr expr="(?!(if|whil|for))[\w_]+"/> <nameExpr expr="(?!(if|whil|for))[\w_]+"/>
</functionName> </functionName>
<className> <className>
<nameExpr expr="[\\w_]+(?=[\\s]*::)"/> <nameExpr expr="[\w_]+(?=[\s]*::)"/>
</className> </className>
</function> </function>
</parser> </parser>