home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / OS2UTIL.ZIP / SM.C < prev    next >
Text File  |  1990-05-21  |  4KB  |  133 lines

  1. #define INCL_SUB
  2. #include <os2def.h>
  3. #include <bsesub.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. int main(int argc, char* *argv);
  8. int rattr(void);
  9.  
  10. main(argc, argv)
  11. int  argc;
  12. char *argv[];
  13. {
  14.     VIOMODEINFO modedata;
  15.     VIOCURSORINFO cursordata;
  16.     int row, col, up;
  17.  
  18.     if (argc != 2) {
  19.        puts("syntax: sm 25 | 43 | 50");
  20.        return(0);
  21.     }
  22.  
  23.     switch(atoi(argv[1])) {
  24.     case 50:
  25.         VioGetCurPos(&row, &col, 0);
  26.         modedata.cb = sizeof( modedata );
  27.         VioGetMode( &modedata, 0 );
  28.         modedata.row = 50;
  29.         VioSetMode( &modedata, 0 );
  30.         cursordata.yStart = 6;
  31.         cursordata.cEnd = 7;
  32.         cursordata.cx = 1;
  33.         cursordata.attr = 0;
  34.         VioSetCurType( &cursordata, 0 );
  35.         VioSetCurPos( row, col, 0 );
  36.     break;
  37.  
  38.     case 43:
  39.         VioGetCurPos(&row, &col, 0);
  40.         modedata.cb = sizeof( modedata );
  41.         VioGetMode( &modedata, 0 );
  42.         modedata.row = 43;
  43.         VioSetMode( &modedata, 0 );
  44.         cursordata.yStart = 6;
  45.         cursordata.cEnd = 7;
  46.         cursordata.cx = 1;
  47.         cursordata.attr = 0;
  48.         VioSetCurType( &cursordata, 0 );
  49.         VioSetCurPos( row, col, 0 );
  50.     break;
  51.  
  52.     case 40:
  53.         modedata.cb = sizeof( modedata );
  54.         VioGetMode( &modedata, 0 );
  55.         up = (modedata.row == 25);
  56.         if (up)
  57.            VioGetCurPos(&row, &col, 0);
  58.         else
  59.         {
  60.            static char  buffer[2] = { 0x20, 0x07 };
  61.                         buffer[1] = (char) rattr();
  62.            VioScrollUp( 0, 0, -1, -1, -1, (char far *)buffer, 0 );
  63.         }
  64.         modedata.row = 40;
  65.         VioSetMode( &modedata, 0 );
  66.         cursordata.yStart = 8;
  67.         cursordata.cEnd = 9;
  68.         cursordata.cx = 1;
  69.         cursordata.attr = 0;
  70.         VioSetCurType( &cursordata, 0 );
  71.         if (up)
  72.            VioSetCurPos( row, col, 0 );
  73.         else
  74.            VioSetCurPos( 0, 0, 0 );
  75.     break;
  76.  
  77.     case 35:
  78.         modedata.cb = sizeof( modedata );
  79.         VioGetMode( &modedata, 0 );
  80.         up = (modedata.row == 25);
  81.         if (up)
  82.            VioGetCurPos(&row, &col, 0);
  83.         else
  84.         {
  85.            static char  buffer[2] = { 0x20, 0x07 };
  86.                         buffer[1] = (char) rattr();
  87.            VioScrollUp( 0, 0, -1, -1, -1, (char far *)buffer, 0 );
  88.         }
  89.         modedata.row = 35;
  90.         VioSetMode( &modedata, 0 );
  91.         cursordata.yStart = 8;
  92.         cursordata.cEnd = 9;
  93.         cursordata.cx = 1;
  94.         cursordata.attr = 0;
  95.         VioSetCurType( &cursordata, 0 );
  96.         if (up)
  97.            VioSetCurPos(row, col, 0);
  98.         else
  99.            VioSetCurPos( 0, 0, 0 );
  100.     break;
  101.  
  102.     case 25: {
  103.         static char  buffer[2] = { 0x20, 0x07 };
  104.                      buffer[1] = (char) rattr();
  105.         VioScrollUp( 0, 0, -1, -1, -1, (char far *)buffer, 0 );
  106.         modedata.cb = sizeof( modedata );
  107.         VioGetMode( &modedata, 0 );
  108.         modedata.row = 25;
  109.         VioSetMode( &modedata, 0 );
  110.         cursordata.yStart = 12;
  111.         cursordata.cEnd = 13;
  112.         cursordata.cx = 1;
  113.         cursordata.attr = 0;
  114.         VioSetCurType( &cursordata, 0 );
  115.         VioSetCurPos( 0, 0, 0 );
  116.     break;    }
  117.     }
  118.     return atoi(argv[1]);
  119. }
  120.  
  121.  
  122. rattr()                     /* read attribute                        */
  123. {                           /* reads foreground and background color */
  124.     char attr[2];
  125.     USHORT cb = sizeof(attr);
  126.     USHORT row, col;
  127.  
  128.     VioGetCurPos(&row, &col, 0);
  129.     VioReadCellStr(attr, &cb, row-1, 0, 0);
  130.     return(attr[1]);
  131. }
  132.  
  133.