{***********************************************************************}
{									}
{ __HorzScn   Scroll text horizontally within an area on the screen	}
{									}
{ procedure __HorzScn(X1,Y1,X2,Y2,NumCols,Fore,Back : byte;		}
{					       Left : boolean); 	}
{									}
{	      X1,Y1	Upper left corner of window area, X1 is the	}
{			column number and Y1 is the row number. 	}
{	      X2,Y2	Lower right corner of window area, X2 is the	}
{			column number and Y2 is the row number. 	}
{	      NumCols	The number of columns to scroll within the	}
{			area. To scroll the entire area, specify 0.	}
{	      Fore,Back The attributes used to fill the columns within	}
{			the window area scrolled.			}
{	      Left	If TRUE, the area to the left (that is, the	}
{			vacant columns are on the right side of the	}
{			area) is scrolled; otherwise to the right.	}
{									}
{ Description This procedure scrolls text within a specified area on	}
{	      physical screen.	The vacant columns in the screen area	}
{	      are filled with the specified attributes.  Columns can be }
{	      scrolled left (so the vacant columns are at the right) or }
{	      right. The current display page is scrolled.		}
{									}
{	      Notice that __HorzScn does not check the parameters to	}
{	      make sure they are reasonable.  It is the programmer's	}
{	      responsibility that the area coordinates be within the	}
{	      physical screen, and the NumCols be less than the number	}
{	      of columns in the area.  To scroll within a the current	}
{	      window, the procedure __HorzWin should be used.		}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

procedure __HorzScn(X1,Y1,X2,Y2,NumCols,Fore,Back : byte;
					     Left : boolean);

  const
    BLANK = #32;

  var
    OutBufLine	: array[1..80] of _ScnPos;
    Filler	: _ScnPos;
    I		: word;

  begin {__HorzScn}

    { First initialize the output buffer to blanks and the correct	}
    { foreground and background attributes.				}

    Filler._Ch	 := BLANK;
    Filler._Attr := __2ByteSup(Back,Fore);
    for I := 1 to 80 do
	Move(Filler,OutBufLine[I],2);

    { If NumCols is specified larger than the number of columns within	}
    { the window, or if it is negative, set NumCols to zero.		}

    if (NumCols >= (X2 - X1 + 1)) then
       NumCols := 0;

    { If we are to scroll the entire window and the display page is the }
    { active page, then use __VertScn because it is much more efficient.}

    if ((NumCols = 0) and (_CurActivePage = _CurDisplayPage)) then
       begin
	 __VertScn(X1,Y1,X2,Y2,0,Fore,Back,TRUE);
	 Exit
       end;

    if (Left) then		       { Move the block to the left and }
       for I := Y1 to Y2 do	       { fill with blank character and	}
	 begin			       { specified attribute.		}
	   __MoveScn(X1 + NumCols,I,X2,I,@OutBufLine[1],FALSE);
	   __MoveScn(X1,I,X2,I,@OutBufLine[1],TRUE)
	 end
    else
       for I := Y1 to Y2 do
	 begin
	   __MoveScn(X1,I,X2 - NumCols,I,@OutBufLine[NumCols + 1],FALSE);
	   __MoveScn(X1,I,X2,I,@OutBufLine[1],TRUE)
	 end

  end;	{__HorzScn}
