Browse Source

* try to enhance dispaly of new html docs

pierre 22 years ago
parent
commit
870e9ca269
2 changed files with 61 additions and 15 deletions
  1. 11 2
      ide/whtml.pas
  2. 50 13
      ide/whtmlhlp.pas

+ 11 - 2
ide/whtml.pas

@@ -294,7 +294,12 @@ begin
       Inc(LinePos);
       Inc(LinePos);
 
 
     end;
     end;
-  if WasThereAnyText then DocSoftBreak;
+  { whtml does not depend on whelp,
+    so I can not use hscLineBreak here. PM }
+  if InTag and InString then
+    CurTag:=CurTag+#0
+  else if WasThereAnyText then DocSoftBreak;
+
   ProcessLine:=true;
   ProcessLine:=true;
 end;
 end;
 
 
@@ -458,6 +463,7 @@ begin
   if (Code=253) or (Name='yacute') then E:='y'   else { small y, acute accent         }
   if (Code=253) or (Name='yacute') then E:='y'   else { small y, acute accent         }
 (*  if (Code=254) or (Name='thorn')  then E:='?'   else { small thorn, Icelandic        }*)
 (*  if (Code=254) or (Name='thorn')  then E:='?'   else { small thorn, Icelandic        }*)
   if (Code=255) or (Name='yuml')   then E:='y'   else { small y, dieresis or umlaut   }
   if (Code=255) or (Name='yuml')   then E:='y'   else { small y, dieresis or umlaut   }
+  if (Code=8217) then E:=''''   else                  { acute accent as generated by TeXH   }
   Found:=false;
   Found:=false;
   DocDecodeNamedEntity:=Found;
   DocDecodeNamedEntity:=Found;
 end;
 end;
@@ -717,7 +723,10 @@ end;
 END.
 END.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2002-09-07 15:40:49  peter
+  Revision 1.5  2003-03-27 14:37:24  pierre
+   * try to enhance dispaly of new html docs
+
+  Revision 1.4  2002/09/07 15:40:49  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
   Revision 1.3  2002/03/25 14:42:23  pierre
   Revision 1.3  2002/03/25 14:42:23  pierre

+ 50 - 13
ide/whtmlhlp.pas

@@ -135,9 +135,10 @@ type
 {      Anchor: TAnchor;}
 {      Anchor: TAnchor;}
       { Table stuff }
       { Table stuff }
       CurrentTable : PTable;
       CurrentTable : PTable;
-      procedure AddText(S: string);
+      procedure AddText(const S: string);
       procedure AddChar(C: char);
       procedure AddChar(C: char);
       procedure AddCharAt(C: char;AtPtr : sw_word);
       procedure AddCharAt(C: char;AtPtr : sw_word);
+      function AddTextAt(const S: string;AtPtr : sw_word) : sw_word;
     end;
     end;
 
 
     PCustomHTMLHelpFile = ^TCustomHTMLHelpFile;
     PCustomHTMLHelpFile = ^TCustomHTMLHelpFile;
@@ -279,13 +280,10 @@ end;
 
 
 procedure TTable.TextInsert(Pos : sw_word;const S : string);
 procedure TTable.TextInsert(Pos : sw_word;const S : string);
 var
 var
-  i : longint;
+  i : sw_word;
 begin
 begin
-  for i:=1 to Length(S) do
-    begin
-      Renderer^.AddCharAt(S[i],Pos+i-1+GlobalOffset);
-    end;
-  GlobalOffset:=GlobalOffset+length(S);
+  i:=Renderer^.AddTextAt(S[i],Pos+GlobalOffset);
+  GlobalOffset:=GlobalOffset+i;
 end;
 end;
 
 
 procedure TTable.FormatTable;
 procedure TTable.FormatTable;
@@ -349,7 +347,10 @@ begin
             begin
             begin
               TextBegin:=CurEl^.TextBegin;
               TextBegin:=CurEl^.TextBegin;
               TextEnd:=CurEl^.TextEnd;
               TextEnd:=CurEl^.TextEnd;
-              Length:=CurEl^.TextEnd-CurEl^.TextBegin;
+              While (TextEnd>TextBegin) and
+                    (Renderer^.Topic^.Text^[TextEnd+GlobalOffset]=ord(hscLineBreak)) do
+                dec(TextEnd);
+              Length:=TextEnd-TextBegin;
               Align:=CurEl^.Alignment;
               Align:=CurEl^.Alignment;
             end;
             end;
           if WithBorder then
           if WithBorder then
@@ -708,7 +709,7 @@ var Src,Alt,SrcLine: string;
     f : text;
     f : text;
     attr : byte;
     attr : byte;
     PA : PHTMLAnsiView;
     PA : PHTMLAnsiView;
-
+    StorePreformatted : boolean;
 begin
 begin
   if DocGetTagParam('SRC',src) then
   if DocGetTagParam('SRC',src) then
     begin
     begin
@@ -724,11 +725,12 @@ begin
               PA:=New(PHTMLAnsiView,init(@self));
               PA:=New(PHTMLAnsiView,init(@self));
               PA^.LoadFile(src);
               PA^.LoadFile(src);
               if AnyCharsInLine then DocBreak;
               if AnyCharsInLine then DocBreak;
+              StorePreformatted:=InPreformatted;
               InPreformatted:=true;
               InPreformatted:=true;
               {AddText('Image from '+src+hscLineBreak); }
               {AddText('Image from '+src+hscLineBreak); }
               AddChar(hscInImage);
               AddChar(hscInImage);
               PA^.CopyToHTML;
               PA^.CopyToHTML;
-              InPreformatted:=false;
+              InPreformatted:=StorePreformatted;
               AddChar(hscInImage);
               AddChar(hscInImage);
               AddChar(hscNormText);
               AddChar(hscNormText);
               if AnyCharsInLine then DocBreak;
               if AnyCharsInLine then DocBreak;
@@ -763,7 +765,13 @@ begin
     end;
     end;
   if Alt<>'' then
   if Alt<>'' then
     begin
     begin
+      StorePreformatted:=InPreformatted;
+      InPreformatted:=true;
+      AddChar(hscInImage);
       AddText('['+Alt+']');
       AddText('['+Alt+']');
+      AddChar(hscInImage);
+      AddChar(hscNormText);
+      InPreformatted:=StorePreformatted;
     end;
     end;
 end;
 end;
 
 
@@ -922,7 +930,8 @@ var
 begin
 begin
   if Entered then
   if Entered then
     begin
     begin
-      if assigned(CurrentTable^.LastLine) and Assigned(CurrentTable^.LastLine^.LastEl) then
+      if assigned(CurrentTable^.LastLine) and Assigned(CurrentTable^.LastLine^.LastEl) and
+         (CurrentTable^.LastLine^.LastEl^.TextEnd=-1) then
         begin
         begin
           NewEl:=CurrentTable^.LastLine^.LastEl;
           NewEl:=CurrentTable^.LastLine^.LastEl;
           NewEl^.TextEnd:=TextPtr;
           NewEl^.TextEnd:=TextPtr;
@@ -933,6 +942,7 @@ begin
       New(NewEl,Init(PAlignEl));
       New(NewEl,Init(PAlignEl));
       CurrentTable^.AddElement(NewEl);
       CurrentTable^.AddElement(NewEl);
       NewEl^.TextBegin:=TextPtr;
       NewEl^.TextBegin:=TextPtr;
+      NewEl^.TextEnd:=-1;
       { AddText(' - ');}
       { AddText(' - ');}
     end
     end
   else
   else
@@ -975,13 +985,37 @@ begin
   Inc(TextPtr);
   Inc(TextPtr);
 end;
 end;
 
 
-procedure THTMLTopicRenderer.AddText(S: string);
+procedure THTMLTopicRenderer.AddText(const S: string);
 var I: sw_integer;
 var I: sw_integer;
 begin
 begin
   for I:=1 to length(S) do
   for I:=1 to length(S) do
     AddChar(S[I]);
     AddChar(S[I]);
 end;
 end;
 
 
+function THTMLTopicRenderer.AddTextAt(const S: String;AtPtr : sw_word) : sw_word;
+var
+  i,slen,len : sw_word;
+begin
+  if (Topic=nil) or (TextPtr>=MaxBytes) then Exit;
+  slen:=length(s);
+  if TextPtr+slen>=MaxBytes then
+    slen:=MaxBytes-TextPtr;
+  if AtPtr>TextPtr then
+    AtPtr:=TextPtr
+  else
+    begin
+      len:=TextPtr-AtPtr;
+      Move(Topic^.Text^[AtPtr],Topic^.Text^[AtPtr+slen],len);
+    end;
+  for i:=1 to slen do
+    begin
+      Topic^.Text^[AtPtr]:=ord(S[i]);
+      Inc(TextPtr);
+      if (TextPtr=MaxBytes) then Exit;
+    end;
+  AddTextAt:=slen;
+end;
+
 function THTMLTopicRenderer.GetSectionColor(Section: THTMLSection; var Color: byte): boolean;
 function THTMLTopicRenderer.GetSectionColor(Section: THTMLSection; var Color: byte): boolean;
 begin
 begin
   GetSectionColor:=HTMLGetSectionColor(Section,Color);
   GetSectionColor:=HTMLGetSectionColor(Section,Color);
@@ -1233,7 +1267,10 @@ end;
 END.
 END.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2002-09-07 15:40:49  peter
+  Revision 1.7  2003-03-27 14:37:52  pierre
+   * try to enhance dispaly of new html docs
+
+  Revision 1.6  2002/09/07 15:40:49  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
   Revision 1.5  2002/04/23 09:55:22  pierre
   Revision 1.5  2002/04/23 09:55:22  pierre