home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name schoriz -- Horizontally scroll columns of text on the
- * current display page via BIOS
- *
- * Synopsis scrolled = schoriz(num_cols,attrib,
- * u_row,u_col,l_row,l_col,dir);
- *
- * int scrolled Number of columns actually scrolled.
- * int num_cols Number of columns to scroll. A value
- * of 0 specifies that all columns
- * within the region should be scrolled
- * (thus clearing the region).
- * int attrib If the screen is in text mode, this
- * is the attribute to be used on the
- * vacant columns. It has the background
- * attribute in the high order four bits
- * of the low order byte, and the
- * foreground in the low order nybble.
- * If the screen is in graphics mode, this
- * is the color to use for the scrolled text.
- * int u_row,u_col Upper left corner of region.
- * int l_row,l_col Lower right corner of region.
- * int dir Scrolling direction (SCR_LEFT or
- * SCR_RIGHT).
- *
- * Description This function moves columns of characters within a
- * rectangular region to the left or right. The vacant
- * columns are filled with blanks and a specified
- * attribute.
- *
- * Use VIHORIZ for greater speed in text modes.
- *
- * Returns scrolled Number of columns actually scrolled.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bscreen.h>
- #include <butility.h>
-
- int schoriz(num_cols,attrib,u_row,u_col,l_row,l_col,dir)
- int num_cols,attrib,u_row,u_col,l_row,l_col,dir;
- {
- int mode,columns,apage; /* Values returned by scmode */
- int graphics,last_row;
- char buffer[160],*pbuffer;
- int row,i;
- int save_row,save_col;
- int fore,back,source,target,width,text_width;
-
- scmode(&mode,&columns,&apage);
- graphics = (mode > 3 && mode != 7);
- last_row = scrows() - 1;
- utbound(u_col,0,columns - 1) /* Force reasonable values */
- utbound(l_col,u_col,columns - 1)
- width = l_col - u_col + 1;
- if (num_cols <= 0 || num_cols > width)
- num_cols = width; /* Do not scroll more columns */
- /* than there are in the window.*/
- if (num_cols >= width)
- { /* Clear the window the easy way*/
- scpscrol(0,attrib,u_row,u_col,l_row,l_col,SCR_UP);
- return num_cols;
- }
- utbound(u_row,0,last_row)
- utbound(l_row,u_row,last_row)
- if (graphics) /* Force attribute for graphics */
- utbound(attrib,0,3)
- fore = utlonyb(attrib);
- back = uthinyb(attrib);
-
- if (dir == SCR_LEFT)
- { /* Leftward */
- source = u_col + num_cols;
- target = u_col;
- }
- else
- { /* Rightward */
- source = u_col;
- target = u_col + num_cols;
- }
- text_width = width - num_cols;
-
- sccurpos(&save_row,&save_col);
-
- for (row = u_row; row <= l_row; row++)
- {
- scrdbuf(row,source,text_width,buffer,CHAR_ATTR | CUR_BEG);
- if (dir == SCR_RIGHT) /* Rightward */
- scattrib(fore,back,(char) ' ',num_cols);
- if (graphics)
- for (i = 0,pbuffer = buffer + 1; i < text_width; i++)
- {
- *pbuffer = (char) attrib; /* Set attributes of */
- pbuffer += 2; /* scrolled text */
- }
- scwrbuf(row,target,text_width,buffer,0,0,CHAR_ATTR | CUR_AFTER);
- if (dir == SCR_LEFT) /* Leftward */
- scattrib(fore,back,(char) ' ',num_cols);
- }
-
- sccurset(save_row,save_col);
- return num_cols;
- }