Add a new format argument/option "ADD_ZERO_PADDING" to NPPM_GETNPPVERSION
Fix #11535
This commit is contained in:
parent
bdf60d80ff
commit
ef609c896f
|
@ -197,11 +197,31 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
|
|||
//void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate)
|
||||
|
||||
#define NPPM_GETNPPVERSION (NPPMSG + 50)
|
||||
// int NPPM_GETNPPVERSION(0, 0)
|
||||
// return version
|
||||
// ex : v4.6
|
||||
// HIWORD(version) == 4
|
||||
// LOWORD(version) == 6
|
||||
// int NPPM_GETNPPVERSION(BOOL ADD_ZERO_PADDING, 0)
|
||||
// Get Notepad++ version
|
||||
// HIWORD(returned_value) is major part of version: the 1st number
|
||||
// LOWORD(returned_value) is minor part of version: the 3 last numbers
|
||||
//
|
||||
// ADD_ZERO_PADDING == TRUE
|
||||
//
|
||||
// version | HIWORD | LOWORD
|
||||
//------------------------------
|
||||
// 8.9.6.4 | 8 | 964
|
||||
// 9 | 9 | 0
|
||||
// 6.9 | 6 | 900
|
||||
// 6.6.6 | 6 | 660
|
||||
// 13.6.6.6 | 13 | 666
|
||||
//
|
||||
//
|
||||
// ADD_ZERO_PADDING == FALSE
|
||||
//
|
||||
// version | HIWORD | LOWORD
|
||||
//------------------------------
|
||||
// 8.9.6.4 | 8 | 964
|
||||
// 9 | 9 | 0
|
||||
// 6.9 | 6 | 9
|
||||
// 6.6.6 | 6 | 66
|
||||
// 13.6.6.6 | 13 | 666
|
||||
|
||||
#define NPPM_HIDETABBAR (NPPMSG + 51)
|
||||
// BOOL NPPM_HIDETABBAR(0, BOOL hideOrNot)
|
||||
|
@ -553,7 +573,6 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
|
|||
#define NPPM_GETNPPFULLFILEPATH (RUNCOMMAND_USER + NPP_FULL_FILE_PATH)
|
||||
|
||||
|
||||
|
||||
// Notification code
|
||||
#define NPPN_FIRST 1000
|
||||
#define NPPN_READY (NPPN_FIRST + 1) // To notify plugins that all the procedures of launchment of notepad++ are done.
|
||||
|
|
|
@ -1265,15 +1265,35 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
// ADD_ZERO_PADDING == TRUE
|
||||
//
|
||||
// version | HIWORD | LOWORD
|
||||
//------------------------------
|
||||
// 8.9.6.4 | 8 | 964
|
||||
// 9 | 9 | 0
|
||||
// 6.9 | 6 | 900
|
||||
// 6.6.6 | 6 | 660
|
||||
// 13.6.6.6 | 13 | 666
|
||||
//
|
||||
//
|
||||
// ADD_ZERO_PADDING == FALSE
|
||||
//
|
||||
// version | HIWORD | LOWORD
|
||||
//------------------------------
|
||||
// 8.9.6.4 | 8 | 964
|
||||
// 9 | 9 | 0
|
||||
// 6.9 | 6 | 9
|
||||
// 6.6.6 | 6 | 66
|
||||
// 13.6.6.6 | 13 | 666
|
||||
case NPPM_GETNPPVERSION:
|
||||
{
|
||||
const TCHAR * verStr = VERSION_VALUE;
|
||||
const TCHAR* verStr = VERSION_VALUE;
|
||||
TCHAR mainVerStr[16];
|
||||
TCHAR auxVerStr[16];
|
||||
bool isDot = false;
|
||||
int j =0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
for (int i = 0 ; verStr[i] ; ++i)
|
||||
for (int i = 0; verStr[i]; ++i)
|
||||
{
|
||||
if (verStr[i] == '.')
|
||||
{
|
||||
|
@ -1291,6 +1311,32 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
mainVerStr[j] = '\0';
|
||||
auxVerStr[k] = '\0';
|
||||
|
||||
// if auxVerStr length should less or equal to 3.
|
||||
// if auxVer is less 3 digits, the padding (0) will be added.
|
||||
bool addZeroPadding = wParam == TRUE;
|
||||
if (addZeroPadding)
|
||||
{
|
||||
size_t nbDigit = lstrlen(auxVerStr);
|
||||
if (nbDigit > 0 && nbDigit <= 3)
|
||||
{
|
||||
if (nbDigit == 3)
|
||||
{
|
||||
// OK, nothing to do.
|
||||
}
|
||||
else if (nbDigit == 2)
|
||||
{
|
||||
auxVerStr[2] = '0';
|
||||
auxVerStr[3] = '\0';
|
||||
}
|
||||
else // if (nbDigit == 1)
|
||||
{
|
||||
auxVerStr[1] = '0';
|
||||
auxVerStr[2] = '0';
|
||||
auxVerStr[3] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int mainVer = 0, auxVer = 0;
|
||||
if (mainVerStr[0])
|
||||
mainVer = generic_atoi(mainVerStr);
|
||||
|
|
Loading…
Reference in New Issue