From 5a73acd944a2dc3ffb621db208276aa45a850663 Mon Sep 17 00:00:00 2001 From: George Prekas Date: Wed, 16 May 2012 20:25:55 +0300 Subject: [PATCH] Snap open implementation. --- projects/2010/Explorer.vcxproj | 8 +- src/Explorer.cpp | 31 +++-- src/Explorer.h | 1 + src/ExplorerDialog.cpp | 16 +++ src/ExplorerDialog.h | 6 + src/ExplorerDialog.rc | 19 +++ src/ExplorerResource.h | 3 + src/MISC/ContextMenu.cpp | 14 +- src/MISC/ContextMenu.h | 2 + src/SnapOpenDlg/PatternMatch.cpp | 36 +++++ src/SnapOpenDlg/PatternMatch.h | 8 ++ src/SnapOpenDlg/SnapOpenDialog.cpp | 216 +++++++++++++++++++++++++++++ src/SnapOpenDlg/SnapOpenDialog.h | 68 +++++++++ 13 files changed, 417 insertions(+), 11 deletions(-) create mode 100644 src/SnapOpenDlg/PatternMatch.cpp create mode 100644 src/SnapOpenDlg/PatternMatch.h create mode 100644 src/SnapOpenDlg/SnapOpenDialog.cpp create mode 100644 src/SnapOpenDlg/SnapOpenDialog.h diff --git a/projects/2010/Explorer.vcxproj b/projects/2010/Explorer.vcxproj index 9027e2f..0e5e054 100755 --- a/projects/2010/Explorer.vcxproj +++ b/projects/2010/Explorer.vcxproj @@ -54,7 +54,7 @@ Disabled - ..\..\externals;..\..\..\Common\Ccpp;..\..\src\NewDlg\;..\..\src\PropDlg\;..\..\src\Toolbar\;..\..\src\FileDlg\;..\..\src\FileList\;.;..\..\src\;..\..\src\MISC\;..\..\src\HelpDlg\;..\..\src\OptionDlg\;..\..\src\PureDnD\;..\..\..\NativeLang\src;%(AdditionalIncludeDirectories) + ..\..\externals;..\..\..\Common\Ccpp;..\..\src\SnapOpenDlg\;..\..\src\NewDlg\;..\..\src\PropDlg\;..\..\src\Toolbar\;..\..\src\FileDlg\;..\..\src\FileList\;.;..\..\src\;..\..\src\MISC\;..\..\src\HelpDlg\;..\..\src\OptionDlg\;..\..\src\PureDnD\;..\..\..\NativeLang\src;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;EXPLORER_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -97,7 +97,7 @@ Full OnlyExplicitInline Size - ..\..\externals;..\..\..\Common\Ccpp;..\..\src\NewDlg\;..\..\src\PropDlg\;..\..\src\FileDlg\;..\..\src\FileList\;.;..\..\src\;..\..\src\MISC\;..\..\src\HelpDlg\;..\..\src\OptionDlg\;..\..\src\PureDnD\;..\..\..\NativeLang\src;%(AdditionalIncludeDirectories) + ..\..\externals;..\..\..\Common\Ccpp;..\..\src\SnapOpenDlg\;..\..\src\NewDlg\;..\..\src\PropDlg\;..\..\src\FileDlg\;..\..\src\FileList\;.;..\..\src\;..\..\src\MISC\;..\..\src\HelpDlg\;..\..\src\OptionDlg\;..\..\src\PureDnD\;..\..\..\NativeLang\src;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_USRDLL;EXPLORER_EXPORTS;%(PreprocessorDefinitions) true MultiThreaded @@ -135,6 +135,8 @@ + + @@ -163,6 +165,8 @@ + + diff --git a/src/Explorer.cpp b/src/Explorer.cpp index 1da221c..127a8da 100644 --- a/src/Explorer.cpp +++ b/src/Explorer.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ExplorerDialog.h" #include "FavesDialog.h" #include "OptionDialog.h" +#include "SnapOpenDialog.h" #include "HelpDialog.h" #include "ToolTip.h" #include "SysMsg.h" @@ -38,7 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define SHGFI_OVERLAYINDEX 0x000000040 -CONST INT nbFunc = 9; +CONST INT nbFunc = 10; @@ -96,6 +97,7 @@ ExplorerDialog explorerDlg; FavesDialog favesDlg; OptionDlg optionDlg; HelpDlg helpDlg; +SnapOpenDlg snapOpenDlg; /* global explorer params */ tExProp exProp; @@ -140,18 +142,20 @@ BOOL APIENTRY DllMain( HANDLE hModule, funcItem[2]._pFunc = NULL; funcItem[3]._pFunc = gotoPath; funcItem[4]._pFunc = clearFilter; - funcItem[5]._pFunc = NULL; - funcItem[6]._pFunc = openOptionDlg; - funcItem[7]._pFunc = NULL; - funcItem[8]._pFunc = openHelpDlg; + funcItem[5]._pFunc = openSnapOpenDlg; + funcItem[6]._pFunc = NULL; + funcItem[7]._pFunc = openOptionDlg; + funcItem[8]._pFunc = NULL; + funcItem[9]._pFunc = openHelpDlg; /* Fill menu names */ _tcscpy(funcItem[0]._itemName, _T("&Explorer...")); _tcscpy(funcItem[1]._itemName, _T("&Favorites...")); _tcscpy(funcItem[3]._itemName, _T("&Go to Path...")); _tcscpy(funcItem[4]._itemName, _T("&Clear Filter")); - _tcscpy(funcItem[6]._itemName, _T("Explorer &Options...")); - _tcscpy(funcItem[8]._itemName, _T("&Help...")); + _tcscpy(funcItem[5]._itemName, _T("&Snap Open...")); + _tcscpy(funcItem[7]._itemName, _T("Explorer &Options...")); + _tcscpy(funcItem[9]._itemName, _T("&Help...")); /* Set shortcuts */ funcItem[0]._pShKey = new ShortcutKey; @@ -167,10 +171,15 @@ BOOL APIENTRY DllMain( HANDLE hModule, funcItem[2]._pShKey = NULL; funcItem[3]._pShKey = NULL; funcItem[4]._pShKey = NULL; - funcItem[5]._pShKey = NULL; + funcItem[5]._pShKey = new ShortcutKey; + funcItem[5]._pShKey->_isAlt = true; + funcItem[5]._pShKey->_isCtrl = true; + funcItem[5]._pShKey->_isShift = false; + funcItem[5]._pShKey->_key = 'O'; funcItem[6]._pShKey = NULL; funcItem[7]._pShKey = NULL; funcItem[8]._pShKey = NULL; + funcItem[9]._pShKey = NULL; /* set image list and icon */ ghImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 6, 30); @@ -239,6 +248,7 @@ extern "C" __declspec(dllexport) void setInfo(NppData notpadPlusData) explorerDlg.init((HINSTANCE)g_hModule, nppData, &exProp); favesDlg.init((HINSTANCE)g_hModule, nppData, szLastElement, &exProp); optionDlg.init((HINSTANCE)g_hModule, nppData); + snapOpenDlg.init((HINSTANCE)g_hModule, nppData); helpDlg.init((HINSTANCE)g_hModule, nppData); /* Subclassing for Notepad */ @@ -517,6 +527,11 @@ void openHelpDlg(void) helpDlg.doDialog(); } +void openSnapOpenDlg(void) +{ + snapOpenDlg.doDialog(); +} + /************************************************************************** * Subclass of Notepad diff --git a/src/Explorer.h b/src/Explorer.h index 9fd7965..4d4a0b5 100644 --- a/src/Explorer.h +++ b/src/Explorer.h @@ -275,6 +275,7 @@ void gotoPath(void); void clearFilter(void); void openOptionDlg(void); void openHelpDlg(void); +void openSnapOpenDlg(void); LRESULT CALLBACK SubWndProcNotepad(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/src/ExplorerDialog.cpp b/src/ExplorerDialog.cpp index 893d2ef..f80c3bd 100644 --- a/src/ExplorerDialog.cpp +++ b/src/ExplorerDialog.cpp @@ -2017,3 +2017,19 @@ bool ExplorerDialog::doPaste(LPCTSTR pszTo, LPDROPFILES hData, const DWORD & dwE return true; } +string ExplorerDialog::GetSelectedPath() +{ + TCHAR pszPath[MAX_PATH]; + GetFolderPathName(TreeView_GetSelection(_hTreeCtrl), pszPath); + return pszPath; +} + +string ExplorerDialog::GetRootPath() +{ + return rootPath; +} + +void ExplorerDialog::SetRootPath(const string rootPath) +{ + this->rootPath = rootPath; +} diff --git a/src/ExplorerDialog.h b/src/ExplorerDialog.h index 9c2e1eb..b2923b1 100644 --- a/src/ExplorerDialog.h +++ b/src/ExplorerDialog.h @@ -95,6 +95,10 @@ class ExplorerDialog : public DockingDlgInterface, public TreeHelper, public CID public: virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect); + string GetSelectedPath(); + string GetRootPath(); + void SetRootPath(const string rootPath); + protected: /* Subclassing tree */ @@ -179,6 +183,8 @@ class ExplorerDialog : public DockingDlgInterface, public TreeHelper, public CID /* drag and drop values */ BOOL _isScrolling; BOOL _isDnDStarted; + + string rootPath; }; diff --git a/src/ExplorerDialog.rc b/src/ExplorerDialog.rc index aa6bd2a..59242f5 100644 --- a/src/ExplorerDialog.rc +++ b/src/ExplorerDialog.rc @@ -159,6 +159,17 @@ BEGIN PUSHBUTTON "Create Example",IDC_BTN_EXAMPLE_FILE,203,112,69,12 END +IDD_QUICK_OPEN_DLG DIALOGEX 0, 0, 347, 154 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Snap Open" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + DEFPUSHBUTTON "&Ok",IDOK,289,10,51,14 + PUSHBUTTON "&Cancel",IDCANCEL,289,29,51,14 + EDITTEXT IDC_EDIT_SEARCH,7,7,273,14,ES_AUTOHSCROLL + LISTBOX IDC_LIST_RESULTS,7,28,273,119,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP +END + #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -235,6 +246,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 147 END + + IDD_QUICK_OPEN_DLG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 340 + TOPMARGIN, 7 + BOTTOMMARGIN, 147 + END END #endif // APSTUDIO_INVOKED diff --git a/src/ExplorerResource.h b/src/ExplorerResource.h index b211261..051eb46 100644 --- a/src/ExplorerResource.h +++ b/src/ExplorerResource.h @@ -141,6 +141,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define IDC_STATIC_HELP (IDD_HELP_DLG + 12) #define IDC_STATIC_VERSION (IDD_HELP_DLG + 13) +#define IDD_QUICK_OPEN_DLG 30750 + #define IDC_EDIT_SEARCH (IDD_QUICK_OPEN_DLG + 1) + #define IDC_LIST_RESULTS (IDD_QUICK_OPEN_DLG + 2) /* Explorer messages */ diff --git a/src/MISC/ContextMenu.cpp b/src/MISC/ContextMenu.cpp index d003537..576a114 100644 --- a/src/MISC/ContextMenu.cpp +++ b/src/MISC/ContextMenu.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "FavesDialog.h" #include "ContextMenu.h" #include "nppexec_msgs.h" - +#include "ExplorerDialog.h" IContextMenu2 * g_IContext2 = NULL; @@ -206,6 +206,7 @@ UINT ContextMenu::ShowContextMenu(HINSTANCE hInst, HWND hWndNpp, HWND hWndParent ::AppendMenu(hMainMenu, MF_STRING, CTX_NEW_FILE, _T("New File...")); ::AppendMenu(hMainMenu, MF_STRING, CTX_NEW_FOLDER, _T("New Folder...")); ::AppendMenu(hMainMenu, MF_STRING, CTX_FIND_IN_FILES, _T("Find in Files...")); + ::AppendMenu(hMainMenu, MF_STRING, CTX_SET_AS_ROOT, _T("Set as Root")); } else { @@ -383,6 +384,11 @@ UINT ContextMenu::ShowContextMenu(HINSTANCE hInst, HWND hWndNpp, HWND hWndParent findInFiles(); break; } + case CTX_SET_AS_ROOT: + { + setAsRoot(); + break; + } case CTX_OPEN: { openFile(); @@ -794,6 +800,12 @@ void ContextMenu::findInFiles(void) ::SendMessage(_hWndNpp, NPPM_LAUNCHFINDINFILESDLG, (WPARAM)_strFirstElement.c_str(), NULL); } +void ContextMenu::setAsRoot(void) +{ + extern ExplorerDialog explorerDlg; + explorerDlg.SetRootPath(_strFirstElement); +} + void ContextMenu::openFile(void) { for (UINT i = 0; i < _strArray.size(); i++) diff --git a/src/MISC/ContextMenu.h b/src/MISC/ContextMenu.h index e167b96..82a4b04 100644 --- a/src/MISC/ContextMenu.h +++ b/src/MISC/ContextMenu.h @@ -69,6 +69,7 @@ typedef enum CTX_NEW_FILE = CTX_MAX, CTX_NEW_FOLDER, CTX_FIND_IN_FILES, + CTX_SET_AS_ROOT, CTX_OPEN, CTX_OPEN_DIFF_VIEW, CTX_OPEN_NEW_INST, @@ -111,6 +112,7 @@ class ContextMenu void newFile(void); void newFolder(void); void findInFiles(void); + void setAsRoot(void); void openFile(void); void openFileInOtherView(void); void openFileInNewInstance(void); diff --git a/src/SnapOpenDlg/PatternMatch.cpp b/src/SnapOpenDlg/PatternMatch.cpp new file mode 100644 index 0000000..eb9392a --- /dev/null +++ b/src/SnapOpenDlg/PatternMatch.cpp @@ -0,0 +1,36 @@ +#include "PatternMatch.h" +#include + +BOOL patternMatch(LPCTSTR text, LPCTSTR pattern) +{ + LPCTSTR nextPattern, match; + TCHAR subPattern[MAX_PATH]; + + while (TRUE) + { + while (*pattern == ' ') + { + pattern++; + } + if (*pattern == 0) + { + return TRUE; + } + nextPattern = _tcschr(pattern, ' '); + if (!nextPattern) + { + nextPattern = pattern + _tcslen(pattern); + } + _tcsncpy(subPattern, pattern, nextPattern - pattern); + subPattern[nextPattern - pattern] = 0; + match = _tcsstr(text, subPattern); + if (!match) + { + return FALSE; + } + text = match + (nextPattern - pattern); + pattern = nextPattern; + } + + return TRUE; +} diff --git a/src/SnapOpenDlg/PatternMatch.h b/src/SnapOpenDlg/PatternMatch.h new file mode 100644 index 0000000..65920be --- /dev/null +++ b/src/SnapOpenDlg/PatternMatch.h @@ -0,0 +1,8 @@ +#ifndef PATTERN_MATCH_H +#define PATTERN_MATCH_H + +#include + +BOOL patternMatch(LPCTSTR text, LPCTSTR pattern); + +#endif // PATTERN_MATCH_H diff --git a/src/SnapOpenDlg/SnapOpenDialog.cpp b/src/SnapOpenDlg/SnapOpenDialog.cpp new file mode 100644 index 0000000..caaa581 --- /dev/null +++ b/src/SnapOpenDlg/SnapOpenDialog.cpp @@ -0,0 +1,216 @@ +/* +This file is part of Explorer Plugin for Notepad++ +Copyright (C)2006 Jens Lorenz + +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. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + +#include "SnapOpenDialog.h" +#include "Explorer.h" +#include "PatternMatch.h" +#include +#include +#include + + +// Set a call back with the handle after init to set the path. +// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp +static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData) +{ + if (uMsg == BFFM_INITIALIZED) + ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData); + return 0; +}; + + +UINT SnapOpenDlg::doDialog() +{ + return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_QUICK_OPEN_DLG), _hParent, (DLGPROC)dlgProc, (LPARAM)this); +} + + +BOOL CALLBACK SnapOpenDlg::run_dlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) +{ + switch (Message) + { + case WM_INITDIALOG: + { + string rootPath = getRoot(); + rootPathLen = rootPath.size(); + + goToCenter(); + findFiles(); + populateResultList(); + ::PostMessage(_hSelf, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(_hSelf, IDC_EDIT_SEARCH), TRUE); + + // Subclass the edit control. + SetWindowLong(GetDlgItem(_hSelf, IDC_EDIT_SEARCH), GWL_USERDATA, (LONG) this); + wpOrigEditProc = (WNDPROC) SetWindowLong(GetDlgItem(_hSelf, IDC_EDIT_SEARCH), GWL_WNDPROC, (LONG) editSubclassProc); + + string title = _T("Snap Open - ") + rootPath; + SetWindowText(_hSelf, title.c_str()); + + break; + } + case WM_DESTROY: + // Remove the subclass from the edit control. + SetWindowLong(GetDlgItem(_hSelf, IDC_EDIT_SEARCH), GWL_WNDPROC, (LONG) wpOrigEditProc); + break; + case WM_COMMAND : + { + switch (LOWORD(wParam)) + { + case IDC_EDIT_SEARCH: + if (HIWORD(wParam) == EN_CHANGE) + { + populateResultList(); + } + break; + case IDCANCEL: + ::EndDialog(_hSelf, IDCANCEL); + return TRUE; + case IDC_LIST_RESULTS: + if (HIWORD(wParam) != LBN_DBLCLK) + { + break; + } + case IDOK: + { + int selection; + string fullPath = getRoot(); + TCHAR pszFilePath[MAX_PATH]; + pszFilePath[0] = 0; + selection = ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_GETCURSEL, 0, 0); + if (selection != LB_ERR) + { + ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_GETTEXT, selection, (LPARAM)&pszFilePath); + } + ::EndDialog(_hSelf, IDOK); + if (pszFilePath[0]) + { + fullPath += pszFilePath; + ::SendMessage(_nppData._nppHandle, NPPM_DOOPEN, 0, (LPARAM)fullPath.c_str()); + } + return TRUE; + } + default: + return FALSE; + } + break; + } + default: + break; + } + return FALSE; +} + +string SnapOpenDlg::getRoot() +{ + extern ExplorerDialog explorerDlg; + string path = explorerDlg.GetRootPath(); + if (path.empty()) + { + path = explorerDlg.GetSelectedPath(); + } + return path; +} + +void SnapOpenDlg::findFiles() +{ + files.clear(); + findFilesRecursively(getRoot().c_str()); +} + +void SnapOpenDlg::findFilesRecursively(LPCTSTR lpFolder) +{ + TCHAR szFullPattern[MAX_PATH]; + WIN32_FIND_DATA FindFileData; + HANDLE hFindFile; + // first we are going to process any subdirectories + PathCombine(szFullPattern, lpFolder, _T("*")); + hFindFile = FindFirstFile(szFullPattern, &FindFileData); + if(hFindFile != INVALID_HANDLE_VALUE) + { + do + { + if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + if (_tcscmp(FindFileData.cFileName, _T(".")) && _tcscmp(FindFileData.cFileName, _T(".."))) + { + // found a subdirectory; recurse into it + PathCombine(szFullPattern, lpFolder, FindFileData.cFileName); + findFilesRecursively(szFullPattern); + } + } + else + { + PathCombine(szFullPattern, lpFolder, FindFileData.cFileName); + files.push_back(&szFullPattern[rootPathLen]); + } + } while(FindNextFile(hFindFile, &FindFileData)); + FindClose(hFindFile); + } +} + +void SnapOpenDlg::populateResultList() +{ + TCHAR pattern[MAX_PATH]; + Edit_GetText(GetDlgItem(_hSelf, IDC_EDIT_SEARCH), pattern, _countof(pattern)); + ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_RESETCONTENT, 0, 0); + int count = 0; + for (vector::const_iterator i=files.begin();i!=files.end();++i) + { + if (count >= 100) + { + ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_ADDSTRING, 0, (LPARAM)_T("-- Too many results --")); + break; + } + if (patternMatch(i->c_str(), pattern)) + { + count++; + ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_ADDSTRING, 0, (LPARAM)(*i).c_str()); + } + } + ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_SETCURSEL, 0, 0); +} + +LRESULT APIENTRY SnapOpenDlg::editSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + SnapOpenDlg *dlg = (SnapOpenDlg *)(GetWindowLong(hwnd, GWL_USERDATA)); + return dlg->run_editSubclassProc(hwnd, uMsg, wParam, lParam); +} + +LRESULT APIENTRY SnapOpenDlg::run_editSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + if (uMsg == WM_KEYDOWN) + { + int selection = ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_GETCURSEL, 0, 0); + int results = ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_GETCOUNT, 0, 0); + + if (wParam == VK_UP && selection > 0) + { + ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_SETCURSEL, selection-1, 0); + return 0; + } + if (wParam == VK_DOWN && selection < results - 1) + { + ::SendDlgItemMessage(_hSelf, IDC_LIST_RESULTS, LB_SETCURSEL, selection+1, 0); + return 0; + } + } + + return ::CallWindowProc(wpOrigEditProc, hwnd, uMsg, wParam, lParam); +} \ No newline at end of file diff --git a/src/SnapOpenDlg/SnapOpenDialog.h b/src/SnapOpenDlg/SnapOpenDialog.h new file mode 100644 index 0000000..2ed0b3e --- /dev/null +++ b/src/SnapOpenDlg/SnapOpenDialog.h @@ -0,0 +1,68 @@ +/* +This file is part of Explorer Plugin for Notepad++ +Copyright (C)2006 Jens Lorenz + +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. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + +#ifndef SNAP_OPEN_DIALOG_H +#define SNAP_OPEN_DIALOG_H + +#include "StaticDialog.h" +#include "Explorer.h" +#include "ExplorerResource.h" + + + +class SnapOpenDlg : public StaticDialog +{ + +public: + SnapOpenDlg() : StaticDialog() {}; + + void init(HINSTANCE hInst, NppData nppData) + { + _nppData = nppData; + Window::init(hInst, nppData._nppHandle); + }; + + UINT doDialog(); + + virtual void destroy() {}; + + +protected : + BOOL CALLBACK run_dlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); + +private: + /* Handles */ + NppData _nppData; + HWND _HSource; + vector files; + WNDPROC wpOrigEditProc; + int rootPathLen; + + void findFiles(); + void findFilesRecursively(LPCTSTR lpFolder); + void populateResultList(); + static LRESULT APIENTRY editSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + LRESULT APIENTRY run_editSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + wstring getRoot(); +}; + + + +#endif // SNAP_OPEN_DIALOG_H