home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / HLPSYS10.ZIP / HFTP.INT < prev    next >
Text File  |  1993-12-28  |  14KB  |  474 lines

  1. {************************************************************}
  2. {************************************************************}
  3. {**                                                        **}
  4. {**  Turbo Vision Demo                                     **}
  5. {**  Portions Copyright (c) 1992 by Borland International  **}
  6. {**  Portions Coypright (c) 1993 by KAP Holger Lembke      **}
  7. {**                                                        **}
  8. {************************************************************}
  9. {************************************************************}
  10.  
  11. {
  12. dt.
  13. KAP - Ergänzungen
  14. 22.12.93
  15.   ■ Seltener Fehler beim Zurücksteppen, wenn kein Link auf Seite
  16.       procedure MakeSelectVisible;
  17.       var D: TPoint;
  18.       begin
  19. **      if (selected=0) or (topic^.crossrefs=nil) then exit;
  20.  
  21.         if (locarray=nil) kap
  22.           then Topic^.GetCrossRef(Selected, KeyPoint, KeyLength, KeyRef)
  23. 18.09.93
  24.   ■ SELECTED im TStackRec (von Byte) auf Word geändert
  25.   ■ MAKEFOCUSVISIBLE Bereichsüberschreitung beim Suchen des Hotkeys
  26.     (while (p<>nil) !!and (count<=topic^.numrefs)!! do begin
  27. 16.09.93
  28.   ■ LASTPARAGRAPH:=NIL; in constructor THelpTopic.Load (Quelle: H.C.F.)
  29.     (Komisch, daß das nicht schon früher gestört hat....)
  30. 19.08.93
  31.   ■ Kontrolle der Streamregistrierung eingebaut. Wenn Hilfsstreams nicht
  32.     registriert, dann reagieren wichtige Objekte im Constructor mit FAIL.
  33. 10.08.93
  34.   ■ Kontrolle der Änderungen vom 8.-9.8.
  35.   ■ Topic link-Jumping eingebaut (MakefocusVisible)
  36. 09.08.93
  37.   ■ Markierung von Schaltflächen dramatisch beschleunigt (Handleevent)
  38.     (alles im Zuge des Deppen-Aufräumens)
  39. 08.08.93
  40.   ■ DRAW-Methode bei vielen Links dramatisch beschleunigt
  41.     (vorher muss ein Depp drangewesen sein...)
  42. 04.08.93
  43.   ■ compressor/decompressor optimiert
  44. 01.08.93
  45.   ■ compressor/decompressor
  46. 22.07.93
  47.   ■ modales Fenster ergänzt um "resizable dialog"
  48. 11.07.93
  49.   ■ Fehler in der thelpviewer.draw methode, wenn farbumschaltung
  50.     ausserhalb des sichtbereiches liegt. es wurde dann übersehen.
  51.     Folge: text war falsch befarbt...
  52.  
  53. 03.07.93
  54.   ■ Speichern der letzten Menüposition umgestellt
  55.  
  56. 02.06.93
  57.   ■ Verändertes Mono-Handling
  58.  
  59. 19.05.93
  60.   ■ Bugfix: Topic-Markierung und Farben in einer Zeile
  61.     Bugfix: Farbmarkierungen und horizontales Scrollen
  62.  
  63. 11.05.93
  64.   ■ Bugfix: thelpviewer.draw und mehrzeiliger Umbruch farbiger texte
  65.  
  66. 25.04.93
  67.   ■ Optimisierung bei "countcs" in THelpTopic.WrapText
  68.     (Die Darstellung bei vielen Topics ist immer noch recht träge.)
  69.  
  70. 21.04.93
  71.   ■ Bugfix: Zeilenumbruch bei langen Paragraphen
  72.  
  73. 20.04.93
  74.   ■ nicht-modale Hilfe merkt sich die Größe
  75.   ■ geänderte Farbe auch über Zeilenumbrüche hinweg
  76.  
  77. 19.04.93
  78.   ■ Umbau der THelpViewer.Draw-Methode
  79.     (incl. Änderungen in THelpTopic.WrapText)
  80.     - lock/unlock zur Darstellungsberuhigung
  81.     - zeichenweises Ablegen wg. Farbänderungen
  82.       methode: #n als Code, es ändert sich =nur= der Vordergrund
  83.                ## für #
  84.                #! für Rücksetzen auf Dialogfarbe
  85.  
  86. 16.04.93
  87.   ■ Alt-F1 focusiert letztes focusiertes topic
  88.  
  89. 15.04.93
  90.   ■ modales Fenster wird in anderem Farbset dargestellt als nicht-modales
  91.   ■ Alt-F1 für Help-History
  92.   ■ Shift-F1 für Hilfe über Hilfe
  93.  
  94. 14.04.93
  95.   ■ Unterscheidung zwischen modaler und nicht-modaler Hilfe
  96.  
  97.  
  98. eng.
  99. 22.12.93
  100.   ■ rare error with "last help", if last page has no link
  101.       procedure MakeSelectVisible;
  102.       var D: TPoint;
  103.       begin
  104. **      if (selected=0) or (topic^.crossrefs=nil) then exit;
  105.  
  106.         if (locarray=nil) kap
  107.           then Topic^.GetCrossRef(Selected, KeyPoint, KeyLength, KeyRef)
  108.  
  109. 18.09.93
  110.   ■ SELECTED at TStackRec (from Byte) changed to Word
  111.   ■ MAKEFOCUSVISIBLE range-error when searching the hotkey
  112.     (while (p<>nil) !!and (count<=topic^.numrefs)!! do begin
  113. 16.09.93
  114.   ■ LASTPARAGRAPH:=NIL; at constructor THelpTopic.Load (Quelle: H.C.F.)
  115.     (funny, that this hadn't disturbed earlyer....)
  116. 19.08.93
  117.   ■ check of stream-registration inserted. if stream is not registered,
  118.     importend constructors will FAIL.
  119. 10.08.93
  120.   ■ check of changes from 8.-9.8.
  121.   ■ Topic link-Jumping einserted (MakefocusVisible)
  122. 09.08.93
  123.   ■ dramaticly increase of link-selection (Handleevent)
  124.     (again: tiding up after the fool)
  125. 08.08.93
  126.   ■ DRAW-methode inceased when lot of links are shown
  127.     (must been programed by a fool.....)
  128. 04.08.93
  129.   ■ compressor/decompressor optimized
  130. 01.08.93
  131.   ■ compressor/decompressor
  132. 22.07.93
  133.   ■ added "resizable dialog" to modalar view
  134. 11.07.93
  135.   ■ fixed error inside thelpviewer.draw methode, if colorchange is outside
  136.     the visible range, it was missed then.
  137.     result: text has wrong color...
  138.  
  139. 03.07.93
  140.   ■ change: storing the last menueposition
  141.  
  142. 02.06.93
  143.   ■ change: mono-handling
  144.  
  145. 19.05.93
  146.   ■ Bugfix: link-color and color of a line of text
  147.     Bugfix: color and horizontal scrolling
  148.  
  149. 11.05.93
  150.   ■ Bugfix: thelpviewer.draw and wrap with more lines
  151.  
  152. 25.04.93
  153.   ■ optimization: at "countcs" in THelpTopic.WrapText
  154.     (displaying lot of links is ugly slow.)
  155.  
  156. 21.04.93
  157.   ■ Bugfix: linewrap with long paragraphs
  158.  
  159. 20.04.93
  160.   ■ non-modal helpview will store its size
  161.   ■ changed color with wrapped lines
  162.  
  163. 19.04.93
  164.   ■ redesign of THelpViewer.Draw-methode
  165.     (incl. changes in THelpTopic.WrapText)
  166.     - lock/unlock
  167.     - changed to piut-by-char because coloring
  168.       methode: #n for colorcode, only foreground!
  169.                ## für #
  170.                #! für reset to "standardcolor"
  171.  
  172. 16.04.93
  173.   ■ Alt-F1 for switching back to last topic
  174.  
  175. 15.04.93
  176.   ■ modale view gets a different color set than non-modal view
  177.   ■ Alt-F1 for help-history
  178.   ■ Shift-F1 for help about help
  179.  
  180. 14.04.93
  181.   ■ nodal view <-> non-modal view
  182. }
  183.  
  184.  
  185. {$A+,B-,D-,E-,F-,G-,I-,L-,N-,O-,P-,Q-,R-,S-,T-,V-,X+,Y-}
  186.  
  187. {$Q-,I-,O- }
  188.  
  189. unit HelpFile;
  190.  
  191. interface
  192.  
  193. uses Objects, Drivers, Views;
  194.  
  195. const
  196.   CHelpColor      = {8} #$37#$3F#$3A#$13#$13#$30#$3E#$1E;
  197.   CHelpBlackWhite = {8} #$07#$0F#$07#$70#$70#$07#$0F#$70;
  198.   CHelpMonochrome = {8} #$07#$0F#$07#$70#$70#$07#$0F#$70;
  199.   CHelpViewer     = {3} #6#7#8;
  200.   Chelpwindow     = {8} #16#17#18#19#20#57#21#13;
  201.   Cdialogwindow   = {8} #32#33#34#35#36#38#40#13; { die farbe der dialoge }
  202.  
  203. {KAP}
  204.   {
  205.   chelpwindow-felder
  206.    1 ????
  207.    2 rahmen
  208.    3 rahmensymbole [■]
  209.    4 scroller
  210.    5 background, scrollersymbole
  211.    6 textinhalt
  212.    7 nicht focusierter topic
  213.    8 linked topics/reaktionstopic für ENTER
  214.   }
  215.  
  216. (*
  217.   CHelpWindow     = #128#129#130#131#132#133#134#135;
  218. *)
  219.  
  220. {KAP}
  221.   maxhelpback           = 50;
  222.  
  223.   indexpagenumber       : word = 100;
  224.   helpabouthelp         : word = 99;
  225.  
  226.   cmhelplast            = 65001;
  227.   cmhelpindex           = 65002;
  228.  
  229.   lastpos               : trect = (a:(x:-1;y:0);b:(x:50;y:18));
  230.  
  231.   MagicHeader           = $46484246; {'FBHF'}
  232.  
  233. { wenn auch tp60-hf geöffnet werden können sollen ... }
  234. { if it should be possible to old tp60-hf }
  235.   openanyway            : boolean = false;
  236.  
  237. { erlaubt den Hilfsfenster (trotz Dialog-Aussehen) die Größe zu ändern }
  238. { a non-modal help will be resizable, if set to true }
  239.   resizeabledialog      : boolean = false;
  240.  
  241.   ct_store              = $01;
  242.   ct_nibble             = $02;
  243.   ct_lastnibble         = $03;
  244.  
  245.   nc_rawchar            = $0f;
  246.   nc_repchar            = $0e;
  247.  
  248.   comparraysize         = 13;
  249.  
  250.   createcompressedhelp  : boolean = false;
  251.  
  252.   helpversion           = $20;  { helpfile - version 2.0 }
  253.  
  254. Type string80 = string[80];
  255.  
  256. Const
  257.  
  258.   helpdialogtitle       : string80 = 'Help-Dialog';
  259.   helpwindowtitle       : string80 = 'Help';
  260.   nohelpInvalidStr      : string80 = #13' No help for this topic link.';
  261.   emptyhelpInvalidStr   : string80 = #13' This helppage is empty.';
  262.  
  263.  
  264. type
  265.       pbytearray = ^tbytearray;
  266.       tbytearray = array[0..63*1024] of byte;
  267.  
  268.       pchararray = ^tchararray;
  269.       tchararray = array[0..63*1024] of char;
  270.  
  271. { TParagraph }
  272.  
  273.   PPParagraph = ^pparagraph;
  274.   PParagraph = ^TParagraph;
  275.   TParagraph = record
  276.     Next: PParagraph;
  277.     Wrap: Boolean;
  278.     Size: Word;
  279.     Text: record end;
  280.   end;
  281.  
  282. { THelpTopic }
  283.  
  284.   TCrossRef = record
  285.     Ref: Word;
  286.     Offset: Integer;
  287.     Length: Byte;
  288.   end;
  289.  
  290.   tCompressinfo = record
  291.     comptype  : byte;                 {                           }
  292.     orgsize   : word;                 { orginalgroesse            }
  293.                                       { original size             }
  294.     chartable : array[0..comparraysize] of byte;
  295.                                       { die comparraysize+1 häufigsten codes   }
  296.                                       { the comparraysize+1 most used codes}
  297.   end;
  298.  
  299.  
  300.   plocarray  = ^tlocarray;
  301.   tlocarray  = array[1..1000] of tpoint;
  302.  
  303.   PCrossRefs = ^TCrossRefs;
  304.   TCrossRefs = array[1..10000] of TCrossRef;
  305.   TCrossRefHandler = procedure (var S: TStream; XRefValue: Integer);
  306.  
  307.   PHelpTopic = ^THelpTopic;
  308.   THelpTopic = object(TObject)
  309. { private}
  310.     Paragraphs    : PParagraph;
  311.     NumRefs       : Integer;
  312.     CrossRefs     : PCrossRefs;
  313.     Width         : Integer;
  314.     LastOffset    : Integer;
  315.     LastLine      : Integer;
  316.     LastParagraph : PParagraph;
  317. { public }
  318.     constructor   Init;
  319.     constructor   Load(var S: TStream);
  320.     destructor    Done; virtual;
  321.  
  322.     procedure     initstatistic    (var compheader : tcompressinfo;     p : pParagraph);
  323.     function      Paragraphcompress(var compheader : tcompressinfo;     p : PPParagraph):word;
  324.     procedure     Paragraphexpand  (var compheader : tcompressinfo; var p : ppparagraph);
  325.  
  326.     procedure     AddCrossRef(Ref: TCrossRef);
  327.     procedure     AddParagraph(P: PParagraph);
  328.  
  329.     procedure     GetCrossRef(I: Integer; var Loc: TPoint; var Length: Byte; var Ref: Word);
  330.     procedure     GetallCrossRef(locarray : plocarray; maxline : integer);
  331.  
  332.     function      GetLine(Line: Integer): String;
  333.     function      GetNumCrossRefs: Integer;
  334.     function      NumLines: Integer;
  335.     procedure     SetCrossRef(I: Integer; var Ref: TCrossRef);
  336.     procedure     SetNumCrossRefs(I: Integer);
  337.     procedure     SetWidth(AWidth: Integer);
  338.     procedure     Store(var S: TStream);
  339. { private }
  340.     function WrapText(var Text; Size: Integer; var Offset: Integer;
  341.       Wrap: Boolean): String;
  342.   end;
  343.  
  344. { THelpIndex }
  345.  
  346.   PIndexArray = ^TIndexArray;
  347.   TIndexArray = array[0..16380] of LongInt;
  348.  
  349.   PContextArray = ^TContextArray;
  350.   TContextArray = array[0..16380] of Word;
  351.  
  352.   PHelpIndex = ^THelpIndex;
  353.   THelpIndex = object(TObject)
  354.     Contexts  : PContextArray;
  355.     Index     : PIndexArray;
  356. { private }
  357.     Size      : Word;
  358.     Used      : Word;
  359. { public }
  360.     constructor Init;
  361.     constructor Load(var S: TStream);
  362.     destructor  Done; virtual;
  363.     function    Position(I: Word): Longint;
  364.     procedure   Add(I: Word; Val: Longint);
  365.     procedure   Store(var S: TStream);
  366. { private }
  367.     function    Find(I: Word):longint;
  368.   end;
  369.  
  370. { THelpFile }
  371.  
  372.   PHelpFile = ^THelpFile;
  373.   THelpFile = object(TObject)
  374.     Stream     : PStream;
  375.     Modified   : Boolean;
  376. {KAP}
  377.     invaltopic : boolean;
  378. { private}
  379.     Index      : PHelpIndex;
  380.     IndexPos   : LongInt;
  381. { public }
  382.     constructor Init(S: PStream);
  383.     destructor  Done; virtual;
  384.     function    GetTopic(I: Word): PHelpTopic;
  385.     function    InvalidTopic: PHelpTopic;
  386.     function    emptyTopic: PHelpTopic;
  387.     procedure   RecordPositionInIndex(I: word);
  388.     procedure   PutTopic(Topic: PHelpTopic);
  389.   end;
  390.  
  391. {KAP}
  392.   TStackrec = record
  393.     helpctx  : word;
  394.     selected : word;
  395.   end;
  396.  
  397.   pstackarray = ^tstackarray;
  398.   tstackarray = array[1..maxhelpback] of TStackrec;
  399.  
  400. { THelpViewer }
  401.   PHelpViewer = ^THelpViewer;
  402.   THelpViewer = object(TScroller)
  403.     HFile         : PHelpFile;
  404.     Topic         : PHelpTopic;
  405.     stack         : pstackarray;
  406.     Selected      : Integer;
  407.  
  408.     oldsize       : byte;
  409.     locarray      : plocarray;
  410.     locarraysize  : word;
  411.     keyfocus      : pstring;
  412.     constructor Init(var Bounds       : TRect;
  413.                          AHScrollBar,
  414.                          AVScrollBar  : PScrollBar;
  415.                          AHelpFile    : PHelpFile;
  416.                          Context      : Word);
  417.     destructor Done; virtual;
  418.     procedure  ChangeBounds(var Bounds: TRect); virtual;
  419.     procedure  Draw; virtual;
  420.     function   GetPalette: PPalette; virtual;
  421.     procedure  HandleEvent(var Event: TEvent); virtual;
  422.     procedure  SwitchToTopic(KeyRef: word);
  423.  
  424.     procedure  invalidatelocarray;
  425.  
  426.     procedure  Popstack(var keyword : word);
  427.     procedure  Pushstack(keyword : word);
  428.     procedure  SwitchTooldTopic(Var keyref : word);
  429.   end;
  430.  
  431. { THelpWindow }
  432.   PHelpWindow = ^THelpWindow;
  433.   THelpWindow = object(TWindow)
  434.     phv      : phelpviewer;
  435.     ismodal  : boolean;
  436.     constructor Init(HFile: PHelpFile; Context: Word; aismodal : boolean);
  437.     function GetPalette: PPalette; virtual;
  438.     destructor done; virtual;
  439.   end;
  440.  
  441. Var
  442.   originalsize, compresssize  : longint;
  443.  
  444.  
  445. const
  446.   RHelpTopic: TStreamRec = (
  447.      ObjType: 10000;
  448.      VmtLink: Ofs(TypeOf(THelpTopic)^);
  449.      Load:    @THelpTopic.Load;
  450.      Store:   @THelpTopic.Store
  451.   );
  452.  
  453. const
  454.   RHelpIndex: TStreamRec = (
  455.      ObjType: 10001;
  456.      VmtLink: Ofs(TypeOf(THelpIndex)^);
  457.      Load:    @THelpIndex.Load;
  458.      Store:   @THelpIndex.Store
  459.   );
  460.  
  461. procedure RegisterHelpFile;
  462.  
  463. procedure NotAssigned(var S: TStream; Value: Integer);
  464.  
  465. const     CrossRefHandler: TCrossRefHandler = NotAssigned;
  466.  
  467.  
  468. implementation
  469.  
  470. {....}
  471.  
  472. end.
  473.  
  474.