mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 22:19:18 +02:00
much improved history support
git-svn-id: trunk@8375 -
This commit is contained in:
parent
b79a3c34cb
commit
753ea08fa2
@ -46,6 +46,7 @@ type
|
|||||||
TIpChmDataProvider = class(TIpAbstractHtmlDataProvider)
|
TIpChmDataProvider = class(TIpAbstractHtmlDataProvider)
|
||||||
private
|
private
|
||||||
fChm: TChmFileList;
|
fChm: TChmFileList;
|
||||||
|
fCurrentPage: String;
|
||||||
fCurrentPath: String;
|
fCurrentPath: String;
|
||||||
fOnHelpPopup: THelpPopupEvent;
|
fOnHelpPopup: THelpPopupEvent;
|
||||||
protected
|
protected
|
||||||
@ -65,7 +66,9 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
property Chm: TChmFileList read fChm write fChm;
|
property Chm: TChmFileList read fChm write fChm;
|
||||||
property OnHelpPopup: THelpPopupEvent read fOnHelpPopup write fOnHelpPopup;
|
property OnHelpPopup: THelpPopupEvent read fOnHelpPopup write fOnHelpPopup;
|
||||||
|
property CurrentPAge: String read fCurrentPage;
|
||||||
property CurrentPath: String read fCurrentPath write fCurrentPath;
|
property CurrentPath: String read fCurrentPath write fCurrentPath;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -88,14 +91,20 @@ end;
|
|||||||
|
|
||||||
function TIpChmDataProvider.DoCheckURL(const URL: string;
|
function TIpChmDataProvider.DoCheckURL(const URL: string;
|
||||||
var ContentType: string): Boolean;
|
var ContentType: string): Boolean;
|
||||||
|
var
|
||||||
|
X: Integer;
|
||||||
begin
|
begin
|
||||||
//DebugLn('RequestedUrl: ',URL);
|
//DebugLn('RequestedUrl: ',URL);
|
||||||
Result := fChm.ObjectExists(Url) > 0;
|
Result := fChm.ObjectExists(Url) > 0;
|
||||||
if Result then begin
|
if Result then begin
|
||||||
ContentType := 'text/html';
|
ContentType := 'text/html';
|
||||||
fCurrentPath := ExtractFilePath(Url);
|
fCurrentPath := ExtractFilePath(Url);
|
||||||
|
if Pos('ms-its:', fCurrentPath) > 0 then begin
|
||||||
|
X := Pos('::', fCurrentPath);
|
||||||
|
fCurrentPath := Copy(fCurrentPath, X+2, Length(fCurrentPAth)-(X+1));
|
||||||
|
end;
|
||||||
Result := True;
|
Result := True;
|
||||||
|
fCurrentPage := URL;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -191,12 +200,22 @@ var
|
|||||||
tmp: String;
|
tmp: String;
|
||||||
X: LongInt;
|
X: LongInt;
|
||||||
RelURL: String = '';
|
RelURL: String = '';
|
||||||
|
fOldUrl: String;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
if Pos('ms-its:', OldURL) > 0 then begin
|
||||||
|
X := Pos('::', OldUrl);
|
||||||
|
fOldUrl := Copy(OldUrl, X+2, Length(OldUrl)-(X+2));
|
||||||
|
end
|
||||||
|
else fOldUrl := OldURL;
|
||||||
|
|
||||||
|
if Length(NewURL) < 1 then Exit(NewURL);
|
||||||
if fChm.ObjectExists(NewURL) > 0 then begin
|
if fChm.ObjectExists(NewURL) > 0 then begin
|
||||||
Result := NewUrl;
|
Result := NewUrl;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
Result:=iputils.BuildURL(Oldurl,NewUrl);
|
Result:=iputils.BuildURL(fOldurl,NewUrl);
|
||||||
|
|
||||||
if NewURL[1] <> '/' then
|
if NewURL[1] <> '/' then
|
||||||
begin
|
begin
|
||||||
if fChm.ObjectExists(Result) > 0 then Tmp := Result
|
if fChm.ObjectExists(Result) > 0 then Tmp := Result
|
||||||
@ -208,6 +227,9 @@ begin
|
|||||||
end
|
end
|
||||||
else if fChm.ObjectExists(fCurrentPath+NewUrl) > 0 then begin
|
else if fChm.ObjectExists(fCurrentPath+NewUrl) > 0 then begin
|
||||||
Tmp := fCurrentPath+NewURL;
|
Tmp := fCurrentPath+NewURL;
|
||||||
|
end
|
||||||
|
else if fChm.ObjectExists('/'+fCurrentPath+NewUrl) > 0 then begin
|
||||||
|
Tmp := '/'+fCurrentPath+NewURL;
|
||||||
end;
|
end;
|
||||||
Result := Tmp;
|
Result := Tmp;
|
||||||
end;
|
end;
|
||||||
@ -216,6 +238,7 @@ begin
|
|||||||
Delete(Result, X ,1);
|
Delete(Result, X ,1);
|
||||||
X := Pos('//', Result);
|
X := Pos('//', Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TIpChmDataProvider.GetDirsParents(ADir: String): TStringList;
|
function TIpChmDataProvider.GetDirsParents(ADir: String): TStringList;
|
||||||
|
@ -104,11 +104,11 @@ type
|
|||||||
procedure FillTOCTimer(Sender: TObject);
|
procedure FillTOCTimer(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
|
fIsUsingHistory: Boolean;
|
||||||
fStopTimer: Boolean;
|
fStopTimer: Boolean;
|
||||||
fFillingToc: Boolean;
|
fFillingToc: Boolean;
|
||||||
fChms: TChmFileList;
|
fChms: TChmFileList;
|
||||||
fHistory: TStringList;
|
fHistory: TStringList;
|
||||||
fHotUrl: String;
|
|
||||||
fHistoryIndex: Integer;
|
fHistoryIndex: Integer;
|
||||||
fServerName: String;
|
fServerName: String;
|
||||||
fServer: TSimpleIPCServer;
|
fServer: TSimpleIPCServer;
|
||||||
@ -148,6 +148,7 @@ procedure THelpForm.BackToolBtnClick(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
if fHistoryIndex > 0 then begin
|
if fHistoryIndex > 0 then begin
|
||||||
Dec(fHistoryIndex);
|
Dec(fHistoryIndex);
|
||||||
|
fIsUsingHistory:=True;
|
||||||
IpHtmlPanel1.OpenURL(fHistory.Strings[fHistoryIndex]);
|
IpHtmlPanel1.OpenURL(fHistory.Strings[fHistoryIndex]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -214,7 +215,6 @@ end;
|
|||||||
procedure THelpForm.FormCreate(Sender: TObject);
|
procedure THelpForm.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
fContext := -1;
|
fContext := -1;
|
||||||
//Chm := TCHMFile.Create;
|
|
||||||
fHistory := TStringList.Create;
|
fHistory := TStringList.Create;
|
||||||
IpHtmlPanel1.DataProvider := TIpChmDataProvider.Create(fChms);
|
IpHtmlPanel1.DataProvider := TIpChmDataProvider.Create(fChms);
|
||||||
ReadCommandLineOptions;
|
ReadCommandLineOptions;
|
||||||
@ -227,6 +227,7 @@ procedure THelpForm.ForwardToolBtnClick(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
if fHistoryIndex < fHistory.Count-1 then begin
|
if fHistoryIndex < fHistory.Count-1 then begin
|
||||||
Inc(fHistoryIndex);
|
Inc(fHistoryIndex);
|
||||||
|
fIsUsingHistory:=True;
|
||||||
IpHtmlPanel1.OpenURL(fHistory.Strings[fHistoryIndex]);
|
IpHtmlPanel1.OpenURL(fHistory.Strings[fHistoryIndex]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -258,17 +259,19 @@ end;
|
|||||||
procedure THelpForm.IpHtmlPanel1DocumentOpen(Sender: TObject);
|
procedure THelpForm.IpHtmlPanel1DocumentOpen(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// StatusBar1.Panels.Items[1] := IpHtmlPanel1.DataProvider.;
|
// StatusBar1.Panels.Items[1] := IpHtmlPanel1.DataProvider.;
|
||||||
|
if fIsUsingHistory = False then
|
||||||
|
AddHistory(TIpChmDataProvider(IpHtmlPanel1.DataProvider).CurrentPage)
|
||||||
|
else fIsUsingHistory := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure THelpForm.IpHtmlPanel1HotChange(Sender: TObject);
|
procedure THelpForm.IpHtmlPanel1HotChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
StatusBar1.Panels.Items[0].Text := IpHtmlPanel1.HotURL;
|
StatusBar1.Panels.Items[0].Text := IpHtmlPanel1.HotURL;
|
||||||
fHotUrl := IpHtmlPanel1.HotURL;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure THelpForm.IpHtmlPanel1HotClick(Sender: TObject);
|
procedure THelpForm.IpHtmlPanel1HotClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
AddHistory(fHotUrl);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure THelpForm.PopupCopyClick(Sender: TObject);
|
procedure THelpForm.PopupCopyClick(Sender: TObject);
|
||||||
@ -450,6 +453,7 @@ procedure THelpForm.DoLoadUrl(Url: String; AChm: TChmReader = nil);
|
|||||||
begin
|
begin
|
||||||
if (fChms = nil) and (AChm = nil) then exit;
|
if (fChms = nil) and (AChm = nil) then exit;
|
||||||
if fChms.ObjectExists(Url, AChm) = 0 then Exit;
|
if fChms.ObjectExists(Url, AChm) = 0 then Exit;
|
||||||
|
fIsUsingHistory := True;
|
||||||
IpHtmlPanel1.OpenURL(Url);
|
IpHtmlPanel1.OpenURL(Url);
|
||||||
TIpChmDataProvider(IpHtmlPanel1.DataProvider).CurrentPath := ExtractFileDir(URL)+'/';
|
TIpChmDataProvider(IpHtmlPanel1.DataProvider).CurrentPath := ExtractFileDir(URL)+'/';
|
||||||
AddHistory(Url);
|
AddHistory(Url);
|
||||||
|
@ -445,7 +445,7 @@ begin
|
|||||||
fFreeStreamOnDestroy := FreeStreamOnDestroy;
|
fFreeStreamOnDestroy := FreeStreamOnDestroy;
|
||||||
ReadHeader;
|
ReadHeader;
|
||||||
if not IsValidFile then Exit;
|
if not IsValidFile then Exit;
|
||||||
FillDirectoryEntries(1000); // the default size of the array
|
FillDirectoryEntries(4096); // the default size of the array
|
||||||
fContextList := TContextList.Create;
|
fContextList := TContextList.Create;
|
||||||
ReadCommonData;
|
ReadCommonData;
|
||||||
end;
|
end;
|
||||||
@ -566,7 +566,7 @@ begin
|
|||||||
LookupPMGLchunk(EntriesBuffer, X, PMGLChunk);
|
LookupPMGLchunk(EntriesBuffer, X, PMGLChunk);
|
||||||
while EntriesBuffer.Position < ChunkStart + fDirectoryHeader.ChunkSize - PMGLChunk.UnusedSpace do begin
|
while EntriesBuffer.Position < ChunkStart + fDirectoryHeader.ChunkSize - PMGLChunk.UnusedSpace do begin
|
||||||
if fDirectoryEntriesCount >= DirEntrySize-1 then begin
|
if fDirectoryEntriesCount >= DirEntrySize-1 then begin
|
||||||
Inc(DirEntrySize, 1000);
|
Inc(DirEntrySize, 1024);
|
||||||
SetLength(fDirectoryEntries, DirEntrySize);
|
SetLength(fDirectoryEntries, DirEntrySize);
|
||||||
end;
|
end;
|
||||||
if ReadPMGLchunkEntryFromStream(EntriesBuffer, fDirectoryEntries[fDirectoryEntriesCount])
|
if ReadPMGLchunkEntryFromStream(EntriesBuffer, fDirectoryEntries[fDirectoryEntriesCount])
|
||||||
|
Loading…
Reference in New Issue
Block a user