home *** CD-ROM | disk | FTP | other *** search
- /*********************
- *
- * sc_field.c - screen primitives for fields.
- *
- * Purpose: This file contains the low level screen functions for fields.
- *
- * Blackstar C Function Library
- * (c) Copyright 1985,1989 Sterling Castle Software
- *
- *******/
-
- #include <string.h>
- #include "blackstr.h"
- #include "kb_head.h"
- #include "sc_head.h"
-
-
- /********
- *
- * sc_scrlu(row,nrows) - scroll screen up
- *
- **/
-
- void sc_scrlu(int row, int nrows)
- {
- if(row<rowen_)
- sc_scroll(nrows,row,colst_,rowen_,colen_);
- else
- {
- sc_setcur(colst_,rowen_);
- sc_scroll(nrows,row,colst_,rowen_,colen_);
- }
- }
-
-
- /********
- *
- * sc_scrld(row,nrows) - scroll screen down nrows
- *
- **/
-
- void sc_scrld(int row, int nrows)
- {
- if(row<rowen_-1)
- sc_scroll(-nrows,row+1,colst_,rowen_,colen_);
- else if(row<rowen_)
- {
- sc_setcur(colst_,rowen_);
- sc_eeol();
- }
- }
-
-
- /********
- *
- * sc_clrf(n) - clear the screen field for n bytes
- *
- **/
-
- void sc_clrf(int n)
- {
- ut_push(sc_col_);
- n = min(n,colen_-sc_col_+1);
- sc_clrwin(sc_col_,sc_row_,sc_col_+n,sc_row_);
- sc_col_=ut_pop();
- }
-
-
- /********
- *
- * sc_putfi(i,n) - ouput integer onto screen in field n
- *
- **/
-
- void sc_putfi(int i, int n)
- {
- char str[16];
-
- sprintf(str,"%15d",i); /* convert to string */
- sc_putsfl(str,n);
- }
-
-
- /********
- *
- * sc_putsfl(str,n) - put string in field with clear
- *
- **/
-
- void sc_putsfl(char *str, int n)
- {
- sc_clrf(n); /* clear it first */
- sc_putsf(str,n);
- }
-
-
- /********
- *
- * sc_putsf(str,n) - put string in field of n bytes
- *
- **/
-
- void sc_putsf(char *str, int n)
- {
- ut_push(wrapf_);
- wrapf_ = FALSE; /* turn off wrap */
- while((n) && (*str!=NUL)) {
- sc_putc(*str++);
- --n;
- }
- wrapf_=ut_pop();
- }
-
-
- /********
- *
- * sc_putlf(line,n) - put line in field of n bytes
- *
- **/
-
- void sc_putlf(char *line, int n)
- {
- ut_push(wrapf_);
- wrapf_ = FALSE; /* turn off wrap */
- sc_clrf(n);
- while((n) && (*line!=NUL) && (*line!=NEWLINE)) {
- sc_putc(*line++);
- --n;
- }
- wrapf_=ut_pop();
- }
-
-
- /********
- *
- * sc_putsfr(str,n) - put string into field right justified
- *
- **/
-
- void sc_putsfr(char *str, int n)
- {
- int nf;
-
- nf = max(n-strlen(str),0);
- sc_movcur(nf,0);
- sc_putsfl(str,n-nf); /* clear field too */
- }
-
-
- /********
- *
- * sc_putsflr(str,n) - put string into field right justified w/clear
- *
- **/
-
- void sc_putsflr(char *str, int n)
- {
- sc_clrf(n);
- sc_putsfr(str,n); /* clear field too */
- }
-
-
- /********
- *
- * sc_putsflc(str,n) - put string in field cntr with clear
- *
- **/
-
- void sc_putsflc(char *str, int n)
- {
- sc_clrf(n);
- sc_putsfc(str,n);
- }
-
-
- /********
- *
- * sc_putsfc(char *str, int n) - put string into field centered
- *
- **/
-
- void sc_putsfc(char *str, int n)
- {
- int nf;
-
- nf = max(1+(n-strlen(str))/2,0);
- sc_movcur(nf,0);
- sc_putsf(str,n-nf);
- }
-
- /********
- *
- * sc_putifr(i,n) - put integer into field right justified
- *
- **/
-
- void sc_putifr(int i, int n)
- {
- char str[16];
-
- sprintf(str,"%d",i); /* convert to string base 10 */
- sc_putsfr(str,n);
- }
-
-
- /********
- *
- * sc_putifc(i,n) - put integer into field centered
- *
- **/
-
- void sc_putifc(int i, int n)
- {
- char str[16];
-
- sprintf(str,"%d",i);
- sc_putsfc(str,n);
- }
-