home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / term43-source.lha / Extras / Source / term-Source.lha / termScroll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-07  |  29.2 KB  |  1,378 lines

  1. /*
  2. **    termScroll.c
  3. **
  4. **    Support routines for optimized screen scrolling.
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12.     /* ScrollLineRectFill():
  13.      *
  14.      *    Fill a rectangular portion of the window raster with the help
  15.      *    of the scrolling information.
  16.      */
  17.  
  18. VOID __regargs
  19. ScrollLineRectFill(struct RastPort *RPort,WORD MinX,WORD MinY,WORD MaxX,WORD MaxY)
  20. {
  21.     WORD BackPen;
  22.  
  23.     if(MinX >= MaxX || MinY >= MaxY)
  24.         return;
  25.  
  26.     if(TextAttributeTable[Attributes] & ATTR_INVERSE)
  27.         BackPen = FgPen;
  28.     else
  29.         BackPen = BgPen;
  30.  
  31.     if(BackPen)
  32.     {
  33.         LONG Start,Stop;
  34.  
  35.         if((Start = MinY / TextFontHeight) < ScrollLineFirst)
  36.             ScrollLineFirst = Start;
  37.  
  38.         if((Stop = (MaxY + 1) / TextFontHeight - 1) > ScrollLineLast)
  39.             ScrollLineLast = Stop;
  40.  
  41.         if(GetBitMapDepth(RPort -> BitMap) > 1)
  42.         {
  43.             if(UseMasking)
  44.             {
  45.                 WORD Mask = BackPen,i;
  46.  
  47.                 for(i = Start ; i <= Stop ; i++)
  48.                 {
  49.                     if(ScrollLines[i] . Width)
  50.                         Mask |= ScrollLines[i] . ColourMask;
  51.                 }
  52.  
  53.                 Mask &= DepthMask;
  54.  
  55.                 if(!Mask)
  56.                     return;
  57.  
  58.                 for(i = Start ; i <= Stop ; i++)
  59.                 {
  60.                     ScrollLines[i] . Left        = 0;
  61.                     ScrollLines[i] . Right        = LastColumn + 1;
  62.                     ScrollLines[i] . Width        = TextFontWidth;
  63.                     ScrollLines[i] . ColourMask    = BackPen;
  64.                 }
  65.  
  66.                 SetMask(RPort,Mask);
  67.             }
  68.             else
  69.             {
  70.                 WORD i;
  71.  
  72.                 for(i = Start ; i <= Stop ; i++)
  73.                 {
  74.                     ScrollLines[i] . Left        = 0;
  75.                     ScrollLines[i] . Right        = LastColumn + 1;
  76.                     ScrollLines[i] . Width        = TextFontWidth;
  77.                     ScrollLines[i] . ColourMask    = BackPen;
  78.                 }
  79.             }
  80.         }
  81.  
  82.         if(BackPen != ReadAPen(RPort))
  83.             SetAPen(RPort,BackPen);
  84.  
  85.         RectFill(RPort,WindowLeft + MinX,WindowTop + MinY,WindowLeft + MaxX,WindowTop + MaxY);
  86.  
  87.         return;
  88.     }
  89.  
  90.     if(GetBitMapDepth(RPort -> BitMap) > 1)
  91.     {
  92.             /* Is there anything on the screen at all? */
  93.  
  94.         if(ScrollLineFirst <= ScrollLineLast)
  95.         {
  96.             if(UseMasking)
  97.             {
  98.                 WORD    ScrollLineMask    = 0,
  99.                     ScrollLineLeft    = 32767,
  100.                     ScrollLineRight    = 0,
  101.                     Temp,
  102.                     i;
  103.  
  104.                     /* Determine screen colour mask. */
  105.  
  106.                 for(i = MinY / TextFontHeight ; i <= MaxY / TextFontHeight ; i++)
  107.                 {
  108.                     if(ScrollLines[i] . Width)
  109.                     {
  110.                         if((Temp = ScrollLines[i] . Left * ScrollLines[i] . Width) < ScrollLineLeft)
  111.                             ScrollLineLeft = Temp;
  112.  
  113.                         if((Temp = (ScrollLines[i] . Right * ScrollLines[i] . Width) - 1) > ScrollLineRight)
  114.                             ScrollLineRight = Temp;
  115.  
  116.                         ScrollLineMask |= ScrollLines[i] . ColourMask;
  117.                     }
  118.                 }
  119.  
  120.                     /* Wrap the bits. */
  121.  
  122.                 ScrollLineMask &= DepthMask;
  123.  
  124.                     /* Did we get a sensible colour? */
  125.  
  126.                 if(ScrollLineMask && ScrollLineLeft <= ScrollLineRight)
  127.                 {
  128.                         /* Determine new left margin. */
  129.  
  130.                     if(ScrollLineLeft > MinX)
  131.                         MinX = ScrollLineLeft;
  132.  
  133.                         /* Determine new right margin. */
  134.  
  135.                     if(ScrollLineRight < MaxX)
  136.                         MaxX = ScrollLineRight;
  137.  
  138.                         /* Determine new top line margin. */
  139.  
  140.                     if((Temp = MUL_Y(ScrollLineFirst)) > MinY)
  141.                         MinY = Temp;
  142.  
  143.                         /* Determine new bottom line margin. */
  144.  
  145.                     if((Temp = MUL_Y(ScrollLineLast + 1) - 1) < MaxY)
  146.                         MaxY = Temp;
  147.  
  148.                         /* Set the colour mask. */
  149.  
  150.                     SetMask(RPort,ScrollLineMask);
  151.  
  152.                         /* Add margin for italics or boldface. */
  153.  
  154.                     if(MaxX == ScrollLineRight)
  155.                         MaxX += FontRightExtend;
  156.                 }
  157.             }
  158.             else
  159.             {
  160.                 WORD    ScrollLineLeft    = 32767,
  161.                     ScrollLineRight    = 0,
  162.                     Temp,
  163.                     i;
  164.  
  165.                     /* Determine screen colour mask. */
  166.  
  167.                 for(i = MinY / TextFontHeight ; i <= MaxY / TextFontHeight ; i++)
  168.                 {
  169.                     if(ScrollLines[i] . Width)
  170.                     {
  171.                         if((Temp = ScrollLines[i] . Left * ScrollLines[i] . Width) < ScrollLineLeft)
  172.                             ScrollLineLeft = Temp;
  173.  
  174.                         if((Temp = (ScrollLines[i] . Right * ScrollLines[i] . Width) - 1) > ScrollLineRight)
  175.                             ScrollLineRight = Temp;
  176.                     }
  177.                 }
  178.  
  179.                     /* Did we get a sensible colour? */
  180.  
  181.                 if(ScrollLineLeft <= ScrollLineRight)
  182.                 {
  183.                         /* Determine new left margin. */
  184.  
  185.                     if(ScrollLineLeft > MinX)
  186.                         MinX = ScrollLineLeft;
  187.  
  188.                         /* Determine new right margin. */
  189.  
  190.                     if(ScrollLineRight < MaxX)
  191.                         MaxX = ScrollLineRight;
  192.  
  193.                         /* Determine new top line margin. */
  194.  
  195.                     if((Temp = MUL_Y(ScrollLineFirst)) > MinY)
  196.                         MinY = Temp;
  197.  
  198.                         /* Determine new bottom line margin. */
  199.  
  200.                     if((Temp = MUL_Y(ScrollLineLast + 1) - 1) < MaxY)
  201.                         MaxY = Temp;
  202.  
  203.                         /* Add margin for italics or boldface. */
  204.  
  205.                     if(MaxX == ScrollLineRight)
  206.                         MaxX += FontRightExtend;
  207.                 }
  208.             }
  209.         }
  210.     }
  211.  
  212.         /* And clear the raster. */
  213.  
  214.     if(MinX < MaxX && MinY < MaxY)
  215.         RectFill(RPort,WindowLeft + MinX,WindowTop + MinY,WindowLeft + MaxX,WindowTop + MaxY);
  216. }
  217.  
  218.     /* ScrollLineRaster():
  219.      *
  220.      *    Scroll the window raster with the help
  221.      *    of the scrolling information.
  222.      */
  223.  
  224. VOID __regargs
  225. ScrollLineRaster(struct RastPort *RPort,WORD DeltaX,WORD DeltaY,WORD MinX,WORD MinY,WORD MaxX,WORD MaxY,BYTE Smooth)
  226. {
  227.     WORD BackPen;
  228.  
  229.     if((!DeltaX && !DeltaY) || MinX >= MaxX || MinY >= MaxY)
  230.         return;
  231.  
  232.     if(TextAttributeTable[Attributes] & ATTR_INVERSE)
  233.         BackPen = FgPen;
  234.     else
  235.         BackPen = BgPen;
  236.  
  237.     if(BackPen)
  238.     {
  239.         if(GetBitMapDepth(RPort -> BitMap) > 1)
  240.         {
  241.             if(UseMasking)
  242.             {
  243.                 WORD i,Mask = BackPen;
  244.  
  245.                 for(i = MinY / TextFontHeight ; i <= MaxY / TextFontHeight ; i++)
  246.                 {
  247.                     if(ScrollLines[i] . Width)
  248.                         Mask |= ScrollLines[i] . ColourMask;
  249.                 }
  250.  
  251.                 Mask &= DepthMask;
  252.  
  253.                 if(!Mask)
  254.                     return;
  255.  
  256.                 SetMask(RPort,Mask);
  257.             }
  258.  
  259.             if(DeltaX)
  260.             {
  261.                 if(!ScrollLines[CursorY] . Width)
  262.                     return;
  263.                 else
  264.                 {
  265.                     ScrollLines[CursorY] . Left    = 0;
  266.                     ScrollLines[CursorY] . Right    = (LastPixel + 1) / ScrollLines[CursorY] . Width;
  267.  
  268.                     ScrollLines[CursorY] . ColourMask |= BackPen;
  269.                 }
  270.             }
  271.             else
  272.             {
  273.                 WORD i,Lines = DeltaY / TextFontHeight,Size,Start;
  274.  
  275.                 Size    = (MaxY - MinY + 1) / TextFontHeight;
  276.                 Start    = MinY / TextFontHeight;
  277.  
  278.                 if(Lines < 0)
  279.                 {
  280.                     if(Size == -Lines)
  281.                     {
  282.                         for(i = 0 ; i < -Lines ; i++)
  283.                         {
  284.                             ScrollLines[Start + i] . Left        = 0;
  285.                             ScrollLines[Start + i] . Right        = LastColumn + 1;
  286.                             ScrollLines[Start + i] . ColourMask    = BackPen;
  287.                             ScrollLines[Start + i] . Width        = TextFontWidth;
  288.                         }
  289.                     }
  290.                     else
  291.                     {
  292.                         for(i = 1 ; i <= -Lines ; i++)
  293.                             ScrollLines[Start + Size - i] = ScrollLines[Start - Lines - i];
  294.  
  295.                         for(i = 0 ; i < -Lines ; i++)
  296.                         {
  297.                             ScrollLines[Start + i] . Left        = 0;
  298.                             ScrollLines[Start + i] . Right        = LastColumn + 1;
  299.                             ScrollLines[Start + i] . ColourMask    = BackPen;
  300.                             ScrollLines[Start + i] . Width        = TextFontWidth;
  301.                         }
  302.                     }
  303.                 }
  304.                 else
  305.                 {
  306.                     if(Size == Lines)
  307.                     {
  308.                         for(i = 0 ; i < Size ; i++)
  309.                         {
  310.                             ScrollLines[Start + i] . Left        = 0;
  311.                             ScrollLines[Start + i] . Right        = LastColumn + 1;
  312.                             ScrollLines[Start + i] . ColourMask    = BackPen;
  313.                             ScrollLines[Start + i] . Width        = TextFontWidth;
  314.                         }
  315.                     }
  316.                     else
  317.                     {
  318.                         for(i = 0 ; i < Lines ; i++)
  319.                             ScrollLines[Start + i] = ScrollLines[Start + Lines + i];
  320.  
  321.                         for(i = Lines ; i < Size ; i++)
  322.                         {
  323.                             ScrollLines[Start + i] . Left        = 0;
  324.                             ScrollLines[Start + i] . Right        = LastColumn + 1;
  325.                             ScrollLines[Start + i] . ColourMask    = BackPen;
  326.                             ScrollLines[Start + i] . Width        = TextFontWidth;
  327.                         }
  328.                     }
  329.                 }
  330.             }
  331.         }
  332.  
  333.         if(MUL_Y(ScrollLineFirst) > MinY)
  334.             ScrollLineFirst = MinY / TextFontHeight;
  335.  
  336.         if(MaxY > MUL_Y(ScrollLineLast + 1) - 1)
  337.             ScrollLineLast = (MaxY + 1) / TextFontHeight;
  338.  
  339.         MinX += WindowLeft;
  340.         MaxX += WindowLeft;
  341.  
  342.         MinY += WindowTop;
  343.         MaxY += WindowTop;
  344.  
  345.         if(BackPen != ReadBPen(RPort))
  346.             SetBPen(RPort,BackPen);
  347.  
  348.             /* Smooth scrolling required? */
  349.  
  350.         if(Smooth && DeltaY)
  351.         {
  352.             WORD Lines,Extra;
  353.  
  354.             Lines = ABS(DeltaY);
  355.             Extra = Lines & 1;
  356.             Lines = Lines / 2;
  357.  
  358.             if(DeltaY > 0)
  359.             {
  360.                 while(Lines--)
  361.                 {
  362.                     WaitTOF();
  363.  
  364.                     ScrollRaster(RPort,0,2,MinX,MinY,MaxX,MaxY);
  365.                 }
  366.  
  367.                 if(Extra)
  368.                 {
  369.                     WaitTOF();
  370.  
  371.                     ScrollRaster(RPort,0,1,MinX,MinY,MaxX,MaxY);
  372.                 }
  373.             }
  374.             else
  375.             {
  376.                 while(Lines--)
  377.                 {
  378.                     WaitTOF();
  379.  
  380.                     ScrollRaster(RPort,0,-2,MinX,MinY,MaxX,MaxY);
  381.                 }
  382.  
  383.                 if(Extra)
  384.                 {
  385.                     WaitTOF();
  386.  
  387.                     ScrollRaster(RPort,0,-1,MinX,MinY,MaxX,MaxY);
  388.                 }
  389.             }
  390.         }
  391.         else
  392.             ScrollRaster(RPort,DeltaX,DeltaY,MinX,MinY,MaxX,MaxY);
  393.  
  394.         return;
  395.     }
  396.  
  397.     if(GetBitMapDepth(RPort -> BitMap) > 1)
  398.     {
  399.         if(UseMasking)
  400.         {
  401.             WORD ScrollLineMask;
  402.  
  403.                 /* Are we to scroll a line in horizontal direction? If so, use the
  404.                  * colour mask of the current line.
  405.                  */
  406.  
  407.             if(DeltaX)
  408.             {
  409.                     /* Set the colour mask. */
  410.  
  411.                 if(ScrollLineMask = ScrollLines[CursorY] . ColourMask & DepthMask)
  412.                     SetMask(RPort,ScrollLineMask);
  413.             }
  414.             else
  415.             {
  416.                     /* Any data on screen worth scrolling? */
  417.  
  418.                 if(ScrollLineFirst <= ScrollLineLast)
  419.                 {
  420.                     WORD Temp,First,Last,SaveMinY = MinY / TextFontHeight,SaveMaxY = MaxY / TextFontHeight,ScrollLineLeft = 32767,ScrollLineRight = 0,i;
  421.  
  422.                         /* Reset colourmask. */
  423.  
  424.                     ScrollLineMask = 0;
  425.  
  426.                         /* Build both the colour mask and the margins. */
  427.  
  428.                     for(i = MinY / TextFontHeight ; i <= MaxY / TextFontHeight ; i++)
  429.                     {
  430.                         if(ScrollLines[i] . Width)
  431.                         {
  432.                             if((Temp = ScrollLines[i] . Left * ScrollLines[i] . Width) < ScrollLineLeft)
  433.                                 ScrollLineLeft = Temp;
  434.  
  435.                             if((Temp = (ScrollLines[i] . Right * ScrollLines[i] . Width) - 1) > ScrollLineRight)
  436.                                 ScrollLineRight = Temp;
  437.  
  438.                             ScrollLineMask |= ScrollLines[i] . ColourMask;
  439.                         }
  440.                     }
  441.  
  442.                         /* Wrap the bits. */
  443.  
  444.                     ScrollLineMask &= DepthMask;
  445.  
  446.                         /* Sensible results? */
  447.  
  448.                     if(ScrollLineMask && ScrollLineLeft <= ScrollLineRight)
  449.                     {
  450.                             /* Determine new left margin. */
  451.  
  452.                         if(ScrollLineLeft > MinX)
  453.                             MinX = ScrollLineLeft;
  454.  
  455.                             /* Determine new right margin. */
  456.  
  457.                         if(ScrollLineRight < MaxX)
  458.                             MaxX = ScrollLineRight;
  459.  
  460.                             /* Scroll down or up? */
  461.  
  462.                         if(DeltaY < 0)
  463.                         {
  464.                                 /* So we are to scroll down, find the first
  465.                                  * blank line if any.
  466.                                  */
  467.  
  468.                             if((Temp = MUL_Y(ScrollLineFirst)) > MinY)
  469.                                 MinY = Temp;
  470.  
  471.                                 /* Find the last blank lines if any. */
  472.  
  473.                             if((Temp = MUL_Y(ScrollLineLast + 1) - DeltaY - 1) < MaxY)
  474.                                 MaxY = Temp;
  475.  
  476.                                 /* Determine margins and the like... */
  477.  
  478.                             Last    = (MaxY + 1) / TextFontHeight;
  479.                             First    = Last - ((MaxY - MinY + TextFontHeight + DeltaY) / TextFontHeight);
  480.                             Temp    = (-DeltaY) / TextFontHeight;
  481.  
  482.                                 /* Move the scroll line info up. */
  483.  
  484.                             for(i = Last - 1 ; i >= First ; i--)
  485.                                 ScrollLines[i] = ScrollLines[i - Temp];
  486.  
  487.                                 /* Clear the remaining lines. */
  488.  
  489.                             for(i = First - Temp ; i < First ; i++)
  490.                             {
  491.                                 ScrollLines[i] . Left        = 32767;
  492.                                 ScrollLines[i] . Right        = 0;
  493.                                 ScrollLines[i] . ColourMask    = 0;
  494.                                 ScrollLines[i] . Width        = 0;
  495.                             }
  496.  
  497.                                 /* Is the first line we were working
  498.                                  * on the first line of the whole display?
  499.                                  * If so, update the line marker.
  500.                                  */
  501.  
  502.                             if(!SaveMinY)
  503.                                 ScrollLineFirst += Temp;
  504.  
  505.                                 /* Now take a look at the last line.
  506.                                  * If the last line we were working
  507.                                  * on is in fact the last line of the
  508.                                  * display, update the line marker.
  509.                                  */
  510.  
  511.                             if(SaveMaxY == LastLine)
  512.                             {
  513.                                 ScrollLineLast += Temp;
  514.  
  515.                                 if(ScrollLineLast > LastLine)
  516.                                     ScrollLineLast = LastLine;
  517.                             }
  518.                         }
  519.                         else
  520.                         {
  521.                                 /* So we are to scroll up, find the last
  522.                                  * blank line if any.
  523.                                  */
  524.  
  525.                             if((Temp = MUL_Y(ScrollLineLast + 1) - 1) < MaxY)
  526.                                 MaxY = Temp;
  527.  
  528.                                 /* Find the first blank lines if any. */
  529.  
  530.                             if((Temp = MUL_Y(ScrollLineFirst) - DeltaY) > MinY)
  531.                                 MinY = Temp;
  532.  
  533.                                 /* Determine margins and the like... */
  534.  
  535.                             First    = MinY / TextFontHeight;
  536.                             Last    = ((MaxY - MinY + TextFontHeight - DeltaY) / TextFontHeight);
  537.                             Temp    = DeltaY / TextFontHeight;
  538.  
  539.                                 /* Move the scroll line info down. */
  540.  
  541.                             for(i = First ; i < First + Last ; i++)
  542.                                 ScrollLines[i] = ScrollLines[i + Temp];
  543.  
  544.                                 /* Clear the remaining lines. */
  545.  
  546.                             for(i = First + Last ; i < First + Last + Temp ; i++)
  547.                             {
  548.                                 ScrollLines[i] . Left        = 32767;
  549.                                 ScrollLines[i] . Right        = 0;
  550.                                 ScrollLines[i] . ColourMask    = 0;
  551.                                 ScrollLines[i] . Width        = 0;
  552.                             }
  553.  
  554.                                 /* Decrease number of last line. */
  555.  
  556.                             if(SaveMaxY == LastLine)
  557.                             {
  558.                                 if(ScrollLineLast > Temp)
  559.                                     ScrollLineLast -= Temp;
  560.                                 else
  561.                                     ScrollLineLast = 0;
  562.                             }
  563.  
  564.                                 /* Decrease number of first line. */
  565.  
  566.                             if(!SaveMinY)
  567.                             {
  568.                                 if(ScrollLineFirst > Temp)
  569.                                     ScrollLineFirst -= Temp;
  570.                                 else
  571.                                     ScrollLineFirst = 0;
  572.                             }
  573.                         }
  574.  
  575.                             /* Adapt possible changes in the lines for first and last line. */
  576.  
  577.                         while(ScrollLineFirst < RasterHeight)
  578.                         {
  579.                             if(ScrollLines[ScrollLineFirst] . Left > ScrollLines[ScrollLineFirst] . Right)
  580.                                 ScrollLineFirst++;
  581.                             else
  582.                                 break;
  583.                         }
  584.  
  585.                         while(ScrollLineLast > 0)
  586.                         {
  587.                             if(ScrollLines[ScrollLineLast] . Left > ScrollLines[ScrollLineLast] . Right)
  588.                                 ScrollLineLast--;
  589.                             else
  590.                                 break;
  591.                         }
  592.  
  593.                             /* Set the colour mask. */
  594.  
  595.                         SetMask(RPort,ScrollLineMask);
  596.  
  597.                             /* Add margin for italics or boldface. */
  598.  
  599.                         if(MaxX == ScrollLineRight)
  600.                             MaxX += FontRightExtend;
  601.                     }
  602.                 }
  603.             }
  604.         }
  605.         else
  606.         {
  607.                 /* Are we to scroll a line in horizontal direction? If so, use the
  608.                  * colour mask of the current line.
  609.                  */
  610.  
  611.             if(!DeltaX)
  612.             {
  613.                     /* Any data on screen worth scrolling? */
  614.  
  615.                 if(ScrollLineFirst <= ScrollLineLast)
  616.                 {
  617.                     WORD Temp,First,Last,SaveMinY = MinY / TextFontHeight,SaveMaxY = MaxY / TextFontHeight,ScrollLineLeft = 32767,ScrollLineRight = 0,i;
  618.  
  619.                         /* Build both the colour mask and the margins. */
  620.  
  621.                     for(i = MinY / TextFontHeight ; i <= MaxY / TextFontHeight ; i++)
  622.                     {
  623.                         if(ScrollLines[i] . Width)
  624.                         {
  625.                             if((Temp = ScrollLines[i] . Left * ScrollLines[i] . Width) < ScrollLineLeft)
  626.                                 ScrollLineLeft = Temp;
  627.  
  628.                             if((Temp = (ScrollLines[i] . Right * ScrollLines[i] . Width) - 1) > ScrollLineRight)
  629.                                 ScrollLineRight = Temp;
  630.                         }
  631.                     }
  632.  
  633.                         /* Sensible results? */
  634.  
  635.                     if(ScrollLineLeft <= ScrollLineRight)
  636.                     {
  637.                             /* Determine new left margin. */
  638.  
  639.                         if(ScrollLineLeft > MinX)
  640.                             MinX = ScrollLineLeft;
  641.  
  642.                             /* Determine new right margin. */
  643.  
  644.                         if(ScrollLineRight < MaxX)
  645.                             MaxX = ScrollLineRight;
  646.  
  647.                             /* Scroll down or up? */
  648.  
  649.                         if(DeltaY < 0)
  650.                         {
  651.                                 /* So we are to scroll down, find the first
  652.                                  * blank line if any.
  653.                                  */
  654.  
  655.                             if((Temp = MUL_Y(ScrollLineFirst)) > MinY)
  656.                                 MinY = Temp;
  657.  
  658.                                 /* Find the last blank lines if any. */
  659.  
  660.                             if((Temp = MUL_Y(ScrollLineLast + 1) - DeltaY - 1) < MaxY)
  661.                                 MaxY = Temp;
  662.  
  663.                                 /* Determine margins and the like... */
  664.  
  665.                             Last    = (MaxY + 1) / TextFontHeight;
  666.                             First    = Last - ((MaxY - MinY + TextFontHeight + DeltaY) / TextFontHeight);
  667.                             Temp    = (-DeltaY) / TextFontHeight;
  668.  
  669.                                 /* Move the scroll line info up. */
  670.  
  671.                             for(i = Last - 1 ; i >= First ; i--)
  672.                                 ScrollLines[i] = ScrollLines[i - Temp];
  673.  
  674.                                 /* Clear the remaining lines. */
  675.  
  676.                             for(i = First - Temp ; i < First ; i++)
  677.                             {
  678.                                 ScrollLines[i] . Left        = 32767;
  679.                                 ScrollLines[i] . Right        = 0;
  680.                                 ScrollLines[i] . Width        = 0;
  681.                             }
  682.  
  683.                                 /* Is the first line we were working
  684.                                  * on the first line of the whole display?
  685.                                  * If so, update the line marker.
  686.                                  */
  687.  
  688.                             if(!SaveMinY)
  689.                                 ScrollLineFirst += Temp;
  690.  
  691.                                 /* Now take a look at the last line.
  692.                                  * If the last line we were working
  693.                                  * on is in fact the last line of the
  694.                                  * display, update the line marker.
  695.                                  */
  696.  
  697.                             if(SaveMaxY == LastLine)
  698.                             {
  699.                                 ScrollLineLast += Temp;
  700.  
  701.                                 if(ScrollLineLast > LastLine)
  702.                                     ScrollLineLast = LastLine;
  703.                             }
  704.                         }
  705.                         else
  706.                         {
  707.                                 /* So we are to scroll up, find the last
  708.                                  * blank line if any.
  709.                                  */
  710.  
  711.                             if((Temp = MUL_Y(ScrollLineLast + 1) - 1) < MaxY)
  712.                                 MaxY = Temp;
  713.  
  714.                                 /* Find the first blank lines if any. */
  715.  
  716.                             if((Temp = MUL_Y(ScrollLineFirst) - DeltaY) > MinY)
  717.                                 MinY = Temp;
  718.  
  719.                                 /* Determine margins and the like... */
  720.  
  721.                             First    = MinY / TextFontHeight;
  722.                             Last    = ((MaxY - MinY + TextFontHeight - DeltaY) / TextFontHeight);
  723.                             Temp    = DeltaY / TextFontHeight;
  724.  
  725.                                 /* Move the scroll line info down. */
  726.  
  727.                             for(i = First ; i < First + Last ; i++)
  728.                                 ScrollLines[i] = ScrollLines[i + Temp];
  729.  
  730.                                 /* Clear the remaining lines. */
  731.  
  732.                             for(i = First + Last ; i < First + Last + Temp ; i++)
  733.                             {
  734.                                 ScrollLines[i] . Left        = 32767;
  735.                                 ScrollLines[i] . Right        = 0;
  736.                                 ScrollLines[i] . Width        = 0;
  737.                             }
  738.  
  739.                                 /* Decrease number of last line. */
  740.  
  741.                             if(SaveMaxY == LastLine)
  742.                             {
  743.                                 if(ScrollLineLast > Temp)
  744.                                     ScrollLineLast -= Temp;
  745.                                 else
  746.                                     ScrollLineLast = 0;
  747.                             }
  748.  
  749.                                 /* Decrease number of first line. */
  750.  
  751.                             if(!SaveMinY)
  752.                             {
  753.                                 if(ScrollLineFirst > Temp)
  754.                                     ScrollLineFirst -= Temp;
  755.                                 else
  756.                                     ScrollLineFirst = 0;
  757.                             }
  758.                         }
  759.  
  760.                             /* Adapt possible changes in the lines for first and last line. */
  761.  
  762.                         while(ScrollLineFirst < RasterHeight)
  763.                         {
  764.                             if(ScrollLines[ScrollLineFirst] . Left > ScrollLines[ScrollLineFirst] . Right)
  765.                                 ScrollLineFirst++;
  766.                             else
  767.                                 break;
  768.                         }
  769.  
  770.                         while(ScrollLineLast > 0)
  771.                         {
  772.                             if(ScrollLines[ScrollLineLast] . Left > ScrollLines[ScrollLineLast] . Right)
  773.                                 ScrollLineLast--;
  774.                             else
  775.                                 break;
  776.                         }
  777.  
  778.                             /* Add margin for italics or boldface. */
  779.  
  780.                         if(MaxX == ScrollLineRight)
  781.                             MaxX += FontRightExtend;
  782.                     }
  783.                 }
  784.             }
  785.         }
  786.     }
  787.  
  788.         /* And scroll the raster. */
  789.  
  790.     if(MinX < MaxX && MinY < MaxY)
  791.     {
  792.         MinX += WindowLeft;
  793.         MaxX += WindowLeft;
  794.  
  795.         MinY += WindowTop;
  796.         MaxY += WindowTop;
  797.  
  798.             /* Smooth scrolling required? */
  799.  
  800.         if(Smooth && DeltaY)
  801.         {
  802.             WORD Lines,Extra;
  803.  
  804.             Lines = ABS(DeltaY);
  805.             Extra = Lines & 1;
  806.             Lines = Lines / 2;
  807.  
  808.             if(DeltaY > 0)
  809.             {
  810.                 while(Lines--)
  811.                 {
  812.                     WaitTOF();
  813.  
  814.                     ScrollRaster(RPort,0,2,MinX,MinY,MaxX,MaxY);
  815.                 }
  816.  
  817.                 if(Extra)
  818.                 {
  819.                     WaitTOF();
  820.  
  821.                     ScrollRaster(RPort,0,1,MinX,MinY,MaxX,MaxY);
  822.                 }
  823.             }
  824.             else
  825.             {
  826.                 while(Lines--)
  827.                 {
  828.                     WaitTOF();
  829.  
  830.                     ScrollRaster(RPort,0,-2,MinX,MinY,MaxX,MaxY);
  831.                 }
  832.  
  833.                 if(Extra)
  834.                 {
  835.                     WaitTOF();
  836.  
  837.                     ScrollRaster(RPort,0,-1,MinX,MinY,MaxX,MaxY);
  838.                 }
  839.             }
  840.         }
  841.         else
  842.             ScrollRaster(RPort,DeltaX,DeltaY,MinX,MinY,MaxX,MaxY);
  843.     }
  844. }
  845.  
  846.     /* ScrollLineEraseScreen(BYTE Mode):
  847.      *
  848.      *    Erase a part of the screen.
  849.      */
  850.  
  851. VOID __regargs
  852. ScrollLineEraseScreen(BYTE Mode)
  853. {
  854.     if(GetBitMapDepth(RPort -> BitMap) > 1)
  855.     {
  856.         WORD BackPen,i;
  857.  
  858.         if(TextAttributeTable[Attributes] & ATTR_INVERSE)
  859.             BackPen = FgPen;
  860.         else
  861.             BackPen = BgPen;
  862.  
  863.         if(BackPen)
  864.         {
  865.             switch(Mode)
  866.             {
  867.                     /* Erase from first line to current cursor line (inclusive). */
  868.  
  869.                 case 1:    ScrollLineFirst = CursorY;
  870.  
  871.                         /* Reset the lines. */
  872.  
  873.                     for(i = 0 ; i < CursorY ; i++)
  874.                     {
  875.                         ScrollLines[i] . Left        = 0;
  876.                         ScrollLines[i] . Right        = LastColumn + 1;
  877.                         ScrollLines[i] . ColourMask    = BackPen;
  878.                         ScrollLines[i] . Width        = TextFontWidth;
  879.                     }
  880.  
  881.                     ScrollLines[CursorY] . Width        = GetFontWidth();
  882.                     ScrollLines[CursorY] . Left        = 0;
  883.                     ScrollLines[CursorY] . Right        = (LastPixel + 1) / ScrollLines[CursorY] . Width;
  884.                     ScrollLines[CursorY] . ColourMask    = BackPen;
  885.  
  886.                     if(ScrollLineLast < CursorY)
  887.                         ScrollLineLast = CursorY;
  888.  
  889.                     break;
  890.  
  891.                     /* Erase entire screen. */
  892.  
  893.                 case 2:    for(i = 0 ; i < RasterHeight ; i++)
  894.                     {
  895.                         ScrollLines[i] . Left        = 0;
  896.                         ScrollLines[i] . Right        = LastColumn + 1;
  897.                         ScrollLines[i] . ColourMask    = BackPen;
  898.                         ScrollLines[i] . Width        = TextFontWidth;
  899.                     }
  900.  
  901.                     ScrollLineFirst    = 0;
  902.                     ScrollLineLast    = RasterHeight - 1;
  903.  
  904.                     break;
  905.  
  906.                     /* Erase from current cursor position to end of screen. */
  907.  
  908.                 default:for(i = CursorY + 1 ; i < RasterHeight ; i++)
  909.                     {
  910.                         ScrollLines[i] . Left        = 0;
  911.                         ScrollLines[i] . Right        = LastColumn + 1;
  912.                         ScrollLines[i] . ColourMask    = BackPen;
  913.                         ScrollLines[i] . Width        = TextFontWidth;
  914.                     }
  915.  
  916.                     ScrollLines[CursorY] . Width        = GetFontWidth();
  917.                     ScrollLines[CursorY] . Left        = 0;
  918.                     ScrollLines[CursorY] . Right        = (LastPixel + 1) / ScrollLines[CursorY] . Width;
  919.                     ScrollLines[CursorY] . ColourMask    = BackPen;
  920.  
  921.                     if(ScrollLineFirst > CursorY)
  922.                         ScrollLineFirst = CursorY;
  923.  
  924.                     ScrollLineLast = RasterHeight - 1;
  925.  
  926.                     break;
  927.             }
  928.  
  929.                 /* Adapt possible changes in the lines for first and last line. */
  930.  
  931.             while(ScrollLineFirst < RasterHeight)
  932.             {
  933.                 if(ScrollLines[ScrollLineFirst] . Left > ScrollLines[ScrollLineFirst] . Right)
  934.                     ScrollLineFirst++;
  935.                 else
  936.                     break;
  937.             }
  938.  
  939.             while(ScrollLineLast > 0)
  940.             {
  941.                 if(ScrollLines[ScrollLineLast] . Left > ScrollLines[ScrollLineLast] . Right)
  942.                     ScrollLineLast--;
  943.                 else
  944.                     break;
  945.             }
  946.  
  947.             return;
  948.         }
  949.  
  950.         switch(Mode)
  951.         {
  952.                 /* Erase from first line to current cursor line (inclusive). */
  953.  
  954.             case 1:    ScrollLineFirst = CursorY;
  955.  
  956.                     /* Reset the lines. */
  957.  
  958.                 for(i = 0 ; i < CursorY ; i++)
  959.                 {
  960.                     ScrollLines[i] . Left        = 32767;
  961.                     ScrollLines[i] . Right        = 0;
  962.                     ScrollLines[i] . ColourMask    = 0;
  963.                     ScrollLines[i] . Width        = 0;
  964.                 }
  965.  
  966.                 ScrollLines[CursorY] . Left = CursorX + 1;
  967.  
  968.                 if(ScrollLines[CursorY] . Right < ScrollLines[CursorY] . Left)
  969.                 {
  970.                     ScrollLines[CursorY] . Left    = 32767;
  971.                     ScrollLines[CursorY] . Right    = 0;
  972.                 }
  973.  
  974.                 break;
  975.  
  976.                 /* Erase entire screen. */
  977.  
  978.             case 2:    for(i = 0 ; i < RasterHeight ; i++)
  979.                 {
  980.                     ScrollLines[i] . Left        = 32767;
  981.                     ScrollLines[i] . Right        = 0;
  982.                     ScrollLines[i] . ColourMask    = 0;
  983.                     ScrollLines[i] . Width        = 0;
  984.                 }
  985.  
  986.                 ScrollLineFirst    = 32767;
  987.                 ScrollLineLast    = 0;
  988.  
  989.                 break;
  990.  
  991.                 /* Erase from current cursor position to end of screen. */
  992.  
  993.             default:for(i = CursorY + 1 ; i < RasterHeight ; i++)
  994.                 {
  995.                     ScrollLines[i] . Left        = 32767;
  996.                     ScrollLines[i] . Right        = 0;
  997.                     ScrollLines[i] . ColourMask    = 0;
  998.                     ScrollLines[i] . Width        = 0;
  999.                 }
  1000.  
  1001.                 if(CursorX)
  1002.                 {
  1003.                     ScrollLines[CursorY] . Right = CursorX;
  1004.  
  1005.                     if(ScrollLines[CursorY] . Right < ScrollLines[CursorY] . Left)
  1006.                     {
  1007.                         ScrollLines[CursorY] . Left    = 32767;
  1008.                         ScrollLines[CursorY] . Right    = 0;
  1009.                     }
  1010.                 }
  1011.                 else
  1012.                 {
  1013.                     ScrollLines[CursorY] . Left    = 32767;
  1014.                     ScrollLines[CursorY] . Right    = 0;
  1015.                 }
  1016.  
  1017.                     /* Cleared the entire screen? */
  1018.  
  1019.                 if(CursorY)
  1020.                     ScrollLineLast = CursorY;
  1021.                 else
  1022.                 {
  1023.                     ScrollLineFirst    = 32767;
  1024.                     ScrollLineLast    = 0;
  1025.                 }
  1026.  
  1027.                 break;
  1028.         }
  1029.  
  1030.             /* Adapt possible changes in the lines for first and last line. */
  1031.  
  1032.         while(ScrollLineFirst < RasterHeight)
  1033.         {
  1034.             if(ScrollLines[ScrollLineFirst] . Left > ScrollLines[ScrollLineFirst] . Right)
  1035.                 ScrollLineFirst++;
  1036.             else
  1037.                 break;
  1038.         }
  1039.  
  1040.         while(ScrollLineLast > 0)
  1041.         {
  1042.             if(ScrollLines[ScrollLineLast] . Left > ScrollLines[ScrollLineLast] . Right)
  1043.                 ScrollLineLast--;
  1044.             else
  1045.                 break;
  1046.         }
  1047.     }
  1048. }
  1049.  
  1050.     /* ScrollLineEraseLine(BYTE Mode):
  1051.      *
  1052.      *    Erase parts of the current cursor line.
  1053.      */
  1054.  
  1055. VOID __regargs
  1056. ScrollLineEraseLine(BYTE Mode)
  1057. {
  1058.     if(GetBitMapDepth(RPort -> BitMap) > 1)
  1059.     {
  1060.         WORD BackPen;
  1061.  
  1062.         if(TextAttributeTable[Attributes] & ATTR_INVERSE)
  1063.             BackPen = FgPen;
  1064.         else
  1065.             BackPen = BgPen;
  1066.  
  1067.         if(BackPen)
  1068.         {
  1069.             switch(Mode)
  1070.             {
  1071.                     /* Erase from left margin to current cursor position (inclusive). */
  1072.  
  1073.                 case 1:    ScrollLines[CursorY] . Left = 0;
  1074.  
  1075.                     ScrollLines[CursorY] . ColourMask |= BackPen;
  1076.  
  1077.                     break;
  1078.  
  1079.                     /* Erase entire line. */
  1080.  
  1081.                 case 2:    ScrollLines[CursorY] . Width        = GetFontWidth();
  1082.                     ScrollLines[CursorY] . Left        = 0;
  1083.                     ScrollLines[CursorY] . Right        = (LastPixel + 1) / ScrollLines[CursorY] . Width;
  1084.                     ScrollLines[CursorY] . ColourMask    = BackPen;
  1085.  
  1086.                     break;
  1087.  
  1088.                     /* Erase from current cursor position towards end of line. */
  1089.  
  1090.                 default:if(CursorX)
  1091.                     {
  1092.                         if(!ScrollLines[CursorY] . Width)
  1093.                             ScrollLines[CursorY] . Width = GetFontWidth();
  1094.  
  1095.                         ScrollLines[CursorY] . Right = (LastPixel + 1) / ScrollLines[CursorY] . Width;
  1096.  
  1097.                         ScrollLines[CursorY] . ColourMask |= BackPen;
  1098.                     }
  1099.                     else
  1100.                     {
  1101.                         ScrollLines[CursorY] . Width        = GetFontWidth();
  1102.                         ScrollLines[CursorY] . Left        = 0;
  1103.                         ScrollLines[CursorY] . Right        = (LastPixel + 1) / ScrollLines[CursorY] . Width;
  1104.                         ScrollLines[CursorY] . ColourMask    = BackPen;
  1105.                     }
  1106.  
  1107.                     break;
  1108.             }
  1109.  
  1110.                 /* Adapt possible changes in the lines for first and last line. */
  1111.  
  1112.             while(ScrollLineFirst < RasterHeight)
  1113.             {
  1114.                 if(ScrollLines[ScrollLineFirst] . Left > ScrollLines[ScrollLineFirst] . Right)
  1115.                     ScrollLineFirst++;
  1116.                 else
  1117.                     break;
  1118.             }
  1119.  
  1120.             while(ScrollLineLast > 0)
  1121.             {
  1122.                 if(ScrollLines[ScrollLineLast] . Left > ScrollLines[ScrollLineLast] . Right)
  1123.                     ScrollLineLast--;
  1124.                 else
  1125.                     break;
  1126.             }
  1127.  
  1128.             return;
  1129.         }
  1130.  
  1131.         switch(Mode)
  1132.         {
  1133.                 /* Erase from left margin to current cursor position (inclusive). */
  1134.  
  1135.             case 1:    ScrollLines[CursorY] . Left = CursorX + 1;
  1136.                 break;
  1137.  
  1138.                 /* Erase entire line. */
  1139.  
  1140.             case 2:    ScrollLines[CursorY] . Left    = 32767;
  1141.                 ScrollLines[CursorY] . Right    = 0;
  1142.  
  1143.                 break;
  1144.  
  1145.                 /* Erase from current cursor position towards end of line. */
  1146.  
  1147.             default:if(CursorX)
  1148.                     ScrollLines[CursorY] . Right = CursorX;
  1149.                 else
  1150.                 {
  1151.                     ScrollLines[CursorY] . Left    = 32767;
  1152.                     ScrollLines[CursorY] . Right    = 0;
  1153.                 }
  1154.  
  1155.                 break;
  1156.         }
  1157.  
  1158.             /* Adapt possible changes in the lines for first and last line. */
  1159.  
  1160.         while(ScrollLineFirst < RasterHeight)
  1161.         {
  1162.             if(ScrollLines[ScrollLineFirst] . Left > ScrollLines[ScrollLineFirst] . Right)
  1163.                 ScrollLineFirst++;
  1164.             else
  1165.                 break;
  1166.         }
  1167.  
  1168.         while(ScrollLineLast > 0)
  1169.         {
  1170.             if(ScrollLines[ScrollLineLast] . Left > ScrollLines[ScrollLineLast] . Right)
  1171.                 ScrollLineLast--;
  1172.             else
  1173.                 break;
  1174.         }
  1175.     }
  1176. }
  1177.  
  1178.     /* ScrollLineEraseCharacters(WORD Chars):
  1179.      *
  1180.      *    Erase a number of characters in the current cursor line.
  1181.      */
  1182.  
  1183. VOID __regargs
  1184. ScrollLineEraseCharacters(WORD Chars)
  1185. {
  1186.     if(GetBitMapDepth(RPort -> BitMap) > 1)
  1187.     {
  1188.         WORD BackPen;
  1189.  
  1190.         if(TextAttributeTable[Attributes] & ATTR_INVERSE)
  1191.             BackPen = FgPen;
  1192.         else
  1193.             BackPen = BgPen;
  1194.  
  1195.             /* Any characters to erase? */
  1196.  
  1197.         if(BackPen)
  1198.         {
  1199.             if(!ScrollLines[CursorY] . Width)
  1200.                 ScrollLines[CursorY] . Width = GetFontWidth();
  1201.  
  1202.             ScrollLines[CursorY] . Left    = 0;
  1203.             ScrollLines[CursorY] . Right    = (LastPixel + 1) / ScrollLines[CursorY] . Width;
  1204.  
  1205.             ScrollLines[CursorY] . ColourMask |= BackPen;
  1206.         }
  1207.         else
  1208.         {
  1209.             if(ScrollLines[CursorY] . Right)
  1210.                 ScrollLines[CursorY] . Right -= Chars;
  1211.         }
  1212.     }
  1213. }
  1214.  
  1215.     /* ScrollLineShiftChar(WORD Size):
  1216.      *
  1217.      *    Shift the characters following the current cursor position
  1218.      *    Size characters to the right.
  1219.      */
  1220.  
  1221. VOID __regargs
  1222. ScrollLineShiftChar(WORD Size)
  1223. {
  1224.     if(GetBitMapDepth(RPort -> BitMap) > 1)
  1225.     {
  1226.         WORD BackPen;
  1227.  
  1228.         if(TextAttributeTable[Attributes] & ATTR_INVERSE)
  1229.             BackPen = FgPen;
  1230.         else
  1231.             BackPen = BgPen;
  1232.  
  1233.             /* Any characters to scroll? */
  1234.  
  1235.         if(BackPen)
  1236.         {
  1237.             if(!ScrollLines[CursorY] . Width)
  1238.                 ScrollLines[CursorY] . Width = GetFontWidth();
  1239.  
  1240.             ScrollLines[CursorY] . Left    = 0;
  1241.             ScrollLines[CursorY] . Right    = (LastPixel + 1) / ScrollLines[CursorY] . Width;
  1242.  
  1243.             ScrollLines[CursorY] . ColourMask |= BackPen;
  1244.         }
  1245.         else
  1246.         {
  1247.             if(ScrollLines[CursorY] . Right > 0)
  1248.                 ScrollLines[CursorY] . Right += Size;
  1249.         }
  1250.     }
  1251. }
  1252.  
  1253.     /* ScrollLinePutString(WORD Length):
  1254.      *
  1255.      *    Update the line info according to the length of a string
  1256.      *    to be printed.
  1257.      */
  1258.  
  1259. VOID __regargs
  1260. ScrollLinePutString(WORD Length)
  1261. {
  1262.     if(GetBitMapDepth(RPort -> BitMap) > 1 && Length)
  1263.     {
  1264.         LONG Width;
  1265.  
  1266.             /* Which scale is the font we are currently using? */
  1267.  
  1268.         if(RasterAttr[CursorY] >= SCALE_ATTR_TOP2X)
  1269.         {
  1270.                 /* Valid length? */
  1271.  
  1272.             if(CursorX + Length >= RasterWidth / 2)
  1273.                 Length = (RasterWidth / 2) - CursorX;
  1274.  
  1275.                 /* Double width. */
  1276.  
  1277.             Width = TextFontWidth * 2;
  1278.         }
  1279.         else
  1280.         {
  1281.             if(Config -> EmulationConfig -> FontScale == SCALE_HALF)
  1282.             {
  1283.                     /* Valid length? */
  1284.  
  1285.                 if(CursorX + Length >= RasterWidth * 2)
  1286.                     Length = (RasterWidth * 2) - CursorX;
  1287.  
  1288.                     /* Half width. */
  1289.  
  1290.                 Width = TextFontWidth / 2;
  1291.             }
  1292.             else
  1293.             {
  1294.                     /* Valid length? */
  1295.  
  1296.                 if(CursorX + Length >= RasterWidth)
  1297.                     Length = RasterWidth - CursorX;
  1298.  
  1299.                     /* Normal width. */
  1300.  
  1301.                 Width = TextFontWidth;
  1302.             }
  1303.         }
  1304.  
  1305.             /* Sensible value? */
  1306.  
  1307.         if(Length > 0)
  1308.         {
  1309.             if(UseMasking)
  1310.             {
  1311.                 struct ScrollLineInfo *Alias = &ScrollLines[CursorY];
  1312.  
  1313.                     /* Update line colour mask. */
  1314.  
  1315.                 Alias -> ColourMask |= FgPen | BgPen;
  1316.  
  1317.                     /* Update font scale. */
  1318.  
  1319.                 Alias -> Width = Width;
  1320.  
  1321.                     /* Set write mask (will affect Text() since it is called
  1322.                      * after this routine has finished.
  1323.                      */
  1324.  
  1325.                 SetMask(RPort,Alias -> ColourMask);
  1326.  
  1327.                     /* Update right margin. */
  1328.  
  1329.                 if(CursorX < Alias -> Left)
  1330.                     Alias -> Left = CursorX;
  1331.  
  1332.                     /* Update left margin. */
  1333.  
  1334.                 if(CursorX + Length > Alias -> Right)
  1335.                     Alias -> Right = CursorX + Length;
  1336.  
  1337.                     /* Update topmost line. */
  1338.  
  1339.                 if(CursorY < ScrollLineFirst)
  1340.                     ScrollLineFirst = CursorY;
  1341.  
  1342.                     /* Update bottommost line. */
  1343.  
  1344.                 if(CursorY > ScrollLineLast)
  1345.                     ScrollLineLast = CursorY;
  1346.             }
  1347.             else
  1348.             {
  1349.                 struct ScrollLineInfo *Alias = &ScrollLines[CursorY];
  1350.  
  1351.                     /* Update font scale. */
  1352.  
  1353.                 Alias -> Width = Width;
  1354.  
  1355.                     /* Update right margin. */
  1356.  
  1357.                 if(CursorX < Alias -> Left)
  1358.                     Alias -> Left = CursorX;
  1359.  
  1360.                     /* Update left margin. */
  1361.  
  1362.                 if(CursorX + Length > Alias -> Right)
  1363.                     Alias -> Right = CursorX + Length;
  1364.  
  1365.                     /* Update topmost line. */
  1366.  
  1367.                 if(CursorY < ScrollLineFirst)
  1368.                     ScrollLineFirst = CursorY;
  1369.  
  1370.                     /* Update bottommost line. */
  1371.  
  1372.                 if(CursorY > ScrollLineLast)
  1373.                     ScrollLineLast = CursorY;
  1374.             }
  1375.         }
  1376.     }
  1377. }
  1378.