Browse Source

+ New bunch of Gabor's changes: see fixes.txt

pierre 25 years ago
parent
commit
ad755d7fb1
3 changed files with 70 additions and 20 deletions
  1. 30 11
      ide/text/whtmlhlp.pas
  2. 11 3
      ide/text/whtmlscn.pas
  3. 29 6
      ide/text/wutils.pas

+ 30 - 11
ide/text/whtmlhlp.pas

@@ -8,7 +8,7 @@ const
      ListIndent = 2;
      DefIndent  = 4;
 
-     MaxTopicLinks = 500; { maximum link on a single HTML page }
+     MaxTopicLinks = 5000; { maximum number of links on a single HTML page }
 
 type
     PTopicLinkCollection = ^TTopicLinkCollection;
@@ -239,20 +239,29 @@ begin
 end;
 
 procedure THTMLTopicRenderer.DocAnchor(Entered: boolean);
-var HRef: string;
+var HRef,Name: string;
 begin
   if Entered and InAnchor then DocAnchor(false);
   if Entered then
     begin
       if DocGetTagParam('HREF',HRef)=false then HRef:='';
-      if (HRef<>'') and (copy(HRef,1,1)<>'#') then
+      if DocGetTagParam('NAME',Name)=false then Name:='';
+      if Name<>'' then
         begin
-          InAnchor:=true;
-          AddChar(hscLink);
-          HRef:=CompleteURL(URL,HRef);
-          LinkIndexes[LinkPtr]:=TopicLinks^.AddItem(HRef);
-          Inc(LinkPtr);
-        end;
+          Topic^.NamedMarks^.InsertStr(Name);
+          AddChar(hscNamedMark);
+        end else
+      if (HRef<>'') then
+          begin
+            InAnchor:=true;
+            AddChar(hscLink);
+            if LinkPtr<MaxTopicLinks then
+            begin
+              HRef:=CompleteURL(URL,HRef);
+              LinkIndexes[LinkPtr]:=TopicLinks^.AddItem(HRef);
+              Inc(LinkPtr);
+            end;
+          end;
     end
   else
     begin
@@ -573,9 +582,10 @@ function TCustomHTMLHelpFile.ReadTopic(T: PTopic): boolean;
 var OK: boolean;
     HTMLFile: PMemoryTextFile;
     Name: string;
-    Link: string;
+    Link,Bookmark: string;
     P: sw_integer;
 begin
+  Bookmark:='';
   OK:=T<>nil;
   if OK then
     begin
@@ -583,7 +593,12 @@ begin
         begin
           Link:=TopicLinks^.At((T^.HelpCtx and $ffff)-1)^;
           Link:=FormatPath(Link);
-          P:=Pos('#',Link); if P>0 then Delete(Link,P,255);
+          P:=Pos('#',Link);
+          if P>0 then
+          begin
+            Bookmark:=copy(Link,P+1,length(Link));
+            Link:=copy(Link,1,P-1);
+          end;
 {          if CurFileName='' then Name:=Link else
           Name:=CompletePath(CurFileName,Link);}
           Name:=Link;
@@ -601,6 +616,10 @@ begin
       OK:=Renderer^.BuildTopic(T,Name,HTMLFile,TopicLinks);
       if OK then CurFileName:=Name;
       if HTMLFile<>nil then Dispose(HTMLFile, Done);
+      if BookMark='' then
+        T^.StartNamedMark:=0
+      else
+        T^.StartNamedMark:=T^.GetNamedMarkIndex(BookMark)+1;
     end;
   ReadTopic:=OK;
 end;

+ 11 - 3
ide/text/whtmlscn.pas

@@ -134,6 +134,7 @@ begin
 end;
 
 procedure TCustomHTMLLinkScanner.DocAnchor(Entered: boolean);
+var P: sw_integer;
 begin
   if Entered then
     begin
@@ -398,10 +399,14 @@ end;
 
 procedure THTMLFileLinkScanner.AddLink(const LinkText, LinkURL: string);
 var D: PHTMLLinkScanFile;
+    P: sw_integer;
+    DocURL: string;
 begin
-  D:=DocumentFiles^.SearchFile(LinkURL);
+  P:=Pos('#',LinkURL);
+  if P=0 then DocURL:=LinkURL else DocURL:=copy(LinkURL,1,P-1);
+  D:=DocumentFiles^.SearchFile(DocURL);
   if Assigned(D)=false then
-    ScheduleDoc(LinkURL);
+      ScheduleDoc(DocURL);
   inherited AddLink(LinkText,LinkURL);
 end;
 
@@ -444,7 +449,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.5  2000-05-17 08:49:16  pierre
+  Revision 1.6  2000-05-29 11:09:14  pierre
+   + New bunch of Gabor's changes: see fixes.txt
+
+  Revision 1.5  2000/05/17 08:49:16  pierre
    readded
 
   Revision 1.1  2000/04/25 08:42:32  pierre

+ 29 - 6
ide/text/wutils.pas

@@ -40,6 +40,7 @@ type
     procedure   FreeItem(Item: Pointer); virtual;
     function    GetItem(var S: TStream): Pointer; virtual;
     procedure   PutItem(var S: TStream; Item: Pointer); virtual;
+    procedure   InsertStr(const S: string);
   end;
 
   PNulStream = ^TNulStream;
@@ -530,6 +531,11 @@ begin
     ALines^.ForEach(@AddIt);
 end;
 
+procedure TUnsortedStringCollection.InsertStr(const S: string);
+begin
+  Insert(NewStr(S));
+end;
+
 function TUnsortedStringCollection.At(Index: Integer): PString;
 begin
   At:=inherited At(Index);
@@ -733,16 +739,30 @@ var P: integer;
     Drive: string[20];
     IsComplete: boolean;
     S: string;
+    Ref: string;
+    Bookmark: string;
 begin
-  IsComplete:=false;
-  P:=Pos(':',URLRef);
-  if P=0 then Drive:='' else Drive:=UpcaseStr(copy(URLRef,1,P-1));
+  IsComplete:=false; Ref:=URLRef;
+  P:=Pos(':',Ref);
+  if P=0 then Drive:='' else Drive:=UpcaseStr(copy(Ref,1,P-1));
   if Drive<>'' then
   if (Drive='MAILTO') or (Drive='FTP') or (Drive='HTTP') or
      (Drive='GOPHER') or (Drive='FILE') then
     IsComplete:=true;
-  if IsComplete then S:=URLRef else
-    S:=CompletePath(Base,URLRef);
+  if IsComplete then S:=Ref else
+  begin
+    P:=Pos('#',Ref);
+    if P=0 then
+      Bookmark:=''
+    else
+      begin
+        Bookmark:=copy(Ref,P+1,length(Ref));
+        Ref:=copy(Ref,1,P-1);
+      end;
+    S:=CompletePath(Base,Ref);
+    if Bookmark<>'' then
+      S:=S+'#'+Bookmark;
+  end;
   CompleteURL:=S;
 end;
 
@@ -889,7 +909,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.21  2000-05-02 08:42:29  pierre
+  Revision 1.22  2000-05-29 11:09:14  pierre
+   + New bunch of Gabor's changes: see fixes.txt
+
+  Revision 1.21  2000/05/02 08:42:29  pierre
    * new set of Gabor changes: see fixes.txt
 
   Revision 1.20  2000/04/25 08:42:36  pierre