home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name viwrrect -- Write rectangular region directly to
- * the current display page
- *
- * Synopsis num_writ = viwrrect(u_row,u_col,l_row,l_col,
- * buffer,fore,back,option);
- *
- * int num_writ Number of character cells actually
- * written (0 if graphics mode)
- * int u_row Top row to write (0 = top of screen)
- * int u_col Leftmost column to write (0 = left edge)
- * int l_row Bottom row to write
- * int l_col Rightmost column to write
- * char *buffer Space containing the data to write
- * int fore If CHARS_ONLY is specified, a value
- * between 0 and 15 specifies a new
- * foreground attribute,
- * unless both fore and back are -1, in which
- * case existing attributes are preserved.
- * int back If CHARS_ONLY is specified, a value
- * between 0 and 15 specifies a new
- * background attribute,
- * unless both fore and back are -1, in which
- * case existing attributes are preserved.
- * int option One bit in the option value tells VIWRRECT
- * how the buffer is constructed. The two
- * possible values for this bit are:
- *
- * Value Meaning
- * ----------- ------------------------------------
- * CHARS_ONLY Buffer contains characters only.
- * The values of fore and back are used
- * as attributes, unless they are both -1,
- * in which case the existing screen
- * attributes are left unchanged.
- * CHAR_ATTR Buffer contains (char,attr) pairs.
- * The values of fore and back are ignored.
- *
- * Description This function fills a rectangular region on the current
- * display page with characters from a buffer with or
- * without their corresponding video attributes. The data
- * is written row by row. The cursor is not moved.
- *
- * This function works only for standard text modes (0, 1,
- * 2, 3, and 7). Use SCWRRECT for other modes.
- *
- * The upper left corner of the region is (u_row,u_col),
- * where (0,0) represents the upper left corner of the
- * entire screen. The lower right corner of the region is
- * (l_row,l_col), where (24,79) is the lower right corner
- * of an 80-by-25 screen.
- *
- * The returned value reports the number of "character
- * cells" written, where "character cells" means the number
- * of physical spaces on the screen. (If CHAR_ATTR is
- * specified, twice this number of bytes will be used from
- * the buffer.)
- *
- * Be aware that this function does NOT recognize NULs
- * ('\0') or any other special characters.
- *
- * Returns num_writ Number of character cells written
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bquery.h>
- #include <bscreen.h>
- #include <bvideo.h>
-
- int viwrrect(u_row,u_col,l_row,l_col,buffer,fore,back,option)
- int u_row,u_col,l_row,l_col;
- char *buffer;
- int fore,back,option;
- {
- int device,mode,last_row,columns,act_page;
- int height,width;
- int command;
- ADS buf_ads,scn_ads;
-
- device = scmode(&mode,&columns,&act_page);
- if (mode > 3 && mode != 7)
- return 0;
- last_row = scrows() - 1;
-
- utbound(u_row,0,last_row) /* Force reasonable values */
- utbound(l_row,u_row,last_row)
- utbound(u_col,0,columns - 1)
- utbound(l_col,u_col,columns - 1)
- height = l_row - u_row + 1;
- width = l_col - u_col + 1;
-
- utabsptr(buffer,&buf_ads);
- viads(u_row,u_col,&scn_ads);
-
- if (option & CHAR_ATTR)
- command = 1; /* (char,attr) pairs */
- else
- if (fore == -1 && back == -1)
- command = 0; /* Preserve attributes */
- else
- command = 2; /* Use fore and back as */
- /* constant attributes. */
-
- if ( mode == 7
- || scequip() == IBM_CV
- || device == b_ega)
- command |= 0x8000; /* Need not await retrace */
-
- vidirect(&buf_ads,&scn_ads,height,width,columns * 2,
- utnybbyt(back,fore),command);
- return height * width;
- }