Skip to content

Commit f0b1ab7

Browse files
committed
CollectionInterface: update NppMetaClass and global instance to require plugin name at instantiation
1 parent f57ea9b commit f0b1ab7

File tree

4 files changed

+32
-38
lines changed

4 files changed

+32
-38
lines changed

src/Classes/NppMetaClass.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include "NppMetaClass.h"
22
#include <pathcch.h>
33
#include <shlwapi.h>
4+
#include "Version.h"
45

5-
// Global NppMetaInfo object
6-
NppMetaInfo gNppMetaInfo;
7-
8-
NppMetaInfo::NppMetaInfo(void)
9-
: hwnd(nppData)
6+
NppMetaInfo::NppMetaInfo(std::wstring wsPluginName)
7+
: hwnd(nppData), _wsPluginName(wsPluginName)
108
{
119
_isInitialized = false;
1210
dir = { L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"" };
@@ -49,7 +47,7 @@ void NppMetaInfo::populate(void)
4947
::SendMessage(hwnd._nppHandle, NPPM_GETPLUGINSCONFIGDIR, sz, reinterpret_cast<LPARAM>(pluginCfgDir.data()));
5048
pcjHelper::delNull(pluginCfgDir);
5149
dir.cfgPluginConfig = pluginCfgDir;
52-
dir.cfgPluginConfigMyDir = pluginCfgDir + L"\\ConfigUpdater";
50+
dir.cfgPluginConfigMyDir = pluginCfgDir + L"\\" + _wsPluginName;
5351

5452
// %AppData%\Notepad++\Plugins or equiv
5553
// since it's removing the tail, it will never be longer than pluginCfgDir; since it's in-place, initialize with the first

src/Classes/NppMetaClass.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class NppMetaInfo {
88
public:
99
// constructor
10-
NppMetaInfo(void);
10+
NppMetaInfo(std::wstring wsPluginName);
1111

1212
// Run this in the constructor for any class that uses it
1313
// (internally tracks whether it's been populated already, and doesn't duplicate effort)
@@ -17,17 +17,17 @@ class NppMetaInfo {
1717

1818
struct {
1919
std::wstring
20-
app,
21-
appDataEquiv,
22-
appThemes,
23-
appExePath,
24-
cfg,
25-
cfgPluginConfig,
26-
cfgPluginConfigMyDir,
27-
cfgUdl,
28-
cfgFunctionList,
29-
cfgAutoCompletion,
30-
cfgThemes;
20+
app, // directory where the executable is found
21+
appDataEquiv, // %AppData% or .app, ignoring Cloud or -settingsDir
22+
appThemes, // .app\Themes\ subfolder (alternate themes always under .app\ directory)
23+
appExePath, // .app\notepad++.exe == "path\to\notepad++.exe" (includes .exe file)
24+
cfg, // SettingsDir >> CloudDir >> AppData(equiv)
25+
cfgPluginConfig, // .appDataEquiv\plugins\Config
26+
cfgPluginConfigMyDir, // .appDataEquiv\plugins\Config\wsPluginName
27+
cfgUdl, // .cfg\userDefinedLangs\ subdir (SettingsDir >> Cloud Dir >> Portable >> AppData(equiv))
28+
cfgFunctionList, // .appDataEquiv\functionList\ subdir (skip Cloud or -settingsDir)
29+
cfgAutoCompletion, // .app\autoCompletion\ subdir
30+
cfgThemes; // .cfg\Themes\ subfoloder (SettingsDir >> Cloud Dir >> Portable >> AppData(equiv))
3131
} dir;
3232

3333
////////////////////////////////
@@ -53,6 +53,7 @@ class NppMetaInfo {
5353
private:
5454
bool _isInitialized;
5555
std::wstring _askSettingsDir(void);
56+
std::wstring _wsPluginName;
5657
};
5758

5859
// make sure everyone who can see this class can see the global instance

src/PluginDefinition.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
#include "PluginDefinition.h"
2121
#include "menuCmdID.h"
2222
#include "resource.h"
23+
#include "Version.h"
2324
#include "AboutDialog.h"
2425
#include "CollectionInterfaceDialog.h"
26+
#include "NppMetaClass.h"
27+
#include "OverrideMapUpdaterClass.h"
2528

2629
static HANDLE _hModule;
2730

@@ -35,6 +38,11 @@ FuncItem funcItem[nbFunc];
3538
//
3639
NppData nppData;
3740

41+
//
42+
// Instantiate global NppMetaInfo object, passing in name of plugin
43+
//
44+
NppMetaInfo gNppMetaInfo(VERSION_NAME_WS);
45+
3846
//
3947
// Initialize your plugin data here
4048
// It will be called while plugin loading
@@ -67,12 +75,10 @@ void commandMenuInit()
6775
// bool check0nInit // optional. Make this menu item be checked visually
6876
// );
6977
setCommand(0, TEXT("Collection Interface: Download"), showCollectionInterface, NULL, false);
70-
setCommand(1, TEXT("Help: Download"), showCIDownloadHelp, NULL, false);
71-
setCommand(2, TEXT(""), NULL, NULL, false);
72-
//setCommand(3, TEXT("About (NonModal)"), showAbout, NULL, false);
73-
setCommand(3, TEXT("About"), showAboutModal, NULL, false);
74-
//setCommand(5, TEXT("Hello Notepad++"), hello, NULL, false);
75-
//setCommand(6, TEXT("Hello (with dialog)"), helloDlg, NULL, false);
78+
setCommand(1, TEXT("Collection Interface:: Experiment"), hello, NULL, false);
79+
setCommand(2, TEXT("Help: Download"), showCIDownloadHelp, NULL, false);
80+
setCommand(3, TEXT(""), NULL, NULL, false);
81+
setCommand(4, TEXT("About"), showAboutModal, NULL, false);
7682
}
7783

7884
//
@@ -108,19 +114,8 @@ bool setCommand(size_t index, TCHAR *cmdName, PFUNCPLUGINCMD pFunc, ShortcutKey
108114
//----------------------------------------------//
109115
void hello()
110116
{
111-
// Open a new document
112-
::SendMessage(nppData._nppHandle, NPPM_MENUCOMMAND, 0, IDM_FILE_NEW);
113-
114-
// Get the current scintilla
115-
int which = -1;
116-
::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&which);
117-
if (which == -1)
118-
return;
119-
HWND curScintilla = (which == 0)?nppData._scintillaMainHandle:nppData._scintillaSecondHandle;
120-
121-
// Say hello now :
122-
// Scintilla control has no Unicode mode, so we use (char *) here
123-
::SendMessage(curScintilla, SCI_SETTEXT, 0, (LPARAM)"Hello, Notepad++!");
117+
OverrideMapUpdater overMapUpdater;
118+
overMapUpdater.experiment();
124119
}
125120

126121
void helloDlg()

src/PluginDefinition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const TCHAR NPP_PLUGIN_NAME[] = TEXT("CollectionInterface");
3838
//
3939
// Here define the number of your plugin commands
4040
//
41-
const int nbFunc = 4;
41+
const int nbFunc = 5;
4242

4343

4444
//

0 commit comments

Comments
 (0)