Browse Source

+ colors for HTML help by Gabor

pierre 25 years ago
parent
commit
20ac91ce38
7 changed files with 203 additions and 77 deletions
  1. 9 2
      ide/text/fpconst.pas
  2. 23 1
      ide/text/fphelp.pas
  3. 11 2
      ide/text/fpmopts.inc
  4. 10 1
      ide/text/fpstre.inc
  5. 10 1
      ide/text/fpstrh.inc
  6. 7 1
      ide/text/whelp.pas
  7. 133 69
      ide/text/whlpview.pas

+ 9 - 2
ide/text/fpconst.pas

@@ -371,6 +371,8 @@ const
 
      CFPCodeMemo    = #26#26#26#28#26#29#26#26#26#27#26#26#26#26#26#26#26;
 
+     CHTMLSectionAttrs = #229#230#231#232#233#234;
+
      CIDEAppColor = CAppColor +
          { CIDEHelpDialog }
 {128-143}#$70#$7F#$7A#$13#$13#$70#$70#$7F#$7E#$20#$2B#$2F#$78#$2E#$70#$30 + { 1-16}
@@ -386,14 +388,19 @@ const
          { CFPClockView }
 {227-227}#$70 +
          { CToolTip }
-{228-228}#$20;
+{228-228}#$20 +
+         { CHTMLSectionAttrs }
+{229-234}#$ff#$3a#$37#$ff#$ff#$ff;
 
 implementation
 
 END.
 {
   $Log$
-  Revision 1.38  2000-05-02 08:42:27  pierre
+  Revision 1.39  2000-05-30 07:18:33  pierre
+   + colors for HTML help by Gabor
+
+  Revision 1.38  2000/05/02 08:42:27  pierre
    * new set of Gabor changes: see fixes.txt
 
   Revision 1.37  2000/04/25 08:42:33  pierre

+ 23 - 1
ide/text/fphelp.pas

@@ -431,8 +431,27 @@ begin
   PAdvancedStatusLine(StatusLine)^.ClearStatusText;
 end;
 
+function FPHTMLGetSectionColor(Section: THTMLSection; var Color: byte): boolean;
+var OK: boolean;
+    S: string;
+begin
+  Color:=0;
+  OK:=(ord(Section) in [1..length(CHTMLSectionAttrs)]);
+  if OK then
+  begin
+    S:=#0;
+    S:=copy(CHTMLSectionAttrs,ord(Section),1);
+    if Assigned(Application)=false then Color:=0 else
+    Color:=Application^.GetColor(ord(S[1]));
+    if (Color and $0f) = ((Color and $f0) shr 4) then { same color ? }
+      OK:=false;
+  end;
+  FPHTMLGetSectionColor:=OK;
+end;
+
 procedure InitHelpFiles;
 begin
+  HTMLGetSectionColor:={$ifdef FPC}@{$endif}FPHTMLGetSectionColor;
   New(HelpFiles, Init(10,10));
 end;
 
@@ -459,7 +478,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.31  2000-05-29 10:44:56  pierre
+  Revision 1.32  2000-05-30 07:18:33  pierre
+   + colors for HTML help by Gabor
+
+  Revision 1.31  2000/05/29 10:44:56  pierre
    + New bunch of Gabor's changes: see fixes.txt
 
   Revision 1.30  2000/05/02 08:42:27  pierre

+ 11 - 2
ide/text/fpmopts.inc

@@ -1134,7 +1134,13 @@ begin
       ColorItem(label_colors_helplinks      , 161,
       ColorItem(label_colors_selectedlink   , 162,
       ColorItem(label_colors_selectedtext   , 163,
-      nil))))))))),
+      ColorItem(label_colors_html_heading1  , 229,
+      ColorItem(label_colors_html_heading2  , 230,
+      ColorItem(label_colors_html_heading3  , 231,
+      ColorItem(label_colors_html_heading4  , 232,
+      ColorItem(label_colors_html_heading5  , 233,
+      ColorItem(label_colors_html_heading6  , 234,
+      nil))))))))))))))),
     ColorGroup(label_colors_grp_menus,   MenuColorItems(nil),
     ColorGroup(label_colors_grp_syntax,
       ColorItem(label_colors_whitespace      , 200,
@@ -1208,7 +1214,10 @@ end;
 
 {
   $Log$
-  Revision 1.33  2000-05-02 08:42:28  pierre
+  Revision 1.34  2000-05-30 07:18:33  pierre
+   + colors for HTML help by Gabor
+
+  Revision 1.33  2000/05/02 08:42:28  pierre
    * new set of Gabor changes: see fixes.txt
 
   Revision 1.32  2000/04/25 08:42:33  pierre

+ 10 - 1
ide/text/fpstre.inc

@@ -462,6 +462,12 @@ const
       label_colors_symbols = 'Symbols';
       label_colors_directives = 'Directives';
       label_colors_tabs = 'Tabs';
+      label_colors_html_heading1 = 'HTML Heading 1';
+      label_colors_html_heading2 = 'HTML Heading 2';
+      label_colors_html_heading3 = 'HTML Heading 3';
+      label_colors_html_heading4 = 'HTML Heading 4';
+      label_colors_html_heading5 = 'HTML Heading 5';
+      label_colors_html_heading6 = 'HTML Heading 6';
 
       dialog_linker = 'Linker';
       label_linker_preferredlibtype = 'Preferred library type';
@@ -944,7 +950,10 @@ const
 
 {
   $Log$
-  Revision 1.2  2000-05-29 10:44:57  pierre
+  Revision 1.3  2000-05-30 07:18:33  pierre
+   + colors for HTML help by Gabor
+
+  Revision 1.2  2000/05/29 10:44:57  pierre
    + New bunch of Gabor's changes: see fixes.txt
 
   Revision 1.1  2000/05/02 08:42:28  pierre

+ 10 - 1
ide/text/fpstrh.inc

@@ -462,6 +462,12 @@ const
       label_colors_symbols = 'Szimb¢lumok';
       label_colors_directives = 'Direkt¡v k';
       label_colors_tabs = 'Tabul torok';
+      label_colors_html_heading1 = 'HTML Heading 1';
+      label_colors_html_heading2 = 'HTML Heading 2';
+      label_colors_html_heading3 = 'HTML Heading 3';
+      label_colors_html_heading4 = 'HTML Heading 4';
+      label_colors_html_heading5 = 'HTML Heading 5';
+      label_colors_html_heading6 = 'HTML Heading 6';
 
       dialog_linker = 'Linker';
       label_linker_preferredlibtype = 'Preferr lt k”nyvt r-t¡pus';
@@ -944,7 +950,10 @@ const
 
 {
   $Log$
-  Revision 1.2  2000-05-29 10:44:57  pierre
+  Revision 1.3  2000-05-30 07:18:33  pierre
+   + colors for HTML help by Gabor
+
+  Revision 1.2  2000/05/29 10:44:57  pierre
    + New bunch of Gabor's changes: see fixes.txt
 
   Revision 1.1  2000/05/02 08:42:28  pierre

+ 7 - 1
ide/text/whelp.pas

@@ -49,6 +49,9 @@ const
       hscCenter      = #10;
       hscRight       = #11;
       hscNamedMark   = #12;
+      hscTextAttr    = #13;
+      hscTextColor   = #14;
+      hscNormText    = #15;
 
 type
       FileStamp      = array [0..32] of char; {+ null terminator + $1A }
@@ -1124,7 +1127,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.20  2000-05-29 10:44:59  pierre
+  Revision 1.21  2000-05-30 07:18:33  pierre
+   + colors for HTML help by Gabor
+
+  Revision 1.20  2000/05/29 10:44:59  pierre
    + New bunch of Gabor's changes: see fixes.txt
 
   Revision 1.19  2000/04/25 08:42:35  pierre

+ 133 - 69
ide/text/whlpview.pas

@@ -52,6 +52,7 @@ type
       THelpColorArea = record
         Color    : byte;
         Bounds   : TRect;
+        AttrMask : byte;
       end;
 
       PHelpKeyword = ^THelpKeyword;
@@ -122,6 +123,7 @@ type
         function    GetColorAreaCount: sw_integer; virtual;
         procedure   GetColorAreaBounds(Index: sw_integer; var R: TRect); virtual;
         function    GetColorAreaColor(Index: sw_integer): word; virtual;
+        function    GetColorAreaMask(Index: sw_integer): word; virtual;
         destructor  Done; virtual;
       private
         Width,Margin: sw_integer;
@@ -158,6 +160,7 @@ type
         function    GetColorAreaCount: sw_integer; virtual;
         procedure   GetColorAreaBounds(Index: sw_integer; var R: TRect); virtual;
         function    GetColorAreaColor(Index: sw_integer): word; virtual;
+        function    GetColorAreaMask(Index: sw_integer): word; virtual;
         procedure   SelectNextLink(ANext: boolean); virtual;
         procedure   SwitchToIndex; virtual;
         procedure   SwitchToTopic(SourceFileID: word; Context: THelpCtx); virtual;
@@ -228,11 +231,12 @@ begin
   if P<>nil then Dispose(P);
 end;
 
-function NewColorArea(Color: byte; StartP, EndP: TPoint): PHelpColorArea;
+function NewColorArea(Color, AttrMask: byte; StartP, EndP: TPoint): PHelpColorArea;
 var P: PHelpColorArea;
 begin
   New(P); FillChar(P^, SizeOf(P^), 0);
-  P^.Color:=Color; P^.Bounds.A:=StartP; P^.Bounds.B:=EndP;
+  P^.Color:=Color; P^.AttrMask:=AttrMask;
+  P^.Bounds.A:=StartP; P^.Bounds.B:=EndP;
   NewColorArea:=P;
 end;
 
@@ -409,13 +413,17 @@ procedure THelpTopic.ReBuild;
 var TextPos,LinkNo,NamedMarkNo: sw_word;
     Line,CurWord: string;
     C: char;
-    InLink,InColorArea: boolean;
-    LinkStart,LinkEnd,ColorAreaStart,ColorAreaEnd: TPoint;
+    InLink,InCodeArea,InColorArea: boolean;
+    LinkStart,LinkEnd,CodeAreaStart,CodeAreaEnd: TPoint;
+    ColorAreaStart,ColorAreaEnd: TPoint;
+    ColorAreaType: (atText,atFull);
     CurPos: TPoint;
     ZeroLevel: sw_integer;
     LineStart,NextLineStart: sw_integer;
     LineAlign : (laLeft,laCenter,laRight);
     FirstLink,LastLink: sw_integer;
+    AreaColor: word;
+    NextByte: (nbNormal,nbAreaColor);
 procedure ClearLine;
 begin
   Line:='';
@@ -485,80 +493,116 @@ begin
        ZeroLevel:=0;
      end;
 end;
+procedure EndColorArea;
+var Mask: word;
 begin
-  Lines^.FreeAll; Links^.FreeAll; NamedMarks^.FreeAll;
+  if ColorAreaType=atText then Mask:=$f0 else Mask:=$00;
+  if CurWord<>'' then AddWord(CurWord); CurWord:='';
+  ColorAreaEnd:=CurPos; Dec(ColorAreaEnd.X);
+  ColorAreas^.Insert(NewColorArea(AreaColor,Mask,ColorAreaStart,ColorAreaEnd));
+  InColorArea:=false; AreaColor:=0;
+end;
+begin
+  Lines^.FreeAll; Links^.FreeAll; NamedMarks^.FreeAll; ColorAreas^.FreeAll;
   if Topic=nil then Lines^.Insert(NewStr('No help available for this topic.')) else
   begin
     LineStart:=0; NextLineStart:=0;
     TextPos:=0; ClearLine; CurWord:=''; Line:='';
     CurPos.X:=Margin+LineStart; CurPos.Y:=0; LinkNo:=0;
     NamedMarkNo:=0;
-    InLink:=false; InColorArea:=false; ZeroLevel:=0;
+    InLink:=false; InCodeArea:=false; InColorArea:=false; ZeroLevel:=0;
     LineAlign:=laLeft;
-    FirstLink:=0; LastLink:=0;
+    FirstLink:=0; LastLink:=0; NextByte:=nbNormal;
     while (TextPos<Topic^.TextSize) do
     begin
       C:=chr(PByteArray(Topic^.Text)^[TextPos]);
-      case C of
-        hscLineBreak :
-            {if ZeroLevel=0 then ZeroLevel:=1 else
-                begin FlushLine; FlushLine; ZeroLevel:=0; end;}
-             if InLink then CurWord:=CurWord+' ' else
-               begin
-                 NextLineStart:=0;
-                 FlushLine;
-                 LineStart:=0;
-                 LineAlign:=laLeft;
-               end;
-        #1 : Break;
-        hscLink :
-             begin
-               CheckZeroLevel;
-               if InLink=false then
-                  begin LinkStart:=CurPos; InLink:=true; end else
-                begin
-                  if CurWord<>'' then AddWord(CurWord); CurWord:='';
-                  LinkEnd:=CurPos; Dec(LinkEnd.X);
-                  if Topic^.Links<>nil then
-                    begin
-                      Inc(LastLink);
-                      if LinkNo<Topic^.LinkCount then
-                      Links^.Insert(NewLink(Topic^.Links^[LinkNo].FileID,
-                        Topic^.Links^[LinkNo].Context,LinkStart,LinkEnd));
-                      Inc(LinkNo);
+      case NextByte of
+        nbAreaColor :
+          begin
+            AreaColor:=ord(C);
+            NextByte:=nbNormal;
+          end;
+        nbNormal :
+          begin
+            case C of
+              hscLineBreak :
+                  {if ZeroLevel=0 then ZeroLevel:=1 else
+                      begin FlushLine; FlushLine; ZeroLevel:=0; end;}
+                   if InLink then CurWord:=CurWord+' ' else
+                     begin
+                       NextLineStart:=0;
+                       FlushLine;
+                       LineStart:=0;
+                       LineAlign:=laLeft;
+                     end;
+              #1 : Break;
+              hscLink :
+                   begin
+                     CheckZeroLevel;
+                     if InLink=false then
+                        begin LinkStart:=CurPos; InLink:=true; end else
+                      begin
+                        if CurWord<>'' then AddWord(CurWord); CurWord:='';
+                        LinkEnd:=CurPos; Dec(LinkEnd.X);
+                        if Topic^.Links<>nil then
+                          begin
+                            Inc(LastLink);
+                            if LinkNo<Topic^.LinkCount then
+                            Links^.Insert(NewLink(Topic^.Links^[LinkNo].FileID,
+                              Topic^.Links^[LinkNo].Context,LinkStart,LinkEnd));
+                            Inc(LinkNo);
+                          end;
+                        InLink:=false;
+                      end;
                     end;
-                  InLink:=false;
-                end;
-              end;
-        hscLineStart :
-             begin
-               NextLineStart:=length(Line)+length(CurWord);
-{               LineStart:=LineStart+(NextLineStart-LineStart);}
-             end;
-        hscCode :
-             begin
-               if InColorArea=false then
-                  ColorAreaStart:=CurPos else
-                begin
-                  if CurWord<>'' then AddWord(CurWord); CurWord:='';
-                  ColorAreaEnd:=CurPos; Dec(ColorAreaEnd.X);
-                  ColorAreas^.Insert(NewColorArea(CommentColor,ColorAreaStart,ColorAreaEnd));
-                end;
-               InColorArea:=not InColorArea;
-             end;
-        hscCenter :
-             LineAlign:=laCenter;
-        hscRight  :
-             LineAlign:=laCenter;
-        hscNamedMark :
-             begin
-               if NamedMarkNo<Topic^.NamedMarks^.Count then
-                 NamedMarks^.Add(GetStr(Topic^.NamedMarks^.At(NamedMarkNo)),CurPos);
-               Inc(NamedMarkNo);
-             end;
-        #32: if InLink then CurWord:=CurWord+C else
-                begin CheckZeroLevel; AddWord(CurWord+C); CurWord:=''; end;
-      else begin CheckZeroLevel; CurWord:=CurWord+C; end;
+              hscLineStart :
+                   begin
+                     NextLineStart:=length(Line)+length(CurWord);
+      {               LineStart:=LineStart+(NextLineStart-LineStart);}
+                   end;
+              hscCode :
+                   begin
+                     if InCodeArea=false then
+                        CodeAreaStart:=CurPos else
+                      begin
+                        if CurWord<>'' then AddWord(CurWord); CurWord:='';
+                        CodeAreaEnd:=CurPos; Dec(CodeAreaEnd.X);
+                        ColorAreas^.Insert(NewColorArea(CommentColor,$f0,CodeAreaStart,CodeAreaEnd));
+                      end;
+                     InCodeArea:=not InCodeArea;
+                   end;
+              hscCenter :
+                   LineAlign:=laCenter;
+              hscRight  :
+                   LineAlign:=laCenter;
+              hscNamedMark :
+                   begin
+                     if NamedMarkNo<Topic^.NamedMarks^.Count then
+                       NamedMarks^.Add(GetStr(Topic^.NamedMarks^.At(NamedMarkNo)),CurPos);
+                     Inc(NamedMarkNo);
+                   end;
+              hscTextAttr,hscTextColor :
+                   begin
+                     if InColorArea then
+                       EndColorArea;
+                     if C=hscTextAttr then
+                       ColorAreaType:=atFull
+                     else
+                       ColorAreaType:=atText;
+                     NextByte:=nbAreaColor;
+                     ColorAreaStart:=CurPos;
+                     InColorArea:=true;
+                   end;
+              hscNormText :
+                   begin
+                     if InColorArea then
+                       EndColorArea;
+                   end;
+              #32: if InLink then CurWord:=CurWord+C else
+                      begin CheckZeroLevel; AddWord(CurWord+C); CurWord:=''; end;
+            else begin CheckZeroLevel; CurWord:=CurWord+C; end;
+            end;
+          end;
       end;
       CurPos.X:=Margin+length(Line)+length(CurWord);
       Inc(TextPos);
@@ -624,6 +668,13 @@ begin
   GetColorAreaColor:=P^.Color;
 end;
 
+function THelpTopic.GetColorAreaMask(Index: sw_integer): word;
+var P: PHelpColorArea;
+begin
+  P:=ColorAreas^.At(Index);
+  GetColorAreaMask:=P^.AttrMask;
+end;
+
 destructor THelpTopic.Done;
 begin
   inherited Done;
@@ -767,6 +818,11 @@ begin
   GetColorAreaColor:=HelpTopic^.GetColorAreaColor(Index);
 end;
 
+function THelpViewer.GetColorAreaMask(Index: sw_integer): word;
+begin
+  GetColorAreaMask:=HelpTopic^.GetColorAreaMask(Index);
+end;
+
 procedure THelpViewer.SelectNextLink(ANext: boolean);
 var I,Link: sw_integer;
     R: TRect;
@@ -1058,8 +1114,9 @@ var NormalColor, LinkColor,
 {$ifndef EDITORS}
     SelR : TRect;
 {$endif}
-    C: word;
+    C,Mask: word;
     CurP: TPoint;
+    ANDSB,ORSB: word;
 begin
   if LockFlag>0 then
     begin
@@ -1095,6 +1152,7 @@ begin
         if (R.A.Y<=Y) and (Y<=R.B.Y) then
         begin
           C:=GetColorAreaColor(I);
+          Mask:=GetColorAreaMask(I);
           for DX:=MinX to MaxX do
           begin
             X:=DX;
@@ -1103,7 +1161,10 @@ begin
             begin
 {              CurP.X:=X; CurP.Y:=Y;
               if LinkAreaContainsPoint(R,CurP) then}
-              B[ScreenX]:=(B[ScreenX] and $f0ff) or (C shl 8);
+(*              B[ScreenX]:=(B[ScreenX] and $f0ff) or (C shl 8);*)
+              ANDSB:=(Mask shl 8)+$ff;
+              ORSB:=(C shl 8);
+              B[ScreenX]:=(B[ScreenX] and ANDSB) or ORSB;
             end;
           end;
         end;
@@ -1257,7 +1318,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.15  2000-05-29 10:45:00  pierre
+  Revision 1.16  2000-05-30 07:18:33  pierre
+   + colors for HTML help by Gabor
+
+  Revision 1.15  2000/05/29 10:45:00  pierre
    + New bunch of Gabor's changes: see fixes.txt
 
   Revision 1.14  2000/04/25 08:42:35  pierre