Skip to content

Commit fde2a41

Browse files
Robert Di PardoRobert Di Pardo
authored andcommitted
Extract version check to plugin base class
Also takes advantage of padded low words, implemented in v8.4.1 Cf. notepad-plus-plus/notepad-plus-plus@ef609c8
1 parent 1af4c1c commit fde2a41

2 files changed

Lines changed: 32 additions & 25 deletions

File tree

src/LibNppPlugin/nppplugin.pas

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ TNppPlugin = class(TObject)
3636
FConfigDir: string;
3737
protected
3838
PluginName: nppString;
39+
function SupportsBigFiles: Boolean;
40+
function GetNppVersion: Cardinal;
3941
function GetPluginsConfigDir: string;
4042
function AddFuncSeparator: Integer;
4143
function AddFuncItem(Name: nppString; Func: PFUNCPLUGINCMD): Integer; overload;
@@ -350,4 +352,34 @@ function TNppPlugin.CmdIdFromDlgId(DlgId: Integer): Integer;
350352
Result := self.FuncArray[DlgId].CmdId;
351353
end;
352354

355+
function TNppPlugin.GetNppVersion: Cardinal;
356+
var
357+
NppVersion: Cardinal;
358+
begin
359+
NppVersion := SendMessage(self.NppData.NppHandle, NPPM_GETNPPVERSION, 0, 0);
360+
// retrieve the zero-padded version, if available
361+
// https://github.com/notepad-plus-plus/notepad-plus-plus/commit/ef609c896f209ecffd8130c3e3327ca8a8157e72
362+
if ((HIWORD(NppVersion) > 8) or
363+
((HIWORD(NppVersion) = 8) and
364+
(((LOWORD(NppVersion) >= 41) and (not (LOWORD(NppVersion) in [191, 192, 193]))) or
365+
(LOWORD(NppVersion) in [5, 6, 7, 8, 9])))) then
366+
NppVersion := SendMessage(self.NppData.NppHandle, NPPM_GETNPPVERSION, 1, 0);
367+
368+
Result := NppVersion;
369+
end;
370+
371+
function TNppPlugin.SupportsBigFiles: Boolean;
372+
var
373+
NppVersion: Cardinal;
374+
begin
375+
NppVersion := GetNppVersion;
376+
Result :=
377+
(HIWORD(NppVersion) > 8) or
378+
((HIWORD(NppVersion) = 8) and
379+
// 8.3 => 8,3 *not* 8,30
380+
((LOWORD(NppVersion) in [3, 4]) or
381+
// Also check for N++ versions 8.1.9.1, 8.1.9.2 and 8.1.9.3
382+
((LOWORD(NppVersion) > 21) and (not (LOWORD(NppVersion) in [191, 192, 193])))));
383+
end;
384+
353385
end.

src/U_Npp_HTMLTag.pas

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ TNppPluginHTMLTag = class(TNppPlugin)
1616
FApp: TApplication;
1717
FVersionInfo: TFileVersionInfo;
1818
FVersionStr: nppString;
19-
function SupportsBigFiles: Boolean;
2019
public
2120
constructor Create;
2221
destructor Destroy; override;
@@ -356,30 +355,6 @@ procedure TNppPluginHTMLTag.commandAbout;
356355
end {TNppPluginHTMLTag.commandAbout};
357356

358357
{ ------------------------------------------------------------------------------------------------ }
359-
function TNppPluginHTMLTag.SupportsBigFiles: Boolean;
360-
const
361-
PatchReleases: Array[0..2] of Word = ( 191, 192, 193 );
362-
var
363-
NppVersion: Cardinal;
364-
IsPatchRelease: Boolean;
365-
i: Byte;
366-
begin
367-
NppVersion := FApp.SendMessage(NPPM_GETNPPVERSION);
368-
IsPatchRelease := False;
369-
370-
for i := 0 to Length(PatchReleases) - 1 do
371-
begin
372-
IsPatchRelease := (LOWORD(NppVersion) = PatchReleases[i]);
373-
if IsPatchRelease then Break;
374-
end;
375-
376-
Result :=
377-
(HIWORD(NppVersion) > 8) or
378-
((HIWORD(NppVersion) = 8) and
379-
// 8.3 -> 8,3 (*not* 8,30)
380-
(((LOWORD(NppVersion) >= 3) and (LOWORD(NppVersion) <= 9)) or
381-
((LOWORD(NppVersion) > 21) and not IsPatchRelease)))
382-
end {TNppPluginHTMLTag.SupportsBigFiles};
383358

384359

385360

0 commit comments

Comments
 (0)