Skip to content

Commit

Permalink
Enable 8-byte character positions on x64
Browse files Browse the repository at this point in the history
  * 64-bit N++ can now open >2GiB files (*).
    This protects API calls in the (unlikely) event that
    a document returns a character position >0x7FFFFFFF

  * Make Unicode strings the default type wherever they
    used to be conditional

 ---
 (*) https://community.notepad-plus-plus.org/topic/22492/notepad-v8-3-release
  • Loading branch information
Robert Di Pardo authored and Robert Di Pardo committed Feb 16, 2022
1 parent b8f8bcb commit ad2e69c
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 132 deletions.
3 changes: 3 additions & 0 deletions src/LibNppPlugin/NppPluginConstants.pas
Expand Up @@ -121,6 +121,9 @@ interface
//void NPPM_GETPLUGINSCONFIGDIR(int strLen, char *str)


NPPM_GETNPPVERSION = (NPPMSG + 50);
//int NPPM_GETNPPVERSION(0, 0)

RUNCOMMAND_USER = (WM_USER + 3000);

VAR_NOT_RECOGNIZED = 0;
Expand Down
249 changes: 138 additions & 111 deletions src/LibNppPlugin/NppSimpleObjects.pas

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions src/U_HTMLTagFinder.pas
Expand Up @@ -28,7 +28,7 @@ implementation
function ExtractTagName(AView: TActiveDocument;
out ATagName: string;
out AOpening, AClosing: boolean;
APosition: integer = -1): TTextRange;
APosition: Sci_Position = -1): TTextRange;
var
{Tag, }TagEnd: TTextRange;
i: Integer;
Expand Down Expand Up @@ -172,7 +172,7 @@ procedure FindMatchingTag(ASelect: boolean = False; AContentsOnly: Boolean = Fal
end;
// ---------------------------------------------------------------------------------------------
var
InitPos: integer;
InitPos: Sci_Position;
begin
npp := GetApplication();
doc := npp.ActiveDocument;
Expand Down Expand Up @@ -333,9 +333,10 @@ procedure FindMatchingTag(ASelect: boolean = False; AContentsOnly: Boolean = Fal
// DebugWrite('FindMatchingTag:Marking', Format('CurrentTag = TTextRange(%d, %d, "%s")', [Tag.StartPos, Tag.EndPos, Tag.Text]));
MatchingTag.Select;
{$IFNDEF NPPUNICODE} // NPP Unicode has always done this itself
// TODO: only if NPP has version < 5.0
Tag.Mark(STYLE_BRACELIGHT, 255, ncHighlightTimeout);
MatchingTag.Mark(STYLE_BRACELIGHT, 255, ncHighlightTimeout);
if HIWORD(npp.SendMessage(NPPM_GETNPPVERSION)) < 5 then begin
Tag.Mark(STYLE_BRACELIGHT, 255, ncHighlightTimeout);
MatchingTag.Mark(STYLE_BRACELIGHT, 255, ncHighlightTimeout);
end;
{$ENDIF}
end;
end else begin
Expand All @@ -344,8 +345,8 @@ procedure FindMatchingTag(ASelect: boolean = False; AContentsOnly: Boolean = Fal
end else begin
MatchingTag.Select;
{$IFNDEF NPPUNICODE} // NPP Unicode has always done this itself
// TODO: only if NPP has version < 5.0
MatchingTag.Mark(STYLE_BRACELIGHT, 255, ncHighlightTimeout);
if HIWORD(npp.SendMessage(NPPM_GETNPPVERSION)) < 5 then
MatchingTag.Mark(STYLE_BRACELIGHT, 255, ncHighlightTimeout);
{$ENDIF}
end;
end;
Expand Down
4 changes: 2 additions & 2 deletions src/U_JSEncode.pas
Expand Up @@ -64,8 +64,8 @@ function PerformConversion(Conversion: TRangeConversionMethod; Scope: TEntityRep
{ ------------------------------------------------------------------------------------------------ }
function DoEncodeJS(var Text: WideString): Integer; overload;
var
CharIndex: integer;
CharCode: SmallInt;
CharIndex: Cardinal;
CharCode: Cardinal;
EntitiesReplaced: integer;
begin
EntitiesReplaced := 0;
Expand Down
7 changes: 5 additions & 2 deletions src/lib/SciSupport.pas
Expand Up @@ -10,14 +10,17 @@ interface
uses Windows;

type
TScintillaMessageFnc = function(ptr : Pointer; Msg: UINT; wParam: WPARAM; lParam : LPARAM) : LRESULT; cdecl;
uptr_t = NativeUInt;
sptr_t = NativeInt;
Sci_Position = NativeInt;
Sci_PositionU = SIZE_T;

TScintillaMessageFnc = function(ptr : sptr_t; Msg: UINT; wParam: uptr_t; lParam : sptr_t) : sptr_t; cdecl;

TNotifyHeader = record
hwndFrom : HWND;
idFrom : uptr_t;
code : NativeUInt;
code : UINT;
end;
PSCNotification = ^TSCNotification;
TSCNotification = record
Expand Down
16 changes: 8 additions & 8 deletions src/lib/nppplugin.pas
Expand Up @@ -510,8 +510,8 @@ TNppPlugin = class(TObject)

// df
function DoOpen(filename: String): boolean; overload;
function DoOpen(filename: String; Line: Integer): boolean; overload;
procedure GetFileLine(var filename: String; var Line: Integer);
function DoOpen(filename: String; Line: Sci_Position): boolean; overload;
procedure GetFileLine(var filename: String; var Line: Sci_Position);
function GetWord: string;

// helpers
Expand Down Expand Up @@ -605,19 +605,19 @@ function TNppPlugin.AddFuncSeparator: Integer;
Result := AddFuncItem('-', nil);
end;

procedure TNppPlugin.GetFileLine(var filename: String; var Line: Integer);
procedure TNppPlugin.GetFileLine(var filename: String; var Line: Sci_Position);
var
s: String;
r: Integer;
r: Sci_Position;
begin
s := '';
SetLength(s, 300);
SendMessage(self.NppData.NppHandle, NPPM_GETFULLCURRENTPATH,0, LPARAM(PChar(s)));
SetLength(s, StrLen(PChar(s)));
filename := s;

r := SendMessage(self.NppData.ScintillaMainHandle, SciSupport.SCI_GETCURRENTPOS, 0, 0);
Line := SendMessage(self.NppData.ScintillaMainHandle, SciSupport.SCI_LINEFROMPOSITION, r, 0);
r := SendMessage(self.NppData.ScintillaMainHandle, SCI_GETCURRENTPOS, 0, 0);
Line := SendMessage(self.NppData.ScintillaMainHandle, SCI_LINEFROMPOSITION, r, 0);
end;

function TNppPlugin.GetFuncsArray(var FuncsCount: Integer): Pointer;
Expand Down Expand Up @@ -731,13 +731,13 @@ function TNppPlugin.DoOpen(filename: String): boolean;
Result := (r<>0);
end;

function TNppPlugin.DoOpen(filename: String; Line: Integer): boolean;
function TNppPlugin.DoOpen(filename: String; Line: Sci_Position): boolean;
var
r: boolean;
begin
r := self.DoOpen(filename);
if (r) then
SendMessage(self.NppData.ScintillaMainHandle, SciSupport.SCI_GOTOLINE, Line,0);
SendMessage(self.NppData.ScintillaMainHandle, SCI_GOTOLINE, Line,0);
Result := r;
end;

Expand Down
6 changes: 4 additions & 2 deletions src/prj/HTMLTag.dproj
Expand Up @@ -69,7 +69,7 @@
<VerInfo_Keys>CompanyName=Voronwë;FileDescription=HTMLTag plugin for Notepad++;FileVersion=1.2.0.0;InternalName=HTMLTag;LegalCopyright=Martijn Coppoolse;LegalTrademarks=;OriginalFilename=HTMLTag.dll;ProductName=Notepad++;ProductVersion=7.0.0.0;Comments=https://bitbucket.org/rdipardo/htmltag/issues</VerInfo_Keys>
<DCC_UsePackage>vcl;rtl;dbrtl;adortl;vcldb;vclx;bdertl;vcldbx;ibxpress;dsnap;cds;bdecds;qrpt;teeui;teedb;tee;dss;teeqr;visualclx;visualdbclx;dsnapcrba;dsnapcon;VclSmp;vclshlctrls;vclie;xmlrtl;inet;inetdbbde;inetdbxpress;inetdb;nmfast;webdsnap;websnap;soaprtl;dbexpress;dbxcds;indy;dclOffice2k;dOCI6;CoolTrayIcon_D6plus;curlpkg;ThemeManagerD6;VirtualTreesD6;Jcl;JclVcl;JvCoreD6R;JvSystemD6R;JvStdCtrlsD6R;JvAppFrmD6R;JvBandsD6R;JvDBD6R;JvDlgsD6R;JvBDED6R;JvCmpD6R;JvCryptD6R;JvCtrlsD6R;JvCustomD6R;JvDockingD6R;JvDotNetCtrlsD6R;JvEDID6R;JvGlobusD6R;JvHMID6R;JvInterpreterD6R;JvJansD6R;JvManagedThreadsD6R;JvMMD6R;JvNetD6R;JvPageCompsD6R;JvPluginD6R;JvPrintPreviewD6R;JvRuntimeDesignD6R;JvTimeFrameworkD6R;JvUIBD6R;JvValidatorsD6R;JvWizardD6R;JvXPCtrlsD6R;$(DCC_UsePackage)</DCC_UsePackage>
<DCC_ExeOutput>..\..\out\$(PLATFORM)\$(CONFIG)</DCC_ExeOutput>
<DCC_Define>NPPUNICODE;$(DCC_Define)</DCC_Define>
<DCC_Define>UNICODE;NPPUNICODE;$(DCC_Define)</DCC_Define>
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Winapi;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)</DCC_Namespace>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<DCC_UnitSearchPath>..\;$(DELPHI)\Lib\Debug;C:\PROGRA~1\Jedi\jcl\lib\d6\debug;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
Expand All @@ -83,6 +83,8 @@
<DCC_SymbolReferenceInfo>1</DCC_SymbolReferenceInfo>
<DCC_E>false</DCC_E>
<DCC_DcuOutput>..\..\out\dcu\$(PLATFORM)\$(CONFIG)</DCC_DcuOutput>
<DCC_IntegerOverflowCheck>true</DCC_IntegerOverflowCheck>
<DCC_RangeChecking>true</DCC_RangeChecking>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
Expand Down Expand Up @@ -121,7 +123,7 @@ $(PostBuildEvent)]]></PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<Debugger_HostApplication>C:\Users\Rob\source\repos\workspace\bin\npp_8.3\notepad++.exe</Debugger_HostApplication>
<Debugger_HostApplication>C:\Users\Rob\source\repos\workspace\bin\npp_8.3.1\notepad++.exe</Debugger_HostApplication>
<PostBuildEvent><![CDATA[]]></PostBuildEvent>
</PropertyGroup>
<ItemGroup>
Expand Down

0 comments on commit ad2e69c

Please sign in to comment.