Check-in [388a0bb939]
Not logged in

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

Overview
Comment:Merge with v1.2 fix.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 388a0bb9393b26120cdc41c3e0b20ad011045dd8
User & Date: tinus 2017-02-07 20:56:02.703
Context
2017-02-08
16:04
Added versionable ignore-glob. Updated and normalized Delphi project (10.1 Berlin Update 2). check-in: 81540a5449 user: tinus tags: trunk
2017-02-07
20:56
Merge with v1.2 fix. check-in: 388a0bb939 user: tinus tags: trunk
20:42
Update project file to Delphi 10.1 Berlin. Changed scroll positions list to TDictionary<TBufferID,TPoint>. check-in: 930e563975 user: tinus tags: trunk
2013-10-20
13:26
Take the document's current code page into account, and don't assume UTF-8 by default. (Untested) Closed-Leaf check-in: 6a71b23ed0 user: Martijn tags: v1.2
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/F_PreviewHTML.pas.
151
152
153
154
155
156
157

158
159
160
161
162
163
164
  hScintilla: THandle;
  Lexer: NativeInt;
  IsHTML, IsXML, IsCustom: Boolean;
  Size: WPARAM;
  Content: UTF8String;
  HTML: string;
  FilterName: string;

begin
  if chkFreeze.Checked then
    Exit;

  try
    tmrAutorefresh.Enabled := False;
ODS('FreeAndNil(FFilterThread);');







>







151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
  hScintilla: THandle;
  Lexer: NativeInt;
  IsHTML, IsXML, IsCustom: Boolean;
  Size: WPARAM;
  Content: UTF8String;
  HTML: string;
  FilterName: string;
  CodePage: NativeInt;
begin
  if chkFreeze.Checked then
    Exit;

  try
    tmrAutorefresh.Enabled := False;
ODS('FreeAndNil(FFilterThread);');
182
183
184
185
186
187
188

189
190
191

192

193






194
195
196
197
198
199
200
      {--- MCO 22-01-2013: determine whether the current document matches a custom filter ---}
      FilterName := DetermineCustomFilter;
      IsCustom := Length(FilterName) > 0;

      {$MESSAGE HINT 'TODO: Find a way to communicate why there is no preview, depending on the situation — MCO 22-01-2013'}

      if IsXML or IsHTML or IsCustom then begin

        Size := SendMessage(hScintilla, SCI_GETTEXT, 0, 0);
        SetLength(Content, Size);
        SendMessage(hScintilla, SCI_GETTEXT, Size, LPARAM(PAnsiChar(Content)));

        Content := UTF8String(PAnsiChar(Content));

        HTML := string(Content);






      end;

      if IsCustom then begin
//MessageBox(Npp.NppData.NppHandle, PChar(Format('FilterName: %s', [FilterName])), 'PreviewHTML', MB_ICONINFORMATION);
        wbIEStatusTextChange(wbIE, Format('Running filter %s...', [FilterName]));
        if ExecuteCustomFilter(FilterName, HTML, BufferID) then begin
          Exit;







>



>
|
>
|
>
>
>
>
>
>







183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
      {--- MCO 22-01-2013: determine whether the current document matches a custom filter ---}
      FilterName := DetermineCustomFilter;
      IsCustom := Length(FilterName) > 0;

      {$MESSAGE HINT 'TODO: Find a way to communicate why there is no preview, depending on the situation — MCO 22-01-2013'}

      if IsXML or IsHTML or IsCustom then begin
        CodePage := SendMessage(hScintilla, SCI_GETCODEPAGE, 0, 0);
        Size := SendMessage(hScintilla, SCI_GETTEXT, 0, 0);
        SetLength(Content, Size);
        SendMessage(hScintilla, SCI_GETTEXT, Size, LPARAM(PAnsiChar(Content)));
        if CodePage = CP_ACP then begin
          HTML := string(PAnsiChar(Content));
        end else begin
          SetLength(HTML, Size);
          if Size > 0 then begin
            SetLength(HTML, MultiByteToWideChar(CodePage, 0, PAnsiChar(Content), Size, PWideChar(HTML), Length(HTML)));
            if Length(HTML) = 0 then
              RaiseLastOSError;
          end;
        end;
      end;

      if IsCustom then begin
//MessageBox(Npp.NppData.NppHandle, PChar(Format('FilterName: %s', [FilterName])), 'PreviewHTML', MB_ICONINFORMATION);
        wbIEStatusTextChange(wbIE, Format('Running filter %s...', [FilterName]));
        if ExecuteCustomFilter(FilterName, HTML, BufferID) then begin
          Exit;