Skip to content

Commit abaac2f

Browse files
committed
fix #386
update to N++ 8.8.2 pre
1 parent f7a4aa2 commit abaac2f

27 files changed

+293
-362
lines changed

NppPlugin/include/Common.h

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const bool dirDown = false;
4848
#endif
4949

5050

51-
#define NPP_INTERNAL_FUCTION_STR L"Notepad++::InternalFunction"
51+
#define NPP_INTERNAL_FUNCTION_STR L"Notepad++::InternalFunction"
5252

5353

5454
std::wstring folderBrowser(HWND parent, const std::wstring & title = L"", int outputCtrlID = 0, const wchar_t *defaultStr = NULL);
@@ -87,17 +87,18 @@ class WcharMbcsConvertor final
8787
return instance;
8888
}
8989

90-
const wchar_t * char2wchar(const char *mbStr, size_t codepage, int lenMbcs =-1, int* pLenOut=NULL, int* pBytesNotProcessed=NULL);
91-
const wchar_t * char2wchar(const char *mbcs2Convert, size_t codepage, intptr_t* mstart, intptr_t* mend);
92-
const char * wchar2char(const wchar_t *wcStr, size_t codepage, int lenIn = -1, int* pLenOut = NULL);
93-
const char * wchar2char(const wchar_t *wcStr, size_t codepage, intptr_t* mstart, intptr_t* mend);
90+
const wchar_t* char2wchar(const char* mbStr, size_t codepage, int lenMbcs = -1, int* pLenOut = NULL, int* pBytesNotProcessed = NULL);
91+
const wchar_t* char2wchar(const char* mbcs2Convert, size_t codepage, intptr_t* mstart, intptr_t* mend, int len = 0);
92+
size_t getSizeW() { return _wideCharStr.size(); };
93+
const char* wchar2char(const wchar_t* wcStr, size_t codepage, int lenIn = -1, int* pLenOut = NULL);
94+
const char* wchar2char(const wchar_t* wcStr, size_t codepage, intptr_t* mstart, intptr_t* mend, int lenIn = 0, int* lenOut = nullptr);
95+
size_t getSizeA() { return _multiByteStr.size(); };
9496

95-
const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn = -1, int* pLenOut=NULL, int* pBytesNotProcessed=NULL)
96-
{
97+
const char* encode(UINT fromCodepage, UINT toCodepage, const char* txt2Encode, int lenIn = -1, int* pLenOut = NULL, int* pBytesNotProcessed = NULL) {
9798
int lenWc = 0;
98-
const wchar_t * strW = char2wchar(txt2Encode, fromCodepage, lenIn, &lenWc, pBytesNotProcessed);
99-
return wchar2char(strW, toCodepage, lenWc, pLenOut);
100-
}
99+
const wchar_t* strW = char2wchar(txt2Encode, fromCodepage, lenIn, &lenWc, pBytesNotProcessed);
100+
return wchar2char(strW, toCodepage, lenWc, pLenOut);
101+
}
101102

102103
protected:
103104
WcharMbcsConvertor() = default;
@@ -112,46 +113,46 @@ class WcharMbcsConvertor final
112113
WcharMbcsConvertor(WcharMbcsConvertor&&) = delete;
113114
WcharMbcsConvertor& operator= (WcharMbcsConvertor&&) = delete;
114115

115-
template <class T>
116-
class StringBuffer final
116+
template <class T> class StringBuffer final
117117
{
118118
public:
119119
~StringBuffer() { if (_allocLen) delete[] _str; }
120120

121-
void sizeTo(size_t size)
122-
{
123-
if (_allocLen < size)
121+
void sizeTo(size_t size) {
122+
if (_allocLen < size + 1)
124123
{
125124
if (_allocLen)
126125
delete[] _str;
127-
_allocLen = std::max<size_t>(size, initSize);
128-
_str = new T[_allocLen];
126+
_allocLen = std::max<size_t>(size + 1, initSize);
127+
_str = new T[_allocLen]{};
129128
}
129+
_dataLen = size;
130130
}
131131

132-
void empty()
133-
{
132+
void empty() {
134133
static T nullStr = 0; // routines may return an empty string, with null terminator, without allocating memory; a pointer to this null character will be returned in that case
135134
if (_allocLen == 0)
136135
_str = &nullStr;
137136
else
138137
_str[0] = 0;
138+
_dataLen = 0;
139139
}
140140

141+
size_t size() const { return _dataLen; }
141142
operator T* () { return _str; }
142143
operator const T* () const { return _str; }
143144

144145
protected:
145146
static const int initSize = 1024;
146147
size_t _allocLen = 0;
148+
size_t _dataLen = 0;
147149
T* _str = nullptr;
148150
};
149151

150152
StringBuffer<char> _multiByteStr;
151153
StringBuffer<wchar_t> _wideCharStr;
152154
};
153155

154-
155156
#define REBARBAND_SIZE sizeof(REBARBANDINFO)
156157

157158
std::wstring pathRemoveFileSpec(std::wstring & path);

NppPlugin/include/Docking.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file is part of Notepad++ project
2-
// Copyright (C)2024 Don HO <[email protected]>
2+
// Copyright (C)2025 Don HO <[email protected]>
33

44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU General Public License as published by
@@ -48,18 +48,18 @@
4848

4949

5050
struct tTbData {
51-
HWND hClient = nullptr; // client Window Handle
51+
HWND hClient = nullptr; // client Window Handle
5252
const wchar_t* pszName = nullptr; // name of plugin (shown in window)
53-
int dlgID = 0; // a funcItem provides the function pointer to start a dialog. Please parse here these ID
53+
int dlgID = 0; // a funcItem provides the function pointer to start a dialog. Please parse here these ID
5454

5555
// user modifications
56-
UINT uMask = 0; // mask params: look to above defines
57-
HICON hIconTab = nullptr; // icon for tabs
58-
const wchar_t* pszAddInfo = nullptr; // for plugin to display additional informations
56+
UINT uMask = 0; // mask params: look to above defines
57+
HICON hIconTab = nullptr; // icon for tabs
58+
const wchar_t* pszAddInfo = nullptr; // for plugin to display additional information
5959

6060
// internal data, do not use !!!
61-
RECT rcFloat = {}; // floating position
62-
int iPrevCont = 0; // stores the privious container (toggling between float and dock)
61+
RECT rcFloat = {}; // floating position
62+
int iPrevCont = 0; // stores the privious container (toggling between float and dock)
6363
const wchar_t* pszModuleName = nullptr; // it's the plugin file name. It's used to identify the plugin
6464
};
6565

NppPlugin/include/DockingDlgInterface.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "dockingResource.h"
2121
#include "Docking.h"
2222

23+
#include <array>
2324
#include <assert.h>
2425
#include <shlwapi.h>
2526
#include "Common.h"
@@ -41,7 +42,7 @@ class DockingDlgInterface : public StaticDialog
4142
_moduleName = ::PathFindFileName(temp);
4243
}
4344

44-
void create(tTbData* data, bool isRTL = false) {
45+
virtual void create(tTbData* data, bool isRTL = false) {
4546
assert(data != nullptr);
4647
StaticDialog::create(_dlgID, isRTL);
4748
wchar_t temp[MAX_PATH];
@@ -56,7 +57,12 @@ class DockingDlgInterface : public StaticDialog
5657
data->uMask = 0;
5758

5859
// additional info
59-
data->pszAddInfo = NULL;
60+
data->pszAddInfo = nullptr;
61+
}
62+
63+
virtual void create(tTbData* data, std::array<int, 3> iconIDs, bool isRTL = false) {
64+
create(data, isRTL);
65+
_iconIDs = iconIDs;
6066
}
6167

6268
virtual void updateDockingDlg() {
@@ -82,12 +88,17 @@ class DockingDlgInterface : public StaticDialog
8288
return _moduleName.c_str();
8389
}
8490

91+
const std::array<int, 3>& getIconIDs() const {
92+
return _iconIDs;
93+
}
94+
8595
protected :
8696
int _dlgID = -1;
87-
bool _isFloating = true;
8897
int _iDockedPos = 0;
8998
std::wstring _moduleName;
9099
std::wstring _pluginName;
100+
std::array<int, 3> _iconIDs{};
101+
bool _isFloating = true;
91102
bool _isClosed = false;
92103

93104
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override {
@@ -100,14 +111,14 @@ protected :
100111
break;
101112
}
102113

103-
RECT rc = {};
114+
RECT rc{};
104115
getClientRect(rc);
105-
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
116+
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDlgBackgroundBrush());
106117
return TRUE;
107118
}
108-
case WM_NOTIFY:
119+
case WM_NOTIFY:
109120
{
110-
LPNMHDR pnmh = reinterpret_cast<LPNMHDR>(lParam);
121+
auto* pnmh = reinterpret_cast<LPNMHDR>(lParam);
111122

112123
if (pnmh->hwndFrom == _hParent)
113124
{

0 commit comments

Comments
 (0)