{***********************************************************************}
{									}
{ __FastWin   Write a string to the current window directly		}
{									}
{ procedure __FastWin(X,Y : byte; BufferPtr : pointer;			}
{				    NoChars : word;			}
{			     Fore,Back,Mode : byte);			}
{									}
{	      X,Y	Column and row position relative to the current }
{			window where the buffer is to be output.	}
{	      BufferPtr Pointer to string (and attributes) which is to	}
{			be displayed.					}
{	      NoChars	The number of characters to be output.		}
{	      Fore,Back Foreground and background attributes used when	}
{			displaying the string.	These parameters are	}
{			ignored if the value of Mode is 0 or 2. 	}
{	      Mode	The mode value tells __FastWin how the buffer	}
{			is constructed: The three values are:		}
{									}
{			Mode Value  Description 			}
{			----------  ----------------------------------- }
{			    0	    The buffer contains just characters }
{				    and the attributes are not altered. }
{			    1	    The buffer contains just characters,}
{				    but the characters are written with }
{				    the specified attributes.		}
{			    2	    The buffer is made up of characters }
{				    followed by attribute bytes.	}
{			    3	    The buffer is ignored, and the	}
{				    characters on the screen are not	}
{				    altered, but the attributes are	}
{				    altered to the values of Fore and	}
{				    Back.				}
{									}
{ Description __FastWin displays a string buffer on the current window	}
{	      starting at the specified cursor position.  This		}
{	      routine is designed for those application requiring fast	}
{	      screen update.  Under less stringent speed requirements,	}
{	      __WriteWin is probably a better choice, because it can	}
{	      function in graphics modes and treats CR/LF, Backspace	}
{	      Ctrl/G as commands rather than displayable characters,	}
{	      and it also wraps the output within the window.  On the	}
{	      other hand, __FastWin simply truncates the buffer if it	}
{	      writes beyond the bounds of the current window.		}
{									}
{	      For mode two (2), it is assumed that the buffer is for-	}
{	      matted in the form char,attr,char,attr,.... (i.e., like	}
{	      the _ScnPos type).  For all other modes, the string just	}
{	      contains characters, and the attributes are determined	}
{	      by the parameters Fore and Back or by the current screen	}
{	      settings.  For mode 3, NoChars is the number of charac-	}
{	      ters on the screen whose attributes are altered. The	}
{	      cursor position and size is not altered by  __FastWin.	}
{									}
{	      NoChars is the number of characters to output; in the	}
{	      case of modes 0 and 1, if a pointer to a string is	}
{	      passed, it must point to the first character, not the 0th }
{	      component (which is the length).				}
{									}
{	      Carriage return, line feed, backspace and bell (Ctrl/G)	}
{	      characters are treated as standard characters rather than }
{	      commands (see __WriteWin).  If the screen mode is not a	}
{	      standard text mode (0,1,2,3 and 7), or the requested	}
{	      cursor position is out of range, then no action is taken	}
{	      and control returns immediately.				}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

procedure __FastWin(X,Y : byte; BufferPtr : pointer;
				  NoChars : word;
			   Fore,Back,Mode : byte);

  var
    XOff,YOff	 : byte;
    Width,Height : byte;

  begin {__FastWin}

    { Determine the correct values for X, Y and NoChars to pass to	}
    { __FastScn.							}

    with _CurWindow do
      begin
	XOff   := _XUpper - 1;
	YOff   := _YUpper - 1;
	Width  := _XLower - XOff;	     { Number of legal columns	}
	Height := _YLower - YOff;	     { Number of legal rows	}
      end;

    if (X < 1) then
       X := 1
    else if (X > Width) then
       Exit;
    if (Y < 1) then
       Y := 1
    else if (Y > Height) then
       Exit;

    if (NoChars <= 0) then
       Exit
    else if (NoChars > (Width - X + 1)) then
       NoChars := Width - X + 1;

    __FastScn(X + XOff,Y + YOff,BufferPtr,NoChars,Fore,Back,Mode)

  end;	{__FastWin}
