Check-in [cb15f520db]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added exception handling to plugin template, to avoid having to implement it everywhere. Exceptions are written to DebugOutput. Added checks for preview form to prevent exception on close of each document.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.2
Files: files | file ages | folders
SHA1:cb15f520dbd17b30ce7aaf3e92ae9b067235288e
User & Date: MCO 2013-01-28 17:22:52
Context
2013-01-29
21:42
Release of v1.2.1.0 check-in: a9b6dbe5b5 user: Martijn tags: release, v1.2.1.0, v1.2
2013-01-28
17:22
Added exception handling to plugin template, to avoid having to implement it everywhere. Exceptions are written to DebugOutput. Added checks for preview form to prevent exception on close of each document. check-in: cb15f520db user: MCO tags: v1.2
2013-01-26
15:43
Release of v1.2.0.0. Added handling of SCN_MODIFIED event, and added a timer which triggers a refresh [20d1203257]. Commented out some remnants of the custom filtering code. Added code to remove scroll positions of files that have been closed [cfc74baf4b]. check-in: e58749fea7 user: Martijn tags: release, v1.2.0.0, v1.2
Changes

Changes to src/F_PreviewHTML.pas.

68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
250
251
252
253
254
255
256

257
258
259

260
261
262
263
264
265
266
{$R *.dfm}

{ ================================================================================================ }

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.FormCreate(Sender: TObject);
begin

  self.NppDefaultDockingMask := DWS_DF_FLOATING; // whats the default docking position
  //self.KeyPreview := true; // special hack for input forms
  self.OnFloat := self.FormFloat;
  self.OnDock := self.FormDock;
  inherited;
  FScrollPositions := TStringList.Create;
  FBufferID := -1;
  with GetSettings() do begin
    tmrAutorefresh.Interval := ReadInteger('Autorefresh', 'Interval', tmrAutorefresh.Interval);
  end;
end {TfrmHTMLPreview.FormCreate};
{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.FormDestroy(Sender: TObject);
begin
  FScrollPositions.Free;
  inherited;
end {TfrmHTMLPreview.FormDestroy};


{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.btnCloseStatusbarClick(Sender: TObject);
begin
................................................................................
{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.ForgetBuffer(const BufferID: NativeInt);
var
  Index: Integer;
begin
  if FBufferID = BufferID then
    FBufferID := -1;

  Index := FScrollPositions.IndexOfObject(TObject(BufferID));
  if Index > -1 then
    FScrollPositions.Delete(Index);

end {TfrmHTMLPreview.ForgetBuffer};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.ResetTimer;
begin
  tmrAutorefresh.Enabled := False;
  tmrAutorefresh.Enabled := True;







>





<








|







 







>
|
|
|
>







68
69
70
71
72
73
74
75
76
77
78
79
80

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
{$R *.dfm}

{ ================================================================================================ }

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.FormCreate(Sender: TObject);
begin
  FScrollPositions := TStringList.Create;
  self.NppDefaultDockingMask := DWS_DF_FLOATING; // whats the default docking position
  //self.KeyPreview := true; // special hack for input forms
  self.OnFloat := self.FormFloat;
  self.OnDock := self.FormDock;
  inherited;

  FBufferID := -1;
  with GetSettings() do begin
    tmrAutorefresh.Interval := ReadInteger('Autorefresh', 'Interval', tmrAutorefresh.Interval);
  end;
end {TfrmHTMLPreview.FormCreate};
{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.FormDestroy(Sender: TObject);
begin
  FreeAndNil(FScrollPositions);
  inherited;
end {TfrmHTMLPreview.FormDestroy};


{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.btnCloseStatusbarClick(Sender: TObject);
begin
................................................................................
{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.ForgetBuffer(const BufferID: NativeInt);
var
  Index: Integer;
begin
  if FBufferID = BufferID then
    FBufferID := -1;
  if Assigned(FScrollPositions) then begin
    Index := FScrollPositions.IndexOfObject(TObject(BufferID));
    if Index > -1 then
      FScrollPositions.Delete(Index);
  end;
end {TfrmHTMLPreview.ForgetBuffer};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmHTMLPreview.ResetTimer;
begin
  tmrAutorefresh.Enabled := False;
  tmrAutorefresh.Enabled := True;

Changes to src/U_Npp_PreviewHTML.pas.

220
221
222
223
224
225
226

227

228
229
230
231
232
233
234
235
236

237
238
239
240
241
242
243
244
245
246
247
248
    frmHTMLPreview.btnRefresh.Click;
  end;
end {TNppPluginPreviewHTML.DoNppnBufferActivated};

{ ------------------------------------------------------------------------------------------------ }
procedure TNppPluginPreviewHTML.DoNppnFileClosed(const BufferID: Cardinal);
begin

  frmHTMLPreview.ForgetBuffer(BufferID);

  inherited;
end {TNppPluginPreviewHTML.DoNppnFileClosed};

{ ------------------------------------------------------------------------------------------------ }
procedure TNppPluginPreviewHTML.DoModified(const hwnd: HWND; const modificationType: Integer);
begin
  if Assigned(frmHTMLPreview) and frmHTMLPreview.Visible and (modificationType and (SC_MOD_INSERTTEXT or SC_MOD_DELETETEXT) <> 0) then begin
    frmHTMLPreview.ResetTimer;
  end;

end {TNppPluginPreviewHTML.DoModified};



////////////////////////////////////////////////////////////////////////////////////////////////////
initialization
  try
    Npp := TNppPluginPreviewHTML.Create;
  except
    ShowException(ExceptObject, ExceptAddr);
  end;
end.







>
|
>









>












220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
    frmHTMLPreview.btnRefresh.Click;
  end;
end {TNppPluginPreviewHTML.DoNppnBufferActivated};

{ ------------------------------------------------------------------------------------------------ }
procedure TNppPluginPreviewHTML.DoNppnFileClosed(const BufferID: Cardinal);
begin
  if Assigned(frmHTMLPreview) then begin
    frmHTMLPreview.ForgetBuffer(BufferID);
  end;
  inherited;
end {TNppPluginPreviewHTML.DoNppnFileClosed};

{ ------------------------------------------------------------------------------------------------ }
procedure TNppPluginPreviewHTML.DoModified(const hwnd: HWND; const modificationType: Integer);
begin
  if Assigned(frmHTMLPreview) and frmHTMLPreview.Visible and (modificationType and (SC_MOD_INSERTTEXT or SC_MOD_DELETETEXT) <> 0) then begin
    frmHTMLPreview.ResetTimer;
  end;
  inherited;
end {TNppPluginPreviewHTML.DoModified};



////////////////////////////////////////////////////////////////////////////////////////////////////
initialization
  try
    Npp := TNppPluginPreviewHTML.Create;
  except
    ShowException(ExceptObject, ExceptAddr);
  end;
end.

Changes to src/lib/nppplugin.pas.

633
634
635
636
637
638
639

640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669





670
671
672
673
674
675
676
    SetString(FConfigDir, PChar(FConfigDir), StrLen(PChar(FConfigDir)));
  end;
  Result := FConfigDir;
end;

procedure TNppPlugin.BeNotified(sn: PSCNotification);
begin

  if HWND(sn^.nmhdr.hwndFrom) = self.NppData.NppHandle then begin
    case sn.nmhdr.code of
      NPPN_TB_MODIFICATION: begin
        self.DoNppnToolbarModification;
      end;
      NPPN_SHUTDOWN: begin
        self.DoNppnShutdown;
      end;
      NPPN_BUFFERACTIVATED: begin
        self.DoNppnBufferActivated(sn.nmhdr.idFrom);
      end;
      NPPN_FILEBEFORECLOSE: begin
        FClosingBufferID := SendMessage(HWND(sn.nmhdr.hwndFrom), NPPM_GETCURRENTBUFFERID, 0, 0);
//        self.DoNppnBeforeFileClose(FClosingBufferID);
      end;
      NPPN_FILECLOSED: begin
        self.DoNppnFileClosed(FClosingBufferID);
      end;
    end;
  end else begin
    case sn.nmhdr.code of
      SCN_MODIFIED: begin
        Self.DoModified(HWND(sn.nmhdr.hwndFrom), sn.modificationType);
      end;
      SCN_UPDATEUI: begin
        self.DoUpdateUI(HWND(sn.nmhdr.hwndFrom), sn.updated);
      end;
    end;
  end;
  // @todo





end;

procedure TNppPlugin.MessageProc(var Msg: TMessage);
//var
//  hm: HMENU;
//  i: integer;
begin







>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>







633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
    SetString(FConfigDir, PChar(FConfigDir), StrLen(PChar(FConfigDir)));
  end;
  Result := FConfigDir;
end;

procedure TNppPlugin.BeNotified(sn: PSCNotification);
begin
  try
    if HWND(sn^.nmhdr.hwndFrom) = self.NppData.NppHandle then begin
      case sn.nmhdr.code of
        NPPN_TB_MODIFICATION: begin
          self.DoNppnToolbarModification;
        end;
        NPPN_SHUTDOWN: begin
          self.DoNppnShutdown;
        end;
        NPPN_BUFFERACTIVATED: begin
          self.DoNppnBufferActivated(sn.nmhdr.idFrom);
        end;
        NPPN_FILEBEFORECLOSE: begin
          FClosingBufferID := SendMessage(HWND(sn.nmhdr.hwndFrom), NPPM_GETCURRENTBUFFERID, 0, 0);
  //        self.DoNppnBeforeFileClose(FClosingBufferID);
        end;
        NPPN_FILECLOSED: begin
          self.DoNppnFileClosed(FClosingBufferID);
        end;
      end;
    end else begin
      case sn.nmhdr.code of
        SCN_MODIFIED: begin
          Self.DoModified(HWND(sn.nmhdr.hwndFrom), sn.modificationType);
        end;
        SCN_UPDATEUI: begin
          self.DoUpdateUI(HWND(sn.nmhdr.hwndFrom), sn.updated);
        end;
      end;
    end;
    // @todo
  except
    on E: Exception do begin
      OutputDebugString(PChar(Format('%s> %s: "%s"', [PluginName, E.ClassName, E.Message])));
    end;
  end;
end;

procedure TNppPlugin.MessageProc(var Msg: TMessage);
//var
//  hm: HMENU;
//  i: integer;
begin

Changes to src/prj/PreviewHTML.dproj.

1
2
3
4
5
6
7
8
9
10
11
12
13
..
81
82
83
84
85
86
87


88
89
90
91
92
93
94
...
130
131
132
133
134
135
136

137






138
139
140
141
142
143
144
...
213
214
215
216
217
218
219
220








221
	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
		<PropertyGroup>
			<ProjectGuid>{A2533A0E-8621-4A31-A675-059AFF5AA9FB}</ProjectGuid>
			<MainSource>PreviewHTML.dpr</MainSource>
			<Base>True</Base>
			<Config Condition="'$(Config)'==''">Release</Config>
			<TargetedPlatforms>1</TargetedPlatforms>
			<AppType>Library</AppType>
			<FrameworkType>VCL</FrameworkType>
			<ProjectVersion>13.4</ProjectVersion>
			<Platform Condition="'$(Platform)'==''">Win32</Platform>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
................................................................................
		<PropertyGroup Condition="'$(Cfg_2)'!=''">
			<DCC_SymbolReferenceInfo>2</DCC_SymbolReferenceInfo>
			<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
			<DCC_Optimize>false</DCC_Optimize>
			<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">


			<PostBuildEvent><![CDATA[]]></PostBuildEvent>
		</PropertyGroup>
		<ItemGroup>
			<DelphiCompile Include="$(MainSource)">
				<MainSource>MainSource</MainSource>
			</DelphiCompile>
			<RcCompile Include="PreviewHTML_TB.rc">
................................................................................
			<Borland.ProjectType/>
			<BorlandProject>
				<Delphi.Personality>
					<Source>
						<Source Name="MainSource">PreviewHTML.dpr</Source>
					</Source>
					<Excluded_Packages>

						<Excluded_Packages Name="W:\LIB\BPL\AbbreviaVCL160.bpl">Abbrevia Run-time package - VCLXE</Excluded_Packages>






						<Excluded_Packages Name="$(BDSBIN)\dcloffice2k160.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
						<Excluded_Packages Name="$(BDSBIN)\dclofficexp160.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
						<Excluded_Packages Name="$(BDSBIN)\bcboffice2k160.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
						<Excluded_Packages Name="$(BDSBIN)\bcbofficexp160.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
					</Excluded_Packages>
					<VersionInfo>
						<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
................................................................................
		<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='OSX32'">
			<PreBuildEvent/>
			<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
			<PreLinkEvent/>
			<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
			<PostBuildEvent>&quot;C:\MC\Run\Util\Compression\UPX\upx.exe&quot; --best -q &quot;$(OUTPUTPATH)&quot; </PostBuildEvent>
			<PostBuildEventIgnoreExitCode>True</PostBuildEventIgnoreExitCode>
		</PropertyGroup>








	</Project>





|







 







>
>







 







>
|
>
>
>
>
>
>







 








>
>
>
>
>
>
>
>

1
2
3
4
5
6
7
8
9
10
11
12
13
..
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
...
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
		<PropertyGroup>
			<ProjectGuid>{A2533A0E-8621-4A31-A675-059AFF5AA9FB}</ProjectGuid>
			<MainSource>PreviewHTML.dpr</MainSource>
			<Base>True</Base>
			<Config Condition="'$(Config)'==''">Debug</Config>
			<TargetedPlatforms>1</TargetedPlatforms>
			<AppType>Library</AppType>
			<FrameworkType>VCL</FrameworkType>
			<ProjectVersion>13.4</ProjectVersion>
			<Platform Condition="'$(Platform)'==''">Win32</Platform>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
................................................................................
		<PropertyGroup Condition="'$(Cfg_2)'!=''">
			<DCC_SymbolReferenceInfo>2</DCC_SymbolReferenceInfo>
			<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
			<DCC_Optimize>false</DCC_Optimize>
			<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
			<VerInfo_Debug>true</VerInfo_Debug>
			<VerInfo_Keys>CompanyName=Voronwë;FileDescription=HTML Preview plugin for Notepad++;FileVersion=1.2.1.0;InternalName=PreviewHTML;LegalCopyright=© Martijn Coppoolse;LegalTrademarks=;OriginalFilename=PreviewHTML.dll;ProductName=Notepad++;ProductVersion=6.0.0.0;Comments=http://martijn.coppoolse.com/software</VerInfo_Keys>
			<PostBuildEvent><![CDATA[]]></PostBuildEvent>
		</PropertyGroup>
		<ItemGroup>
			<DelphiCompile Include="$(MainSource)">
				<MainSource>MainSource</MainSource>
			</DelphiCompile>
			<RcCompile Include="PreviewHTML_TB.rc">
................................................................................
			<Borland.ProjectType/>
			<BorlandProject>
				<Delphi.Personality>
					<Source>
						<Source Name="MainSource">PreviewHTML.dpr</Source>
					</Source>
					<Excluded_Packages>
						<Excluded_Packages Name="W:\LIB\BPL\AbbreviaVCLDesign160.bpl">File W:\LIB\BPL\AbbreviaVCLDesign160.bpl not found</Excluded_Packages>
						<Excluded_Packages Name="W:\LIB\BPL\AbbreviaVCL160.bpl">File W:\LIB\BPL\AbbreviaVCL160.bpl not found</Excluded_Packages>
						<Excluded_Packages Name="W:\LIB\BPL\DL_Control_XE2.bpl">File W:\LIB\BPL\DL_Control_XE2.bpl not found</Excluded_Packages>
						<Excluded_Packages Name="W:\LIB\BPL\tmsdXE2.bpl">File W:\LIB\BPL\tmsdXE2.bpl not found</Excluded_Packages>
						<Excluded_Packages Name="W:\LIB\BPL\RaizeComponentsVcl_Design.bpl">File W:\LIB\BPL\RaizeComponentsVcl_Design.bpl not found</Excluded_Packages>
						<Excluded_Packages Name="W:\LIB\BPL\tmsdedXE2.bpl">File W:\LIB\BPL\tmsdedXE2.bpl not found</Excluded_Packages>
						<Excluded_Packages Name="W:\LIB\BPL\tmsexdXE2.bpl">File W:\LIB\BPL\tmsexdXE2.bpl not found</Excluded_Packages>
						<Excluded_Packages Name="W:\LIB\BPL\wPDF3_XE2.bpl">File W:\LIB\BPL\wPDF3_XE2.bpl not found</Excluded_Packages>
						<Excluded_Packages Name="$(BDSBIN)\dcloffice2k160.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
						<Excluded_Packages Name="$(BDSBIN)\dclofficexp160.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
						<Excluded_Packages Name="$(BDSBIN)\bcboffice2k160.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
						<Excluded_Packages Name="$(BDSBIN)\bcbofficexp160.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
					</Excluded_Packages>
					<VersionInfo>
						<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
................................................................................
		<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='OSX32'">
			<PreBuildEvent/>
			<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
			<PreLinkEvent/>
			<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
			<PostBuildEvent>&quot;C:\MC\Run\Util\Compression\UPX\upx.exe&quot; --best -q &quot;$(OUTPUTPATH)&quot; </PostBuildEvent>
			<PostBuildEventIgnoreExitCode>True</PostBuildEventIgnoreExitCode>
		</PropertyGroup>
		<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='Win32'">
			<PreBuildEvent/>
			<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
			<PreLinkEvent/>
			<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
			<PostBuildEvent><![CDATA[]]></PostBuildEvent>
			<PostBuildEventIgnoreExitCode>True</PostBuildEventIgnoreExitCode>
		</PropertyGroup>
	</Project>