Skip to content

Commit

Permalink
Snap open implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
prekageo committed May 16, 2012
1 parent d04b50e commit 5a73acd
Show file tree
Hide file tree
Showing 13 changed files with 417 additions and 11 deletions.
8 changes: 6 additions & 2 deletions projects/2010/Explorer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\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)</AdditionalIncludeDirectories>
<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)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;EXPLORER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
Expand Down Expand Up @@ -97,7 +97,7 @@
<Optimization>Full</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>..\..\externals;..\..\..\Common\Ccpp;..\..\src\NewDlg\;..\..\src\PropDlg\;..\..\src\FileDlg\;..\..\src\FileList\;.;..\..\src\;..\..\src\MISC\;..\..\src\HelpDlg\;..\..\src\OptionDlg\;..\..\src\PureDnD\;..\..\..\NativeLang\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<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)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;EXPLORER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
Expand Down Expand Up @@ -135,6 +135,8 @@
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\SnapOpenDlg\SnapOpenDialog.cpp" />
<ClCompile Include="..\..\src\SnapOpenDlg\PatternMatch.cpp" />
<ClCompile Include="..\..\src\FileList\ComboOrgi.cpp" />
<ClCompile Include="..\..\src\MISC\ContextMenu.cpp" />
<ClCompile Include="..\..\src\PureDnD\DragDropImpl.cpp" />
Expand Down Expand Up @@ -163,6 +165,8 @@
<ResourceCompile Include="..\..\src\ExplorerDialog.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\SnapOpenDlg\SnapOpenDialog.h" />
<ClInclude Include="..\..\src\SnapOpenDlg\PatternMatch.h" />
<ClInclude Include="..\..\src\FileList\ComboOrgi.h" />
<ClInclude Include="..\..\src\MISC\ContextMenu.h" />
<ClInclude Include="..\..\src\PureDnD\DragDropImpl.h" />
Expand Down
31 changes: 23 additions & 8 deletions src/Explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;



Expand Down Expand Up @@ -96,6 +97,7 @@ ExplorerDialog explorerDlg;
FavesDialog favesDlg;
OptionDlg optionDlg;
HelpDlg helpDlg;
SnapOpenDlg snapOpenDlg;

/* global explorer params */
tExProp exProp;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -517,6 +527,11 @@ void openHelpDlg(void)
helpDlg.doDialog();
}

void openSnapOpenDlg(void)
{
snapOpenDlg.doDialog();
}


/**************************************************************************
* Subclass of Notepad
Expand Down
1 change: 1 addition & 0 deletions src/Explorer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 16 additions & 0 deletions src/ExplorerDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
6 changes: 6 additions & 0 deletions src/ExplorerDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -179,6 +183,8 @@ class ExplorerDialog : public DockingDlgInterface, public TreeHelper, public CID
/* drag and drop values */
BOOL _isScrolling;
BOOL _isDnDStarted;

string rootPath;
};


Expand Down
19 changes: 19 additions & 0 deletions src/ExplorerDialog.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/ExplorerResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
14 changes: 13 additions & 1 deletion src/MISC/ContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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++)
Expand Down
2 changes: 2 additions & 0 deletions src/MISC/ContextMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
36 changes: 36 additions & 0 deletions src/SnapOpenDlg/PatternMatch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "PatternMatch.h"
#include <tchar.h>

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;
}
8 changes: 8 additions & 0 deletions src/SnapOpenDlg/PatternMatch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef PATTERN_MATCH_H
#define PATTERN_MATCH_H

#include <windows.h>

BOOL patternMatch(LPCTSTR text, LPCTSTR pattern);

#endif // PATTERN_MATCH_H
Loading

0 comments on commit 5a73acd

Please sign in to comment.