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

  1. /*********************
  2.  *
  3.  *  sc_test2.c - screen functions test program.
  4.  *
  5.  *  Purpose: This file contains functions to test the screen
  6.  *           functions. See also sc_test1.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. {
  20.     int   i;
  21.     long  l;
  22.  
  23.     /********************************************
  24.      INITIALIZE AND TELL WHAT'S TESTED
  25.     ********************************************/
  26.     kb_init(NULL,NULL,NULL);
  27.     sc_init(MO_CO80,BLUE,WHITE); /* init screen to: Color              */
  28.                  /*                 80x25              */
  29.                  /*                 foreground = blue  */
  30.                  /*                 background = white */
  31.  
  32.     sc_setcur(0,0);  sc_eeol();
  33.     sc_setcur(28,0);
  34.     sc_puts("Hello from screen test 2");
  35.  
  36.     sc_setcur(0,2);  sc_eeol();
  37.     sc_setcur(0,2);
  38.     sc_puts("Phase 1 - Functions tested: sc_setcur(), sc_movcur(), sc_cursor(), sc_putsv()");
  39.  
  40.     sc_setcur(10,7);
  41.  
  42.     /********************************
  43.      TURN CURSOR OFF AND ON
  44.     ********************************/
  45.     sc_puts("Turn cursor off and on");
  46.     sc_movcur(2,0);
  47.     for (i = 0; i < 4; i++) {
  48.     if ((i%2) == 0) {
  49.         sc_setcur(34,7);
  50.         sc_puts(" [ ] ON ");
  51.         sc_setcur(36,7);
  52.         sc_cursor(1);               /* Turn cursor on     */
  53.     }
  54.     else {
  55.         sc_setcur(34,7);
  56.         sc_puts(" [ ] OFF");
  57.         sc_setcur(36,7);
  58.         sc_cursor(0);               /* Turn cursor off    */
  59.     }
  60.     for (l = 0; l < 30000; l++);    /* Kill a little time   */
  61.     }
  62.     sc_cursor(1);                     /* Turn cursor on again */
  63.  
  64.     sc_setcur(60,7);
  65.     sc_putsv("Vertical chars");
  66.  
  67.     sc_setcur(0,23);
  68.     sc_puts("Press any key to continue...");
  69.     kb_getc();
  70.  
  71.     /**********************************
  72.      CLEAR AND TEST PUT FUNCTIONS
  73.     **********************************/
  74.     sc_clr();
  75.     sc_color(WHITE,BLUE);
  76.     sc_setcur(0,0);  sc_eeol();
  77.     sc_setcur(0,0);
  78.     sc_puts("Phase 2 - Functions tested: sc_putl(), sc_putc() with TABs");
  79.  
  80.     sc_setcur(0,5);
  81.     sc_putl("This is a line with an embedded <CR>\r - ignore it\n");
  82.     sc_setcur(0,7);
  83.     sc_puts("          1         2         3         4         5         6");
  84.     sc_setcur(0,8);
  85.     sc_puts("0123456789012345678901234567890123456789012345678901234567890");
  86.     sc_setcur(0,9);
  87.     sc_puts("This line has 4 embedded TABs\t#1\t#2\t#3\t#4");
  88.  
  89.     sc_setcur(0,23);
  90.     sc_puts("Press any key to continue...");
  91.     kb_getc();
  92.  
  93.     /**************************************
  94.      NOW TEST GETCH AND PRINTF ALIAS
  95.     ***************************************/
  96.     sc_clr();
  97.     sc_color(WHITE,BLUE);
  98.     sc_setcur(0,0);  sc_eeol();
  99.     sc_setcur(0,0);
  100.     sc_puts("Phase 3 - Functions tested: sc_getch(), sc_printf()");
  101.  
  102.     sc_setcur(10,5);
  103.     sc_puts("Test line 1");
  104.     sc_setcur(30,7);
  105.     sc_puts("Test line 2");
  106.  
  107.     sc_setcur(0,9);
  108.     sc_printf("Col Row Char  Hex\n\r--- --- ---- ----\n\r");
  109.     i = sc_getch(11,5);
  110.     sc_printf(" 11   5   %c  [%02x]\n\r", i, i);
  111.     i = sc_getch(20,5);
  112.     sc_printf(" 20   5   %c  [%02x]\n\r", i, i);
  113.     i = sc_getch(33,7);
  114.     sc_printf(" 33   7   %c  [%02x]\n\r", i, i);
  115.     i = sc_getch(40,7);
  116.     sc_printf(" 40   7   %c  [%02x]\n\r", i, i);
  117.  
  118.     sc_setcur(0,23);
  119.     sc_puts("Press any key to continue...");
  120.     kb_getc();
  121.  
  122.     /***************************
  123.      SHOW PUTS OPTIONS
  124.     ****************************/
  125.     sc_clr();
  126.     sc_color(WHITE,BLUE);
  127.     sc_setcur(0,0);  sc_eeol();
  128.     sc_setcur(0,0);
  129.     sc_puts("Phase 4 - Functions tested: sc_puts()");
  130.  
  131.     sc_box(29,4,61,16);
  132.     sc_windo(30,5,60,15);
  133.     sc_setcur(30,15);
  134.     sc_puts("Line of text written using sc_puts() with wrap and scroll ON");
  135.  
  136.     sc_windo(0,0,sc_cols_-1,sc_rows_-1);
  137.     sc_color(WHITE,BLUE);
  138.     sc_setcur(0,22);  sc_eeol();
  139.     sc_puts("END OF TEST - Press any key to exit...");
  140.     sc_color(WHITE,BLACK);
  141.     kb_getc();
  142.     sc_clr();
  143. }
  144.