home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1988 / 08_09 / scr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-10  |  1.9 KB  |  81 lines

  1. /* ------------------------------------------------- */
  2. /*                   scr.c                           */
  3. /*          setzt Bildschirmattribute                */
  4. /* (c) 1988 by B.Eichinger-Wieschmann & PASCAL Int.  */
  5. /*   erfordert angabe von ANSI.SYS in CONFIG.SYS     */
  6. /* ------------------------------------------------- */
  7.  
  8. #include <stdio.h>
  9. #include <dos.h>
  10.  
  11. void clr( void );
  12. void save( void );
  13. void restore( void );
  14.  
  15. main( int argc, char *argv[] )
  16. {
  17.   if( argc > 1 )
  18.   {
  19.    switch( *(argv[1]+1) )
  20.    {
  21.     case 'c' :
  22.     case 'C' : clr();
  23.                break;
  24.     case 'h' :
  25.     case 'H' : fprintf( stdout,"\033[1m\n");
  26.                break;
  27.     case 'n' :
  28.     case 'N' : fprintf( stdout,"\033[0m\n");
  29.                break;
  30.     case 'i' :
  31.     case 'I' : fprintf( stdout,"\033[7m\n");
  32.                break;
  33.    }
  34.   }
  35. }
  36.  
  37. void clr( void )
  38. {
  39.   save();
  40.   clrscr();
  41.   getch();
  42.   restore();
  43. }
  44.  
  45. static unsigned scrbuf[25 * 80 * 2];
  46.                                  /* Bildschirmpuffer */
  47. union  REGS ri,ro;
  48. static unsigned oldcur;          /* Cursor-Form      */
  49. static unsigned oldpos;          /* Cursorposition   */
  50.  
  51. void save( void )
  52. {
  53.   gettext( 0,0,80,25, scrbuf );
  54.                                /* Bildschirm sichern */
  55.   ri.h.ah = 3;                 /* Cursor holen       */
  56.   ri.h.bh = 0;
  57.   int86(0x10,&ri,&ro);
  58.   oldcur = ro.x.cx;             /* Cursor sichern    */
  59.   oldpos = ro.x.dx;             /* Position sichern  */
  60.  
  61.   ri.h.ah = 1;
  62.   ri.x.cx = 0x2020;             /* Cursor verstecken */
  63.             /* nicht bei jedem Video-Adapter möglich */
  64.   int86(0x10,&ri,&ro);
  65. }
  66.  
  67. void restore( void )
  68. {
  69.   puttext( 0,0,80,25, scrbuf );
  70.                       /* Bildschirm wiederherstellen */
  71.   ri.h.ah = 1;
  72.   ri.x.cx = oldcur;
  73.   int86(0x10,&ri,&ro);        /* alten Cursor setzen */
  74.  
  75.   ri.h.ah = 2;
  76.   ri.h.bh = 0;
  77.   ri.x.dx = oldpos;
  78.   int86(0x10,&ri,&ro);          /* auf alte Position */
  79. }
  80.  
  81.