home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / SCHORIZ.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  3.4 KB  |  107 lines

  1. /**
  2. *
  3. * Name        schoriz -- Horizontally scroll columns of text on the
  4. *               current display page via BIOS
  5. *
  6. * Synopsis    scrolled = schoriz(num_cols,attrib,
  7. *                    u_row,u_col,l_row,l_col,dir);
  8. *
  9. *        int scrolled      Number of columns actually scrolled.
  10. *        int num_cols      Number of columns to scroll.    A value
  11. *                  of 0 specifies that all columns
  12. *                  within the region should be scrolled
  13. *                  (thus clearing the region).
  14. *        int attrib      If the screen is in text mode, this
  15. *                  is the attribute to be used on the
  16. *                  vacant columns.  It has the background
  17. *                  attribute in the high order four bits
  18. *                  of the low order byte, and the
  19. *                  foreground in the low order nybble.
  20. *                  If the screen is in graphics mode, this
  21. *                  is the color to use for the scrolled text.
  22. *        int u_row,u_col   Upper left corner of region.
  23. *        int l_row,l_col   Lower right corner of region.
  24. *        int dir       Scrolling direction (SCR_LEFT or
  25. *                  SCR_RIGHT).
  26. *
  27. * Description    This function moves columns of characters within a
  28. *        rectangular region to the left or right.  The vacant
  29. *        columns are filled with blanks and a specified
  30. *        attribute.
  31. *
  32. *        Use VIHORIZ for greater speed in text modes.
  33. *
  34. * Returns    scrolled      Number of columns actually scrolled.
  35. *
  36. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  37. *
  38. **/
  39.  
  40. #include <bscreen.h>
  41. #include <butility.h>
  42.  
  43. int schoriz(num_cols,attrib,u_row,u_col,l_row,l_col,dir)
  44. int num_cols,attrib,u_row,u_col,l_row,l_col,dir;
  45. {
  46.     int  mode,columns,apage;           /* Values returned by scmode    */
  47.     int  graphics,last_row;
  48.     char buffer[160],*pbuffer;
  49.     int  row,i;
  50.     int  save_row,save_col;
  51.     int  fore,back,source,target,width,text_width;
  52.  
  53.     scmode(&mode,&columns,&apage);
  54.     graphics = (mode > 3 && mode != 7);
  55.     last_row = scrows() - 1;
  56.     utbound(u_col,0,columns - 1)        /* Force reasonable values */
  57.     utbound(l_col,u_col,columns - 1)
  58.     width = l_col - u_col + 1;
  59.     if (num_cols <= 0 || num_cols > width)
  60.     num_cols = width;           /* Do not scroll more columns   */
  61.                        /* than there are in the window.*/
  62.     if (num_cols >= width)
  63.     {                       /* Clear the window the easy way*/
  64.     scpscrol(0,attrib,u_row,u_col,l_row,l_col,SCR_UP);
  65.     return num_cols;
  66.     }
  67.     utbound(u_row,0,last_row)
  68.     utbound(l_row,u_row,last_row)
  69.     if (graphics)              /* Force attribute for graphics */
  70.     utbound(attrib,0,3)
  71.     fore = utlonyb(attrib);
  72.     back = uthinyb(attrib);
  73.  
  74.     if (dir == SCR_LEFT)
  75.     {                      /* Leftward              */
  76.     source = u_col + num_cols;
  77.     target = u_col;
  78.     }
  79.     else
  80.     {                      /* Rightward              */
  81.     source = u_col;
  82.     target = u_col + num_cols;
  83.     }
  84.     text_width = width - num_cols;
  85.  
  86.     sccurpos(&save_row,&save_col);
  87.  
  88.     for (row = u_row; row <= l_row; row++)
  89.     {
  90.     scrdbuf(row,source,text_width,buffer,CHAR_ATTR | CUR_BEG);
  91.     if (dir == SCR_RIGHT)          /* Rightward              */
  92.         scattrib(fore,back,(char) ' ',num_cols);
  93.     if (graphics)
  94.         for (i = 0,pbuffer = buffer + 1; i < text_width; i++)
  95.         {
  96.         *pbuffer = (char) attrib;    /* Set attributes of     */
  97.         pbuffer += 2;             /* scrolled text          */
  98.         }
  99.     scwrbuf(row,target,text_width,buffer,0,0,CHAR_ATTR | CUR_AFTER);
  100.     if (dir == SCR_LEFT)          /* Leftward              */
  101.         scattrib(fore,back,(char) ' ',num_cols);
  102.     }
  103.  
  104.     sccurset(save_row,save_col);
  105.     return num_cols;
  106. }
  107.