home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ANSITEST.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  3KB  |  97 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4.  *                                                                     *
  5.  *       ANSITEST.C                                                    *
  6.  *                                                                     *
  7.  *       Demonstration of ANSICODE.H (includes ANSI detection)         *
  8.  *                                                                     *
  9.  *       Donated to the public domain 96-11-12 by                      *
  10.  *       Tom Torfs (tomtorfs@www.dma.be, 2:292/516@fidonet)            *
  11.  *                                                                     *
  12.  *       The ANSI detection in this module is not the usual method,    *
  13.  *       but unlike most of the other methods it allows detection      *
  14.  *       through a serial connection etc. (e.g. BBS software)          *
  15.  *                                                                     *
  16.  *       This module requires DOSGETCH.ASM.                            *
  17.  *                                                                     *
  18.  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  19.  
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <time.h>
  23. #include <dos.h>
  24.  
  25. #include "ansicode.h"
  26. #include "dosgetch.h"
  27.  
  28. int main(void)
  29. {
  30.    int ch;
  31.    int x,y;
  32.    clock_t waitclock;
  33.    
  34.    ANSI_report();
  35.    
  36.    waitclock = clock() + CLK_TCK; /* wait at most 1 second */
  37.    do
  38.       ch = dosgetch();
  39.    while (ch==EOF && clock()<waitclock);
  40.    
  41.    if (ch!=27 || scanf("[%d;%dR",&y,&x)!=2)
  42.    {
  43.       printf("No ANSI screen driver detected.\n");
  44.       return 1;
  45.    }
  46.  
  47.    ANSI_attrcolor(ANSI_WHITE,ANSI_BLUE,ANSI_BOLD);
  48.    ANSI_cls();
  49.    
  50.    ANSI_fgcolor(ANSI_RED);
  51.    printf("Very primitive ANSI screen I/O demonstration\n\n");
  52.  
  53.    ANSI_fgcolor(ANSI_GREEN);
  54.    printf("The cursor position at startup was %d,%d.\n",x,y);
  55.    
  56.    ANSI_fgcolor(ANSI_WHITE);
  57.    ANSI_locate(1,12);
  58.    printf("On a regular screen this should be about the middle.\n");
  59.    
  60.    ANSI_down(2);
  61.  
  62.    printf("And this is a few lines lower.\n");
  63.  
  64.    ANSI_locate(1,25);
  65.    ANSI_attrib(ANSI_BLINK);
  66.    printf("Press any key to continue..."); /* no \n, don't want to scroll */
  67.  
  68.    doswaitkey();
  69.    
  70.    ANSI_videomode(ANSI_640x350x2);
  71.  
  72.    ANSI_attrcolor(ANSI_WHITE,ANSI_BLACK,ANSI_NORMAL);
  73.    ANSI_cls();
  74.  
  75.    printf("You like EGA 640x350x2 graphics mode ?\n\n");
  76.  
  77.    printf("If not, press a key...\n");
  78.    
  79.    doswaitkey();
  80.    
  81.    ANSI_videomode(ANSI_80x25);
  82.    
  83.    ANSI_attrcolor(ANSI_WHITE,ANSI_RED,ANSI_BOLD);
  84.    ANSI_cls();
  85.  
  86.    printf("Aah that's better...\n\n");
  87.    
  88.    printf("Press any key to exit...\n");
  89.    
  90.    doswaitkey();
  91.  
  92.    ANSI_attrcolor(ANSI_WHITE,ANSI_BLACK,ANSI_NORMAL);
  93.    ANSI_cls();
  94.    
  95.    return 0;
  96. }
  97.