home *** CD-ROM | disk | FTP | other *** search
- {$A+,B-,R-,S-,V-}
-
- (* ------------------------------------------------------ *)
- (* GRWRITE.PAS *)
- (* *)
- (* Sprache : Turbo Pascal Version 5.50 *)
- (* *)
- (* Macht WRITE bzw. WRITELN für den Grafikmodus nutzbar. *)
- (* Ausgaben auf den Bildschirm können wie im Textmodus *)
- (* vorgenommen werden. Zeichensatz, Rotation, Textgröße *)
- (* werden berücksichtigt. *)
- (* *)
- (* Anmerkung: *)
- (* *)
- (* Der Cursor wird bei der Ausgabe nur dann in Schreib- *)
- (* richtung versetzt, wenn *)
- (* *)
- (* a) der Text horizontal ausgegeben wird (SetTextStyle) *)
- (* und die horizontale Ausrichtung auf LeftText ge- *)
- (* setzt wurde (SetTextJustify), oder *)
- (* *)
- (* b) der Text vertikal ausgegeben wird (SetTextStyle) *)
- (* und die vertikale Ausrichtung auf BottomText ge- *)
- (* setzt wurde (SetTextJustify). *)
- (* *)
- (* D.h.: Die Ausgaben von mehreren hintereinanderfolgen- *)
- (* den Write-Anweisungen (z.B: "Write('X'); Write('Y')")) *)
- (* erscheinen nur dann auch neben- bzw. untereinander auf *)
- (* dem Bildschirm, wenn a) oder b) zutrifft. Ansonsten *)
- (* überschreibt die zweite Ausgabe die erste. *)
- (* *)
- (* *)
- (* 1991 Ralf Homburg *)
- (* ------------------------------------------------------ *)
-
-
-
- unit GRWRITE;
-
-
- interface
-
-
- uses
- DOS,
- Graph;
-
-
- const
- HorizLineSpacing : byte = 2; { Zeilenabstand bei hori- }
- { zontaler Ausgabe }
- VertLineSpacing : byte = 2; { Zeilenabstand bei verti- }
- { kaler Ausgabe }
-
- procedure InstallGraphWrite;
- { Installiert eine Treiberfunktion für die Standardaus- }
- { gabe zur Verwendung von WRITE(LN) im Grafikmodus. }
-
- procedure InstallCrtWrite;
- { Installiert die normale Standardausgabe-Routine. Die }
- { Prozedur muß beim Verlassen des Grafikmodus aufgerufen }
- { werden (auch wenn keine weiteren Ausgaben mehr erfol- }
- { gen!). }
-
-
- implementation
-
-
- var
- OldOutputInOut : pointer;
-
-
- {$F+} function OutputInOut(var F:TextRec):integer; {$F-}
-
- var
- I :integer;
- St :string;
- Len :byte absolute St;
- TextInfo :TextSettingsType;
- ViewPort :ViewPortType;
-
- begin
- Len := 0;
- GetTextSettings(TextInfo);
- with F do
- begin
- for I := 0 to BufPos-1 do
- case byte(BufPtr^[I]) of
- 13: begin
- if St <> '' then
- begin
- OutText(St);
- St := '';
- end;
- if (TextInfo.Horiz = LeftText) and
- (TextInfo.Direction = HorizDir) then
- MoveTo(0,GetY)
- else
- if (TextInfo.Direction = VertDir) and
- (TextInfo.Vert = BottomText) then
- begin
- GetViewSettings(ViewPort);
- MoveTo(GetX,ViewPort.Y2 -ViewPort.Y1);
- end;
- end;
- 10: begin
- if St <> '' then
- begin
- OutText(St);
- St := '';
- end;
- if TextInfo.Direction = HorizDir then
- MoveRel(0,TextHeight('M') +HorizLineSpacing)
- else
- MoveRel(TextWidth('M') +VertLineSpacing,0);
- end;
- else
- begin
- inc(Len);
- St[Len] := char(BufPtr^[I]);
- end;
- end;
- if St <> '' then
- begin
- OutText(St);
- if (TextInfo.Direction = VertDir) and
- (TextInfo.Vert = BottomText) then
- MoveRel(0,-Len *TextHeight('M'));
- end;
- BufPos := 0;
- BufEnd := 0;
- end;
- OutputInOut := 0;
- end;
-
-
- procedure InstallGraphWrite;
-
- begin
- with TextRec(Output) do
- begin
- InOutFunc := @OutputInOut;
- FlushFunc := @OutputInOut;
- end;
- end;
-
-
- procedure InstallCrtWrite;
-
- begin
- with TextRec(Output) do
- begin
- InOutFunc := OldOutputInOut;
- FlushFunc := OldOutputInOut;
- end;
- end;
-
-
- begin
- OldOutputInOut := TextRec(Output).InOutFunc;
- end.