Skip to content

Commit 1939e89

Browse files
authored
Merge branch 'master' into src_MakeResourceAlignedWithVS
2 parents fb1fb58 + 2d18457 commit 1939e89

File tree

10 files changed

+192
-177
lines changed

10 files changed

+192
-177
lines changed

NppJSONViewer/DockingDlgInterface.h

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ along with this program; if not, write to the Free Software
1717
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1818
*/
1919

20-
#ifndef DOCKINGDLGINTERFACE_H
21-
#define DOCKINGDLGINTERFACE_H
20+
#pragma once
2221

2322
#include "StaticDialog.h"
2423
#include "dockingResource.h"
@@ -29,95 +28,93 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2928
class DockingDlgInterface : public StaticDialog
3029
{
3130
public:
32-
DockingDlgInterface(): StaticDialog() {};
33-
DockingDlgInterface(int dlgID): StaticDialog(), _dlgID(dlgID) {};
34-
31+
DockingDlgInterface() : StaticDialog() {};
32+
DockingDlgInterface(int dlgID) : StaticDialog(), _dlgID(dlgID) {};
33+
3534
virtual void init(HINSTANCE hInst, HWND parent)
3635
{
3736
StaticDialog::init(hInst, parent);
3837
::GetModuleFileName((HMODULE)hInst, _moduleName, MAX_PATH);
3938
lstrcpy(_moduleName, PathFindFileName(_moduleName));
4039
}
4140

42-
void create(tTbData * data, bool isRTL = false){
41+
void create(tTbData * data, bool isRTL = false)
42+
{
4343
StaticDialog::create(_dlgID, isRTL);
4444
::GetWindowText(_hSelf, _pluginName, sizeof(_pluginName));
4545

46-
// user information
47-
data->hClient = _hSelf;
48-
data->pszName = _pluginName;
46+
// user information
47+
data->hClient = _hSelf;
48+
data->pszName = _pluginName;
4949

5050
// supported features by plugin
51-
data->uMask = 0;
51+
data->uMask = 0;
5252

5353
// additional info
54-
data->pszAddInfo = NULL;
54+
data->pszAddInfo = NULL;
5555
_data = data;
5656

57-
};
57+
}
5858

59-
virtual void updateDockingDlg(void) {
59+
virtual void updateDockingDlg(void)
60+
{
6061
::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, (LPARAM)_hSelf);
6162
}
6263

63-
virtual void destroy() {
64-
};
64+
virtual void destroy() {}
6565

66-
virtual void display(bool toShow = true) const {
67-
::SendMessage(_hParent, toShow?NPPM_DMMSHOW:NPPM_DMMHIDE, 0, (LPARAM)_hSelf);
68-
};
66+
virtual void display(bool toShow = true) const
67+
{
68+
::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, (LPARAM)_hSelf);
69+
}
6970

70-
const TCHAR * getPluginFileName() const {
71-
return _moduleName;
72-
};
71+
const TCHAR * getPluginFileName() const { return _moduleName; }
7372

74-
protected :
73+
protected:
7574
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM /*wParam*/, LPARAM lParam)
7675
{
77-
switch (message)
76+
switch (message)
7877
{
7978

80-
case WM_NOTIFY:
81-
{
82-
LPNMHDR pnmh = (LPNMHDR)lParam;
79+
case WM_NOTIFY:
80+
{
81+
LPNMHDR pnmh = (LPNMHDR)lParam;
8382

84-
if (pnmh->hwndFrom == _hParent)
83+
if (pnmh->hwndFrom == _hParent)
84+
{
85+
switch (LOWORD(pnmh->code))
86+
{
87+
case DMN_CLOSE:
88+
{
89+
break;
90+
}
91+
case DMN_FLOAT:
92+
{
93+
_isFloating = true;
94+
break;
95+
}
96+
case DMN_DOCK:
8597
{
86-
switch (LOWORD(pnmh->code))
87-
{
88-
case DMN_CLOSE:
89-
{
90-
break;
91-
}
92-
case DMN_FLOAT:
93-
{
94-
_isFloating = true;
95-
break;
96-
}
97-
case DMN_DOCK:
98-
{
99-
_isFloating = false;
100-
break;
101-
}
102-
default:
103-
break;
104-
}
98+
_isFloating = false;
99+
break;
100+
}
101+
default:
102+
break;
105103
}
106-
break;
107104
}
108-
default:
109-
break;
105+
break;
106+
}
107+
default:
108+
break;
110109
}
111110
return FALSE;
112111
};
113-
112+
114113
// Handles
115-
HWND _HSource;
116-
tTbData* _data;
117-
int _dlgID;
118-
bool _isFloating;
119-
TCHAR _moduleName[MAX_PATH];
120-
TCHAR _pluginName[MAX_PATH];
114+
HWND _HSource = nullptr;
115+
tTbData* _data = nullptr;
116+
int _dlgID = 0;
117+
bool _isFloating = false;
118+
TCHAR _moduleName[MAX_PATH] = {};
119+
TCHAR _pluginName[MAX_PATH] = {};
121120
};
122-
123-
#endif // DOCKINGDLGINTERFACE_H

NppJSONViewer/JSONDialog.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ HTREEITEM JSONDialog::insertToTree(HWND hWndDlg,HTREEITEM parent, const char *te
6161
tvinsert.hInsertAfter=TVI_LAST;
6262
tvinsert.item.mask=TVIF_TEXT;
6363

64-
int len = strlen(text) + 1;
64+
auto len = strlen(text) + 1;
6565
wchar_t *w_msg = new wchar_t[len];
6666
if (w_msg)
6767
{
6868
memset(w_msg, 0, len);
69-
MultiByteToWideChar(CP_UTF8, NULL, text, -1, w_msg, len);
69+
MultiByteToWideChar(CP_UTF8, NULL, text, -1, w_msg, static_cast<int>(len));
7070

7171
tvinsert.item.pszText = w_msg;
7272
item = (HTREEITEM)SendDlgItemMessage(hWndDlg, IDC_TREE, TVM_INSERTITEM, 0, (LPARAM)&tvinsert);
@@ -88,14 +88,16 @@ void JSONDialog::setJSON(char* json)
8888
drawTreeSaxParse();
8989
}
9090

91-
void JSONDialog::populateTreeUsingSax(HWND hWndDlg, HTREEITEM tree_root, char *json) {
91+
void JSONDialog::populateTreeUsingSax(HWND /*hWndDlg*/, HTREEITEM tree_root, char *json)
92+
{
9293
//Stopwatch sw;
9394
//sw.Start();
9495
TreeBuilder handler(this, tree_root);
9596
rapidjson::Reader reader;
9697

9798
rapidjson::StringStream ss(json);
98-
if (!reader.Parse<rapidjson::kParseNumbersAsStringsFlag>(ss, handler)) {
99+
if (!reader.Parse<rapidjson::kParseNumbersAsStringsFlag>(ss, handler))
100+
{
99101
::MessageBox(nppData._nppHandle, TEXT("Could not parse!!"), TEXT("JSON Viewer"), MB_OK | MB_ICONERROR);
100102

101103
//mark the error position
@@ -341,7 +343,8 @@ void JSONDialog::drawTreeSaxParse()
341343
HTREEITEM tree_root;
342344
tree_root = initTree(this->getHSelf());
343345

344-
if (strlen(curJSON) == 0) {
346+
if (strlen(curJSON) == 0)
347+
{
345348
insertToTree(this->getHSelf(), tree_root, "Error:Please select a JSON String.");
346349
TreeView_Expand(GetDlgItem(this->getHSelf(), IDC_TREE), tree_root, TVE_EXPAND);
347350
return;

NppJSONViewer/JSONDialog.h

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,57 @@
1-
/*
2-
This file is part of JSONViewer Plugin for Notepad++
3-
Copyright (C)2011 Kapil Ratnani <kapil.ratnani@iiitb.net>
4-
5-
This program is free software; you can redistribute it and/or
6-
modify it under the terms of the GNU General Public License
7-
as published by the Free Software Foundation; either version 2
8-
of the License, or (at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU General Public License for more details.
14-
15-
You should have received a copy of the GNU General Public License
16-
along with this program; if not, write to the Free Software
17-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18-
*/
19-
20-
#ifndef JSONDIALOG_H
21-
#define JSONDIALOG_H
22-
23-
#include "DockingDlgInterface.h"
24-
#include "PluginInterface.h"
25-
#include <commctrl.h>
26-
#include "resource.h"
27-
#include "json.h"
28-
29-
class JSONDialog : public DockingDlgInterface
30-
{
31-
char *curJSON;
32-
HANDLE hTree;
33-
//void drawTree();
34-
void drawTreeSaxParse();
35-
HTREEITEM initTree(HWND hWndDlg);
36-
HTREEITEM insertToTree(HWND hWndDlg,HTREEITEM parent,const char *text);
37-
//void populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_root, int level);
38-
void populateTreeUsingSax(HWND hWndDlg, HTREEITEM tree_root, char * json);
39-
public :
40-
JSONDialog() : DockingDlgInterface(IDD_TREEDLG){};
41-
42-
HTREEITEM insertToTree(HTREEITEM parent, const char *text);
43-
44-
virtual void display(bool toShow = true) const {
45-
DockingDlgInterface::display(toShow);
46-
};
47-
48-
void setParent(HWND parent2set){
49-
_hParent = parent2set;
50-
};
51-
52-
void setJSON(char *json);
53-
54-
protected :
55-
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
56-
};
57-
58-
#endif //JSONDIALOG_H
1+
/*
2+
This file is part of JSONViewer Plugin for Notepad++
3+
Copyright (C)2011 Kapil Ratnani <kapil.ratnani@iiitb.net>
4+
5+
This program is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU General Public License
7+
as published by the Free Software Foundation; either version 2
8+
of the License, or (at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18+
*/
19+
20+
#pragma once
21+
22+
#include "DockingDlgInterface.h"
23+
#include "PluginInterface.h"
24+
#include <commctrl.h>
25+
#include "resource.h"
26+
#include "json.h"
27+
28+
class JSONDialog : public DockingDlgInterface
29+
{
30+
char *curJSON = nullptr;
31+
HANDLE hTree = nullptr;
32+
//void drawTree();
33+
void drawTreeSaxParse();
34+
HTREEITEM initTree(HWND hWndDlg);
35+
HTREEITEM insertToTree(HWND hWndDlg, HTREEITEM parent, const char *text);
36+
//void populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_root, int level);
37+
void populateTreeUsingSax(HWND hWndDlg, HTREEITEM tree_root, char * json);
38+
public :
39+
JSONDialog() : DockingDlgInterface(IDD_TREEDLG){};
40+
41+
HTREEITEM insertToTree(HTREEITEM parent, const char *text);
42+
43+
virtual void display(bool toShow = true) const
44+
{
45+
DockingDlgInterface::display(toShow);
46+
}
47+
48+
void setParent(HWND parent2set)
49+
{
50+
_hParent = parent2set;
51+
}
52+
53+
void setJSON(char *json);
54+
55+
protected:
56+
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
57+
};

NppJSONViewer/NPPJSONViewer.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
9999
<SDLCheck>true</SDLCheck>
100100
<MultiProcessorCompilation>true</MultiProcessorCompilation>
101+
<TreatWarningAsError>true</TreatWarningAsError>
101102
</ClCompile>
102103
<Link>
103104
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -116,6 +117,7 @@
116117
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
117118
<SDLCheck>true</SDLCheck>
118119
<MultiProcessorCompilation>true</MultiProcessorCompilation>
120+
<TreatWarningAsError>true</TreatWarningAsError>
119121
</ClCompile>
120122
<Link>
121123
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -136,6 +138,7 @@
136138
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
137139
<SDLCheck>true</SDLCheck>
138140
<MultiProcessorCompilation>true</MultiProcessorCompilation>
141+
<TreatWarningAsError>true</TreatWarningAsError>
139142
</ClCompile>
140143
<Link>
141144
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -159,6 +162,7 @@
159162
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
160163
<SDLCheck>true</SDLCheck>
161164
<MultiProcessorCompilation>true</MultiProcessorCompilation>
165+
<TreatWarningAsError>true</TreatWarningAsError>
162166
</ClCompile>
163167
<Link>
164168
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>

NppJSONViewer/PluginDefinition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void formatSelectedJSON() {
242242
rapidjson::StringBuffer sb;
243243
rapidjson::PrettyWriter<rapidjson::StringBuffer> pw(sb);
244244
bool useTabs = ::SendMessage(curScintilla, SCI_GETUSETABS, 0, 0);
245-
int indentLen = useTabs ? 1 : ::SendMessage(curScintilla, SCI_GETTABWIDTH, 0, 0);
245+
unsigned indentLen = useTabs ? 1 : static_cast<unsigned>(::SendMessage(curScintilla, SCI_GETTABWIDTH, 0, 0));
246246
char indentChar = useTabs ? '\t' : ' ';
247247
pw.SetIndent(indentChar, indentLen);
248248
rapidjson::StringStream ss(curJSON);

NppJSONViewer/StaticDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void StaticDialog::create(int dialogID, bool isRTL)
8080
{
8181
DWORD err = ::GetLastError();
8282
char errMsg[256];
83-
sprintf(errMsg, "CreateDialogParam() return NULL.\rGetLastError() == %u", err);
83+
sprintf(errMsg, "CreateDialogParam() return NULL.\rGetLastError() == %lu", err);
8484
::MessageBoxA(NULL, errMsg, "In StaticDialog::create()", MB_OK);
8585
return;
8686
}

0 commit comments

Comments
 (0)