{***********************************************************************}
{									}
{ __WCharWin  Write copies of a character in the current window 	}
{									}
{ procedure __WCharWin(DispCh : char; Count : word);			}
{									}
{	      DispCh	The character to display			}
{	      Count	The number of copies of Ch to display		}
{									}
{ Description __WCharWin writes Count copies of the character Ch start- }
{	      ing at the current cursor position.  The characters are	}
{	      written to the current display page (_CurDisplayPage),	}
{	      within the current window (_CurWindow) dimensions, and	}
{	      without altering the screen attributes.  Characters are	}
{	      written by making successive calls to __WCharScn. 	}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc. 1986, 1987	}
{_______________________________________________________________________}

procedure __WCharWin(DispCh : char; Count : word);

  var
    Width     : word;		       { Window line width		}
    FirstLine : word;		       { Starting row in window to fill }
    LastLine  : word;		       { Last row in window to fill	}
    FullLines : word;		       { Number of lines to write chars }
    Lines     : word;		       { Lines available for writing	}
    X,Y       : byte;		       { Current cursor position	}
    I	      : word;
    CTop,CBot : byte;

  begin {__WCharWin}

    { Start by determining how many characters on the current line to	}
    { output, then how many full, and finally, how many partial lines.	}
    { Like __WCharScn, if more characters are specified than remain in	}
    { the window from the current cursor position, the remaining char-	}
    { acters are not output (that is, there is no wrap around.		}

    __WhereWin(X,Y,CTop,CBot);
    with _CurWindow do
      begin
	Width := _XLower - _XUpper + 1;
	Lines := _YLower - _YUpper + 1 - Y   { Full lines after cursor	}
      end;
    FirstLine := Width - X + 1;
    if (Count < FirstLine) then
       begin
	 __WCharScn(DispCh,Count);
	 Exit				     { all done....		}
       end
    else
       begin
	 __WCharScn(DispCh,FirstLine);
	 Count := Count - FirstLine
       end;
    FullLines := Count div Width;
    if (FullLines > Lines) then
       begin
	 FullLines := Lines;
	 LastLine := 0
       end
    else
       LastLine := Count mod Width;

    for I := 1 to FullLines do		     { Output each line at a	}
      begin				     { time using __WCharScn.	}
	__GotoWin(1,byte(Y + I));
	__WCharScn(DispCh,Width)
      end;
    if (LastLine > 0) then
      begin
	__GotoWin(1,byte(Y + 1 + FullLines));
	__WCharScn(DispCh,LastLine)
      end;

    __GotoWin(X,Y)			     { Return to where we were. }

  end;	{__WCharWin}
