home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-ASM_VI.ARJ / PROGC.ZIP / PROGC055.C < prev    next >
Text File  |  1988-04-10  |  2KB  |  46 lines

  1.  
  2. /************************************************************************/
  3. /* Scroll smoothly in 100 column text screen using cursor keys          */
  4. /* Quit on Escape key.                                                  */
  5. /************************************************************************/
  6.  
  7. smooth_text_scroll()
  8.         {
  9.         #define KEY_ESC         0x011B
  10.         #define KEY_UP          0x4800
  11.         #define KEY_DOWN        0x5000
  12.         #define KEY_LEFT        0x4B00
  13.         #define KEY_RIGHT       0x4D00
  14.         #define KEY_ENTER       0x1C0D
  15.  
  16.         int     x = 0, y = 0, i, key;
  17.         set_more_columns(100);  /* Select 100 text column mode          */
  18.         set_cursor_position(0,0);
  19.         for (i = 0; i < 100;i++)/* Fill newly organized text buffer     */
  20.              write_string(i, 0,
  21.              "This is text line in the new 100 column text buffer");
  22.         while((key = get_key()) != KEY_ENTER)
  23.                 switch (key)
  24.                     {
  25.                     case KEY_RIGHT:                     /* Scroll right */
  26.                         x = (x < 799) ? ++x : 799;
  27.                         smooth_scroll(x,y);
  28.                         break;
  29.                     case KEY_LEFT:                      /* Scroll left  */
  30.                         x = ( x > 0) ? --x : 0;
  31.                         smooth_scroll(x, y);
  32.                         break;
  33.                     case KEY_UP:                        /* Scroll up    */
  34.                         y = (y > 0) ? --y : 0;
  35.                         smooth_scroll(x, y);
  36.                         break;
  37.                     case KEY_DOWN:                      /* Scroll down  */
  38.                         y = (y < 1399) ? ++y : 1399;
  39.                         smooth_scroll(x, y);
  40.                         break;
  41.                     default:
  42.                         break;
  43.                     }
  44.         smooth_scroll(0,0);
  45.         }
  46.