home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / DEMOS / SC_TEST1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-22  |  4.7 KB  |  152 lines

  1. /*********************
  2.  *
  3.  *  sc_test1.c - screen functions test program.
  4.  *
  5.  *  Purpose: This file contains functions to test the the screen
  6.  *           functions. See also sc_test2.c
  7.  *
  8.  *  Blackstar C Function Library
  9.  *  (c) Copyright 1985 Sterling Castle Software
  10.  *
  11.  *******/
  12.  
  13. #include <stdio.h>
  14. #include "blackstr.h"
  15. #include "sc_head.h"
  16.  
  17. void main()
  18. {
  19.     int  i, j;
  20.  
  21.     kb_init(NULL,NULL,NULL);
  22.     sc_init(MO_CO80,BLUE,WHITE);  /* init screen to: Color              */
  23.                   /*                 80x25              */
  24.     sc_setcur(0,0);  sc_eeol();
  25.     sc_setcur(28,0);
  26.     sc_puts("Hello from screen test 1\n\r");
  27.  
  28.     sc_setcur(0,2);  sc_eeol();
  29.     sc_setcur(0,3);  sc_eeol();
  30.     sc_setcur(0,4);  sc_eeol();
  31.     sc_setcur(0,5);  sc_eeol();
  32.     sc_setcur(0,2);
  33.     sc_puts("Phase 1 - Functions tested: sc_init(), sc_setcur(), sc_eeol(), sc_puts()\n\r");
  34.     sc_puts("                             printf(), kb_getch()\n\r");
  35.     sc_puts("          Externals tested: sc_col_, sc_row_\n\r");
  36.     sc_puts("          Foreground = blue, background = white\n\r");
  37.  
  38.     sc_setcur(10,7);
  39.     sc_puts("Cursor should now be at column = 10, row = 7");
  40.     sc_setcur(10,8);
  41.     printf("Test of printf - attributes return to black & white");
  42.     sc_setcur(10,9);
  43.     printf("                 Numbers: %d %d %d",2,4,6,8);
  44.     sc_setcur(10,10);
  45.     printf("                 String:  %s", "Test string");
  46.     sc_setcur(10,11);
  47.     printf("Cursor is at column = %d, row = %d",sc_col_,sc_row_);
  48.  
  49.     sc_setcur(0,15);
  50.     sc_puts("Press any key to continue...");
  51.     kb_getc();
  52.  
  53.     sc_clr();
  54.     sc_color(WHITE,BLUE);
  55.     sc_setcur(0,0);  sc_eeol();
  56.     sc_setcur(0,1);  sc_eeol();
  57.     sc_setcur(0,0);
  58.     sc_puts("Phase 2 - Functions tested: sc_clr(), sc_color(), sc_box(), sc_windo()\n\r");
  59.     sc_puts("          Foreground = white, background = blue\n\r");
  60.  
  61.     sc_box(29,4,61,16);
  62.     sc_windo(30,5,60,15);
  63.     sc_setcur(0,0);
  64.     sc_puts("Now is the time for all good men to see ");
  65.     sc_puts("if the window wrap feature will work.");
  66.  
  67.     sc_setcur(0,15);
  68.     sc_puts("Press any key to continue...");
  69.     kb_getc();
  70.  
  71.     sc_windo(0,0,sc_cols_-1,sc_rows_-1);
  72.     sc_setcur(0,0);  sc_eeol();
  73.     sc_setcur(0,1);  sc_eeol();
  74.     sc_setcur(0,2);  sc_eeol();
  75.     sc_setcur(0,0);
  76.     sc_puts("Phase 3 - Functions tested: sc_attr(AT_REG), sc_attr(AT_INV), sc_attr(AT_BLINK)\n\r");
  77.     sc_puts("                            sc_scroll(), sc_clrwin()\n\r");
  78.     sc_puts("          Foreground = red, background = green\n\r");
  79.  
  80.     sc_color(RED,GREEN);
  81.     sc_windo(30,5,60,15);
  82.     sc_clrwin(30,5,60,15);
  83.     sc_setcur(0,0);
  84.     sc_puts("\n\rNow is the time for all good men to see regular");
  85.     sc_attr(AT_INV);
  86.     sc_puts("\n\rNow is the time for all good men to see inverse");
  87.     sc_attr(AT_BLINK);
  88.     sc_puts("\n\rNow is the time for all good men to see blinking or EGA color");
  89.     sc_attr(AT_REG);
  90.     sc_setcur(0,15);
  91.     sc_puts("Press any key to scroll up 1");
  92.     kb_getc();
  93.     sc_scroll(-1,30,5,60,14);
  94.     sc_setcur(0,15);  sc_eeol();
  95.     sc_puts("Press any key to scroll down 2");
  96.     kb_getc();
  97.     sc_scroll(2,30,5,60,14);
  98.  
  99.     sc_setcur(0,15);  sc_eeol();
  100.     sc_puts("Press any key to continue...");
  101.     kb_getc();
  102.  
  103.     sc_windo(0,0,sc_cols_-1,sc_rows_-1);
  104.     sc_clr();
  105.     sc_color(WHITE,BLUE);
  106.     sc_setcur(0,0);  sc_eeol();
  107.     sc_setcur(0,0);
  108.     sc_puts("Phase 4 - Draw bars of different colors\n\r");
  109.  
  110.     sc_windo(20,3,60,22);
  111.     sc_setcur(0,0);
  112.     for(i=0;i<16; ++i) {
  113.     sc_setcur(0,i+3);
  114.     sc_color(i,i);
  115.     sc_eeol();
  116.     }
  117.  
  118.     sc_color(WHITE,BLUE);
  119.     sc_setcur(0,22);  sc_eeol();
  120.     sc_puts("Press any key to continue...");
  121.     kb_getc();
  122.  
  123.     sc_windo(0,0,sc_cols_-1,sc_rows_-1);
  124.     sc_clr();
  125.     sc_color(BLUE,YELLOW);
  126.     sc_setcur(0,0);  sc_eeol();
  127.     sc_setcur(0,1);  sc_eeol();
  128.     sc_setcur(0,2);  sc_eeol();
  129.     sc_setcur(0,0);
  130.     sc_puts("Phase 5 - Functions tested: sc_getcol(), sc_getrow()\n\r");
  131.     sc_puts("          External  tested: wrapf_\n\r");
  132.     sc_puts("          Foreground = blue, background = yellow\n\r");
  133.     sc_box(24,4,51,13);
  134.     sc_windo(25,5,50,12);
  135.     wrapf_ = FALSE;
  136.     sc_setcur(0,7);
  137.     sc_puts("The wrap flag is now off and the characters will overwrite in last column");
  138.  
  139.     sc_windo(0,0,sc_cols_-1,sc_rows_-1);
  140.     sc_setcur(5,20);
  141.     i = sc_getcol();
  142.     j = sc_getrow();
  143.     printf("Cursor moved to col = 5, row = 20 - sc_getcur() = %d  sc_getrow() = %d",i,j);
  144.  
  145.     sc_color(WHITE,BLUE);
  146.     sc_setcur(0,22);  sc_eeol();
  147.     sc_puts("END OF TEST - Press any key to exit...");
  148.     kb_getc();
  149.     sc_color(WHITE,BLACK);
  150.     sc_clr();
  151. }
  152.